Compare commits
4 commits
3542231987
...
b430f626c9
| Author | SHA1 | Date | |
|---|---|---|---|
| b430f626c9 | |||
| d205496ff3 | |||
| 33022cdcfa | |||
| 72e0c40a68 |
8 changed files with 19 additions and 14 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,3 +1,4 @@
|
||||||
.cache/
|
.cache/
|
||||||
build/
|
build/
|
||||||
.godot/
|
.godot/
|
||||||
|
demo/bin/libant.so
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ void Channel::_bind_methods() {
|
||||||
Channel::Channel() {
|
Channel::Channel() {
|
||||||
channel_config_.frequency = 57;
|
channel_config_.frequency = 57;
|
||||||
channel_config_.transmission_type = 0;
|
channel_config_.transmission_type = 0;
|
||||||
device_number_ = DeviceNumbers::Wildcard;
|
channel_config_.device_number = DeviceNumbers::Wildcard;
|
||||||
channel_ = 0;
|
channel_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,9 +91,9 @@ protected:
|
||||||
state_ = _state;
|
state_ = _state;
|
||||||
}
|
}
|
||||||
void SetDeviceNumber(const DeviceNumber device_number) {
|
void SetDeviceNumber(const DeviceNumber device_number) {
|
||||||
device_number_ = device_number;
|
channel_config_.device_number = device_number;
|
||||||
}
|
}
|
||||||
DeviceNumber GetDeviceNumber() const { return device_number_; }
|
DeviceNumber GetDeviceNumber() const { return channel_config_.device_number; }
|
||||||
|
|
||||||
void SetChannel(const ChannelNumber channel) { channel_ = channel; }
|
void SetChannel(const ChannelNumber channel) { channel_ = channel; }
|
||||||
ChannelNumber GetChannel() const { return channel_; }
|
ChannelNumber GetChannel() const { return channel_; }
|
||||||
|
|
@ -112,7 +112,6 @@ protected:
|
||||||
|
|
||||||
// PROPERTIES
|
// PROPERTIES
|
||||||
ChannelNumber channel_;
|
ChannelNumber channel_;
|
||||||
DeviceNumber device_number_;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Initialize();
|
void Initialize();
|
||||||
|
|
|
||||||
|
|
@ -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(
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
|
|
@ -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));
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in a new issue