From 72e0c40a680dfa6e55e451a64316dfab040c1b20 Mon Sep 17 00:00:00 2001 From: Thies Lennart Alff Date: Thu, 10 Apr 2025 11:42:31 +0200 Subject: [PATCH] removed some magic numbers --- ant/src/ant/ant.hpp | 5 +++++ .../ant/channel/fitness_equipment_channel.cpp | 2 +- ant/src/ant/channel/heart_rate_channel.cpp | 2 +- ant/src/ant/channel/power_channel.cpp | 16 ++++++++-------- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ant/src/ant/ant.hpp b/ant/src/ant/ant.hpp index 56d6465..eec7c26 100644 --- a/ant/src/ant/ant.hpp +++ b/ant/src/ant/ant.hpp @@ -92,6 +92,11 @@ struct DeviceNumbers { }; }; typedef uint16_t ChannelPeriod; +namespace ChannelPeriods { + static constexpr ChannelPeriod kBicyclePower = 8182; + static constexpr ChannelPeriod kHeartRate = 8070; + static constexpr ChannelPeriod kFitnessEquipment = 8192; +} static constexpr DeviceNumber DeviceNumberWildcard = 0x00; diff --git a/ant/src/ant/channel/fitness_equipment_channel.cpp b/ant/src/ant/channel/fitness_equipment_channel.cpp index 9578709..9cff138 100644 --- a/ant/src/ant/channel/fitness_equipment_channel.cpp +++ b/ant/src/ant/channel/fitness_equipment_channel.cpp @@ -22,7 +22,7 @@ FitnessEquipmentChannel::FitnessEquipmentChannel() { channel_config_.type = ChannelTypes::kRX; channel_config_.transmission_type = 0; channel_config_.device_type = DeviceTypes::kFitnessEquipment; - channel_config_.channel_period = 8192; + channel_config_.channel_period = ChannelPeriods::kFitnessEquipment; } void FitnessEquipmentChannel::OnBroadcastData( diff --git a/ant/src/ant/channel/heart_rate_channel.cpp b/ant/src/ant/channel/heart_rate_channel.cpp index 02e8988..d18ec85 100644 --- a/ant/src/ant/channel/heart_rate_channel.cpp +++ b/ant/src/ant/channel/heart_rate_channel.cpp @@ -12,7 +12,7 @@ HeartRateChannel::HeartRateChannel() { channel_config_.type = ChannelTypes::kRX; channel_config_.transmission_type = 0; channel_config_.device_type = DeviceTypes::kHeartRate; - channel_config_.channel_period = 8070; + channel_config_.channel_period = ChannelPeriods::kHeartRate; } void HeartRateChannel::OnBroadcastData(godot::Ref data) { if (state_ != ChannelState::kConnected) { diff --git a/ant/src/ant/channel/power_channel.cpp b/ant/src/ant/channel/power_channel.cpp index 55c86e1..8300808 100644 --- a/ant/src/ant/channel/power_channel.cpp +++ b/ant/src/ant/channel/power_channel.cpp @@ -23,7 +23,7 @@ PowerChannel::PowerChannel() { channel_config_.frequency = 57; channel_config_.transmission_type = 0; channel_config_.device_type = DeviceTypes::kPower; - channel_config_.channel_period = 8182; + channel_config_.channel_period = ChannelPeriods::kBicyclePower; } void PowerChannel::OnBroadcastData(godot::Ref data) { @@ -33,12 +33,12 @@ void PowerChannel::OnBroadcastData(godot::Ref data) { SetChannelState(ChannelState::kConnected); msg::common::RequestChannelID msg(channel_); SendBuffered(msg); - // bicycle_power::AdvancedCapabilities2 caps2; - // caps2.EnableAllDynamics(); - // caps2.UnmaskAllDynamics(); - // caps2.Enable8Hz(); - // caps2.Unmask8Hz(); - // SetAdvancedCapabilities2(caps2); + bicycle_power::AdvancedCapabilities2 caps2; + caps2.EnableAllDynamics(); + caps2.UnmaskAllDynamics(); + caps2.Enable8Hz(); + caps2.Unmask8Hz(); + SetAdvancedCapabilities2(caps2); // bicycle_power::AdvancedCapabilities caps; // RequestAdvancedCapabilities2(); // RequestAdvancedCapabilities1(); @@ -47,7 +47,7 @@ void PowerChannel::OnBroadcastData(godot::Ref data) { // SetAdvancedCapabilities(caps); } uint8_t page_number = data->raw_data[0]; - //printf("[channel %hu] received page: %hu\n", channel_, page_number); + // printf("[channel %hu] received page: %hu\n", channel_, page_number); switch (page_number) { case PowerProfilePages::kBattery: { BatteryStatusMessage msg(BatteryStatusMessage::FromPayload(data->raw_data));