removed some magic numbers

This commit is contained in:
Thies Lennart Alff 2025-04-10 11:42:31 +02:00
parent 3542231987
commit 72e0c40a68
Signed by: lennartalff
GPG key ID: 4EC67D34D594104D
4 changed files with 15 additions and 10 deletions

View file

@ -92,6 +92,11 @@ struct DeviceNumbers {
}; };
}; };
typedef uint16_t ChannelPeriod; 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; static constexpr DeviceNumber DeviceNumberWildcard = 0x00;

View file

@ -22,7 +22,7 @@ FitnessEquipmentChannel::FitnessEquipmentChannel() {
channel_config_.type = ChannelTypes::kRX; channel_config_.type = ChannelTypes::kRX;
channel_config_.transmission_type = 0; channel_config_.transmission_type = 0;
channel_config_.device_type = DeviceTypes::kFitnessEquipment; channel_config_.device_type = DeviceTypes::kFitnessEquipment;
channel_config_.channel_period = 8192; channel_config_.channel_period = ChannelPeriods::kFitnessEquipment;
} }
void FitnessEquipmentChannel::OnBroadcastData( void FitnessEquipmentChannel::OnBroadcastData(

View file

@ -12,7 +12,7 @@ HeartRateChannel::HeartRateChannel() {
channel_config_.type = ChannelTypes::kRX; channel_config_.type = ChannelTypes::kRX;
channel_config_.transmission_type = 0; channel_config_.transmission_type = 0;
channel_config_.device_type = DeviceTypes::kHeartRate; channel_config_.device_type = DeviceTypes::kHeartRate;
channel_config_.channel_period = 8070; channel_config_.channel_period = ChannelPeriods::kHeartRate;
} }
void HeartRateChannel::OnBroadcastData(godot::Ref<BroadcastPayload> data) { void HeartRateChannel::OnBroadcastData(godot::Ref<BroadcastPayload> data) {
if (state_ != ChannelState::kConnected) { if (state_ != ChannelState::kConnected) {

View file

@ -23,7 +23,7 @@ PowerChannel::PowerChannel() {
channel_config_.frequency = 57; channel_config_.frequency = 57;
channel_config_.transmission_type = 0; channel_config_.transmission_type = 0;
channel_config_.device_type = DeviceTypes::kPower; channel_config_.device_type = DeviceTypes::kPower;
channel_config_.channel_period = 8182; channel_config_.channel_period = ChannelPeriods::kBicyclePower;
} }
void PowerChannel::OnBroadcastData(godot::Ref<BroadcastPayload> data) { void PowerChannel::OnBroadcastData(godot::Ref<BroadcastPayload> data) {
@ -33,12 +33,12 @@ void PowerChannel::OnBroadcastData(godot::Ref<BroadcastPayload> data) {
SetChannelState(ChannelState::kConnected); SetChannelState(ChannelState::kConnected);
msg::common::RequestChannelID msg(channel_); msg::common::RequestChannelID msg(channel_);
SendBuffered(msg); SendBuffered(msg);
// bicycle_power::AdvancedCapabilities2 caps2; bicycle_power::AdvancedCapabilities2 caps2;
// caps2.EnableAllDynamics(); caps2.EnableAllDynamics();
// caps2.UnmaskAllDynamics(); caps2.UnmaskAllDynamics();
// caps2.Enable8Hz(); caps2.Enable8Hz();
// caps2.Unmask8Hz(); caps2.Unmask8Hz();
// SetAdvancedCapabilities2(caps2); SetAdvancedCapabilities2(caps2);
// bicycle_power::AdvancedCapabilities caps; // bicycle_power::AdvancedCapabilities caps;
// RequestAdvancedCapabilities2(); // RequestAdvancedCapabilities2();
// RequestAdvancedCapabilities1(); // RequestAdvancedCapabilities1();
@ -47,7 +47,7 @@ void PowerChannel::OnBroadcastData(godot::Ref<BroadcastPayload> data) {
// SetAdvancedCapabilities(caps); // SetAdvancedCapabilities(caps);
} }
uint8_t page_number = data->raw_data[0]; 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) { switch (page_number) {
case PowerProfilePages::kBattery: { case PowerProfilePages::kBattery: {
BatteryStatusMessage msg(BatteryStatusMessage::FromPayload(data->raw_data)); BatteryStatusMessage msg(BatteryStatusMessage::FromPayload(data->raw_data));