diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9996e74..a79fd0d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,13 +14,18 @@ jobs: strategy: matrix: example: [ + examples/BicyclePowerDisplay/BicyclePowerDisplay.ino, + examples/BicyclePowerSensor/BicyclePowerSensor.ino, examples/BicycleSpeedDisplay/BicycleSpeedDisplay.ino, examples/DeviceSearch/DeviceSearch.ino, examples/DynamicProfiles/DynamicProfiles.ino, examples/EnvironmentDisplay/EnvironmentDisplay.ino, + examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino, examples/HeartRateDisplay/HeartRateDisplay.ino, examples/HeartRateMonitor/HeartRateMonitor.ino, - examples/LEVDisplay/LEVDisplay.ino] + examples/LEVDisplay/LEVDisplay.ino, + examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino, + examples/ShiftingShifter/ShiftingShifter.ino] # Steps represent a sequence of tasks that will be executed as part of the job steps: @@ -83,6 +88,9 @@ jobs: python -m pip install --upgrade pip pip install --upgrade platformio + - name: Install platform + run: pio platform install native + - name: Install library dependencies run: pio lib -g install ANT diff --git a/.gitignore b/.gitignore index 068fc6d..fe969e2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,10 +2,13 @@ .piolibdeps .ycm* *.swp +*.DS_Store # used for testing src/main.cpp + .DS_Store .tags* tags .pio +*-e diff --git a/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino new file mode 100644 index 0000000..c81a466 --- /dev/null +++ b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino @@ -0,0 +1,281 @@ +/*********************************** + * AntPlus Bicycle Power Display example + * + * Finds a nearby Bike Power Sensor, pairs + * to it and then reads the information + * out via the serial port. + * + * Example built for ESP32 + * Note: HardwareSerial required for this controller + * + * Author Andrew Hillier +* based on the work of Curtis Malainey + ************************************/ +#include +#include "ANT.h" +#include "ANTPLUS.h" +#include + +#define BAUD_RATE 9600 +#define CHANNEL_0 0 +#define antSerial Serial2 + +const uint8_t NETWORK_KEY[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}; // get this from thisisant.com + +// ************************************* +// Specific to test ANT+ chip and ESP32 setup +const int RTS_PIN = 23; +const int SUSPEND_PIN = 22; +const int SLEEP_PIN = 19; +const int RESET_PIN = 2; + +// ************************************* + +ArduinoSerialAntWithCallbacks ant; +AntPlusRouter router; +ProfileBicyclePowerDisplay bikePower; + +void bicyclePowerBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data); +void batteryStatusDataPageHandler(BatteryStatus& msg, uintptr_t data); +void manufacturerIDDataPageHandler(ManufacturersInformation& msg, uintptr_t data); +void productIDDataPageHandler(ProductInformation& msg, uintptr_t data); +void powerOnlyDataPageHandler(BicyclePowerStandardPowerOnly& msg, uintptr_t data); +void crankTorqueDataPageHandler(BicyclePowerStandardCrankTorque& msg, uintptr_t data); +void wheelTorqueDataPageHandler(BicyclePowerStandardWheelTorque& msg, uintptr_t data); +void pedalSmoothnessDataPageHandler(BicyclePowerTorqueEffectivenessAndPedalSmoothness& msg, uintptr_t data); +void crankTorqueFrequencyDataPageHandler(BicyclePowerCrankTorqueFrequency& msg, uintptr_t data); + +void bicyclePowerBatteryStatus(uint8_t flags); +void printStatus(uint8_t status); + +void setup() { + +// Powering on the ANT+ chip +// ************************************* + + pinMode(SUSPEND_PIN, OUTPUT); + pinMode(SLEEP_PIN, OUTPUT); + pinMode(RESET_PIN, OUTPUT); + pinMode(RTS_PIN, INPUT); + + digitalWrite(RESET_PIN, HIGH); + digitalWrite(SUSPEND_PIN, HIGH); + digitalWrite(SLEEP_PIN, LOW); + + +// ************************************* + + antSerial.begin(BAUD_RATE); + ant.setSerial(antSerial); + delay(5000); + + router.setDriver(&ant); // never touch ant again + router.setAntPlusNetworkKey(NETWORK_KEY); + router.setProfile(CHANNEL_0, &bikePower); + // Delay after initial setup to wait for user to connect on serial + + Serial.begin(BAUD_RATE); + Serial.println("Running"); + bikePower.onDataPage(bicyclePowerBaseDataPageHandler); + bikePower.onBatteryStatus(batteryStatusDataPageHandler); + bikePower.onManufacturersInformation(manufacturerIDDataPageHandler); + bikePower.onProductInformation(productIDDataPageHandler); + bikePower.onBicyclePowerStandardPowerOnly(powerOnlyDataPageHandler); + bikePower.onBicyclePowerStandardCrankTorque(crankTorqueDataPageHandler); + bikePower.onBicyclePowerStandardWheelTorque(wheelTorqueDataPageHandler); + bikePower.onBicyclePowerTorqueEffectivenessAndPedalSmoothness(pedalSmoothnessDataPageHandler); + bikePower.onBicyclePowerCrankTorqueFrequency(crankTorqueFrequencyDataPageHandler); + bikePower.begin(); + // wait for pair to complete + uint8_t status = bikePower.waitForPair(); + // print channel status + Serial.println("==========================="); + printStatus(status); + Serial.print("Device Number: "); + Serial.println(bikePower.getDeviceNumber()); + Serial.print("Transmisison Type: "); + Serial.println(bikePower.getTransmissionType()); +} + +void loop() { + router.loop(); +} + +void printOrInvalid(uint8_t value, uint8_t invalidValue) { + if (value == invalidValue) { + Serial.println("Invalid"); + } else { + Serial.println(value); + } +} + +void crankTorqueFrequencyDataPageHandler(BicyclePowerCrankTorqueFrequency& msg, uintptr_t data) { + Serial.print("Slope: "); + Serial.println(msg.getSlope()); + Serial.print("Timestamp: "); + Serial.println(msg.getTimeStamp()); + Serial.print("Torque Ticks Stamp: "); + Serial.println(msg.getTorqueTicksStamp()); +} + +void batteryStatusDataPageHandler(BatteryStatus& msg, uintptr_t data) { + Serial.print("Number of Batteries: "); + Serial.println(msg.getNumberOfBatteries()); + Serial.print("Battery Identifier: "); + Serial.println(msg.getBatteryIdentifier()); + Serial.print("Cumulative Operating Time: "); + Serial.println(msg.getCumulativeOperatingTime()); + Serial.print("Fractional Battery Voltage: "); + Serial.println(msg.getFractionalBatteryVoltage()); + Serial.print("Coarse Battery Voltage: "); + Serial.println(msg.getCoarseBatteryVoltage()); + Serial.print("Battery Status: "); + bicyclePowerBatteryStatus(msg.getBatteryStatus()); + Serial.print("Cumulative Operating Time Resolution: "); + Serial.println(msg.getCumulativeOperatingTimeResolution()); +} + +void manufacturerIDDataPageHandler(ManufacturersInformation& msg, uintptr_t data) { + Serial.print("Hardware ID: "); + Serial.println(msg.getHWRevision()); + Serial.print("Manufacturer ID: "); + Serial.println(msg.getManufacturerID()); + Serial.print("Model Number: "); + Serial.println(msg.getModelNumber()); +} + +void productIDDataPageHandler(ProductInformation& msg, uintptr_t data) { + Serial.print("Software Version Supplemental: "); + Serial.println(msg.getSWRevisionSupplemental()); + Serial.print("Software Version: "); + Serial.println(msg.getSWRevisionMain()); + Serial.print("Serial Number: "); + Serial.println(msg.getSerialNumber()); +} + +void bicyclePowerBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data) { + BicyclePowerBaseMainDataPage dp = BicyclePowerBaseMainDataPage(msg); + Serial.println("==========================="); + Serial.print("DataPage: "); + Serial.println(dp.getDataPageNumber()); + if (dp.getDataPageNumber() >= ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER) { + return; + } + Serial.print("Update Event Count: "); + Serial.println(dp.getUpdateEventCount()); +} + +void powerOnlyDataPageHandler(BicyclePowerStandardPowerOnly& msg, uintptr_t data) { + Serial.print("Pedal Power: "); + if (msg.getPedalPower() == ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_PEDALPOWER_NOTUSED && + msg.getPedalDifferentiation()) { + Serial.println("Not Used"); + } else { + Serial.println(msg.getPedalPower()); + Serial.print(" From Pedal: "); + if (msg.getPedalDifferentiation() == ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_PEDALDIFFERENTIATION_RIGHT) { + Serial.println("Right"); + } else { + Serial.println("Unknown"); + } + } + Serial.print("Instantaneous Cadence: "); + if (msg.getInstantaneousCadence() == ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_INSTANTANEOUSCADENCE_INVALID) { + Serial.println("Invalid"); + } else { + Serial.println(msg.getInstantaneousCadence()); + } + Serial.print("Accumulated Power: "); + Serial.println(msg.getAccumulatedPower()); + Serial.print("Instantaneous Power: "); + Serial.println(msg.getInstantaneousPower()); +} + +void crankTorqueDataPageHandler(BicyclePowerStandardCrankTorque& msg, uintptr_t data) { + Serial.print("Crank Ticks: "); + Serial.println(msg.getCrankTicks()); + Serial.print("Instantaneous Cadence: "); + printOrInvalid(msg.getInstantaneousCadence(), + ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDCRANKTORQUE_INSTANTANEOUSCADENCE_INVALID); + Serial.print("Crank Period: "); + Serial.println(msg.getCrankPeriod()); + Serial.print("Accumulated Torque: "); + Serial.println(msg.getAccumulatedTorque()); +} + +void wheelTorqueDataPageHandler(BicyclePowerStandardWheelTorque& msg, uintptr_t data) { + Serial.print("Wheel Ticks: "); + Serial.println(msg.getWheelTicks()); + Serial.print("Instantaneous Cadence: "); + printOrInvalid(msg.getInstantaneousCadence(), + ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDWHEELTORQUE_INSTANTANEOUSCADENCE_INVALID); + Serial.print("Wheel Period: "); + Serial.println(msg.getWheelPeriod()); + Serial.print("Accumulated Torque: "); + Serial.println(msg.getAccumulatedTorque()); +} + +void pedalSmoothnessDataPageHandler(BicyclePowerTorqueEffectivenessAndPedalSmoothness& msg, uintptr_t data) { + Serial.print("Left Torque Effectiveness: "); + printOrInvalid(msg.getLeftTorqueEffectiveness(), + ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_TORQUEEFFECTIVENESS_INVALID); + Serial.print("Right Torque Effectiveness: "); + printOrInvalid(msg.getRightTorqueEffectiveness(), + ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_TORQUEEFFECTIVENESS_INVALID); + if (msg.getRightPedalSmoothness() == ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_RIGHTPEDALSMOOTHNESS_COMBINED) { + Serial.print("Combined Pedal Smoothness: "); + printOrInvalid(msg.getLeftPedalSmoothness(), + ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_PEDALSMOOTHNESS_INVALID); + } else { + Serial.print("Left Pedal Smoothness: "); + printOrInvalid(msg.getLeftPedalSmoothness(), + ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_PEDALSMOOTHNESS_INVALID); + Serial.print("Right Pedal Smoothness: "); + printOrInvalid(msg.getRightPedalSmoothness(), + ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_PEDALSMOOTHNESS_INVALID); + } +} + +void printStatus(uint8_t status) { + Serial.print("Channel Status: "); + switch (status) { + case CHANNEL_STATUS_UNASSIGNED: + Serial.println("Unassigned"); + break; + case CHANNEL_STATUS_ASSIGNED: + Serial.println("Assigned"); + break; + case CHANNEL_STATUS_SEARCHING: + Serial.println("Searching"); + break; + case CHANNEL_STATUS_TRACKING: + Serial.println("Tracking"); + break; + } +} + +void bicyclePowerBatteryStatus(uint8_t flags) { + switch (flags) { + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_NEW: + Serial.println("New"); + break; + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_GOOD: + Serial.println("Good"); + break; + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_OK: + Serial.println("Ok"); + break; + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_LOW: + Serial.println("Low"); + break; + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_CRITICAL: + Serial.println("Critical"); + break; + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_INVALID: + Serial.println("Invalid"); + break; + default: + Serial.println("Reserved/Unknown"); + break; + } +} diff --git a/examples/BicyclePowerSensor/BicyclePowerSensor.ino b/examples/BicyclePowerSensor/BicyclePowerSensor.ino new file mode 100644 index 0000000..9f8f103 --- /dev/null +++ b/examples/BicyclePowerSensor/BicyclePowerSensor.ino @@ -0,0 +1,134 @@ +/*********************************** + * AntPlus Bicycle Power Sensor example + * + * Creates a Bike Power Sensor, in + * Crank Torque mode and transmits + * openly with mocked data + * + * Example built for external radio + * + * Author Curtis Malainey + ************************************/ +#include +#include "ANT.h" +#include "ANTPLUS.h" + +#define BAUD_RATE 9600 +#define CHANNEL_0 0 +#define antSerial Serial2 + +const uint8_t NETWORK_KEY[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}; // get this from thisisant.com + +// ************************************* +// Specific to test ANT+ chip and ESP32 setup +const int RTS_PIN = 23; +const int SUSPEND_PIN = 22; +const int SLEEP_PIN = 19; +const int RESET_PIN = 2; + +// ************************************* + +ArduinoSerialAntWithCallbacks ant; +AntPlusRouter router; +ProfileBicyclePowerSensor bikePower(123, 0, ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUECRANK); + +void batteryStatusDataPageHandler(BatteryStatusMsg& msg, uintptr_t data); +void manufacturerIDDataPageHandler(ManufacturersInformationMsg& msg, uintptr_t data); +void productIDDataPageHandler(ProductInformationMsg& msg, uintptr_t data); +void powerOnlyDataPageHandler(BicyclePowerStandardPowerOnlyMsg& msg, uintptr_t data); +void crankTorqueDataPageHandler(BicyclePowerStandardCrankTorqueMsg& msg, uintptr_t data); +void wheelTorqueDataPageHandler(BicyclePowerStandardWheelTorqueMsg& msg, uintptr_t data); +void pedalSmoothnessDataPageHandler(BicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg& msg, uintptr_t data); + +void setup() { + + // Powering on the ANT+ chip + // ************************************* + + pinMode(SUSPEND_PIN, OUTPUT); + pinMode(SLEEP_PIN, OUTPUT); + pinMode(RESET_PIN, OUTPUT); + pinMode(RTS_PIN, INPUT); + + digitalWrite(RESET_PIN, HIGH); + digitalWrite(SUSPEND_PIN, HIGH); + digitalWrite(SLEEP_PIN, LOW); + + + // ************************************* + + antSerial.begin(BAUD_RATE); + ant.setSerial(antSerial); + delay(5000); + + router.setDriver(&ant); // never touch ant again + router.setAntPlusNetworkKey(NETWORK_KEY); + router.setProfile(CHANNEL_0, &bikePower); + // Delay after initial setup to wait for user to connect on serial + + Serial.begin(BAUD_RATE); + Serial.println("Running"); + /// bikePower.createBatteryStatusMsg(batteryStatusDataPageHandler); + bikePower.createManufacturersInformationMsg(manufacturerIDDataPageHandler); + bikePower.createProductInformationMsg(productIDDataPageHandler); + bikePower.createBicyclePowerStandardPowerOnlyMsg(powerOnlyDataPageHandler); + bikePower.createBicyclePowerStandardCrankTorqueMsg(crankTorqueDataPageHandler); + // bikePower.createBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg(pedalSmoothnessDataPageHandler); + Serial.println("==========================="); + bikePower.begin(); +} + +void loop() { + // call this frequently + router.loop(); +} + +void printDpMsg(int dp, const char* s) { + Serial.print("Sending DataPage: "); + Serial.print(dp); + Serial.print(" - "); + Serial.println(s); +} + +/* Optional */ +// void batteryStatusDataPageHandler(BatteryStatusMsg& msg, uintptr_t data) { +// printDpMsg(82, "Battery Status"); +// } + +void manufacturerIDDataPageHandler(ManufacturersInformationMsg& msg, uintptr_t data) { + printDpMsg(80, "Manufacturers Information"); + msg.setHWRevision(1); + msg.setManufacturerId(456); + msg.setModelNumber(789); +} + +void productIDDataPageHandler(ProductInformationMsg& msg, uintptr_t data) { + printDpMsg(81, "Product Information"); + msg.setSWRevisionSupplemental(12); + msg.setSWRevisionMain(34); + msg.setSerialNumber(0xDEADBEEF); +} + +void powerOnlyDataPageHandler(BicyclePowerStandardPowerOnlyMsg& msg, uintptr_t data) { + static uint8_t eventCount = 0; + + printDpMsg(16, "Power Only"); + msg.setUpdateEventCount(eventCount++); + msg.setAccumulatedPower(eventCount * 3); + msg.setInstantaneousPower(eventCount * 2); +} + +void crankTorqueDataPageHandler(BicyclePowerStandardCrankTorqueMsg& msg, uintptr_t data) { + static uint8_t ticks = 0; + + printDpMsg(18, "Crank Torque"); + msg.setCrankTicks(ticks++); + msg.setInstantaneousCadence(ticks / 2); + msg.setCrankPeriod(ticks * 2); + msg.setAccumulatedTorque(ticks * 3); +} + +/* Optional */ +// void pedalSmoothnessDataPageHandler(BicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg& msg, uintptr_t data) { +// printDpMsg(19, "Torque Effectiveness and Pedal Smoothness"); +// } diff --git a/examples/BicycleSpeedDisplay/BicycleSpeedDisplay.ino b/examples/BicycleSpeedDisplay/BicycleSpeedDisplay.ino index ee4efc0..629a6fa 100644 --- a/examples/BicycleSpeedDisplay/BicycleSpeedDisplay.ino +++ b/examples/BicycleSpeedDisplay/BicycleSpeedDisplay.ino @@ -144,22 +144,22 @@ void bicycleSpeedFlags(uint8_t flags) { void bicycleSpeedBatteryStatus(uint8_t flags) { switch (flags) { - case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_NEW: + case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_NEW: Serial.println("New"); break; - case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_GOOD: + case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_GOOD: Serial.println("Good"); break; - case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_OK: + case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_OK: Serial.println("Ok"); break; - case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_LOW: + case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_LOW: Serial.println("Low"); break; - case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_CRITICAL: + case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_CRITICAL: Serial.println("Critical"); break; - case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_INVALID: + case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_INVALID: Serial.println("Invalid"); break; default: diff --git a/examples/DeviceSearch/DeviceSearch.ino b/examples/DeviceSearch/DeviceSearch.ino index c216db3..276bef0 100644 --- a/examples/DeviceSearch/DeviceSearch.ino +++ b/examples/DeviceSearch/DeviceSearch.ino @@ -62,9 +62,30 @@ void searchCallback(uint16_t deviceNumber, uint8_t deviceType, uint8_t transmiss Serial.print(deviceNumber); Serial.print(" Device Type: "); switch (deviceType) { + case ANTPLUS_BICYCLEPOWER_DEVICETYPE: + Serial.println("Bicycle Power"); + break; + case ANTPLUS_BICYCLESPEED_DEVICETYPE: + Serial.println("Bicycle Speed"); + break; + case ANTPLUS_ENVIRONMENT_DEVICETYPE: + Serial.println("Environment"); + break; + case ANTPLUS_FEC_REALTIMECHANNEL_DEVICETYPE: + Serial.println("Realtime Fitness Equiment"); + break; case ANTPLUS_HEARTRATE_DEVICETYPE: Serial.println("Heart Rate"); break; + case ANTPLUS_LEV_DEVICETYPE: + Serial.println("Light Electric Vehicle"); + break; + case ANTPLUS_MUSCLEOXYGEN_DEVICETYPE: + Serial.println("Muscle Oxygen"); + break; + case ANTPLUS_SHIFTING_DEVICETYPE: + Serial.println("Shifting"); + break; default: Serial.println("Unknown"); break; diff --git a/examples/DynamicProfiles/DynamicProfiles.ino b/examples/DynamicProfiles/DynamicProfiles.ino index 9d3bbc9..462e79f 100644 --- a/examples/DynamicProfiles/DynamicProfiles.ino +++ b/examples/DynamicProfiles/DynamicProfiles.ino @@ -293,22 +293,22 @@ void bicycleSpeedFlags(uint8_t flags) { void bicycleSpeedBatteryStatus(uint8_t flags) { switch (flags) { - case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_NEW: + case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_NEW: Serial.println("New"); break; - case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_GOOD: + case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_GOOD: Serial.println("Good"); break; - case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_OK: + case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_OK: Serial.println("Ok"); break; - case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_LOW: + case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_LOW: Serial.println("Low"); break; - case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_CRITICAL: + case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_CRITICAL: Serial.println("Critical"); break; - case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_INVALID: + case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_INVALID: Serial.println("Invalid"); break; default: diff --git a/examples/EnvironmentDisplay/EnvironmentDisplay.ino b/examples/EnvironmentDisplay/EnvironmentDisplay.ino index d581c9f..5d68af2 100644 --- a/examples/EnvironmentDisplay/EnvironmentDisplay.ino +++ b/examples/EnvironmentDisplay/EnvironmentDisplay.ino @@ -20,6 +20,7 @@ ArduinoSerialAntWithCallbacks ant; AntPlusRouter router; ProfileEnvironmentDisplay env; +void environmentBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data); void generalInformationDataPageHandler(EnvironmentGeneralInformation& msg, uintptr_t data); void temperatureDataPageHandler(EnvironmentTemperature& msg, uintptr_t data); void manufacturersInformationDataPageHandler(ManufacturersInformation& msg, uintptr_t data); @@ -39,6 +40,7 @@ void setup() { Serial.begin(BAUD_RATE); Serial.println("Running"); + env.onDataPage(environmentBaseDataPageHandler); env.onEnvironmentGeneralInformation(generalInformationDataPageHandler); env.onEnvironmentTemperature(temperatureDataPageHandler); env.onManufacturersInformation(manufacturersInformationDataPageHandler); @@ -59,10 +61,14 @@ void loop() { router.loop(); } -void generalInformationDataPageHandler(EnvironmentGeneralInformation& msg, uintptr_t data) { +void environmentBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data) { + EnvironmentBaseDataPage ebd(msg); Serial.println("==========================="); Serial.print("DataPage: "); - Serial.println(msg.getDataPageNumber()); + Serial.println(ebd.getDataPageNumber()); +} + +void generalInformationDataPageHandler(EnvironmentGeneralInformation& msg, uintptr_t data) { Serial.print("Local Time: "); Serial.println(msg.getTransmissionInfoLocalTime()); Serial.print("UTC Time: "); @@ -85,9 +91,6 @@ void generalInformationDataPageHandler(EnvironmentGeneralInformation& msg, uintp } void temperatureDataPageHandler(EnvironmentTemperature& msg, uintptr_t data) { - Serial.println("==========================="); - Serial.print("DataPage: "); - Serial.println(msg.getDataPageNumber()); Serial.print("Event Count: "); Serial.println(msg.getEventCount()); Serial.print("24h Low (C): "); @@ -99,9 +102,6 @@ void temperatureDataPageHandler(EnvironmentTemperature& msg, uintptr_t data) { } void manufacturersInformationDataPageHandler(ManufacturersInformation& msg, uintptr_t data) { - Serial.println("==========================="); - Serial.print("DataPage: "); - Serial.println(msg.getDataPageNumber()); Serial.print("HW Revision: "); Serial.println(msg.getHWRevision()); Serial.print("ManufacturerID: "); @@ -111,9 +111,6 @@ void manufacturersInformationDataPageHandler(ManufacturersInformation& msg, uint } void productInformationDataPageHandler(ProductInformation& msg, uintptr_t data) { - Serial.println("==========================="); - Serial.print("DataPage: "); - Serial.println(msg.getDataPageNumber()); Serial.print("SW Revision Supplemental: "); Serial.println(msg.getSWRevisionSupplemental()); Serial.print("SW Revision Main: "); diff --git a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino new file mode 100644 index 0000000..132c361 --- /dev/null +++ b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino @@ -0,0 +1,357 @@ +/*********************************** + * AntPlus Native Drive Fe-c Display + * + * Finds a nearby Indoor bike trainer + * And display content sent by it + * + * Author Charles-Antoine FOURNEL + * Updated by Curtis Malainey + ************************************/ +#include +#include "ANT.h" +#include "ANTPLUS.h" +#define BAUD_RATE 9600 +#define CHANNEL_0 0 + +const uint8_t NETWORK_KEY[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}; // get this from thisisant.com + +ArduinoSerialAntWithCallbacks ant; +AntPlusRouter router; +ProfileFecDisplay fec; + +void fecBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data); +void manufacturerInformationDataPageHandler(ManufacturersInformation& msg, uintptr_t data); +void productInformationDataPageHandler(ProductInformation& msg, uintptr_t data); +void GeneralDataPageHandler(FecGeneralFeData& msg, uintptr_t data); +void GeneralSettingsDataPageHandler(FecGeneralSettingsPage& msg, uintptr_t data); +void SpecificTrainerDataPageHandler(FecSpecificTrainerData& msg, uintptr_t data); +void FeCapabitiliesDataPageHandler(FecFeCapabilities& msg, uintptr_t data); + +unsigned long previousMillis = 0; +const unsigned long interval = 4000; +int TargetPower = 50; +void fecRateFeatures(uint8_t bitfield); +void printStatus(uint8_t status); + +void setup() { + delay(2000); + Serial1.begin(BAUD_RATE); + ant.begin(Serial1); + delay(5000); + + router.setDriver(&ant); // never touch ant again + router.setAntPlusNetworkKey(NETWORK_KEY); + router.setProfile(CHANNEL_0, &fec); + // Delay after initial setup to wait for user to connect on serial + + Serial.begin(BAUD_RATE); + Serial.println("Running"); + fec.onDataPage(fecBaseDataPageHandler); + fec.onManufacturersInformation(manufacturerInformationDataPageHandler); + fec.onProductInformation(productInformationDataPageHandler); + fec.onFecGeneralFeData(GeneralDataPageHandler); + fec.onFecGeneralSettingsPage(GeneralSettingsDataPageHandler); + fec.onFecTrainerData(SpecificTrainerDataPageHandler); + fec.onFecFeCapabilities(FeCapabitiliesDataPageHandler); + + fec.begin(); + // wait for pair to complete + uint8_t status = fec.waitForPair(); + // print channel status + Serial.println("==========================="); + printStatus(status); + Serial.print("Device Number: "); + Serial.println(fec.getDeviceNumber()); + Serial.print("Transmisison Type: "); + Serial.println(fec.getTransmissionType()); + Serial.print("settings user information"); + FecUserConfigurationMsg uc; + uc.setUserWeight(9000); + uc.setBicycleWeight(3000); + fec.send(uc); + // get fec capabilities + RequestDataPageMsg rq; + rq.setRequestedPageNumber(ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_NUMBER); + rq.setCommandType(ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_COMMANDTYPE_REQUESTDATAPAGE); + rq.setRequestedTransmissionResponseCount(3); + fec.send(rq); +} + +void loop() { + router.loop(); + if (ant.getResponse().isError()) + { + Serial.print("ANT MSG ERROR: "); + Serial.println(ant.getResponse().getErrorCode()); + } + unsigned long currentMillis = millis(); + + /** + * + * Just a quick test to switch target power + * every **interval** + * + */ + if(currentMillis - previousMillis > interval) + { + previousMillis = currentMillis; + if (TargetPower == 100) + { + TargetPower = 50; + }else{ + TargetPower = 100; + } + FecTargetPowerMsg tp; + tp.setTargetPower(TargetPower); + fec.send(tp); + } +} + +void printFeState(uint8_t fe_state) { + Serial.print("FE State: "); + switch (fe_state) { + case ANTPLUS_FEC_DATAPAGE_FESTATE_RESERVED: + Serial.println("Reserved"); + break; + case ANTPLUS_FEC_DATAPAGE_FESTATE_ASLEEP: + Serial.println("Asleep / Off"); + break; + case ANTPLUS_FEC_DATAPAGE_FESTATE_READY: + Serial.println("Ready"); + break; + case ANTPLUS_FEC_DATAPAGE_FESTATE_INUSE: + Serial.println("In Use"); + break; + case ANTPLUS_FEC_DATAPAGE_FESTATE_FINISHED: + Serial.println("Finished / Paused"); + break; + default: + Serial.println("Unknown/Reserved"); + break; + } +} + +void printLapToggleBit(uint8_t bit) { + Serial.print("Lap Toggle Bit: "); + Serial.println(bit); +} + +void manufacturerInformationDataPageHandler(ManufacturersInformation& msg, uintptr_t data) { + Serial.print("Manufacturer ID: "); + Serial.println(msg.getManufacturerID()); + Serial.print("Model Number: "); + Serial.println(msg.getModelNumber()); + Serial.print("hardware Revision: "); + Serial.println(msg.getHWRevision()); +} + +void productInformationDataPageHandler(ProductInformation& msg, uintptr_t data) { + Serial.print("Software Revision Main: "); + Serial.println(msg.getSWRevisionMain()); + Serial.print("Software Revision Supplemental: "); + Serial.println(msg.getSWRevisionSupplemental()); + Serial.print("Serial Number: "); + Serial.println(msg.getSerialNumber()); +} + +void GeneralDataPageHandler(FecGeneralFeData& msg, uintptr_t data) { + uint8_t fe_type = msg.getFeType(); + Serial.print("Equipment type: "); + switch (fe_type) { + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_GENERAL: + Serial.println("General"); + break; + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_TREADMILL: + Serial.println("Treadmill"); + break; + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_ELLIPTICAL: + Serial.println("Elliptical"); + break; + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_STATIONARYBIKE: + Serial.println("Stationary Bike"); + break; + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_ROWER: + Serial.println("Rower"); + break; + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_CLIMBER: + Serial.println("Climber"); + break; + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_NORDICSKIER: + Serial.println("Nordic Skier"); + break; + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_TRAINER: + Serial.println("Trainer"); + break; + default: + Serial.println("Unknown"); + break; + } + Serial.print("Elapsed time: "); + Serial.println(msg.getElapsedTime()); + Serial.print("Distance traveled: "); + Serial.println(msg.getDistanceTraveled()); + Serial.print("Current speed: "); + uint16_t speed = msg.getSpeed(); + if (speed == ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_SPEED_INVALID) { + Serial.println("Invalid"); + } else { + Serial.println(speed); + } + Serial.print("Heart Rate: "); + uint8_t hr = msg.getHeartRate(); + if (hr == ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_HEARTRATE_INVALID) { + Serial.println("Invalid"); + } else { + Serial.println(hr); + } + Serial.print("HR Data Source: "); + uint8_t source = msg.getHrDataSource(); + switch (source) { + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_HRDATASOURCE_INVALID: + Serial.println("Invalid"); + break; + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_HRDATASOURCE_ANTPLUSMONITOR: + Serial.println("ANT+ HR Monitor"); + break; + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_HRDATASOURCE_EMMONITOR: + Serial.println("EM Monitor"); + break; + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_HRDATASOURCE_HANDSCONTACT: + Serial.println("Hand Contact"); + break; + } + Serial.print("Distance Traveled Enabled: "); + Serial.println(msg.getDistanceTraveledEnabled()); + Serial.print("Virtual Speed Flag: "); + Serial.println(msg.getVirtualSpeedFlag()); + printFeState(msg.getFeState()); + printLapToggleBit(msg.getLapToggleBit()); +} + +void GeneralSettingsDataPageHandler(FecGeneralSettingsPage& msg, uintptr_t data) { + uint8_t cycle_length = msg.getCycleLength(); + Serial.print("Cycle length: "); + if (cycle_length == ANTPLUS_FEC_DATAPAGE_GENERALSETTINGSPAGE_CYCLELENGTH_INVALID) { + Serial.println("Invalid"); + } else { + Serial.println(cycle_length); + } + uint16_t incline = msg.getIncline(); + Serial.print("Incline value: "); + if (incline == ANTPLUS_FEC_DATAPAGE_GENERALSETTINGSPAGE_INCLINE_INVALID) { + Serial.println("Invalid"); + } else { + Serial.println(incline); + } + uint8_t resistance = msg.getResistanceLevel(); + Serial.print("Resistance level: "); + if (resistance == ANTPLUS_FEC_DATAPAGE_GENERALSETTINGSPAGE_RESISTANCELEVEL_INVALID) { + Serial.println("Invalid"); + } else { + Serial.println(resistance); + } + printFeState(msg.getFeState()); + printLapToggleBit(msg.getLapToggleBit()); +} + +void fecBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data) { + FecBaseMainDataPage dp = FecBaseMainDataPage(msg); + Serial.println("==========================="); + Serial.print("DataPage: "); + Serial.println(dp.getDataPageNumber()); +} + +void SpecificTrainerDataPageHandler(FecSpecificTrainerData& msg, uintptr_t data){ + Serial.print("Update Event Count: "); + Serial.println(msg.getUpdateEventCount()); + Serial.print("Instantaneous Cadence: "); + uint8_t cadence = msg.getInstantaneousCadence(); + if (cadence == ANTPLUS_FEC_DATAPAGE_SPECIFICTRAINERDATA_INSTANTANEOUSCADENCE_INVALID) { + Serial.println("Invalid"); + } else { + Serial.println(cadence); + } + uint16_t power = msg.getInstantaneousPower(); + if (power == ANTPLUS_FEC_DATAPAGE_SPECIFICTRAINERDATA_INSTANTANEOUSPOWER_INVALID) { + Serial.println("Accumulated Power: Invalid"); + Serial.println("Instantaneous Power: Invalid"); + } else { + Serial.print("Accumulated Power: "); + Serial.println(msg.getAccumulatedPower()); + Serial.print("Instantaneous Power: "); + Serial.println(power); + } + Serial.print("Bicycle Power Calibration: "); + if (msg.getBicyclePowerCalibration()) + { + Serial.println("Required"); + } else { + Serial.println("Complete/Not Required"); + } + Serial.print("Resistance Calibration: "); + if (msg.getResistanceCalibration()) + { + Serial.println("Required"); + } else { + Serial.println("Complete/Not Required"); + } + Serial.print("User Configuration: "); + if (msg.getUserConfiguration()) + { + Serial.println("Required"); + FecUserConfigurationMsg uc; + uc.setUserWeight(9000); + uc.setBicycleWeight(3000); + fec.send(uc); + } else { + Serial.println("Complete/Not Required"); + } + Serial.print("Target Power Limits: "); + uint8_t limit = msg.getTargetPowerLimits(); + switch(limit) { + case ANTPLUS_FEC_DATAPAGE_SPECIFICTRAINERDATA_TARGETPOWERLIMITS_ATTARGET: + Serial.println("Trainer at target power"); + break; + case ANTPLUS_FEC_DATAPAGE_SPECIFICTRAINERDATA_TARGETPOWERLIMITS_SPEEDTOOLOW: + Serial.println("User cycling speed is too low"); + break; + case ANTPLUS_FEC_DATAPAGE_SPECIFICTRAINERDATA_TARGETPOWERLIMITS_SPEEDTOOHIGH: + Serial.println("User cycling speed is too high"); + break; + case ANTPLUS_FEC_DATAPAGE_SPECIFICTRAINERDATA_TARGETPOWERLIMITS_UNDERTERMINED: + Serial.println("Undetermined"); + break; + } + printFeState(msg.getFeState()); + printLapToggleBit(msg.getLapToggleBit()); +} + +void FeCapabitiliesDataPageHandler(FecFeCapabilities& msg, uintptr_t data) { + Serial.print("Max resistance: "); + Serial.println(msg.getMaximumResistance()); + Serial.println("Fec Capabilities: "); + Serial.print(" Supports Basic Resistance Mode: "); + Serial.println(msg.getBasicResistanceModeSupport() ? "Y" : "N"); + Serial.print(" Supports Target Power Mode: "); + Serial.println(msg.getTargetPowerModeSupport() ? "Y" : "N"); + Serial.print(" Supports Sumulation Mode: "); + Serial.println(msg.getSimulationModeSupport() ? "Y" : "N"); +} + +void printStatus(uint8_t status) { + Serial.print("Channel Status: "); + switch (status) { + case CHANNEL_STATUS_UNASSIGNED: + Serial.println("Unassigned"); + break; + case CHANNEL_STATUS_ASSIGNED: + Serial.println("Assigned"); + break; + case CHANNEL_STATUS_SEARCHING: + Serial.println("Searching"); + break; + case CHANNEL_STATUS_TRACKING: + Serial.println("Tracking"); + break; + } +} diff --git a/examples/HeartRateDisplay/HeartRateDisplay.ino b/examples/HeartRateDisplay/HeartRateDisplay.ino index 465553b..89f2dcc 100644 --- a/examples/HeartRateDisplay/HeartRateDisplay.ino +++ b/examples/HeartRateDisplay/HeartRateDisplay.ino @@ -72,13 +72,44 @@ void loop() { void batteryStatusDataPageHandler(HeartRateBatteryStatus& msg, uintptr_t data) { Serial.print("Battery Level: "); - Serial.println(msg.getBatteryLevel()); + if (msg.getBatteryLevel() == ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYLEVEL_INVALID) { + Serial.println("Invalid"); + } else { + Serial.println(msg.getBatteryLevel()); + } Serial.print("Fractional Battery Voltage: "); Serial.println(msg.getFractionalBatteryVoltage()); Serial.print("Coarse Battery Voltage: "); - Serial.println(msg.getCoarseBatteryVoltage()); + if (msg.getCoarseBatteryVoltage() == ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_INVALID) { + Serial.println("Invalid"); + } else { + Serial.println(msg.getCoarseBatteryVoltage()); + } Serial.print("Battery Status: "); - Serial.println(msg.getBatteryStatus()); + uint8_t batteryStatus = msg.getBatteryStatus(); + switch (batteryStatus) { + case ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_NEW: + Serial.println("New"); + break; + case ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_GOOD: + Serial.println("Good"); + break; + case ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_OK: + Serial.println("Ok"); + break; + case ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_LOW: + Serial.println("Low"); + break; + case ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_CRITICAL: + Serial.println("Critical"); + break; + case ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_INVALID: + Serial.println("Invalid"); + break; + default: + Serial.println("Invalid Value"); + break; + } } void capabilitiesDataPageHandler(HeartRateCapabilities& msg, uintptr_t data) { @@ -106,7 +137,11 @@ void manufacturerInformationDataPageHandler(HeartRateManufacturerInformation& ms void previousHeartBeatDataPageHandler(HeartRatePreviousHeartBeat& dp, uintptr_t data) { Serial.print("Manufacturer Specific Byte: "); - Serial.println(dp.getManufacturerSpecific()); + if (dp.getManufacturerSpecific() == ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_MANUFACTURERSPECIFIC_INVALID) { + Serial.println("Invalid"); + } else { + Serial.println(dp.getManufacturerSpecific()); + } Serial.print("Previous Heart Beat Event Time: "); Serial.println(dp.getPreviousHeartBeatEventTime()); } @@ -122,11 +157,25 @@ void productInformationDataPageHandler(HeartRateProductInformation& msg, uintptr void swimIntervalSummary(HeartRateSwimIntervalSummary& msg, uintptr_t data) { Serial.print("Interval Average Heart Rate: "); - Serial.println(msg.getIntervalAverageHeartRate()); + if (msg.getIntervalAverageHeartRate() == ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALAVERAGEHEARTRATE_INVALID) { + Serial.println("Invalid"); + } else { + Serial.println(msg.getIntervalAverageHeartRate()); + } + Serial.print("Interval Maximum Heart Rate: "); - Serial.println(msg.getIntervalMaximumHeartRate()); + if (msg.getIntervalMaximumHeartRate() == ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALMAXIMUMHEARTRATE_INVALID) { + Serial.println("Invalid"); + } else { + Serial.println(msg.getIntervalMaximumHeartRate()); + } + Serial.print("Session Average Heart Rate: "); - Serial.println(msg.getSessionAverageHeartRate()); + if (msg.getSessionAverageHeartRate() == ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_SESSIONAVERAGEHEARTRATE_INVALID) { + Serial.println("Invalid"); + } else { + Serial.println(msg.getSessionAverageHeartRate()); + } } void heartRateBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data) { diff --git a/examples/LEVDisplay/LEVDisplay.ino b/examples/LEVDisplay/LEVDisplay.ino index 7e49d00..2560fd6 100644 --- a/examples/LEVDisplay/LEVDisplay.ino +++ b/examples/LEVDisplay/LEVDisplay.ino @@ -173,6 +173,7 @@ void levSpeedSystemInformation2Handler(LevSpeedSystemInformation2& msg, uintptr_ } else { Serial.println(percent); } + printCommonSpeedSystemInformation(msg); } void levBatteryInformation(LevBatteryInformation& msg, uintptr_t data) { diff --git a/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino b/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino new file mode 100644 index 0000000..41659f5 --- /dev/null +++ b/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino @@ -0,0 +1,88 @@ +/********************************************** + * AntPlus muscle oxygen monitor example + * + * Deliver data of a muscle oxygen sensor + * to a display via serial port + * + * Author Bernd Woköck + * based on the work of Curtis Malainey + **********************************************/ +#include +#include "ANT.h" +#include "ANTPLUS.h" + +#define BAUD_RATE 9600 +#define CHANNEL_0 0 + +const uint8_t NETWORK_KEY[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; + +ArduinoSerialAntWithCallbacks ant; +AntPlusRouter router; +ProfileMuscleOxygenMonitor moxy(123); + +void moxyCreateMsgHandler(MuscleOxygenMuscleOxygenDataMsg& msg, uintptr_t data); +void moxyCreateManufacturerInformationMsg(ManufacturersInformationMsg& msg, uintptr_t data); +void moxyCreateProductInformationMsg(ProductInformationMsg& msg, uintptr_t data); + +void setup() { + Serial2.begin(BAUD_RATE); + ant.setSerial(Serial2); + delay(1000); + + router.setDriver(&ant); // never touch ant again + router.setAntPlusNetworkKey(NETWORK_KEY); + router.setProfile(CHANNEL_0, &moxy); + // Delay after initial setup to wait for user to connect on serial + + Serial.begin(BAUD_RATE); + Serial.println("Running"); + + // setup muscle oxygen monitor + moxy.createMuscleOxygenMuscleOxygenDataMsg(moxyCreateMsgHandler); + moxy.createManufacturerInformationMsg(moxyCreateManufacturerInformationMsg); + moxy.createProductInformationMsg(moxyCreateProductInformationMsg); + moxy.begin(); +} + +void loop() { + router.loop(); +} + +void printDpMsg(int dp, const char* s) { + Serial.print("Sending DataPage: "); + Serial.print(dp); + Serial.print(" - "); + Serial.println(s); +} + +void moxyCreateMsgHandler(MuscleOxygenMuscleOxygenDataMsg& msg, uintptr_t data) +{ + const int lo = 500, hi = 2500; + static uint16_t _c = lo; + static uint8_t _eventCount = 0; + + printDpMsg(ANTPLUS_SHIFTING_DATAPAGE_SHIFTSYSTEMSTATUS_NUMBER, "Muscle Oxygen Data"); + // demo data + msg.setTotalHemoglobinConcentration(_c); + msg.setCurrentSaturatedHemoglobinPercentage(_c++/4); + msg.setEventCount(_eventCount++); + msg.setAntFSSupport(ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_CAPABILITIES_ANTFSSUPPORT_SUPPORTED); + msg.setMeasurementInterval(ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_CAPABILITIES_MEASUREMENTINTERVAL_1S); + + if (_c > hi) + _c = lo; +} + +void moxyCreateManufacturerInformationMsg(ManufacturersInformationMsg& msg, uintptr_t data) { + printDpMsg(ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER, "Manufacturers Information"); + msg.setHWRevision(0x01); + msg.setManufacturerId(0x1234); + msg.setModelNumber(0x0001); +} + +void moxyCreateProductInformationMsg(ProductInformationMsg& msg, uintptr_t data) { + printDpMsg(ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER, "Product Information"); + msg.setSerialNumber(0x12345678); + msg.setSWRevisionMain(0x01); + msg.setSWRevisionSupplemental(0x00); +} diff --git a/examples/ShiftingShifter/ShiftingShifter.ino b/examples/ShiftingShifter/ShiftingShifter.ino new file mode 100644 index 0000000..11dbe53 --- /dev/null +++ b/examples/ShiftingShifter/ShiftingShifter.ino @@ -0,0 +1,103 @@ +/********************************************** + * AntPlus shifting shifter example + * + * Deliver data of a shifting sensor + * to a display via serial port + * + * Author Bernd Woköck + * based on the work of Curtis Malainey + **********************************************/ +#include +#include "ANT.h" +#include "ANTPLUS.h" + +#define BAUD_RATE 9600 +#define CHANNEL_0 0 + +const uint8_t NETWORK_KEY[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}; // get this from thisisant.com + +ArduinoSerialAntWithCallbacks ant; +AntPlusRouter router; +ProfileShiftingShifter shift(7370); + +void shiftSystemStatusMsgHandler(ShiftingShiftSystemStatusMsg& msg, uintptr_t data); +void multiComponentSystemManufacturersInformationMsgHandler(MultiComponentSystemManufacturersInformationMsg& msg, uintptr_t data); +void multiComponentSystemProductInformationMsgHandler(MultiComponentSystemProductInformationMsg& msg, uintptr_t data); +void batteryStatusMsgHandler(BatteryStatusMsg& msg, uintptr_t data); + +void setup() { + Serial1.begin(BAUD_RATE); + ant.setSerial(Serial1); + delay(3000); + + router.setDriver(&ant); // never touch ant again + router.setAntPlusNetworkKey(NETWORK_KEY); + router.setProfile(CHANNEL_0, &shift); + + Serial.begin(BAUD_RATE); + Serial.println("Running"); + + // setup shifting monitor + shift.createShiftingShiftSystemStatusMsg(shiftSystemStatusMsgHandler); + shift.createMultiComponentSystemManufacturersInformationMsg(multiComponentSystemManufacturersInformationMsgHandler); + shift.createMultiComponentSystemProductInformationMsg(multiComponentSystemProductInformationMsgHandler); + shift.createBatteryStatusMsg(batteryStatusMsgHandler); + shift.begin(); +} + +void loop() { + router.loop(); +} + +void printDpMsg(int dp, const char* s) { + Serial.print("Sending DataPage: "); + Serial.print(dp); + Serial.print(" - "); + Serial.println(s); +} + +void shiftSystemStatusMsgHandler(ShiftingShiftSystemStatusMsg& msg, uintptr_t data) { + static int _gear = 0; + static int _eventCount = 0; + printDpMsg(1, "Shift System Status"); + msg.setTotalNumbersGearFront(1); + msg.setTotalNumbersGearRear(10); + msg.setCurrentGearFront(1); + msg.setCurrentGearRear(_gear++ % 10); + msg.setEventCount(_eventCount++); + msg.setInvalidInboardShiftCountRear(2); + msg.setInvalidOutboardShiftCountRear(3); + msg.setInvalidInboardShiftCountFront(4); + msg.setInvalidOutboardShiftCountFront(5); + msg.setShiftFailureCountRear(6); + msg.setShiftFailureCountFront(7); +} + +void multiComponentSystemManufacturersInformationMsgHandler(MultiComponentSystemManufacturersInformationMsg& msg, uintptr_t data) { + printDpMsg(78, "Multi Component System Manufacturers Information"); + msg.setNumberOfComponents(3); + msg.setComponentIdentifier(1); + msg.setHWRevision(0x01); + msg.setManufacturerId(0x1234); + msg.setModelNumber(0x0002); +} + +void multiComponentSystemProductInformationMsgHandler(MultiComponentSystemProductInformationMsg& msg, uintptr_t data) { + printDpMsg(79, "Multi Component System Product Information"); + msg.setNumberOfComponents(3); + msg.setComponentIdentifier(1); + msg.setSerialNumber(0x12345678); + msg.setSWRevisionMain(0x01); + msg.setSWRevisionSupplemental(0x00); +} + +void batteryStatusMsgHandler(BatteryStatusMsg& msg, uintptr_t data) { + printDpMsg(82, "Battery Status"); + msg.setNumberOfBatteries(3); + msg.setBatteryIdentifier(1); + msg.setCumulativeOperatingTime(123); + msg.setFractionalBatteryVoltage(12); + msg.setCoarseBatteryVoltage(12); + msg.setBatteryStatus(ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_OK); + msg.setCumulativeOperatingTimeResolution(ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIMERESOLUTION_2S); +} diff --git a/library.json b/library.json index 750b1bf..8b41bcc 100644 --- a/library.json +++ b/library.json @@ -7,7 +7,7 @@ "type": "git", "url": "https://github.com/cujomalainey/antplus-arduino.git" }, - "version": "1.1.1", + "version": "1.2.0", "frameworks": "*", "platforms": "*", "dependencies": diff --git a/library.properties b/library.properties index 570c6b6..2f3eb04 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=ANTPLUS-Arduino -version=1.1.1 +version=1.2.0 author=Curtis Malainey maintainer=Curtis Malainey sentence=Library for easy ANT+ integration diff --git a/src/ANTPLUS.h b/src/ANTPLUS.h index 0d7eb56..8518104 100644 --- a/src/ANTPLUS.h +++ b/src/ANTPLUS.h @@ -10,4 +10,4 @@ // Profiles #include -#endif // ANTPLUS_h \ No newline at end of file +#endif // ANTPLUS_h diff --git a/src/ANTPLUS_PrivateDefines.h b/src/ANTPLUS_PrivateDefines.h index f86b0b8..e685da7 100644 --- a/src/ANTPLUS_PrivateDefines.h +++ b/src/ANTPLUS_PrivateDefines.h @@ -1,6 +1,9 @@ #ifndef ANTPLUS_PRIVATEDEFINES_h #define ANTPLUS_PRIVATEDEFINES_h +#define ANTPLUS_TRANSMISSIONTYPE_LSN_MASK 0x0F +#define ANTPLUS_TRANSMISSION_SET_LSN(x, flags) ((x & ~ANTPLUS_TRANSMISSIONTYPE_LSN_MASK) | (ANTPLUS_TRANSMISSIONTYPE_LSN_MASK & flags)) + /* Channel config stuff */ #define ANTPLUS_CHANNEL_FREQUENCY 57 #define ANTPLUS_DEVICENUMBER_WILDCARD 0 @@ -14,4 +17,4 @@ #define ANTPLUS_CHANNELEVENT_MESSAGECODE 1 -#endif // ANTPLUS_PRIVATEDEFINES_h \ No newline at end of file +#endif // ANTPLUS_PRIVATEDEFINES_h diff --git a/src/BaseClasses/ANTPLUS_BaseDataPage.h b/src/BaseClasses/ANTPLUS_BaseDataPage.h index 9a2b869..8d2f7ca 100644 --- a/src/BaseClasses/ANTPLUS_BaseDataPage.h +++ b/src/BaseClasses/ANTPLUS_BaseDataPage.h @@ -8,7 +8,7 @@ template class BaseDataPage : virtual public CoreDataPage { public: - BaseDataPage(AntRxDataResponse& msg); + explicit BaseDataPage(AntRxDataResponse& msg); #ifndef UNIT_TEST protected: #endif // UNIT_TEST diff --git a/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp b/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp index 985062b..6232b8a 100644 --- a/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp +++ b/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp @@ -1,7 +1,7 @@ -#include #include -#include -#include +#include +#include +#include BaseMasterProfile::BaseMasterProfile(uint16_t deviceNumber, uint8_t transmissionType) : BaseProfile(deviceNumber, transmissionType) { } @@ -19,6 +19,7 @@ void BaseMasterProfile::onChannelEventResponse(ChannelEventResponse& msg) { void BaseMasterProfile::onAcknowledgedData(AcknowledgedData& msg) { BaseProfile::onAcknowledgedData(msg); BaseDataPage dp(msg); + if (dp.getDataPageNumber() == ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER) { handleRequestDataPage(msg); } @@ -30,10 +31,11 @@ void BaseMasterProfile::handleRequestDataPage(AcknowledgedData& msg) { // Datapage requested isn't supported, don't do anything return; } - _requestedCount = dp.getRequestedPageCount(); + _requestedCount = dp.getRequestedTransmissionResponseCount(); _requestedPage = dp.getRequestedPageNumber(); - _isRequestAcknowledged = dp.getUseAcknowledgedMsgs(); + _isRequestAcknowledged = dp.getRequestedTransmissionUseAcknowledged(); _requestAcked = !dp.transmitTillAcknowledged(); + // TODO handle command type } bool BaseMasterProfile::isRequestedPagePending() { @@ -48,7 +50,7 @@ uint8_t BaseMasterProfile::getRequestedPage() { } bool BaseMasterProfile::isRequestedPageAcknowledged() { - return _isRequestAcknowledged; + return _isRequestAcknowledged && _ackMessagesAllowed; } void BaseMasterProfile::begin() { @@ -57,6 +59,15 @@ void BaseMasterProfile::begin() { transmitNextDataPage(); } +void BaseMasterProfile::invalidateDataPageRequest() { + _requestedCount = 0; + _requestAcked = true; +} + +void BaseMasterProfile::setAckMessageUsage(bool on) { + _ackMessagesAllowed = on; +} + void BaseMasterProfile::transmitMsg(BaseDataPageMsg &msg) { if (isRequestedPageAcknowledged() && isRequestedPagePending()) { AcknowledgedDataMsg ack; diff --git a/src/BaseClasses/ANTPLUS_BaseMasterProfile.h b/src/BaseClasses/ANTPLUS_BaseMasterProfile.h index dcfaa37..ff1431a 100644 --- a/src/BaseClasses/ANTPLUS_BaseMasterProfile.h +++ b/src/BaseClasses/ANTPLUS_BaseMasterProfile.h @@ -41,6 +41,16 @@ class BaseMasterProfile : public BaseProfile { * returns true if the request is meant to be sent as a acknowledged message */ bool isRequestedPageAcknowledged(); + /** + * Allows a profile to further validate datapage requests and invludate at a later + * time if deemed appropriate. An example is the descriptor byte fields. + */ + void invalidateDataPageRequest(); + /** + * Some profiles are forbidden from replying with ACK messages, this allows the profile + * to disable automatic request conversions; + */ + void setAckMessageUsage(bool on); /** * Handles ack msg conversions for requests, all transmissions that are part of the broadcast pattern should be through this. */ @@ -50,6 +60,7 @@ class BaseMasterProfile : public BaseProfile { void handleRequestDataPage(AcknowledgedData& msg); uint8_t _requestedPage = 0; uint8_t _requestedCount = 0; + bool _ackMessagesAllowed = true; bool _isRequestAcknowledged = false; bool _requestAcked = true; }; diff --git a/src/BaseClasses/ANTPLUS_BaseProfile.h b/src/BaseClasses/ANTPLUS_BaseProfile.h index dd00b30..7ba82b2 100644 --- a/src/BaseClasses/ANTPLUS_BaseProfile.h +++ b/src/BaseClasses/ANTPLUS_BaseProfile.h @@ -98,10 +98,10 @@ class BaseProfile { private: void checkProfileStatus(); AntPlusRouter* _router = NULL; - AntCallback _onDataPage; - AntCallback _onOtherDataPage; - AntCallback _onChannelEvent; - AntCallback _onChannelIdResponse; + AntCallback _onDataPage = {.func = NULL}; + AntCallback _onOtherDataPage = {.func = NULL}; + AntCallback _onChannelEvent = {.func = NULL}; + AntCallback _onChannelIdResponse = {.func = NULL}; uint8_t _channel = 0; uint8_t _channelType = 0; uint16_t _channelPeriod = 0; diff --git a/src/BaseClasses/ANTPLUS_BaseSlaveProfile.cpp b/src/BaseClasses/ANTPLUS_BaseSlaveProfile.cpp index 023ac13..94d2f8e 100644 --- a/src/BaseClasses/ANTPLUS_BaseSlaveProfile.cpp +++ b/src/BaseClasses/ANTPLUS_BaseSlaveProfile.cpp @@ -1,17 +1,8 @@ #include #include -BaseSlaveProfile::BaseSlaveProfile() : BaseProfile(ANTPLUS_DEVICENUMBER_WILDCARD, ANTPLUS_TRANSMISSIONTYPE_WILDCARD) { - -} - -BaseSlaveProfile::BaseSlaveProfile(uint16_t deviceNumber) : BaseProfile(deviceNumber, ANTPLUS_TRANSMISSIONTYPE_WILDCARD) { - -} - -BaseSlaveProfile::BaseSlaveProfile(uint16_t deviceNumber, uint8_t transmissionType) : BaseProfile(deviceNumber, transmissionType) { - -} +BaseSlaveProfile::BaseSlaveProfile(uint16_t deviceNumber, uint8_t transmissionType) : + BaseProfile(deviceNumber, transmissionType) {} uint8_t BaseSlaveProfile::waitForPair() { // TODO add a timeout in the event packed was dropped? diff --git a/src/BaseClasses/ANTPLUS_BaseSlaveProfile.h b/src/BaseClasses/ANTPLUS_BaseSlaveProfile.h index b819255..b2998f3 100644 --- a/src/BaseClasses/ANTPLUS_BaseSlaveProfile.h +++ b/src/BaseClasses/ANTPLUS_BaseSlaveProfile.h @@ -5,9 +5,7 @@ class BaseSlaveProfile : public BaseProfile { public: - BaseSlaveProfile(); - BaseSlaveProfile(uint16_t deviceNumber); - BaseSlaveProfile(uint16_t deviceNumber, uint8_t transmissionType); + explicit BaseSlaveProfile(uint16_t deviceNumber = 0, uint8_t transmissionType = 0); /** * Will return once the device either pairs or timesout its search */ diff --git a/src/BaseClasses/ANTPLUS_CoreDataPage.cpp b/src/BaseClasses/ANTPLUS_CoreDataPage.cpp index 32b248d..9171175 100644 --- a/src/BaseClasses/ANTPLUS_CoreDataPage.cpp +++ b/src/BaseClasses/ANTPLUS_CoreDataPage.cpp @@ -4,9 +4,7 @@ #include "ANT.h" template -CoreDataPage::CoreDataPage() : T() { - -} +CoreDataPage::CoreDataPage() : T() {} template uint8_t CoreDataPage::getDataPageNumber() { diff --git a/src/CommonDataPages/RX/ANTPLUS_ANTFSClientBeacon.cpp b/src/CommonDataPages/ANTPLUS_ANTFSClientBeacon.cpp similarity index 100% rename from src/CommonDataPages/RX/ANTPLUS_ANTFSClientBeacon.cpp rename to src/CommonDataPages/ANTPLUS_ANTFSClientBeacon.cpp diff --git a/src/CommonDataPages/RX/ANTPLUS_ANTFSClientBeacon.h b/src/CommonDataPages/ANTPLUS_ANTFSClientBeacon.h similarity index 100% rename from src/CommonDataPages/RX/ANTPLUS_ANTFSClientBeacon.h rename to src/CommonDataPages/ANTPLUS_ANTFSClientBeacon.h diff --git a/src/CommonDataPages/ANTPLUS_BatteryStatus.cpp b/src/CommonDataPages/ANTPLUS_BatteryStatus.cpp new file mode 100644 index 0000000..d7e1837 --- /dev/null +++ b/src/CommonDataPages/ANTPLUS_BatteryStatus.cpp @@ -0,0 +1,118 @@ +#include +#include +#include + +#define RESERVED_BYTE 1 +#define RESERVED_VALUE 0xFF +#define BATTERYIDENTIFIER_BYTE 2 +#define BATTERYIDENTIFIER_NUMBEROFBATTERIES_MASK 0x0F +#define BATTERYIDENTIFIER_IDENTIFIER_MASK 0xF0 +#define BATTERYIDENTIFIER_IDENTIFIER_SHIFT 4 +#define CUMULATIVEOPERATINGTIME_LSB_BYTE 3 +#define CUMULATIVEOPERATINGTIME_MSB_BYTE 5 +#define FRACTIONALBATTERYVOLTAGE_BYTE 6 +#define DESCRIPTIVEBITFIELD_BYTE 7 +#define DESCRIPTIVEBITFIELD_COARSEBATTERYVOLTAGE_MASK 0x0F +#define DESCRIPTIVEBITFIELD_BATTERYSTATUS_MASK 0x70 +#define DESCRIPTIVEBITFIELD_BATTERYSTATUS_SHIFT 4 +#define DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_MASK 0x80 +#define DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_SHIFT 7 + + +template +BaseBatteryStatus::BaseBatteryStatus() : CoreDataPage() {} + +template +uint8_t BaseBatteryStatus::getNumberOfBatteries() { + return this->get8BitValue(BATTERYIDENTIFIER_BYTE, + BATTERYIDENTIFIER_NUMBEROFBATTERIES_MASK); +} + +template +uint8_t BaseBatteryStatus::getBatteryIdentifier() { + return this->get8BitValue(BATTERYIDENTIFIER_BYTE, + BATTERYIDENTIFIER_IDENTIFIER_MASK, + BATTERYIDENTIFIER_IDENTIFIER_SHIFT); +} + +template +uint32_t BaseBatteryStatus::getCumulativeOperatingTime() { + return this->get24BitValue(CUMULATIVEOPERATINGTIME_LSB_BYTE, + CUMULATIVEOPERATINGTIME_MSB_BYTE); +} + +template +uint8_t BaseBatteryStatus::getFractionalBatteryVoltage() { + return this->get8BitValue(FRACTIONALBATTERYVOLTAGE_BYTE); +} + +template +uint8_t BaseBatteryStatus::getCoarseBatteryVoltage() { + return this->get8BitValue(DESCRIPTIVEBITFIELD_BYTE, + DESCRIPTIVEBITFIELD_COARSEBATTERYVOLTAGE_MASK); +} + +template +uint8_t BaseBatteryStatus::getBatteryStatus() { + return this->get8BitValue(DESCRIPTIVEBITFIELD_BYTE, + DESCRIPTIVEBITFIELD_BATTERYSTATUS_MASK, + DESCRIPTIVEBITFIELD_BATTERYSTATUS_SHIFT); +} + +template +uint8_t BaseBatteryStatus::getCumulativeOperatingTimeResolution() { + return this->get8BitValue(DESCRIPTIVEBITFIELD_BYTE, + DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_MASK, + DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_SHIFT); +} + +template class BaseBatteryStatus; +template class BaseBatteryStatus; + +BatteryStatus::BatteryStatus(AntRxDataResponse& dp) : + BaseDataPage(dp), + BaseBatteryStatus() {} + +BatteryStatusMsg::BatteryStatusMsg() : + BaseDataPageMsg(), + BaseBatteryStatus() { + setDataBuffer(_buffer); + set8BitValue(ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); + set8BitValue(RESERVED_VALUE, RESERVED_BYTE); +} + +void BatteryStatusMsg::setNumberOfBatteries(uint8_t num) { + set8BitValue(num, BATTERYIDENTIFIER_BYTE, + BATTERYIDENTIFIER_NUMBEROFBATTERIES_MASK); +} + +void BatteryStatusMsg::setBatteryIdentifier(uint8_t id) { + set8BitValue(id, BATTERYIDENTIFIER_BYTE, BATTERYIDENTIFIER_IDENTIFIER_MASK, + BATTERYIDENTIFIER_IDENTIFIER_SHIFT); +} + +void BatteryStatusMsg::setCumulativeOperatingTime(uint32_t time) { + set24BitValue(time, CUMULATIVEOPERATINGTIME_LSB_BYTE, + CUMULATIVEOPERATINGTIME_MSB_BYTE); +} + +void BatteryStatusMsg::setFractionalBatteryVoltage(uint8_t voltage) { + set8BitValue(voltage, FRACTIONALBATTERYVOLTAGE_BYTE); +} + +void BatteryStatusMsg::setCoarseBatteryVoltage(uint8_t voltage) { + set8BitValue(voltage, DESCRIPTIVEBITFIELD_BYTE, + DESCRIPTIVEBITFIELD_COARSEBATTERYVOLTAGE_MASK); +} + +void BatteryStatusMsg::setBatteryStatus(uint8_t status) { + set8BitValue(status, DESCRIPTIVEBITFIELD_BYTE, + DESCRIPTIVEBITFIELD_BATTERYSTATUS_MASK, + DESCRIPTIVEBITFIELD_BATTERYSTATUS_SHIFT); +} + +void BatteryStatusMsg::setCumulativeOperatingTimeResolution(uint8_t resolution) { + set8BitValue(resolution, DESCRIPTIVEBITFIELD_BYTE, + DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_MASK, + DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_SHIFT); +} diff --git a/src/CommonDataPages/ANTPLUS_BatteryStatus.h b/src/CommonDataPages/ANTPLUS_BatteryStatus.h new file mode 100644 index 0000000..3d5c142 --- /dev/null +++ b/src/CommonDataPages/ANTPLUS_BatteryStatus.h @@ -0,0 +1,41 @@ +#ifndef ANTPLUS_BATTERYSTATUS_h +#define ANTPLUS_BATTERYSTATUS_h + +#include +#include + +// Common page 82 + +template +class BaseBatteryStatus : virtual public CoreDataPage { +public: + BaseBatteryStatus(); + uint8_t getNumberOfBatteries(); + uint8_t getBatteryIdentifier(); + uint32_t getCumulativeOperatingTime(); + uint8_t getFractionalBatteryVoltage(); + uint8_t getCoarseBatteryVoltage(); + uint8_t getBatteryStatus(); + uint8_t getCumulativeOperatingTimeResolution(); +}; + +class BatteryStatus : public BaseDataPage, public BaseBatteryStatus { +public: + explicit BatteryStatus(AntRxDataResponse& dp); +}; + +class BatteryStatusMsg : public BaseDataPageMsg, public BaseBatteryStatus { +public: + BatteryStatusMsg(); + void setNumberOfBatteries(uint8_t num); + void setBatteryIdentifier(uint8_t id); + void setCumulativeOperatingTime(uint32_t time); + void setFractionalBatteryVoltage(uint8_t voltage); + void setCoarseBatteryVoltage(uint8_t voltage); + void setBatteryStatus(uint8_t status); + void setCumulativeOperatingTimeResolution(uint8_t resolution); +private: + uint8_t _buffer[MESSAGE_SIZE] = {0}; +}; + +#endif // ANTPLUS_BATTERYSTATUS_h diff --git a/src/CommonDataPages/RX/ANTPLUS_CommandStatus.cpp b/src/CommonDataPages/ANTPLUS_CommandStatus.cpp similarity index 100% rename from src/CommonDataPages/RX/ANTPLUS_CommandStatus.cpp rename to src/CommonDataPages/ANTPLUS_CommandStatus.cpp diff --git a/src/CommonDataPages/RX/ANTPLUS_CommandStatus.h b/src/CommonDataPages/ANTPLUS_CommandStatus.h similarity index 100% rename from src/CommonDataPages/RX/ANTPLUS_CommandStatus.h rename to src/CommonDataPages/ANTPLUS_CommandStatus.h diff --git a/src/CommonDataPages/ANTPLUS_CommonDataPageDefines.h b/src/CommonDataPages/ANTPLUS_CommonDataPageDefines.h index 9d99c0e..f11f17d 100644 --- a/src/CommonDataPages/ANTPLUS_CommonDataPageDefines.h +++ b/src/CommonDataPages/ANTPLUS_CommonDataPageDefines.h @@ -2,6 +2,8 @@ #define ANTPLUS_COMMONDATAPAGEDEFINES_h /* Request Data Page */ +#define ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER 70 + #define ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_SLAVESERIALNUMBER_INVALID 0xFFFF #define ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE1_INVALID 0xFF @@ -16,9 +18,44 @@ #define ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_COMMANDTYPE_REQUESTDATAPAGEFROMSLAVE 3 #define ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_COMMANDTYPE_REQUESTDATAPAGESET 4 + /* Mode Settings */ +#define ANTPLUS_COMMON_DATAPAGE_MODESETTINGS_NUMBER 76 + #define ANTPLUS_COMMON_DATAPAGE_MODESETTINGS_SPORTSMODE_RUNNING 1 #define ANTPLUS_COMMON_DATAPAGE_MODESETTINGS_SPORTSMODE_CYCLING 2 #define ANTPLUS_COMMON_DATAPAGE_MODESETTINGS_SPORTSMODE_SWIMMING 5 + +/* Multi-Component Manufacturers Information */ +#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER 78 + + +/* Multi-Component Product Information */ +#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER 79 + + +/* Manufacturers Information */ +#define ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER 80 + + +/* Product Information */ +#define ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER 81 + +#define ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SWREVISIONSUPPLEMENTAL_INVALID 0xFF + + +/* Battery Status */ +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER 82 + +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_NEW 1 +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_GOOD 2 +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_OK 3 +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_LOW 4 +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_CRITICAL 5 +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_INVALID 7 + +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIMERESOLUTION_16S 0 +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIMERESOLUTION_2S 1 + #endif // ANTPLUS_COMMONDATAPAGEDEFINES_h diff --git a/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h b/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h deleted file mode 100644 index ba2fbd0..0000000 --- a/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef ANTPLUS_COMMONDATAPAGEPRIVATEDEFINES_h -#define ANTPLUS_COMMONDATAPAGEPRIVATEDEFINES_h - -/* Request Data Page */ -#define ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER 70 - -#define ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_SLAVESERIALNUMBER_LSB_BYTE 1 -#define ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_SLAVESERIALNUMBER_MSB_BYTE 2 - -#define ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE1_BYTE 3 - -#define ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE2_BYTE 4 - -#define ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_BYTE 5 -#define ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_COUNT_MASK 0x7F -#define ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_MASK 0x80 -#define ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_SHIFT 7 -#define ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_TRANSMITTILLACKNOWLEDGED_VALUE 0x80 - -#define ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDPAGENUMBER_BYTE 6 - -#define ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_COMMANDTYPE_BYTE 7 - -/* Mode Settings */ -#define ANTPLUS_COMMON_DATAPAGE_MODESETTINGS_NUMBER 76 - -#define ANTPLUS_COMMON_DATAPAGE_MODESETTINGS_SPORTSMODE_BYTE 7 - -/* Manufacturers Information */ -#define ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER 80 - -#define ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_HWREVISION_BYTE 3 - -#define ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_MANUFACTURERID_LSB_BYTE 4 -#define ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_MANUFACTURERID_MSB_BYTE 5 - -#define ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_MODELNUMBER_LSB_BYTE 6 -#define ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_MODELNUMBER_MSB_BYTE 7 - -/* Product Information */ -#define ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER 81 - -#define ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SWREVISIONSUPPLEMENTAL_BYTE 2 - -#define ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SWREVISIONMAIN_BYTE 3 - -#define ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SERIALNUMBER_LSB_BYTE 4 -#define ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SERIALNUMBER_MSB_BYTE 7 - -#endif // ANTPLUS_COMMONDATAPAGEPRIVATEDEFINES_h diff --git a/src/CommonDataPages/ANTPLUS_CommonDataPages.h b/src/CommonDataPages/ANTPLUS_CommonDataPages.h index 55e2f0e..4d1bbf5 100644 --- a/src/CommonDataPages/ANTPLUS_CommonDataPages.h +++ b/src/CommonDataPages/ANTPLUS_CommonDataPages.h @@ -2,39 +2,21 @@ #define ANTPLUS_COMMONHEADERS_h // RX -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// TX -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif // ANTPLUS_COMMONHEADERS_h diff --git a/src/CommonDataPages/RX/ANTPLUS_ErrorDescription.cpp b/src/CommonDataPages/ANTPLUS_ErrorDescription.cpp similarity index 100% rename from src/CommonDataPages/RX/ANTPLUS_ErrorDescription.cpp rename to src/CommonDataPages/ANTPLUS_ErrorDescription.cpp diff --git a/src/CommonDataPages/RX/ANTPLUS_ErrorDescription.h b/src/CommonDataPages/ANTPLUS_ErrorDescription.h similarity index 100% rename from src/CommonDataPages/RX/ANTPLUS_ErrorDescription.h rename to src/CommonDataPages/ANTPLUS_ErrorDescription.h diff --git a/src/CommonDataPages/RX/ANTPLUS_GenericCommand.cpp b/src/CommonDataPages/ANTPLUS_GenericCommand.cpp similarity index 100% rename from src/CommonDataPages/RX/ANTPLUS_GenericCommand.cpp rename to src/CommonDataPages/ANTPLUS_GenericCommand.cpp diff --git a/src/CommonDataPages/RX/ANTPLUS_GenericCommand.h b/src/CommonDataPages/ANTPLUS_GenericCommand.h similarity index 100% rename from src/CommonDataPages/RX/ANTPLUS_GenericCommand.h rename to src/CommonDataPages/ANTPLUS_GenericCommand.h diff --git a/src/CommonDataPages/ANTPLUS_ManufacturersInformation.cpp b/src/CommonDataPages/ANTPLUS_ManufacturersInformation.cpp new file mode 100644 index 0000000..349d502 --- /dev/null +++ b/src/CommonDataPages/ANTPLUS_ManufacturersInformation.cpp @@ -0,0 +1,60 @@ +#include +#include +#include + +#define HWREVISION_BYTE 3 +#define MANUFACTURERID_LSB_BYTE 4 +#define MANUFACTURERID_MSB_BYTE 5 +#define MODELNUMBER_LSB_BYTE 6 +#define MODELNUMBER_MSB_BYTE 7 +#define RESERVED_LSB_BYTE 1 +#define RESERVED_MSB_BYTE 2 +#define RESERVED_VALUE 0xFFFF + +template +BaseManufacturersInformation::BaseManufacturersInformation() : + CoreDataPage() {} + +template +uint8_t BaseManufacturersInformation::getHWRevision() { + return this->get8BitValue(HWREVISION_BYTE); +} + +template +uint16_t BaseManufacturersInformation::getManufacturerID() { + return this->get16BitValue(MANUFACTURERID_LSB_BYTE, + MANUFACTURERID_MSB_BYTE); +} + +template +uint16_t BaseManufacturersInformation::getModelNumber() { + return this->get16BitValue(MODELNUMBER_LSB_BYTE, MODELNUMBER_MSB_BYTE); +} + +template class BaseManufacturersInformation; +template class BaseManufacturersInformation; + +ManufacturersInformation::ManufacturersInformation(AntRxDataResponse& dp) : + BaseDataPage(dp), + BaseManufacturersInformation() {} + +ManufacturersInformationMsg::ManufacturersInformationMsg() : + BaseDataPageMsg(), + BaseManufacturersInformation() { + setDataBuffer(_buffer); + set8BitValue(ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER, + ANTPLUS_DEFAULT_DATAPAGE_BYTE); + set16BitValue(RESERVED_VALUE, RESERVED_LSB_BYTE, RESERVED_MSB_BYTE); +} + +void ManufacturersInformationMsg::setHWRevision(uint8_t revision) { + set8BitValue(revision, HWREVISION_BYTE); +} + +void ManufacturersInformationMsg::setManufacturerId(uint16_t id) { + set16BitValue(id, MANUFACTURERID_LSB_BYTE, MANUFACTURERID_MSB_BYTE); +} + +void ManufacturersInformationMsg::setModelNumber(uint16_t modelNumber) { + set16BitValue(modelNumber, MODELNUMBER_LSB_BYTE, MODELNUMBER_MSB_BYTE); +} diff --git a/src/CommonDataPages/ANTPLUS_ManufacturersInformation.h b/src/CommonDataPages/ANTPLUS_ManufacturersInformation.h new file mode 100644 index 0000000..93c3811 --- /dev/null +++ b/src/CommonDataPages/ANTPLUS_ManufacturersInformation.h @@ -0,0 +1,33 @@ +#ifndef ANTPLUS_MANUFACTURERSINFORMATION_h +#define ANTPLUS_MANUFACTURERSINFORMATION_h + +#include +#include + +// Common page 80 + +template +class BaseManufacturersInformation : virtual public CoreDataPage { +public: + BaseManufacturersInformation(); + uint8_t getHWRevision(); + uint16_t getManufacturerID(); + uint16_t getModelNumber(); +}; + +class ManufacturersInformation : public BaseDataPage, public BaseManufacturersInformation { +public: + explicit ManufacturersInformation(AntRxDataResponse& dp); +}; + +class ManufacturersInformationMsg : public BaseDataPageMsg, BaseManufacturersInformation { +public: + ManufacturersInformationMsg(); + void setHWRevision(uint8_t revision); + void setManufacturerId(uint16_t id); + void setModelNumber(uint16_t modelNumber); +private: + uint8_t _buffer[MESSAGE_SIZE] = {0}; +}; + +#endif // ANTPLUS_MANUFACTURERSINFORMATION_h diff --git a/src/CommonDataPages/RX/ANTPLUS_MemoryLevel.cpp b/src/CommonDataPages/ANTPLUS_MemoryLevel.cpp similarity index 100% rename from src/CommonDataPages/RX/ANTPLUS_MemoryLevel.cpp rename to src/CommonDataPages/ANTPLUS_MemoryLevel.cpp diff --git a/src/CommonDataPages/RX/ANTPLUS_MemoryLevel.h b/src/CommonDataPages/ANTPLUS_MemoryLevel.h similarity index 100% rename from src/CommonDataPages/RX/ANTPLUS_MemoryLevel.h rename to src/CommonDataPages/ANTPLUS_MemoryLevel.h diff --git a/src/CommonDataPages/ANTPLUS_ModeSettings.cpp b/src/CommonDataPages/ANTPLUS_ModeSettings.cpp new file mode 100644 index 0000000..412cddd --- /dev/null +++ b/src/CommonDataPages/ANTPLUS_ModeSettings.cpp @@ -0,0 +1,38 @@ +#include +#include +#include + +#define SPORTSMODE_BYTE 7 +#define RESERVED_VALUE 0xFF + +template +BaseModeSettings::BaseModeSettings() : CoreDataPage() {} + +template +uint8_t BaseModeSettings::getSportMode() { + return this->get8BitValue(SPORTSMODE_BYTE); +} + +template class BaseModeSettings; +template class BaseModeSettings; + +ModeSettings::ModeSettings(AntRxDataResponse& dp) : + BaseDataPage(dp), + BaseModeSettings() {} + +ModeSettingsMsg::ModeSettingsMsg() : + BaseDataPageMsg(), + BaseModeSettings() { + setDataBuffer(_buffer); + set8BitValue(ANTPLUS_COMMON_DATAPAGE_MODESETTINGS_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); + set8BitValue(RESERVED_VALUE, 1); + set8BitValue(RESERVED_VALUE, 2); + set8BitValue(RESERVED_VALUE, 3); + set8BitValue(RESERVED_VALUE, 4); + set8BitValue(RESERVED_VALUE, 5); + set8BitValue(RESERVED_VALUE, 6); +} + +void ModeSettingsMsg::setSportMode(uint8_t sportsMode) { + set8BitValue(sportsMode, SPORTSMODE_BYTE); +} diff --git a/src/CommonDataPages/ANTPLUS_ModeSettings.h b/src/CommonDataPages/ANTPLUS_ModeSettings.h new file mode 100644 index 0000000..904e917 --- /dev/null +++ b/src/CommonDataPages/ANTPLUS_ModeSettings.h @@ -0,0 +1,28 @@ +#ifndef ANTPLUS_MODESETTINGS_h +#define ANTPLUS_MODESETTINGS_h + +#include +#include + +// Common page 76 + +template +class BaseModeSettings : virtual public CoreDataPage { +public: + BaseModeSettings(); + uint8_t getSportMode(); +}; + +class ModeSettings : public BaseDataPage, public BaseModeSettings { +public: + explicit ModeSettings(AntRxDataResponse& dp); +}; + +class ModeSettingsMsg : public BaseDataPageMsg, public BaseModeSettings { + ModeSettingsMsg(); + void setSportMode(uint8_t sportsMode); +private: + uint8_t _buffer[MESSAGE_SIZE] = {0}; +}; + +#endif // ANTPLUS_MODESETTINGS_h diff --git a/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp b/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp new file mode 100644 index 0000000..18517f8 --- /dev/null +++ b/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp @@ -0,0 +1,87 @@ +#include +#include +#include + +#define RESERVED_BYTE 1 +#define RESERVED_VALUE 0xFF +#define COMPONENTIDENTIFIER_BYTE 2 +#define COMPONENTIDENTIFIER_NUMBERCOMPONENTS_MASK 0x0F +#define COMPONENTIDENTIFIER_IDENTIFIER_MASK 0xF0 +#define COMPONENTIDENTIFIER_IDENTIFIER_SHIFT 4 +#define HWREVISION_BYTE 3 +#define MANUFACTURERID_LSB_BYTE 4 +#define MANUFACTURERID_MSB_BYTE 5 +#define MODELNUMBER_LSB_BYTE 6 +#define MODELNUMBER_MSB_BYTE 7 + +template +BaseMultiComponentSystemManufacturersInformation::BaseMultiComponentSystemManufacturersInformation() : + CoreDataPage() {} + +template +uint8_t BaseMultiComponentSystemManufacturersInformation::getNumberOfComponents() { + return this->get8BitValue(COMPONENTIDENTIFIER_BYTE, + COMPONENTIDENTIFIER_NUMBERCOMPONENTS_MASK); +} + +template +uint8_t BaseMultiComponentSystemManufacturersInformation::getComponentIdentifier() { + return this->get8BitValue(COMPONENTIDENTIFIER_BYTE, + COMPONENTIDENTIFIER_IDENTIFIER_MASK, + COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); +} + +template +uint8_t BaseMultiComponentSystemManufacturersInformation::getHWRevision() { + return this->get8BitValue(HWREVISION_BYTE); +} + +template +uint16_t BaseMultiComponentSystemManufacturersInformation::getManufacturerId() { + return this->get16BitValue(MANUFACTURERID_LSB_BYTE, MANUFACTURERID_MSB_BYTE); +} + +template +uint16_t BaseMultiComponentSystemManufacturersInformation::getModelNumber() { + return this->get16BitValue(MODELNUMBER_LSB_BYTE, MODELNUMBER_MSB_BYTE); +} + +template class BaseMultiComponentSystemManufacturersInformation; +template class BaseMultiComponentSystemManufacturersInformation; + +MultiComponentSystemManufacturersInformation::MultiComponentSystemManufacturersInformation(AntRxDataResponse& dp) : + BaseDataPage(dp), + BaseMultiComponentSystemManufacturersInformation() {} + +MultiComponentSystemManufacturersInformationMsg::MultiComponentSystemManufacturersInformationMsg() : + BaseDataPageMsg(), + BaseMultiComponentSystemManufacturersInformation() { + setDataBuffer(_buffer); + set8BitValue( + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER, + ANTPLUS_DEFAULT_DATAPAGE_BYTE); + set8BitValue(RESERVED_VALUE, RESERVED_BYTE); +} + +void MultiComponentSystemManufacturersInformationMsg::setNumberOfComponents(uint8_t count) { + set8BitValue(count, COMPONENTIDENTIFIER_BYTE, + COMPONENTIDENTIFIER_NUMBERCOMPONENTS_MASK); +} + +void MultiComponentSystemManufacturersInformationMsg::setComponentIdentifier(uint8_t identifier) { + set8BitValue(identifier, COMPONENTIDENTIFIER_BYTE, + COMPONENTIDENTIFIER_IDENTIFIER_MASK, + COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); +} + +void MultiComponentSystemManufacturersInformationMsg::setHWRevision(uint8_t rev) { + set8BitValue(rev, HWREVISION_BYTE); +} + +void MultiComponentSystemManufacturersInformationMsg::setManufacturerId(uint16_t id) { + set16BitValue(id, MANUFACTURERID_LSB_BYTE, MANUFACTURERID_MSB_BYTE); +} + +void MultiComponentSystemManufacturersInformationMsg::setModelNumber(uint16_t model) { + set16BitValue(model, MODELNUMBER_LSB_BYTE, MODELNUMBER_MSB_BYTE); +} diff --git a/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.h b/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.h new file mode 100644 index 0000000..0bba1cc --- /dev/null +++ b/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.h @@ -0,0 +1,37 @@ +#ifndef ANTPLUS_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_h +#define ANTPLUS_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_h + +#include +#include + +// Common page 78 + +template +class BaseMultiComponentSystemManufacturersInformation : virtual public CoreDataPage { +public: + BaseMultiComponentSystemManufacturersInformation(); + uint8_t getNumberOfComponents(); + uint8_t getComponentIdentifier(); + uint8_t getHWRevision(); + uint16_t getManufacturerId(); + uint16_t getModelNumber(); +}; + +class MultiComponentSystemManufacturersInformation : public BaseDataPage, public BaseMultiComponentSystemManufacturersInformation { +public: + explicit MultiComponentSystemManufacturersInformation(AntRxDataResponse& dp); +}; + +class MultiComponentSystemManufacturersInformationMsg : public BaseDataPageMsg, public BaseMultiComponentSystemManufacturersInformation { +public: + MultiComponentSystemManufacturersInformationMsg(); + void setNumberOfComponents(uint8_t count); + void setComponentIdentifier(uint8_t identifier); + void setHWRevision(uint8_t rev); + void setManufacturerId(uint16_t id); + void setModelNumber(uint16_t model); +private: + uint8_t _buffer[MESSAGE_SIZE] = {0}; +}; + +#endif // ANTPLUS_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_h diff --git a/src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.cpp b/src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.cpp new file mode 100644 index 0000000..0080158 --- /dev/null +++ b/src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.cpp @@ -0,0 +1,82 @@ +#include +#include +#include + +#define COMPONENTIDENTIFIER_BYTE 1 +#define COMPONENTIDENTIFIER_NUMBEROFCOMPONENTS_MASK 0x0F +#define COMPONENTIDENTIFIER_IDENTIFIER_MASK 0xF0 +#define COMPONENTIDENTIFIER_IDENTIFIER_SHIFT 4 +#define SWREVISIONSUPPLEMENTAL_BYTE 2 +#define SWREVISIONMAIN_BYTE 3 +#define SERIALNUMBER_LSB_BYTE 4 +#define SERIALNUMBER_MSB_BYTE 7 + +template +BaseMultiComponentSystemProductInformation::BaseMultiComponentSystemProductInformation() : + CoreDataPage() {} + +template +uint8_t BaseMultiComponentSystemProductInformation::getNumberOfComponents() { + return this->get8BitValue(COMPONENTIDENTIFIER_BYTE, + COMPONENTIDENTIFIER_NUMBEROFCOMPONENTS_MASK); +} + +template +uint8_t BaseMultiComponentSystemProductInformation::getComponentIdentifier() { + return this->get8BitValue(COMPONENTIDENTIFIER_BYTE, + COMPONENTIDENTIFIER_IDENTIFIER_MASK, + COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); +} + +template +uint8_t BaseMultiComponentSystemProductInformation::getSWRevisionSupplemental() { + return this->get8BitValue(SWREVISIONSUPPLEMENTAL_BYTE); +} + +template +uint8_t BaseMultiComponentSystemProductInformation::getSWRevisionMain() { + return this->get8BitValue(SWREVISIONMAIN_BYTE); +} + +template +uint32_t BaseMultiComponentSystemProductInformation::getSerialNumber() { + return this->get32BitValue(SERIALNUMBER_LSB_BYTE, SERIALNUMBER_MSB_BYTE); +} + +template class BaseMultiComponentSystemProductInformation; +template class BaseMultiComponentSystemProductInformation; + +MultiComponentSystemProductInformation::MultiComponentSystemProductInformation(AntRxDataResponse& dp) : + BaseDataPage(dp), + BaseMultiComponentSystemProductInformation() {} + +MultiComponentSystemProductInformationMsg::MultiComponentSystemProductInformationMsg() : + BaseDataPageMsg(), + BaseMultiComponentSystemProductInformation() { + setDataBuffer(_buffer); + set8BitValue(ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER, + ANTPLUS_DEFAULT_DATAPAGE_BYTE); +} + +void MultiComponentSystemProductInformationMsg::setNumberOfComponents(uint8_t count) { + set8BitValue(count, COMPONENTIDENTIFIER_BYTE, + COMPONENTIDENTIFIER_NUMBEROFCOMPONENTS_MASK); +} + +void MultiComponentSystemProductInformationMsg::setComponentIdentifier(uint8_t identifier) { + set8BitValue(identifier, COMPONENTIDENTIFIER_BYTE, + COMPONENTIDENTIFIER_IDENTIFIER_MASK, + COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); +} + +void MultiComponentSystemProductInformationMsg::setSWRevisionSupplemental(uint8_t revision) { + set8BitValue(revision, SWREVISIONSUPPLEMENTAL_BYTE); +} + +void MultiComponentSystemProductInformationMsg::setSWRevisionMain(uint8_t revision) { + set8BitValue(revision, SWREVISIONMAIN_BYTE); +} + +void MultiComponentSystemProductInformationMsg::setSerialNumber(uint32_t serialNumber) { + set32BitValue(serialNumber, SERIALNUMBER_LSB_BYTE, SERIALNUMBER_MSB_BYTE); +} diff --git a/src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.h b/src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.h new file mode 100644 index 0000000..8ba5cdf --- /dev/null +++ b/src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.h @@ -0,0 +1,37 @@ +#ifndef ANTPLUS_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_h +#define ANTPLUS_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_h + +#include +#include + +// Common page 79 + +template +class BaseMultiComponentSystemProductInformation : virtual public CoreDataPage { +public: + BaseMultiComponentSystemProductInformation(); + uint8_t getNumberOfComponents(); + uint8_t getComponentIdentifier(); + uint8_t getSWRevisionSupplemental(); + uint8_t getSWRevisionMain(); + uint32_t getSerialNumber(); +}; + +class MultiComponentSystemProductInformation : public BaseDataPage, public BaseMultiComponentSystemProductInformation { +public: + explicit MultiComponentSystemProductInformation(AntRxDataResponse& dp); +}; + +class MultiComponentSystemProductInformationMsg : public BaseDataPageMsg, public BaseMultiComponentSystemProductInformation { +public: + MultiComponentSystemProductInformationMsg(); + void setNumberOfComponents(uint8_t count); + void setComponentIdentifier(uint8_t identifier); + void setSWRevisionSupplemental(uint8_t revision); + void setSWRevisionMain(uint8_t revision); + void setSerialNumber(uint32_t serialNumber); +private: + uint8_t _buffer[MESSAGE_SIZE] = {0}; +}; + +#endif // ANTPLUS_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_h diff --git a/src/CommonDataPages/RX/ANTPLUS_OpenChannelCommand.cpp b/src/CommonDataPages/ANTPLUS_OpenChannelCommand.cpp similarity index 100% rename from src/CommonDataPages/RX/ANTPLUS_OpenChannelCommand.cpp rename to src/CommonDataPages/ANTPLUS_OpenChannelCommand.cpp diff --git a/src/CommonDataPages/RX/ANTPLUS_OpenChannelCommand.h b/src/CommonDataPages/ANTPLUS_OpenChannelCommand.h similarity index 100% rename from src/CommonDataPages/RX/ANTPLUS_OpenChannelCommand.h rename to src/CommonDataPages/ANTPLUS_OpenChannelCommand.h diff --git a/src/CommonDataPages/RX/ANTPLUS_PairedDevices.cpp b/src/CommonDataPages/ANTPLUS_PairedDevices.cpp similarity index 100% rename from src/CommonDataPages/RX/ANTPLUS_PairedDevices.cpp rename to src/CommonDataPages/ANTPLUS_PairedDevices.cpp diff --git a/src/CommonDataPages/RX/ANTPLUS_PairedDevices.h b/src/CommonDataPages/ANTPLUS_PairedDevices.h similarity index 100% rename from src/CommonDataPages/RX/ANTPLUS_PairedDevices.h rename to src/CommonDataPages/ANTPLUS_PairedDevices.h diff --git a/src/CommonDataPages/ANTPLUS_ProductInformation.cpp b/src/CommonDataPages/ANTPLUS_ProductInformation.cpp new file mode 100644 index 0000000..cfeab92 --- /dev/null +++ b/src/CommonDataPages/ANTPLUS_ProductInformation.cpp @@ -0,0 +1,56 @@ +#include +#include +#include + +#define RESERVED_BYTE 1 +#define RESERVED_VALUE 0xFF +#define SWREVISIONSUPPLEMENTAL_BYTE 2 +#define SWREVISIONMAIN_BYTE 3 +#define SERIALNUMBER_LSB_BYTE 4 +#define SERIALNUMBER_MSB_BYTE 7 + +template +BaseProductInformation::BaseProductInformation() : CoreDataPage() {} + +template +uint8_t BaseProductInformation::getSWRevisionSupplemental() { + return this->get8BitValue(SWREVISIONSUPPLEMENTAL_BYTE); +} + +template +uint8_t BaseProductInformation::getSWRevisionMain() { + return this->get8BitValue(SWREVISIONMAIN_BYTE); +} + +template +uint32_t BaseProductInformation::getSerialNumber() { + return this->get32BitValue(SERIALNUMBER_LSB_BYTE, SERIALNUMBER_MSB_BYTE); +} + +template class BaseProductInformation; +template class BaseProductInformation; + +ProductInformation::ProductInformation(AntRxDataResponse& dp) : + BaseDataPage(dp), + BaseProductInformation() {} + +ProductInformationMsg::ProductInformationMsg() : + BaseDataPageMsg(), + BaseProductInformation() { + setDataBuffer(_buffer); + set8BitValue(ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); + set8BitValue(RESERVED_VALUE, RESERVED_BYTE); + set8BitValue(ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SWREVISIONSUPPLEMENTAL_INVALID, SWREVISIONSUPPLEMENTAL_BYTE); +} + +void ProductInformationMsg::setSWRevisionSupplemental(uint8_t revision) { + set8BitValue(revision, SWREVISIONSUPPLEMENTAL_BYTE); +} + +void ProductInformationMsg::setSWRevisionMain(uint8_t revision) { + set8BitValue(revision, SWREVISIONMAIN_BYTE); +} + +void ProductInformationMsg::setSerialNumber(uint32_t serialNumber) { + set32BitValue(serialNumber, SERIALNUMBER_LSB_BYTE, SERIALNUMBER_MSB_BYTE); +} diff --git a/src/CommonDataPages/ANTPLUS_ProductInformation.h b/src/CommonDataPages/ANTPLUS_ProductInformation.h new file mode 100644 index 0000000..33ad5e1 --- /dev/null +++ b/src/CommonDataPages/ANTPLUS_ProductInformation.h @@ -0,0 +1,33 @@ +#ifndef ANTPLUS_PRODUCTINFORMATION_h +#define ANTPLUS_PRODUCTINFORMATION_h + +#include +#include + +// Common page 81 + +template +class BaseProductInformation : virtual public CoreDataPage { +public: + BaseProductInformation(); + uint8_t getSWRevisionSupplemental(); + uint8_t getSWRevisionMain(); + uint32_t getSerialNumber(); +}; + +class ProductInformation : public BaseDataPage, public BaseProductInformation { +public: + explicit ProductInformation(AntRxDataResponse& dp); +}; + +class ProductInformationMsg : public BaseDataPageMsg, public BaseProductInformation { +public: + ProductInformationMsg(); + void setSWRevisionSupplemental(uint8_t revision); + void setSWRevisionMain(uint8_t revision); + void setSerialNumber(uint32_t serialNumber); +private: + uint8_t _buffer[MESSAGE_SIZE] = {0}; +}; + +#endif // ANTPLUS_PRODUCTINFORMATION_h diff --git a/src/CommonDataPages/ANTPLUS_RequestDataPage.cpp b/src/CommonDataPages/ANTPLUS_RequestDataPage.cpp new file mode 100644 index 0000000..85ee8d7 --- /dev/null +++ b/src/CommonDataPages/ANTPLUS_RequestDataPage.cpp @@ -0,0 +1,118 @@ +#include +#include +#include + +#define SLAVESERIALNUMBER_LSB_BYTE 1 +#define SLAVESERIALNUMBER_MSB_BYTE 2 +#define DESCRIPTORBYTE1_BYTE 3 +#define DESCRIPTORBYTE2_BYTE 4 +#define REQUESTEDTRANSMISSIONRESPONSE_BYTE 5 +#define REQUESTEDTRANSMISSIONRESPONSE_COUNT_MASK 0x7F +#define REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_MASK 0x80 +#define REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_SHIFT 7 +#define REQUESTEDTRANSMISSIONRESPONSE_TRANSMITTILLACKNOWLEDGED_VALUE 0x80 +#define REQUESTEDPAGENUMBER_BYTE 6 +#define COMMANDTYPE_BYTE 7 + +template +BaseRequestDataPage::BaseRequestDataPage() : + CoreDataPage() {} + +template +uint16_t BaseRequestDataPage::getSlaveSerialNumber() { + return this->get16BitValue( + SLAVESERIALNUMBER_LSB_BYTE, SLAVESERIALNUMBER_MSB_BYTE); +} + +template +uint8_t BaseRequestDataPage::getDescriptorByte1() { + return this->get8BitValue(DESCRIPTORBYTE1_BYTE); +} + +template +uint8_t BaseRequestDataPage::getDescriptorByte2() { + return this->get8BitValue(DESCRIPTORBYTE2_BYTE); +} + +template +uint8_t BaseRequestDataPage::getRequestedTransmissionResponseCount() { + return this->get8BitValue( + REQUESTEDTRANSMISSIONRESPONSE_BYTE, + REQUESTEDTRANSMISSIONRESPONSE_COUNT_MASK); +} + +template +uint8_t BaseRequestDataPage::getRequestedTransmissionUseAcknowledged() { + return this->get8BitValue( + REQUESTEDTRANSMISSIONRESPONSE_BYTE, + REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_MASK, + REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_SHIFT); +} + +template +uint8_t BaseRequestDataPage::transmitTillAcknowledged() { + return this->get8BitValue(REQUESTEDTRANSMISSIONRESPONSE_BYTE) + == REQUESTEDTRANSMISSIONRESPONSE_TRANSMITTILLACKNOWLEDGED_VALUE; +} + +template +uint8_t BaseRequestDataPage::getRequestedPageNumber() { + return this->get8BitValue(REQUESTEDPAGENUMBER_BYTE); +} + +template +uint8_t BaseRequestDataPage::getCommandType() { + return this->get8BitValue(COMMANDTYPE_BYTE); +} + +template class BaseRequestDataPage; +template class BaseRequestDataPage; + +RequestDataPage::RequestDataPage(AntRxDataResponse& dp) : + BaseDataPage(dp), + BaseRequestDataPage() {} + +RequestDataPageMsg::RequestDataPageMsg() : + BaseDataPageMsg(), + BaseRequestDataPage() { + setDataBuffer(_buffer); + setDescriptorByte1(ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE1_INVALID); + setDescriptorByte2(ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE2_INVALID); + set8BitValue(ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); +} + +void RequestDataPageMsg::setSlaveSerialNumber(uint16_t serialNumber) { + set16BitValue(serialNumber, + SLAVESERIALNUMBER_LSB_BYTE, SLAVESERIALNUMBER_MSB_BYTE); +} + +void RequestDataPageMsg::setDescriptorByte1(uint8_t descriptorByte) { + set8BitValue(descriptorByte, DESCRIPTORBYTE1_BYTE); +} + +void RequestDataPageMsg::setDescriptorByte2(uint8_t descriptorByte) { + set8BitValue(descriptorByte, DESCRIPTORBYTE2_BYTE); +} + +void RequestDataPageMsg::setRequestedTransmissionResponseCount(uint8_t count) { + set8BitValue(count, + REQUESTEDTRANSMISSIONRESPONSE_BYTE, + REQUESTEDTRANSMISSIONRESPONSE_COUNT_MASK); +} + +void RequestDataPageMsg::setRequestedTransmissionUseAcknowledged(uint8_t useAcknowledged) { + set8BitValue(useAcknowledged ? 1 : 0, REQUESTEDTRANSMISSIONRESPONSE_BYTE, + REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_MASK, + REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_SHIFT); +} + +void RequestDataPageMsg::setRequestedPageNumber(uint8_t pageNumber) { + set8BitValue(pageNumber, REQUESTEDPAGENUMBER_BYTE); +} + +void RequestDataPageMsg::setCommandType(uint8_t commandType) { + if (commandType != ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_COMMANDTYPE_REQUESTDATAPAGEFROMSLAVE) { + setSlaveSerialNumber(ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_SLAVESERIALNUMBER_INVALID); + } + set8BitValue(commandType, COMMANDTYPE_BYTE); +} diff --git a/src/CommonDataPages/ANTPLUS_RequestDataPage.h b/src/CommonDataPages/ANTPLUS_RequestDataPage.h new file mode 100644 index 0000000..d42a970 --- /dev/null +++ b/src/CommonDataPages/ANTPLUS_RequestDataPage.h @@ -0,0 +1,42 @@ +#ifndef ANTPLUS_REQUESTDATAPAGE_h +#define ANTPLUS_REQUESTDATAPAGE_h + +#include +#include + +// Common Page 70 + +template +class BaseRequestDataPage : virtual public CoreDataPage { +public: + BaseRequestDataPage(); + uint16_t getSlaveSerialNumber(); + uint8_t getDescriptorByte1(); + uint8_t getDescriptorByte2(); + uint8_t getRequestedTransmissionResponseCount(); + uint8_t getRequestedTransmissionUseAcknowledged(); + uint8_t transmitTillAcknowledged(); + uint8_t getRequestedPageNumber(); + uint8_t getCommandType(); +}; + +class RequestDataPage : public BaseDataPage, public BaseRequestDataPage { +public: + explicit RequestDataPage(AntRxDataResponse& dp); +}; + +class RequestDataPageMsg : public BaseDataPageMsg, public BaseRequestDataPage { +public: + RequestDataPageMsg(); + void setSlaveSerialNumber(uint16_t serialNumber); + void setDescriptorByte1(uint8_t descriptorByte); + void setDescriptorByte2(uint8_t descriptorByte); + void setRequestedTransmissionResponseCount(uint8_t count); + void setRequestedTransmissionUseAcknowledged(uint8_t useAcknowledged); + void setRequestedPageNumber(uint8_t pageNumber); + void setCommandType(uint8_t commandType); +private: + uint8_t _buffer[MESSAGE_SIZE] = {0}; +}; + +#endif // ANTPLUS_REQUESTDATAPAGE_h diff --git a/src/CommonDataPages/RX/ANTPLUS_SubfieldData.cpp b/src/CommonDataPages/ANTPLUS_SubfieldData.cpp similarity index 100% rename from src/CommonDataPages/RX/ANTPLUS_SubfieldData.cpp rename to src/CommonDataPages/ANTPLUS_SubfieldData.cpp diff --git a/src/CommonDataPages/RX/ANTPLUS_SubfieldData.h b/src/CommonDataPages/ANTPLUS_SubfieldData.h similarity index 100% rename from src/CommonDataPages/RX/ANTPLUS_SubfieldData.h rename to src/CommonDataPages/ANTPLUS_SubfieldData.h diff --git a/src/CommonDataPages/RX/ANTPLUS_TimeAndDate.cpp b/src/CommonDataPages/ANTPLUS_TimeAndDate.cpp similarity index 100% rename from src/CommonDataPages/RX/ANTPLUS_TimeAndDate.cpp rename to src/CommonDataPages/ANTPLUS_TimeAndDate.cpp diff --git a/src/CommonDataPages/RX/ANTPLUS_TimeAndDate.h b/src/CommonDataPages/ANTPLUS_TimeAndDate.h similarity index 100% rename from src/CommonDataPages/RX/ANTPLUS_TimeAndDate.h rename to src/CommonDataPages/ANTPLUS_TimeAndDate.h diff --git a/src/CommonDataPages/Base/ANTPLUS_BaseManufacturersInformation.cpp b/src/CommonDataPages/Base/ANTPLUS_BaseManufacturersInformation.cpp deleted file mode 100644 index e39c0d8..0000000 --- a/src/CommonDataPages/Base/ANTPLUS_BaseManufacturersInformation.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -template -BaseManufacturersInformation::BaseManufacturersInformation() : CoreDataPage() { -} - -template -uint8_t BaseManufacturersInformation::getHWRevision() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_HWREVISION_BYTE); -} - -template -uint16_t BaseManufacturersInformation::getManufacturerID() { - return this->get16BitValue( - ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_MANUFACTURERID_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_MANUFACTURERID_MSB_BYTE); -} - -template -uint16_t BaseManufacturersInformation::getModelNumber() { - return this->get16BitValue( - ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_MODELNUMBER_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_MODELNUMBER_MSB_BYTE); -} - -template class BaseManufacturersInformation; -template class BaseManufacturersInformation; diff --git a/src/CommonDataPages/Base/ANTPLUS_BaseManufacturersInformation.h b/src/CommonDataPages/Base/ANTPLUS_BaseManufacturersInformation.h deleted file mode 100644 index d7ea012..0000000 --- a/src/CommonDataPages/Base/ANTPLUS_BaseManufacturersInformation.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef ANTPLUS_BASEMANUFACTURERSINFORMATION_h -#define ANTPLUS_BASEMANUFACTURERSINFORMATION_h - -#include - -#include "ANT.h" - -// Common page 80 - -template -class BaseManufacturersInformation : virtual public CoreDataPage { -public: - BaseManufacturersInformation(); - uint8_t getHWRevision(); - uint16_t getManufacturerID(); - uint16_t getModelNumber(); -}; - -#endif // ANTPLUS_BASEMANUFACTURERSINFORMATION_h diff --git a/src/CommonDataPages/Base/ANTPLUS_BaseModeSettings.cpp b/src/CommonDataPages/Base/ANTPLUS_BaseModeSettings.cpp deleted file mode 100644 index 91c8de8..0000000 --- a/src/CommonDataPages/Base/ANTPLUS_BaseModeSettings.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include - -template -BaseModeSettings::BaseModeSettings() : CoreDataPage() { -} - -template -uint8_t BaseModeSettings::getSportMode() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_MODESETTINGS_SPORTSMODE_BYTE); -} - -template class BaseModeSettings; -template class BaseModeSettings; diff --git a/src/CommonDataPages/Base/ANTPLUS_BaseModeSettings.h b/src/CommonDataPages/Base/ANTPLUS_BaseModeSettings.h deleted file mode 100644 index c212857..0000000 --- a/src/CommonDataPages/Base/ANTPLUS_BaseModeSettings.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef ANTPLUS_BASEMODESETTINGS_h -#define ANTPLUS_BASEMODESETTINGS_h - -#include - -#include "ANT.h" - -// Common page 76 - -template -class BaseModeSettings : virtual public CoreDataPage { -public: - BaseModeSettings(); - uint8_t getSportMode(); -}; - -#endif // ANTPLUS_BASEMODESETTINGS_h diff --git a/src/CommonDataPages/Base/ANTPLUS_BaseProductInformation.cpp b/src/CommonDataPages/Base/ANTPLUS_BaseProductInformation.cpp deleted file mode 100644 index 8e0d100..0000000 --- a/src/CommonDataPages/Base/ANTPLUS_BaseProductInformation.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include - -template -BaseProductInformation::BaseProductInformation() : CoreDataPage() { -} - -template -uint8_t BaseProductInformation::getSWRevisionSupplemental() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SWREVISIONSUPPLEMENTAL_BYTE); -} - -template -uint8_t BaseProductInformation::getSWRevisionMain() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SWREVISIONMAIN_BYTE); -} - -template -uint32_t BaseProductInformation::getSerialNumber() { - return this->get32BitValue( - ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SERIALNUMBER_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SERIALNUMBER_MSB_BYTE); -} - -template class BaseProductInformation; -template class BaseProductInformation; diff --git a/src/CommonDataPages/Base/ANTPLUS_BaseProductInformation.h b/src/CommonDataPages/Base/ANTPLUS_BaseProductInformation.h deleted file mode 100644 index c6ecbba..0000000 --- a/src/CommonDataPages/Base/ANTPLUS_BaseProductInformation.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef ANTPLUS_BASEPRODUCTINFORMATION_h -#define ANTPLUS_BASEPRODUCTINFORMATION_h - -#include - -#include "ANT.h" - -// Common page 81 - -template -class BaseProductInformation : virtual public CoreDataPage { -public: - BaseProductInformation(); - uint8_t getSWRevisionSupplemental(); - uint8_t getSWRevisionMain(); - uint32_t getSerialNumber(); -}; - -#endif // ANTPLUS_BASEPRODUCTINFORMATION_h diff --git a/src/CommonDataPages/Base/ANTPLUS_BaseRequestDataPage.cpp b/src/CommonDataPages/Base/ANTPLUS_BaseRequestDataPage.cpp deleted file mode 100644 index 31a90ad..0000000 --- a/src/CommonDataPages/Base/ANTPLUS_BaseRequestDataPage.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include -#include - -template -BaseRequestDataPage::BaseRequestDataPage() : CoreDataPage() { -} - -template -uint16_t BaseRequestDataPage::getSlaveSerialNumber() { - return this->get16BitValue( - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_SLAVESERIALNUMBER_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_SLAVESERIALNUMBER_MSB_BYTE); -} - -template -uint8_t BaseRequestDataPage::getDescriptorByte1() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE1_BYTE); -} - -template -uint8_t BaseRequestDataPage::getDescriptorByte2() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE2_BYTE); -} - -template -uint8_t BaseRequestDataPage::getRequestedPageCount() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_BYTE, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_COUNT_MASK); -} - -template -uint8_t BaseRequestDataPage::getUseAcknowledgedMsgs() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_BYTE, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_MASK, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_SHIFT); -} - -template -uint8_t BaseRequestDataPage::transmitTillAcknowledged() { - return this->get8BitValue(ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_BYTE) - == ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_TRANSMITTILLACKNOWLEDGED_VALUE; -} - -template -uint8_t BaseRequestDataPage::getRequestedPageNumber() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDPAGENUMBER_BYTE); -} - -template -uint8_t BaseRequestDataPage::getCommandType() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_COMMANDTYPE_BYTE); -} - -template class BaseRequestDataPage; -template class BaseRequestDataPage; diff --git a/src/CommonDataPages/Base/ANTPLUS_BaseRequestDataPage.h b/src/CommonDataPages/Base/ANTPLUS_BaseRequestDataPage.h deleted file mode 100644 index 58be6bf..0000000 --- a/src/CommonDataPages/Base/ANTPLUS_BaseRequestDataPage.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef ANTPLUS_BASEREQUESTDATAPAGE_h -#define ANTPLUS_BASEREQUESTDATAPAGE_h - -#include - -#include "ANT.h" - -// Common Page 70 - -template -class BaseRequestDataPage : virtual public CoreDataPage { -public: - BaseRequestDataPage(); - uint16_t getSlaveSerialNumber(); - uint8_t getDescriptorByte1(); - uint8_t getDescriptorByte2(); - uint8_t getRequestedPageCount(); - uint8_t getUseAcknowledgedMsgs(); - uint8_t transmitTillAcknowledged(); - uint8_t getRequestedPageNumber(); - uint8_t getCommandType(); -}; - -#endif // ANTPLUS_BASEREQUESTDATAPAGE_h diff --git a/src/CommonDataPages/RX/ANTPLUS_BatteryStatus.cpp b/src/CommonDataPages/RX/ANTPLUS_BatteryStatus.cpp deleted file mode 100644 index 0ffdd02..0000000 --- a/src/CommonDataPages/RX/ANTPLUS_BatteryStatus.cpp +++ /dev/null @@ -1 +0,0 @@ -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/RX/ANTPLUS_BatteryStatus.h b/src/CommonDataPages/RX/ANTPLUS_BatteryStatus.h deleted file mode 100644 index 04c978c..0000000 --- a/src/CommonDataPages/RX/ANTPLUS_BatteryStatus.h +++ /dev/null @@ -1,2 +0,0 @@ -// Common Page 82 -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/RX/ANTPLUS_ManufacturersInformation.cpp b/src/CommonDataPages/RX/ANTPLUS_ManufacturersInformation.cpp deleted file mode 100644 index 197f42b..0000000 --- a/src/CommonDataPages/RX/ANTPLUS_ManufacturersInformation.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include -#include - -ManufacturersInformation::ManufacturersInformation(AntRxDataResponse& dp) : BaseDataPage(dp), BaseManufacturersInformation() { -} diff --git a/src/CommonDataPages/RX/ANTPLUS_ManufacturersInformation.h b/src/CommonDataPages/RX/ANTPLUS_ManufacturersInformation.h deleted file mode 100644 index 274c469..0000000 --- a/src/CommonDataPages/RX/ANTPLUS_ManufacturersInformation.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef ANTPLUS_MANUFACTURERSINFORMATION_h -#define ANTPLUS_MANUFACTURERSINFORMATION_h - -#include -#include - -#include "ANT.h" - -// Common page 80 - -class ManufacturersInformation : public BaseDataPage, public BaseManufacturersInformation { -public: - ManufacturersInformation(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_MANUFACTURERSINFORMATION_h diff --git a/src/CommonDataPages/RX/ANTPLUS_ModeSettings.cpp b/src/CommonDataPages/RX/ANTPLUS_ModeSettings.cpp deleted file mode 100644 index e07c1fe..0000000 --- a/src/CommonDataPages/RX/ANTPLUS_ModeSettings.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include - -ModeSettings::ModeSettings(AntRxDataResponse& dp) : BaseDataPage(dp), BaseModeSettings() { -} diff --git a/src/CommonDataPages/RX/ANTPLUS_ModeSettings.h b/src/CommonDataPages/RX/ANTPLUS_ModeSettings.h deleted file mode 100644 index f4444e7..0000000 --- a/src/CommonDataPages/RX/ANTPLUS_ModeSettings.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef ANTPLUS_MODESETTINGS_h -#define ANTPLUS_MODESETTINGS_h - -#include -#include - -#include "ANT.h" - -// Common page 76 - -class ModeSettings : public BaseDataPage, public BaseModeSettings { -public: - ModeSettings(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_MODESETTINGS_h diff --git a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp b/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp deleted file mode 100644 index 219841a..0000000 --- a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp +++ /dev/null @@ -1,2 +0,0 @@ -// Common page 78 -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.h b/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.h deleted file mode 100644 index b9bfbf9..0000000 --- a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.h +++ /dev/null @@ -1,2 +0,0 @@ -// Common Page 79 -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.cpp b/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.cpp deleted file mode 100644 index 0ffdd02..0000000 --- a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.cpp +++ /dev/null @@ -1 +0,0 @@ -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.h b/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.h deleted file mode 100644 index b9bfbf9..0000000 --- a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.h +++ /dev/null @@ -1,2 +0,0 @@ -// Common Page 79 -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/RX/ANTPLUS_ProductInformation.cpp b/src/CommonDataPages/RX/ANTPLUS_ProductInformation.cpp deleted file mode 100644 index 64cd3a4..0000000 --- a/src/CommonDataPages/RX/ANTPLUS_ProductInformation.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include - -ProductInformation::ProductInformation(AntRxDataResponse& dp) : BaseDataPage(dp), BaseProductInformation() { -} diff --git a/src/CommonDataPages/RX/ANTPLUS_ProductInformation.h b/src/CommonDataPages/RX/ANTPLUS_ProductInformation.h deleted file mode 100644 index c6864db..0000000 --- a/src/CommonDataPages/RX/ANTPLUS_ProductInformation.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef ANTPLUS_PRODUCTINFORMATION_h -#define ANTPLUS_PRODUCTINFORMATION_h - -#include -#include - -#include "ANT.h" - -// Common page 81 - -class ProductInformation : public BaseDataPage, public BaseProductInformation { -public: - ProductInformation(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_PRODUCTINFORMATION_h diff --git a/src/CommonDataPages/RX/ANTPLUS_RequestDataPage.cpp b/src/CommonDataPages/RX/ANTPLUS_RequestDataPage.cpp deleted file mode 100644 index e06af61..0000000 --- a/src/CommonDataPages/RX/ANTPLUS_RequestDataPage.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include - -RequestDataPage::RequestDataPage(AntRxDataResponse& dp) : BaseDataPage(dp), BaseRequestDataPage() { -} diff --git a/src/CommonDataPages/RX/ANTPLUS_RequestDataPage.h b/src/CommonDataPages/RX/ANTPLUS_RequestDataPage.h deleted file mode 100644 index 64b4c8f..0000000 --- a/src/CommonDataPages/RX/ANTPLUS_RequestDataPage.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef ANTPLUS_REQUESTDATAPAGE_h -#define ANTPLUS_REQUESTDATAPAGE_h - -#include -#include - -#include "ANT.h" - -// Common Page 70 - -class RequestDataPage : public BaseDataPage, public BaseRequestDataPage { -public: - RequestDataPage(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_REQUESTDATAPAGE_h diff --git a/src/CommonDataPages/TX/ANTPLUS_ANTFSClientBeaconMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_ANTFSClientBeaconMsg.cpp deleted file mode 100644 index 0ffdd02..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_ANTFSClientBeaconMsg.cpp +++ /dev/null @@ -1 +0,0 @@ -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_ANTFSClientBeaconMsg.h b/src/CommonDataPages/TX/ANTPLUS_ANTFSClientBeaconMsg.h deleted file mode 100644 index 3db1a5e..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_ANTFSClientBeaconMsg.h +++ /dev/null @@ -1,2 +0,0 @@ -// Common Page 67 -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.cpp deleted file mode 100644 index 0ffdd02..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.cpp +++ /dev/null @@ -1 +0,0 @@ -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.h b/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.h deleted file mode 100644 index 04c978c..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.h +++ /dev/null @@ -1,2 +0,0 @@ -// Common Page 82 -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_CommandStatusMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_CommandStatusMsg.cpp deleted file mode 100644 index 0ffdd02..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_CommandStatusMsg.cpp +++ /dev/null @@ -1 +0,0 @@ -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_CommandStatusMsg.h b/src/CommonDataPages/TX/ANTPLUS_CommandStatusMsg.h deleted file mode 100644 index 856900b..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_CommandStatusMsg.h +++ /dev/null @@ -1,2 +0,0 @@ -// Common Page 71 -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_ErrorDescriptionMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_ErrorDescriptionMsg.cpp deleted file mode 100644 index 0ffdd02..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_ErrorDescriptionMsg.cpp +++ /dev/null @@ -1 +0,0 @@ -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_ErrorDescriptionMsg.h b/src/CommonDataPages/TX/ANTPLUS_ErrorDescriptionMsg.h deleted file mode 100644 index cfbdb0c..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_ErrorDescriptionMsg.h +++ /dev/null @@ -1,2 +0,0 @@ -// Common Page 87 -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_GenericCommandMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_GenericCommandMsg.cpp deleted file mode 100644 index 0ffdd02..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_GenericCommandMsg.cpp +++ /dev/null @@ -1 +0,0 @@ -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_GenericCommandMsg.h b/src/CommonDataPages/TX/ANTPLUS_GenericCommandMsg.h deleted file mode 100644 index d3fb31b..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_GenericCommandMsg.h +++ /dev/null @@ -1,2 +0,0 @@ -// Common page 73 -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_ManufacturersInformationMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_ManufacturersInformationMsg.cpp deleted file mode 100644 index 230cc85..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_ManufacturersInformationMsg.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -#include -#include - -// TODO Magic numbers -ManufacturersInformationMsg::ManufacturersInformationMsg() : BaseDataPageMsg(), BaseManufacturersInformation() { - setDataBuffer(_buffer); - _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER; - _buffer[1] = 0xFF; - _buffer[2] = 0xFF; -} - -void ManufacturersInformationMsg::setHWRevision(uint8_t revision) { - set8BitValue(revision, - ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_HWREVISION_BYTE); -} - -void ManufacturersInformationMsg::setManufacturerId(uint16_t id) { - set16BitValue(id, - ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_MANUFACTURERID_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_MANUFACTURERID_MSB_BYTE); -} - -void ManufacturersInformationMsg::setModelNumber(uint16_t modelNumber) { - set16BitValue(modelNumber, - ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_MODELNUMBER_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_MODELNUMBER_MSB_BYTE); -} diff --git a/src/CommonDataPages/TX/ANTPLUS_ManufacturersInformationMsg.h b/src/CommonDataPages/TX/ANTPLUS_ManufacturersInformationMsg.h deleted file mode 100644 index d8fb562..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_ManufacturersInformationMsg.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef ANTPLUS_MANUFACTURERSINFORMATIONMSG_h -#define ANTPLUS_MANUFACTURERSINFORMATIONMSG_h - -#include -#include - -#include "ANT.h" - -// Common page 80 - -class ManufacturersInformationMsg : public BaseDataPageMsg, BaseManufacturersInformation { -public: - ManufacturersInformationMsg(); - void setHWRevision(uint8_t revision); - void setManufacturerId(uint16_t id); - void setModelNumber(uint16_t modelNumber); -private: - uint8_t _buffer[MESSAGE_SIZE]; -}; - -#endif // ANTPLUS_MANUFACTURERSINFORMATIONMSG_h diff --git a/src/CommonDataPages/TX/ANTPLUS_MemoryLevelMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_MemoryLevelMsg.cpp deleted file mode 100644 index 0ffdd02..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_MemoryLevelMsg.cpp +++ /dev/null @@ -1 +0,0 @@ -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_MemoryLevelMsg.h b/src/CommonDataPages/TX/ANTPLUS_MemoryLevelMsg.h deleted file mode 100644 index 80a5dd0..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_MemoryLevelMsg.h +++ /dev/null @@ -1,2 +0,0 @@ -// Common Page 85 -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_ModeSettingsMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_ModeSettingsMsg.cpp deleted file mode 100644 index 0ffdd02..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_ModeSettingsMsg.cpp +++ /dev/null @@ -1 +0,0 @@ -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_ModeSettingsMsg.h b/src/CommonDataPages/TX/ANTPLUS_ModeSettingsMsg.h deleted file mode 100644 index f0c35a5..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_ModeSettingsMsg.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef ANTPLUS_MODESETTINGSMSG_h -#define ANTPLUS_MODESETTINGSMSG_h - -#include - -#include "ANT.h" - -// Common page 76 - -class ModeSettingsMsg : public BaseDataPageMsg, public BaseModeSettings { -// TODO -}; - -#endif // ANTPLUS_MODESETTINGSMSG_h diff --git a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp deleted file mode 100644 index 219841a..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp +++ /dev/null @@ -1,2 +0,0 @@ -// Common page 78 -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h deleted file mode 100644 index b9bfbf9..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h +++ /dev/null @@ -1,2 +0,0 @@ -// Common Page 79 -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.cpp deleted file mode 100644 index 0ffdd02..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.cpp +++ /dev/null @@ -1 +0,0 @@ -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.h b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.h deleted file mode 100644 index b9bfbf9..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.h +++ /dev/null @@ -1,2 +0,0 @@ -// Common Page 79 -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_OpenChannelCommandMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_OpenChannelCommandMsg.cpp deleted file mode 100644 index 0ffdd02..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_OpenChannelCommandMsg.cpp +++ /dev/null @@ -1 +0,0 @@ -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_OpenChannelCommandMsg.h b/src/CommonDataPages/TX/ANTPLUS_OpenChannelCommandMsg.h deleted file mode 100644 index 247a5a7..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_OpenChannelCommandMsg.h +++ /dev/null @@ -1,2 +0,0 @@ -// Common Page 74 -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_PairedDevicesMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_PairedDevicesMsg.cpp deleted file mode 100644 index 0ffdd02..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_PairedDevicesMsg.cpp +++ /dev/null @@ -1 +0,0 @@ -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_PairedDevicesMsg.h b/src/CommonDataPages/TX/ANTPLUS_PairedDevicesMsg.h deleted file mode 100644 index 3bc5cd6..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_PairedDevicesMsg.h +++ /dev/null @@ -1,2 +0,0 @@ -// Common Page 86 -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_ProductInformationMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_ProductInformationMsg.cpp deleted file mode 100644 index 7cd530f..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_ProductInformationMsg.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include -#include - -ProductInformationMsg::ProductInformationMsg() : BaseDataPageMsg(), BaseProductInformation() { - // TODO set default values - setDataBuffer(_buffer); - _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER; - _buffer[1] = 0xFF; -} - -void ProductInformationMsg::setSWRevisionSupplemental(uint8_t revision) { - set8BitValue(revision, - ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SWREVISIONSUPPLEMENTAL_BYTE); -} - -void ProductInformationMsg::setSWRevisionMain(uint8_t revision) { - set8BitValue(revision, - ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SWREVISIONMAIN_BYTE); -} - -void ProductInformationMsg::setSerialNumber(uint32_t serialNumber) { - set32BitValue(serialNumber, - ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SERIALNUMBER_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SERIALNUMBER_MSB_BYTE); -} diff --git a/src/CommonDataPages/TX/ANTPLUS_ProductInformationMsg.h b/src/CommonDataPages/TX/ANTPLUS_ProductInformationMsg.h deleted file mode 100644 index 1548ae4..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_ProductInformationMsg.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef ANTPLUS_PRODUCTINFORMATIONMSG_h -#define ANTPLUS_PRODUCTINFORMATIONMSG_h - -#include -#include - -#include "ANT.h" - -// Common page 81 - -class ProductInformationMsg : public BaseDataPageMsg, public BaseProductInformation { -public: - ProductInformationMsg(); - void setSWRevisionSupplemental(uint8_t revision); - void setSWRevisionMain(uint8_t revision); - void setSerialNumber(uint32_t serialNumber); -private: - uint8_t _buffer[MESSAGE_SIZE]; -}; - -#endif // ANTPLUS_PRODUCTINFORMATIONMSG_h diff --git a/src/CommonDataPages/TX/ANTPLUS_RequestDataPageMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_RequestDataPageMsg.cpp deleted file mode 100644 index 8c84e74..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_RequestDataPageMsg.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include -#include -#include -#include - -RequestDataPageMsg::RequestDataPageMsg() : BaseDataPageMsg(), BaseRequestDataPage() { - setDataBuffer(_buffer); - setDescriptorByte1(ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE1_INVALID); - setDescriptorByte2(ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE2_INVALID); - _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER; -} - -void RequestDataPageMsg::setSlaveSerialNumber(uint16_t serialNumber) { - this->set16BitValue(serialNumber, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_SLAVESERIALNUMBER_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_SLAVESERIALNUMBER_MSB_BYTE); -} - -void RequestDataPageMsg::setDescriptorByte1(uint8_t descriptorByte) { - _buffer[ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE1_BYTE] = descriptorByte; -} - -void RequestDataPageMsg::setDescriptorByte2(uint8_t descriptorByte) { - _buffer[ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE2_BYTE] = descriptorByte; -} - -void RequestDataPageMsg::setRequestedTransmissionResponseCount(uint8_t count) { - uint8_t temp = _buffer[ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_BYTE] & ~ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_COUNT_MASK; - _buffer[ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_BYTE] = temp | (count & ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_COUNT_MASK); -} - -void RequestDataPageMsg::setRequestedTransmissionUseAcknowledged(uint8_t useAcknowledged) { - uint8_t temp = _buffer[ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_BYTE] & ~ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_MASK; - _buffer[ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_BYTE] = temp | (useAcknowledged & ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_MASK); -} - -void RequestDataPageMsg::setRequestedPageNumber(uint8_t pageNumber) { - _buffer[ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDPAGENUMBER_BYTE] = pageNumber; -} - -void RequestDataPageMsg::setCommandType(uint8_t commandType) { - if (commandType != ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_COMMANDTYPE_REQUESTDATAPAGEFROMSLAVE) { - setSlaveSerialNumber(ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_SLAVESERIALNUMBER_INVALID); - } - _buffer[ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_COMMANDTYPE_BYTE] = commandType; -} diff --git a/src/CommonDataPages/TX/ANTPLUS_RequestDataPageMsg.h b/src/CommonDataPages/TX/ANTPLUS_RequestDataPageMsg.h deleted file mode 100644 index 3246eed..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_RequestDataPageMsg.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef ANTPLUS_REQUESTDATAPAGEMSG_h -#define ANTPLUS_REQUESTDATAPAGEMSG_h - -#include -#include - -#include "ANT.h" - -// Common Page 70 - -class RequestDataPageMsg : public BaseDataPageMsg, public BaseRequestDataPage { -public: - RequestDataPageMsg(); - void setSlaveSerialNumber(uint16_t serialNumber); - void setDescriptorByte1(uint8_t descriptorByte); - void setDescriptorByte2(uint8_t descriptorByte); - void setRequestedTransmissionResponseCount(uint8_t count); - void setRequestedTransmissionUseAcknowledged(uint8_t useAcknowledged); - void setRequestedPageNumber(uint8_t pageNumber); - void setCommandType(uint8_t commandType); -private: - uint8_t _buffer[MESSAGE_SIZE]; -}; - -#endif // ANTPLUS_REQUESTDATAPAGEMSG_h diff --git a/src/CommonDataPages/TX/ANTPLUS_SubfieldDataMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_SubfieldDataMsg.cpp deleted file mode 100644 index 0ffdd02..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_SubfieldDataMsg.cpp +++ /dev/null @@ -1 +0,0 @@ -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_SubfieldDataMsg.h b/src/CommonDataPages/TX/ANTPLUS_SubfieldDataMsg.h deleted file mode 100644 index 4fc4fa1..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_SubfieldDataMsg.h +++ /dev/null @@ -1,2 +0,0 @@ -// Common Page 84 -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_TimeAndDateMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_TimeAndDateMsg.cpp deleted file mode 100644 index 0ffdd02..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_TimeAndDateMsg.cpp +++ /dev/null @@ -1 +0,0 @@ -// TODO \ No newline at end of file diff --git a/src/CommonDataPages/TX/ANTPLUS_TimeAndDateMsg.h b/src/CommonDataPages/TX/ANTPLUS_TimeAndDateMsg.h deleted file mode 100644 index 3b701dd..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_TimeAndDateMsg.h +++ /dev/null @@ -1,2 +0,0 @@ -// Common Page 83 -// TODO \ No newline at end of file diff --git a/src/MainClasses/ANTPLUS_AntPlusRouter.cpp b/src/MainClasses/ANTPLUS_AntPlusRouter.cpp index 6123b67..e6d90d3 100644 --- a/src/MainClasses/ANTPLUS_AntPlusRouter.cpp +++ b/src/MainClasses/ANTPLUS_AntPlusRouter.cpp @@ -72,7 +72,7 @@ void AntPlusRouter::setProfile(uint8_t channel, BaseProfile* profile) { profile->setRouter(this); } -void AntPlusRouter::removeProfile(BaseProfile *profile) { +void AntPlusRouter::removeProfile(const BaseProfile *profile) { for (uint8_t i = 0; i < ANTPLUS_MAX_CHANNELS_POSSIBLE; i++) { if (_profiles[i] == profile) { removeProfileByChannel(i); @@ -181,19 +181,19 @@ void AntPlusRouter::startRxSearch(void(*callback)(uint16_t, uint8_t, uint8_t, ui OpenRxScanMode osm; _searchCallback = callback; stopAllProfiles(); - uc.setChannel(0); // TODO magic number (pull from ant-arduino once define is released) + uc.setChannel(OPEN_RX_SCAN_MODE_CHANNEL); send(uc); - ac.setChannel(0); + ac.setChannel(OPEN_RX_SCAN_MODE_CHANNEL); ac.setChannelType(CHANNEL_TYPE_UNIDIRECTIONAL_RECEIVE); ac.setChannelNetwork(ANTPLUS_NETWORKKEY_INDEX); send(ac); - ci.setChannel(0); + ci.setChannel(OPEN_RX_SCAN_MODE_CHANNEL); ci.setDeviceNumber(0); ci.setDeviceType(0); ci.setPairingBit(false); ci.setTransmissionType(0); send(ci); - crf.setChannel(0); + crf.setChannel(OPEN_RX_SCAN_MODE_CHANNEL); crf.setRfFrequency(ANTPLUS_CHANNEL_FREQUENCY); send(crf); lb.setConfig(LIB_CONFIG_RSSI | LIB_CONFIG_CHANNEL_ID); @@ -205,12 +205,12 @@ void AntPlusRouter::stopRxSearch() { LibConfig lb; CloseChannel cc; UnAssignChannel uc; - cc.setChannel(0); // TODO magic number (pull from ant-arduino once define is released) + cc.setChannel(OPEN_RX_SCAN_MODE_CHANNEL); send(cc); lb.setConfig(0); send(lb); flushMessages(); - uc.setChannel(0); + uc.setChannel(OPEN_RX_SCAN_MODE_CHANNEL); send(uc); // No need to reapply config as it will be sent on next begin call _searchCallback = NULL; diff --git a/src/MainClasses/ANTPLUS_AntPlusRouter.h b/src/MainClasses/ANTPLUS_AntPlusRouter.h index 0b131b9..3021da5 100644 --- a/src/MainClasses/ANTPLUS_AntPlusRouter.h +++ b/src/MainClasses/ANTPLUS_AntPlusRouter.h @@ -12,8 +12,8 @@ class BaseProfile; class AntPlusRouter { public: AntPlusRouter(); - AntPlusRouter(BaseAntWithCallbacks* driver); - AntPlusRouter(BaseAntWithCallbacks* driver, const uint8_t* key); + explicit AntPlusRouter(BaseAntWithCallbacks* driver); + explicit AntPlusRouter(BaseAntWithCallbacks* driver, const uint8_t* key); /** * Give the router a driver to use (Ant, NativeAnt, SpiAnt) */ @@ -39,7 +39,7 @@ class AntPlusRouter { * Unassigns channel * Removes the profile from index */ - void removeProfile(BaseProfile *profile); + void removeProfile(const BaseProfile *profile); /** * Stops a profile at the given channel * Unassigns channel diff --git a/src/Profiles/ANTPLUS_Profiles.h b/src/Profiles/ANTPLUS_Profiles.h index 6d96a05..2d08126 100644 --- a/src/Profiles/ANTPLUS_Profiles.h +++ b/src/Profiles/ANTPLUS_Profiles.h @@ -1,9 +1,13 @@ #ifndef ANTPLUS_PROFILES_h #define ANTPLUS_PROFILES_h +#include #include -#include #include +#include +#include #include +#include +#include #endif // ANTPLUS_ANTROUTER_h diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDataPages.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDataPages.h new file mode 100644 index 0000000..2af9bce --- /dev/null +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDataPages.h @@ -0,0 +1,10 @@ +#ifndef ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h +#define ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h + +#include +#include +#include +#include +#include + +#endif // ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h new file mode 100644 index 0000000..10426bd --- /dev/null +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h @@ -0,0 +1,48 @@ +#ifndef ANTPLUS_BICYCLEPOWERPROFILEDEFINES_h +#define ANTPLUS_BICYCLEPOWERPROFILEDEFINES_h + +#define ANTPLUS_BICYCLEPOWER_DEVICETYPE 11 + +/* Sensor Types */ +#define ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_POWERONLY 0 +#define ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUEWHEEL 1 +#define ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUECRANK 2 +#define ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_CTF 3 + +/* DataPage Defines */ +#define ANTPLUS_BICYCLEPOWER_DATAPAGES_GENERALCALIBRATION_NUMBER 0x01 + + +/* Standard Power Only */ +#define ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_NUMBER 0x10 + +#define ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_PEDALDIFFERENTIATION_RIGHT 1 +#define ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_PEDALPOWER_NOTUSED 0x7F +#define ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_INSTANTANEOUSCADENCE_INVALID 0xFF + + +/* Standard Wheel Torque */ +#define ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDWHEELTORQUE_NUMBER 0x11 + +#define ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDWHEELTORQUE_INSTANTANEOUSCADENCE_INVALID 0xFF + + +/* Standard Crank Torque */ +#define ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDCRANKTORQUE_NUMBER 0x12 + +#define ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDCRANKTORQUE_INSTANTANEOUSCADENCE_INVALID 0xFF + + +/* Torqyue and Pedal Smoothness */ +#define ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER 0x13 + +#define ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_TORQUEEFFECTIVENESS_INVALID 0xFF + +#define ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_PEDALSMOOTHNESS_INVALID 0xFF +#define ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_RIGHTPEDALSMOOTHNESS_COMBINED 0xFE + +/* Crank Torque Frequency */ +#define ANTPLUS_BICYCLEPOWER_DATAPAGES_CRANKTORQUEFREQUENCY_NUMBER 0x20 + + +#endif // ANTPLUS_BICYCLEPOWERPROFILEDEFINES_h diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h new file mode 100644 index 0000000..eb82f8b --- /dev/null +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h @@ -0,0 +1,11 @@ +#ifndef ANTPLUS_BICYCLEPOWERPROFILEPRIVATEDEFINES_h +#define ANTPLUS_BICYCLEPOWERPROFILEPRIVATEDEFINES_h + +#include + +/* Channel Config */ +#define BICYCLEPOWER_CHANNELPERIOD 8182 +// 30 / 2.5 = 12 +#define BICYCLEPOWER_SEARCHTIMEOUT 12 + +#endif // ANTPLUS_BICYCLEPOWERPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h new file mode 100644 index 0000000..1b2e5c8 --- /dev/null +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h @@ -0,0 +1,14 @@ +#ifndef ANTPLUS_BICYCLEPOWERPROFILE_h +#define ANTPLUS_BICYCLEPOWERPROFILE_h + +// General Definitions +#include + +// Datapages +#include + +// Profile Classes +#include +#include + +#endif // ANTPLUS_BICYCLEPOWERPROFILE_h diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.cpp new file mode 100644 index 0000000..a06dcb6 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.cpp @@ -0,0 +1,27 @@ +#include +#include +#include + +// TODO make second base class for callibration messages +#define UPDATEEVENTCOUNT_BYTE 1 + +BicyclePowerBaseMainDataPage::BicyclePowerBaseMainDataPage(AntRxDataResponse& dp) : + BaseDataPage(dp) {} + +uint8_t BicyclePowerBaseMainDataPage::getDataPageNumber() { + return this->get8BitValue(ANTPLUS_DEFAULT_DATAPAGE_BYTE); +} + +uint8_t BicyclePowerBaseMainDataPage::getUpdateEventCount() { + return this->get8BitValue(UPDATEEVENTCOUNT_BYTE); +} + +BicyclePowerBaseMainDataPageMsg::BicyclePowerBaseMainDataPageMsg(uint8_t dataPageNumber) : + BaseDataPageMsg() { + setDataBuffer(_buffer); + set8BitValue(dataPageNumber, ANTPLUS_DEFAULT_DATAPAGE_BYTE); +}; + +void BicyclePowerBaseMainDataPageMsg::setUpdateEventCount(uint8_t eventCount) { + set8BitValue(eventCount, UPDATEEVENTCOUNT_BYTE); +} diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.h new file mode 100644 index 0000000..a608dbc --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.h @@ -0,0 +1,22 @@ +#ifndef ANTPLUS_BICYCLEPOWERBASEMAINDATAPAGE_h +#define ANTPLUS_BICYCLEPOWERBASEMAINDATAPAGE_h + +#include +#include + +class BicyclePowerBaseMainDataPage : public BaseDataPage { +public: + explicit BicyclePowerBaseMainDataPage(AntRxDataResponse& dp); + uint8_t getDataPageNumber() override; + uint8_t getUpdateEventCount(); +}; + +class BicyclePowerBaseMainDataPageMsg : public BaseDataPageMsg { +public: + explicit BicyclePowerBaseMainDataPageMsg(uint8_t dataPageNumber); + void setUpdateEventCount(uint8_t eventCount); +protected: + uint8_t _buffer[MESSAGE_SIZE] = {0}; +}; + +#endif // ANTPLUS_BICYCLEPOWERPOWERONLYDATAPAGE_h diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.cpp new file mode 100644 index 0000000..d5921ce --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.cpp @@ -0,0 +1,53 @@ +#include +#include + +#define SLOPE_MSB_BYTE 2 +#define SLOPE_LSB_BYTE 3 +#define TIMESTAMP_MSB_BYTE 4 +#define TIMESTAMP_LSB_BYTE 5 +#define TORQUETICKSTAMP_MSB_BYTE 6 +#define TORQUETICKSTAMP_LSB_BYTE 7 + +template +BicyclePowerBaseCrankTorqueFrequency::BicyclePowerBaseCrankTorqueFrequency() : + CoreDataPage() {} + +template +uint16_t BicyclePowerBaseCrankTorqueFrequency::getSlope() { + return this->get16BitValue(SLOPE_LSB_BYTE, SLOPE_MSB_BYTE); +} + +template +uint16_t BicyclePowerBaseCrankTorqueFrequency::getTimeStamp() { + return this->get16BitValue(TIMESTAMP_LSB_BYTE, TIMESTAMP_MSB_BYTE); +} + +template +uint16_t BicyclePowerBaseCrankTorqueFrequency::getTorqueTicksStamp() { + return this->get16BitValue(TORQUETICKSTAMP_LSB_BYTE, + TORQUETICKSTAMP_MSB_BYTE); +} + +template class BicyclePowerBaseCrankTorqueFrequency; +template class BicyclePowerBaseCrankTorqueFrequency; + +BicyclePowerCrankTorqueFrequency::BicyclePowerCrankTorqueFrequency(AntRxDataResponse& dp) : + BicyclePowerBaseMainDataPage(dp), + BicyclePowerBaseCrankTorqueFrequency() {} + +BicyclePowerCrankTorqueFrequencyMsg::BicyclePowerCrankTorqueFrequencyMsg() : + BicyclePowerBaseMainDataPageMsg(ANTPLUS_BICYCLEPOWER_DATAPAGES_CRANKTORQUEFREQUENCY_NUMBER), + BicyclePowerBaseCrankTorqueFrequency() {} + +void BicyclePowerCrankTorqueFrequencyMsg::setSlope(uint16_t slope) { + set16BitValue(slope, SLOPE_LSB_BYTE, SLOPE_MSB_BYTE); +} + +void BicyclePowerCrankTorqueFrequencyMsg::setTimeStamp(uint16_t timestamp) { + set16BitValue(timestamp, TIMESTAMP_LSB_BYTE, TIMESTAMP_MSB_BYTE); +} + +void BicyclePowerCrankTorqueFrequencyMsg::setTorqueTicksStamp(uint16_t tickstamp) { + set16BitValue(tickstamp, TORQUETICKSTAMP_LSB_BYTE, + TORQUETICKSTAMP_MSB_BYTE); +} diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.h new file mode 100644 index 0000000..e16c309 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.h @@ -0,0 +1,32 @@ +#ifndef ANTPLUS_BICYCLEPOWERCRANKTORQUEFREQUENCY_h +#define ANTPLUS_BICYCLEPOWERCRANKTORQUEFREQUENCY_h + +#include + +template +class BicyclePowerBaseCrankTorqueFrequency : virtual public CoreDataPage { +public: + BicyclePowerBaseCrankTorqueFrequency(); + uint16_t getSlope(); + uint16_t getTimeStamp(); + uint16_t getTorqueTicksStamp(); +}; + +class BicyclePowerCrankTorqueFrequency : + public BicyclePowerBaseMainDataPage, + public BicyclePowerBaseCrankTorqueFrequency { +public: + explicit BicyclePowerCrankTorqueFrequency(AntRxDataResponse& dp); +}; + +class BicyclePowerCrankTorqueFrequencyMsg : + public BicyclePowerBaseMainDataPageMsg, + public BicyclePowerBaseCrankTorqueFrequency { +public: + BicyclePowerCrankTorqueFrequencyMsg(); + void setSlope(uint16_t slope); + void setTimeStamp(uint16_t timestamp); + void setTorqueTicksStamp(uint16_t tickstamp); +}; + +#endif // ANTPLUS_BICYCLEPOWERCRANKTORQUEFREQUENCY_h diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.cpp new file mode 100644 index 0000000..c46ab86 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.cpp @@ -0,0 +1,62 @@ +#include +#include + +#define CRANKTICKS_BYTE 2 +#define INSTANTANEOUSCADENCE_BYTE 3 +#define PERIOD_LSB_BYTE 4 +#define PERIOD_MSB_BYTE 5 +#define ACCUMULATEDTORQUE_LSB_BYTE 6 +#define ACCUMULATEDTORQUE_MSB_BYTE 7 + +template +BicyclePowerBaseStandardCrankTorque::BicyclePowerBaseStandardCrankTorque() : + CoreDataPage() {} + +template +uint8_t BicyclePowerBaseStandardCrankTorque::getCrankTicks() { + return this->get8BitValue(CRANKTICKS_BYTE); +} + +template +uint8_t BicyclePowerBaseStandardCrankTorque::getInstantaneousCadence() { + return this->get8BitValue(INSTANTANEOUSCADENCE_BYTE); +} + +template +uint16_t BicyclePowerBaseStandardCrankTorque::getCrankPeriod() { + return this->get16BitValue(PERIOD_LSB_BYTE, PERIOD_MSB_BYTE); +} + +template +uint16_t BicyclePowerBaseStandardCrankTorque::getAccumulatedTorque() { + return this->get16BitValue( + ACCUMULATEDTORQUE_LSB_BYTE, ACCUMULATEDTORQUE_MSB_BYTE); +} + +template class BicyclePowerBaseStandardCrankTorque; +template class BicyclePowerBaseStandardCrankTorque; + +BicyclePowerStandardCrankTorque::BicyclePowerStandardCrankTorque(AntRxDataResponse& dp) : + BicyclePowerBaseMainDataPage(dp), + BicyclePowerBaseStandardCrankTorque() {} + +BicyclePowerStandardCrankTorqueMsg::BicyclePowerStandardCrankTorqueMsg() : + BicyclePowerBaseMainDataPageMsg(ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDCRANKTORQUE_NUMBER), + BicyclePowerBaseStandardCrankTorque() { + setInstantaneousCadence(ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDCRANKTORQUE_INSTANTANEOUSCADENCE_INVALID); +} + +void BicyclePowerStandardCrankTorqueMsg::setCrankTicks(uint8_t ticks) { + set8BitValue(ticks, CRANKTICKS_BYTE); +} +void BicyclePowerStandardCrankTorqueMsg::setInstantaneousCadence(uint8_t cadence) { + set8BitValue(cadence, INSTANTANEOUSCADENCE_BYTE); +} + +void BicyclePowerStandardCrankTorqueMsg::setCrankPeriod(uint16_t period) { + set16BitValue(period, PERIOD_LSB_BYTE, PERIOD_MSB_BYTE); +} + +void BicyclePowerStandardCrankTorqueMsg::setAccumulatedTorque(uint16_t torque) { + set16BitValue(torque, ACCUMULATEDTORQUE_LSB_BYTE, ACCUMULATEDTORQUE_MSB_BYTE); +} diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.h new file mode 100644 index 0000000..2e7ec6d --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.h @@ -0,0 +1,34 @@ +#ifndef ANTPLUS_BICYCLEPOWERSTANDARDCRANKTORQUE_h +#define ANTPLUS_BICYCLEPOWERSTANDARDCRANKTORQUE_h + +#include + +template +class BicyclePowerBaseStandardCrankTorque : virtual public CoreDataPage { +public: + BicyclePowerBaseStandardCrankTorque(); + uint8_t getCrankTicks(); + uint8_t getInstantaneousCadence(); + uint16_t getCrankPeriod(); + uint16_t getAccumulatedTorque(); +}; + +class BicyclePowerStandardCrankTorque : + public BicyclePowerBaseMainDataPage, + public BicyclePowerBaseStandardCrankTorque { +public: + explicit BicyclePowerStandardCrankTorque(AntRxDataResponse& dp); +}; + +class BicyclePowerStandardCrankTorqueMsg : + public BicyclePowerBaseMainDataPageMsg, + public BicyclePowerBaseStandardCrankTorque { +public: + BicyclePowerStandardCrankTorqueMsg(); + void setCrankTicks(uint8_t ticks); + void setInstantaneousCadence(uint8_t cadence); + void setCrankPeriod(uint16_t period); + void setAccumulatedTorque(uint16_t torque); +}; + +#endif // ANTPLUS_BICYCLEPOWERSTANDARDCRANKTORQUE_h diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp new file mode 100644 index 0000000..f458b84 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp @@ -0,0 +1,86 @@ +#include +#include +#include +#include + +#define PEDALPOWER_BYTE 2 +#define PEDALPOWER_MASK 0x7F +#define PEDALDIFFERENTIATION_BYTE 2 +#define PEDALDIFFERENTIATION_MASK 0x80 +#define PEDALDIFFERENTIATION_SHIFT 7 +#define INSTANTANEOUSCADENCE_BYTE 3 +#define ACCUMULATEDPOWER_LSB_BYTE 4 +#define ACCUMULATEDPOWER_MSB_BYTE 5 +#define INSTANTANEOUSPOWER_LSB_BYTE 6 +#define INSTANTANEOUSPOWER_MSB_BYTE 7 + +template +BicyclePowerBaseStandardPowerOnly::BicyclePowerBaseStandardPowerOnly() : + CoreDataPage() {} + +template +uint8_t BicyclePowerBaseStandardPowerOnly::getPedalPower() { + return this->get8BitValue(PEDALPOWER_BYTE, PEDALPOWER_MASK); +} + +template +uint8_t BicyclePowerBaseStandardPowerOnly::getPedalDifferentiation() { + return this->get8BitValue(PEDALDIFFERENTIATION_BYTE, + PEDALDIFFERENTIATION_MASK, + PEDALDIFFERENTIATION_SHIFT); +} + +template +uint8_t BicyclePowerBaseStandardPowerOnly::getInstantaneousCadence() { + return this->get8BitValue(INSTANTANEOUSCADENCE_BYTE); +} + +template +uint16_t BicyclePowerBaseStandardPowerOnly::getAccumulatedPower() { + return this->get16BitValue( + ACCUMULATEDPOWER_LSB_BYTE, ACCUMULATEDPOWER_MSB_BYTE); +} + +template +uint16_t BicyclePowerBaseStandardPowerOnly::getInstantaneousPower() { + return this->get16BitValue( + INSTANTANEOUSPOWER_LSB_BYTE, INSTANTANEOUSPOWER_MSB_BYTE); +} + +template class BicyclePowerBaseStandardPowerOnly; +template class BicyclePowerBaseStandardPowerOnly; + +BicyclePowerStandardPowerOnly::BicyclePowerStandardPowerOnly(AntRxDataResponse& dp) : + BicyclePowerBaseMainDataPage(dp), + BicyclePowerBaseStandardPowerOnly() {} + +BicyclePowerStandardPowerOnlyMsg::BicyclePowerStandardPowerOnlyMsg() : + BicyclePowerBaseMainDataPageMsg(ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_NUMBER), + BicyclePowerBaseStandardPowerOnly() { + setPedalPower(ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_PEDALPOWER_NOTUSED); + setPedalDifferentiation(ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_PEDALDIFFERENTIATION_RIGHT); + setInstantaneousCadence(ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_INSTANTANEOUSCADENCE_INVALID); +} + +void BicyclePowerStandardPowerOnlyMsg::setPedalPower(uint8_t pedalPower) { + set8BitValue(pedalPower, PEDALPOWER_BYTE, PEDALPOWER_MASK); +} + +void BicyclePowerStandardPowerOnlyMsg::setPedalDifferentiation(uint8_t differentiation) { + set8BitValue(differentiation, + PEDALDIFFERENTIATION_BYTE, + PEDALDIFFERENTIATION_MASK, + PEDALDIFFERENTIATION_SHIFT); +} + +void BicyclePowerStandardPowerOnlyMsg::setInstantaneousCadence(uint8_t cadence) { + set8BitValue(cadence, INSTANTANEOUSCADENCE_BYTE); +} + +void BicyclePowerStandardPowerOnlyMsg::setAccumulatedPower(uint16_t accPower) { + set16BitValue(accPower, ACCUMULATEDPOWER_LSB_BYTE, ACCUMULATEDPOWER_MSB_BYTE); +} + +void BicyclePowerStandardPowerOnlyMsg::setInstantaneousPower(uint16_t instantaneousPower) { + set16BitValue(instantaneousPower, INSTANTANEOUSPOWER_LSB_BYTE, INSTANTANEOUSPOWER_MSB_BYTE); +} diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.h new file mode 100644 index 0000000..a401189 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.h @@ -0,0 +1,32 @@ +#ifndef ANTPLUS_BICYCLEPOWERSTANDARDPOWERONLY_h +#define ANTPLUS_BICYCLEPOWERSTANDARDPOWERONLY_h + +#include + +template +class BicyclePowerBaseStandardPowerOnly : virtual public CoreDataPage { +public: + BicyclePowerBaseStandardPowerOnly(); + uint8_t getPedalPower(); + uint8_t getPedalDifferentiation(); + uint8_t getInstantaneousCadence(); + uint16_t getAccumulatedPower(); + uint16_t getInstantaneousPower(); +}; + +class BicyclePowerStandardPowerOnly : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseStandardPowerOnly { +public: + explicit BicyclePowerStandardPowerOnly(AntRxDataResponse& dp); +}; + +class BicyclePowerStandardPowerOnlyMsg : public BicyclePowerBaseMainDataPageMsg, public BicyclePowerBaseStandardPowerOnly { +public: + BicyclePowerStandardPowerOnlyMsg(void); + void setPedalPower(uint8_t pedalPower); + void setPedalDifferentiation(uint8_t differentiation); + void setInstantaneousCadence(uint8_t cadence); + void setAccumulatedPower(uint16_t accPower); + void setInstantaneousPower(uint16_t instantaneousPower); +}; + +#endif // ANTPLUS_BICYCLEPOWERSTANDARDPOWERONLY_h diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.cpp new file mode 100644 index 0000000..54b0698 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.cpp @@ -0,0 +1,64 @@ +#include +#include + +#define WHEELTICKS_BYTE 2 +#define INSTANTANEOUSCADENCE_BYTE 3 +#define WHEELPERIOD_LSB_BYTE 4 +#define WHEELPERIOD_MSB_BYTE 5 +#define ACCUMULATEDTORQUE_LSB_BYTE 6 +#define ACCUMULATEDTORQUE_MSB_BYTE 7 + +template +BicyclePowerBaseStandardWheelTorque::BicyclePowerBaseStandardWheelTorque() : + CoreDataPage() {} + +template +uint8_t BicyclePowerBaseStandardWheelTorque::getWheelTicks() { + return this->get8BitValue(WHEELTICKS_BYTE); +} + +template +uint8_t BicyclePowerBaseStandardWheelTorque::getInstantaneousCadence() { + return this->get8BitValue(INSTANTANEOUSCADENCE_BYTE); +} + +template +uint16_t BicyclePowerBaseStandardWheelTorque::getWheelPeriod() { + return this->get16BitValue(WHEELPERIOD_LSB_BYTE, WHEELPERIOD_MSB_BYTE); +} + +template +uint16_t BicyclePowerBaseStandardWheelTorque::getAccumulatedTorque() { + return this->get16BitValue( + ACCUMULATEDTORQUE_LSB_BYTE, ACCUMULATEDTORQUE_MSB_BYTE); +} + +template class BicyclePowerBaseStandardWheelTorque; +template class BicyclePowerBaseStandardWheelTorque; + +BicyclePowerStandardWheelTorque::BicyclePowerStandardWheelTorque(AntRxDataResponse& dp) : + BicyclePowerBaseMainDataPage(dp), + BicyclePowerBaseStandardWheelTorque() {} + +BicyclePowerStandardWheelTorqueMsg::BicyclePowerStandardWheelTorqueMsg() : + BicyclePowerBaseMainDataPageMsg(ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDWHEELTORQUE_NUMBER), + BicyclePowerBaseStandardWheelTorque() { + setInstantaneousCadence(ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDWHEELTORQUE_INSTANTANEOUSCADENCE_INVALID); +} + +void BicyclePowerStandardWheelTorqueMsg::setWheelTicks(uint8_t ticks) { + set8BitValue(ticks, WHEELTICKS_BYTE); +} + +void BicyclePowerStandardWheelTorqueMsg::setInstantaneousCadence(uint8_t cadence) { + set8BitValue(cadence, INSTANTANEOUSCADENCE_BYTE); +} + +void BicyclePowerStandardWheelTorqueMsg::setWheelPeriod(uint16_t period) { + set16BitValue(period, WHEELPERIOD_LSB_BYTE, WHEELPERIOD_MSB_BYTE); +} + +void BicyclePowerStandardWheelTorqueMsg::setAccumulatedTorque(uint16_t torque) { + set16BitValue(torque, ACCUMULATEDTORQUE_LSB_BYTE, + ACCUMULATEDTORQUE_MSB_BYTE); +} diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.h new file mode 100644 index 0000000..ab80491 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.h @@ -0,0 +1,34 @@ +#ifndef ANTPLUS_BICYCLEPOWERSTANDARDWHEELTORQUE_h +#define ANTPLUS_BICYCLEPOWERSTANDARDWHEELTORQUE_h + +#include + +template +class BicyclePowerBaseStandardWheelTorque : virtual public CoreDataPage { +public: + BicyclePowerBaseStandardWheelTorque(); + uint8_t getWheelTicks(); + uint8_t getInstantaneousCadence(); + uint16_t getWheelPeriod(); + uint16_t getAccumulatedTorque(); +}; + +class BicyclePowerStandardWheelTorque : + public BicyclePowerBaseMainDataPage, + public BicyclePowerBaseStandardWheelTorque { +public: + explicit BicyclePowerStandardWheelTorque(AntRxDataResponse& dp); +}; + +class BicyclePowerStandardWheelTorqueMsg : + public BicyclePowerBaseMainDataPageMsg, + public BicyclePowerBaseStandardWheelTorque { +public: + BicyclePowerStandardWheelTorqueMsg(); + void setWheelTicks(uint8_t ticks); + void setInstantaneousCadence(uint8_t cadence); + void setWheelPeriod(uint16_t period); + void setAccumulatedTorque(uint16_t torque); +}; + +#endif // ANTPLUS_BICYCLEPOWERSTANDARDWHEELTORQUE_h diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.cpp new file mode 100644 index 0000000..e656c6f --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.cpp @@ -0,0 +1,63 @@ +#include +#include + +#define LEFTEFFECTIVENESS_BYTE 2 +#define RIGHTEFFECTIVENESS_BYTE 3 +#define LEFTSMOOTHNESS_BYTE 4 +#define RIGHTSMOOTHNESS_BYTE 5 + +template +BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness::BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness() : + CoreDataPage() {} + +template +uint8_t BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness::getLeftTorqueEffectiveness() { + return this->get8BitValue(LEFTEFFECTIVENESS_BYTE); +} + +template +uint8_t BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness::getRightTorqueEffectiveness() { + return this->get8BitValue(RIGHTEFFECTIVENESS_BYTE); +} + +template +uint8_t BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness::getLeftPedalSmoothness() { + return this->get8BitValue(LEFTSMOOTHNESS_BYTE); +} + +template +uint8_t BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness::getRightPedalSmoothness() { + return this->get8BitValue(RIGHTSMOOTHNESS_BYTE); +} + +template class BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness; +template class BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness; + +BicyclePowerTorqueEffectivenessAndPedalSmoothness::BicyclePowerTorqueEffectivenessAndPedalSmoothness(AntRxDataResponse& dp) : + BicyclePowerBaseMainDataPage(dp), + BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness() {} + +BicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg::BicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg() : + BicyclePowerBaseMainDataPageMsg(ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER), + BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness() { + setLeftTorqueEffectiveness(ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_TORQUEEFFECTIVENESS_INVALID); + setRightTorqueEffectiveness(ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_TORQUEEFFECTIVENESS_INVALID); + setLeftPedalSmoothness(ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_PEDALSMOOTHNESS_INVALID); + setRightPedalSmoothness(ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_PEDALSMOOTHNESS_INVALID); +} + +void BicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg::setLeftTorqueEffectiveness(uint8_t effectiveness) { + set8BitValue(effectiveness, LEFTEFFECTIVENESS_BYTE); +} + +void BicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg::setRightTorqueEffectiveness(uint8_t effectiveness) { + set8BitValue(effectiveness, RIGHTEFFECTIVENESS_BYTE); +} + +void BicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg::setLeftPedalSmoothness(uint8_t smoothness) { + set8BitValue(smoothness, LEFTSMOOTHNESS_BYTE); +} + +void BicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg::setRightPedalSmoothness(uint8_t smoothness) { + set8BitValue(smoothness, RIGHTSMOOTHNESS_BYTE); +} diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.h new file mode 100644 index 0000000..de0a376 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.h @@ -0,0 +1,35 @@ +#ifndef ANTPLUS_BICYCLEPOWERPEDALSMOOTHNESS_h +#define ANTPLUS_BICYCLEPOWERPEDALSMOOTHNESS_h + +#include + +template +class BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness : + virtual public CoreDataPage { +public: + BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness(); + uint8_t getLeftTorqueEffectiveness(); + uint8_t getRightTorqueEffectiveness(); + uint8_t getLeftPedalSmoothness(); + uint8_t getRightPedalSmoothness(); +}; + +class BicyclePowerTorqueEffectivenessAndPedalSmoothness : + public BicyclePowerBaseMainDataPage, + public BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness { +public: + explicit BicyclePowerTorqueEffectivenessAndPedalSmoothness(AntRxDataResponse& dp); +}; + +class BicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg : + public BicyclePowerBaseMainDataPageMsg, + public BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness { +public: + BicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg(); + void setLeftTorqueEffectiveness(uint8_t effectiveness); + void setRightTorqueEffectiveness(uint8_t effectiveness); + void setLeftPedalSmoothness(uint8_t smoothness); + void setRightPedalSmoothness(uint8_t smoothness); +}; + +#endif // ANTPLUS_BICYCLEPOWERPEDALSMOOTHNESS_h diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp new file mode 100644 index 0000000..a9eed11 --- /dev/null +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp @@ -0,0 +1,108 @@ +#include +#include +#include +#include + +#define DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE + +ProfileBicyclePowerDisplay::ProfileBicyclePowerDisplay(uint16_t deviceNumber, uint8_t transmissionType) : BaseSlaveProfile(deviceNumber, transmissionType) { + setChannelConfig(); +} + +void ProfileBicyclePowerDisplay::onBroadcastData(BroadcastData& msg) { + BicyclePowerBaseMainDataPage dp = BicyclePowerBaseMainDataPage(msg); + BaseProfile::onBroadcastData(msg); + if (!handleDataPage(dp)) { + callOnOtherDataPage(msg); + } +} + +bool ProfileBicyclePowerDisplay::handleDataPage(BicyclePowerBaseMainDataPage& dp) { + uint8_t dataPage = dp.getDataPageNumber(); + bool called = false; + + switch (dataPage) { + case ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER: + called = handleManufacturersInformation(dp); + break; + case ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER: + called = handleProductInformation(dp); + break; + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER: + called = handleBatteryStatus(dp); + break; + case ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_NUMBER: + called = handleStandardPowerOnly(dp); + break; + case ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDCRANKTORQUE_NUMBER: + called = handleStandardCrankTorque(dp); + break; + case ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDWHEELTORQUE_NUMBER: + called = handleStandardWheelTorque(dp); + break; + case ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: + called = handleTorqueEffectivenessAndPedalSmoothness(dp); + break; + case ANTPLUS_BICYCLEPOWER_DATAPAGES_CRANKTORQUEFREQUENCY_NUMBER: + called = handleCrankTorqueFrequency(dp); + break; + } + + return called; +} + +void ProfileBicyclePowerDisplay::onAcknowledgedData(AcknowledgedData& msg) { + BicyclePowerBaseMainDataPage dp = BicyclePowerBaseMainDataPage(msg); + BaseProfile::onAcknowledgedData(msg); + if (!handleDataPage(dp)) { + callOnOtherDataPage(msg); + } +} + + +void ProfileBicyclePowerDisplay::setChannelConfig() { + setChannelType(DISPLAY_CHANNELTYPE); + setDeviceType(ANTPLUS_BICYCLEPOWER_DEVICETYPE); + setChannelPeriod(BICYCLEPOWER_CHANNELPERIOD); + setSearchTimeout(BICYCLEPOWER_SEARCHTIMEOUT); +} + +bool ProfileBicyclePowerDisplay::handleBatteryStatus(BicyclePowerBaseMainDataPage& dataPage) { + BatteryStatus dp(dataPage); + return _onBatteryStatus.call(dp); +} + +bool ProfileBicyclePowerDisplay::handleManufacturersInformation(BicyclePowerBaseMainDataPage& dataPage) { + ManufacturersInformation dp(dataPage); + return _onManufacturersInformation.call(dp); +} + +bool ProfileBicyclePowerDisplay::handleProductInformation(BicyclePowerBaseMainDataPage& dataPage) { + ProductInformation dp(dataPage); + return _onProductInformation.call(dp); +} + +bool ProfileBicyclePowerDisplay::handleStandardPowerOnly(BicyclePowerBaseMainDataPage& dataPage) { + BicyclePowerStandardPowerOnly dp(dataPage); + return _onBicyclePowerStandardPowerOnly.call(dp); +} + +bool ProfileBicyclePowerDisplay::handleStandardCrankTorque(BicyclePowerBaseMainDataPage& dataPage) { + BicyclePowerStandardCrankTorque dp(dataPage); + return _onBicyclePowerStandardCrankTorque.call(dp); +} + +bool ProfileBicyclePowerDisplay::handleCrankTorqueFrequency(BicyclePowerBaseMainDataPage& dataPage) { + BicyclePowerCrankTorqueFrequency dp(dataPage); + return _onBicyclePowerCrankTorqueFrequency.call(dp); +} + +bool ProfileBicyclePowerDisplay::handleStandardWheelTorque(BicyclePowerBaseMainDataPage& dataPage) { + BicyclePowerStandardWheelTorque dp(dataPage); + return _onBicyclePowerStandardWheelTorque.call(dp); +} + +bool ProfileBicyclePowerDisplay::handleTorqueEffectivenessAndPedalSmoothness(BicyclePowerBaseMainDataPage& dataPage) { + BicyclePowerTorqueEffectivenessAndPedalSmoothness dp(dataPage); + return _onBicyclePowerTorqueEffectivenessAndPedalSmoothness.call(dp); +} diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.h b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.h new file mode 100644 index 0000000..be4bc17 --- /dev/null +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.h @@ -0,0 +1,45 @@ +#ifndef ANTPLUS_PROFILEBICYCLEPOWERDISPLAY_h +#define ANTPLUS_PROFILEBICYCLEPOWERDISPLAY_h + +#include +#include +#include + +class ProfileBicyclePowerDisplay : public BaseSlaveProfile { +public: + ProfileBicyclePowerDisplay(uint16_t deviceNumber = 0, uint8_t transmissionType = 0); + void onBatteryStatus(void (*func)(BatteryStatus&, uintptr_t), uintptr_t data = 0) { _onBatteryStatus.set(func, data); } + void onManufacturersInformation(void (*func)(ManufacturersInformation&, uintptr_t), uintptr_t data = 0) { _onManufacturersInformation.set(func, data); } + void onProductInformation(void (*func)(ProductInformation&, uintptr_t), uintptr_t data = 0) { _onProductInformation.set(func, data); } + void onBicyclePowerStandardPowerOnly(void (*func)(BicyclePowerStandardPowerOnly&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerStandardPowerOnly.set(func, data); } + void onBicyclePowerStandardCrankTorque(void (*func)(BicyclePowerStandardCrankTorque&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerStandardCrankTorque.set(func, data); } + void onBicyclePowerStandardWheelTorque(void (*func)(BicyclePowerStandardWheelTorque&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerStandardWheelTorque.set(func, data); } + void onBicyclePowerCrankTorqueFrequency(void (*func)(BicyclePowerCrankTorqueFrequency&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerCrankTorqueFrequency.set(func, data); } + void onBicyclePowerTorqueEffectivenessAndPedalSmoothness(void (*func)(BicyclePowerTorqueEffectivenessAndPedalSmoothness&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerTorqueEffectivenessAndPedalSmoothness.set(func, data); } + +private: + void setChannelConfig(); + void onBroadcastData(BroadcastData& msg) override; + void onAcknowledgedData(AcknowledgedData& msg) override; + + bool handleDataPage(BicyclePowerBaseMainDataPage& dp); + + bool handleBatteryStatus(BicyclePowerBaseMainDataPage& dataPage); + bool handleManufacturersInformation(BicyclePowerBaseMainDataPage& dataPage); + bool handleProductInformation(BicyclePowerBaseMainDataPage& dataPage); + bool handleStandardPowerOnly(BicyclePowerBaseMainDataPage& dataPage); + bool handleStandardCrankTorque(BicyclePowerBaseMainDataPage& dataPage); + bool handleCrankTorqueFrequency(BicyclePowerBaseMainDataPage& dataPage); + bool handleStandardWheelTorque(BicyclePowerBaseMainDataPage& dataPage); + bool handleTorqueEffectivenessAndPedalSmoothness(BicyclePowerBaseMainDataPage& dataPage); + AntCallback _onBatteryStatus = { .func = NULL }; + AntCallback _onManufacturersInformation = { .func = NULL }; + AntCallback _onProductInformation = { .func = NULL }; + AntCallback _onBicyclePowerStandardPowerOnly = { .func = NULL }; + AntCallback _onBicyclePowerStandardCrankTorque = { .func = NULL }; + AntCallback _onBicyclePowerCrankTorqueFrequency = { .func = NULL }; + AntCallback _onBicyclePowerStandardWheelTorque = { .func = NULL }; + AntCallback _onBicyclePowerTorqueEffectivenessAndPedalSmoothness = { .func = NULL }; +}; + +#endif // ANTPLUS_PROFILEBICYCLEPOWERDISPLAY_h diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp new file mode 100644 index 0000000..fe28935 --- /dev/null +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -0,0 +1,284 @@ +#include +#include +#include +#include +#include + +#define SENSOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT +#define SENSOR_TRANSMISSIONTYPE (TRANSMISSION_TYPE_INDEPENDENT | TRANSMISSION_TYPE_GLOBALDATAPGESUSED) + +#define FLAGS_SENSORTYPE(x) (x & 0x3) + +ProfileBicyclePowerSensor::ProfileBicyclePowerSensor( + uint16_t deviceNumber, + uint8_t transmissionType, + uint32_t flags) : + BaseMasterProfile(deviceNumber, + ANTPLUS_TRANSMISSION_SET_LSN( + transmissionType, SENSOR_TRANSMISSIONTYPE)), + _flags(flags) { + setChannelConfig(); +} + +void ProfileBicyclePowerSensor::onBroadcastData(BroadcastData& msg) { + BicyclePowerStandardPowerOnly dp(msg); + uint8_t dataPage = dp.getDataPageNumber(); + bool called = false; + + BaseMasterProfile::onBroadcastData(msg); + + switch (dataPage) { + // Display always should be using acknowledged messages + } + + if (!called) { + callOnOtherDataPage(msg); + } +} + +void ProfileBicyclePowerSensor::onAcknowledgedData(AcknowledgedData& msg) { + BicyclePowerStandardPowerOnly dp(msg); + uint8_t dataPage = dp.getDataPageNumber(); + bool called = false; + + BaseMasterProfile::onAcknowledgedData(msg); + switch (dataPage) { + + case ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER: + called = handleRequestDataPage(dp); + break; + case ANTPLUS_BICYCLEPOWER_DATAPAGES_GENERALCALIBRATION_NUMBER: + called = handleGeneralCalibration(dp); + break; + } + if (!called) { + callOnOtherDataPage(msg); + } +} + +void ProfileBicyclePowerSensor::transmitNextDataPage() { + uint8_t page = 0; + uint8_t sensorType = FLAGS_SENSORTYPE(_flags); + + if (isRequestedPagePending()) { + transmitDataPage(getRequestedPage()); + return; + } + + _patternStep++; + if (_patternStep == 120) { + _patternStep = 0; + } + + switch (sensorType) { + case ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_POWERONLY: + page = getNextPowerOnlySensorPage(); + break; + case ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUEWHEEL: + case ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUECRANK: + page = getNextTorqueSensorPage(); + break; + case ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_CTF: + page = ANTPLUS_BICYCLEPOWER_DATAPAGES_CRANKTORQUEFREQUENCY_NUMBER; + break; + } + + transmitDataPage(page); +} + +uint8_t ProfileBicyclePowerSensor::getNextPowerOnlySensorPage() { + uint8_t backgroundPage; + uint8_t mod_five = _patternStep % 5; + + if ((mod_five == 0) && _createBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg.func) { + /* Interleave every 5th message if implemented */ + return ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER; + } + + backgroundPage = getBackgroundPage(); + if (backgroundPage) { + return backgroundPage; + } + return ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_NUMBER; +} + +uint8_t ProfileBicyclePowerSensor::getNextTorqueSensorPage() { + uint8_t backgroundPage; + uint8_t mod_five = _patternStep % 5; + + if (mod_five == 0) { + /* Interleave every 5th message */ + return ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_NUMBER; + } else if ((mod_five == 1) && _createBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg.func) { + /* Interleave every 5th message if implemented */ + return ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER; + } + + backgroundPage = getBackgroundPage(); + if (backgroundPage) { + return backgroundPage; + } + + return FLAGS_SENSORTYPE(_flags) == ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUECRANK ? + ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDCRANKTORQUE_NUMBER : + ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDWHEELTORQUE_NUMBER; +} + + +bool ProfileBicyclePowerSensor::handleRequestDataPage(BicyclePowerStandardPowerOnly& dataPage) { + RequestDataPage dp(dataPage); + return _onRequestDataPage.call(dp); +} + +bool ProfileBicyclePowerSensor::handleGeneralCalibration(BicyclePowerStandardPowerOnly& dataPage) { + // TODO + return false; +} + +void ProfileBicyclePowerSensor::transmitBicyclePowerStandardPowerOnlyMsg() { + BicyclePowerStandardPowerOnlyMsg msg; + _createBicyclePowerStandardPowerOnlyMsg.call(msg); + transmitMsg(msg); +} + +void ProfileBicyclePowerSensor::transmitBicyclePowerStandardWheelTorqueMsg() { + BicyclePowerStandardWheelTorqueMsg msg; + _createBicyclePowerStandardWheelTorqueMsg.call(msg); + transmitMsg(msg); +} + +void ProfileBicyclePowerSensor::transmitBicyclePowerStandardCrankTorqueMsg() { + BicyclePowerStandardCrankTorqueMsg msg; + _createBicyclePowerStandardCrankTorqueMsg.call(msg); + transmitMsg(msg); +} + +void ProfileBicyclePowerSensor::transmitBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg() { + BicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg msg; + _createBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg.call(msg); + transmitMsg(msg); +} + +void ProfileBicyclePowerSensor::transmitBicyclePowerCrankTorqueFrequencyMsg() { + BicyclePowerCrankTorqueFrequencyMsg msg; + _createBicyclePowerCrankTorqueFrequencyMsg.call(msg); + transmitMsg(msg); +} + +void ProfileBicyclePowerSensor::transmitBatteryStatusMsg() { + BatteryStatusMsg msg; + _createBatteryStatusMsg.call(msg); + transmitMsg(msg); +} + +void ProfileBicyclePowerSensor::transmitProductInfomrationMsg() { + ProductInformationMsg msg; + _createProductInformationMsg.call(msg); + transmitMsg(msg); +} + +void ProfileBicyclePowerSensor::transmitManufacturesInformationMsg() { + ManufacturersInformationMsg msg; + _createManufacturersInformationMsg.call(msg); + transmitMsg(msg); +} + +void ProfileBicyclePowerSensor::transmitBicyclePowerGeneralCalibrationResponse() { + // TODO +} + +uint8_t ProfileBicyclePowerSensor::getBackgroundPage() { + /* Note: on logic behind numbers here + * + * Messages are on 5 page period, so first 2 slots (i.e N % 5 = 0 and N % 5 = 1) are + * Main page 1 + * Main page 2 + * These slots may not actually be used but given this is configurable this makes it safe + * + * last 3 slots are synced in background pages in sub minimum requirement + * The magic numbers are N % 5 > 1 and are within the period assuming the counter + * resets on a 120 message period + * + * Verification + * 118 % 5 = 3 + * 119 % 5 = 4 + * 33 % 5 = 3 + * 93 % 5 = 3 + * */ + + if (_patternStep == 118) { + return ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER; + } + + if (_patternStep == 119) { + return ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER; + } + + if ((_patternStep == 33 || _patternStep == 93) && _createBatteryStatusMsg.func) { + return ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER; + } + + /* we don't have anything to transmit */ + return 0; +} + +void ProfileBicyclePowerSensor::transmitDataPage(uint8_t page) { + switch (page) { + // TODO calibration datapages + case ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_NUMBER: + transmitBicyclePowerStandardPowerOnlyMsg(); + break; + case ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDWHEELTORQUE_NUMBER: + transmitBicyclePowerStandardWheelTorqueMsg(); + break; + case ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDCRANKTORQUE_NUMBER: + transmitBicyclePowerStandardCrankTorqueMsg(); + break; + case ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: + transmitBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg(); + break; + case ANTPLUS_BICYCLEPOWER_DATAPAGES_CRANKTORQUEFREQUENCY_NUMBER: + transmitBicyclePowerCrankTorqueFrequencyMsg(); + break; + case ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER: + transmitProductInfomrationMsg(); + break; + case ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER: + transmitManufacturesInformationMsg(); + break; + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER: + transmitBatteryStatusMsg(); + break; + } +} + +void ProfileBicyclePowerSensor::setChannelConfig() { + setChannelType(SENSOR_CHANNELTYPE); + setDeviceType(ANTPLUS_BICYCLEPOWER_DEVICETYPE); + setChannelPeriod(BICYCLEPOWER_CHANNELPERIOD); + setSearchTimeout(BICYCLEPOWER_SEARCHTIMEOUT); +} + +bool ProfileBicyclePowerSensor::isDataPageValid(uint8_t dataPage) { + // TODO calibration data pages + switch (dataPage) { + case ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_NUMBER: + return FLAGS_SENSORTYPE(_flags) != ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_CTF; + case ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDWHEELTORQUE_NUMBER: + return FLAGS_SENSORTYPE(_flags) == ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUEWHEEL; + case ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDCRANKTORQUE_NUMBER: + return FLAGS_SENSORTYPE(_flags) == ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUECRANK; + case ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: + return FLAGS_SENSORTYPE(_flags) != ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_CTF && + (bool)_createBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg.func; + case ANTPLUS_BICYCLEPOWER_DATAPAGES_CRANKTORQUEFREQUENCY_NUMBER: + return FLAGS_SENSORTYPE(_flags) == ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_CTF; + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER: + return (bool)_createBatteryStatusMsg.func; + case ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER: + return true; + default: + return false; + } +} diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h new file mode 100644 index 0000000..0c5d013 --- /dev/null +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h @@ -0,0 +1,61 @@ +#ifndef ANTPLUS_PROFILEBICYCLEPOWERSENSOR_h +#define ANTPLUS_PROFILEBICYCLEPOWERSENSOR_h + +#include +#include +#include + +class ProfileBicyclePowerSensor : public BaseMasterProfile { +public: + explicit ProfileBicyclePowerSensor(uint16_t deviceNumber, uint8_t transmissionType = 0, uint32_t flags = 0); + /** + * Register callback to populate default data messages (Datapage 0) + */ + void createBicyclePowerStandardPowerOnlyMsg(void (*func)(BicyclePowerStandardPowerOnlyMsg&, uintptr_t), uintptr_t data = 0) { _createBicyclePowerStandardPowerOnlyMsg.set(func, data); } + void createBicyclePowerStandardWheelTorqueMsg(void (*func)(BicyclePowerStandardWheelTorqueMsg&, uintptr_t), uintptr_t data = 0) { _createBicyclePowerStandardWheelTorqueMsg.set(func, data); } + void createBicyclePowerStandardCrankTorqueMsg(void (*func)(BicyclePowerStandardCrankTorqueMsg&, uintptr_t), uintptr_t data = 0) { _createBicyclePowerStandardCrankTorqueMsg.set(func, data); } + void createBicyclePowerCrankTorqueFrequencyMsg(void (*func)(BicyclePowerCrankTorqueFrequencyMsg&, uintptr_t), uintptr_t data = 0) { _createBicyclePowerCrankTorqueFrequencyMsg.set(func, data); } + void createBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg(void (*func)(BicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg&, uintptr_t), uintptr_t data = 0) { _createBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg.set(func, data); } + void createBatteryStatusMsg(void (*func)(BatteryStatusMsg&, uintptr_t), uintptr_t data = 0) { _createBatteryStatusMsg.set(func, data); } + void createProductInformationMsg(void (*func)(ProductInformationMsg&, uintptr_t), uintptr_t data = 0) { _createProductInformationMsg.set(func, data); } + void createManufacturersInformationMsg(void (*func)(ManufacturersInformationMsg&, uintptr_t), uintptr_t data = 0) { _createManufacturersInformationMsg.set(func, data); } + +protected: + void transmitNextDataPage() override; + void onAcknowledgedData(AcknowledgedData& msg) override; + void onBroadcastData(BroadcastData& msg) override; + bool isDataPageValid(uint8_t dataPage) override; +private: + void setChannelConfig(); + void transmitDataPage(uint8_t page); + uint8_t getNextPowerOnlySensorPage(); + uint8_t getNextTorqueSensorPage(); + uint8_t getNextCTFSensorPage(); + uint8_t getBackgroundPage(); + void transmitBicyclePowerDefaultMsg(); + void transmitBicycleStandardPowerOnlyMsg(BicyclePowerStandardPowerOnlyMsg& msg); + void transmitBicyclePowerStandardPowerOnlyMsg(); + void transmitBicyclePowerStandardWheelTorqueMsg(); + void transmitBicyclePowerStandardCrankTorqueMsg(); + void transmitBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg(); + void transmitBicyclePowerCrankTorqueFrequencyMsg(); + void transmitBicyclePowerGeneralCalibrationResponse(); + void transmitBatteryStatusMsg(); + void transmitProductInfomrationMsg(); + void transmitManufacturesInformationMsg(); + bool handleRequestDataPage(BicyclePowerStandardPowerOnly& dataPage); + bool handleGeneralCalibration(BicyclePowerStandardPowerOnly& dataPage); + AntCallback _onRequestDataPage = { .func = NULL }; + AntCallback _createBicyclePowerStandardPowerOnlyMsg = { .func = NULL }; + AntCallback _createBicyclePowerStandardWheelTorqueMsg = { .func = NULL }; + AntCallback _createBicyclePowerStandardCrankTorqueMsg = { .func = NULL }; + AntCallback _createBicyclePowerCrankTorqueFrequencyMsg = { .func = NULL }; + AntCallback _createBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg = { .func = NULL }; + AntCallback _createBatteryStatusMsg = { .func = NULL }; + AntCallback _createProductInformationMsg = { .func = NULL }; + AntCallback _createManufacturersInformationMsg = { .func = NULL }; + uint8_t _patternStep = 0; + uint32_t _flags = 0; +}; + +#endif // ANTPLUS_PROFILEBICYCLEPOWERSENSOR_h diff --git a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedDataPages.h b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedDataPages.h new file mode 100644 index 0000000..995e436 --- /dev/null +++ b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedDataPages.h @@ -0,0 +1,11 @@ +#ifndef ANTPLUS_PROFILEBICYCLESPEEDDATAPAGES_h +#define ANTPLUS_PROFILEBICYCLESPEEDDATAPAGES_h + +#include +#include +#include +#include +#include +#include + +#endif // ANTPLUS_PROFILEBICYCLESPEEDDATAPAGES_h diff --git a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedDefines.h b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedDefines.h index ae07e3f..dcd4b99 100644 --- a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedDefines.h +++ b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedDefines.h @@ -1,12 +1,32 @@ #ifndef ANTPLUS_BICYCLESPEEDPROFILEDEFINES_h #define ANTPLUS_BICYCLESPEEDPROFILEDEFINES_h -#define ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_NEW 1 -#define ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_GOOD 2 -#define ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_OK 3 -#define ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_LOW 4 -#define ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_CRITICAL 5 -#define ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_INVALID 7 +#define ANTPLUS_BICYCLESPEED_DEVICETYPE 123 + + +#define ANTPLUS_BICYCLESPEED_DATAPAGE_DEFAULT_NUMBER 0 + + +#define ANTPLUS_BICYCLESPEED_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER 1 + + +#define ANTPLUS_BICYCLESPEED_DATAPAGE_MANUFACTURERID_NUMBER 2 + + +#define ANTPLUS_BICYCLESPEED_DATAPAGE_PRODUCTID_NUMBER 3 + + +#define ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_NUMBER 4 + +#define ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_NEW 1 +#define ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_GOOD 2 +#define ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_OK 3 +#define ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_LOW 4 +#define ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_CRITICAL 5 +#define ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_INVALID 7 + + +#define ANTPLUS_BICYCLESPEED_DATAPAGE_MOTIONANDSPEED_NUMBER 5 #define ANTPLUS_BICYCLESPEED_DATAPAGE_MOTIONANDSPEED_FLAGS_STOPINDICATOR 1 diff --git a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedPrivateDefines.h b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedPrivateDefines.h index c3df331..4bd0381 100644 --- a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedPrivateDefines.h +++ b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedPrivateDefines.h @@ -1,66 +1,11 @@ #ifndef ANTPLUS_BICYCLESPEEDPROFILEPRIVATEDEFINES_h #define ANTPLUS_BICYCLESPEEDPROFILEPRIVATEDEFINES_h +#include + /* Channel Config */ -#define ANTPLUS_BICYCLESPEED_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE -#define ANTPLUS_BICYCLESPEED_DEVICETYPE 123 -#define ANTPLUS_BICYCLESPEED_CHANNELPERIOD 8118 +#define BICYCLESPEED_CHANNELPERIOD 8118 // 30 / 2.5 = 12 -#define ANTPLUS_BICYCLESPEED_SEARCHTIMEOUT 12 - -/* Base DataPage */ -#define ANTPLUS_BICYCLESPEED_DATAPAGEBASE_DATAPAGE_BYTE 0 -#define ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_BYTE 0 -#define ANTPLUS_BICYCLESPEED_DATAPAGEBASE_BIKESPEEDEVENTTIMELSB_BYTE 4 -#define ANTPLUS_BICYCLESPEED_DATAPAGEBASE_BIKESPEEDEVENTTIMEMSB_BYTE 5 -#define ANTPLUS_BICYCLESPEED_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNTLSB_BYTE 6 -#define ANTPLUS_BICYCLESPEED_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNTMSB_BYTE 7 - -#define ANTPLUS_BICYCLESPEED_DATAPAGEBASE_DATAPAGE_MASK 0x7F -#define ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_MASK 0x80 - -#define ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_SHIFT 7 -#define ANTPLUS_BICYCLESPEED_DATAPAGEBASE_BIKESPEEDEVENTTIMEMSB_SHIFT 8 -#define ANTPLUS_BICYCLESPEED_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNTMSB_SHIFT 8 - -/* Default Page */ -#define ANTPLUS_BICYCLESPEED_DATAPAGE_DEFAULT_NUMBER 0 - -/* Cumulative Operating Time */ -#define ANTPLUS_BICYCLESPEED_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER 1 - -#define ANTPLUS_BICYCLESPEED_DATAPAGE_CUMULATIVEOPERATINGTIME_TIME_LSB_BYTE 1 -#define ANTPLUS_BICYCLESPEED_DATAPAGE_CUMULATIVEOPERATINGTIME_TIME_MSB_BYTE 3 - -/* ManufacturerID */ -#define ANTPLUS_BICYCLESPEED_DATAPAGE_MANUFACTURERID_NUMBER 2 - -#define ANTPLUS_BICYCLESPEED_DATAPAGE_MANUFACTURERINFORMATION_MANUFACTUREREID_BYTE 1 -#define ANTPLUS_BICYCLESPEED_DATAPAGE_MANUFACTURERINFORMATION_SERIALNUMBER_LSB_BYTE 2 -#define ANTPLUS_BICYCLESPEED_DATAPAGE_MANUFACTURERINFORMATION_SERIALNUMBER_MSB_BYTE 3 - -/* Product ID */ -#define ANTPLUS_BICYCLESPEED_DATAPAGE_PRODUCTID_NUMBER 3 - -#define ANTPLUS_BICYCLESPEED_DATAPAGE_PRODUCTINFORMATION_HARDWAREVERSION_BYTE 1 -#define ANTPLUS_BICYCLESPEED_DATAPAGE_PRODUCTINFORMATION_SOFTWAREVERSION_BYTE 2 -#define ANTPLUS_BICYCLESPEED_DATAPAGE_PRODUCTINFORMATION_MODELNUMBER_BYTE 3 - -/* Battery Status */ -#define ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_NUMBER 4 - -#define ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE 2 -#define ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_BYTE 3 -#define ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_BYTE 3 - -#define ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_MASK 0x0F -#define ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_MASK 0x70 - -#define ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_SHIFT 4 - -/* Motion And Speed */ -#define ANTPLUS_BICYCLESPEED_DATAPAGE_MOTIONANDSPEED_NUMBER 5 - -#define ANTPLUS_BICYCLESPEED_DATAPAGE_MOTIONANDSPEED_FLAGS_BYTE 1 +#define BICYCLESPEED_SEARCHTIMEOUT 12 #endif // ANTPLUS_BICYCLESPEEDPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedProfile.h b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedProfile.h index 23ac74f..54ffffa 100644 --- a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedProfile.h +++ b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedProfile.h @@ -5,10 +5,10 @@ #include // Datapages -#include +#include // Profile Classes -#include -#include +#include +#include #endif // ANTPLUS_BICYCLESPEEDPROFILE_h diff --git a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.cpp b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.cpp new file mode 100644 index 0000000..644cfa3 --- /dev/null +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.cpp @@ -0,0 +1,66 @@ +#include +#include +#include + +#define DATAPAGE_BYTE 0 +#define TOGGLE_BYTE 0 +#define BIKESPEEDEVENTTIME_LSB_BYTE 4 +#define BIKESPEEDEVENTTIME_MSB_BYTE 5 +#define CUMULATIVESPEEDREVOLUTIONCOUNT_LSB_BYTE 6 +#define CUMULATIVESPEEDREVOLUTIONCOUNT_MSB_BYTE 7 +#define DATAPAGE_MASK 0x7F +#define TOGGLE_MASK 0x80 +#define TOGGLE_SHIFT 7 + +template +BicycleSpeedCoreMainDataPage::BicycleSpeedCoreMainDataPage() : + CoreDataPage() {} + +template +uint8_t BicycleSpeedCoreMainDataPage::getDataPageNumber() { + return this->get8BitValue(DATAPAGE_BYTE, DATAPAGE_MASK); +} + +template +uint8_t BicycleSpeedCoreMainDataPage::getPageChangeToggle() { + return this->get8BitValue(TOGGLE_BYTE, TOGGLE_MASK, TOGGLE_SHIFT); +} + +template +uint16_t BicycleSpeedCoreMainDataPage::getBikeSpeedEventTime() { + return this->get16BitValue(BIKESPEEDEVENTTIME_LSB_BYTE, + BIKESPEEDEVENTTIME_MSB_BYTE); +} + +template +uint16_t BicycleSpeedCoreMainDataPage::getCumulativeSpeedRevolutionCount() { + return this->get16BitValue(CUMULATIVESPEEDREVOLUTIONCOUNT_LSB_BYTE, + CUMULATIVESPEEDREVOLUTIONCOUNT_MSB_BYTE); +} +template class BicycleSpeedCoreMainDataPage; +template class BicycleSpeedCoreMainDataPage; + +BicycleSpeedBaseMainDataPage::BicycleSpeedBaseMainDataPage(AntRxDataResponse& dp) : + BaseDataPage(dp), + BicycleSpeedCoreMainDataPage() {} + +BicycleSpeedBaseMainDataPageMsg::BicycleSpeedBaseMainDataPageMsg(uint8_t dataPageNumber) : + BaseDataPageMsg(), + BicycleSpeedCoreMainDataPage() { + setDataBuffer(_buffer); + set8BitValue(dataPageNumber, ANTPLUS_DEFAULT_DATAPAGE_BYTE); +} + +void BicycleSpeedBaseMainDataPageMsg::setPageChangeToggle(uint8_t toggle) { + set8BitValue(toggle ? TOGGLE_MASK : 0, TOGGLE_BYTE, TOGGLE_MASK); +} + +void BicycleSpeedBaseMainDataPageMsg::setBikeSpeedEventTime(uint16_t time) { + set16BitValue(time, BIKESPEEDEVENTTIME_LSB_BYTE, + BIKESPEEDEVENTTIME_MSB_BYTE); +} + +void BicycleSpeedBaseMainDataPageMsg::setCumulativeSpeedRevolutionCount(uint16_t count) { + set16BitValue(count, CUMULATIVESPEEDREVOLUTIONCOUNT_LSB_BYTE, + CUMULATIVESPEEDREVOLUTIONCOUNT_MSB_BYTE); +} diff --git a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.h b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.h new file mode 100644 index 0000000..68717a2 --- /dev/null +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.h @@ -0,0 +1,32 @@ +#ifndef ANTPLUS_BICYCLESPEEDBASEMAINDATAPAGE_h +#define ANTPLUS_BICYCLESPEEDBASEMAINDATAPAGE_h + +#include +#include + +template +class BicycleSpeedCoreMainDataPage : virtual public CoreDataPage { +public: + BicycleSpeedCoreMainDataPage(); + uint8_t getDataPageNumber() override; + uint8_t getPageChangeToggle(); + uint16_t getBikeSpeedEventTime(); + uint16_t getCumulativeSpeedRevolutionCount(); +}; + +class BicycleSpeedBaseMainDataPage : public BaseDataPage, public BicycleSpeedCoreMainDataPage { +public: + explicit BicycleSpeedBaseMainDataPage(AntRxDataResponse& dp); +}; + +class BicycleSpeedBaseMainDataPageMsg : public BaseDataPageMsg, public BicycleSpeedCoreMainDataPage { +public: + explicit BicycleSpeedBaseMainDataPageMsg(uint8_t dataPageNumber); + void setPageChangeToggle(uint8_t toggle); + void setBikeSpeedEventTime(uint16_t time); + void setCumulativeSpeedRevolutionCount(uint16_t count); +protected: + uint8_t _buffer[MESSAGE_SIZE] = {0}; +}; + +#endif // ANTPLUS_BICYCLESPEEDBASEMAINDATAPAGE_h diff --git a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBatteryStatus.cpp b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBatteryStatus.cpp new file mode 100644 index 0000000..fe29703 --- /dev/null +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBatteryStatus.cpp @@ -0,0 +1,37 @@ +#include +#include + +#define FRACTIONALBATTERYVOLTAGE_BYTE 2 +#define COARSEBATTERYVOLTAGE_BYTE 3 +#define BATTERYSTATUS_BYTE 3 +#define COARSEBATTERYVOLTAGE_MASK 0x0F +#define BATTERYSTATUS_MASK 0x70 +#define BATTERYSTATUS_SHIFT 4 + +template +BicycleSpeedBaseBatteryStatus::BicycleSpeedBaseBatteryStatus() : + CoreDataPage() {} + +template +uint8_t BicycleSpeedBaseBatteryStatus::getFractionalBatteryVoltage() { + return this->get8BitValue(FRACTIONALBATTERYVOLTAGE_BYTE); +} + +template +uint8_t BicycleSpeedBaseBatteryStatus::getCoarseBatteryVoltage() { + return this->get8BitValue(COARSEBATTERYVOLTAGE_BYTE, + COARSEBATTERYVOLTAGE_MASK); +} + +template +uint8_t BicycleSpeedBaseBatteryStatus::getBatteryStatus() { + return this->get8BitValue(BATTERYSTATUS_BYTE, BATTERYSTATUS_MASK, + BATTERYSTATUS_SHIFT); +} + +template class BicycleSpeedBaseBatteryStatus; +template class BicycleSpeedBaseBatteryStatus; + +BicycleSpeedBatteryStatus::BicycleSpeedBatteryStatus(AntRxDataResponse& dp) : + BicycleSpeedBaseMainDataPage(dp), + BicycleSpeedBaseBatteryStatus() {} diff --git a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBatteryStatus.h b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBatteryStatus.h new file mode 100644 index 0000000..62aa65f --- /dev/null +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBatteryStatus.h @@ -0,0 +1,20 @@ +#ifndef ANTPLUS_BICYCLESPEEDBATTERYSTATUS_h +#define ANTPLUS_BICYCLESPEEDBATTERYSTATUS_h + +#include + +template +class BicycleSpeedBaseBatteryStatus : virtual public CoreDataPage { +public: + BicycleSpeedBaseBatteryStatus(); + uint8_t getFractionalBatteryVoltage(); + uint8_t getCoarseBatteryVoltage(); + uint8_t getBatteryStatus(); +}; + +class BicycleSpeedBatteryStatus : public BicycleSpeedBaseMainDataPage, public BicycleSpeedBaseBatteryStatus { +public: + explicit BicycleSpeedBatteryStatus(AntRxDataResponse& dp); +}; + +#endif // ANTPLUS_BICYCLESPEEDBATTERYSTATUS_h diff --git a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedCumulativeOperatingTime.cpp b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedCumulativeOperatingTime.cpp new file mode 100644 index 0000000..d0a49fa --- /dev/null +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedCumulativeOperatingTime.cpp @@ -0,0 +1,21 @@ +#include +#include + +#define CUMULATIVEOPERATINGTIME_TIME_LSB_BYTE 1 +#define CUMULATIVEOPERATINGTIME_TIME_MSB_BYTE 3 + +template +BicycleSpeedBaseCumulativeOperatingTime::BicycleSpeedBaseCumulativeOperatingTime() : + CoreDataPage() {} + +template +uint32_t BicycleSpeedBaseCumulativeOperatingTime::getCumulativeOperatingTime() { + return this->get24BitValue(CUMULATIVEOPERATINGTIME_TIME_LSB_BYTE, + CUMULATIVEOPERATINGTIME_TIME_MSB_BYTE); +} + +template class BicycleSpeedBaseCumulativeOperatingTime; +template class BicycleSpeedBaseCumulativeOperatingTime; + +BicycleSpeedCumulativeOperatingTime::BicycleSpeedCumulativeOperatingTime(AntRxDataResponse& dp) : + BicycleSpeedBaseMainDataPage(dp), BicycleSpeedBaseCumulativeOperatingTime() {} diff --git a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedCumulativeOperatingTime.h b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedCumulativeOperatingTime.h new file mode 100644 index 0000000..71925a9 --- /dev/null +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedCumulativeOperatingTime.h @@ -0,0 +1,18 @@ +#ifndef ANTPLUS_BICYCLESPEEDCUMULITIVEOPERATINGTIME_h +#define ANTPLUS_BICYCLESPEEDCUMULITIVEOPERATINGTIME_h + +#include + +template +class BicycleSpeedBaseCumulativeOperatingTime : virtual public CoreDataPage { +public: + BicycleSpeedBaseCumulativeOperatingTime(); + uint32_t getCumulativeOperatingTime(); // only 24 bits +}; + +class BicycleSpeedCumulativeOperatingTime : public BicycleSpeedBaseMainDataPage, public BicycleSpeedBaseCumulativeOperatingTime { +public: + explicit BicycleSpeedCumulativeOperatingTime(AntRxDataResponse& dp); +}; + +#endif // ANTPLUS_BICYCLESPEEDCUMULITIVEOPERATINGTIME_h diff --git a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedDefault.cpp b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedDefault.cpp similarity index 57% rename from src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedDefault.cpp rename to src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedDefault.cpp index 4ab1c81..d6cd74f 100644 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedDefault.cpp +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedDefault.cpp @@ -1,4 +1,4 @@ -#include +#include BicycleSpeedDefault::BicycleSpeedDefault(AntRxDataResponse& dp) : BicycleSpeedBaseMainDataPage(dp) { } diff --git a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedDefault.h b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedDefault.h similarity index 58% rename from src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedDefault.h rename to src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedDefault.h index 3130a62..49e36e6 100644 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedDefault.h +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedDefault.h @@ -1,11 +1,11 @@ #ifndef ANTPLUS_BICYCLESPEEDDEFAULT_h #define ANTPLUS_BICYCLESPEEDDEFAULT_h -#include +#include class BicycleSpeedDefault : public BicycleSpeedBaseMainDataPage { public: - BicycleSpeedDefault(AntRxDataResponse& dp); + explicit BicycleSpeedDefault(AntRxDataResponse& dp); }; #endif // ANTPLUS_BICYCLESPEEDDEFAULT_h diff --git a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedManufacturerID.cpp b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedManufacturerID.cpp new file mode 100644 index 0000000..003a89d --- /dev/null +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedManufacturerID.cpp @@ -0,0 +1,27 @@ +#include +#include + +#define MANUFACTUREREID_BYTE 1 +#define SERIALNUMBER_LSB_BYTE 2 +#define SERIALNUMBER_MSB_BYTE 3 + +template +BicycleSpeedBaseManufacturerID::BicycleSpeedBaseManufacturerID() : + CoreDataPage() {} + +template +uint8_t BicycleSpeedBaseManufacturerID::getManufacturerId() { + return this->get8BitValue(MANUFACTUREREID_BYTE); +} + +template +uint16_t BicycleSpeedBaseManufacturerID::getSerialNumber() { + return this->get16BitValue(SERIALNUMBER_LSB_BYTE, SERIALNUMBER_MSB_BYTE); +} + +template class BicycleSpeedBaseManufacturerID; +template class BicycleSpeedBaseManufacturerID; + +BicycleSpeedManufacturerID::BicycleSpeedManufacturerID(AntRxDataResponse& dp) : + BicycleSpeedBaseMainDataPage(dp), + BicycleSpeedBaseManufacturerID() {} diff --git a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedManufacturerID.h b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedManufacturerID.h new file mode 100644 index 0000000..9f1fa2d --- /dev/null +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedManufacturerID.h @@ -0,0 +1,19 @@ +#ifndef ANTPLUS_BICYCLESPEEDMANUFACTURERID_h +#define ANTPLUS_BICYCLESPEEDMANUFACTURERID_h + +#include + +template +class BicycleSpeedBaseManufacturerID : virtual public CoreDataPage { +public: + BicycleSpeedBaseManufacturerID(); + uint8_t getManufacturerId(); + uint16_t getSerialNumber(); +}; + +class BicycleSpeedManufacturerID : public BicycleSpeedBaseMainDataPage, public BicycleSpeedBaseManufacturerID { +public: + explicit BicycleSpeedManufacturerID(AntRxDataResponse& dp); +}; + +#endif // ANTPLUS_BICYCLESPEEDMANUFACTURERID_h diff --git a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMotionAndSpeed.cpp b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedMotionAndSpeed.cpp similarity index 50% rename from src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMotionAndSpeed.cpp rename to src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedMotionAndSpeed.cpp index c70f0a8..77736f6 100644 --- a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMotionAndSpeed.cpp +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedMotionAndSpeed.cpp @@ -1,15 +1,20 @@ -#include +#include #include +#define FLAGS_BYTE 1 + template -BicycleSpeedBaseMotionAndSpeed::BicycleSpeedBaseMotionAndSpeed() : CoreDataPage() { -} +BicycleSpeedBaseMotionAndSpeed::BicycleSpeedBaseMotionAndSpeed() : + CoreDataPage() {} template uint8_t BicycleSpeedBaseMotionAndSpeed::getFlags() { - return this->get8BitValue( - ANTPLUS_BICYCLESPEED_DATAPAGE_MOTIONANDSPEED_FLAGS_BYTE); + return this->get8BitValue(FLAGS_BYTE); } template class BicycleSpeedBaseMotionAndSpeed; template class BicycleSpeedBaseMotionAndSpeed; + +BicycleSpeedMotionAndSpeed::BicycleSpeedMotionAndSpeed(AntRxDataResponse& dp) : + BicycleSpeedBaseMainDataPage(dp), + BicycleSpeedBaseMotionAndSpeed() {} diff --git a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedMotionAndSpeed.h b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedMotionAndSpeed.h new file mode 100644 index 0000000..97e66f0 --- /dev/null +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedMotionAndSpeed.h @@ -0,0 +1,18 @@ +#ifndef ANTPLUS_BICYCLESPEEDMOTIONANDSPEED_h +#define ANTPLUS_BICYCLESPEEDMOTIONANDSPEED_h + +#include + +template +class BicycleSpeedBaseMotionAndSpeed : virtual public CoreDataPage { +public: + BicycleSpeedBaseMotionAndSpeed(); + uint8_t getFlags(); +}; + +class BicycleSpeedMotionAndSpeed : public BicycleSpeedBaseMainDataPage, public BicycleSpeedBaseMotionAndSpeed { +public: + explicit BicycleSpeedMotionAndSpeed(AntRxDataResponse& dp); +}; + +#endif // ANTPLUS_BICYCLESPEEDMOTIONANDSPEED_h diff --git a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseProductID.cpp b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedProductID.cpp similarity index 50% rename from src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseProductID.cpp rename to src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedProductID.cpp index 4dcfe1b..c3f92b2 100644 --- a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseProductID.cpp +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedProductID.cpp @@ -1,27 +1,31 @@ -#include +#include #include +#define HARDWAREVERSION_BYTE 1 +#define SOFTWAREVERSION_BYTE 2 +#define MODELNUMBER_BYTE 3 + template -BicycleSpeedBaseProductID::BicycleSpeedBaseProductID() : CoreDataPage() { -} +BicycleSpeedBaseProductID::BicycleSpeedBaseProductID() : CoreDataPage() {} template uint8_t BicycleSpeedBaseProductID::getHardwareVersion() { - return this->get8BitValue( - ANTPLUS_BICYCLESPEED_DATAPAGE_PRODUCTINFORMATION_HARDWAREVERSION_BYTE); + return this->get8BitValue(HARDWAREVERSION_BYTE); } template uint8_t BicycleSpeedBaseProductID::getSoftwareVersion() { - return this->get8BitValue( - ANTPLUS_BICYCLESPEED_DATAPAGE_PRODUCTINFORMATION_SOFTWAREVERSION_BYTE); + return this->get8BitValue(SOFTWAREVERSION_BYTE); } template uint8_t BicycleSpeedBaseProductID::getModelNumber() { - return this->get8BitValue( - ANTPLUS_BICYCLESPEED_DATAPAGE_PRODUCTINFORMATION_MODELNUMBER_BYTE); + return this->get8BitValue(MODELNUMBER_BYTE); } template class BicycleSpeedBaseProductID; template class BicycleSpeedBaseProductID; + +BicycleSpeedProductID::BicycleSpeedProductID(AntRxDataResponse& dp) : + BicycleSpeedBaseMainDataPage(dp), + BicycleSpeedBaseProductID() {} diff --git a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedProductID.h b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedProductID.h new file mode 100644 index 0000000..a8bc40d --- /dev/null +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedProductID.h @@ -0,0 +1,20 @@ +#ifndef ANTPLUS_BICYCLESPEEDPRODUCTIONID_h +#define ANTPLUS_BICYCLESPEEDPRODUCTIONID_h + +#include + +template +class BicycleSpeedBaseProductID : virtual public CoreDataPage { +public: + BicycleSpeedBaseProductID(); + uint8_t getHardwareVersion(); + uint8_t getSoftwareVersion(); + uint8_t getModelNumber(); +}; + +class BicycleSpeedProductID : public BicycleSpeedBaseMainDataPage, public BicycleSpeedBaseProductID { +public: + explicit BicycleSpeedProductID(AntRxDataResponse& dp); +}; + +#endif // ANTPLUS_BICYCLESPEEDPRODUCTIONID_h diff --git a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_ProfileBicycleSpeedDataPages.h b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_ProfileBicycleSpeedDataPages.h deleted file mode 100644 index 7adb488..0000000 --- a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_ProfileBicycleSpeedDataPages.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef ANTPLUS_PROFILEBICYCLESPEEDDATAPAGES_h -#define ANTPLUS_PROFILEBICYCLESPEEDDATAPAGES_h - -/* RX */ -#include -#include -#include -#include -#include -#include - -/* TX */ - -#endif // ANTPLUS_PROFILEBICYCLESPEEDDATAPAGES_h diff --git a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseBatteryStatus.cpp b/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseBatteryStatus.cpp deleted file mode 100644 index b740cb2..0000000 --- a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseBatteryStatus.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -template -BicycleSpeedBaseBatteryStatus::BicycleSpeedBaseBatteryStatus() : CoreDataPage() { -} - -template -uint8_t BicycleSpeedBaseBatteryStatus::getFractionalBatteryVoltage() { - return this->get8BitValue( - ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE); -} - -template -uint8_t BicycleSpeedBaseBatteryStatus::getCoarseBatteryVoltage() { - return this->get8BitValue( - ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_BYTE, - ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_MASK); -} - -template -uint8_t BicycleSpeedBaseBatteryStatus::getBatteryStatus() { - return this->get8BitValue( - ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_BYTE, - ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_MASK, - ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_SHIFT); -} - -template class BicycleSpeedBaseBatteryStatus; -template class BicycleSpeedBaseBatteryStatus; diff --git a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseBatteryStatus.h b/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseBatteryStatus.h deleted file mode 100644 index fb7f7c1..0000000 --- a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseBatteryStatus.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef ANTPLUS_BICYCLESPEEDBASEBATTERYSTATUS_h -#define ANTPLUS_BICYCLESPEEDBASEBATTERYSTATUS_h - -#include - -#include "ANT.h" - -template -class BicycleSpeedBaseBatteryStatus : virtual public CoreDataPage { -public: - BicycleSpeedBaseBatteryStatus(); - uint8_t getFractionalBatteryVoltage(); - uint8_t getCoarseBatteryVoltage(); - uint8_t getBatteryStatus(); -}; - -#endif // ANTPLUS_BICYCLESPEEDBASEBATTERYSTATUS_h diff --git a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseCumulativeOperatingTime.cpp b/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseCumulativeOperatingTime.cpp deleted file mode 100644 index 52870cf..0000000 --- a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseCumulativeOperatingTime.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -template -BicycleSpeedBaseCumulativeOperatingTime::BicycleSpeedBaseCumulativeOperatingTime() : CoreDataPage() { -} - -template -uint32_t BicycleSpeedBaseCumulativeOperatingTime::getCumulativeOperatingTime() { - return this->get24BitValue( - ANTPLUS_BICYCLESPEED_DATAPAGE_CUMULATIVEOPERATINGTIME_TIME_LSB_BYTE, - ANTPLUS_BICYCLESPEED_DATAPAGE_CUMULATIVEOPERATINGTIME_TIME_MSB_BYTE); -} - -template class BicycleSpeedBaseCumulativeOperatingTime; -template class BicycleSpeedBaseCumulativeOperatingTime; diff --git a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseCumulativeOperatingTime.h b/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseCumulativeOperatingTime.h deleted file mode 100644 index c830f9a..0000000 --- a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseCumulativeOperatingTime.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef ANTPLUS_BICYCLESPEEDBASECUMULITIVEOPERATINGTIME_h -#define ANTPLUS_BICYCLESPEEDBASECUMULITIVEOPERATINGTIME_h - -#include - -#include "ANT.h" - -template -class BicycleSpeedBaseCumulativeOperatingTime : virtual public CoreDataPage { -public: - BicycleSpeedBaseCumulativeOperatingTime(); - uint32_t getCumulativeOperatingTime(); // only 24 bits -}; - -#endif // ANTPLUS_BICYCLESPEEDBASECUMULITIVEOPERATINGTIME_h diff --git a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPage.cpp b/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPage.cpp deleted file mode 100644 index aea0758..0000000 --- a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPage.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -BicycleSpeedBaseMainDataPage::BicycleSpeedBaseMainDataPage(AntRxDataResponse& dp) : BaseDataPage(dp) { - -} - -uint8_t BicycleSpeedBaseMainDataPage::getDataPageNumber() { - return getData(ANTPLUS_BICYCLESPEED_DATAPAGEBASE_DATAPAGE_BYTE) & ANTPLUS_BICYCLESPEED_DATAPAGEBASE_DATAPAGE_MASK; -} - -uint8_t BicycleSpeedBaseMainDataPage::getPageChangeToggle() { - return (getData(ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_BYTE) & ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_MASK) >> ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_SHIFT; -} - -uint16_t BicycleSpeedBaseMainDataPage::getBikeSpeedEventTime() { - return (getData(ANTPLUS_BICYCLESPEED_DATAPAGEBASE_BIKESPEEDEVENTTIMEMSB_BYTE) << ANTPLUS_BICYCLESPEED_DATAPAGEBASE_BIKESPEEDEVENTTIMEMSB_SHIFT) | getData(ANTPLUS_BICYCLESPEED_DATAPAGEBASE_BIKESPEEDEVENTTIMELSB_BYTE); -} - -uint16_t BicycleSpeedBaseMainDataPage::getCumulativeSpeedRevolutionCount() { - return (getData(ANTPLUS_BICYCLESPEED_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNTMSB_BYTE) << ANTPLUS_BICYCLESPEED_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNTMSB_SHIFT) | getData(ANTPLUS_BICYCLESPEED_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNTLSB_BYTE); -} diff --git a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPage.h b/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPage.h deleted file mode 100644 index d101c9d..0000000 --- a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPage.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef ANTPLUS_BICYCLESPEEDBASEMAINDATAPAGE_h -#define ANTPLUS_BICYCLESPEEDBASEMAINDATAPAGE_h - -#include - -#include "ANT.h" - -class BicycleSpeedBaseMainDataPage : public BaseDataPage { -public: - BicycleSpeedBaseMainDataPage(AntRxDataResponse& dp); - uint8_t getDataPageNumber() override; - uint8_t getPageChangeToggle(); - uint16_t getBikeSpeedEventTime(); - uint16_t getCumulativeSpeedRevolutionCount(); -}; - -#endif // ANTPLUS_BICYCLESPEEDBASEMAINDATAPAGE_h diff --git a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPageMsg.cpp b/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPageMsg.cpp deleted file mode 100644 index 2069edd..0000000 --- a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPageMsg.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -#include - -BicycleSpeedBaseMainDataPageMsg::BicycleSpeedBaseMainDataPageMsg(uint8_t dataPageNumber) : BaseDataPageMsg() { - setDataBuffer(_buffer); - _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = dataPageNumber; -} - -uint8_t BicycleSpeedBaseMainDataPageMsg::getPageChangeToggle() { - return (_buffer[ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_BYTE] & ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_MASK) >> ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_SHIFT; -} - -uint16_t BicycleSpeedBaseMainDataPageMsg::getBikeSpeedEventTime() { - return (_buffer[ANTPLUS_BICYCLESPEED_DATAPAGEBASE_BIKESPEEDEVENTTIMEMSB_BYTE] << ANTPLUS_BICYCLESPEED_DATAPAGEBASE_BIKESPEEDEVENTTIMEMSB_SHIFT) | _buffer[ANTPLUS_BICYCLESPEED_DATAPAGEBASE_BIKESPEEDEVENTTIMELSB_BYTE]; -} - -uint16_t BicycleSpeedBaseMainDataPageMsg::getCumulativeSpeedRevolutionCount() { - return (_buffer[ANTPLUS_BICYCLESPEED_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNTMSB_BYTE] << ANTPLUS_BICYCLESPEED_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNTMSB_SHIFT) | _buffer[ANTPLUS_BICYCLESPEED_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNTLSB_BYTE]; -} - -void BicycleSpeedBaseMainDataPageMsg::setPageChangeToggle(uint8_t toggle) { - _buffer[ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_BYTE] = _buffer[ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_BYTE] & ~ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_MASK; - _buffer[ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_BYTE] |= toggle ? ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_MASK : 0; -} - -void BicycleSpeedBaseMainDataPageMsg::setBikeSpeedEventTime(uint16_t time) { - _buffer[ANTPLUS_BICYCLESPEED_DATAPAGEBASE_BIKESPEEDEVENTTIMEMSB_BYTE] = time >> ANTPLUS_BICYCLESPEED_DATAPAGEBASE_BIKESPEEDEVENTTIMEMSB_SHIFT; - _buffer[ANTPLUS_BICYCLESPEED_DATAPAGEBASE_BIKESPEEDEVENTTIMELSB_BYTE] = time & ANTPLUS_DEFAULT_BYTE_MASK; -} - -void BicycleSpeedBaseMainDataPageMsg::setCumulativeSpeedRevolutionCount(uint16_t count) { - _buffer[ANTPLUS_BICYCLESPEED_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNTMSB_BYTE] = count >> ANTPLUS_BICYCLESPEED_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNTMSB_SHIFT; - _buffer[ANTPLUS_BICYCLESPEED_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNTLSB_BYTE] = count & ANTPLUS_DEFAULT_BYTE_MASK; -} diff --git a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPageMsg.h b/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPageMsg.h deleted file mode 100644 index a7221e3..0000000 --- a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPageMsg.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef ANTPLUS_HEARTRATEBASEMAINDATAPAGEMSG_h -#define ANTPLUS_HEARTRATEBASEMAINDATAPAGEMSG_h - -#include - -#include "ANT.h" - -class BicycleSpeedBaseMainDataPageMsg : public BaseDataPageMsg { -public: - BicycleSpeedBaseMainDataPageMsg(uint8_t dataPageNumber); - uint8_t getPageChangeToggle(); - uint16_t getBikeSpeedEventTime(); - uint16_t getCumulativeSpeedRevolutionCount(); - void setPageChangeToggle(uint8_t toggle); - void setBikeSpeedEventTime(uint16_t time); - void setCumulativeSpeedRevolutionCount(uint16_t count); -protected: - uint8_t _buffer[MESSAGE_SIZE]; -}; - -#endif // ANTPLUS_HEARTRATEBASEMAINDATAPAGEMSG_h diff --git a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseManufacturerID.cpp b/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseManufacturerID.cpp deleted file mode 100644 index 0150e28..0000000 --- a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseManufacturerID.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -template -BicycleSpeedBaseManufacturerID::BicycleSpeedBaseManufacturerID() : CoreDataPage() { -} - -template -uint8_t BicycleSpeedBaseManufacturerID::getManufacturerId() { - return this->get8BitValue( - ANTPLUS_BICYCLESPEED_DATAPAGE_MANUFACTURERINFORMATION_MANUFACTUREREID_BYTE); -} - -template -uint16_t BicycleSpeedBaseManufacturerID::getSerialNumber() { - return this->get16BitValue( - ANTPLUS_BICYCLESPEED_DATAPAGE_MANUFACTURERINFORMATION_SERIALNUMBER_LSB_BYTE, - ANTPLUS_BICYCLESPEED_DATAPAGE_MANUFACTURERINFORMATION_SERIALNUMBER_MSB_BYTE); -} - -template class BicycleSpeedBaseManufacturerID; -template class BicycleSpeedBaseManufacturerID; diff --git a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseManufacturerID.h b/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseManufacturerID.h deleted file mode 100644 index 97982e0..0000000 --- a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseManufacturerID.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef ANTPLUS_BICYCLESPEEDBASEMANUFACTURERID_h -#define ANTPLUS_BICYCLESPEEDBASEMANUFACTURERID_h - -#include - -#include "ANT.h" - -template -class BicycleSpeedBaseManufacturerID : virtual public CoreDataPage { -public: - BicycleSpeedBaseManufacturerID(); - uint8_t getManufacturerId(); - uint16_t getSerialNumber(); -}; - -#endif // ANTPLUS_BICYCLESPEEDBASEMANUFACTURERID_h diff --git a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMotionAndSpeed.h b/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMotionAndSpeed.h deleted file mode 100644 index fb3635f..0000000 --- a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMotionAndSpeed.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef ANTPLUS_BICYCLESPEEDBASEMOTIONANDSPEED_h -#define ANTPLUS_BICYCLESPEEDBASEMOTIONANDSPEED_h - -#include - -#include "ANT.h" - -template -class BicycleSpeedBaseMotionAndSpeed : virtual public CoreDataPage { -public: - BicycleSpeedBaseMotionAndSpeed(); - uint8_t getFlags(); -}; - -#endif // ANTPLUS_BICYCLESPEEDBASEMOTIONANDSPEED_h diff --git a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseProductID.h b/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseProductID.h deleted file mode 100644 index 73ca1d8..0000000 --- a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseProductID.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef ANTPLUS_BICYCLESPEEDBASEPRODUCTIONID_h -#define ANTPLUS_BICYCLESPEEDBASEPRODUCTIONID_h - -#include - -#include "ANT.h" - -template -class BicycleSpeedBaseProductID : virtual public CoreDataPage { -public: - BicycleSpeedBaseProductID(); - uint8_t getHardwareVersion(); - uint8_t getSoftwareVersion(); - uint8_t getModelNumber(); -}; - -#endif // ANTPLUS_BICYCLESPEEDBASEPRODUCTIONID_h diff --git a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedBatteryStatus.cpp b/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedBatteryStatus.cpp deleted file mode 100644 index 150b666..0000000 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedBatteryStatus.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include - -BicycleSpeedBatteryStatus::BicycleSpeedBatteryStatus(AntRxDataResponse& dp) : BicycleSpeedBaseMainDataPage(dp), BicycleSpeedBaseBatteryStatus() { -} diff --git a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedBatteryStatus.h b/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedBatteryStatus.h deleted file mode 100644 index a97fb1c..0000000 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedBatteryStatus.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_BICYCLESPEEDBATTERYSTATUS_h -#define ANTPLUS_BICYCLESPEEDBATTERYSTATUS_h - -#include -#include - -class BicycleSpeedBatteryStatus : public BicycleSpeedBaseMainDataPage, public BicycleSpeedBaseBatteryStatus { -public: - BicycleSpeedBatteryStatus(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_BICYCLESPEEDBATTERYSTATUS_h diff --git a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedCumulativeOperatingTime.cpp b/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedCumulativeOperatingTime.cpp deleted file mode 100644 index 3b1ddd4..0000000 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedCumulativeOperatingTime.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include - -BicycleSpeedCumulativeOperatingTime::BicycleSpeedCumulativeOperatingTime(AntRxDataResponse& dp) : BicycleSpeedBaseMainDataPage(dp) { -} diff --git a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedCumulativeOperatingTime.h b/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedCumulativeOperatingTime.h deleted file mode 100644 index a6427f9..0000000 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedCumulativeOperatingTime.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_BICYCLESPEEDCUMULITIVEOPERATINGTIME_h -#define ANTPLUS_BICYCLESPEEDCUMULITIVEOPERATINGTIME_h - -#include -#include - -class BicycleSpeedCumulativeOperatingTime : public BicycleSpeedBaseMainDataPage, public BicycleSpeedBaseCumulativeOperatingTime { -public: - BicycleSpeedCumulativeOperatingTime(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_BICYCLESPEEDCUMULITIVEOPERATINGTIME_h diff --git a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedManufacturerID.cpp b/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedManufacturerID.cpp deleted file mode 100644 index bd29b90..0000000 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedManufacturerID.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include - -BicycleSpeedManufacturerID::BicycleSpeedManufacturerID(AntRxDataResponse& dp) : BicycleSpeedBaseMainDataPage(dp), BicycleSpeedBaseManufacturerID() { -} diff --git a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedManufacturerID.h b/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedManufacturerID.h deleted file mode 100644 index 885f0ae..0000000 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedManufacturerID.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_BICYCLESPEEDMANUFACTURERID_h -#define ANTPLUS_BICYCLESPEEDMANUFACTURERID_h - -#include -#include - -class BicycleSpeedManufacturerID : public BicycleSpeedBaseMainDataPage, public BicycleSpeedBaseManufacturerID { -public: - BicycleSpeedManufacturerID(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_BICYCLESPEEDMANUFACTURERID_h diff --git a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedMotionAndSpeed.cpp b/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedMotionAndSpeed.cpp deleted file mode 100644 index 47b7bf8..0000000 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedMotionAndSpeed.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include - -BicycleSpeedMotionAndSpeed::BicycleSpeedMotionAndSpeed(AntRxDataResponse& dp) : BicycleSpeedBaseMainDataPage(dp) { -} diff --git a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedMotionAndSpeed.h b/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedMotionAndSpeed.h deleted file mode 100644 index 2357e2f..0000000 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedMotionAndSpeed.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_BICYCLESPEEDMOTIONANDSPEED_h -#define ANTPLUS_BICYCLESPEEDMOTIONANDSPEED_h - -#include -#include - -class BicycleSpeedMotionAndSpeed : public BicycleSpeedBaseMainDataPage, public BicycleSpeedBaseMotionAndSpeed { -public: - BicycleSpeedMotionAndSpeed(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_BICYCLESPEEDMOTIONANDSPEED_h diff --git a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedProductID.cpp b/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedProductID.cpp deleted file mode 100644 index b2b4dc5..0000000 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedProductID.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include - -BicycleSpeedProductID::BicycleSpeedProductID(AntRxDataResponse& dp) : BicycleSpeedBaseMainDataPage(dp), BicycleSpeedBaseProductID() { -} diff --git a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedProductID.h b/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedProductID.h deleted file mode 100644 index b849b77..0000000 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedProductID.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_BICYCLESPEEDPRODUCTIONID_h -#define ANTPLUS_BICYCLESPEEDPRODUCTIONID_h - -#include -#include - -class BicycleSpeedProductID : public BicycleSpeedBaseMainDataPage, public BicycleSpeedBaseProductID { -public: - BicycleSpeedProductID(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_BICYCLESPEEDPRODUCTIONID_h diff --git a/src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.cpp b/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.cpp similarity index 90% rename from src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.cpp rename to src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.cpp index 3727088..3483695 100644 --- a/src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.cpp +++ b/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.cpp @@ -1,7 +1,7 @@ -#include +#include #include -#include -#include + +#define DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE ProfileBicycleSpeedDisplay::ProfileBicycleSpeedDisplay() : BaseSlaveProfile() { setChannelConfig(); @@ -61,10 +61,10 @@ void ProfileBicycleSpeedDisplay::onAcknowledgedData(AcknowledgedData& msg) { void ProfileBicycleSpeedDisplay::setChannelConfig() { - setChannelType(ANTPLUS_BICYCLESPEED_CHANNELTYPE); + setChannelType(DISPLAY_CHANNELTYPE); setDeviceType(ANTPLUS_BICYCLESPEED_DEVICETYPE); - setChannelPeriod(ANTPLUS_BICYCLESPEED_CHANNELPERIOD); - setSearchTimeout(ANTPLUS_BICYCLESPEED_SEARCHTIMEOUT); + setChannelPeriod(BICYCLESPEED_CHANNELPERIOD); + setSearchTimeout(BICYCLESPEED_SEARCHTIMEOUT); } bool ProfileBicycleSpeedDisplay::handleBatteryStatus(BicycleSpeedBaseMainDataPage& dataPage) { diff --git a/src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.h b/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.h similarity index 83% rename from src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.h rename to src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.h index 13aaf82..3dbc004 100644 --- a/src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.h +++ b/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.h @@ -2,16 +2,14 @@ #define ANTPLUS_PROFILEBICYCLESPEEDDISPLAY_h #include -#include +#include #include -#include "ANT.h" - class ProfileBicycleSpeedDisplay : public BaseSlaveProfile { public: ProfileBicycleSpeedDisplay(); - ProfileBicycleSpeedDisplay(uint16_t deviceNumber); - ProfileBicycleSpeedDisplay(uint16_t deviceNumber, uint8_t transmissionType); + explicit ProfileBicycleSpeedDisplay(uint16_t deviceNumber); + explicit ProfileBicycleSpeedDisplay(uint16_t deviceNumber, uint8_t transmissionType); void onBicycleSpeedBatteryStatus(void (*func)(BicycleSpeedBatteryStatus&, uintptr_t), uintptr_t data = 0) { _onBicycleSpeedBatteryStatus.set(func, data); } void onBicycleSpeedCumulativeOperatingTime(void (*func)(BicycleSpeedCumulativeOperatingTime&, uintptr_t), uintptr_t data = 0) { _onBicycleSpeedCumulativeOperatingTime.set(func, data); } void onBicycleSpeedDefault(void (*func)(BicycleSpeedDefault&, uintptr_t), uintptr_t data = 0) { _onBicycleSpeedDefault.set(func, data); } @@ -31,12 +29,12 @@ class ProfileBicycleSpeedDisplay : public BaseSlaveProfile { bool handleManufacturerID(BicycleSpeedBaseMainDataPage& dataPage); bool handleMotionAndSpeed(BicycleSpeedBaseMainDataPage& dataPage); bool handleProductID(BicycleSpeedBaseMainDataPage& dataPage); - AntCallback _onBicycleSpeedBatteryStatus; - AntCallback _onBicycleSpeedCumulativeOperatingTime; - AntCallback _onBicycleSpeedDefault; - AntCallback _onBicycleSpeedManufacturerID; - AntCallback _onBicycleSpeedMotionAndSpeed; - AntCallback _onBicycleSpeedProductID; + AntCallback _onBicycleSpeedBatteryStatus = { .func = NULL }; + AntCallback _onBicycleSpeedCumulativeOperatingTime = { .func = NULL }; + AntCallback _onBicycleSpeedDefault = { .func = NULL }; + AntCallback _onBicycleSpeedManufacturerID = { .func = NULL }; + AntCallback _onBicycleSpeedMotionAndSpeed = { .func = NULL }; + AntCallback _onBicycleSpeedProductID = { .func = NULL }; }; #endif // ANTPLUS_PROFILEBICYCLESPEEDDISPLAY_h diff --git a/src/Profiles/BicycleSpeed/Sensor/ANTPLUS_ProfileBicycleSpeedSensor.h b/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedSensor.h similarity index 92% rename from src/Profiles/BicycleSpeed/Sensor/ANTPLUS_ProfileBicycleSpeedSensor.h rename to src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedSensor.h index 5c924de..6a56ff0 100644 --- a/src/Profiles/BicycleSpeed/Sensor/ANTPLUS_ProfileBicycleSpeedSensor.h +++ b/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedSensor.h @@ -2,9 +2,10 @@ #define ANTPLUS_PROFILEBICYCLESPEEDSENSOR_h #include -#include +#include #include +// TODO class ProfileBicycleSpeedSensor : BaseMasterProfile { public: // void onHeartRateCapabilities(void (*func)(HeartRateCapabilities&, uintptr_t), uintptr_t data = 0) { _onHeartRateCapabilities.set(func, data); } diff --git a/src/Profiles/Environment/ANTPLUS_EnvironmentDataPages.h b/src/Profiles/Environment/ANTPLUS_EnvironmentDataPages.h new file mode 100644 index 0000000..faa2ad1 --- /dev/null +++ b/src/Profiles/Environment/ANTPLUS_EnvironmentDataPages.h @@ -0,0 +1,7 @@ +#ifndef ANTPLUS_PROFILEENVIRONMENTDATAPAGES_h +#define ANTPLUS_PROFILEENVIRONMENTDATAPAGES_h + +#include +#include + +#endif // ANTPLUS_PROFILEENVIRONMENTDATAPAGES_h diff --git a/src/Profiles/Environment/ANTPLUS_EnvironmentDefines.h b/src/Profiles/Environment/ANTPLUS_EnvironmentDefines.h index efd7a2f..c85089c 100644 --- a/src/Profiles/Environment/ANTPLUS_EnvironmentDefines.h +++ b/src/Profiles/Environment/ANTPLUS_EnvironmentDefines.h @@ -1,7 +1,14 @@ #ifndef ANTPLUS_ENVIRONMENTPROFILEDEFINES_h #define ANTPLUS_ENVIRONMENTPROFILEDEFINES_h +#define ANTPLUS_ENVIRONMENT_DEVICETYPE 25 + +#define ANTPLUS_ENVIRONMENT_DATAPAGE_ENVIRONMENT_GENERALINFORMATION_NUMBER 0 + #define ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_SUPPORTEDPAGES_PAGE0SUPPORT 1 #define ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_SUPPORTEDPAGES_PAGE1SUPPORT 2 + +#define ANTPLUS_ENVIRONMENT_DATAPAGE_ENVIRONMENT_TEMPERATURE_NUMBER 1 + #endif // ANTPLUS_ENVIRONMENTPROFILEDEFINES_h diff --git a/src/Profiles/Environment/ANTPLUS_EnvironmentPrivateDefines.h b/src/Profiles/Environment/ANTPLUS_EnvironmentPrivateDefines.h index c277479..b562204 100644 --- a/src/Profiles/Environment/ANTPLUS_EnvironmentPrivateDefines.h +++ b/src/Profiles/Environment/ANTPLUS_EnvironmentPrivateDefines.h @@ -1,57 +1,11 @@ #ifndef ANTPLUS_ENVIRONMENTPROFILEPRIVATEDEFINES_h #define ANTPLUS_ENVIRONMENTPROFILEPRIVATEDEFINES_h +#include + /* Channel Config */ -#define ANTPLUS_ENVIRONMENT_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE -#define ANTPLUS_ENVIRONMENT_DEVICETYPE 25 -#define ANTPLUS_ENVIRONMENT_CHANNELPERIOD 8192 +#define ENVIRONMENT_CHANNELPERIOD 8192 // 45 / 2.5 = 18 -#define ANTPLUS_ENVIRONMENT_SEARCHTIMEOUT 18 - -/* Base DataPage */ -#define ANTPLUS_ENVIRONMENT_DATAPAGEBASE_DATAPAGE_BYTE 0 - -/* General Information DataPage */ -#define ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_NUMBER 0 - -/* Transmission Info */ -#define ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_TRANSMISSIONINFO_BYTE 3 - -#define ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_TRANSMISSIONINFO_LOCALTIME_MASK 0x30 -#define ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_TRANSMISSIONINFO_UTCTIME_MASK 0x0C -#define ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_TRANSMISSIONINFO_DEFAULTTRANSMISSIONRATE_MASK 0x03 - -#define ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_TRANSMISSIONINFO_LOCALTIME_SHIFT 4 -#define ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_TRANSMISSIONINFO_UTCTIME_SHIFT 2 - -/* Supported Pages */ -#define ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_SUPPORTEDPAGES_LSB_BYTE 4 -#define ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_SUPPORTEDPAGES_MSB_BYTE 7 - -/* Temperature DataPage */ -#define ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_NUMBER 1 - -/* Event Count */ -#define ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_EVENTCOUNT_BYTE 2 - -/* 24 Hour Low */ -#define ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_24HOURLOW_LSB_BYTE 3 -#define ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_24HOURLOW_MSB_BYTE 4 - -#define ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_24HOURLOW_MSB_MASK 0xF0 - -#define ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_24HOURLOW_MSB_SHIFT 4 - -/* 24 Hour High */ -#define ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_24HOURHIGH_LSB_BYTE 4 -#define ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_24HOURHIGH_MSB_BYTE 5 - -#define ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_24HOURHIGH_LSB_MASK 0x0F - -#define ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_24HOURHIGH_MSB_SHIFT 4 - -/* Current Temp */ -#define ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_CURRENTTEMP_LSB_BYTE 6 -#define ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_CURRENTTEMP_MSB_BYTE 7 +#define ENVIRONMENT_SEARCHTIMEOUT 18 #endif // ANTPLUS_ENVIRONMENTPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/Environment/ANTPLUS_EnvironmentProfile.h b/src/Profiles/Environment/ANTPLUS_EnvironmentProfile.h index 7a5a5a2..466e5ff 100644 --- a/src/Profiles/Environment/ANTPLUS_EnvironmentProfile.h +++ b/src/Profiles/Environment/ANTPLUS_EnvironmentProfile.h @@ -5,10 +5,10 @@ #include // Datapages -#include +#include // Profile Classes -#include -#include +#include +#include #endif // ANTPLUS_ENVIRONMENTPROFILE_h diff --git a/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseDataPage.cpp b/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentBaseDataPage.cpp similarity index 51% rename from src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseDataPage.cpp rename to src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentBaseDataPage.cpp index e89110b..be8a090 100644 --- a/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseDataPage.cpp +++ b/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentBaseDataPage.cpp @@ -1,5 +1,5 @@ -#include +#include #include -EnvironmentBaseDataPage::EnvironmentBaseDataPage(AntRxDataResponse& dp) : BaseDataPage(dp) { -} +EnvironmentBaseDataPage::EnvironmentBaseDataPage(AntRxDataResponse& dp) : + BaseDataPage(dp) {} diff --git a/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseDataPage.h b/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentBaseDataPage.h similarity index 79% rename from src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseDataPage.h rename to src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentBaseDataPage.h index f8fb62d..85f41c3 100644 --- a/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseDataPage.h +++ b/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentBaseDataPage.h @@ -3,11 +3,9 @@ #include -#include "ANT.h" - class EnvironmentBaseDataPage : public BaseDataPage { public: - EnvironmentBaseDataPage(AntRxDataResponse& dp); + explicit EnvironmentBaseDataPage(AntRxDataResponse& dp); }; #endif // ANTPLUS_ENVIRONMENTBASEMAINDATAPAGE_h diff --git a/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentGeneralInformation.cpp b/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentGeneralInformation.cpp new file mode 100644 index 0000000..5b48e24 --- /dev/null +++ b/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentGeneralInformation.cpp @@ -0,0 +1,46 @@ +#include +#include + +#define TRANSMISSIONINFO_BYTE 3 +#define TRANSMISSIONINFO_LOCALTIME_MASK 0x30 +#define TRANSMISSIONINFO_UTCTIME_MASK 0x0C +#define TRANSMISSIONINFO_DEFAULTTRANSMISSIONRATE_MASK 0x03 +#define TRANSMISSIONINFO_LOCALTIME_SHIFT 4 +#define TRANSMISSIONINFO_UTCTIME_SHIFT 2 +#define SUPPORTEDPAGES_LSB_BYTE 4 +#define SUPPORTEDPAGES_MSB_BYTE 7 + +template +EnvironmentBaseGeneralInformation::EnvironmentBaseGeneralInformation() : + CoreDataPage() {} + +template +uint8_t EnvironmentBaseGeneralInformation::getTransmissionInfoLocalTime() { + return this->get8BitValue(TRANSMISSIONINFO_BYTE, + TRANSMISSIONINFO_LOCALTIME_MASK, TRANSMISSIONINFO_LOCALTIME_SHIFT); +} + +template +uint8_t EnvironmentBaseGeneralInformation::getTransmissionInfoUtcTime() { + return this->get8BitValue(TRANSMISSIONINFO_BYTE, + TRANSMISSIONINFO_UTCTIME_MASK, TRANSMISSIONINFO_UTCTIME_SHIFT); +} + +template +uint8_t EnvironmentBaseGeneralInformation::getTransmissionInfoDefaultTransmissionRate() { + return this->get8BitValue(TRANSMISSIONINFO_BYTE, + TRANSMISSIONINFO_DEFAULTTRANSMISSIONRATE_MASK); +} + +template +uint32_t EnvironmentBaseGeneralInformation::getSupportedPages() { + return this->get32BitValue(SUPPORTEDPAGES_LSB_BYTE, + SUPPORTEDPAGES_MSB_BYTE); +} + +template class EnvironmentBaseGeneralInformation; +template class EnvironmentBaseGeneralInformation; + +EnvironmentGeneralInformation::EnvironmentGeneralInformation(AntRxDataResponse& dp) : + EnvironmentBaseDataPage(dp), + EnvironmentBaseGeneralInformation() {} diff --git a/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentGeneralInformation.h b/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentGeneralInformation.h new file mode 100644 index 0000000..5549c90 --- /dev/null +++ b/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentGeneralInformation.h @@ -0,0 +1,21 @@ +#ifndef ANTPLUS_ENVIRONMENTGENERALINFORMATION_h +#define ANTPLUS_ENVIRONMENTGENERALINFORMATION_h + +#include + +template +class EnvironmentBaseGeneralInformation : virtual public CoreDataPage { +public: + EnvironmentBaseGeneralInformation(); + uint8_t getTransmissionInfoLocalTime(); + uint8_t getTransmissionInfoUtcTime(); + uint8_t getTransmissionInfoDefaultTransmissionRate(); + uint32_t getSupportedPages(); +}; + +class EnvironmentGeneralInformation : public EnvironmentBaseDataPage, public EnvironmentBaseGeneralInformation { +public: + explicit EnvironmentGeneralInformation(AntRxDataResponse& dp); +}; + +#endif // ANTPLUS_ENVIRONMENTGENERALINFORMATION_h diff --git a/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentTemperature.cpp b/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentTemperature.cpp new file mode 100644 index 0000000..b9aca44 --- /dev/null +++ b/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentTemperature.cpp @@ -0,0 +1,58 @@ +#include +#include + +#define EVENTCOUNT_BYTE 2 +#define LOW24HOUR_LSB_BYTE 3 +#define LOW24HOUR_MSB_BYTE 4 +#define LOW24HOUR_MSB_MASK 0xF0 +#define LOW24HOUR_MSB_SHIFT 4 +#define HIGH24HOUR_LSB_BYTE 4 +#define HIGH24HOUR_MSB_BYTE 5 +#define HIGH24HOUR_LSB_MASK 0x0F +#define HIGH24HOUR_MSB_SHIFT 4 +#define CURRENTTEMP_LSB_BYTE 6 +#define CURRENTTEMP_MSB_BYTE 7 + +template +EnvironmentBaseTemperature::EnvironmentBaseTemperature() : + CoreDataPage() {} + +template +uint8_t EnvironmentBaseTemperature::getEventCount() { + return this->get8BitValue(EVENTCOUNT_BYTE); +} + +/* NOTE: this is a non-contigous data field, which resuls in the shenanigans below */ +template +int16_t EnvironmentBaseTemperature::get24HourLow() { + int16_t low = this->get8BitValue(LOW24HOUR_MSB_BYTE, LOW24HOUR_MSB_MASK); + low <<= LOW24HOUR_MSB_SHIFT; + low |= this->get8BitValue(LOW24HOUR_LSB_BYTE); + // extend bits if negative + low = (0x800 & low) ? low | 0xF000 : low; + return low; +} + +/* NOTE: this is a non-contigous data field, which resuls in the shenanigans below */ +template +int16_t EnvironmentBaseTemperature::get24HourHigh() { + int16_t high = this->get8BitValue(HIGH24HOUR_MSB_BYTE); + high <<= HIGH24HOUR_MSB_SHIFT; + high |= this->get8BitValue(HIGH24HOUR_LSB_BYTE, HIGH24HOUR_LSB_MASK); + // extend bits if negative + high = (0x800 & high) ? high | 0xF000 : high; + return high; +} + +template +int16_t EnvironmentBaseTemperature::getCurrentTemp() { + return this->get16BitValue(CURRENTTEMP_LSB_BYTE, CURRENTTEMP_MSB_BYTE); +} + +template class EnvironmentBaseTemperature; +template class EnvironmentBaseTemperature; + +EnvironmentTemperature::EnvironmentTemperature(AntRxDataResponse& dp) : + EnvironmentBaseDataPage(dp), + EnvironmentBaseTemperature() {} + diff --git a/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentTemperature.h b/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentTemperature.h new file mode 100644 index 0000000..b331de9 --- /dev/null +++ b/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentTemperature.h @@ -0,0 +1,22 @@ +#ifndef ANTPLUS_ENVIRONMENTTEMPERATURE_h +#define ANTPLUS_ENVIRONMENTTEMPERATURE_h + +#include + +template +class EnvironmentBaseTemperature : virtual public CoreDataPage { +public: + EnvironmentBaseTemperature(); + uint8_t getEventCount(); + int16_t get24HourLow(); + int16_t get24HourHigh(); + int16_t getCurrentTemp(); +}; + +class EnvironmentTemperature : public EnvironmentBaseDataPage, public EnvironmentBaseTemperature { +public: + explicit EnvironmentTemperature(AntRxDataResponse& dp); +}; + +#endif // ANTPLUS_ENVIRONMENTTEMPERATURE_h + diff --git a/src/Profiles/Environment/DataPages/ANTPLUS_ProfileEnvironmentDataPages.h b/src/Profiles/Environment/DataPages/ANTPLUS_ProfileEnvironmentDataPages.h deleted file mode 100644 index 63d7285..0000000 --- a/src/Profiles/Environment/DataPages/ANTPLUS_ProfileEnvironmentDataPages.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef ANTPLUS_PROFILEENVIRONMENTDATAPAGES_h -#define ANTPLUS_PROFILEENVIRONMENTDATAPAGES_h - -/* RX */ -#include -#include - -/* TX */ - -#endif // ANTPLUS_PROFILEENVIRONMENTDATAPAGES_h diff --git a/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseGeneralInformation.cpp b/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseGeneralInformation.cpp deleted file mode 100644 index 83b76b9..0000000 --- a/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseGeneralInformation.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include - -template -EnvironmentBaseGeneralInformation::EnvironmentBaseGeneralInformation() : CoreDataPage() { -} - -template -uint8_t EnvironmentBaseGeneralInformation::getTransmissionInfoLocalTime() { - return this->get8BitValue( - ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_TRANSMISSIONINFO_BYTE, - ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_TRANSMISSIONINFO_LOCALTIME_MASK, - ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_TRANSMISSIONINFO_LOCALTIME_SHIFT); -} - -template -uint8_t EnvironmentBaseGeneralInformation::getTransmissionInfoUtcTime() { - return this->get8BitValue( - ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_TRANSMISSIONINFO_BYTE, - ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_TRANSMISSIONINFO_UTCTIME_MASK, - ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_TRANSMISSIONINFO_UTCTIME_SHIFT); -} - -template -uint8_t EnvironmentBaseGeneralInformation::getTransmissionInfoDefaultTransmissionRate() { - return this->get8BitValue( - ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_TRANSMISSIONINFO_BYTE, - ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_TRANSMISSIONINFO_DEFAULTTRANSMISSIONRATE_MASK); -} - -template -uint32_t EnvironmentBaseGeneralInformation::getSupportedPages() { - return this->get32BitValue( - ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_SUPPORTEDPAGES_LSB_BYTE, - ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_SUPPORTEDPAGES_MSB_BYTE); -} - -template class EnvironmentBaseGeneralInformation; -template class EnvironmentBaseGeneralInformation; diff --git a/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseGeneralInformation.h b/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseGeneralInformation.h deleted file mode 100644 index 4c47cdd..0000000 --- a/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseGeneralInformation.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef ANTPLUS_ENVIRONMENTBASEGENERALINFORMATION_h -#define ANTPLUS_ENVIRONMENTBASEGENERALINFORMATION_h - -#include - -#include "ANT.h" - -template -class EnvironmentBaseGeneralInformation : virtual public CoreDataPage { -public: - EnvironmentBaseGeneralInformation(); - uint8_t getTransmissionInfoLocalTime(); - uint8_t getTransmissionInfoUtcTime(); - uint8_t getTransmissionInfoDefaultTransmissionRate(); - uint32_t getSupportedPages(); -}; - -#endif // ANTPLUS_ENVIRONMENTBASEGENERALINFORMATION_h diff --git a/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseTemperature.cpp b/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseTemperature.cpp deleted file mode 100644 index 5a6ea1c..0000000 --- a/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseTemperature.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include - -template -EnvironmentBaseTemperature::EnvironmentBaseTemperature() : CoreDataPage() { -} - -template -uint8_t EnvironmentBaseTemperature::getEventCount() { - return this->get8BitValue( - ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_EVENTCOUNT_BYTE); -} - -// TODO check if these can be replaced with get16bitValues -/* NOTE: this is a non-contigous data field, which resuls in the shenanigans below */ -template -int16_t EnvironmentBaseTemperature::get24HourLow() { - int16_t low = this->get8BitValue( - ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_24HOURLOW_MSB_BYTE, - ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_24HOURLOW_MSB_MASK); - low <<= ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_24HOURLOW_MSB_SHIFT; - low |= this->get8BitValue( - ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_24HOURLOW_LSB_BYTE); - // extend bits if negative - low = (0x800 & low) ? low | 0xF000 : low; - return low; -} - -/* NOTE: this is a non-contigous data field, which resuls in the shenanigans below */ -template -int16_t EnvironmentBaseTemperature::get24HourHigh() { - int16_t high = this->get8BitValue( - ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_24HOURHIGH_MSB_BYTE); - high <<= ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_24HOURHIGH_MSB_SHIFT; - high |= this->get8BitValue( - ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_24HOURHIGH_LSB_BYTE, - ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_24HOURHIGH_LSB_MASK); - // extend bits if negative - high = (0x800 & high) ? high | 0xF000 : high; - return high; -} - -template -int16_t EnvironmentBaseTemperature::getCurrentTemp() { - return this->get16BitValue( - ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_CURRENTTEMP_LSB_BYTE, - ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_CURRENTTEMP_MSB_BYTE); -} - -template class EnvironmentBaseTemperature; -template class EnvironmentBaseTemperature; diff --git a/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseTemperature.h b/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseTemperature.h deleted file mode 100644 index 9f36519..0000000 --- a/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseTemperature.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef ANTPLUS_ENVIRONMENTBASETEMPERATURE_h -#define ANTPLUS_ENVIRONMENTBASETEMPERATURE_h - -#include - -#include "ANT.h" - -template -class EnvironmentBaseTemperature : virtual public CoreDataPage { -public: - EnvironmentBaseTemperature(); - uint8_t getEventCount(); - int16_t get24HourLow(); - int16_t get24HourHigh(); - int16_t getCurrentTemp(); -}; - -#endif // ANTPLUS_ENVIRONMENTBASETEMPERATURE_h diff --git a/src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentGeneralInformation.cpp b/src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentGeneralInformation.cpp deleted file mode 100644 index 1908202..0000000 --- a/src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentGeneralInformation.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include -#include - -EnvironmentGeneralInformation::EnvironmentGeneralInformation(AntRxDataResponse& dp) : EnvironmentBaseDataPage(dp) { -} diff --git a/src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentGeneralInformation.h b/src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentGeneralInformation.h deleted file mode 100644 index c208172..0000000 --- a/src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentGeneralInformation.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_ENVIRONMENTGENERALINFORMATION_h -#define ANTPLUS_ENVIRONMENTGENERALINFORMATION_h - -#include -#include - -class EnvironmentGeneralInformation : public EnvironmentBaseDataPage, public EnvironmentBaseGeneralInformation { -public: - EnvironmentGeneralInformation(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_ENVIRONMENTGENERALINFORMATION_h diff --git a/src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentTemperature.cpp b/src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentTemperature.cpp deleted file mode 100644 index c2c110b..0000000 --- a/src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentTemperature.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include - -EnvironmentTemperature::EnvironmentTemperature(AntRxDataResponse& dp) : EnvironmentBaseDataPage(dp) { -} - diff --git a/src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentTemperature.h b/src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentTemperature.h deleted file mode 100644 index d3f48b6..0000000 --- a/src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentTemperature.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef ANTPLUS_ENVIRONMENTTEMPERATURE_h -#define ANTPLUS_ENVIRONMENTTEMPERATURE_h - -#include -#include - -class EnvironmentTemperature : public EnvironmentBaseDataPage, public EnvironmentBaseTemperature { -public: - EnvironmentTemperature(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_ENVIRONMENTTEMPERATURE_h - diff --git a/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.cpp b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.cpp similarity index 84% rename from src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.cpp rename to src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.cpp index b77fc32..6de1902 100644 --- a/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.cpp +++ b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.cpp @@ -1,6 +1,8 @@ -#include +#include #include -#include +#include + +#define DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE ProfileEnvironmentDisplay::ProfileEnvironmentDisplay() : BaseSlaveProfile() { setChannelConfig(); @@ -27,10 +29,10 @@ bool ProfileEnvironmentDisplay::handleDataPage(EnvironmentBaseDataPage& dp) { bool called = false; switch (dataPage) { - case ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_NUMBER: + case ANTPLUS_ENVIRONMENT_DATAPAGE_ENVIRONMENT_GENERALINFORMATION_NUMBER: called = handleGeneralInformation(dp); break; - case ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_NUMBER: + case ANTPLUS_ENVIRONMENT_DATAPAGE_ENVIRONMENT_TEMPERATURE_NUMBER: called = handleTemperature(dp); break; case ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER: @@ -53,10 +55,10 @@ void ProfileEnvironmentDisplay::onAcknowledgedData(AcknowledgedData& msg) { } void ProfileEnvironmentDisplay::setChannelConfig() { - setChannelType(ANTPLUS_ENVIRONMENT_CHANNELTYPE); + setChannelType(DISPLAY_CHANNELTYPE); setDeviceType(ANTPLUS_ENVIRONMENT_DEVICETYPE); - setChannelPeriod(ANTPLUS_ENVIRONMENT_CHANNELPERIOD); - setSearchTimeout(ANTPLUS_ENVIRONMENT_SEARCHTIMEOUT); + setChannelPeriod(ENVIRONMENT_CHANNELPERIOD); + setSearchTimeout(ENVIRONMENT_SEARCHTIMEOUT); } bool ProfileEnvironmentDisplay::handleGeneralInformation(EnvironmentBaseDataPage& dataPage) { diff --git a/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.h b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.h similarity index 81% rename from src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.h rename to src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.h index 8f1360e..c255f6c 100644 --- a/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.h +++ b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.h @@ -2,16 +2,14 @@ #define ANTPLUS_PROFILEENVIRONMENTDISPLAY_h #include -#include +#include #include -#include "ANT.h" - class ProfileEnvironmentDisplay : public BaseSlaveProfile { public: ProfileEnvironmentDisplay(); - ProfileEnvironmentDisplay(uint16_t deviceNumber); - ProfileEnvironmentDisplay(uint16_t deviceNumber, uint8_t transmissionType); + explicit ProfileEnvironmentDisplay(uint16_t deviceNumber); + explicit ProfileEnvironmentDisplay(uint16_t deviceNumber, uint8_t transmissionType); void onEnvironmentGeneralInformation(void (*func)(EnvironmentGeneralInformation&, uintptr_t), uintptr_t data = 0) { _onEnvironmentGeneralInformation.set(func, data); } void onEnvironmentTemperature(void (*func)(EnvironmentTemperature&, uintptr_t), uintptr_t data = 0) { _onEnvironmentTemperature.set(func, data); } void onManufacturersInformation(void (*func)(ManufacturersInformation&, uintptr_t), uintptr_t data = 0) { _onManufacturersInformation.set(func, data); } @@ -28,10 +26,10 @@ class ProfileEnvironmentDisplay : public BaseSlaveProfile { bool handleTemperature(EnvironmentBaseDataPage& dataPage); bool handleManufacturersInformation(EnvironmentBaseDataPage& dataPage); bool handleProductInformation(EnvironmentBaseDataPage& dataPage); - AntCallback _onEnvironmentGeneralInformation; - AntCallback _onEnvironmentTemperature; - AntCallback _onManufacturersInformation; - AntCallback _onProductInformation; + AntCallback _onEnvironmentGeneralInformation = { .func = NULL }; + AntCallback _onEnvironmentTemperature = { .func = NULL }; + AntCallback _onManufacturersInformation = { .func = NULL }; + AntCallback _onProductInformation = { .func = NULL }; }; #endif // ANTPLUS_PROFILEENVIRONMENTDISPLAY_h diff --git a/src/Profiles/Environment/Monitor/ANTPLUS_ProfileEnvironmentMonitor.h b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentMonitor.h similarity index 67% rename from src/Profiles/Environment/Monitor/ANTPLUS_ProfileEnvironmentMonitor.h rename to src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentMonitor.h index 533aebc..eb60f67 100644 --- a/src/Profiles/Environment/Monitor/ANTPLUS_ProfileEnvironmentMonitor.h +++ b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentMonitor.h @@ -2,12 +2,13 @@ #define ANTPLUS_PROFILEENVIRONMENTMONITOR_h #include -#include +#include #include class ProfileEnvironmentMonitor : BaseMasterProfile { public: // TODO + explicit ProfileEnvironmentMonitor(uint16_t deviceNumber, uint8_t transmissionType = 0); }; #endif // ANTPLUS_PROFILEENVIRONMENTMONITOR_h diff --git a/src/Profiles/Fec/ANTPLUS_FecDataPages.h b/src/Profiles/Fec/ANTPLUS_FecDataPages.h new file mode 100644 index 0000000..29abb1c --- /dev/null +++ b/src/Profiles/Fec/ANTPLUS_FecDataPages.h @@ -0,0 +1,13 @@ +#ifndef ANTPLUS_PROFILEFECDATAPAGES_h +#define ANTPLUS_PROFILEFECDATAPAGES_h + +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // ANTPLUS_PROFILEFECDATAPAGES_h diff --git a/src/Profiles/Fec/ANTPLUS_FecDefines.h b/src/Profiles/Fec/ANTPLUS_FecDefines.h new file mode 100644 index 0000000..b541d91 --- /dev/null +++ b/src/Profiles/Fec/ANTPLUS_FecDefines.h @@ -0,0 +1,96 @@ +#ifndef ANTPLUS_FECPROFILEDEFINES_h +#define ANTPLUS_FECPROFILEDEFINES_h + +#define ANTPLUS_FEC_REALTIMECHANNEL_DEVICETYPE 17 +// TODO there are multiple device types for this profile + +#define ANTPLUS_FEC_DATAPAGE_FESTATE_RESERVED 0 +#define ANTPLUS_FEC_DATAPAGE_FESTATE_ASLEEP 1 +#define ANTPLUS_FEC_DATAPAGE_FESTATE_READY 2 +#define ANTPLUS_FEC_DATAPAGE_FESTATE_INUSE 3 +#define ANTPLUS_FEC_DATAPAGE_FESTATE_FINISHED 4 + + +/* General FE Data */ +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_NUMBER 16 + +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_GENERAL 16 +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_TREADMILL 19 +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_ELLIPTICAL 20 +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_STATIONARYBIKE 21 +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_ROWER 22 +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_CLIMBER 23 +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_NORDICSKIER 24 +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_TRAINER 25 + +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_SPEED_INVALID 0xFFFF + +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_HEARTRATE_INVALID 0xFF + +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_HRDATASOURCE_INVALID 0 +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_HRDATASOURCE_ANTPLUSMONITOR 1 +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_HRDATASOURCE_EMMONITOR 2 +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_HRDATASOURCE_HANDSCONTACT 3 + +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_DISTANCETRAVELED_ENABLED 1 + +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_VIRTUALSPEEDFLAG_VIRTUALSPEED 1 + +/* FE Capabilities */ +#define ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_NUMBER 54 + +#define ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_MAXIMUM_RESISTANCE_INVALID 0xFFFF + + +/* General Settings Page */ +#define ANTPLUS_FEC_DATAPAGE_GENERALSETTINGSPAGE_NUMBER 17 + +#define ANTPLUS_FEC_DATAPAGE_GENERALSETTINGSPAGE_CYCLELENGTH_INVALID 0xFF + +#define ANTPLUS_FEC_DATAPAGE_GENERALSETTINGSPAGE_INCLINE_INVALID 0x7FFF + +#define ANTPLUS_FEC_DATAPAGE_GENERALSETTINGSPAGE_RESISTANCELEVEL_INVALID 0xFF + + +/* Specifc Trainer Data */ +#define ANTPLUS_FEC_DATAPAGE_SPECIFICTRAINERDATA_NUMBER 25 + +#define ANTPLUS_FEC_DATAPAGE_SPECIFICTRAINERDATA_INSTANTANEOUSCADENCE_INVALID 0xFF + +#define ANTPLUS_FEC_DATAPAGE_SPECIFICTRAINERDATA_INSTANTANEOUSPOWER_INVALID 0xFFF + +#define ANTPLUS_FEC_DATAPAGE_SPECIFICTRAINERDATA_TARGETPOWERLIMITS_ATTARGET 0 +#define ANTPLUS_FEC_DATAPAGE_SPECIFICTRAINERDATA_TARGETPOWERLIMITS_SPEEDTOOLOW 1 +#define ANTPLUS_FEC_DATAPAGE_SPECIFICTRAINERDATA_TARGETPOWERLIMITS_SPEEDTOOHIGH 2 +#define ANTPLUS_FEC_DATAPAGE_SPECIFICTRAINERDATA_TARGETPOWERLIMITS_UNDERTERMINED 3 + +/* Basic Resistance */ +#define ANTPLUS_FEC_DATAPAGE_BASICRESISTANCE_NUMBER 48 + + +/* Target Power */ +#define ANTPLUS_FEC_DATAPAGE_TARGETPOWER_NUMBER 49 + + +/* Track Resistance */ +#define ANTPLUS_FEC_DATAPAGE_TRACKRESISTANCE_NUMBER 51 + +#define ANTPLUS_FEC_DATAPAGE_TRACKRESISTANCE_GRADE_INVALID 0xFFFF + +#define ANTPLUS_FEC_DATAPAGE_TRACKRESISTANCE_COEFFICIENTOFROLLINGRESISTANCE_INVALID 0xFF + + +/* User Configuration */ +#define ANTPLUS_FEC_DATAPAGE_USERCONFIGURATION_NUMBER 55 + +#define ANTPLUS_FEC_DATAPAGE_USERCONFIGURATION_USERWEIGHT_INVALID 0xFFFF + +#define ANTPLUS_FEC_DATAPAGE_USERCONFIGURATION_BICYCLEWHEELDIAMETEROFFSET_INVALID 0xF + +#define ANTPLUS_FEC_DATAPAGE_USERCONFIGURATION_BICYCLEWEIGHT_INVALID 0xFFF + +#define ANTPLUS_FEC_DATAPAGE_USERCONFIGURATION_BICYCLEWHEELDIAMETER_INVALID 0xFF + +#define ANTPLUS_FEC_DATAPAGE_USERCONFIGURATION_GEARRATIO_INVALID 0 + +#endif // ANTPLUS_FECPROFILEDEFINES_h diff --git a/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h b/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h new file mode 100644 index 0000000..420f0ee --- /dev/null +++ b/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h @@ -0,0 +1,20 @@ +#ifndef ANTPLUS_FECPROFILEPRIVATEDEFINES_h +#define ANTPLUS_FECPROFILEPRIVATEDEFINES_h + +#include + +/* Channel Config */ +#define ANTPLUS_FEC_MONITOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT +#define ANTPLUS_FEC_CHANNELPERIOD 8192 +// 30 / 2.5 = 12 +#define ANTPLUS_FEC_SEARCHTIMEOUT 12 + +// Field common to some base messages +#define FESTATE_BYTE 7 +#define FESTATE_MASK 0x70 +#define FESTATE_SHIFT 4 +#define LAPTOGGLEBIT_BYTE 7 +#define LAPTOGGLEBIT_MASK 0x80 +#define LAPTOGGLEBIT_SHIFT 7 + +#endif // ANTPLUS_FECPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/Fec/ANTPLUS_FecProfile.h b/src/Profiles/Fec/ANTPLUS_FecProfile.h new file mode 100644 index 0000000..fc9a540 --- /dev/null +++ b/src/Profiles/Fec/ANTPLUS_FecProfile.h @@ -0,0 +1,14 @@ +#ifndef ANTPLUS_FECPROFILE_h +#define ANTPLUS_FECPROFILE_h + +// General Definitions +#include + +// Datapages +#include + +// Profile Classes +#include +// #include + +#endif // ANTPLUS_FECPROFILE_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecBaseMainDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecBaseMainDataPage.cpp new file mode 100644 index 0000000..d125920 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecBaseMainDataPage.cpp @@ -0,0 +1,12 @@ +#include +#include + +FecBaseMainDataPage::FecBaseMainDataPage(AntRxDataResponse& dp) : + BaseDataPage(dp) {} + +FecBaseMainDataPageMsg::FecBaseMainDataPageMsg(uint8_t dataPageNumber) : + BaseDataPageMsg() { + setDataBuffer(_buffer); + set8BitValue(dataPageNumber, ANTPLUS_DEFAULT_DATAPAGE_BYTE); +} + diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecBaseMainDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecBaseMainDataPage.h new file mode 100644 index 0000000..e505b7d --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecBaseMainDataPage.h @@ -0,0 +1,19 @@ +#ifndef ANTPLUS_FECBASEMAINDATAPAGE_h +#define ANTPLUS_FECBASEMAINDATAPAGE_h + +#include +#include + +class FecBaseMainDataPage : public BaseDataPage { +public: + explicit FecBaseMainDataPage(AntRxDataResponse& dp); +}; + +class FecBaseMainDataPageMsg : public BaseDataPageMsg { +public: + explicit FecBaseMainDataPageMsg(uint8_t dataPageNumber); +protected: + uint8_t _buffer[MESSAGE_SIZE] = {0}; +}; + +#endif // ANTPLUS_FECBASEMAINDATAPAGE_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistance.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistance.cpp new file mode 100644 index 0000000..6faa4b9 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistance.cpp @@ -0,0 +1,37 @@ +#include +#include + +#define RESERVED0_LSB_BYTE 1 +#define RESERVED0_MSB_BYTE 4 +#define RESERVED0_VALUE 0xFFFFFFFF +#define RESERVED1_LSB_BYTE 5 +#define RESERVED1_MSB_BYTE 6 +#define RESERVED1_VALUE 0xFFFF +#define TOTAL_RESISTANCE_BYTE 7 + +template +FecBaseBasicResistance::FecBaseBasicResistance() : + CoreDataPage() {} + +template +uint8_t FecBaseBasicResistance::getTotalResistance() { + return this->get8BitValue(TOTAL_RESISTANCE_BYTE); +} + +template class FecBaseBasicResistance; +template class FecBaseBasicResistance; + +FecBasicResistance::FecBasicResistance(AntRxDataResponse& dp) : + FecBaseMainDataPage(dp), + FecBaseBasicResistance() {} + +FecBasicResistanceMsg::FecBasicResistanceMsg() : + FecBaseMainDataPageMsg(ANTPLUS_FEC_DATAPAGE_TRACKRESISTANCE_NUMBER), + FecBaseBasicResistance() { + set32BitValue(RESERVED0_VALUE, RESERVED0_LSB_BYTE, RESERVED0_MSB_BYTE); + set16BitValue(RESERVED1_VALUE, RESERVED1_LSB_BYTE, RESERVED1_MSB_BYTE); +} + +void FecBasicResistanceMsg::setTotalResistance(uint8_t totalResistance) { + set8BitValue(totalResistance, TOTAL_RESISTANCE_BYTE); +} diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistance.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistance.h new file mode 100644 index 0000000..7bb4e69 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistance.h @@ -0,0 +1,25 @@ +#ifndef ANTPLUS_FECBASICRESISTANCE_h +#define ANTPLUS_FECBASICRESISTANCE_h + +#include + +template +class FecBaseBasicResistance : virtual public CoreDataPage { +public: + FecBaseBasicResistance(); + uint8_t getTotalResistance(); +}; + +class FecBasicResistance : public FecBaseMainDataPage, public FecBaseBasicResistance { +public: + explicit FecBasicResistance(AntRxDataResponse& dp); +}; + +class FecBasicResistanceMsg : public FecBaseMainDataPageMsg, public FecBaseBasicResistance { +public: + FecBasicResistanceMsg(); + void setTotalResistance(uint8_t totalResistance); +}; + + +#endif // ANTPLUS_FECBASICRESISTANCE_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.cpp new file mode 100644 index 0000000..65d1a46 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.cpp @@ -0,0 +1,80 @@ +#include +#include + +#define MAXIMUM_RESISTANCE_LSB_BYTE 5 +#define MAXIMUM_RESISTANCE_MSB_BYTE 6 +#define BASICRESISTANCEMODESUPPORT_BYTE 7 +#define BASICRESISTANCEMODESUPPORT_MASK 0x1 +#define TARGETPOWERMODESUPPORT_BYTE 7 +#define TARGETPOWERMODESUPPORT_MASK 0x2 +#define TARGETPOWERMODESUPPORT_SHIFT 1 +#define SIMULATIONMODESUPPORT_BYTE 7 +#define SIMULATIONMODESUPPORT_MASK 0x4 +#define SIMULATIONMODESUPPORT_SHIFT 2 +#define RESERVED_LSB_BYTE 1 +#define RESERVED_MSB_BYTE 4 +#define RESERVED_VALUE 0xFFFFFFFF + +template +FecBaseFeCapabilities::FecBaseFeCapabilities() : + CoreDataPage() {} + +template +uint16_t FecBaseFeCapabilities::getMaximumResistance() { + return this->get16BitValue(MAXIMUM_RESISTANCE_LSB_BYTE, MAXIMUM_RESISTANCE_MSB_BYTE); +} + +template +uint8_t FecBaseFeCapabilities::getBasicResistanceModeSupport() { + return this->get8BitValue(BASICRESISTANCEMODESUPPORT_BYTE, BASICRESISTANCEMODESUPPORT_MASK); +} + +template +uint8_t FecBaseFeCapabilities::getTargetPowerModeSupport() { + return this->get8BitValue(TARGETPOWERMODESUPPORT_BYTE, + TARGETPOWERMODESUPPORT_MASK, + TARGETPOWERMODESUPPORT_SHIFT); +} + +template +uint8_t FecBaseFeCapabilities::getSimulationModeSupport() { + return this->get8BitValue(SIMULATIONMODESUPPORT_BYTE, + SIMULATIONMODESUPPORT_MASK, + SIMULATIONMODESUPPORT_SHIFT); +} + +template class FecBaseFeCapabilities; +template class FecBaseFeCapabilities; + +FecFeCapabilities::FecFeCapabilities(AntRxDataResponse& dp) : + FecBaseMainDataPage(dp), + FecBaseFeCapabilities() {} + +FecFeCapabilitiesMsg::FecFeCapabilitiesMsg() : + FecBaseMainDataPageMsg(ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_NUMBER), + FecBaseFeCapabilities() { + this->set32BitValue(RESERVED_VALUE, RESERVED_LSB_BYTE, RESERVED_MSB_BYTE); + setMaximumResistance(ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_MAXIMUM_RESISTANCE_INVALID); +} + +void FecFeCapabilitiesMsg::setMaximumResistance(uint16_t maximumResistance) { + set16BitValue(maximumResistance, MAXIMUM_RESISTANCE_LSB_BYTE, MAXIMUM_RESISTANCE_MSB_BYTE); +} + +void FecFeCapabilitiesMsg::setBasicResistanceModeSupport(uint8_t support) { + set8BitValue(support, BASICRESISTANCEMODESUPPORT_BYTE, BASICRESISTANCEMODESUPPORT_MASK); +} + +void FecFeCapabilitiesMsg::setTargetPowerModeSupport(uint8_t support) { + set8BitValue(support, + TARGETPOWERMODESUPPORT_BYTE, + TARGETPOWERMODESUPPORT_MASK, + TARGETPOWERMODESUPPORT_SHIFT); +} + +void FecFeCapabilitiesMsg::setSimulationModeSupport(uint8_t support) { + set8BitValue(support, + SIMULATIONMODESUPPORT_BYTE, + SIMULATIONMODESUPPORT_MASK, + SIMULATIONMODESUPPORT_SHIFT); +} diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.h new file mode 100644 index 0000000..169dcc2 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.h @@ -0,0 +1,31 @@ +#ifndef ANTPLUS_FECFECAPABILITIES_h +#define ANTPLUS_FECFECAPABILITIES_h + +#include + +template +class FecBaseFeCapabilities : virtual public CoreDataPage { +public: + FecBaseFeCapabilities(); + uint16_t getMaximumResistance(); + uint8_t getBasicResistanceModeSupport(); + uint8_t getTargetPowerModeSupport(); + uint8_t getSimulationModeSupport(); +}; + +class FecFeCapabilities : public FecBaseMainDataPage, public FecBaseFeCapabilities { +public: + explicit FecFeCapabilities(AntRxDataResponse& dp); +}; + +class FecFeCapabilitiesMsg : public FecBaseMainDataPageMsg, public FecBaseFeCapabilities { +public: + FecFeCapabilitiesMsg(); + void setMaximumResistance(uint16_t UserWeight); + void setBasicResistanceModeSupport(uint8_t support); + void setTargetPowerModeSupport(uint8_t support); + void setSimulationModeSupport(uint8_t support); +}; + +#endif // ANTPLUS_FECFECAPABILITIES_h + diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.cpp new file mode 100644 index 0000000..78f88f4 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.cpp @@ -0,0 +1,134 @@ +#include +#include + +#define FETYPE_BYTE 1 +#define FETYPE_MASK 0x1F +#define ELAPSEDTIME_BYTE 2 +#define DISTANCETRAVELED_BYTE 3 +#define SPEED_LSB_BYTE 4 +#define SPEED_MSB_BYTE 5 +#define HEARTRATE_BYTE 6 +#define HRDATASOURCE_BYTE 7 +#define HRDATASOURCE_MASK 0x03 +#define DISTANCETRAVELEDENABLED_BYTE 7 +#define DISTANCETRAVELEDENABLED_MASK 0x04 +#define DISTANCETRAVELEDENABLED_SHIFT 2 +#define VIRTUALSPEEDFLAG_BYTE 7 +#define VIRTUALSPEEDFLAG_MASK 0x08 +#define VIRTUALSPEEDFLAG_SHIFT 3 + +template +FecBaseGeneralFeData::FecBaseGeneralFeData() : CoreDataPage() {} + +template +uint8_t FecBaseGeneralFeData::getFeType() { + return this->get8BitValue(FETYPE_BYTE, FETYPE_MASK); +} + +template +uint8_t FecBaseGeneralFeData::getElapsedTime() { + return this->get8BitValue(ELAPSEDTIME_BYTE); +} + +template +uint8_t FecBaseGeneralFeData::getDistanceTraveled() { + return this->get8BitValue(DISTANCETRAVELED_BYTE); +} + +template +uint16_t FecBaseGeneralFeData::getSpeed() { + return this->get16BitValue(SPEED_LSB_BYTE, SPEED_MSB_BYTE); +} + +template +uint8_t FecBaseGeneralFeData::getHeartRate() { + return this->get8BitValue(HEARTRATE_BYTE); +} + +template +uint8_t FecBaseGeneralFeData::getHrDataSource() { + return this->get8BitValue(HRDATASOURCE_BYTE, HRDATASOURCE_MASK); +} + +template +uint8_t FecBaseGeneralFeData::getDistanceTraveledEnabled() { + return this->get8BitValue(DISTANCETRAVELEDENABLED_BYTE, + DISTANCETRAVELEDENABLED_MASK, + DISTANCETRAVELEDENABLED_SHIFT); +} + +template +uint8_t FecBaseGeneralFeData::getVirtualSpeedFlag() { + return this->get8BitValue(VIRTUALSPEEDFLAG_BYTE, + VIRTUALSPEEDFLAG_MASK, + VIRTUALSPEEDFLAG_SHIFT); +} + +template +uint8_t FecBaseGeneralFeData::getFeState() { + return this->get8BitValue(FESTATE_BYTE, FESTATE_MASK, FESTATE_SHIFT); +} + +template +uint8_t FecBaseGeneralFeData::getLapToggleBit() { + return this->get8BitValue(LAPTOGGLEBIT_BYTE, LAPTOGGLEBIT_MASK, LAPTOGGLEBIT_SHIFT); +} + +template class FecBaseGeneralFeData; +template class FecBaseGeneralFeData; + +FecGeneralFeData::FecGeneralFeData(AntRxDataResponse& dp) : + FecBaseMainDataPage(dp), + FecBaseGeneralFeData() {} + +FecGeneralFeDataMsg::FecGeneralFeDataMsg() : + FecBaseMainDataPageMsg(ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_NUMBER), + FecBaseGeneralFeData() { + setSpeed(ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_SPEED_INVALID); + setHeartRate(ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_HEARTRATE_INVALID); + setFeType(ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_GENERAL); + setHrDataSource(ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_HRDATASOURCE_INVALID); + setFeState(ANTPLUS_FEC_DATAPAGE_FESTATE_INUSE); +} + +void FecGeneralFeDataMsg::setFeType(uint8_t fe_type) { +} + +void FecGeneralFeDataMsg::setElapsedTime(uint8_t time) { + set8BitValue(time, ELAPSEDTIME_BYTE); +} + +void FecGeneralFeDataMsg::setDistanceTraveled(uint8_t distance) { + set8BitValue(distance, DISTANCETRAVELED_BYTE); +} + +void FecGeneralFeDataMsg::setSpeed(uint16_t speed) { + set16BitValue(speed, SPEED_LSB_BYTE, SPEED_MSB_BYTE); +} + +void FecGeneralFeDataMsg::setHeartRate(uint8_t hr) { + set8BitValue(hr, HEARTRATE_BYTE); +} + +void FecGeneralFeDataMsg::setHrDataSource(uint8_t source) { + set8BitValue(source, HRDATASOURCE_BYTE, HRDATASOURCE_MASK); +} + +void FecGeneralFeDataMsg::setDistanceTraveledEnabled(uint8_t enabled) { + set8BitValue(enabled, + DISTANCETRAVELEDENABLED_BYTE, + DISTANCETRAVELEDENABLED_MASK, + DISTANCETRAVELEDENABLED_SHIFT); +} + +void FecGeneralFeDataMsg::setVirtualSpeedFlag(uint8_t real) { + set8BitValue(real, VIRTUALSPEEDFLAG_BYTE, VIRTUALSPEEDFLAG_MASK, VIRTUALSPEEDFLAG_SHIFT); +} + +void FecGeneralFeDataMsg::setFeState(uint8_t state) { + set8BitValue(state, FESTATE_BYTE, FESTATE_MASK, FESTATE_SHIFT); +} + +void FecGeneralFeDataMsg::setLapToggleBit(uint8_t bit) { + set8BitValue(bit, LAPTOGGLEBIT_BYTE, LAPTOGGLEBIT_MASK, LAPTOGGLEBIT_SHIFT); +} diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.h new file mode 100644 index 0000000..a700668 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.h @@ -0,0 +1,43 @@ +#ifndef ANTPLUS_FECGENERALFEDATA_h +#define ANTPLUS_FECGENERALFEDATA_h + +#include + +template +class FecBaseGeneralFeData : virtual public CoreDataPage { +public: + FecBaseGeneralFeData(); + uint8_t getFeType(); + uint8_t getElapsedTime(); + uint8_t getDistanceTraveled(); + uint16_t getSpeed(); + uint8_t getHeartRate(); + uint8_t getHrDataSource(); + uint8_t getDistanceTraveledEnabled(); + uint8_t getVirtualSpeedFlag(); + uint8_t getFeState(); + uint8_t getLapToggleBit(); +}; + +class FecGeneralFeData : public FecBaseMainDataPage, public FecBaseGeneralFeData { +public: + explicit FecGeneralFeData(AntRxDataResponse& dp); +}; + +class FecGeneralFeDataMsg : public FecBaseMainDataPageMsg, public FecBaseGeneralFeData { +public: + FecGeneralFeDataMsg(); + void setFeType(uint8_t fe_type); + void setElapsedTime(uint8_t time); + void setDistanceTraveled(uint8_t distance); + void setSpeed(uint16_t speed); + void setHeartRate(uint8_t hr); + void setHrDataSource(uint8_t source); + void setDistanceTraveledEnabled(uint8_t enabled); + void setVirtualSpeedFlag(uint8_t real); + void setFeState(uint8_t state); + void setLapToggleBit(uint8_t toggle); +}; + + +#endif // ANTPLUS_FECGENERALFEDATA_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsPage.cpp new file mode 100644 index 0000000..5d21b12 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsPage.cpp @@ -0,0 +1,72 @@ +#include +#include + +#define CYCLE_LENGTH_BYTE 3 +#define INCLINE_LSB_BYTE 4 +#define INCLINE_MSB_BYTE 5 +#define RESISTANTCE_LEVEL_BYTE 6 + +template +FecBaseGeneralSettingsPage::FecBaseGeneralSettingsPage() : + CoreDataPage() {} + +template +uint8_t FecBaseGeneralSettingsPage::getCycleLength() { + return this->get8BitValue(CYCLE_LENGTH_BYTE); +} + +template +uint16_t FecBaseGeneralSettingsPage::getIncline() { + return this->get16BitValue(INCLINE_LSB_BYTE, INCLINE_MSB_BYTE); +} + +template +uint8_t FecBaseGeneralSettingsPage::getResistanceLevel() { + return this->get8BitValue(RESISTANTCE_LEVEL_BYTE); +} + +template +uint8_t FecBaseGeneralSettingsPage::getFeState() { + return this->get8BitValue(FESTATE_BYTE, FESTATE_MASK, FESTATE_SHIFT); +} + +template +uint8_t FecBaseGeneralSettingsPage::getLapToggleBit() { + return this->get8BitValue(LAPTOGGLEBIT_BYTE, LAPTOGGLEBIT_MASK, LAPTOGGLEBIT_SHIFT); +} + +template class FecBaseGeneralSettingsPage; +template class FecBaseGeneralSettingsPage; + +FecGeneralSettingsPage::FecGeneralSettingsPage(AntRxDataResponse& dp) : + FecBaseMainDataPage(dp), + FecBaseGeneralSettingsPage() {} + +FecGeneralSettingsPageMsg::FecGeneralSettingsPageMsg() : + FecBaseMainDataPageMsg(ANTPLUS_FEC_DATAPAGE_GENERALSETTINGSPAGE_NUMBER), + FecBaseGeneralSettingsPage() { + setCycleLength(ANTPLUS_FEC_DATAPAGE_GENERALSETTINGSPAGE_CYCLELENGTH_INVALID); + setIncline(ANTPLUS_FEC_DATAPAGE_GENERALSETTINGSPAGE_INCLINE_INVALID); + setResistanceLevel(ANTPLUS_FEC_DATAPAGE_GENERALSETTINGSPAGE_RESISTANCELEVEL_INVALID); + setFeState(ANTPLUS_FEC_DATAPAGE_FESTATE_INUSE); +} + +void FecGeneralSettingsPageMsg::setCycleLength(uint8_t cycleLength) { + set8BitValue(cycleLength, CYCLE_LENGTH_BYTE); +} + +void FecGeneralSettingsPageMsg::setIncline(uint16_t incline) { + set16BitValue(incline, INCLINE_LSB_BYTE, INCLINE_MSB_BYTE); +} + +void FecGeneralSettingsPageMsg::setResistanceLevel(uint8_t resistanceLevel) { + set8BitValue(resistanceLevel, RESISTANTCE_LEVEL_BYTE); +} + +void FecGeneralSettingsPageMsg::setFeState(uint8_t state) { + set8BitValue(state, FESTATE_BYTE, FESTATE_MASK, FESTATE_SHIFT); +} + +void FecGeneralSettingsPageMsg::setLapToggleBit(uint8_t bit) { + set8BitValue(bit, LAPTOGGLEBIT_BYTE, LAPTOGGLEBIT_MASK, LAPTOGGLEBIT_SHIFT); +} diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsPage.h new file mode 100644 index 0000000..71ff4da --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsPage.h @@ -0,0 +1,34 @@ +#ifndef ANTPLUS_FECGENERALSEETTINGSPAGE_h +#define ANTPLUS_FECGENERALSEETTINGSPAGE_h + +#include + +template +class FecBaseGeneralSettingsPage : virtual public CoreDataPage { +public: + FecBaseGeneralSettingsPage(); + uint8_t getCycleLength(); + uint16_t getIncline(); + uint8_t getResistanceLevel(); + // Capability bits are reserved + uint8_t getFeState(); + uint8_t getLapToggleBit(); +}; + +class FecGeneralSettingsPage : public FecBaseMainDataPage, public FecBaseGeneralSettingsPage { +public: + explicit FecGeneralSettingsPage(AntRxDataResponse& dp); +}; + +class FecGeneralSettingsPageMsg : public FecBaseMainDataPageMsg, public FecBaseGeneralSettingsPage { +public: + FecGeneralSettingsPageMsg(); + void setCycleLength(uint8_t cycleLength); + void setIncline(uint16_t incline); + void setResistanceLevel(uint8_t resistanceLevel); + // Capability bits are reserved + void setFeState(uint8_t state); + void setLapToggleBit(uint8_t toggle); +}; + +#endif // ANTPLUS_FECGENERALSETTINGSPAGE_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp new file mode 100644 index 0000000..e42091b --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp @@ -0,0 +1,145 @@ +#include +#include + +#define UPDATEEVENTCOUNT_BYTE 1 +#define INSTANTANEOUSCADENCE_BYTE 2 +#define ACCUMULATEDPOWER_LSB_BYTE 3 +#define ACCUMULATEDPOWER_MSB_BYTE 4 +#define INSTANTANEOUSPOWER_LSB_BYTE 5 +#define INSTANTANEOUSPOWER_MSB_BYTE 6 +#define INSTANTANEOUSPOWER_MSB_MASK 0x0FFF +#define BICYCLEPOWERCALIBRATION_BYTE 6 +#define BICYCLEPOWERCALIBRATION_MASK 0x10 +#define BICYCLEPOWERCALIBRATION_SHIFT 4 +#define RESISTANCECALIBRATION_BYTE 6 +#define RESISTANCECALIBRATION_MASK 0x20 +#define RESISTANCECALIBRATION_SHIFT 5 +#define USERCONFIGURATION_BYTE 6 +#define USERCONFIGURATION_MASK 0x40 +#define USERCONFIGURATION_SHIFT 6 +#define TARGETPOWERLIMITS_BYTE 7 +#define TARGETPOWERLIMITS_MASK 0x03 + +template +FecBaseSpecificTrainerData::FecBaseSpecificTrainerData() : + CoreDataPage() {} + +template +uint8_t FecBaseSpecificTrainerData::getUpdateEventCount() { + return this->get8BitValue(UPDATEEVENTCOUNT_BYTE); +} + +template +uint8_t FecBaseSpecificTrainerData::getInstantaneousCadence() { + return this->get8BitValue(INSTANTANEOUSCADENCE_BYTE); +} + +template +uint16_t FecBaseSpecificTrainerData::getAccumulatedPower() { + return this->get16BitValue(ACCUMULATEDPOWER_LSB_BYTE, + ACCUMULATEDPOWER_MSB_BYTE); +} + +template +uint16_t FecBaseSpecificTrainerData::getInstantaneousPower() { + return this->get16BitValue(INSTANTANEOUSPOWER_LSB_BYTE, + INSTANTANEOUSPOWER_MSB_BYTE, + INSTANTANEOUSPOWER_MSB_MASK); +} + +template +uint8_t FecBaseSpecificTrainerData::getBicyclePowerCalibration() { + return this->get8BitValue(BICYCLEPOWERCALIBRATION_BYTE, + BICYCLEPOWERCALIBRATION_MASK, + BICYCLEPOWERCALIBRATION_SHIFT); +} + +template +uint8_t FecBaseSpecificTrainerData::getResistanceCalibration() { + return this->get8BitValue(RESISTANCECALIBRATION_BYTE, + RESISTANCECALIBRATION_MASK, + RESISTANCECALIBRATION_SHIFT); +} + +template +uint8_t FecBaseSpecificTrainerData::getUserConfiguration() { + return this->get8BitValue(USERCONFIGURATION_BYTE, + USERCONFIGURATION_MASK, + USERCONFIGURATION_SHIFT); +} + +template +uint8_t FecBaseSpecificTrainerData::getTargetPowerLimits() { + return this->get8BitValue(TARGETPOWERLIMITS_BYTE, TARGETPOWERLIMITS_MASK); +} + +template +uint8_t FecBaseSpecificTrainerData::getFeState() { + return this->get8BitValue(FESTATE_BYTE, FESTATE_MASK, FESTATE_SHIFT); +} + +template +uint8_t FecBaseSpecificTrainerData::getLapToggleBit() { + return this->get8BitValue(LAPTOGGLEBIT_BYTE, LAPTOGGLEBIT_MASK, LAPTOGGLEBIT_SHIFT); +} + +template class FecBaseSpecificTrainerData; +template class FecBaseSpecificTrainerData; + +FecSpecificTrainerData::FecSpecificTrainerData(AntRxDataResponse& dp) : + BaseDataPage(dp), + FecBaseSpecificTrainerData() {} + +FecSpecificTrainerDataMsg::FecSpecificTrainerDataMsg() : + BaseDataPageMsg(), + FecBaseSpecificTrainerData() {} + +void FecSpecificTrainerDataMsg::setUpdateEventCount(uint8_t eventCount) { + set8BitValue(eventCount, UPDATEEVENTCOUNT_BYTE); +} + +void FecSpecificTrainerDataMsg::setInstantaneousCadence(uint8_t cadence) { + set8BitValue(cadence, INSTANTANEOUSCADENCE_BYTE); +} + +void FecSpecificTrainerDataMsg::setAccumulatedPower(uint16_t accPower) { + set16BitValue(accPower, ACCUMULATEDPOWER_LSB_BYTE, + ACCUMULATEDPOWER_MSB_BYTE); +} + +void FecSpecificTrainerDataMsg::setInstantaneousPower(uint16_t intPower) { + set16BitValue(intPower, INSTANTANEOUSPOWER_LSB_BYTE, + INSTANTANEOUSPOWER_MSB_BYTE, + INSTANTANEOUSPOWER_MSB_MASK); +} + +void FecSpecificTrainerDataMsg::setBicyclePowerCalibration(uint8_t powerCalibration) { + set8BitValue(powerCalibration, BICYCLEPOWERCALIBRATION_BYTE, + BICYCLEPOWERCALIBRATION_MASK, + BICYCLEPOWERCALIBRATION_SHIFT); +} + +void FecSpecificTrainerDataMsg::setResistanceCalibration(uint8_t resistanceCalibration) { + set8BitValue(resistanceCalibration, RESISTANCECALIBRATION_BYTE, + RESISTANCECALIBRATION_MASK, + RESISTANCECALIBRATION_SHIFT); +} + +void FecSpecificTrainerDataMsg::setUserConfiguration(uint8_t userConfiguration) { + set8BitValue(userConfiguration, USERCONFIGURATION_BYTE, + USERCONFIGURATION_MASK, + USERCONFIGURATION_SHIFT); +} + +void FecSpecificTrainerDataMsg::setTargetPowerLimits(uint8_t targetPower) { + set8BitValue(targetPower, TARGETPOWERLIMITS_BYTE, TARGETPOWERLIMITS_MASK); +} + +void FecSpecificTrainerDataMsg::setFeState(uint8_t feState) { + set8BitValue(feState, FESTATE_BYTE, FESTATE_MASK, FESTATE_SHIFT); +} + +void FecSpecificTrainerDataMsg::setLapToggleBit(uint8_t lapToggle) { + set8BitValue(lapToggle, LAPTOGGLEBIT_BYTE, + LAPTOGGLEBIT_MASK, LAPTOGGLEBIT_SHIFT); +} diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.h new file mode 100644 index 0000000..a70f061 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.h @@ -0,0 +1,42 @@ +#ifndef ANTPLUS_FECTRAINERDATA_h +#define ANTPLUS_FECTRAINERDATA_h + +#include + +template +class FecBaseSpecificTrainerData : virtual public CoreDataPage { +public: + FecBaseSpecificTrainerData(); + uint8_t getUpdateEventCount(); + uint8_t getInstantaneousCadence(); + uint16_t getAccumulatedPower(); + uint16_t getInstantaneousPower(); + uint8_t getBicyclePowerCalibration(); + uint8_t getResistanceCalibration(); + uint8_t getUserConfiguration(); + uint8_t getTargetPowerLimits(); + uint8_t getFeState(); + uint8_t getLapToggleBit(); +}; + +class FecSpecificTrainerData : public BaseDataPage, public FecBaseSpecificTrainerData { +public: + explicit FecSpecificTrainerData(AntRxDataResponse& dp); +}; + +class FecSpecificTrainerDataMsg : public BaseDataPageMsg, public FecBaseSpecificTrainerData { +public: + FecSpecificTrainerDataMsg(); + void setUpdateEventCount(uint8_t eventCount); + void setInstantaneousCadence(uint8_t cadence); + void setAccumulatedPower(uint16_t accPower); + void setInstantaneousPower(uint16_t intPower); + void setBicyclePowerCalibration(uint8_t powerCalibration); + void setResistanceCalibration(uint8_t resistanceCalibration); + void setUserConfiguration(uint8_t userConfiguration); + void setTargetPowerLimits(uint8_t targetPower); + void setFeState(uint8_t feState); + void setLapToggleBit(uint8_t lapToggle); +}; + +#endif // ANTPLUS_FECTRAINERDATA_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPower.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPower.cpp new file mode 100644 index 0000000..36c56fd --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPower.cpp @@ -0,0 +1,37 @@ +#include +#include + +#define TARGET_POWER_LSB_BYTE 6 +#define TARGET_POWER_MSB_BYTE 7 +#define RESERVED0_LSB_BYTE 1 +#define RESERVED0_MSB_BYTE 4 +#define RESERVED0_VALUE 0xFFFFFFFF +#define RESERVED1_BYTE 5 +#define RESERVED1_VALUE 0xFF + +template +FecBaseTargetPower::FecBaseTargetPower() : + CoreDataPage() {} + +template +uint16_t FecBaseTargetPower::getTargetPower() { + return this->get16BitValue(TARGET_POWER_LSB_BYTE, TARGET_POWER_MSB_BYTE); +} + +template class FecBaseTargetPower; +template class FecBaseTargetPower; + +FecTargetPower::FecTargetPower(AntRxDataResponse& dp) : + FecBaseMainDataPage(dp), + FecBaseTargetPower() {} + +FecTargetPowerMsg::FecTargetPowerMsg() : + FecBaseMainDataPageMsg(ANTPLUS_FEC_DATAPAGE_TARGETPOWER_NUMBER), + FecBaseTargetPower() { + set32BitValue(RESERVED0_VALUE, RESERVED0_LSB_BYTE, RESERVED0_MSB_BYTE); + set8BitValue(RESERVED1_VALUE, RESERVED1_BYTE); +} + +void FecTargetPowerMsg::setTargetPower(uint16_t targetPower) { + set16BitValue(targetPower, TARGET_POWER_LSB_BYTE, TARGET_POWER_MSB_BYTE); +} diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPower.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPower.h new file mode 100644 index 0000000..7449787 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPower.h @@ -0,0 +1,26 @@ +#ifndef ANTPLUS_FECTARGETPOWER_h +#define ANTPLUS_FECTARGETPOWER_h + +#include + +template +class FecBaseTargetPower : virtual public CoreDataPage { +public: + FecBaseTargetPower(); + uint16_t getTargetPower(); +}; + +class FecTargetPower : public FecBaseMainDataPage, public FecBaseTargetPower { +public: + explicit FecTargetPower(AntRxDataResponse& dp); +}; + +class FecTargetPowerMsg : public FecBaseMainDataPageMsg, public FecBaseTargetPower { +public: + FecTargetPowerMsg(); + void setTargetPower(uint16_t targetPower); +}; + + +#endif // ANTPLUS_FECTARGETPOWER_h + diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistance.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistance.cpp new file mode 100644 index 0000000..475f468 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistance.cpp @@ -0,0 +1,46 @@ +#include +#include + +#define RESERVED_LSB_BYTE 1 +#define RESERVED_MSB_BYTE 4 +#define RESERVED_VALUE 0xFFFFFFFF +#define GRADE_LSB_BYTE 5 +#define GRADE_MSB_BYTE 6 +#define COEFFICIENTOFROLLINGRESISTANCE_BYTE 7 + +template +FecBaseTrackResistance::FecBaseTrackResistance() : + CoreDataPage() {} + +template +uint16_t FecBaseTrackResistance::getGrade() { + return this->get16BitValue(GRADE_LSB_BYTE, GRADE_MSB_BYTE); +} + +template +uint8_t FecBaseTrackResistance::getCoefficientOfRollingResistance() { + return this->get8BitValue(COEFFICIENTOFROLLINGRESISTANCE_BYTE); +} + +template class FecBaseTrackResistance; +template class FecBaseTrackResistance; + +FecTrackResistance::FecTrackResistance(AntRxDataResponse& dp) : + FecBaseMainDataPage(dp), + FecBaseTrackResistance() {} + +FecTrackResistanceMsg::FecTrackResistanceMsg() : + FecBaseMainDataPageMsg(ANTPLUS_FEC_DATAPAGE_TRACKRESISTANCE_NUMBER), + FecBaseTrackResistance() { + set32BitValue(RESERVED_VALUE, RESERVED_LSB_BYTE, RESERVED_MSB_BYTE); + setTargetGrade(ANTPLUS_FEC_DATAPAGE_TRACKRESISTANCE_GRADE_INVALID); + setCoefficientOfRollingResistance(ANTPLUS_FEC_DATAPAGE_TRACKRESISTANCE_COEFFICIENTOFROLLINGRESISTANCE_INVALID); +} + +void FecTrackResistanceMsg::setTargetGrade(uint16_t TargetGrade) { + set16BitValue(TargetGrade, GRADE_LSB_BYTE, GRADE_MSB_BYTE); +} + +void FecTrackResistanceMsg::setCoefficientOfRollingResistance(uint8_t coefficient) { + set8BitValue(coefficient, COEFFICIENTOFROLLINGRESISTANCE_BYTE); +} diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistance.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistance.h new file mode 100644 index 0000000..90f4ebb --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistance.h @@ -0,0 +1,28 @@ +#ifndef ANTPLUS_FECTRACKRESISTANCE_h +#define ANTPLUS_FECTRACKRESISTANCE_h + +#include + +template +class FecBaseTrackResistance : virtual public CoreDataPage { +public: + FecBaseTrackResistance(); + uint16_t getGrade(); + uint8_t getCoefficientOfRollingResistance(); +}; + +class FecTrackResistance : public FecBaseMainDataPage, public FecBaseTrackResistance { +public: + explicit FecTrackResistance(AntRxDataResponse& dp); +}; + +class FecTrackResistanceMsg : public FecBaseMainDataPageMsg, public FecBaseTrackResistance { +public: + FecTrackResistanceMsg(); + void setTargetGrade(uint16_t targetGrade); + void setCoefficientOfRollingResistance(uint8_t coefficient); +}; + + +#endif // ANTPLUS_FECTRACKRESISTANCE_h + diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecUserConfiguration.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecUserConfiguration.cpp new file mode 100644 index 0000000..da4bbab --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecUserConfiguration.cpp @@ -0,0 +1,89 @@ +#include +#include + +#define USERWEIGHT_LSB_BYTE 1 +#define USERWEIGHT_MSB_BYTE 2 +#define RESERVED_BYTE 3 +#define RESERVED_VALUE 0xFF +#define BICYCLEWHEELDIAMETEROFFSET_BYTE 4 +#define BICYCLEWHEELDIAMETEROFFSET_MASK 0x0F +#define BICYCLEWEIGHT_LSB_BYTE 4 +#define BICYCLEWEIGHT_MSB_BYTE 5 +#define BICYCLEWEIGHT_MASK 0xFFF0 +#define BICYCLEWEIGHT_SHIFT 4 +#define BICYCLEWHEELDIAMETER_BYTE 6 +#define GEARRATIO_BYTE 7 + +template +FecBaseUserConfiguration::FecBaseUserConfiguration() : + CoreDataPage() {} + +template +uint16_t FecBaseUserConfiguration::getUserWeight() { + return this->get16BitValue(USERWEIGHT_LSB_BYTE, USERWEIGHT_MSB_BYTE); +} + +template +uint8_t FecBaseUserConfiguration::getBicycleWheelDiameterOffset() { + return this->get8BitValue(BICYCLEWHEELDIAMETEROFFSET_BYTE, BICYCLEWHEELDIAMETEROFFSET_MASK); +} + +template +uint16_t FecBaseUserConfiguration::getBicycleWeight() { + return this->get16BitValue(BICYCLEWEIGHT_LSB_BYTE, + BICYCLEWEIGHT_MSB_BYTE, + BICYCLEWEIGHT_MASK, + BICYCLEWEIGHT_SHIFT); +} + +template +uint8_t FecBaseUserConfiguration::getBicycleWheelDiameter() { + return this->get8BitValue(BICYCLEWHEELDIAMETER_BYTE); +} + +template +uint8_t FecBaseUserConfiguration::getGearRatio() { + return this->get8BitValue(GEARRATIO_BYTE); +} + +template class FecBaseUserConfiguration; +template class FecBaseUserConfiguration; + +FecUserConfiguration::FecUserConfiguration(AntRxDataResponse& dp) : + FecBaseMainDataPage(dp), + FecBaseUserConfiguration() {} + +FecUserConfigurationMsg::FecUserConfigurationMsg() : + FecBaseMainDataPageMsg(ANTPLUS_FEC_DATAPAGE_USERCONFIGURATION_NUMBER), + FecBaseUserConfiguration() { + setUserWeight(ANTPLUS_FEC_DATAPAGE_USERCONFIGURATION_USERWEIGHT_INVALID); + set8BitValue(RESERVED_VALUE, RESERVED_BYTE); + setBicycleWheelDiameterOffset(ANTPLUS_FEC_DATAPAGE_USERCONFIGURATION_BICYCLEWHEELDIAMETEROFFSET_INVALID); + setBicycleWeight(ANTPLUS_FEC_DATAPAGE_USERCONFIGURATION_BICYCLEWEIGHT_INVALID); + setBicycleWheelDiameter(ANTPLUS_FEC_DATAPAGE_USERCONFIGURATION_BICYCLEWHEELDIAMETER_INVALID); + setGearRatio(ANTPLUS_FEC_DATAPAGE_USERCONFIGURATION_GEARRATIO_INVALID); +} + +void FecUserConfigurationMsg::setBicycleWheelDiameterOffset(uint8_t offset) { + set8BitValue(offset, BICYCLEWHEELDIAMETEROFFSET_BYTE, BICYCLEWHEELDIAMETEROFFSET_MASK); +} + +void FecUserConfigurationMsg::setUserWeight(uint16_t userWeight) { + set16BitValue(userWeight, USERWEIGHT_LSB_BYTE, USERWEIGHT_MSB_BYTE); +} + +void FecUserConfigurationMsg::setBicycleWeight(uint16_t bicycleWeight) { + set16BitValue(bicycleWeight, + BICYCLEWEIGHT_LSB_BYTE, + BICYCLEWEIGHT_MSB_BYTE, + BICYCLEWEIGHT_MASK, + BICYCLEWEIGHT_SHIFT); +} + +void FecUserConfigurationMsg::setBicycleWheelDiameter(uint8_t diameter) { + set8BitValue(diameter, BICYCLEWHEELDIAMETER_BYTE); +} + +void FecUserConfigurationMsg::setGearRatio(uint8_t gearRatio) { + set8BitValue(gearRatio, GEARRATIO_BYTE); +} diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecUserConfiguration.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecUserConfiguration.h new file mode 100644 index 0000000..0b06493 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecUserConfiguration.h @@ -0,0 +1,33 @@ +#ifndef ANTPLUS_FECUSERCONFIGURATION_h +#define ANTPLUS_FECUSERCONFIGURATION_h + +#include + +template +class FecBaseUserConfiguration : virtual public CoreDataPage { +public: + FecBaseUserConfiguration(); + uint16_t getUserWeight(); + uint8_t getBicycleWheelDiameterOffset(); + uint16_t getBicycleWeight(); + uint8_t getBicycleWheelDiameter(); + uint8_t getGearRatio(); +}; + +class FecUserConfiguration : public FecBaseMainDataPage, public FecBaseUserConfiguration { +public: + explicit FecUserConfiguration(AntRxDataResponse& dp); +}; + +class FecUserConfigurationMsg : public FecBaseMainDataPageMsg, public FecBaseUserConfiguration { +public: + FecUserConfigurationMsg(); + void setUserWeight(uint16_t userWeight); + void setBicycleWheelDiameterOffset(uint8_t offset); + void setBicycleWeight(uint16_t bicycleWeight); + void setBicycleWheelDiameter(uint8_t diameter); + void setGearRatio(uint8_t gearRatio); +}; + +#endif // ANTPLUS_FECUSERCONFIGURATION_h + diff --git a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp new file mode 100644 index 0000000..14212ef --- /dev/null +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp @@ -0,0 +1,95 @@ +#include +#include +#include + +#define DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE + +ProfileFecDisplay::ProfileFecDisplay(uint16_t deviceNumber, uint8_t transmissionType) : BaseSlaveProfile(deviceNumber, transmissionType) { + setChannelConfig(); +} + +void ProfileFecDisplay::onBroadcastData(BroadcastData& msg) { + FecBaseMainDataPage dp(msg); + BaseSlaveProfile::onBroadcastData(msg); + if (!handleDataPage(dp)) { + callOnOtherDataPage(msg); + } +} + +bool ProfileFecDisplay::handleDataPage(FecBaseMainDataPage& dp) { + uint8_t dataPage = dp.getDataPageNumber(); + bool called = false; + + switch (dataPage) { + case ANTPLUS_FEC_DATAPAGE_SPECIFICTRAINERDATA_NUMBER: + called = handleTrainerData(dp); + break; + + case ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER: + called = handleManufacturerInformation(dp); + break; + + case ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER: + called = handleProductInformation(dp); + break; + + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_NUMBER: + called = handleGeneralFeData(dp); + break; + + case ANTPLUS_FEC_DATAPAGE_GENERALSETTINGSPAGE_NUMBER: + called = handleGeneralSettingsPage(dp); + break; + + case ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_NUMBER: + called = handleFeCapabilities(dp); + break; + } + + return called; +} + +void ProfileFecDisplay::onAcknowledgedData(AcknowledgedData& msg) { + FecBaseMainDataPage dp = FecBaseMainDataPage(msg); + BaseSlaveProfile::onAcknowledgedData(msg); + if (!handleDataPage(dp)) { + callOnOtherDataPage(msg); + } +} + +void ProfileFecDisplay::setChannelConfig() { + setChannelType(DISPLAY_CHANNELTYPE); + setDeviceType(ANTPLUS_FEC_REALTIMECHANNEL_DEVICETYPE); + setChannelPeriod(ANTPLUS_FEC_CHANNELPERIOD); + setSearchTimeout(ANTPLUS_FEC_SEARCHTIMEOUT); +} + +bool ProfileFecDisplay::handleManufacturerInformation(FecBaseMainDataPage& dataPage) { + ManufacturersInformation dp(dataPage); + return _onManufacturersInformation.call(dp); +} + +bool ProfileFecDisplay::handleProductInformation(FecBaseMainDataPage& dataPage) { + ProductInformation dp(dataPage); + return _onProductInformation.call(dp); +} + +bool ProfileFecDisplay::handleGeneralFeData(FecBaseMainDataPage& dataPage) { + FecGeneralFeData dp(dataPage); + return _onFecGeneralFeData.call(dp); +} + +bool ProfileFecDisplay::handleGeneralSettingsPage(FecBaseMainDataPage& dataPage) { + FecGeneralSettingsPage dp(dataPage); + return _onFecGeneralSettingsPage.call(dp); +} + +bool ProfileFecDisplay::handleFeCapabilities(FecBaseMainDataPage& dataPage) { + FecFeCapabilities dp(dataPage); + return _onFecFeCapabilities.call(dp); +} + +bool ProfileFecDisplay::handleTrainerData(FecBaseMainDataPage& dataPage) { + FecSpecificTrainerData dp(dataPage); + return _onFecSpecificTrainerData.call(dp); +} diff --git a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h new file mode 100644 index 0000000..267421a --- /dev/null +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h @@ -0,0 +1,39 @@ +#ifndef ANTPLUS_PROFILEFECDISPLAY_h +#define ANTPLUS_PROFILEFECDISPLAY_h + +#include +#include +#include + +class ProfileFecDisplay : public BaseSlaveProfile { +public: + ProfileFecDisplay(uint16_t deviceNumber = 0, uint8_t transmissionType = 0); + void onFecTrainerData(void (*func)(FecSpecificTrainerData&, uintptr_t), uintptr_t data = 0) { _onFecSpecificTrainerData.set(func, data); } + void onManufacturersInformation(void (*func)(ManufacturersInformation&, uintptr_t), uintptr_t data = 0) { _onManufacturersInformation.set(func, data); } + void onProductInformation(void (*func)(ProductInformation&, uintptr_t), uintptr_t data = 0) { _onProductInformation.set(func, data); } + void onFecGeneralFeData(void (*func)(FecGeneralFeData&, uintptr_t), uintptr_t data = 0) { _onFecGeneralFeData.set(func, data); } + void onFecGeneralSettingsPage(void (*func)(FecGeneralSettingsPage&, uintptr_t), uintptr_t data = 0) { _onFecGeneralSettingsPage.set(func, data); } + void onFecFeCapabilities(void (*func)(FecFeCapabilities&, uintptr_t), uintptr_t data = 0) { _onFecFeCapabilities.set(func, data); } + +private: + void setChannelConfig(); + void onBroadcastData(BroadcastData& msg) override; + void onAcknowledgedData(AcknowledgedData& msg) override; + + bool handleDataPage(FecBaseMainDataPage& dp); + bool handleManufacturerInformation(FecBaseMainDataPage& dataPage); + bool handleProductInformation(FecBaseMainDataPage& dataPage); + bool handleGeneralFeData(FecBaseMainDataPage& dataPage); + bool handleGeneralSettingsPage(FecBaseMainDataPage& dataPage); + bool handleTrainerData(FecBaseMainDataPage& dataPage); + bool handleFeCapabilities(FecBaseMainDataPage& dataPage); + + AntCallback _onFecSpecificTrainerData = { .func = NULL }; + AntCallback _onManufacturersInformation = { .func = NULL }; + AntCallback _onProductInformation = { .func = NULL }; + AntCallback _onFecGeneralFeData = { .func = NULL }; + AntCallback _onFecGeneralSettingsPage = { .func = NULL }; + AntCallback _onFecFeCapabilities = { .func = NULL }; +}; + +#endif // ANTPLUS_PROFILEFECDISPLAY_h diff --git a/src/Profiles/HeartRate/ANTPLUS_HeartRateDataPages.h b/src/Profiles/HeartRate/ANTPLUS_HeartRateDataPages.h new file mode 100644 index 0000000..adb9157 --- /dev/null +++ b/src/Profiles/HeartRate/ANTPLUS_HeartRateDataPages.h @@ -0,0 +1,14 @@ +#ifndef ANTPLUS_PROFILEHEARTRATEDATAPAGES_h +#define ANTPLUS_PROFILEHEARTRATEDATAPAGES_h + +/* RX */ +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // ANTPLUS_PROFILEHEARTRATEDATAPAGES_h diff --git a/src/Profiles/HeartRate/ANTPLUS_HeartRateDefines.h b/src/Profiles/HeartRate/ANTPLUS_HeartRateDefines.h index 5f716ce..6803d3a 100644 --- a/src/Profiles/HeartRate/ANTPLUS_HeartRateDefines.h +++ b/src/Profiles/HeartRate/ANTPLUS_HeartRateDefines.h @@ -3,10 +3,34 @@ #define ANTPLUS_HEARTRATE_DEVICETYPE 120 -#define ANTPLUS_HEARTRATE_FLAGS_CUMULATIVEOPERATINGTIME_SUPPORTED (1 << 0) -#define ANTPLUS_HEARTRATE_FLAGS_PREVIOUSHEARTBEAT_SUPPORTED (1 << 1) -#define ANTPLUS_HEARTRATE_FLAGS_EXTENTED_FEATURES (1 << 2) -#define ANTPLUS_HEARTRATE_FLAGS_BATTERYSTATUS_SUPPORTED (1 << 3) +#define ANTPLUS_HEARTRATE_FLAGS_EXTENTED_FEATURES (1 << 0) + +/* DataPage Numbers */ +#define ANTPLUS_HEARTRATE_DATAPAGE_DEFAULT_NUMBER 0 + + +#define ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER 1 + + +#define ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER 2 + + +#define ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_NUMBER 3 + + +#define ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_NUMBER 4 + +#define ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_MANUFACTURERSPECIFIC_INVALID 0xFF + + +#define ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_NUMBER 5 + +#define ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALAVERAGEHEARTRATE_INVALID 0 +#define ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALMAXIMUMHEARTRATE_INVALID 0 +#define ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_SESSIONAVERAGEHEARTRATE_INVALID 0 + + +#define ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_NUMBER 6 #define ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURES_EXTENDEDRUNNING 0x01 #define ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURES_EXTENDEDCYCLING 0x02 @@ -14,11 +38,18 @@ #define ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURES_MANUFACTURER1 0x40 #define ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURES_MANUFACTURER2 0x80 -// TODO all below defines need to be added to example -#define ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_MANUFACTURERSPECIFIC_INVALID 0xFF -#define ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALAVERAGEHEARTRATE_INVALID 0 -#define ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALMAXIMUMHEARTRATE_INVALID 0 -#define ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_SESSIONAVERAGEHEARTRATE_INVALID 0 +#define ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_NUMBER 7 + +#define ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYLEVEL_INVALID 0xFF + +#define ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_INVALID 0xF + +#define ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_NEW 1 +#define ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_GOOD 2 +#define ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_OK 3 +#define ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_LOW 4 +#define ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_CRITICAL 5 +#define ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_INVALID 7 #endif // ANTPLUS_HEARTRATEPROFILEDEFINES_h diff --git a/src/Profiles/HeartRate/ANTPLUS_HeartRatePrivateDefines.h b/src/Profiles/HeartRate/ANTPLUS_HeartRatePrivateDefines.h index 1bfecc4..a3a6961 100644 --- a/src/Profiles/HeartRate/ANTPLUS_HeartRatePrivateDefines.h +++ b/src/Profiles/HeartRate/ANTPLUS_HeartRatePrivateDefines.h @@ -2,81 +2,19 @@ #define ANTPLUS_HEARTRATEPROFILEPRIVATEDEFINES_h /* Channel Config */ -#define ANTPLUS_HEARTRATE_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE -#define ANTPLUS_HEARTRATE_MONITOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT -#define ANTPLUS_HEARTRATE_CHANNELPERIOD 8070 +#define HEARTRATE_CHANNELPERIOD 8070 // 30 / 2.5 = 12 -#define ANTPLUS_HEARTRATE_SEARCHTIMEOUT 12 - -/* Base DataPage */ -#define ANTPLUS_HEARTRATE_DATAPAGEBASE_DATAPAGE_BYTE 0 -#define ANTPLUS_HEARTRATE_DATAPAGEBASE_TOGGLE_BYTE 0 -#define ANTPLUS_HEARTRATE_DATAPAGEBASE_HEARTBEATEVENTTIMELSB_BYTE 4 -#define ANTPLUS_HEARTRATE_DATAPAGEBASE_HEARTBEATEVENTTIMEMSB_BYTE 5 -#define ANTPLUS_HEARTRATE_DATAPAGEBASE_HEARTBEATCOUNT_BYTE 6 -#define ANTPLUS_HEARTRATE_DATAPAGEBASE_COMPUTEDHEARTRATE_BYTE 7 - -#define ANTPLUS_HEARTRATE_DATAPAGEBASE_DATAPAGE_MASK 0x7F -#define ANTPLUS_HEARTRATE_DATAPAGEBASE_TOGGLE_MASK 0x80 - -#define ANTPLUS_HEARTRATE_DATAPAGEBASE_TOGGLE_SHIFT 7 - -/* Default DataPage */ -#define ANTPLUS_HEARTRATE_DATAPAGE_DEFAULT_NUMBER 0 - -/* Cumulative Operating Time */ -#define ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER 1 - -#define ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_TIME_LSB_BYTE 1 -#define ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_TIME_MSB_BYTE 3 - -/* Manufacturer Information */ -#define ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER 2 - -#define ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_MANUFACTUREREIDLSB_BYTE 1 -#define ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_SERIALNUMBERLSB_BYTE 2 -#define ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_SERIALNUMBERMSB_BYTE 3 - -/* Product Information */ -#define ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_NUMBER 3 - -#define ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_HARDWAREVERSION_BYTE 1 -#define ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_SOFTWAREVERSION_BYTE 2 -#define ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_MODELNUMBER_BYTE 3 - -/* Previous Heart Beat */ -#define ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_NUMBER 4 - -#define ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_MANUFACTURERSPECIFIC_BYTE 1 -#define ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_PREVIOUSHEARTBEATEVENTTIMELSB_BYTE 2 -#define ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_PREVIOUSHEARTBEATEVENTTIMEMSB_BYTE 3 - -/* Swim Interval Summary */ -#define ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_NUMBER 5 - -#define ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALAVERAGEHEARTRATE_BYTE 1 -#define ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALMAXIMUMHEARTRATE_BYTE 2 -#define ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_SESSIONAVERAGEHEARTRATE_BYTE 3 - -/* Capabilities */ -#define ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_NUMBER 6 - -#define ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURESSUPPORTED_BYTE 2 -#define ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURESENABLED_BYTE 3 - -#define ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURES_MASK 0xC7 - -/* Battery Status */ -#define ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_NUMBER 7 - -#define ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYLEVEL_BYTE 1 -#define ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE 2 -#define ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_BYTE 3 -#define ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_BYTE 3 - -#define ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_MASK 0x0F -#define ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_MASK 0x70 - -#define ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_SHIFT 4 +#define HEARTRATE_SEARCHTIMEOUT 12 + +/* DataPage Numbers */ +#warning "derp" +#define HEARTRATE_DEFAULT_NUMBER 0 +#define HEARTRATE_CUMULATIVEOPERATINGTIME_NUMBER 1 +#define HEARTRATE_MANUFACTURERINFORMATION_NUMBER 2 +#define HEARTRATE_PRODUCTINFORMATION_NUMBER 3 +#define HEARTRATE_PREVIOUSHEARTBEAT_NUMBER 4 +#define HEARTRATE_SWIMINTERVALSUMMARY_NUMBER 5 +#define HEARTRATE_CAPABILITIES_NUMBER 6 +#define HEARTRATE_BATTERYSTATUS_NUMBER 7 #endif // ANTPLUS_HEARTRATEPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/HeartRate/ANTPLUS_HeartRateProfile.h b/src/Profiles/HeartRate/ANTPLUS_HeartRateProfile.h index bffbd4f..6fb1c92 100644 --- a/src/Profiles/HeartRate/ANTPLUS_HeartRateProfile.h +++ b/src/Profiles/HeartRate/ANTPLUS_HeartRateProfile.h @@ -5,10 +5,10 @@ #include // Datapages -#include +#include // Profile Classes -#include -#include +#include +#include #endif // ANTPLUS_HEARTRATEPROFILE_h diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.cpp new file mode 100644 index 0000000..55c2bfa --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.cpp @@ -0,0 +1,72 @@ +#include +#include +#include + +#define DATAPAGE_BYTE 0 +#define TOGGLE_BYTE 0 +#define HEARTBEATEVENTTIME_LSB_BYTE 4 +#define HEARTBEATEVENTTIME_MSB_BYTE 5 +#define HEARTBEATCOUNT_BYTE 6 +#define COMPUTEDHEARTRATE_BYTE 7 +#define DATAPAGE_MASK 0x7F +#define TOGGLE_MASK 0x80 +#define TOGGLE_SHIFT 7 + +template +HeartRateCoreMainDataPage::HeartRateCoreMainDataPage() : CoreDataPage() {} + +template +uint8_t HeartRateCoreMainDataPage::getDataPageNumber() { + return this->get8BitValue(DATAPAGE_BYTE, DATAPAGE_MASK); +} + +template +uint8_t HeartRateCoreMainDataPage::getPageChangeToggle() { + return this->get8BitValue(TOGGLE_BYTE, TOGGLE_MASK, TOGGLE_SHIFT); +} + +template +uint16_t HeartRateCoreMainDataPage::getHeartBeatEventTime() { + return this->get16BitValue(HEARTBEATEVENTTIME_LSB_BYTE, HEARTBEATEVENTTIME_MSB_BYTE); +} + +template +uint8_t HeartRateCoreMainDataPage::getHeartBeatCount() { + return this->get8BitValue(HEARTBEATCOUNT_BYTE); +} + +template +uint8_t HeartRateCoreMainDataPage::getComputedHeartRate() { + return this->get8BitValue(COMPUTEDHEARTRATE_BYTE); +} + +template class HeartRateCoreMainDataPage; +template class HeartRateCoreMainDataPage; + +HeartRateBaseMainDataPage::HeartRateBaseMainDataPage(AntRxDataResponse& dp) : + BaseDataPage(dp), + HeartRateCoreMainDataPage() {} + +HeartRateBaseMainDataPageMsg::HeartRateBaseMainDataPageMsg(uint8_t dataPageNumber) : + BaseDataPageMsg(), + HeartRateCoreMainDataPage() { + setDataBuffer(_buffer); + set8BitValue(dataPageNumber, ANTPLUS_DEFAULT_DATAPAGE_BYTE); +} + +void HeartRateBaseMainDataPageMsg::setPageChangeToggle(uint8_t toggle) { + set8BitValue(toggle ? 1 : 0, TOGGLE_BYTE, TOGGLE_MASK, TOGGLE_SHIFT); +} + +void HeartRateBaseMainDataPageMsg::setHeartBeatEventTime(uint16_t time) { + set16BitValue(time, HEARTBEATEVENTTIME_LSB_BYTE, + HEARTBEATEVENTTIME_MSB_BYTE); +} + +void HeartRateBaseMainDataPageMsg::setHeartBeatCount(uint8_t count) { + set8BitValue(count, HEARTBEATCOUNT_BYTE); +} + +void HeartRateBaseMainDataPageMsg::setComputedHeartRate(uint8_t heartRate) { + set8BitValue(heartRate, COMPUTEDHEARTRATE_BYTE); +} diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.h b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.h new file mode 100644 index 0000000..0f3880c --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.h @@ -0,0 +1,34 @@ +#ifndef ANTPLUS_HEARTRATEBASEMAINDATAPAGE_h +#define ANTPLUS_HEARTRATEBASEMAINDATAPAGE_h + +#include +#include + +template +class HeartRateCoreMainDataPage : virtual public CoreDataPage { +public: + HeartRateCoreMainDataPage(); + uint8_t getDataPageNumber() override; + uint8_t getPageChangeToggle(); + uint16_t getHeartBeatEventTime(); + uint8_t getHeartBeatCount(); + uint8_t getComputedHeartRate(); +}; + +class HeartRateBaseMainDataPage : public BaseDataPage, public HeartRateCoreMainDataPage { +public: + explicit HeartRateBaseMainDataPage(AntRxDataResponse& dp); +}; + +class HeartRateBaseMainDataPageMsg : public BaseDataPageMsg, public HeartRateCoreMainDataPage { +public: + explicit HeartRateBaseMainDataPageMsg(uint8_t dataPageNumber); + void setPageChangeToggle(uint8_t toggle); + void setHeartBeatEventTime(uint16_t time); + void setHeartBeatCount(uint8_t count); + void setComputedHeartRate(uint8_t heartRate); +protected: + uint8_t _buffer[MESSAGE_SIZE] = {0}; +}; + +#endif // ANTPLUS_HEARTRATEBASEMAINDATAPAGE_h diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBatteryStatus.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBatteryStatus.cpp new file mode 100644 index 0000000..cf7b334 --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBatteryStatus.cpp @@ -0,0 +1,68 @@ +#include +#include + +#define BATTERYLEVEL_BYTE 1 +#define FRACTIONALBATTERYVOLTAGE_BYTE 2 +#define COARSEBATTERYVOLTAGE_BYTE 3 +#define BATTERYSTATUS_BYTE 3 +#define COARSEBATTERYVOLTAGE_MASK 0x0F +#define BATTERYSTATUS_MASK 0x70 +#define BATTERYSTATUS_SHIFT 4 + +template +HeartRateBaseBatteryStatus::HeartRateBaseBatteryStatus() : + CoreDataPage() {} + +template +uint8_t HeartRateBaseBatteryStatus::getBatteryLevel() { + return this->get8BitValue(BATTERYLEVEL_BYTE); +} + +template +uint8_t HeartRateBaseBatteryStatus::getFractionalBatteryVoltage() { + return this->get8BitValue(FRACTIONALBATTERYVOLTAGE_BYTE); +} + +template +uint8_t HeartRateBaseBatteryStatus::getCoarseBatteryVoltage() { + return this->get8BitValue( + COARSEBATTERYVOLTAGE_BYTE, COARSEBATTERYVOLTAGE_MASK); +} + +template +uint8_t HeartRateBaseBatteryStatus::getBatteryStatus() { + return this->get8BitValue( + BATTERYSTATUS_BYTE, BATTERYSTATUS_MASK, BATTERYSTATUS_SHIFT); +} + +template class HeartRateBaseBatteryStatus; +template class HeartRateBaseBatteryStatus; + +HeartRateBatteryStatus::HeartRateBatteryStatus(AntRxDataResponse& dp) : + HeartRateBaseMainDataPage(dp), + HeartRateBaseBatteryStatus() {} + +HeartRateBatteryStatusMsg::HeartRateBatteryStatusMsg() : + HeartRateBaseMainDataPageMsg(ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_NUMBER), + HeartRateBaseBatteryStatus() { + setBatteryLevel(ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYLEVEL_INVALID); + setCoarseBatteryVolage(ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_INVALID); + setBatteryStatus(ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_INVALID); +} + +void HeartRateBatteryStatusMsg::setBatteryLevel(uint8_t level) { + set8BitValue(level, BATTERYLEVEL_BYTE); +} + +void HeartRateBatteryStatusMsg::setFractionalBatteryVoltage(uint8_t voltage) { + set8BitValue(voltage, FRACTIONALBATTERYVOLTAGE_BYTE); +} + +void HeartRateBatteryStatusMsg::setCoarseBatteryVolage(uint8_t voltage) { + set8BitValue(voltage, COARSEBATTERYVOLTAGE_BYTE, COARSEBATTERYVOLTAGE_MASK); +} + +void HeartRateBatteryStatusMsg::setBatteryStatus(uint8_t status) { + set8BitValue(status, + BATTERYSTATUS_BYTE, BATTERYSTATUS_MASK, BATTERYSTATUS_SHIFT); +} diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBatteryStatus.h b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBatteryStatus.h new file mode 100644 index 0000000..1d6254c --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBatteryStatus.h @@ -0,0 +1,30 @@ +#ifndef ANTPLUS_HEARTRATEBATTERYSTATUS_h +#define ANTPLUS_HEARTRATEBATTERYSTATUS_h + +#include + +template +class HeartRateBaseBatteryStatus : virtual public CoreDataPage { +public: + HeartRateBaseBatteryStatus(); + uint8_t getBatteryLevel(); + uint8_t getFractionalBatteryVoltage(); + uint8_t getCoarseBatteryVoltage(); + uint8_t getBatteryStatus(); +}; + +class HeartRateBatteryStatus : public HeartRateBaseMainDataPage, public HeartRateBaseBatteryStatus { +public: + explicit HeartRateBatteryStatus(AntRxDataResponse& dp); +}; + +class HeartRateBatteryStatusMsg : public HeartRateBaseMainDataPageMsg, public HeartRateBaseBatteryStatus { +public: + HeartRateBatteryStatusMsg(); + void setBatteryLevel(uint8_t level); + void setFractionalBatteryVoltage(uint8_t voltage); + void setCoarseBatteryVolage(uint8_t voltage); + void setBatteryStatus(uint8_t status); +}; + +#endif // ANTPLUS_HEARTRATEBATTERYSTATUS_h diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCapabilities.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCapabilities.cpp new file mode 100644 index 0000000..cdfac9d --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCapabilities.cpp @@ -0,0 +1,39 @@ +#include +#include + +#define FEATURESSUPPORTED_BYTE 2 +#define FEATURESENABLED_BYTE 3 +#define FEATURES_MASK 0xC7 + +template +HeartRateBaseCapabilities::HeartRateBaseCapabilities() : + CoreDataPage() {} + +template +uint8_t HeartRateBaseCapabilities::getFeaturesSupported() { + return this->get8BitValue(FEATURESSUPPORTED_BYTE); +} + +template +uint8_t HeartRateBaseCapabilities::getFeaturesEnabled() { + return this->get8BitValue(FEATURESENABLED_BYTE); +} + +template class HeartRateBaseCapabilities; +template class HeartRateBaseCapabilities; + +HeartRateCapabilities::HeartRateCapabilities(AntRxDataResponse& dp) : + HeartRateBaseMainDataPage(dp), + HeartRateBaseCapabilities() {} + +HeartRateCapabilitiesMsg::HeartRateCapabilitiesMsg() : + HeartRateBaseMainDataPageMsg(ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_NUMBER), + HeartRateBaseCapabilities() {} + +void HeartRateCapabilitiesMsg::setFeaturesSupported(uint8_t supported) { + set8BitValue(supported, FEATURESSUPPORTED_BYTE, FEATURES_MASK); +} + +void HeartRateCapabilitiesMsg::setFeaturesEnabled(uint8_t enabled) { + set8BitValue(enabled, FEATURESENABLED_BYTE, FEATURES_MASK); +} diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCapabilities.h b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCapabilities.h new file mode 100644 index 0000000..48a437f --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCapabilities.h @@ -0,0 +1,26 @@ +#ifndef ANTPLUS_HEARTRATECAPABILITIES_h +#define ANTPLUS_HEARTRATECAPABILITIES_h + +#include + +template +class HeartRateBaseCapabilities : virtual public CoreDataPage { +public: + HeartRateBaseCapabilities(); + uint8_t getFeaturesSupported(); + uint8_t getFeaturesEnabled(); +}; + +class HeartRateCapabilities : public HeartRateBaseMainDataPage, public HeartRateBaseCapabilities { +public: + explicit HeartRateCapabilities(AntRxDataResponse& dp); +}; + +class HeartRateCapabilitiesMsg : public HeartRateBaseMainDataPageMsg, HeartRateBaseCapabilities { +public: + HeartRateCapabilitiesMsg(); + void setFeaturesSupported(uint8_t supported); + void setFeaturesEnabled(uint8_t enabled); +}; + +#endif // ANTPLUS_HEARTRATECAPABILITIES_h diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCumulativeOperatingTime.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCumulativeOperatingTime.cpp new file mode 100644 index 0000000..1c83022 --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCumulativeOperatingTime.cpp @@ -0,0 +1,29 @@ +#include +#include + +#define TIME_LSB_BYTE 1 +#define TIME_MSB_BYTE 3 + +template +HeartRateBaseCumulativeOperatingTime::HeartRateBaseCumulativeOperatingTime() : + CoreDataPage() {} + +template +uint32_t HeartRateBaseCumulativeOperatingTime::getCumulativeOperatingTime() { + return this->get24BitValue(TIME_LSB_BYTE, TIME_MSB_BYTE); +} + +template class HeartRateBaseCumulativeOperatingTime; +template class HeartRateBaseCumulativeOperatingTime; + +HeartRateCumulativeOperatingTime::HeartRateCumulativeOperatingTime(AntRxDataResponse& dp) : + HeartRateBaseMainDataPage(dp), + HeartRateBaseCumulativeOperatingTime() {} + +HeartRateCumulativeOperatingTimeMsg::HeartRateCumulativeOperatingTimeMsg() : + HeartRateBaseMainDataPageMsg(HEARTRATE_CUMULATIVEOPERATINGTIME_NUMBER), + HeartRateBaseCumulativeOperatingTime() {} + +void HeartRateCumulativeOperatingTimeMsg::setCumulativeOperatingTime(uint32_t time) { + set24BitValue(time, TIME_LSB_BYTE, TIME_MSB_BYTE); +} diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCumulativeOperatingTime.h b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCumulativeOperatingTime.h new file mode 100644 index 0000000..55aa63b --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCumulativeOperatingTime.h @@ -0,0 +1,24 @@ +#ifndef ANTPLUS_HEARTRATECUMULITIVEOPERATINGTIME_h +#define ANTPLUS_HEARTRATECUMULITIVEOPERATINGTIME_h + +#include + +template +class HeartRateBaseCumulativeOperatingTime : virtual public CoreDataPage { +public: + HeartRateBaseCumulativeOperatingTime(); + uint32_t getCumulativeOperatingTime(); // only 24 bits +}; + +class HeartRateCumulativeOperatingTime : public HeartRateBaseMainDataPage, public HeartRateBaseCumulativeOperatingTime { +public: + explicit HeartRateCumulativeOperatingTime(AntRxDataResponse& dp); +}; + +class HeartRateCumulativeOperatingTimeMsg : public HeartRateBaseMainDataPageMsg, public HeartRateBaseCumulativeOperatingTime { +public: + HeartRateCumulativeOperatingTimeMsg(); + void setCumulativeOperatingTime(uint32_t time); +}; + +#endif // ANTPLUS_HEARTRATECUMULITIVEOPERATINGTIME_h diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.cpp new file mode 100644 index 0000000..c8dcba1 --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.cpp @@ -0,0 +1,14 @@ +#include +#include + +#define RESERVED_LSB_BYTE 1 +#define RESERVED_MSB_BYTE 3 +#define RESERVED_VALUE 0xFFFFFF + +HeartRateDefault::HeartRateDefault(AntRxDataResponse& dp) : + HeartRateBaseMainDataPage(dp) {} + +HeartRateDefaultMsg::HeartRateDefaultMsg() : + HeartRateBaseMainDataPageMsg(ANTPLUS_HEARTRATE_DATAPAGE_DEFAULT_NUMBER) { + set24BitValue(RESERVED_VALUE, RESERVED_LSB_BYTE, RESERVED_MSB_BYTE); +} diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.h b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.h new file mode 100644 index 0000000..95f8129 --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.h @@ -0,0 +1,16 @@ +#ifndef ANTPLUS_HEARTRATEDEFAULT_h +#define ANTPLUS_HEARTRATEDEFAULT_h + +#include + +class HeartRateDefault : public HeartRateBaseMainDataPage { +public: + explicit HeartRateDefault(AntRxDataResponse& dp); +}; + +class HeartRateDefaultMsg : public HeartRateBaseMainDataPageMsg { +public: + HeartRateDefaultMsg(); +}; + +#endif // ANTPLUS_HEARTRATEDEFAULT_h diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateManufacturerInformation.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateManufacturerInformation.cpp new file mode 100644 index 0000000..03f3ee9 --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateManufacturerInformation.cpp @@ -0,0 +1,39 @@ +#include +#include + +#define MANUFACTUREREIDLSB_BYTE 1 +#define SERIALNUMBER_LSB_BYTE 2 +#define SERIALNUMBER_MSB_BYTE 3 + +template +HeartRateBaseManufacturerInformation::HeartRateBaseManufacturerInformation() : + CoreDataPage() {} + +template +uint8_t HeartRateBaseManufacturerInformation::getManufacturerIdLsb() { + return this->get8BitValue(MANUFACTUREREIDLSB_BYTE); +} + +template +uint16_t HeartRateBaseManufacturerInformation::getSerialNumber() { + return this->get16BitValue(SERIALNUMBER_LSB_BYTE, SERIALNUMBER_MSB_BYTE); +} + +template class HeartRateBaseManufacturerInformation; +template class HeartRateBaseManufacturerInformation; + +HeartRateManufacturerInformation::HeartRateManufacturerInformation(AntRxDataResponse& dp) : + HeartRateBaseMainDataPage(dp), + HeartRateBaseManufacturerInformation() {} + +HeartRateManufacturerInformationMsg::HeartRateManufacturerInformationMsg() : + HeartRateBaseMainDataPageMsg(HEARTRATE_MANUFACTURERINFORMATION_NUMBER), + HeartRateBaseManufacturerInformation() {} + +void HeartRateManufacturerInformationMsg::setManufacturerIdLsb(uint8_t id) { + set8BitValue(id, MANUFACTUREREIDLSB_BYTE); +} + +void HeartRateManufacturerInformationMsg::setSerialNumber(uint16_t serialNumber) { + set16BitValue(serialNumber, SERIALNUMBER_LSB_BYTE, SERIALNUMBER_MSB_BYTE); +} diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateManufacturerInformation.h b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateManufacturerInformation.h new file mode 100644 index 0000000..642e1e7 --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateManufacturerInformation.h @@ -0,0 +1,26 @@ +#ifndef ANTPLUS_HEARTRATEMANUFACTURERINFORMATION_h +#define ANTPLUS_HEARTRATEMANUFACTURERINFORMATION_h + +#include + +template +class HeartRateBaseManufacturerInformation : virtual public CoreDataPage { +public: + HeartRateBaseManufacturerInformation(); + uint8_t getManufacturerIdLsb(); + uint16_t getSerialNumber(); +}; + +class HeartRateManufacturerInformation : public HeartRateBaseMainDataPage, public HeartRateBaseManufacturerInformation { +public: + explicit HeartRateManufacturerInformation(AntRxDataResponse& dp); +}; + +class HeartRateManufacturerInformationMsg : public HeartRateBaseMainDataPageMsg, public HeartRateBaseManufacturerInformation { +public: + HeartRateManufacturerInformationMsg(); + void setManufacturerIdLsb(uint8_t id); + void setSerialNumber(uint16_t serialNumber); +}; + +#endif // ANTPLUS_HEARTRATEMANUFACTURERINFORMATION_h diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRatePreviousHeartBeat.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRatePreviousHeartBeat.cpp new file mode 100644 index 0000000..10990a7 --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRatePreviousHeartBeat.cpp @@ -0,0 +1,48 @@ +#include +#include +#include + +#define MANUFACTURERSPECIFIC_BYTE 1 +#define PREVIOUSHEARTBEATEVENTTIME_LSB_BYTE 2 +#define PREVIOUSHEARTBEATEVENTTIME_MSB_BYTE 3 + +template +HeartRateBasePreviousHeartBeat::HeartRateBasePreviousHeartBeat() : + CoreDataPage() {} + +template +uint8_t HeartRateBasePreviousHeartBeat::getManufacturerSpecific() { + return this->get8BitValue(MANUFACTURERSPECIFIC_BYTE); +} + +template +uint16_t HeartRateBasePreviousHeartBeat::getPreviousHeartBeatEventTime() { + return this->get16BitValue( + PREVIOUSHEARTBEATEVENTTIME_LSB_BYTE, + PREVIOUSHEARTBEATEVENTTIME_MSB_BYTE); +} + +template class HeartRateBasePreviousHeartBeat; +template class HeartRateBasePreviousHeartBeat; + +HeartRatePreviousHeartBeat::HeartRatePreviousHeartBeat(AntRxDataResponse& dp) : + HeartRateBaseMainDataPage(dp), + HeartRateBasePreviousHeartBeat() {} + +// TODO add isValid method to manufactueres byte +HeartRatePreviousHeartBeatMsg::HeartRatePreviousHeartBeatMsg() : + HeartRateBaseMainDataPageMsg(HEARTRATE_PREVIOUSHEARTBEAT_NUMBER), + HeartRateBasePreviousHeartBeat() { + setManufacturerSpecific( + ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_MANUFACTURERSPECIFIC_INVALID); +} + +void HeartRatePreviousHeartBeatMsg::setManufacturerSpecific(uint8_t specificByte) { + set8BitValue(specificByte, MANUFACTURERSPECIFIC_BYTE); +} + +void HeartRatePreviousHeartBeatMsg::setPreviousHeartBeatEventTime(uint16_t eventTime) { + set16BitValue(eventTime, + PREVIOUSHEARTBEATEVENTTIME_LSB_BYTE, + PREVIOUSHEARTBEATEVENTTIME_MSB_BYTE); +} diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRatePreviousHeartBeat.h b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRatePreviousHeartBeat.h new file mode 100644 index 0000000..b1f9b91 --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRatePreviousHeartBeat.h @@ -0,0 +1,26 @@ +#ifndef ANTPLUS_HEARTRATEPREVIOUSHEARTBEAT_h +#define ANTPLUS_HEARTRATEPREVIOUSHEARTBEAT_h + +#include + +template +class HeartRateBasePreviousHeartBeat : virtual public CoreDataPage { +public: + HeartRateBasePreviousHeartBeat(); + uint8_t getManufacturerSpecific(); + uint16_t getPreviousHeartBeatEventTime(); +}; + +class HeartRatePreviousHeartBeat : public HeartRateBaseMainDataPage, public HeartRateBasePreviousHeartBeat { +public: + explicit HeartRatePreviousHeartBeat(AntRxDataResponse& dp); +}; + +class HeartRatePreviousHeartBeatMsg : public HeartRateBaseMainDataPageMsg, public HeartRateBasePreviousHeartBeat { +public: + HeartRatePreviousHeartBeatMsg(); + void setManufacturerSpecific(uint8_t specificByte); + void setPreviousHeartBeatEventTime(uint16_t eventTime); +}; + +#endif // ANTPLUS_HEARTRATEPREVIOUSHEARTBEAT_h diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateProductInformation.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateProductInformation.cpp new file mode 100644 index 0000000..1df0d3c --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateProductInformation.cpp @@ -0,0 +1,48 @@ +#include +#include + +#define HARDWAREVERSION_BYTE 1 +#define SOFTWAREVERSION_BYTE 2 +#define MODELNUMBER_BYTE 3 + +template +HeartRateBaseProductInformation::HeartRateBaseProductInformation() : + CoreDataPage() {} + +template +uint8_t HeartRateBaseProductInformation::getHardwareVersion() { + return this->get8BitValue(HARDWAREVERSION_BYTE); +} + +template +uint8_t HeartRateBaseProductInformation::getSoftwareVersion() { + return this->get8BitValue(SOFTWAREVERSION_BYTE); +} + +template +uint8_t HeartRateBaseProductInformation::getModelNumber() { + return this->get8BitValue(MODELNUMBER_BYTE); +} + +template class HeartRateBaseProductInformation; +template class HeartRateBaseProductInformation; + +HeartRateProductInformation::HeartRateProductInformation(AntRxDataResponse& dp) : + HeartRateBaseMainDataPage(dp), + HeartRateBaseProductInformation() {} + +HeartRateProductInformationMsg::HeartRateProductInformationMsg() : + HeartRateBaseMainDataPageMsg(HEARTRATE_PRODUCTINFORMATION_NUMBER), + HeartRateBaseProductInformation() {} + +void HeartRateProductInformationMsg::setHardwareVersion(uint8_t hwVersion) { + this->set8BitValue(hwVersion, HARDWAREVERSION_BYTE); +} + +void HeartRateProductInformationMsg::setSoftwareVersion(uint8_t swVersion) { + this->set8BitValue(swVersion, SOFTWAREVERSION_BYTE); +} + +void HeartRateProductInformationMsg::setModelNumber(uint8_t modelNumber) { + this->set8BitValue(modelNumber, MODELNUMBER_BYTE); +} diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateProductInformation.h b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateProductInformation.h new file mode 100644 index 0000000..0d79faa --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateProductInformation.h @@ -0,0 +1,28 @@ +#ifndef ANTPLUS_HEARTRATEPRODUCTIONINFORMATION_h +#define ANTPLUS_HEARTRATEPRODUCTIONINFORMATION_h + +#include + +template +class HeartRateBaseProductInformation : virtual public CoreDataPage { +public: + HeartRateBaseProductInformation(); + uint8_t getHardwareVersion(); + uint8_t getSoftwareVersion(); + uint8_t getModelNumber(); +}; + +class HeartRateProductInformation : public HeartRateBaseMainDataPage, public HeartRateBaseProductInformation { +public: + explicit HeartRateProductInformation(AntRxDataResponse& dp); +}; + +class HeartRateProductInformationMsg : public HeartRateBaseMainDataPageMsg, public HeartRateBaseProductInformation { +public: + HeartRateProductInformationMsg(); + void setHardwareVersion(uint8_t hwVersion); + void setSoftwareVersion(uint8_t swVersion); + void setModelNumber(uint8_t modelNumber); +}; + +#endif // ANTPLUS_HEARTRATEPRODUCTIONINFORMATION_h diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateSwimIntervalSummary.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateSwimIntervalSummary.cpp new file mode 100644 index 0000000..c3ad8c2 --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateSwimIntervalSummary.cpp @@ -0,0 +1,54 @@ +#include +#include +#include + +#define INTERVALAVERAGEHEARTRATE_BYTE 1 +#define INTERVALMAXIMUMHEARTRATE_BYTE 2 +#define SESSIONAVERAGEHEARTRATE_BYTE 3 + +template +HeartRateBaseSwimIntervalSummary::HeartRateBaseSwimIntervalSummary() : + CoreDataPage() {} + +template +uint8_t HeartRateBaseSwimIntervalSummary::getIntervalAverageHeartRate() { + return this->get8BitValue(INTERVALAVERAGEHEARTRATE_BYTE); +} + +template +uint8_t HeartRateBaseSwimIntervalSummary::getIntervalMaximumHeartRate() { + return this->get8BitValue(INTERVALMAXIMUMHEARTRATE_BYTE); +} + +template +uint8_t HeartRateBaseSwimIntervalSummary::getSessionAverageHeartRate() { + return this->get8BitValue(SESSIONAVERAGEHEARTRATE_BYTE); +} + +template class HeartRateBaseSwimIntervalSummary; +template class HeartRateBaseSwimIntervalSummary; + +HeartRateSwimIntervalSummary::HeartRateSwimIntervalSummary(AntRxDataResponse& dp) : + HeartRateBaseMainDataPage(dp), + HeartRateBaseSwimIntervalSummary() {} + +HeartRateSwimIntervalSummaryMsg::HeartRateSwimIntervalSummaryMsg() : + HeartRateBaseMainDataPageMsg(HEARTRATE_SWIMINTERVALSUMMARY_NUMBER), + HeartRateBaseSwimIntervalSummary() { + setIntervalAverageHeartRate(ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALAVERAGEHEARTRATE_INVALID); + setIntervalMaximumHeartRate(ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALMAXIMUMHEARTRATE_INVALID); + setSessionAverageHeartRate(ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_SESSIONAVERAGEHEARTRATE_INVALID); +} + +void HeartRateSwimIntervalSummaryMsg::setIntervalAverageHeartRate(uint8_t intervalAverage) { + set8BitValue(intervalAverage, INTERVALAVERAGEHEARTRATE_BYTE); +} + +void HeartRateSwimIntervalSummaryMsg::setIntervalMaximumHeartRate(uint8_t intervalMaximum) { + set8BitValue(intervalMaximum, INTERVALMAXIMUMHEARTRATE_BYTE); +} + +void HeartRateSwimIntervalSummaryMsg::setSessionAverageHeartRate(uint8_t sessionAverage) { + set8BitValue(sessionAverage, SESSIONAVERAGEHEARTRATE_BYTE); +} + diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateSwimIntervalSummary.h b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateSwimIntervalSummary.h new file mode 100644 index 0000000..c82fe1a --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateSwimIntervalSummary.h @@ -0,0 +1,29 @@ +#ifndef ANTPLUS_HEARTRATESWIMINTERVALSUMMARY_h +#define ANTPLUS_HEARTRATESWIMINTERVALSUMMARY_h + +#include +#include + +template +class HeartRateBaseSwimIntervalSummary : virtual public CoreDataPage { +public: + HeartRateBaseSwimIntervalSummary(); + uint8_t getIntervalAverageHeartRate(); + uint8_t getIntervalMaximumHeartRate(); + uint8_t getSessionAverageHeartRate(); +}; + +class HeartRateSwimIntervalSummary : public HeartRateBaseMainDataPage, public HeartRateBaseSwimIntervalSummary { +public: + explicit HeartRateSwimIntervalSummary(AntRxDataResponse& dp); +}; + +class HeartRateSwimIntervalSummaryMsg : public HeartRateBaseMainDataPageMsg, public HeartRateBaseSwimIntervalSummary { +public: + HeartRateSwimIntervalSummaryMsg(); + void setIntervalAverageHeartRate(uint8_t intervalAverage); + void setIntervalMaximumHeartRate(uint8_t intervalMaximum); + void setSessionAverageHeartRate(uint8_t sessionAverage); +}; + +#endif // ANTPLUS_HEARTRATESWIMINTERVALSUMMARY_h diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_ProfileHeartRateDataPages.h b/src/Profiles/HeartRate/DataPages/ANTPLUS_ProfileHeartRateDataPages.h deleted file mode 100644 index 1beb2e1..0000000 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_ProfileHeartRateDataPages.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef ANTPLUS_PROFILEHEARTRATEDATAPAGES_h -#define ANTPLUS_PROFILEHEARTRATEDATAPAGES_h - -/* RX */ -#include -#include -#include -#include -#include -#include -#include -#include - -/* TX */ -#include -#include -#include -#include -#include -#include -#include -#include - -#endif // ANTPLUS_PROFILEHEARTRATEDATAPAGES_h diff --git a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseBatteryStatus.cpp b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseBatteryStatus.cpp deleted file mode 100644 index 01e3aa7..0000000 --- a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseBatteryStatus.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include - -template -HeartRateBaseBatteryStatus::HeartRateBaseBatteryStatus() : CoreDataPage() { -} - -template -uint8_t HeartRateBaseBatteryStatus::getBatteryLevel() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYLEVEL_BYTE); -} - -template -uint8_t HeartRateBaseBatteryStatus::getFractionalBatteryVoltage() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE); -} - -template -uint8_t HeartRateBaseBatteryStatus::getCoarseBatteryVoltage() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_BYTE, - ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_MASK); -} - -template -uint8_t HeartRateBaseBatteryStatus::getBatteryStatus() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_BYTE, - ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_MASK, - ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_SHIFT); -} - -template class HeartRateBaseBatteryStatus; -template class HeartRateBaseBatteryStatus; diff --git a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseBatteryStatus.h b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseBatteryStatus.h deleted file mode 100644 index 0096efd..0000000 --- a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseBatteryStatus.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef ANTPLUS_HEARTRATEBASEBATTERYSTATUS_h -#define ANTPLUS_HEARTRATEBASEBATTERYSTATUS_h - -#include - -#include "ANT.h" - -template -class HeartRateBaseBatteryStatus : virtual public CoreDataPage { -public: - HeartRateBaseBatteryStatus(); - uint8_t getBatteryLevel(); - uint8_t getFractionalBatteryVoltage(); - uint8_t getCoarseBatteryVoltage(); - uint8_t getBatteryStatus(); -}; - -#endif // ANTPLUS_HEARTRATEBASEBATTERYSTATUS_h diff --git a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseCapabilities.cpp b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseCapabilities.cpp deleted file mode 100644 index 1149c70..0000000 --- a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseCapabilities.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -template -HeartRateBaseCapabilities::HeartRateBaseCapabilities() : CoreDataPage() { -} - -template -uint8_t HeartRateBaseCapabilities::getFeaturesSupported() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURESSUPPORTED_BYTE); -} - -template -uint8_t HeartRateBaseCapabilities::getFeaturesEnabled() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURESENABLED_BYTE); -} - -template class HeartRateBaseCapabilities; -template class HeartRateBaseCapabilities; diff --git a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseCapabilities.h b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseCapabilities.h deleted file mode 100644 index 991d687..0000000 --- a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseCapabilities.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef ANTPLUS_HEARTRATEBASECAPABILITIES_h -#define ANTPLUS_HEARTRATEBASECAPABILITIES_h - -#include - -#include "ANT.h" - -template -class HeartRateBaseCapabilities : virtual public CoreDataPage { -public: - HeartRateBaseCapabilities(); - uint8_t getFeaturesSupported(); - uint8_t getFeaturesEnabled(); -}; - -#endif // ANTPLUS_HEARTRATEBASECAPABILITIES_h diff --git a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseCumulativeOperatingTime.cpp b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseCumulativeOperatingTime.cpp deleted file mode 100644 index 79b552f..0000000 --- a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseCumulativeOperatingTime.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -template -HeartRateBaseCumulativeOperatingTime::HeartRateBaseCumulativeOperatingTime() : CoreDataPage() { -} - -template -uint32_t HeartRateBaseCumulativeOperatingTime::getCumulativeOperatingTime() { - return this->get24BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_TIME_LSB_BYTE, - ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_TIME_MSB_BYTE); -} - -template class HeartRateBaseCumulativeOperatingTime; -template class HeartRateBaseCumulativeOperatingTime; diff --git a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseCumulativeOperatingTime.h b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseCumulativeOperatingTime.h deleted file mode 100644 index 35c85d3..0000000 --- a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseCumulativeOperatingTime.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef ANTPLUS_HEARTRATEBASECUMULITIVEOPERATINGTIME_h -#define ANTPLUS_HEARTRATEBASECUMULITIVEOPERATINGTIME_h - -#include - -#include "ANT.h" - -template -class HeartRateBaseCumulativeOperatingTime : virtual public CoreDataPage { -public: - HeartRateBaseCumulativeOperatingTime(); - uint32_t getCumulativeOperatingTime(); // only 24 bits -}; - -#endif // ANTPLUS_HEARTRATEBASECUMULITIVEOPERATINGTIME_h diff --git a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPage.cpp b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPage.cpp deleted file mode 100644 index 029d876..0000000 --- a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPage.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include -#include - -HeartRateBaseMainDataPage::HeartRateBaseMainDataPage(AntRxDataResponse& dp) : BaseDataPage(dp), HeartRateCoreMainDataPage() { -} diff --git a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPage.h b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPage.h deleted file mode 100644 index 6a45de4..0000000 --- a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPage.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef ANTPLUS_HEARTRATEBASEMAINDATAPAGE_h -#define ANTPLUS_HEARTRATEBASEMAINDATAPAGE_h - -#include -#include - -#include "ANT.h" - -class HeartRateBaseMainDataPage : public BaseDataPage, public HeartRateCoreMainDataPage { -public: - HeartRateBaseMainDataPage(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_HEARTRATEBASEMAINDATAPAGE_h diff --git a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPageMsg.cpp b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPageMsg.cpp deleted file mode 100644 index e6e491c..0000000 --- a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPageMsg.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include -#include - -HeartRateBaseMainDataPageMsg::HeartRateBaseMainDataPageMsg(uint8_t dataPageNumber) : BaseDataPageMsg(), HeartRateCoreMainDataPage() { - setDataBuffer(_buffer); - _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = dataPageNumber; -} - -void HeartRateBaseMainDataPageMsg::setPageChangeToggle(uint8_t toggle) { - set8BitValue(toggle ? 1 : 0, - ANTPLUS_HEARTRATE_DATAPAGEBASE_TOGGLE_BYTE, - ANTPLUS_HEARTRATE_DATAPAGEBASE_TOGGLE_MASK, - ANTPLUS_HEARTRATE_DATAPAGEBASE_TOGGLE_SHIFT); -} - -void HeartRateBaseMainDataPageMsg::setHeartBeatEventTime(uint16_t time) { - set16BitValue(time, - ANTPLUS_HEARTRATE_DATAPAGEBASE_HEARTBEATEVENTTIMELSB_BYTE, - ANTPLUS_HEARTRATE_DATAPAGEBASE_HEARTBEATEVENTTIMEMSB_BYTE); -} - -void HeartRateBaseMainDataPageMsg::setHeartBeatCount(uint8_t count) { - set8BitValue(count, - ANTPLUS_HEARTRATE_DATAPAGEBASE_HEARTBEATCOUNT_BYTE); -} - -void HeartRateBaseMainDataPageMsg::setComputedHeartRate(uint8_t heartRate) { - set8BitValue(heartRate, - ANTPLUS_HEARTRATE_DATAPAGEBASE_COMPUTEDHEARTRATE_BYTE); -} diff --git a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPageMsg.h b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPageMsg.h deleted file mode 100644 index 0c411e4..0000000 --- a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPageMsg.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef ANTPLUS_HEARTRATEBASEMAINDATAPAGEMSG_h -#define ANTPLUS_HEARTRATEBASEMAINDATAPAGEMSG_h - -#include -#include - -#include "ANT.h" - -class HeartRateBaseMainDataPageMsg : public BaseDataPageMsg, public HeartRateCoreMainDataPage { -public: - HeartRateBaseMainDataPageMsg(uint8_t dataPageNumber); - void setPageChangeToggle(uint8_t toggle); - void setHeartBeatEventTime(uint16_t time); - void setHeartBeatCount(uint8_t count); - void setComputedHeartRate(uint8_t heartRate); -protected: - uint8_t _buffer[MESSAGE_SIZE]; -}; - -#endif // ANTPLUS_HEARTRATEBASEMAINDATAPAGEMSG_h diff --git a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseManufacturerInformation.cpp b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseManufacturerInformation.cpp deleted file mode 100644 index 9ae747d..0000000 --- a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseManufacturerInformation.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -template -HeartRateBaseManufacturerInformation::HeartRateBaseManufacturerInformation() : CoreDataPage() { -} - -template -uint8_t HeartRateBaseManufacturerInformation::getManufacturerIdLsb() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_MANUFACTUREREIDLSB_BYTE); -} - -template -uint16_t HeartRateBaseManufacturerInformation::getSerialNumber() { - return this->get16BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_SERIALNUMBERLSB_BYTE, - ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_SERIALNUMBERMSB_BYTE); -} - -template class HeartRateBaseManufacturerInformation; -template class HeartRateBaseManufacturerInformation; diff --git a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseManufacturerInformation.h b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseManufacturerInformation.h deleted file mode 100644 index 6a1c885..0000000 --- a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseManufacturerInformation.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef ANTPLUS_HEARTRATEBASEMANUFACTURERINFORMATION_h -#define ANTPLUS_HEARTRATEBASEMANUFACTURERINFORMATION_h - -#include - -#include "ANT.h" - -template -class HeartRateBaseManufacturerInformation : virtual public CoreDataPage { -public: - HeartRateBaseManufacturerInformation(); - uint8_t getManufacturerIdLsb(); - uint16_t getSerialNumber(); -}; - -#endif // ANTPLUS_HEARTRATEBASEMANUFACTURERINFORMATION_h diff --git a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBasePreviousHeartBeat.cpp b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBasePreviousHeartBeat.cpp deleted file mode 100644 index f0d1550..0000000 --- a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBasePreviousHeartBeat.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -template -HeartRateBasePreviousHeartBeat::HeartRateBasePreviousHeartBeat() : CoreDataPage() { -} - -template -uint8_t HeartRateBasePreviousHeartBeat::getManufacturerSpecific() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_MANUFACTURERSPECIFIC_BYTE); -} - -template -uint16_t HeartRateBasePreviousHeartBeat::getPreviousHeartBeatEventTime() { - return this->get16BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_PREVIOUSHEARTBEATEVENTTIMELSB_BYTE, - ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_PREVIOUSHEARTBEATEVENTTIMEMSB_BYTE); -} - -template class HeartRateBasePreviousHeartBeat; -template class HeartRateBasePreviousHeartBeat; diff --git a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBasePreviousHeartBeat.h b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBasePreviousHeartBeat.h deleted file mode 100644 index cea34d4..0000000 --- a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBasePreviousHeartBeat.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef ANTPLUS_HEARTRATEBASEPREVIOUSHEARTBEAT_h -#define ANTPLUS_HEARTRATEBASEPREVIOUSHEARTBEAT_h - -#include - -#include "ANT.h" - -template -class HeartRateBasePreviousHeartBeat : virtual public CoreDataPage { -public: - HeartRateBasePreviousHeartBeat(); - uint8_t getManufacturerSpecific(); - uint16_t getPreviousHeartBeatEventTime(); -}; - -#endif // ANTPLUS_HEARTRATEBASEPREVIOUSHEARTBEAT_h diff --git a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseProductInformation.cpp b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseProductInformation.cpp deleted file mode 100644 index bb67ae3..0000000 --- a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseProductInformation.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include - -template -HeartRateBaseProductInformation::HeartRateBaseProductInformation() : CoreDataPage() { -} - -template -uint8_t HeartRateBaseProductInformation::getHardwareVersion() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_HARDWAREVERSION_BYTE); -} - -template -uint8_t HeartRateBaseProductInformation::getSoftwareVersion() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_SOFTWAREVERSION_BYTE); -} - -template -uint8_t HeartRateBaseProductInformation::getModelNumber() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_MODELNUMBER_BYTE); -} - -template class HeartRateBaseProductInformation; -template class HeartRateBaseProductInformation; diff --git a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseProductInformation.h b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseProductInformation.h deleted file mode 100644 index c17f36f..0000000 --- a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseProductInformation.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef ANTPLUS_HEARTRATEBASEPRODUCTIONINFORMATION_h -#define ANTPLUS_HEARTRATEBASEPRODUCTIONINFORMATION_h - -#include - -#include "ANT.h" - -template -class HeartRateBaseProductInformation : virtual public CoreDataPage { -public: - HeartRateBaseProductInformation(); - uint8_t getHardwareVersion(); - uint8_t getSoftwareVersion(); - uint8_t getModelNumber(); -}; - -#endif // ANTPLUS_HEARTRATEBASEPRODUCTIONINFORMATION_h diff --git a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseSwimIntervalSummary.cpp b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseSwimIntervalSummary.cpp deleted file mode 100644 index 8bca94b..0000000 --- a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseSwimIntervalSummary.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include - -template -HeartRateBaseSwimIntervalSummary::HeartRateBaseSwimIntervalSummary() : CoreDataPage() { -} - -template -uint8_t HeartRateBaseSwimIntervalSummary::getIntervalAverageHeartRate() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALAVERAGEHEARTRATE_BYTE); -} - -template -uint8_t HeartRateBaseSwimIntervalSummary::getIntervalMaximumHeartRate() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALMAXIMUMHEARTRATE_BYTE); -} - -template -uint8_t HeartRateBaseSwimIntervalSummary::getSessionAverageHeartRate() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_SESSIONAVERAGEHEARTRATE_BYTE); -} - -template class HeartRateBaseSwimIntervalSummary; -template class HeartRateBaseSwimIntervalSummary; diff --git a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseSwimIntervalSummary.h b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseSwimIntervalSummary.h deleted file mode 100644 index 1712850..0000000 --- a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseSwimIntervalSummary.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef ANTPLUS_HEARTRATEBASESWIMINTERVALSUMMARY_h -#define ANTPLUS_HEARTRATEBASESWIMINTERVALSUMMARY_h - -#include - -#include "ANT.h" - -template -class HeartRateBaseSwimIntervalSummary : virtual public CoreDataPage { -public: - HeartRateBaseSwimIntervalSummary(); - uint8_t getIntervalAverageHeartRate(); - uint8_t getIntervalMaximumHeartRate(); - uint8_t getSessionAverageHeartRate(); -}; - -#endif // ANTPLUS_HEARTRATEBASESWIMINTERVALSUMMARY_h diff --git a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateCoreMainDataPage.cpp b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateCoreMainDataPage.cpp deleted file mode 100644 index 6b2cbd6..0000000 --- a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateCoreMainDataPage.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include - -template -HeartRateCoreMainDataPage::HeartRateCoreMainDataPage() : CoreDataPage() { -} - -template -uint8_t HeartRateCoreMainDataPage::getDataPageNumber() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGEBASE_DATAPAGE_BYTE, - ANTPLUS_HEARTRATE_DATAPAGEBASE_DATAPAGE_MASK); -} - -template -uint8_t HeartRateCoreMainDataPage::getPageChangeToggle() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGEBASE_TOGGLE_BYTE, - ANTPLUS_HEARTRATE_DATAPAGEBASE_TOGGLE_MASK, - ANTPLUS_HEARTRATE_DATAPAGEBASE_TOGGLE_SHIFT); -} - -template -uint16_t HeartRateCoreMainDataPage::getHeartBeatEventTime() { - return this->get16BitValue( - ANTPLUS_HEARTRATE_DATAPAGEBASE_HEARTBEATEVENTTIMELSB_BYTE, - ANTPLUS_HEARTRATE_DATAPAGEBASE_HEARTBEATEVENTTIMEMSB_BYTE); -} - -template -uint8_t HeartRateCoreMainDataPage::getHeartBeatCount() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGEBASE_HEARTBEATCOUNT_BYTE); -} - -template -uint8_t HeartRateCoreMainDataPage::getComputedHeartRate() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGEBASE_COMPUTEDHEARTRATE_BYTE); -} - -template class HeartRateCoreMainDataPage; -template class HeartRateCoreMainDataPage; diff --git a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateCoreMainDataPage.h b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateCoreMainDataPage.h deleted file mode 100644 index 8ed2396..0000000 --- a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateCoreMainDataPage.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef ANTPLUS_HEARTRATECOREMAINDATAPAGE_h -#define ANTPLUS_HEARTRATECOREMAINDATAPAGE_h - -#include - -#include "ANT.h" - -template -class HeartRateCoreMainDataPage : virtual public CoreDataPage { -public: - HeartRateCoreMainDataPage(); - uint8_t getDataPageNumber() override; - uint8_t getPageChangeToggle(); - uint16_t getHeartBeatEventTime(); - uint8_t getHeartBeatCount(); - uint8_t getComputedHeartRate(); -}; - -#endif // ANTPLUS_HEARTRATECOREMAINDATAPAGE_h diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateBatteryStatus.cpp b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateBatteryStatus.cpp deleted file mode 100644 index 2b679d6..0000000 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateBatteryStatus.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -HeartRateBatteryStatus::HeartRateBatteryStatus(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp), HeartRateBaseBatteryStatus() { - -} diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateBatteryStatus.h b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateBatteryStatus.h deleted file mode 100644 index 3ef54d1..0000000 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateBatteryStatus.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_HEARTRATEBATTERYSTATUS_h -#define ANTPLUS_HEARTRATEBATTERYSTATUS_h - -#include -#include - -class HeartRateBatteryStatus : public HeartRateBaseMainDataPage, public HeartRateBaseBatteryStatus { -public: - HeartRateBatteryStatus(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_HEARTRATEBATTERYSTATUS_h diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCapabilities.cpp b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCapabilities.cpp deleted file mode 100644 index 7cd3b28..0000000 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCapabilities.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include - -HeartRateCapabilities::HeartRateCapabilities(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp), HeartRateBaseCapabilities() { -} diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCapabilities.h b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCapabilities.h deleted file mode 100644 index 77cad66..0000000 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCapabilities.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_HEARTRATECAPABILITIES_h -#define ANTPLUS_HEARTRATECAPABILITIES_h - -#include -#include - -class HeartRateCapabilities : public HeartRateBaseMainDataPage, public HeartRateBaseCapabilities { -public: - HeartRateCapabilities(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_HEARTRATECAPABILITIES_h diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCumulativeOperatingTime.cpp b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCumulativeOperatingTime.cpp deleted file mode 100644 index 26b3ab1..0000000 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCumulativeOperatingTime.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include - -HeartRateCumulativeOperatingTime::HeartRateCumulativeOperatingTime(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp), HeartRateBaseCumulativeOperatingTime() { -} diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCumulativeOperatingTime.h b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCumulativeOperatingTime.h deleted file mode 100644 index 29d6990..0000000 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCumulativeOperatingTime.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_HEARTRATECUMULITIVEOPERATINGTIME_h -#define ANTPLUS_HEARTRATECUMULITIVEOPERATINGTIME_h - -#include -#include - -class HeartRateCumulativeOperatingTime : public HeartRateBaseMainDataPage, public HeartRateBaseCumulativeOperatingTime { -public: - HeartRateCumulativeOperatingTime(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_HEARTRATECUMULITIVEOPERATINGTIME_h diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateDefault.cpp b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateDefault.cpp deleted file mode 100644 index de4c789..0000000 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateDefault.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include - -HeartRateDefault::HeartRateDefault(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp) { -} diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateDefault.h b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateDefault.h deleted file mode 100644 index b3fb62a..0000000 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateDefault.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef ANTPLUS_HEARTRATEDEFAULT_h -#define ANTPLUS_HEARTRATEDEFAULT_h - -#include - -class HeartRateDefault : public HeartRateBaseMainDataPage { -public: - HeartRateDefault(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_HEARTRATEDEFAULT_h \ No newline at end of file diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateManufacturerInformation.cpp b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateManufacturerInformation.cpp deleted file mode 100644 index 855384b..0000000 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateManufacturerInformation.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include - -HeartRateManufacturerInformation::HeartRateManufacturerInformation(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp), HeartRateBaseManufacturerInformation() { -} diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateManufacturerInformation.h b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateManufacturerInformation.h deleted file mode 100644 index 0e65a03..0000000 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateManufacturerInformation.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_HEARTRATEMANUFACTURERINFORMATION_h -#define ANTPLUS_HEARTRATEMANUFACTURERINFORMATION_h - -#include -#include - -class HeartRateManufacturerInformation : public HeartRateBaseMainDataPage, public HeartRateBaseManufacturerInformation { -public: - HeartRateManufacturerInformation(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_HEARTRATEMANUFACTURERINFORMATION_h diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRatePreviousHeartBeat.cpp b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRatePreviousHeartBeat.cpp deleted file mode 100644 index 5f9f9c6..0000000 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRatePreviousHeartBeat.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include - -HeartRatePreviousHeartBeat::HeartRatePreviousHeartBeat(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp), HeartRateBasePreviousHeartBeat() { -} diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRatePreviousHeartBeat.h b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRatePreviousHeartBeat.h deleted file mode 100644 index 8a53ba7..0000000 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRatePreviousHeartBeat.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_HEARTRATEPREVIOUSHEARTBEAT_h -#define ANTPLUS_HEARTRATEPREVIOUSHEARTBEAT_h - -#include -#include - -class HeartRatePreviousHeartBeat : public HeartRateBaseMainDataPage, public HeartRateBasePreviousHeartBeat { -public: - HeartRatePreviousHeartBeat(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_HEARTRATEPREVIOUSHEARTBEAT_h diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateProductInformation.cpp b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateProductInformation.cpp deleted file mode 100644 index 387fa79..0000000 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateProductInformation.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include - -HeartRateProductInformation::HeartRateProductInformation(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp), HeartRateBaseProductInformation() { -} diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateProductInformation.h b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateProductInformation.h deleted file mode 100644 index 357ad9a..0000000 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateProductInformation.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_HEARTRATEPRODUCTIONINFORMATION_h -#define ANTPLUS_HEARTRATEPRODUCTIONINFORMATION_h - -#include -#include - -class HeartRateProductInformation : public HeartRateBaseMainDataPage, public HeartRateBaseProductInformation { -public: - HeartRateProductInformation(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_HEARTRATEPRODUCTIONINFORMATION_h diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateSwimIntervalSummary.cpp b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateSwimIntervalSummary.cpp deleted file mode 100644 index fff842e..0000000 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateSwimIntervalSummary.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include - -HeartRateSwimIntervalSummary::HeartRateSwimIntervalSummary(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp), HeartRateBaseSwimIntervalSummary() { -} diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateSwimIntervalSummary.h b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateSwimIntervalSummary.h deleted file mode 100644 index 2dc07e6..0000000 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateSwimIntervalSummary.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_HEARTRATESWIMINTERVALSUMMARY_h -#define ANTPLUS_HEARTRATESWIMINTERVALSUMMARY_h - -#include -#include - -class HeartRateSwimIntervalSummary : public HeartRateBaseMainDataPage, public HeartRateBaseSwimIntervalSummary { -public: - HeartRateSwimIntervalSummary(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_HEARTRATESWIMINTERVALSUMMARY_h diff --git a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateBatteryStatusMsg.cpp b/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateBatteryStatusMsg.cpp deleted file mode 100644 index ee4cf85..0000000 --- a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateBatteryStatusMsg.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include - -HeartRateBatteryStatusMsg::HeartRateBatteryStatusMsg() : HeartRateBaseMainDataPageMsg(ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_NUMBER), HeartRateBaseBatteryStatus() { -} - -void HeartRateBatteryStatusMsg::setBatteryLevel(uint8_t level) { - set8BitValue(level, - ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYLEVEL_BYTE); -} - -void HeartRateBatteryStatusMsg::setFractionalBatteryVoltage(uint8_t voltage) { - set8BitValue(voltage, - ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE); -} - -void HeartRateBatteryStatusMsg::setCoarseBatteryVolage(uint8_t voltage) { - set8BitValue(voltage, - ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_BYTE, - ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_MASK); -} - -void HeartRateBatteryStatusMsg::setBatteryStatus(uint8_t status) { - set8BitValue(status, - ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_BYTE, - ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_MASK, - ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_SHIFT); -} diff --git a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateBatteryStatusMsg.h b/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateBatteryStatusMsg.h deleted file mode 100644 index c5ba047..0000000 --- a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateBatteryStatusMsg.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef ANTPLUS_HEARTRATEBATTERYSTATUSMSG_h -#define ANTPLUS_HEARTRATEBATTERYSTATUSMSG_h - -#include -#include - -class HeartRateBatteryStatusMsg : public HeartRateBaseMainDataPageMsg, public HeartRateBaseBatteryStatus { -public: - HeartRateBatteryStatusMsg(); - void setBatteryLevel(uint8_t level); - void setFractionalBatteryVoltage(uint8_t voltage); - void setCoarseBatteryVolage(uint8_t voltage); - void setBatteryStatus(uint8_t status); -}; - -#endif // ANTPLUS_HEARTRATEBATTERYSTATUSMSG_h diff --git a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateCapabilitiesMsg.cpp b/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateCapabilitiesMsg.cpp deleted file mode 100644 index 03cdff0..0000000 --- a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateCapabilitiesMsg.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -HeartRateCapabilitiesMsg::HeartRateCapabilitiesMsg() : HeartRateBaseMainDataPageMsg(ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_NUMBER), HeartRateBaseCapabilities() { -} - -void HeartRateCapabilitiesMsg::setFeaturesSupported(uint8_t supported) { - set8BitValue(supported, - ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURESSUPPORTED_BYTE, - ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURES_MASK); -} - -void HeartRateCapabilitiesMsg::setFeaturesEnabled(uint8_t enabled) { - set8BitValue(enabled, - ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURESENABLED_BYTE, - ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURES_MASK); -} diff --git a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateCapabilitiesMsg.h b/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateCapabilitiesMsg.h deleted file mode 100644 index 68306c7..0000000 --- a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateCapabilitiesMsg.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef ANTPLUS_HEARTRATECAPABILITIESMSG_h -#define ANTPLUS_HEARTRATECAPABILITIESMSG_h - -#include -#include - -class HeartRateCapabilitiesMsg : public HeartRateBaseMainDataPageMsg, HeartRateBaseCapabilities { -public: - HeartRateCapabilitiesMsg(); - void setFeaturesSupported(uint8_t supported); - void setFeaturesEnabled(uint8_t enabled); -}; - -#endif // ANTPLUS_HEARTRATECAPABILITIESMSG_h diff --git a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateCumulativeOperatingTimeMsg.cpp b/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateCumulativeOperatingTimeMsg.cpp deleted file mode 100644 index 111f472..0000000 --- a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateCumulativeOperatingTimeMsg.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - -HeartRateCumulativeOperatingTimeMsg::HeartRateCumulativeOperatingTimeMsg() : HeartRateBaseMainDataPageMsg(ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER), HeartRateBaseCumulativeOperatingTime() { -} - -void HeartRateCumulativeOperatingTimeMsg::setCumulativeOperatingTime(uint32_t time) { - set24BitValue(time, - ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_TIME_LSB_BYTE, - ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_TIME_MSB_BYTE); -} diff --git a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateCumulativeOperatingTimeMsg.h b/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateCumulativeOperatingTimeMsg.h deleted file mode 100644 index 1620d2b..0000000 --- a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateCumulativeOperatingTimeMsg.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef ANTPLUS_HEARTRATECUMULITIVEOPERATINGTIMEMSG_h -#define ANTPLUS_HEARTRATECUMULITIVEOPERATINGTIMEMSG_h - -#include -#include - -class HeartRateCumulativeOperatingTimeMsg : public HeartRateBaseMainDataPageMsg, public HeartRateBaseCumulativeOperatingTime { -public: - HeartRateCumulativeOperatingTimeMsg(); - void setCumulativeOperatingTime(uint32_t time); -}; - -#endif // ANTPLUS_HEARTRATECUMULITIVEOPERATINGTIMEMSG_h diff --git a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateDefaultMsg.cpp b/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateDefaultMsg.cpp deleted file mode 100644 index 5ab11e2..0000000 --- a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateDefaultMsg.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -HeartRateDefaultMsg::HeartRateDefaultMsg() : HeartRateBaseMainDataPageMsg(ANTPLUS_HEARTRATE_DATAPAGE_DEFAULT_NUMBER) { - // TODO magic numbers - _buffer[1] = 0xFF; - _buffer[2] = 0xFF; - _buffer[3] = 0xFF; -} diff --git a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateDefaultMsg.h b/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateDefaultMsg.h deleted file mode 100644 index 3e87919..0000000 --- a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateDefaultMsg.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef ANTPLUS_HEARTRATEDEFAULTMSG_h -#define ANTPLUS_HEARTRATEDEFAULTMSG_h - -#include - -class HeartRateDefaultMsg : public HeartRateBaseMainDataPageMsg { -public: - HeartRateDefaultMsg(); -}; - -#endif // ANTPLUS_HEARTRATEDEFAULTMSG_h \ No newline at end of file diff --git a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateManufacturerInformationMsg.cpp b/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateManufacturerInformationMsg.cpp deleted file mode 100644 index c54a828..0000000 --- a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateManufacturerInformationMsg.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -HeartRateManufacturerInformationMsg::HeartRateManufacturerInformationMsg() : HeartRateBaseMainDataPageMsg(ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER), HeartRateBaseManufacturerInformation() { -} - -void HeartRateManufacturerInformationMsg::setManufacturerIdLsb(uint8_t id) { - set8BitValue(id, - ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_MANUFACTUREREIDLSB_BYTE); -} - -void HeartRateManufacturerInformationMsg::setSerialNumber(uint16_t serialNumber) { - set16BitValue(serialNumber, - ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_SERIALNUMBERLSB_BYTE, - ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_SERIALNUMBERMSB_BYTE); -} diff --git a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateManufacturerInformationMsg.h b/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateManufacturerInformationMsg.h deleted file mode 100644 index cd0e807..0000000 --- a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateManufacturerInformationMsg.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef ANTPLUS_HEARTRATEMANUFACTURERINFORMATIONMSG_h -#define ANTPLUS_HEARTRATEMANUFACTURERINFORMATIONMSG_h - -#include -#include - -class HeartRateManufacturerInformationMsg : public HeartRateBaseMainDataPageMsg, public HeartRateBaseManufacturerInformation { -public: - HeartRateManufacturerInformationMsg(); - void setManufacturerIdLsb(uint8_t id); - void setSerialNumber(uint16_t serialNumber); -}; - -#endif // ANTPLUS_HEARTRATEMANUFACTURERINFORMATIONMSG_h diff --git a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRatePreviousHeartBeatMsg.cpp b/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRatePreviousHeartBeatMsg.cpp deleted file mode 100644 index 87d9b47..0000000 --- a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRatePreviousHeartBeatMsg.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include -#include - -HeartRatePreviousHeartBeatMsg::HeartRatePreviousHeartBeatMsg() : HeartRateBaseMainDataPageMsg(ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_NUMBER), HeartRateBasePreviousHeartBeat() { - setManufacturerSpecific(ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_MANUFACTURERSPECIFIC_INVALID); -} - -void HeartRatePreviousHeartBeatMsg::setManufacturerSpecific(uint8_t specificByte) { - set8BitValue(specificByte, - ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_MANUFACTURERSPECIFIC_BYTE); -} - -void HeartRatePreviousHeartBeatMsg::setPreviousHeartBeatEventTime(uint16_t eventTime) { - set16BitValue(eventTime, - ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_PREVIOUSHEARTBEATEVENTTIMELSB_BYTE, - ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_PREVIOUSHEARTBEATEVENTTIMEMSB_BYTE); -} diff --git a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRatePreviousHeartBeatMsg.h b/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRatePreviousHeartBeatMsg.h deleted file mode 100644 index 47ac2fd..0000000 --- a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRatePreviousHeartBeatMsg.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef ANTPLUS_HEARTRATEPREVIOUSHEARTBEATMSG_h -#define ANTPLUS_HEARTRATEPREVIOUSHEARTBEATMSG_h - -#include -#include - -class HeartRatePreviousHeartBeatMsg : public HeartRateBaseMainDataPageMsg, public HeartRateBasePreviousHeartBeat { -public: - HeartRatePreviousHeartBeatMsg(); - void setManufacturerSpecific(uint8_t specificByte); - void setPreviousHeartBeatEventTime(uint16_t eventTime); -}; - -#endif // ANTPLUS_HEARTRATEPREVIOUSHEARTBEATMSG_h diff --git a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateProductInformationMsg.cpp b/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateProductInformationMsg.cpp deleted file mode 100644 index a89d10e..0000000 --- a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateProductInformationMsg.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -HeartRateProductInformationMsg::HeartRateProductInformationMsg() : HeartRateBaseMainDataPageMsg(ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_NUMBER) { - -} - -void HeartRateProductInformationMsg::setHardwareVersion(uint8_t hwVersion) { - _buffer[ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_HARDWAREVERSION_BYTE] = hwVersion; -} - -void HeartRateProductInformationMsg::setSoftwareVersion(uint8_t swVersion) { - _buffer[ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_SOFTWAREVERSION_BYTE] = swVersion; -} - -void HeartRateProductInformationMsg::setModelNumber(uint8_t modelNumber) { - _buffer[ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_MODELNUMBER_BYTE] = modelNumber; -} diff --git a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateProductInformationMsg.h b/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateProductInformationMsg.h deleted file mode 100644 index ca26056..0000000 --- a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateProductInformationMsg.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef ANTPLUS_HEARTRATEPRODUCTIONINFORMATIONMSG_h -#define ANTPLUS_HEARTRATEPRODUCTIONINFORMATIONMSG_h - -#include -#include - -class HeartRateProductInformationMsg : public HeartRateBaseMainDataPageMsg, public HeartRateBaseProductInformation { -public: - HeartRateProductInformationMsg(); - void setHardwareVersion(uint8_t hwVersion); - void setSoftwareVersion(uint8_t swVersion); - void setModelNumber(uint8_t modelNumber); -}; - -#endif // ANTPLUS_HEARTRATEPRODUCTIONINFORMATIONMSG_h diff --git a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateSwimIntervalSummaryMsg.cpp b/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateSwimIntervalSummaryMsg.cpp deleted file mode 100644 index a91f8df..0000000 --- a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateSwimIntervalSummaryMsg.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include -#include - -HeartRateSwimIntervalSummaryMsg::HeartRateSwimIntervalSummaryMsg() : HeartRateBaseMainDataPageMsg(ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_NUMBER), HeartRateBaseSwimIntervalSummary() { - setIntervalAverageHeartRate(ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALAVERAGEHEARTRATE_INVALID); - setIntervalMaximumHeartRate(ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALMAXIMUMHEARTRATE_INVALID); - setSessionAverageHeartRate(ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_SESSIONAVERAGEHEARTRATE_INVALID); -} - -void HeartRateSwimIntervalSummaryMsg::setIntervalAverageHeartRate(uint8_t intervalAverage) { - set8BitValue(intervalAverage, - ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALAVERAGEHEARTRATE_BYTE); -} - -void HeartRateSwimIntervalSummaryMsg::setIntervalMaximumHeartRate(uint8_t intervalMaximum) { - set8BitValue(intervalMaximum, - ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALMAXIMUMHEARTRATE_BYTE); -} - -void HeartRateSwimIntervalSummaryMsg::setSessionAverageHeartRate(uint8_t sessionAverage) { - set8BitValue(sessionAverage, - ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_SESSIONAVERAGEHEARTRATE_BYTE); -} diff --git a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateSwimIntervalSummaryMsg.h b/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateSwimIntervalSummaryMsg.h deleted file mode 100644 index 467049d..0000000 --- a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateSwimIntervalSummaryMsg.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef ANTPLUS_HEARTRATESWIMINTERVALSUMMARYMSG_h -#define ANTPLUS_HEARTRATESWIMINTERVALSUMMARYMSG_h - -#include -#include - -class HeartRateSwimIntervalSummaryMsg : public HeartRateBaseMainDataPageMsg, public HeartRateBaseSwimIntervalSummary { -public: - HeartRateSwimIntervalSummaryMsg(); - void setIntervalAverageHeartRate(uint8_t intervalAverage); - void setIntervalMaximumHeartRate(uint8_t intervalMaximum); - void setSessionAverageHeartRate(uint8_t sessionAverage); -}; - -#endif // ANTPLUS_HEARTRATESWIMINTERVALSUMMARYMSG_h diff --git a/src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.cpp b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp similarity index 80% rename from src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.cpp rename to src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp index 0efa5b2..607c47c 100644 --- a/src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.cpp +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp @@ -1,8 +1,8 @@ -#include +#include #include #include -#include -#include + +#define DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE ProfileHeartRateDisplay::ProfileHeartRateDisplay() : BaseSlaveProfile() { setChannelConfig(); @@ -29,28 +29,28 @@ bool ProfileHeartRateDisplay::handleDataPage(HeartRateBaseMainDataPage& dp) { bool called = false; switch (dataPage) { - case ANTPLUS_HEARTRATE_DATAPAGE_DEFAULT_NUMBER: + case HEARTRATE_DEFAULT_NUMBER: called = handleDefault(dp); break; - case ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER: + case HEARTRATE_CUMULATIVEOPERATINGTIME_NUMBER: called = handleCumulativeOperatingTime(dp); break; - case ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER: + case HEARTRATE_MANUFACTURERINFORMATION_NUMBER: called = handleManufacturerInformation(dp); break; - case ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_NUMBER: + case HEARTRATE_PRODUCTINFORMATION_NUMBER: called = handleProductInformation(dp); break; - case ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_NUMBER: + case HEARTRATE_PREVIOUSHEARTBEAT_NUMBER: called = handlePreviousHeartBeat(dp); break; - case ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_NUMBER: + case HEARTRATE_SWIMINTERVALSUMMARY_NUMBER: called = handleSwimIntervalSummary(dp); break; - case ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_NUMBER: + case HEARTRATE_BATTERYSTATUS_NUMBER: called = handleBatteryStatus(dp); break; - case ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_NUMBER: + case HEARTRATE_CAPABILITIES_NUMBER: called = handleCapabilities(dp); break; } @@ -68,10 +68,10 @@ void ProfileHeartRateDisplay::onAcknowledgedData(AcknowledgedData& msg) { void ProfileHeartRateDisplay::setChannelConfig() { - setChannelType(ANTPLUS_HEARTRATE_DISPLAY_CHANNELTYPE); + setChannelType(DISPLAY_CHANNELTYPE); setDeviceType(ANTPLUS_HEARTRATE_DEVICETYPE); - setChannelPeriod(ANTPLUS_HEARTRATE_CHANNELPERIOD); - setSearchTimeout(ANTPLUS_HEARTRATE_SEARCHTIMEOUT); + setChannelPeriod(HEARTRATE_CHANNELPERIOD); + setSearchTimeout(HEARTRATE_SEARCHTIMEOUT); } bool ProfileHeartRateDisplay::handleBatteryStatus(HeartRateBaseMainDataPage& dataPage) { diff --git a/src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.h b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.h similarity index 84% rename from src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.h rename to src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.h index 7d8b8e0..b926b00 100644 --- a/src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.h +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.h @@ -2,16 +2,14 @@ #define ANTPLUS_PROFILEHEARTRATEDISPLAY_h #include -#include +#include #include -#include "ANT.h" - class ProfileHeartRateDisplay : public BaseSlaveProfile { public: ProfileHeartRateDisplay(); - ProfileHeartRateDisplay(uint16_t deviceNumber); - ProfileHeartRateDisplay(uint16_t deviceNumber, uint8_t transmissionType); + explicit ProfileHeartRateDisplay(uint16_t deviceNumber); + explicit ProfileHeartRateDisplay(uint16_t deviceNumber, uint8_t transmissionType); void onHeartRateBatteryStatus(void (*func)(HeartRateBatteryStatus&, uintptr_t), uintptr_t data = 0) { _onHeartRateBatteryStatus.set(func, data); } void onHeartRateCapabilities(void (*func)(HeartRateCapabilities&, uintptr_t), uintptr_t data = 0) { _onHeartRateCapabilities.set(func, data); } void onHeartRateCumulativeOperatingTime(void (*func)(HeartRateCumulativeOperatingTime&, uintptr_t), uintptr_t data = 0) { _onHeartRateCumulativeOperatingTime.set(func, data); } @@ -36,14 +34,14 @@ class ProfileHeartRateDisplay : public BaseSlaveProfile { bool handlePreviousHeartBeat(HeartRateBaseMainDataPage& dataPage); bool handleProductInformation(HeartRateBaseMainDataPage& dataPage); bool handleSwimIntervalSummary(HeartRateBaseMainDataPage& dataPage); - AntCallback _onHeartRateBatteryStatus; - AntCallback _onHeartRateCapabilities; - AntCallback _onHeartRateCumulativeOperatingTime; - AntCallback _onHeartRateDefault; - AntCallback _onHeartRateManufacturerInformation; - AntCallback _onHeartRatePreviousHeartBeat; - AntCallback _onHeartRateProductInformation; - AntCallback _onHeartRateSwimIntervalSummary; + AntCallback _onHeartRateBatteryStatus = { .func = NULL }; + AntCallback _onHeartRateCapabilities = { .func = NULL }; + AntCallback _onHeartRateCumulativeOperatingTime = { .func = NULL }; + AntCallback _onHeartRateDefault = { .func = NULL }; + AntCallback _onHeartRateManufacturerInformation = { .func = NULL }; + AntCallback _onHeartRatePreviousHeartBeat = { .func = NULL }; + AntCallback _onHeartRateProductInformation = { .func = NULL }; + AntCallback _onHeartRateSwimIntervalSummary = { .func = NULL }; }; #endif // ANTPLUS_PROFILEHEARTRATEDISPLAY_h diff --git a/src/Profiles/HeartRate/Monitor/ANTPLUS_ProfileHeartRateMonitor.cpp b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp similarity index 58% rename from src/Profiles/HeartRate/Monitor/ANTPLUS_ProfileHeartRateMonitor.cpp rename to src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp index 875450e..a921516 100644 --- a/src/Profiles/HeartRate/Monitor/ANTPLUS_ProfileHeartRateMonitor.cpp +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp @@ -1,23 +1,21 @@ -#include +#include #include #include -#include +#include +#include -ProfileHeartRateMonitor::ProfileHeartRateMonitor( - uint16_t deviceNumber, - uint8_t transmissionType) : - BaseMasterProfile(deviceNumber, transmissionType), - _nextBackgroundPage(ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER), - _flags(0) { - setChannelConfig(); -} +#define MONITOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT +#define MONITOR_TRANSMISSIONTYPE TRANSMISSION_TYPE_INDEPENDENT +// TODO switch from flags to checking if callbacks are set ProfileHeartRateMonitor::ProfileHeartRateMonitor( uint16_t deviceNumber, uint8_t transmissionType, uint32_t flags) : - BaseMasterProfile(deviceNumber, transmissionType), - _nextBackgroundPage(ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER), + BaseMasterProfile(deviceNumber, + ANTPLUS_TRANSMISSION_SET_LSN( + transmissionType, MONITOR_TRANSMISSIONTYPE)), + _nextBackgroundPage(HEARTRATE_MANUFACTURERINFORMATION_NUMBER), _flags(flags) { setChannelConfig(); } @@ -63,15 +61,16 @@ void ProfileHeartRateMonitor::onAcknowledgedData(AcknowledgedData& msg) { void ProfileHeartRateMonitor::transmitNextDataPage() { if (isRequestedPagePending()) { transmitRequestedDataPage(); + return; + } + + if (_patternStep++ < 64) { + transmitPrimaryDataPage(); } else { - if (_patternStep++ < 64) { - transmitPrimaryDataPage(); - } else { - transmitBackgroundDataPage(); - if (_patternStep > 67) { - _nextBackgroundPage = getNextBackgroundPage(_nextBackgroundPage); - _patternStep = 0; - } + transmitBackgroundDataPage(); + if (_patternStep > 67) { + _nextBackgroundPage = getNextBackgroundPage(_nextBackgroundPage); + _patternStep = 0; } } } @@ -79,46 +78,50 @@ void ProfileHeartRateMonitor::transmitNextDataPage() { void ProfileHeartRateMonitor::transmitPrimaryDataPage() { if (_sportsMode == ANTPLUS_COMMON_DATAPAGE_MODESETTINGS_SPORTSMODE_SWIMMING) { transmitHeartRateSwimIntervalSummaryMsg(); + return; + } + + if (_createHeartRatePreviousHeartBeatMsg.func) { + transmitHeartRatePreviousHeartBeatMsg(); } else { - if (_flags & ANTPLUS_HEARTRATE_FLAGS_PREVIOUSHEARTBEAT_SUPPORTED) { - transmitHeartRatePreviousHeartBeatMsg(); - } else { - transmitHeartRateDefaultMsg(); - } + transmitHeartRateDefaultMsg(); } } void ProfileHeartRateMonitor::transmitBackgroundDataPage() { switch (_nextBackgroundPage) { - case ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER: + case HEARTRATE_CUMULATIVEOPERATINGTIME_NUMBER: transmitHeartRateCumulativeOperatingTimeMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER: + case HEARTRATE_MANUFACTURERINFORMATION_NUMBER: transmitHeartRateManufacturerInformationMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_NUMBER: + case HEARTRATE_PRODUCTINFORMATION_NUMBER: transmitHeartRateProductInformationMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_NUMBER: + case HEARTRATE_BATTERYSTATUS_NUMBER: transmitHeartRateBatteryStatusMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_NUMBER: + case HEARTRATE_CAPABILITIES_NUMBER: transmitHeartRateCapabilitiesMsg(); break; } } uint8_t ProfileHeartRateMonitor::getNextBackgroundPage(uint8_t currentPage) { - if ((currentPage < ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER) && (_flags & ANTPLUS_HEARTRATE_FLAGS_CUMULATIVEOPERATINGTIME_SUPPORTED)) { - return ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER; - } else if (currentPage < ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER) { - return ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER; - } else if (currentPage < ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_NUMBER) { - return ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_NUMBER; - } else if ((currentPage < ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_NUMBER) && (_flags & ANTPLUS_HEARTRATE_FLAGS_EXTENTED_FEATURES)) { - return ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_NUMBER; - } else if ((currentPage < ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_NUMBER) && (_flags & ANTPLUS_HEARTRATE_FLAGS_BATTERYSTATUS_SUPPORTED)) { - return ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_NUMBER; + if ((currentPage < HEARTRATE_CUMULATIVEOPERATINGTIME_NUMBER) && + (_createHeartRateCumulativeOperatingTimeMsg.func)) { + return HEARTRATE_CUMULATIVEOPERATINGTIME_NUMBER; + } else if (currentPage < HEARTRATE_MANUFACTURERINFORMATION_NUMBER) { + return HEARTRATE_MANUFACTURERINFORMATION_NUMBER; + } else if (currentPage < HEARTRATE_PRODUCTINFORMATION_NUMBER) { + return HEARTRATE_PRODUCTINFORMATION_NUMBER; + } else if ((currentPage < HEARTRATE_CAPABILITIES_NUMBER) && + (_flags & ANTPLUS_HEARTRATE_FLAGS_EXTENTED_FEATURES)) { + return HEARTRATE_CAPABILITIES_NUMBER; + } else if ((currentPage < HEARTRATE_BATTERYSTATUS_NUMBER) && + (_createHeartRateBatteryStatusMsg.func)) { + return HEARTRATE_BATTERYSTATUS_NUMBER; } else { // Reached end of the loop, start again return getNextBackgroundPage(0); @@ -128,28 +131,28 @@ uint8_t ProfileHeartRateMonitor::getNextBackgroundPage(uint8_t currentPage) { void ProfileHeartRateMonitor::transmitRequestedDataPage() { uint8_t requestedPage = getRequestedPage(); switch (requestedPage) { - case ANTPLUS_HEARTRATE_DATAPAGE_DEFAULT_NUMBER: + case HEARTRATE_DEFAULT_NUMBER: transmitHeartRateDefaultMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER: + case HEARTRATE_CUMULATIVEOPERATINGTIME_NUMBER: transmitHeartRateCumulativeOperatingTimeMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER: + case HEARTRATE_MANUFACTURERINFORMATION_NUMBER: transmitHeartRateManufacturerInformationMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_NUMBER: + case HEARTRATE_PRODUCTINFORMATION_NUMBER: transmitHeartRateProductInformationMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_NUMBER: + case HEARTRATE_PREVIOUSHEARTBEAT_NUMBER: transmitHeartRatePreviousHeartBeatMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_NUMBER: + case HEARTRATE_SWIMINTERVALSUMMARY_NUMBER: transmitHeartRateSwimIntervalSummaryMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_NUMBER: + case HEARTRATE_CAPABILITIES_NUMBER: transmitHeartRateCapabilitiesMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_NUMBER: + case HEARTRATE_BATTERYSTATUS_NUMBER: transmitHeartRateBatteryStatusMsg(); break; } @@ -213,20 +216,22 @@ void ProfileHeartRateMonitor::transmitHeartRateMsg(HeartRateBaseMainDataPageMsg& bool ProfileHeartRateMonitor::isDataPageValid(uint8_t dataPage) { switch (dataPage) { - case ANTPLUS_HEARTRATE_DATAPAGE_DEFAULT_NUMBER: - return !(_flags & ANTPLUS_HEARTRATE_FLAGS_PREVIOUSHEARTBEAT_SUPPORTED); - case ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER: - return _flags & ANTPLUS_HEARTRATE_FLAGS_CUMULATIVEOPERATINGTIME_SUPPORTED; - case ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER: - case ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_NUMBER: + case HEARTRATE_DEFAULT_NUMBER: + return (bool)(_createHeartRateDefaultMsg.func); + case HEARTRATE_CUMULATIVEOPERATINGTIME_NUMBER: + return (bool)(_createHeartRateCumulativeOperatingTimeMsg.func); + case HEARTRATE_MANUFACTURERINFORMATION_NUMBER: + case HEARTRATE_PRODUCTINFORMATION_NUMBER: return true; - case ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_NUMBER: - return _flags & ANTPLUS_HEARTRATE_FLAGS_PREVIOUSHEARTBEAT_SUPPORTED; - case ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_NUMBER: - case ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_NUMBER: + case HEARTRATE_PREVIOUSHEARTBEAT_NUMBER: + return (bool)(_createHeartRatePreviousHeartBeatMsg.func); + case HEARTRATE_CAPABILITIES_NUMBER: return _flags & ANTPLUS_HEARTRATE_FLAGS_EXTENTED_FEATURES; - case ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_NUMBER: - return _flags & ANTPLUS_HEARTRATE_FLAGS_BATTERYSTATUS_SUPPORTED; + case HEARTRATE_SWIMINTERVALSUMMARY_NUMBER: + return _flags & ANTPLUS_HEARTRATE_FLAGS_EXTENTED_FEATURES && + (bool)(_createHeartRateSwimIntervalSummaryMsg.func); + case HEARTRATE_BATTERYSTATUS_NUMBER: + return (bool)(_createHeartRateBatteryStatusMsg.func); default: return false; } @@ -243,8 +248,8 @@ bool ProfileHeartRateMonitor::handleRequestDataPage(HeartRateBaseMainDataPage& d } void ProfileHeartRateMonitor::setChannelConfig() { - setChannelType(ANTPLUS_HEARTRATE_MONITOR_CHANNELTYPE); + setChannelType(MONITOR_CHANNELTYPE); setDeviceType(ANTPLUS_HEARTRATE_DEVICETYPE); - setChannelPeriod(ANTPLUS_HEARTRATE_CHANNELPERIOD); - setSearchTimeout(ANTPLUS_HEARTRATE_SEARCHTIMEOUT); + setChannelPeriod(HEARTRATE_CHANNELPERIOD); + setSearchTimeout(HEARTRATE_SEARCHTIMEOUT); } diff --git a/src/Profiles/HeartRate/Monitor/ANTPLUS_ProfileHeartRateMonitor.h b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.h similarity index 89% rename from src/Profiles/HeartRate/Monitor/ANTPLUS_ProfileHeartRateMonitor.h rename to src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.h index bb2516a..d372575 100644 --- a/src/Profiles/HeartRate/Monitor/ANTPLUS_ProfileHeartRateMonitor.h +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.h @@ -2,14 +2,13 @@ #define ANTPLUS_PROFILEHEARTRATEMONITOR_h #include -#include +#include #include #include class ProfileHeartRateMonitor : public BaseMasterProfile { public: - ProfileHeartRateMonitor(uint16_t deviceNumber, uint8_t transmissionType); - ProfileHeartRateMonitor(uint16_t deviceNumber, uint8_t transmissionType, uint32_t flags); + explicit ProfileHeartRateMonitor(uint16_t deviceNumber, uint8_t transmissionType = 0, uint32_t flags = 0); /** * Register callback to populate default data messages (Datapage 0) */ @@ -80,16 +79,16 @@ class ProfileHeartRateMonitor : public BaseMasterProfile { bool handleModeSettings(HeartRateBaseMainDataPage& dataPage); bool handleRequestDataPage(HeartRateBaseMainDataPage& dataPage); uint8_t getNextBackgroundPage(uint8_t currentPage); - AntCallback _onRequestDataPage; - AntCallback _onModeSettings; - AntCallback _createHeartRateDefaultMsg; - AntCallback _createHeartRateCumulativeOperatingTimeMsg; - AntCallback _createHeartRateManufacturerInformationMsg; - AntCallback _createHeartRateProductInformationMsg; - AntCallback _createHeartRatePreviousHeartBeatMsg; - AntCallback _createHeartRateSwimIntervalSummaryMsg; - AntCallback _createHeartRateCapabilitiesMsg; - AntCallback _createHeartRateBatteryStatusMsg; + AntCallback _onRequestDataPage = { .func = NULL }; + AntCallback _onModeSettings = { .func = NULL }; + AntCallback _createHeartRateDefaultMsg = { .func = NULL }; + AntCallback _createHeartRateCumulativeOperatingTimeMsg = { .func = NULL }; + AntCallback _createHeartRateManufacturerInformationMsg = { .func = NULL }; + AntCallback _createHeartRateProductInformationMsg = { .func = NULL }; + AntCallback _createHeartRatePreviousHeartBeatMsg = { .func = NULL }; + AntCallback _createHeartRateSwimIntervalSummaryMsg = { .func = NULL }; + AntCallback _createHeartRateCapabilitiesMsg = { .func = NULL }; + AntCallback _createHeartRateBatteryStatusMsg = { .func = NULL }; uint8_t _nextBackgroundPage; uint8_t _sportsMode = ANTPLUS_COMMON_DATAPAGE_MODESETTINGS_SPORTSMODE_RUNNING; uint32_t _flags = 0; diff --git a/src/Profiles/Lev/ANTPLUS_LevDataPages.h b/src/Profiles/Lev/ANTPLUS_LevDataPages.h new file mode 100644 index 0000000..055fe99 --- /dev/null +++ b/src/Profiles/Lev/ANTPLUS_LevDataPages.h @@ -0,0 +1,12 @@ +#ifndef ANTPLUS_PROFILELEVDATAPAGES_h +#define ANTPLUS_PROFILELEVDATAPAGES_h + +#include +#include +#include +#include +#include +#include +#include + +#endif // ANTPLUS_PROFILELEVDATAPAGES_h diff --git a/src/Profiles/Lev/ANTPLUS_LevDefines.h b/src/Profiles/Lev/ANTPLUS_LevDefines.h index 66af537..b32f057 100644 --- a/src/Profiles/Lev/ANTPLUS_LevDefines.h +++ b/src/Profiles/Lev/ANTPLUS_LevDefines.h @@ -3,6 +3,9 @@ #define ANTPLUS_LEV_DEVICETYPE 20 + +#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_NUMBER 1 + #define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_TEMPERATURESTATE_STATE_UNKNOWN 0 #define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_TEMPERATURESTATE_STATE_COLD 1 #define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_TEMPERATURESTATE_STATE_COLDWARM 2 @@ -32,15 +35,24 @@ #define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_ERRORMESSAGE_OVERHEATING 4 #define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_ERRORMESSAGE_MANUFACTURERSPECIFIC 16 + +#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION2_NUMBER 3 + #define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION2_PERCENTASSIST_UNKNOWN 0xFF +#define ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_NUMBER 2 + #define ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_REMAININGRANGE_UNKNOWN 0 +#define ANTPLUS_LEV_DATAPAGE_ALTSPEEDDISTANCEINFORMATION_NUMBER 34 + #define ANTPLUS_LEV_DATAPAGE_ALTSPEEDDISTANCEINFORMATION_FUELCONSUMPTION_UNKNOWN 0 +#define ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_NUMBER 4 + #define ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_CHARGINGCYCLECOUNT_UNKNOWN 0 #define ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_FUELCONSUMPTION_UNKNOWN 0 @@ -50,6 +62,10 @@ #define ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_DISTANCEONCURRENTCHARGE_UNKNOWN 0 +#define ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_NUMBER 5 + #define ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_WHEELCIRCUMFERENCE_UNKOWN 0 +#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_NUMBER 16 + #endif // ANTPLUS_BICYCLESPEEDPROFILEDEFINES_h diff --git a/src/Profiles/Lev/ANTPLUS_LevPrivateDefines.h b/src/Profiles/Lev/ANTPLUS_LevPrivateDefines.h index 5b20072..577f9b9 100644 --- a/src/Profiles/Lev/ANTPLUS_LevPrivateDefines.h +++ b/src/Profiles/Lev/ANTPLUS_LevPrivateDefines.h @@ -2,129 +2,8 @@ #define ANTPLUS_LEVPROFILEPRIVATEDEFINES_h /* Channel Config */ -#define ANTPLUS_LEV_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE -#define ANTPLUS_LEV_CHANNELPERIOD 8192 +#define LEV_CHANNELPERIOD 8192 // 30 / 2.5 = 12 -#define ANTPLUS_LEV_SEARCHTIMEOUT 12 - -// Base page */ -#define ANTPLUS_LEV_DATAPAGEBASE_DATAPAGE_BYTE 0x00 - -/* Base Speed & System Information */ -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_TRAVELMODESTATE_BYTE 2 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_TRAVELMODESTATE_CURRENTREGENERATIVELEVEL_MASK 0x7 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_TRAVELMODESTATE_CURRENTASSISTLEVEL_SHIFT 3 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_TRAVELMODESTATE_CURRENTASSISTLEVEL_MASK 0x38 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_SYSTEMSTATE_BYTE 3 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_GEARSTATE_BYTE 4 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_GEARSTATE_CURRENTFRONTGEAR_MASK 0x3 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_GEARSTATE_CURRENTREARGEAR_SHIFT 2 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_GEARSTATE_CURRENTREARGEAR_MASK 0x3C -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_GEARSTATE_MANUALAUTO_SHIFT 6 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_GEARSTATE_MANUALAUTO_MASK 0x40 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_GEARSTATE_GEAREXIST_SHIFT 7 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_GEARSTATE_GEAREXIST_MASK 0x80 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_LEVSPEED_LSB_BYTE 6 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_LEVSPEED_MSB_BYTE 7 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_LEVSPEED_MSB_SHIFT 8 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_LEVSPEED_MSB_MASK 0x0F - -/* Base Speed & Distance Information */ -#define ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_ODOMETER_LSB_BYTE 1 -#define ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_ODOMETER_MID_BYTE 2 -#define ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_ODOMETER_MID_SHIFT 8 -#define ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_ODOMETER_MSB_BYTE 3 -#define ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_ODOMETER_MSB_SHIFT 16 -#define ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_LEVSPEED_LSB_BYTE 6 -#define ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_LEVSPEED_MSB_BYTE 7 -#define ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_LEVSPEED_MSB_SHIFT 8 -#define ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_LEVSPEED_MSB_MASK 0xF - -/* Speed & System Information 1 */ -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_NUMBER 1 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_TEMPERATURESTATE_BYTE 1 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_TEMPERATURESTATE_BATTERYTEMPERATURE_MASK 0x7 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_TEMPERATURESTATE_BATTERYTEMPERATUREALERT_SHIFT 3 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_TEMPERATURESTATE_BATTERYTEMPERATUREALERT_MASK 0x8 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_TEMPERATURESTATE_MOTORTEMPERATURE_SHIFT 4 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_TEMPERATURESTATE_MOTORTEMPERATURE_MASK 0x70 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_TEMPERATURESTATE_MOTORTEMPERATUREALERT_SHIFT 7 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_TEMPERATURESTATE_MOTORTEMPERATUREALERT_MASK 0x80 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_ERRORMESSAGE_BYTE 5 - -/* Speed & Distance Information */ -#define ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_NUMBER 2 -#define ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_REMAININGRANGE_LSB_BYTE 4 -#define ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_REMAININGRANGE_MSB_BYTE 5 -#define ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_REMAININGRANGE_MSB_SHIFT 8 -#define ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_REMAININGRANGE_MSB_MASK 0xF - -/* Alternative Speed & Distance Information */ -#define ANTPLUS_LEV_DATAPAGE_ALTSPEEDDISTANCEINFORMATION_NUMBER 34 -#define ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_FUELCONSUMPTION_LSB_BYTE 4 -#define ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_FUELCONSUMPTION_MSB_BYTE 5 -#define ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_FUELCONSUMPTION_MSB_SHIFT 8 -#define ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_FUELCONSUMPTION_MSB_MASK 0xF - -/* Speed & System Information 2 */ -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION2_NUMBER 3 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION2_BATTERYSOC_BYTE 1 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION2_BATTERYSOC_STATEOFCHARGE_MASK 0x7F -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION2_BATTERYSOC_BATTERYEMPTY_SHIFT 7 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION2_BATTERYSOC_BATTERYEMPTY_MASK 0x80 -#define ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION2_PERCENTASSIST_BYTE 5 - -/* Battery Information */ -#define ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_NUMBER 4 -#define ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_CHARGINGCYCLECOUNT_LSB_BYTE 2 -#define ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_CHARGINGCYCLECOUNT_MSB_BYTE 3 -#define ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_CHARGINGCYCLECOUNT_MSB_MASK 0xF -#define ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_CHARGINGCYCLECOUNT_MSB_SHIFT 8 -#define ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_FUELCONSUMPTION_LSB_BYTE 4 -#define ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_FUELCONSUMPTION_MSB_BYTE 3 -#define ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_FUELCONSUMPTION_MSB_MASK 0xF0 -#define ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_FUELCONSUMPTION_MSB_SHIFT 4 -#define ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_BATTERYVOLTAGE_BYTE 5 -#define ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_DISTANCEONCURRENTCHARGE_LSB_BYTE 6 -#define ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_DISTANCEONCURRENTCHARGE_MSB_BYTE 7 -#define ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_DISTANCEONCURRENTCHARGE_MSB_SHIFT 8 - -/* Capabilities */ -#define ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_NUMBER 5 -#define ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_TRAVELMODESSUPPORTED_BYTE 2 -#define ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_TRAVELMODESSUPPORTED_NUMBERASSISTMODES_MASK 0x38 -#define ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_TRAVELMODESSUPPORTED_NUMBERASSISTMODES_SHIFT 3 -#define ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_TRAVELMODESSUPPORTED_NUMBERREGENERATIVEMODES_MASK 0x7 -#define ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_WHEELCIRCUMFERENCE_LSB_BYTE 3 -#define ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_WHEELCIRCUMFERENCE_MSB_BYTE 4 -#define ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_WHEELCIRCUMFERENCE_MSB_MASK 0xF -#define ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_WHEELCIRCUMFERENCE_MSB_SHIFT 8 - -/* Display Data */ -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_NUMBER 16 -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_WHEELCIRCUMFERENCE_LSB_BYTE 1 -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_WHEELCIRCUMFERENCE_MSB_BYTE 2 -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_WHEELCIRCUMFERENCE_MASK 0xFFF -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_RESERVED1_BYTE 2 -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_RESERVED1_VALUE 0xF0 -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_RESERVED2_BYTE 5 -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_RESERVED2_VALUE 0 -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTASSISTLEVEL_BYTE 3 -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTASSISTLEVEL_MASK 0x38 -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTASSISTLEVEL_SHIFT 3 -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTREGENERATIVELEVEL_BYTE 3 -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTREGENERATIVELEVEL_MASK 0x7 -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTREARGEAR_LSB_BYTE 4 -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTREARGEAR_MSB_BYTE 5 -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTREARGEAR_MASK 0x3C0 -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTREARGEAR_SHIFT 6 -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTFRONTGEAR_BYTE 4 -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTFRONTGEAR_MASK 0x30 -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTFRONTGEAR_SHIFT 4 -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTLIGHTMODE_BYTE 4 -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTLIGHTMODE_MASK 0xF -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_MANUFACTURERID_LSB_BYTE 6 -#define ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_MANUFACTURERID_MSB_BYTE 7 - +#define LEV_SEARCHTIMEOUT 12 #endif // ANTPLUS_BICYCLESPEEDPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/Lev/ANTPLUS_LevProfile.h b/src/Profiles/Lev/ANTPLUS_LevProfile.h index 7da71fc..a94ed73 100644 --- a/src/Profiles/Lev/ANTPLUS_LevProfile.h +++ b/src/Profiles/Lev/ANTPLUS_LevProfile.h @@ -5,9 +5,9 @@ #include // Datapages -#include +#include // Profile Classes -#include +#include #endif // ANTPLUS_LEVPROFILE_h diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.cpp new file mode 100644 index 0000000..2a17734 --- /dev/null +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.cpp @@ -0,0 +1,35 @@ +#include +#include + +#define FUELCONSUMPTION_LSB_BYTE 4 +#define FUELCONSUMPTION_MSB_BYTE 5 +#define FUELCONSUMPTION_MASK 0x0FFF + +/* Alt Speed and Distance */ +template +LevBaseAltSpeedDistanceInformation::LevBaseAltSpeedDistanceInformation() : + CoreDataPage() {} + +template +uint16_t LevBaseAltSpeedDistanceInformation::getFuelConsumption() // in Wh/km +{ + return this->get16BitValue(FUELCONSUMPTION_LSB_BYTE, + FUELCONSUMPTION_MSB_BYTE, FUELCONSUMPTION_MASK); +} + +template class LevBaseAltSpeedDistanceInformation; +template class LevBaseAltSpeedDistanceInformation; + +LevAltSpeedDistanceInformation::LevAltSpeedDistanceInformation(AntRxDataResponse& dp) : + LevBaseSpeedDistanceInformation(dp), + LevBaseAltSpeedDistanceInformation() {} + +LevAltSpeedDistanceInformationMsg::LevAltSpeedDistanceInformationMsg() : + LevBaseSpeedDistanceInformationMsg(ANTPLUS_LEV_DATAPAGE_ALTSPEEDDISTANCEINFORMATION_NUMBER), + LevBaseAltSpeedDistanceInformation() {} + +void LevAltSpeedDistanceInformationMsg::setFuelConsumption(uint16_t consumption) // in Wh/km +{ + set16BitValue(consumption, FUELCONSUMPTION_LSB_BYTE, + FUELCONSUMPTION_MSB_BYTE, FUELCONSUMPTION_MASK); +} diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.h new file mode 100644 index 0000000..7d8167d --- /dev/null +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.h @@ -0,0 +1,24 @@ +#ifndef ANTPLUS_LEVALTSPEEDDISTANCEINFORMATION_h +#define ANTPLUS_LEVALTSPEEDDISTANCEINFORMATION_h + +#include + +template +class LevBaseAltSpeedDistanceInformation : virtual public CoreDataPage { +public: + LevBaseAltSpeedDistanceInformation(); + uint16_t getFuelConsumption(); // in Wh/km +}; + +class LevAltSpeedDistanceInformation : public LevBaseSpeedDistanceInformation, public LevBaseAltSpeedDistanceInformation { +public: + explicit LevAltSpeedDistanceInformation(AntRxDataResponse& dp); +}; + +class LevAltSpeedDistanceInformationMsg : public LevBaseSpeedDistanceInformationMsg, public LevBaseAltSpeedDistanceInformation { +public: + LevAltSpeedDistanceInformationMsg(); + void setFuelConsumption(uint16_t consumption); // in Wh/km +}; + +#endif // ANTPLUS_LEVALTSPEEDDISTANCEINFORMATION_h diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.cpp new file mode 100644 index 0000000..d4ae47b --- /dev/null +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.cpp @@ -0,0 +1,15 @@ +#include +#include + +LevBaseMainDataPage::LevBaseMainDataPage(AntRxDataResponse& dp) : + BaseDataPage(dp) {} + +template +LevBaseMainDataPageMsg::LevBaseMainDataPageMsg(uint8_t dataPageNumber) : + BaseDataPageMsg() { + this->setDataBuffer(_buffer); + this->set8BitValue(dataPageNumber, ANTPLUS_DEFAULT_DATAPAGE_BYTE); +} + +template class LevBaseMainDataPageMsg; +template class LevBaseMainDataPageMsg; diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.h new file mode 100644 index 0000000..b2c1ecb --- /dev/null +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.h @@ -0,0 +1,20 @@ +#ifndef ANTPLUS_LEVBASEMAINDATAPAGE_h +#define ANTPLUS_LEVBASEMAINDATAPAGE_h + +#include +#include + +class LevBaseMainDataPage : public BaseDataPage { +public: + explicit LevBaseMainDataPage(AntRxDataResponse& dp); +}; + +template +class LevBaseMainDataPageMsg : public BaseDataPageMsg { +public: + explicit LevBaseMainDataPageMsg(uint8_t dataPageNumber); +protected: + uint8_t _buffer[MESSAGE_SIZE] = {0}; +}; + +#endif // ANTPLUS_LEVBASEMAINDATAPAGE_h diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.cpp new file mode 100644 index 0000000..63a23b9 --- /dev/null +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.cpp @@ -0,0 +1,43 @@ +#include +#include + +#define ODOMETER_LSB_BYTE 1 +#define ODOMETER_MSB_BYTE 3 +#define LEVSPEED_LSB_BYTE 6 +#define LEVSPEED_MSB_BYTE 7 +#define LEVSPEED_MASK 0x0FFF + +/* Speed and Distance */ +template +LevCoreSpeedDistanceInformation::LevCoreSpeedDistanceInformation() : + CoreDataPage() {} + +template +uint32_t LevCoreSpeedDistanceInformation::getOdometer() { // in km + return this->get24BitValue(ODOMETER_LSB_BYTE, ODOMETER_MSB_BYTE); +} + +template +uint16_t LevCoreSpeedDistanceInformation::getLevSpeed() { // in 1/10 km/h + return this->get16BitValue(LEVSPEED_LSB_BYTE, LEVSPEED_MSB_BYTE, + LEVSPEED_MASK); +} + +template class LevCoreSpeedDistanceInformation; +template class LevCoreSpeedDistanceInformation; + +LevBaseSpeedDistanceInformation::LevBaseSpeedDistanceInformation(AntRxDataResponse& dp) : + LevBaseMainDataPage(dp), + LevCoreSpeedDistanceInformation() {} + +LevBaseSpeedDistanceInformationMsg::LevBaseSpeedDistanceInformationMsg(uint8_t dataPageNumber) : + LevBaseMainDataPageMsg(dataPageNumber), + LevCoreSpeedDistanceInformation() {} + +void LevBaseSpeedDistanceInformationMsg::setOdometer(uint32_t odometer) { + set24BitValue(odometer, ODOMETER_LSB_BYTE, ODOMETER_MSB_BYTE); +} + +void LevBaseSpeedDistanceInformationMsg::setLevSpeed(uint16_t speed) { + set16BitValue(speed, LEVSPEED_LSB_BYTE, LEVSPEED_MSB_BYTE, LEVSPEED_MASK); +} diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.h new file mode 100644 index 0000000..72c6d7a --- /dev/null +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.h @@ -0,0 +1,26 @@ +#ifndef ANTPLUS_LEVBASESPEEDDISTANCEINFORMATION_h +#define ANTPLUS_LEVBASESPEEDDISTANCEINFORMATION_h + +#include + +template +class LevCoreSpeedDistanceInformation : virtual public CoreDataPage { +public: + LevCoreSpeedDistanceInformation(); + uint32_t getOdometer(); // in km + uint16_t getLevSpeed(); // in 1/10 km/h +}; + +class LevBaseSpeedDistanceInformation : public LevBaseMainDataPage, public LevCoreSpeedDistanceInformation { +public: + explicit LevBaseSpeedDistanceInformation(AntRxDataResponse& dp); +}; + +class LevBaseSpeedDistanceInformationMsg : public LevBaseMainDataPageMsg, public LevCoreSpeedDistanceInformation { +public: + LevBaseSpeedDistanceInformationMsg(uint8_t dataPageNumber); + void setOdometer(uint32_t odometer); // in km + void setLevSpeed(uint16_t speed); // in 1/10 km/h +}; + +#endif // ANTPLUS_LEVBASESPEEDDISTANCEINFORMATION_h diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedSystemInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedSystemInformation.cpp new file mode 100644 index 0000000..e6a6c5a --- /dev/null +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedSystemInformation.cpp @@ -0,0 +1,120 @@ +#include +#include + +#define TRAVELMODESTATE_BYTE 2 +#define TRAVELMODESTATE_CURRENTREGENERATIVELEVEL_MASK 0x7 +#define TRAVELMODESTATE_CURRENTASSISTLEVEL_SHIFT 3 +#define TRAVELMODESTATE_CURRENTASSISTLEVEL_MASK 0x38 +#define SYSTEMSTATE_BYTE 3 +#define GEARSTATE_BYTE 4 +#define GEARSTATE_CURRENTFRONTGEAR_MASK 0x3 +#define GEARSTATE_CURRENTREARGEAR_SHIFT 2 +#define GEARSTATE_CURRENTREARGEAR_MASK 0x3C +#define GEARSTATE_MANUALAUTO_SHIFT 6 +#define GEARSTATE_MANUALAUTO_MASK 0x40 +#define GEARSTATE_GEAREXIST_SHIFT 7 +#define GEARSTATE_GEAREXIST_MASK 0x80 +#define LEVSPEED_LSB_BYTE 6 +#define LEVSPEED_MSB_BYTE 7 +#define LEVSPEED_MASK 0x0FFF + +template +LevCoreSpeedSystemInformation::LevCoreSpeedSystemInformation() : + CoreDataPage() {} + +template +uint8_t LevCoreSpeedSystemInformation::getCurrentRegenerativeLevel() { + return this->get8BitValue(TRAVELMODESTATE_BYTE, + TRAVELMODESTATE_CURRENTREGENERATIVELEVEL_MASK); +} + +template +uint8_t LevCoreSpeedSystemInformation::getCurrentAssistLevel() { + return this->get8BitValue(TRAVELMODESTATE_BYTE, + TRAVELMODESTATE_CURRENTASSISTLEVEL_MASK, + TRAVELMODESTATE_CURRENTASSISTLEVEL_SHIFT); +} + +template +uint8_t LevCoreSpeedSystemInformation::getSystemState() { + return this->get8BitValue(SYSTEMSTATE_BYTE); +} + +template +uint8_t LevCoreSpeedSystemInformation::getCurrentFrontGear() { + return this->get8BitValue(GEARSTATE_BYTE, GEARSTATE_CURRENTFRONTGEAR_MASK); +} + +template +uint8_t LevCoreSpeedSystemInformation::getCurrentRearGear() { + return this->get8BitValue(GEARSTATE_BYTE, GEARSTATE_CURRENTREARGEAR_MASK, + GEARSTATE_CURRENTREARGEAR_SHIFT); +} + +template +uint8_t LevCoreSpeedSystemInformation::getManualAutoState() { + return this->get8BitValue(GEARSTATE_BYTE, GEARSTATE_MANUALAUTO_MASK, + GEARSTATE_MANUALAUTO_SHIFT); +} + +template +uint8_t LevCoreSpeedSystemInformation::getGearExist() { + return this->get8BitValue(GEARSTATE_BYTE, GEARSTATE_GEAREXIST_MASK, + GEARSTATE_GEAREXIST_SHIFT); +} + +template +uint16_t LevCoreSpeedSystemInformation::getSpeed() { // in 1/10 km/h + return this->get16BitValue(LEVSPEED_LSB_BYTE, LEVSPEED_MSB_BYTE, + LEVSPEED_MASK); +} + +template class LevCoreSpeedSystemInformation; +template class LevCoreSpeedSystemInformation; + +LevBaseSpeedSystemInformation::LevBaseSpeedSystemInformation(AntRxDataResponse& dp) : + LevBaseMainDataPage(dp), + LevCoreSpeedSystemInformation() {} + +LevBaseSpeedSystemInformationMsg::LevBaseSpeedSystemInformationMsg(uint8_t dataPageNumber) : + LevBaseMainDataPageMsg(dataPageNumber), + LevCoreSpeedSystemInformation() {} + +void LevBaseSpeedSystemInformationMsg::setCurrentRegenerativeLevel(uint8_t level) { + set8BitValue(level, TRAVELMODESTATE_BYTE, + TRAVELMODESTATE_CURRENTREGENERATIVELEVEL_MASK); +} + +void LevBaseSpeedSystemInformationMsg::setCurrentAssistLevel(uint8_t level) { + set8BitValue(level, TRAVELMODESTATE_BYTE, + TRAVELMODESTATE_CURRENTASSISTLEVEL_MASK, + TRAVELMODESTATE_CURRENTASSISTLEVEL_SHIFT); +} + +void LevBaseSpeedSystemInformationMsg::setSystemState(uint8_t state) { + set8BitValue(state, SYSTEMSTATE_BYTE); +} + +void LevBaseSpeedSystemInformationMsg::setCurrentFrontGear(uint8_t gear) { + set8BitValue(gear, GEARSTATE_BYTE, GEARSTATE_CURRENTFRONTGEAR_MASK); +} + +void LevBaseSpeedSystemInformationMsg::setCurrentRearGear(uint8_t gear) { + set8BitValue(gear, GEARSTATE_BYTE, GEARSTATE_CURRENTREARGEAR_MASK, + GEARSTATE_CURRENTREARGEAR_SHIFT); +} + +void LevBaseSpeedSystemInformationMsg::setManualAutoState(uint8_t state) { + set8BitValue(state, GEARSTATE_BYTE, GEARSTATE_MANUALAUTO_MASK, + GEARSTATE_MANUALAUTO_SHIFT); +} + +void LevBaseSpeedSystemInformationMsg::setGearExist(uint8_t exists) { + set8BitValue(exists, GEARSTATE_BYTE, GEARSTATE_GEAREXIST_MASK, + GEARSTATE_GEAREXIST_SHIFT); +} + +void LevBaseSpeedSystemInformationMsg::setSpeed(uint16_t speed) { // in 1/10 km/h + set16BitValue(speed, LEVSPEED_LSB_BYTE, LEVSPEED_MSB_BYTE, + LEVSPEED_MASK); +} diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedSystemInformation.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedSystemInformation.h new file mode 100644 index 0000000..4b9e330 --- /dev/null +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedSystemInformation.h @@ -0,0 +1,38 @@ +#ifndef ANTPLUS_LEVBASESPEEDSYSTEMINFORMATION_h +#define ANTPLUS_LEVBASESPEEDSYSTEMINFORMATION_h + +#include + +template +class LevCoreSpeedSystemInformation : virtual public CoreDataPage { +public: + LevCoreSpeedSystemInformation(); + uint8_t getCurrentRegenerativeLevel(); + uint8_t getCurrentAssistLevel(); + uint8_t getSystemState(); + uint8_t getCurrentFrontGear(); + uint8_t getCurrentRearGear(); + uint8_t getManualAutoState(); + uint8_t getGearExist(); + uint16_t getSpeed(); // in 1/10 km/h +}; + +class LevBaseSpeedSystemInformation : public LevBaseMainDataPage, public LevCoreSpeedSystemInformation { +public: + explicit LevBaseSpeedSystemInformation(AntRxDataResponse& dp); +}; + +class LevBaseSpeedSystemInformationMsg : public LevBaseMainDataPageMsg, public LevCoreSpeedSystemInformation { +public: + LevBaseSpeedSystemInformationMsg(uint8_t dataPageNumber); + void setCurrentRegenerativeLevel(uint8_t level); + void setCurrentAssistLevel(uint8_t level); + void setSystemState(uint8_t state); + void setCurrentFrontGear(uint8_t gear); + void setCurrentRearGear(uint8_t gear); + void setManualAutoState(uint8_t state); + void setGearExist(uint8_t exists); + void setSpeed(uint16_t speed); // in 1/10 km/h +}; + +#endif // ANTPLUS_LEVBASESPEEDSYSTEMINFORMATION_h diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.cpp new file mode 100644 index 0000000..0dfa56b --- /dev/null +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.cpp @@ -0,0 +1,80 @@ +#include +#include + +#define RESERVED_BYTE 1 +#define RESERVED_VALUE 0xFF +#define CHARGINGCYCLECOUNT_LSB_BYTE 2 +#define CHARGINGCYCLECOUNT_MSB_BYTE 3 +#define CHARGINGCYCLECOUNT_MASK 0x0FFF +#define FUELCONSUMPTION_LSB_BYTE 4 +#define FUELCONSUMPTION_MSN_BYTE 3 +#define FUELCONSUMPTION_MSN_MASK 0xF0 +#define FUELCONSUMPTION_MSN_SHIFT 4 +#define BATTERYVOLTAGE_BYTE 5 +#define DISTANCEONCURRENTCHARGE_LSB_BYTE 6 +#define DISTANCEONCURRENTCHARGE_MSB_BYTE 7 + +template +LevBaseBatteryInformation::LevBaseBatteryInformation() : CoreDataPage() {} + +template +uint16_t LevBaseBatteryInformation::getChargingCycleCount() { + return this->get16BitValue(CHARGINGCYCLECOUNT_LSB_BYTE, + CHARGINGCYCLECOUNT_MSB_BYTE, CHARGINGCYCLECOUNT_MASK); +} + +// NOTE this a bit inverted field which results in the non-sense below +template +uint16_t LevBaseBatteryInformation::getFuelConsumption() { + return this->get8BitValue(FUELCONSUMPTION_LSB_BYTE) | + (((uint16_t)this->get8BitValue(FUELCONSUMPTION_MSN_BYTE, + FUELCONSUMPTION_MSN_MASK, + FUELCONSUMPTION_MSN_SHIFT)) << BITS_IN_BYTE); +} + +template +uint8_t LevBaseBatteryInformation::getBatteryVoltage() { + return this->get8BitValue(BATTERYVOLTAGE_BYTE); +} + +template +uint16_t LevBaseBatteryInformation::getDistanceOnCurrentCharge() { + return this->get16BitValue(DISTANCEONCURRENTCHARGE_LSB_BYTE, + DISTANCEONCURRENTCHARGE_MSB_BYTE); +} + +template class LevBaseBatteryInformation; +template class LevBaseBatteryInformation; + +LevBatteryInformation::LevBatteryInformation(AntRxDataResponse& dp) : + LevBaseMainDataPage(dp), + LevBaseBatteryInformation() {} + +LevBatteryInformationMsg::LevBatteryInformationMsg() : + LevBaseMainDataPageMsg(ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_NUMBER), + LevBaseBatteryInformation() { + set8BitValue(RESERVED_VALUE, RESERVED_BYTE); +} + +void LevBatteryInformationMsg::setChargingCycleCount(uint16_t cycleCount) { + set16BitValue(cycleCount, CHARGINGCYCLECOUNT_LSB_BYTE, + CHARGINGCYCLECOUNT_MSB_BYTE, + CHARGINGCYCLECOUNT_MASK); +} + +// NOTE this a bit inverted field which results in the non-sense below +void LevBatteryInformationMsg::setFuelConsumption(uint16_t consumption) { + set8BitValue(consumption & 0xFF, FUELCONSUMPTION_LSB_BYTE); + set8BitValue(consumption >> BITS_IN_BYTE, FUELCONSUMPTION_MSN_BYTE, + FUELCONSUMPTION_MSN_MASK, + FUELCONSUMPTION_MSN_SHIFT); +} + +void LevBatteryInformationMsg::setBatteryVoltage(uint8_t voltage) { + set8BitValue(voltage, BATTERYVOLTAGE_BYTE); +} + +void LevBatteryInformationMsg::setDistanceOnCurrentCharge(uint16_t distance) { + set16BitValue(distance, DISTANCEONCURRENTCHARGE_LSB_BYTE, + DISTANCEONCURRENTCHARGE_MSB_BYTE); +} diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.h new file mode 100644 index 0000000..a5abce8 --- /dev/null +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.h @@ -0,0 +1,29 @@ +#ifndef ANTPLUS_LEVBATTERYINFORMATION_h +#define ANTPLUS_LEVBATTERYINFORMATION_h + +#include + +template +class LevBaseBatteryInformation : virtual public CoreDataPage { +public: + LevBaseBatteryInformation(); + uint16_t getChargingCycleCount(); + uint16_t getFuelConsumption(); + uint8_t getBatteryVoltage(); + uint16_t getDistanceOnCurrentCharge(); +}; + +class LevBatteryInformation : public LevBaseMainDataPage, public LevBaseBatteryInformation { +public: + explicit LevBatteryInformation(AntRxDataResponse& dp); +}; + +class LevBatteryInformationMsg : public LevBaseMainDataPageMsg, public LevBaseBatteryInformation { +public: + LevBatteryInformationMsg(); + void setChargingCycleCount(uint16_t cycleCount); + void setFuelConsumption(uint16_t consumption); + void setBatteryVoltage(uint8_t voltage); + void setDistanceOnCurrentCharge(uint16_t distance); +}; +#endif // ANTPLUS_LEVBATTERYINFORMATION_h diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.cpp new file mode 100644 index 0000000..ea94b6b --- /dev/null +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.cpp @@ -0,0 +1,58 @@ +#include +#include + +#define TRAVELMODESSUPPORTED_BYTE 2 +#define TRAVELMODESSUPPORTED_NUMBERASSISTMODES_MASK 0x38 +#define TRAVELMODESSUPPORTED_NUMBERASSISTMODES_SHIFT 3 +#define TRAVELMODESSUPPORTED_NUMBERREGENERATIVEMODES_MASK 0x7 +#define WHEELCIRCUMFERENCE_LSB_BYTE 3 +#define WHEELCIRCUMFERENCE_MSB_BYTE 4 +#define WHEELCIRCUMFERENCE_MASK 0xFFF + +template +LevBaseCapabilities::LevBaseCapabilities() : CoreDataPage() {} + +template +uint8_t LevBaseCapabilities::getNumberOfAssistModesSupported() { + return this->get8BitValue(TRAVELMODESSUPPORTED_BYTE, + TRAVELMODESSUPPORTED_NUMBERASSISTMODES_MASK, + TRAVELMODESSUPPORTED_NUMBERASSISTMODES_SHIFT); +} + +template +uint8_t LevBaseCapabilities::getNumberOfRegenerativeModesSupported() { + return this->get8BitValue(TRAVELMODESSUPPORTED_BYTE, + TRAVELMODESSUPPORTED_NUMBERREGENERATIVEMODES_MASK); +} + +template +uint16_t LevBaseCapabilities::getWheelCircumference() { + return this->get16BitValue(WHEELCIRCUMFERENCE_LSB_BYTE, + WHEELCIRCUMFERENCE_MSB_BYTE, WHEELCIRCUMFERENCE_MASK); +} + +template class LevBaseCapabilities; +template class LevBaseCapabilities; + +LevCapabilities::LevCapabilities(AntRxDataResponse& dp) : + LevBaseMainDataPage(dp), LevBaseCapabilities() {} + +LevCapabilitiesMsg::LevCapabilitiesMsg() : + LevBaseMainDataPageMsg(ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_NUMBER), + LevBaseCapabilities() {} + +void LevCapabilitiesMsg::setNumberOfAssistModesSupported(uint8_t modes) { + set8BitValue(modes, TRAVELMODESSUPPORTED_BYTE, + TRAVELMODESSUPPORTED_NUMBERASSISTMODES_MASK, + TRAVELMODESSUPPORTED_NUMBERASSISTMODES_SHIFT); +} + +void LevCapabilitiesMsg::setNumberOfRegenerativeModesSupported(uint8_t modes) { + set8BitValue(modes, TRAVELMODESSUPPORTED_BYTE, + TRAVELMODESSUPPORTED_NUMBERREGENERATIVEMODES_MASK); +} + +void LevCapabilitiesMsg::setWheelCircumference(uint16_t circumference) { + set16BitValue(circumference, WHEELCIRCUMFERENCE_LSB_BYTE, + WHEELCIRCUMFERENCE_MSB_BYTE, WHEELCIRCUMFERENCE_MASK); +} diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.h new file mode 100644 index 0000000..1a80731 --- /dev/null +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.h @@ -0,0 +1,28 @@ +#ifndef ANTPLUS_LEVCAPABILITIES_h +#define ANTPLUS_LEVCAPABILITIES_h + +#include + +template +class LevBaseCapabilities : virtual public CoreDataPage { +public: + LevBaseCapabilities(); + uint8_t getNumberOfAssistModesSupported(); + uint8_t getNumberOfRegenerativeModesSupported(); + uint16_t getWheelCircumference(); +}; + +class LevCapabilities : public LevBaseMainDataPage, public LevBaseCapabilities { +public: + explicit LevCapabilities(AntRxDataResponse& dp); +}; + +class LevCapabilitiesMsg : public LevBaseMainDataPageMsg, public LevBaseCapabilities { +public: + LevCapabilitiesMsg(); + void setNumberOfAssistModesSupported(uint8_t modes); + void setNumberOfRegenerativeModesSupported(uint8_t modes); + void setWheelCircumference(uint16_t circumference); +}; + +#endif // ANTPLUS_LEVCAPABILITIES_h diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.cpp new file mode 100644 index 0000000..81208f4 --- /dev/null +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.cpp @@ -0,0 +1,162 @@ +#include +#include + +#define WHEELCIRCUMFERENCE_LSB_BYTE 1 +#define WHEELCIRCUMFERENCE_MSB_BYTE 2 +#define WHEELCIRCUMFERENCE_MASK 0xFFF +#define RESERVED1_BYTE 2 +#define RESERVED1_VALUE 0xF0 +#define RESERVED2_BYTE 5 +#define RESERVED2_VALUE 0 +#define CURRENTASSISTLEVEL_BYTE 3 +#define CURRENTASSISTLEVEL_MASK 0x38 +#define CURRENTASSISTLEVEL_SHIFT 3 +#define CURRENTREGENERATIVELEVEL_BYTE 3 +#define CURRENTREGENERATIVELEVEL_MASK 0x7 +#define CURRENTREARGEAR_LSB_BYTE 4 +#define CURRENTREARGEAR_MSB_BYTE 5 +#define CURRENTREARGEAR_MASK 0x3C0 +#define CURRENTREARGEAR_SHIFT 6 +#define CURRENTFRONTGEAR_BYTE 4 +#define CURRENTFRONTGEAR_MASK 0x30 +#define CURRENTFRONTGEAR_SHIFT 4 +#define DISPLAYCOMMAND_BYTE 4 +#define DISPLAYCOMMANDTURNSIGNALRIGHT_MASK 0x1 +#define DISPLAYCOMMANDTURNSIGNALLEFT_MASK 0x2 +#define DISPLAYCOMMANDTURNSIGNALLEFT_SHIFT 1 +#define DISPLAYCOMMANDLIGHTHIGHBEAM_MASK 0x4 +#define DISPLAYCOMMANDLIGHTHIGHBEAM_SHIFT 2 +#define DISPLAYCOMMANDLIGHTONFOFF_MASK 0x8 +#define DISPLAYCOMMANDLIGHTONFOFF_SHIFT 3 +#define MANUFACTURERID_LSB_BYTE 6 +#define MANUFACTURERID_MSB_BYTE 7 + +template +LevBaseDisplayData::LevBaseDisplayData() : CoreDataPage() {} + +template +uint16_t LevBaseDisplayData::getWheelCircumference() { + return this->get16BitValue(WHEELCIRCUMFERENCE_LSB_BYTE, + WHEELCIRCUMFERENCE_MSB_BYTE, WHEELCIRCUMFERENCE_MASK); +} + +template +uint8_t LevBaseDisplayData::getCurrentAssistLevel() { + return this->get8BitValue(CURRENTASSISTLEVEL_BYTE, CURRENTASSISTLEVEL_MASK, + CURRENTASSISTLEVEL_SHIFT); +} + +template +uint8_t LevBaseDisplayData::getCurrentRegenerativeLevel() { + return this->get8BitValue(CURRENTREGENERATIVELEVEL_BYTE, + CURRENTREGENERATIVELEVEL_MASK); +} + +template +uint8_t LevBaseDisplayData::getCurrentRearGear() { + // This is a 16 bit call because the 4 bits spans 2 bytes + return (uint8_t)this->get16BitValue(CURRENTREARGEAR_LSB_BYTE, + CURRENTREARGEAR_MSB_BYTE, CURRENTREARGEAR_MASK, + CURRENTREARGEAR_SHIFT); +} + +template +uint8_t LevBaseDisplayData::getCurrentFrontGear() { + return this->get8BitValue(CURRENTFRONTGEAR_BYTE, CURRENTFRONTGEAR_MASK, + CURRENTFRONTGEAR_SHIFT); +} + +template +bool LevBaseDisplayData::getDisplayCommandTurnSignalRight() { + return this->get8BitValue(DISPLAYCOMMAND_BYTE, + DISPLAYCOMMANDTURNSIGNALRIGHT_MASK); +} + +template +bool LevBaseDisplayData::getDisplayCommandTurnSignalLeft() { + return this->get8BitValue(DISPLAYCOMMAND_BYTE, + DISPLAYCOMMANDTURNSIGNALLEFT_MASK, + DISPLAYCOMMANDTURNSIGNALLEFT_SHIFT); +} + +template +bool LevBaseDisplayData::getDisplayCommandLightHighBeam() { + return this->get8BitValue(DISPLAYCOMMAND_BYTE, + DISPLAYCOMMANDLIGHTHIGHBEAM_MASK, + DISPLAYCOMMANDLIGHTHIGHBEAM_SHIFT); +} + +template +bool LevBaseDisplayData::getDisplayCommandLightOnOff() { + return this->get8BitValue(DISPLAYCOMMAND_BYTE, + DISPLAYCOMMANDLIGHTONFOFF_MASK, + DISPLAYCOMMANDLIGHTONFOFF_SHIFT); +} + +template +uint16_t LevBaseDisplayData::getManufacturerID() { + return this->get16BitValue(MANUFACTURERID_LSB_BYTE, MANUFACTURERID_MSB_BYTE); +} + +template class LevBaseDisplayData; +template class LevBaseDisplayData; + +LevDisplayDataMsg::LevDisplayDataMsg() : + LevBaseMainDataPageMsg(ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_NUMBER), + LevBaseDisplayData() { + set8BitValue(RESERVED1_VALUE, RESERVED1_BYTE); + set8BitValue(RESERVED2_VALUE, RESERVED2_BYTE); +} + + +void LevDisplayDataMsg::setWheelCircumference(uint16_t circumference) { + set16BitValue(circumference, WHEELCIRCUMFERENCE_LSB_BYTE, + WHEELCIRCUMFERENCE_MSB_BYTE, WHEELCIRCUMFERENCE_MASK); +} + +void LevDisplayDataMsg::setCurrentAssistLevel(uint8_t level) { + set8BitValue(level, CURRENTASSISTLEVEL_BYTE, CURRENTASSISTLEVEL_MASK, + CURRENTASSISTLEVEL_SHIFT); +} + +void LevDisplayDataMsg::setCurrentRegenerativeLevel(uint8_t level) { + set8BitValue(level, CURRENTREGENERATIVELEVEL_BYTE, + CURRENTREGENERATIVELEVEL_MASK); +} + +void LevDisplayDataMsg::setCurrentRearGear(uint8_t gear) { + set16BitValue(gear, CURRENTREARGEAR_LSB_BYTE, CURRENTREARGEAR_MSB_BYTE, + CURRENTREARGEAR_MASK, CURRENTREARGEAR_SHIFT); +} + +void LevDisplayDataMsg::setCurrentFrontGear(uint8_t gear) { + set8BitValue(gear, CURRENTFRONTGEAR_BYTE, CURRENTFRONTGEAR_MASK, + CURRENTFRONTGEAR_SHIFT); +} + +void LevDisplayDataMsg::setDisplayCommandTurnSignalRight(bool rightSignal) { + set8BitValue(rightSignal, DISPLAYCOMMAND_BYTE, + DISPLAYCOMMANDTURNSIGNALRIGHT_MASK); +} + +void LevDisplayDataMsg::setDisplayCommandTurnSignalLeft(bool leftSignal) { + set8BitValue(leftSignal, DISPLAYCOMMAND_BYTE, + DISPLAYCOMMANDTURNSIGNALLEFT_MASK, + DISPLAYCOMMANDTURNSIGNALLEFT_SHIFT); +} + +void LevDisplayDataMsg::setDisplayCommandLightHighBeam(bool highBeam) { + set8BitValue(highBeam, DISPLAYCOMMAND_BYTE, + DISPLAYCOMMANDLIGHTHIGHBEAM_MASK, + DISPLAYCOMMANDLIGHTHIGHBEAM_SHIFT); +} + +void LevDisplayDataMsg::setDisplayCommandLightOnOff(bool onOff) { + set8BitValue(onOff, DISPLAYCOMMAND_BYTE, + DISPLAYCOMMANDLIGHTONFOFF_MASK, + DISPLAYCOMMANDLIGHTONFOFF_SHIFT); +} + +void LevDisplayDataMsg::setManufacturerID(uint16_t id) { + set16BitValue(id, MANUFACTURERID_LSB_BYTE, MANUFACTURERID_MSB_BYTE); +} diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.h new file mode 100644 index 0000000..baa63a2 --- /dev/null +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.h @@ -0,0 +1,47 @@ +#ifndef ANTPLUS_LEVDISPLAYDATAMSG_h +#define ANTPLUS_LEVDISPLAYDATAMSG_h + +#include + +template +class LevBaseDisplayData : virtual public CoreDataPage { +public: + LevBaseDisplayData(); + uint16_t getWheelCircumference(); + uint8_t getCurrentAssistLevel(); + uint8_t getCurrentRegenerativeLevel(); + uint8_t getCurrentRearGear(); + uint8_t getCurrentFrontGear(); + uint8_t getCurrentLightMode(); + bool getDisplayCommandTurnSignalRight(); + bool getDisplayCommandTurnSignalLeft(); + bool getDisplayCommandLightHighBeam(); + bool getDisplayCommandLightOnOff(); + uint16_t getManufacturerID(); +}; + +class LevDisplayData : public LevBaseMainDataPage, public LevBaseDisplayData { +public: + explicit LevDisplayData(AntRxDataResponse& dp); +}; + +class LevDisplayDataMsg : public LevBaseMainDataPageMsg, public LevBaseDisplayData { +public: + LevDisplayDataMsg(); + void setWheelCircumference(uint16_t circumference); + /** + * TODO add special handler to set special case for TravelMode not supported/not set + * requires changing reserved bits + */ + void setCurrentAssistLevel(uint8_t level); + void setCurrentRegenerativeLevel(uint8_t level); + void setCurrentRearGear(uint8_t gear); + void setCurrentFrontGear(uint8_t gear); + void setDisplayCommandTurnSignalRight(bool rightSignal); + void setDisplayCommandTurnSignalLeft(bool leftSignal); + void setDisplayCommandLightHighBeam(bool highBeam); + void setDisplayCommandLightOnOff(bool onOff); + void setManufacturerID(uint16_t id); +}; + +#endif // ANTPLUS_LEVDISPLAYDATAMSG_h diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.cpp new file mode 100644 index 0000000..72b874b --- /dev/null +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.cpp @@ -0,0 +1,33 @@ +#include +#include + +#define REMAININGRANGE_LSB_BYTE 4 +#define REMAININGRANGE_MSB_BYTE 5 +#define REMAININGRANGE_MASK 0x0FFF + +/* Speed and Distance */ +template +LevInternalSpeedDistanceInformation::LevInternalSpeedDistanceInformation() : + CoreDataPage() {} + +template +uint16_t LevInternalSpeedDistanceInformation::getRemainingRange() { // in km + return this->get16BitValue(REMAININGRANGE_LSB_BYTE, REMAININGRANGE_MSB_BYTE, + REMAININGRANGE_MASK); +} + +template class LevInternalSpeedDistanceInformation; +template class LevInternalSpeedDistanceInformation; + +LevSpeedDistanceInformation::LevSpeedDistanceInformation(AntRxDataResponse& dp) : + LevBaseSpeedDistanceInformation(dp), + LevInternalSpeedDistanceInformation() {} + +LevSpeedDistanceInformationMsg::LevSpeedDistanceInformationMsg() : + LevBaseSpeedDistanceInformationMsg(ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_NUMBER), + LevInternalSpeedDistanceInformation() {} + +void LevSpeedDistanceInformationMsg::setRemainingRange(uint16_t remainingRange) { // in km + set16BitValue(remainingRange, REMAININGRANGE_LSB_BYTE, REMAININGRANGE_MSB_BYTE, + REMAININGRANGE_MASK); +} diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.h new file mode 100644 index 0000000..4c8c397 --- /dev/null +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.h @@ -0,0 +1,24 @@ +#ifndef ANTPLUS_LEVSPEEDDISTANCEINFORMATION_h +#define ANTPLUS_LEVSPEEDDISTANCEINFORMATION_h + +#include + +template +class LevInternalSpeedDistanceInformation : virtual public CoreDataPage { +public: + LevInternalSpeedDistanceInformation(); + uint16_t getRemainingRange(); // in km +}; + +class LevSpeedDistanceInformation : public LevBaseSpeedDistanceInformation, public LevInternalSpeedDistanceInformation { +public: + explicit LevSpeedDistanceInformation(AntRxDataResponse& dp); +}; + +class LevSpeedDistanceInformationMsg : public LevBaseSpeedDistanceInformationMsg, public LevInternalSpeedDistanceInformation { +public: + LevSpeedDistanceInformationMsg(); + void setRemainingRange(uint16_t remainingRange); // in km +}; + +#endif // ANTPLUS_LEVSPEEDDISTANCEINFORMATION_h diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.cpp new file mode 100644 index 0000000..f38018a --- /dev/null +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.cpp @@ -0,0 +1,93 @@ +#include +#include + +#define TEMPERATURESTATE_BYTE 1 +#define TEMPERATURESTATE_BATTERYTEMPERATURE_MASK 0x7 +#define TEMPERATURESTATE_BATTERYTEMPERATUREALERT_SHIFT 3 +#define TEMPERATURESTATE_BATTERYTEMPERATUREALERT_MASK 0x8 +#define TEMPERATURESTATE_MOTORTEMPERATURE_SHIFT 4 +#define TEMPERATURESTATE_MOTORTEMPERATURE_MASK 0x70 +#define TEMPERATURESTATE_MOTORTEMPERATUREALERT_SHIFT 7 +#define TEMPERATURESTATE_MOTORTEMPERATUREALERT_MASK 0x80 +#define ERRORMESSAGE_BYTE 5 +#define RESERVED_BYTE 7 +#define RESERVED_MASK 0xF +#define RESERVED_SHIFT 4 + +template +LevBaseSpeedSystemInformation1::LevBaseSpeedSystemInformation1() : + CoreDataPage() {} + +template +uint8_t LevBaseSpeedSystemInformation1::getBatteryTemperatureState() { + return this->get8BitValue(TEMPERATURESTATE_BYTE, + TEMPERATURESTATE_BATTERYTEMPERATURE_MASK); +} + +template +uint8_t LevBaseSpeedSystemInformation1::getBatteryTemperatureAlert() { + return this->get8BitValue(TEMPERATURESTATE_BYTE, + TEMPERATURESTATE_BATTERYTEMPERATUREALERT_MASK, + TEMPERATURESTATE_BATTERYTEMPERATUREALERT_SHIFT); +} + +template +uint8_t LevBaseSpeedSystemInformation1::getMotorTemperatureState() { + return this->get8BitValue(TEMPERATURESTATE_BYTE, + TEMPERATURESTATE_MOTORTEMPERATURE_MASK, + TEMPERATURESTATE_MOTORTEMPERATURE_SHIFT); +} + +template +uint8_t LevBaseSpeedSystemInformation1::getMotorTemperatureAlert() { + return this->get8BitValue(TEMPERATURESTATE_BYTE, + TEMPERATURESTATE_MOTORTEMPERATUREALERT_MASK, + TEMPERATURESTATE_MOTORTEMPERATUREALERT_SHIFT); +} + +template +uint8_t LevBaseSpeedSystemInformation1::getErrorMessage() { + return this->get8BitValue(ERRORMESSAGE_BYTE); +} + +template class LevBaseSpeedSystemInformation1; +template class LevBaseSpeedSystemInformation1; + +LevSpeedSystemInformation1::LevSpeedSystemInformation1(AntRxDataResponse& dp) : + LevBaseSpeedSystemInformation(dp), + LevBaseSpeedSystemInformation1() { +} + +LevSpeedSystemInformation1Msg::LevSpeedSystemInformation1Msg() : + LevBaseSpeedSystemInformationMsg(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_NUMBER), + LevBaseSpeedSystemInformation1() { + set8BitValue(RESERVED_BYTE, RESERVED_MASK, RESERVED_SHIFT); +} + +void LevSpeedSystemInformation1Msg::setBatteryTemperatureState(uint8_t state) { + set8BitValue(state, TEMPERATURESTATE_BYTE, + TEMPERATURESTATE_BATTERYTEMPERATURE_MASK); +} + +void LevSpeedSystemInformation1Msg::setBatteryTemperatureAlert(uint8_t alert) { + set8BitValue(alert, TEMPERATURESTATE_BYTE, + TEMPERATURESTATE_BATTERYTEMPERATUREALERT_MASK, + TEMPERATURESTATE_BATTERYTEMPERATUREALERT_SHIFT); +} + +void LevSpeedSystemInformation1Msg::setMotorTemperatureState(uint8_t state) { + set8BitValue(state, TEMPERATURESTATE_BYTE, + TEMPERATURESTATE_MOTORTEMPERATURE_MASK, + TEMPERATURESTATE_MOTORTEMPERATURE_SHIFT); +} + +void LevSpeedSystemInformation1Msg::setMotorTemperatureAlert(uint8_t alert) { + set8BitValue(alert, TEMPERATURESTATE_BYTE, + TEMPERATURESTATE_MOTORTEMPERATUREALERT_MASK, + TEMPERATURESTATE_MOTORTEMPERATUREALERT_SHIFT); +} + +void LevSpeedSystemInformation1Msg::setErrorMessage(uint8_t err) { + set8BitValue(err, ERRORMESSAGE_BYTE); +} + diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.h new file mode 100644 index 0000000..311cba4 --- /dev/null +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.h @@ -0,0 +1,32 @@ +#ifndef ANTPLUS_LEVSPEEDSYSTEMINFORMATION1_h +#define ANTPLUS_LEVSPEEDSYSTEMINFORMATION1_h + +#include + +template +class LevBaseSpeedSystemInformation1 : virtual public CoreDataPage { +public: + LevBaseSpeedSystemInformation1(); + uint8_t getBatteryTemperatureState(); + uint8_t getBatteryTemperatureAlert(); + uint8_t getMotorTemperatureState(); + uint8_t getMotorTemperatureAlert(); + uint8_t getErrorMessage(); +}; + +class LevSpeedSystemInformation1 : public LevBaseSpeedSystemInformation, public LevBaseSpeedSystemInformation1 { +public: + explicit LevSpeedSystemInformation1(AntRxDataResponse& dp); +}; + +class LevSpeedSystemInformation1Msg : public LevBaseSpeedSystemInformationMsg, public LevBaseSpeedSystemInformation1 { +public: + LevSpeedSystemInformation1Msg(); + void setBatteryTemperatureState(uint8_t state); + void setBatteryTemperatureAlert(uint8_t alert); + void setMotorTemperatureState(uint8_t state); + void setMotorTemperatureAlert(uint8_t alert); + void setErrorMessage(uint8_t err); +}; + +#endif // ANTPLUS_LEVSPEEDSYSTEMINFORMATION1_h diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.cpp new file mode 100644 index 0000000..60a7dff --- /dev/null +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.cpp @@ -0,0 +1,58 @@ +#include +#include + +#define BATTERYSOC_BYTE 1 +#define BATTERYSOC_STATEOFCHARGE_MASK 0x7F +#define BATTERYSOC_BATTERYEMPTY_SHIFT 7 +#define BATTERYSOC_BATTERYEMPTY_MASK 0x80 +#define PERCENTASSIST_BYTE 5 +#define RESERVED_BYTE 7 +#define RESERVED_MASK 0xF +#define RESERVED_SHIFT 4 + +template +LevBaseSpeedSystemInformation2::LevBaseSpeedSystemInformation2() : + CoreDataPage() {} + +template +uint8_t LevBaseSpeedSystemInformation2::getBatterySOC() { + return this->get8BitValue(BATTERYSOC_BYTE, BATTERYSOC_STATEOFCHARGE_MASK); +} + +template +uint8_t LevBaseSpeedSystemInformation2::getBatteryEmptyWarning() { + return this->get8BitValue(BATTERYSOC_BYTE, + BATTERYSOC_BATTERYEMPTY_MASK, + BATTERYSOC_BATTERYEMPTY_SHIFT); +} + +template +uint8_t LevBaseSpeedSystemInformation2::getPercentAssist() { + return this->get8BitValue(PERCENTASSIST_BYTE); +} + +template class LevBaseSpeedSystemInformation2; +template class LevBaseSpeedSystemInformation2; + +LevSpeedSystemInformation2::LevSpeedSystemInformation2(AntRxDataResponse& dp) : + LevBaseSpeedSystemInformation(dp), + LevBaseSpeedSystemInformation2() {} + +LevSpeedSystemInformation2Msg::LevSpeedSystemInformation2Msg() : + LevBaseSpeedSystemInformationMsg(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION2_NUMBER), + LevBaseSpeedSystemInformation2() { + set8BitValue(RESERVED_BYTE, RESERVED_MASK, RESERVED_SHIFT); +} + +void LevSpeedSystemInformation2Msg::setBatterySOC(uint8_t soc) { + set8BitValue(soc, BATTERYSOC_BYTE, BATTERYSOC_STATEOFCHARGE_MASK); +} + +void LevSpeedSystemInformation2Msg::setBatteryEmptyWarning(uint8_t warning) { + set8BitValue(warning, BATTERYSOC_BYTE, BATTERYSOC_BATTERYEMPTY_MASK, + BATTERYSOC_BATTERYEMPTY_SHIFT); +} + +void LevSpeedSystemInformation2Msg::setPercentAssist(uint8_t percent) { + set8BitValue(percent, PERCENTASSIST_BYTE); +} diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.h new file mode 100644 index 0000000..961d991 --- /dev/null +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.h @@ -0,0 +1,28 @@ +#ifndef ANTPLUS_LEVSPEEDSYSTEMINFORMATION2_h +#define ANTPLUS_LEVSPEEDSYSTEMINFORMATION2_h + +#include + +template +class LevBaseSpeedSystemInformation2 : virtual public CoreDataPage { +public: + LevBaseSpeedSystemInformation2(); + uint8_t getBatterySOC(); + uint8_t getBatteryEmptyWarning(); + uint8_t getPercentAssist(); +}; + +class LevSpeedSystemInformation2 : public LevBaseSpeedSystemInformation, public LevBaseSpeedSystemInformation2 { +public: + explicit LevSpeedSystemInformation2(AntRxDataResponse& dp); +}; + +class LevSpeedSystemInformation2Msg : public LevBaseSpeedSystemInformationMsg, public LevBaseSpeedSystemInformation2 { +public: + LevSpeedSystemInformation2Msg(); + void setBatterySOC(uint8_t soc); + void setBatteryEmptyWarning(uint8_t warning); + void setPercentAssist(uint8_t percent); +}; + +#endif // ANTPLUS_LEVSPEEDSYSTEMINFORMATION2_h diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_ProfileLevDataPages.h b/src/Profiles/Lev/DataPages/ANTPLUS_ProfileLevDataPages.h deleted file mode 100644 index 48e30f3..0000000 --- a/src/Profiles/Lev/DataPages/ANTPLUS_ProfileLevDataPages.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef ANTPLUS_PROFILELEVDATAPAGES_h -#define ANTPLUS_PROFILELEVDATAPAGES_h - -/* RX */ -#include -#include -#include -#include -#include -#include - -/* TX */ -#include - -#endif // ANTPLUS_PROFILELEVDATAPAGES_h diff --git a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPage.cpp b/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPage.cpp deleted file mode 100644 index 1d2d407..0000000 --- a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPage.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include -#include - -LevBaseMainDataPage::LevBaseMainDataPage(AntRxDataResponse& dp) : BaseDataPage(dp) { -} diff --git a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPage.h b/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPage.h deleted file mode 100644 index e66f57c..0000000 --- a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPage.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef ANTPLUS_LEVBASEMAINDATAPAGE_h -#define ANTPLUS_LEVBASEMAINDATAPAGE_h - -#include - -#include "ANT.h" - -class LevBaseMainDataPage : public BaseDataPage { -public: - LevBaseMainDataPage(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_LEVBASEMAINDATAPAGE_h diff --git a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPageMsg.cpp b/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPageMsg.cpp deleted file mode 100644 index 132d75d..0000000 --- a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPageMsg.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include -#include - -LevBaseMainDataPageMsg::LevBaseMainDataPageMsg(uint8_t dataPageNumber) : BaseDataPageMsg() { - setDataBuffer(_buffer); - _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = dataPageNumber; -} diff --git a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPageMsg.h b/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPageMsg.h deleted file mode 100644 index f3db147..0000000 --- a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPageMsg.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef ANTPLUS_LEVBASEMAINDATAPAGEMSG_h -#define ANTPLUS_LEVBASEMAINDATAPAGEMSG_h - -#include - -#include "ANT.h" - -class LevBaseMainDataPageMsg : public BaseDataPageMsg { -public: - LevBaseMainDataPageMsg(uint8_t dataPageNumber); -protected: - uint8_t _buffer[MESSAGE_SIZE]; -}; - -#endif // ANTPLUS_LEVBASEMAINDATAPAGEMSG_h diff --git a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedDistanceInformation.cpp b/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedDistanceInformation.cpp deleted file mode 100644 index fc1372d..0000000 --- a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedDistanceInformation.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include - -/* Speed and Distance */ -LevBaseSpeedDistanceInformation::LevBaseSpeedDistanceInformation(AntRxDataResponse& dp) : LevBaseMainDataPage(dp) { -} - -uint32_t LevBaseSpeedDistanceInformation::getOdometer() { // in km - return (uint32_t)getData(ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_ODOMETER_LSB_BYTE) + ((uint32_t)getData(ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_ODOMETER_MID_BYTE) << ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_ODOMETER_MID_SHIFT) + ((uint32_t)getData(ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_ODOMETER_MSB_BYTE) << ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_ODOMETER_MSB_SHIFT); -} - -uint16_t LevBaseSpeedDistanceInformation::getLevSpeed() // in 1/10 km/h -{ - return (uint16_t)getData(ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_LEVSPEED_LSB_BYTE) + (((uint16_t)getData(ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_LEVSPEED_MSB_BYTE) & ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_LEVSPEED_MSB_MASK) << ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_LEVSPEED_MSB_SHIFT); -} diff --git a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedDistanceInformation.h b/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedDistanceInformation.h deleted file mode 100644 index 1529a43..0000000 --- a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedDistanceInformation.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef ANTPLUS_LEVBASESPEEDDISTANCEINFORMATION_h -#define ANTPLUS_LEVBASESPEEDDISTANCEINFORMATION_h - -#include - -class LevBaseSpeedDistanceInformation : public LevBaseMainDataPage { -public: - LevBaseSpeedDistanceInformation(AntRxDataResponse& dp); - uint32_t getOdometer(); // in km - uint16_t getLevSpeed(); // in 1/10 km/h -}; - -#endif // ANTPLUS_LEVBASESPEEDDISTANCEINFORMATION_h diff --git a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedSystemInformation.cpp b/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedSystemInformation.cpp deleted file mode 100644 index 1007328..0000000 --- a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedSystemInformation.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include - -LevBaseSpeedSystemInformation::LevBaseSpeedSystemInformation(AntRxDataResponse& dp) : LevBaseMainDataPage(dp) { -} - -uint8_t LevBaseSpeedSystemInformation::getCurrentRegenerativeLevel() { - return getData(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_TRAVELMODESTATE_BYTE) & ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_TRAVELMODESTATE_CURRENTREGENERATIVELEVEL_MASK; -} - -uint8_t LevBaseSpeedSystemInformation::getCurrentAssistLevel() { - return (getData(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_TRAVELMODESTATE_BYTE) & ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_TRAVELMODESTATE_CURRENTASSISTLEVEL_MASK) >> ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_TRAVELMODESTATE_CURRENTASSISTLEVEL_SHIFT; -} - -uint8_t LevBaseSpeedSystemInformation::getSystemState() { - return getData(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_SYSTEMSTATE_BYTE); -} - -uint8_t LevBaseSpeedSystemInformation::getCurrentFrontGear() { - return getData(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_GEARSTATE_BYTE) & ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_GEARSTATE_CURRENTFRONTGEAR_MASK; -} - -uint8_t LevBaseSpeedSystemInformation::getCurrentRearGear() { - return (getData(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_GEARSTATE_BYTE) & ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_GEARSTATE_CURRENTREARGEAR_MASK) >> ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_GEARSTATE_CURRENTREARGEAR_SHIFT; -} - -uint8_t LevBaseSpeedSystemInformation::getManualAutoState() { - return (getData(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_GEARSTATE_BYTE) & ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_GEARSTATE_MANUALAUTO_MASK) >> ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_GEARSTATE_MANUALAUTO_SHIFT; -} - -uint8_t LevBaseSpeedSystemInformation::getGearExist() { - return (getData(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_GEARSTATE_BYTE) & ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_GEARSTATE_GEAREXIST_MASK) >> ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_GEARSTATE_GEAREXIST_SHIFT; -} - -uint16_t LevBaseSpeedSystemInformation::getSpeed() { // in 1/10 km/h - return (uint16_t)getData(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_LEVSPEED_LSB_BYTE) + (((uint16_t)getData(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_LEVSPEED_MSB_BYTE) & ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_LEVSPEED_MSB_MASK) << ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_LEVSPEED_MSB_SHIFT); -} diff --git a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedSystemInformation.h b/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedSystemInformation.h deleted file mode 100644 index c9f8b58..0000000 --- a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedSystemInformation.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef ANTPLUS_LEVBASESPEEDSYSTEMINFORMATION_h -#define ANTPLUS_LEVBASESPEEDSYSTEMINFORMATION_h - -#include - -class LevBaseSpeedSystemInformation : public LevBaseMainDataPage { -public: - LevBaseSpeedSystemInformation(AntRxDataResponse& dp); - uint8_t getCurrentRegenerativeLevel(); - uint8_t getCurrentAssistLevel(); - uint8_t getSystemState(); - uint8_t getCurrentFrontGear(); - uint8_t getCurrentRearGear(); - uint8_t getManualAutoState(); - uint8_t getGearExist(); - uint16_t getSpeed(); // in 1/10 km/h -}; - -#endif // ANTPLUS_LEVBASESPEEDSYSTEMINFORMATION_h diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevAltSpeedDistanceInformation.cpp b/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevAltSpeedDistanceInformation.cpp deleted file mode 100644 index 962dac0..0000000 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevAltSpeedDistanceInformation.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include - -/* Alt Speed and Distance */ -LevAltSpeedDistanceInformation::LevAltSpeedDistanceInformation(AntRxDataResponse& dp) : LevBaseSpeedDistanceInformation(dp) { -} - -uint16_t LevAltSpeedDistanceInformation::getFuelConsumption() // in Wh/km -{ - return (uint16_t)getData(ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_FUELCONSUMPTION_LSB_BYTE) + (((uint16_t)getData(ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_FUELCONSUMPTION_MSB_BYTE) & ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_FUELCONSUMPTION_MSB_MASK) << ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_FUELCONSUMPTION_MSB_SHIFT); -} - diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevAltSpeedDistanceInformation.h b/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevAltSpeedDistanceInformation.h deleted file mode 100644 index 4e6aa87..0000000 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevAltSpeedDistanceInformation.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_LEVALTSPEEDDISTANCEINFORMATION_h -#define ANTPLUS_LEVALTSPEEDDISTANCEINFORMATION_h - -#include - -class LevAltSpeedDistanceInformation : public LevBaseSpeedDistanceInformation { -public: - LevAltSpeedDistanceInformation(AntRxDataResponse& dp); - uint16_t getFuelConsumption(); // in Wh/km -}; - -#endif // ANTPLUS_LEVALTSPEEDDISTANCEINFORMATION_h diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevBatteryInformation.cpp b/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevBatteryInformation.cpp deleted file mode 100644 index 4814d8b..0000000 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevBatteryInformation.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -LevBatteryInformation::LevBatteryInformation(AntRxDataResponse& dp) : LevBaseMainDataPage(dp) { -} - -uint16_t LevBatteryInformation::getChargingCycleCount() { - return (uint16_t)getData(ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_CHARGINGCYCLECOUNT_LSB_BYTE) + (((uint16_t)getData(ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_CHARGINGCYCLECOUNT_MSB_BYTE) & ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_CHARGINGCYCLECOUNT_MSB_MASK) << ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_CHARGINGCYCLECOUNT_MSB_SHIFT); -} - -uint16_t LevBatteryInformation::getFuelConsumption() { - return (((uint16_t)getData(ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_FUELCONSUMPTION_MSB_BYTE) & ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_FUELCONSUMPTION_MSB_MASK) << ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_FUELCONSUMPTION_MSB_SHIFT) + (uint16_t)getData(ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_FUELCONSUMPTION_LSB_BYTE); -} - -uint8_t LevBatteryInformation::getBatteryVoltage() { - return getData(ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_BATTERYVOLTAGE_BYTE); -} - -uint16_t LevBatteryInformation::getDistanceOnCurrentCharge() { - return getData(ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_DISTANCEONCURRENTCHARGE_LSB_BYTE) + (getData(ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_DISTANCEONCURRENTCHARGE_MSB_BYTE) << ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_DISTANCEONCURRENTCHARGE_MSB_SHIFT); -} diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevBatteryInformation.h b/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevBatteryInformation.h deleted file mode 100644 index b9d997f..0000000 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevBatteryInformation.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef ANTPLUS_LEVBATTERYINFORMATION_h -#define ANTPLUS_LEVBATTERYINFORMATION_h - -#include - -class LevBatteryInformation : public LevBaseMainDataPage { -public: - LevBatteryInformation(AntRxDataResponse& dp); - uint16_t getChargingCycleCount(); - uint16_t getFuelConsumption(); - uint8_t getBatteryVoltage(); - uint16_t getDistanceOnCurrentCharge(); -}; - -#endif // ANTPLUS_LEVBATTERYINFORMATION_h diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevCapabilities.cpp b/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevCapabilities.cpp deleted file mode 100644 index b759e93..0000000 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevCapabilities.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -LevCapabilities::LevCapabilities(AntRxDataResponse& dp) : LevBaseMainDataPage(dp) { -} - -uint8_t LevCapabilities::getNumberOfAssistModesSupported() { - return (getData(ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_TRAVELMODESSUPPORTED_BYTE) & ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_TRAVELMODESSUPPORTED_NUMBERASSISTMODES_MASK) >> ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_TRAVELMODESSUPPORTED_NUMBERASSISTMODES_SHIFT; -} - -uint8_t LevCapabilities::getNumberOfRegenerativeModesSupported() { - return getData(ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_TRAVELMODESSUPPORTED_BYTE) & ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_TRAVELMODESSUPPORTED_NUMBERREGENERATIVEMODES_MASK; -} - -uint16_t LevCapabilities::getWheelCircumference() { - return (uint16_t)getData(ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_WHEELCIRCUMFERENCE_LSB_BYTE) + (((uint16_t)getData(ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_WHEELCIRCUMFERENCE_MSB_BYTE) & ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_WHEELCIRCUMFERENCE_MSB_MASK) << ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_WHEELCIRCUMFERENCE_MSB_SHIFT); -} diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevCapabilities.h b/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevCapabilities.h deleted file mode 100644 index 67a4cbd..0000000 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevCapabilities.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef ANTPLUS_LEVCAPABILITIES_h -#define ANTPLUS_LEVCAPABILITIES_h - -#include - -class LevCapabilities : public LevBaseMainDataPage { -public: - LevCapabilities(AntRxDataResponse& dp); - uint8_t getNumberOfAssistModesSupported(); - uint8_t getNumberOfRegenerativeModesSupported(); - uint16_t getWheelCircumference(); -}; - -#endif // ANTPLUS_LEVCAPABILITIES_h diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedDistanceInformation.cpp b/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedDistanceInformation.cpp deleted file mode 100644 index 9926254..0000000 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedDistanceInformation.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include - -/* Speed and Distance */ -LevSpeedDistanceInformation::LevSpeedDistanceInformation(AntRxDataResponse& dp) : LevBaseSpeedDistanceInformation(dp) { -} - -uint16_t LevSpeedDistanceInformation::getRemainingRange() { // in km - return (uint16_t)getData(ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_REMAININGRANGE_LSB_BYTE) + (((uint16_t)getData(ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_REMAININGRANGE_MSB_BYTE) & ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_REMAININGRANGE_MSB_MASK) << ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_REMAININGRANGE_MSB_SHIFT); -} diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedDistanceInformation.h b/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedDistanceInformation.h deleted file mode 100644 index e98498b..0000000 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedDistanceInformation.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_LEVSPEEDDISTANCEINFORMATION_h -#define ANTPLUS_LEVSPEEDDISTANCEINFORMATION_h - -#include - -class LevSpeedDistanceInformation : public LevBaseSpeedDistanceInformation { -public: - LevSpeedDistanceInformation(AntRxDataResponse& dp); - uint16_t getRemainingRange(); // in km -}; - -#endif // ANTPLUS_LEVSPEEDDISTANCEINFORMATION_h diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation1.cpp b/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation1.cpp deleted file mode 100644 index 1171382..0000000 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation1.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include - -LevSpeedSystemInformation1::LevSpeedSystemInformation1(AntRxDataResponse& dp) : LevBaseSpeedSystemInformation(dp) { -} - -uint8_t LevSpeedSystemInformation1::getBatteryTemperatureState() { - return getData(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_TEMPERATURESTATE_BYTE) & ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_TEMPERATURESTATE_BATTERYTEMPERATURE_MASK; -} - -uint8_t LevSpeedSystemInformation1::getBatteryTemperatureAlert() { - return (getData(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_TEMPERATURESTATE_BYTE) & ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_TEMPERATURESTATE_BATTERYTEMPERATUREALERT_MASK) >> ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_TEMPERATURESTATE_BATTERYTEMPERATUREALERT_SHIFT; -} - -uint8_t LevSpeedSystemInformation1::getMotorTemperatureState() { - return (getData(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_TEMPERATURESTATE_BYTE) & ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_TEMPERATURESTATE_MOTORTEMPERATURE_MASK) >> ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_TEMPERATURESTATE_MOTORTEMPERATURE_SHIFT; -} - -uint8_t LevSpeedSystemInformation1::getMotorTemperatureAlert() { - return (getData(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_TEMPERATURESTATE_BYTE) & ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_TEMPERATURESTATE_MOTORTEMPERATUREALERT_MASK) >> ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_TEMPERATURESTATE_MOTORTEMPERATUREALERT_SHIFT; -} - - -uint8_t LevSpeedSystemInformation1::getErrorMessage() { - return getData(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_ERRORMESSAGE_BYTE); -} - diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation1.h b/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation1.h deleted file mode 100644 index 6c3f72d..0000000 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation1.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef ANTPLUS_LEVSPEEDSYSTEMINFORMATION1_h -#define ANTPLUS_LEVSPEEDSYSTEMINFORMATION1_h - -#include - -class LevSpeedSystemInformation1 : public LevBaseSpeedSystemInformation { -public: - LevSpeedSystemInformation1(AntRxDataResponse& dp); - uint8_t getBatteryTemperatureState(); - uint8_t getBatteryTemperatureAlert(); - uint8_t getMotorTemperatureState(); - uint8_t getMotorTemperatureAlert(); - uint8_t getErrorMessage(); -}; - -#endif // ANTPLUS_LEVSPEEDSYSTEMINFORMATION1_h diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation2.cpp b/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation2.cpp deleted file mode 100644 index b985fac..0000000 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation2.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -LevSpeedSystemInformation2::LevSpeedSystemInformation2(AntRxDataResponse& dp) : LevBaseSpeedSystemInformation(dp) { -} - -uint8_t LevSpeedSystemInformation2::getBatterySOC() { - return getData(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION2_BATTERYSOC_BYTE) & ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION2_BATTERYSOC_STATEOFCHARGE_MASK; -} - -uint8_t LevSpeedSystemInformation2::getBatteryEmptyWarning() { - return (getData(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION2_BATTERYSOC_BYTE) & ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION2_BATTERYSOC_BATTERYEMPTY_MASK) >> ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION2_BATTERYSOC_BATTERYEMPTY_SHIFT; -} - -uint8_t LevSpeedSystemInformation2::getPercentAssist() { - return getData(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION2_PERCENTASSIST_BYTE); -} diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation2.h b/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation2.h deleted file mode 100644 index 533a7e2..0000000 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation2.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef ANTPLUS_LEVSPEEDSYSTEMINFORMATION2_h -#define ANTPLUS_LEVSPEEDSYSTEMINFORMATION2_h - -#include - -class LevSpeedSystemInformation2 : public LevBaseSpeedSystemInformation { -public: - LevSpeedSystemInformation2(AntRxDataResponse& dp); - uint8_t getBatterySOC(); - uint8_t getBatteryEmptyWarning(); - uint8_t getPercentAssist(); -}; - -#endif // ANTPLUS_LEVSPEEDSYSTEMINFORMATION2_h diff --git a/src/Profiles/Lev/DataPages/TX/ANTPLUS_LevDisplayDataMsg.cpp b/src/Profiles/Lev/DataPages/TX/ANTPLUS_LevDisplayDataMsg.cpp deleted file mode 100644 index b5f8efd..0000000 --- a/src/Profiles/Lev/DataPages/TX/ANTPLUS_LevDisplayDataMsg.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include -#include - -LevDisplayDataMsg::LevDisplayDataMsg() : LevBaseMainDataPageMsg(ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_NUMBER) { - _buffer[ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_RESERVED1_BYTE] = ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_RESERVED1_VALUE; - _buffer[ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_RESERVED2_BYTE] = ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_RESERVED2_VALUE; -} - -uint16_t LevDisplayDataMsg::getWheelCircumference() { - return get16BitValue(ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_WHEELCIRCUMFERENCE_LSB_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_WHEELCIRCUMFERENCE_MSB_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_WHEELCIRCUMFERENCE_MASK); -} - -uint8_t LevDisplayDataMsg::getCurrentAssistLevel() { - return get8BitValue(ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTASSISTLEVEL_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTASSISTLEVEL_MASK, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTASSISTLEVEL_SHIFT); -} - -uint8_t LevDisplayDataMsg::getCurrentRegenerativeLevel() { - return get8BitValue(ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTREGENERATIVELEVEL_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTREGENERATIVELEVEL_MASK); -} - -uint8_t LevDisplayDataMsg::getCurrentRearGear() { - // This is a 16 bit call because the 4 bits spans 2 bytes - return (uint8_t)get16BitValue( - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTREARGEAR_LSB_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTREARGEAR_MSB_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTREARGEAR_MASK, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTREARGEAR_SHIFT); -} - -uint8_t LevDisplayDataMsg::getCurrentFrontGear() { - return get8BitValue(ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTFRONTGEAR_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTFRONTGEAR_MASK, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTFRONTGEAR_SHIFT); -} - -uint8_t LevDisplayDataMsg::getCurrentLightMode() { - return get8BitValue(ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTLIGHTMODE_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTLIGHTMODE_MASK); -} - -uint16_t LevDisplayDataMsg::getManufacturerID() { - return get16BitValue(ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_MANUFACTURERID_LSB_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_MANUFACTURERID_MSB_BYTE); -} - -void LevDisplayDataMsg::setWheelCircumference(uint16_t circumference) { - set16BitValue(circumference, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_WHEELCIRCUMFERENCE_LSB_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_WHEELCIRCUMFERENCE_MSB_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_WHEELCIRCUMFERENCE_MASK); -} - -void LevDisplayDataMsg::setCurrentAssistLevel(uint8_t level) { - set8BitValue(level, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTASSISTLEVEL_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTASSISTLEVEL_MASK, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTASSISTLEVEL_SHIFT); -} - -void LevDisplayDataMsg::setCurrentRegenerativeLevel(uint8_t level) { - set8BitValue(level, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTREGENERATIVELEVEL_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTREGENERATIVELEVEL_MASK); -} - -void LevDisplayDataMsg::setCurrentRearGear(uint8_t gear) { - set16BitValue(gear, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTREARGEAR_LSB_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTREARGEAR_MSB_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTREARGEAR_MASK, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTREARGEAR_SHIFT); -} - -void LevDisplayDataMsg::setCurrentFrontGear(uint8_t gear) { - set8BitValue(gear, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTFRONTGEAR_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTFRONTGEAR_MASK, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTFRONTGEAR_SHIFT); -} - -void LevDisplayDataMsg::setCurrentLightMode(uint8_t state) { - set8BitValue(state, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTLIGHTMODE_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTLIGHTMODE_MASK); -} - -void LevDisplayDataMsg::setManufacturerID(uint16_t id) { - set16BitValue(id, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_MANUFACTURERID_LSB_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_MANUFACTURERID_MSB_BYTE); -} diff --git a/src/Profiles/Lev/DataPages/TX/ANTPLUS_LevDisplayDataMsg.h b/src/Profiles/Lev/DataPages/TX/ANTPLUS_LevDisplayDataMsg.h deleted file mode 100644 index 67c165b..0000000 --- a/src/Profiles/Lev/DataPages/TX/ANTPLUS_LevDisplayDataMsg.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef ANTPLUS_LEVDISPLAYDATAMSG_h -#define ANTPLUS_LEVDISPLAYDATAMSG_h - -#include - -class LevDisplayDataMsg : public LevBaseMainDataPageMsg { -public: - LevDisplayDataMsg(); - uint16_t getWheelCircumference(); - uint8_t getCurrentAssistLevel(); - uint8_t getCurrentRegenerativeLevel(); - uint8_t getCurrentRearGear(); - uint8_t getCurrentFrontGear(); - uint8_t getCurrentLightMode(); - uint16_t getManufacturerID(); - void setWheelCircumference(uint16_t circumference); - /** - * TODO add special handler to set special case for TravelMode not supported/not set - * requires changing reserved bits - */ - void setCurrentAssistLevel(uint8_t level); - void setCurrentRegenerativeLevel(uint8_t level); - void setCurrentRearGear(uint8_t gear); - void setCurrentFrontGear(uint8_t gear); - void setCurrentLightMode(uint8_t state); - void setManufacturerID(uint16_t id); -}; - -#endif // ANTPLUS_LEVDISPLAYDATAMSG_h diff --git a/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.cpp b/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.cpp similarity index 74% rename from src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.cpp rename to src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.cpp index 29886a3..db7b757 100644 --- a/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.cpp +++ b/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.cpp @@ -1,26 +1,19 @@ -#include +#include #include #include -#include -#include +#include -ProfileLevDisplay::ProfileLevDisplay() : BaseSlaveProfile() { - setChannelConfig(); -} - -ProfileLevDisplay::ProfileLevDisplay(uint16_t deviceNumber) : BaseSlaveProfile(deviceNumber) { - setChannelConfig(); -} +#define DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE ProfileLevDisplay::ProfileLevDisplay(uint16_t deviceNumber, uint8_t transmissionType) : BaseSlaveProfile(deviceNumber, transmissionType) { setChannelConfig(); } void ProfileLevDisplay::setChannelConfig() { - setChannelType(ANTPLUS_LEV_DISPLAY_CHANNELTYPE); + setChannelType(DISPLAY_CHANNELTYPE); setDeviceType(ANTPLUS_LEV_DEVICETYPE); - setChannelPeriod(ANTPLUS_LEV_CHANNELPERIOD); - setSearchTimeout(ANTPLUS_LEV_SEARCHTIMEOUT); + setChannelPeriod(LEV_CHANNELPERIOD); + setSearchTimeout(LEV_SEARCHTIMEOUT); } void ProfileLevDisplay::onBroadcastData(BroadcastData& msg) { @@ -74,41 +67,41 @@ bool ProfileLevDisplay::handleDataPage(LevBaseMainDataPage& dp) { } bool ProfileLevDisplay::handleSpeedSystemInformation1(LevBaseMainDataPage& dataPage) { - LevSpeedSystemInformation1 dp = LevSpeedSystemInformation1(dataPage); + LevSpeedSystemInformation1 dp(dataPage); return _onLevSpeedSystemInformation1.call(dp); } bool ProfileLevDisplay::handleSpeedDistanceInformation(LevBaseMainDataPage& dataPage) { - LevSpeedDistanceInformation dp = LevSpeedDistanceInformation(dataPage); + LevSpeedDistanceInformation dp(dataPage); return _onLevSpeedDistanceInformation.call(dp); } bool ProfileLevDisplay::handleAltSpeedDistanceInformation(LevBaseMainDataPage& dataPage) { - LevAltSpeedDistanceInformation dp = LevAltSpeedDistanceInformation(dataPage); + LevAltSpeedDistanceInformation dp(dataPage); return _onLevAltSpeedDistanceInformation.call(dp); } bool ProfileLevDisplay::handleSpeedSystemInformation2(LevBaseMainDataPage& dataPage) { - LevSpeedSystemInformation2 dp = LevSpeedSystemInformation2(dataPage); + LevSpeedSystemInformation2 dp(dataPage); return _onLevSpeedSystemInformation2.call(dp); } bool ProfileLevDisplay::handleBatteryInformation(LevBaseMainDataPage& dataPage) { - LevBatteryInformation dp = LevBatteryInformation(dataPage); + LevBatteryInformation dp(dataPage); return _onLevBatteryInformation.call(dp); } bool ProfileLevDisplay::handleCapabilities(LevBaseMainDataPage& dataPage) { - LevCapabilities dp = LevCapabilities(dataPage); + LevCapabilities dp(dataPage); return _onLevCapabilities.call(dp); } bool ProfileLevDisplay::handleManufacturersInformation(LevBaseMainDataPage& dataPage) { - ManufacturersInformation dp = ManufacturersInformation(dataPage); + ManufacturersInformation dp(dataPage); return _onManufacturersInformation.call(dp); } bool ProfileLevDisplay::handleProductInformation(LevBaseMainDataPage& dataPage) { - ProductInformation dp = ProductInformation(dataPage); + ProductInformation dp(dataPage); return _onProductInformation.call(dp); } diff --git a/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.h b/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.h similarity index 84% rename from src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.h rename to src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.h index debd74e..0b04e95 100644 --- a/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.h +++ b/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.h @@ -2,16 +2,12 @@ #define ANTPLUS_PROFILELEVDISPLAY_h #include -#include +#include #include -#include "ANT.h" - class ProfileLevDisplay : public BaseSlaveProfile { public: - ProfileLevDisplay(); - ProfileLevDisplay(uint16_t deviceNumber); - ProfileLevDisplay(uint16_t deviceNumber, uint8_t transmissionType); + explicit ProfileLevDisplay(uint16_t deviceNumber = 0, uint8_t transmissionType = 0); void onLevSpeedSystemInformation1(void(*func)(LevSpeedSystemInformation1&, uintptr_t), uintptr_t data = 0) { _onLevSpeedSystemInformation1.set(func, data); } void onLevSpeedDistanceInformation(void(*func)(LevSpeedDistanceInformation&, uintptr_t), uintptr_t data = 0) { _onLevSpeedDistanceInformation.set(func, data); } @@ -37,14 +33,14 @@ class ProfileLevDisplay : public BaseSlaveProfile { bool handleManufacturersInformation(LevBaseMainDataPage& dataPage); bool handleProductInformation(LevBaseMainDataPage& dataPage); - AntCallback _onLevSpeedSystemInformation1; - AntCallback _onLevSpeedDistanceInformation; - AntCallback _onLevAltSpeedDistanceInformation; - AntCallback _onLevSpeedSystemInformation2; - AntCallback _onLevBatteryInformation; - AntCallback _onLevCapabilities; - AntCallback _onManufacturersInformation; - AntCallback _onProductInformation; + AntCallback _onLevSpeedSystemInformation1 = { .func = NULL }; + AntCallback _onLevSpeedDistanceInformation = { .func = NULL }; + AntCallback _onLevAltSpeedDistanceInformation = { .func = NULL }; + AntCallback _onLevSpeedSystemInformation2 = { .func = NULL }; + AntCallback _onLevBatteryInformation = { .func = NULL }; + AntCallback _onLevCapabilities = { .func = NULL }; + AntCallback _onManufacturersInformation = { .func = NULL }; + AntCallback _onProductInformation = { .func = NULL }; }; #endif // ANTPLUS_PROFILELEVDISPLAY_h diff --git a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h new file mode 100644 index 0000000..95ccfb0 --- /dev/null +++ b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h @@ -0,0 +1,28 @@ +#ifndef ANTPLUS_MUSCLEOXYGENDEFINES_h +#define ANTPLUS_MUSCLEOXYGENDEFINES_h + +#define ANTPLUS_MUSCLEOXYGEN_DEVICETYPE 31 + +#define ANTPLUS_MUSCLEOXYGEN_FLAGS_BATTERYSTATUS_SUPPORTED (1 << 0) + + +#define ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_NUMBER 1 + +#define ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_NOTIFICATIONS_UTCTIMEREQUIRED 1 + +#define ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_CAPABILITIES_ANTFSSUPPORT_SUPPORTED 1 + +#define ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_CAPABILITIES_MEASUREMENTINTERVAL_250MS 1 +#define ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_CAPABILITIES_MEASUREMENTINTERVAL_500MS 2 +#define ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_CAPABILITIES_MEASUREMENTINTERVAL_1S 3 +#define ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_CAPABILITIES_MEASUREMENTINTERVAL_2S 4 + +#define ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_TOTALHEMOGLOBINCONCENTRATION_AMBIENTLIGHTOOHIGH 0xFFE +#define ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_TOTALHEMOGLOBINCONCENTRATION_INVALID 0xFFF +#define ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_PREVIOUSSATURATEDHEMOGLOBINPERCENTAGE_INVALID 0xFFF +#define ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_CURRENTSATURATEDHEMOGLOBINPERCENTAGE_INVALID 0xFFF + + +#define ANTPLUS_MUSCLEOXYGEN_DATAPAGE_COMMANDS_NUMBER 16 + +#endif // ANTPLUS_MUSCLEOXYGENDEFINES_h diff --git a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h new file mode 100644 index 0000000..54eb483 --- /dev/null +++ b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h @@ -0,0 +1,12 @@ +#ifndef ANTPLUS_MUSCLEOXYGENPRIVATEDEFINES_h +#define ANTPLUS_MUSCLEOXYGENPRIVATEDEFINES_h + +#include + +// Master channel +#define MUSCLEOXYGEN_CHANNELPERIOD 8192 + +// 30 / 2.5 = 12 +#define MUSCLEOXYGEN_SEARCHTIMEOUT 12 + +#endif // ANTPLUS_MUSCLEOXYGENPRIVATEDEFINES_h diff --git a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenProfile.h b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenProfile.h new file mode 100644 index 0000000..09b2988 --- /dev/null +++ b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenProfile.h @@ -0,0 +1,13 @@ +#ifndef ANTPLUS_MUSCLEOXYGENPROFILE_h +#define ANTPLUS_MUSCLEOXYGENPROFILE_h + +// General Definitions +#include + +// Datapages +#include + +// Profile Classes +#include + +#endif // ANTPLUS_MUSCLEOXYGENPROFILE_h diff --git a/src/Profiles/MuscleOxygen/ANTPLUS_ProfileMuscleOxygenDataPages.h b/src/Profiles/MuscleOxygen/ANTPLUS_ProfileMuscleOxygenDataPages.h new file mode 100644 index 0000000..fb93d19 --- /dev/null +++ b/src/Profiles/MuscleOxygen/ANTPLUS_ProfileMuscleOxygenDataPages.h @@ -0,0 +1,7 @@ +#ifndef ANTPLUS_PROFILEMUSCLEOXYGENDATAPAGES_h +#define ANTPLUS_PROFILEMUSCLEOXYGENDATAPAGES_h + +#include +#include + +#endif // ANTPLUS_PROFILEMUSCLEOXYGENDATAPAGES_h diff --git a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.cpp b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.cpp new file mode 100644 index 0000000..dc470da --- /dev/null +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.cpp @@ -0,0 +1,10 @@ +#include +#include + +MuscleOxygenBaseMainDataPage::MuscleOxygenBaseMainDataPage(AntRxDataResponse& dp) : + BaseDataPage(dp) {} + +MuscleOxygenBaseMainDataPageMsg::MuscleOxygenBaseMainDataPageMsg(uint8_t dataPageNumber) : BaseDataPageMsg() { + setDataBuffer(_buffer); + set8BitValue(dataPageNumber, ANTPLUS_DEFAULT_DATAPAGE_BYTE); +} diff --git a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.h b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.h new file mode 100644 index 0000000..e6bd474 --- /dev/null +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.h @@ -0,0 +1,19 @@ +#ifndef ANTPLUS_MUSCLEOXYGENBASEMAINDATAPAGEMSG_h +#define ANTPLUS_MUSCLEOXYGENBASEMAINDATAPAGEMSG_h + +#include +#include + +class MuscleOxygenBaseMainDataPage : public BaseDataPage { +public: + explicit MuscleOxygenBaseMainDataPage(AntRxDataResponse& dp); +}; + +class MuscleOxygenBaseMainDataPageMsg : public BaseDataPageMsg { +public: + explicit MuscleOxygenBaseMainDataPageMsg(uint8_t dataPageNumber); +protected: + uint8_t _buffer[MESSAGE_SIZE] = {0}; +}; + +#endif // ANTPLUS_MUSCLEOXYGENBASEMAINDATAPAGEMSG_h diff --git a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenCommands.cpp b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenCommands.cpp new file mode 100644 index 0000000..f9440ae --- /dev/null +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenCommands.cpp @@ -0,0 +1,55 @@ +#include +#include + +#define COMMANDID_BYTE 1 +#define RESERVED_BYTE 2 +#define LOCALTIMEOFFSET_BYTE 3 +#define CURRENTTIMETIMESTAMP_LSB_BYTE 4 +#define CURRENTTIMETIMESTAMP_MSB_BYTE 7 + +#define RESERVED_VALUE 0xFF + +template +MuscleOxygenBaseCommands::MuscleOxygenBaseCommands() : CoreDataPage() {} + +template +uint8_t MuscleOxygenBaseCommands::getCommandId() { + return this->get8BitValue(COMMANDID_BYTE); +} + +template +uint8_t MuscleOxygenBaseCommands::getLocalTimeOffset() { + return this->get8BitValue(LOCALTIMEOFFSET_BYTE); +} + +template +uint32_t MuscleOxygenBaseCommands::getCurrentTimestamp() { + return this->get32BitValue(CURRENTTIMETIMESTAMP_LSB_BYTE, + CURRENTTIMETIMESTAMP_MSB_BYTE); +} + +template class MuscleOxygenBaseCommands; +template class MuscleOxygenBaseCommands; + +MuscleOxygenCommands::MuscleOxygenCommands(AntRxDataResponse& dp) : + MuscleOxygenBaseMainDataPage(dp), + MuscleOxygenBaseCommands() {} + +MuscleOxygenCommandsMsg::MuscleOxygenCommandsMsg() : + MuscleOxygenBaseMainDataPageMsg(ANTPLUS_MUSCLEOXYGEN_DATAPAGE_COMMANDS_NUMBER), + MuscleOxygenBaseCommands() { + set8BitValue(RESERVED_VALUE, RESERVED_BYTE); +} + +void MuscleOxygenCommandsMsg::setCommandId(uint8_t id) { + set8BitValue(id, COMMANDID_BYTE); +} + +void MuscleOxygenCommandsMsg::setLocalTimeOffset(uint8_t offset) { + set8BitValue(offset, LOCALTIMEOFFSET_BYTE); +} + +void MuscleOxygenCommandsMsg::setCurrentTimestamp(uint32_t timestamp) { + set32BitValue(timestamp, CURRENTTIMETIMESTAMP_LSB_BYTE, + CURRENTTIMETIMESTAMP_MSB_BYTE); +} diff --git a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenCommands.h b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenCommands.h new file mode 100644 index 0000000..183c2e2 --- /dev/null +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenCommands.h @@ -0,0 +1,32 @@ +#ifndef ANTPLUS_MUSCLEOXYGENCOMMANDS_h +#define ANTPLUS_MUSCLEOXYGENCOMMANDS_h + +#include + +template +class MuscleOxygenBaseCommands : public virtual CoreDataPage { +public: + MuscleOxygenBaseCommands(); + uint8_t getCommandId(); + uint8_t getLocalTimeOffset(); + uint32_t getCurrentTimestamp(); +}; + +class MuscleOxygenCommands : + public MuscleOxygenBaseMainDataPage, + public MuscleOxygenBaseCommands { +public: + explicit MuscleOxygenCommands(AntRxDataResponse& dp); +}; + +class MuscleOxygenCommandsMsg : + public MuscleOxygenBaseMainDataPageMsg, + public MuscleOxygenBaseCommands { +public: + MuscleOxygenCommandsMsg(); + void setCommandId(uint8_t id); + void setLocalTimeOffset(uint8_t offset); + void setCurrentTimestamp(uint32_t timestamp); +}; + +#endif // ANTPLUS_MUSCLEOXYGENMUSCLEOXYGENDATA_h diff --git a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.cpp b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.cpp new file mode 100644 index 0000000..5f06877 --- /dev/null +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.cpp @@ -0,0 +1,117 @@ +#include +#include + +#define EVENTCOUNT_BYTE 1 +#define NOTIFICATIONS_BYTE 2 +#define CAPABILITIES_BYTE 3 +#define ANTFSSUPPORT_MASK 0x01 +#define MEASUREMENTINTERVAL_MASK 0x0E +#define MEASUREMENTINTERVAL_SHIFT 1 +#define TOTALHEMOGLOBINCONCENTRATION_LSB_BYTE 4 +#define TOTALHEMOGLOBINCONCENTRATION_MSB_BYTE 5 +#define TOTALHEMOGLOBINCONCENTRATION_MASK 0x0FFF +#define PREVIOUSSATURATEDHEMOGLOBINPERCENTAGE_LSB_BYTE 5 +#define PREVIOUSSATURATEDHEMOGLOBINPERCENTAGE_MSB_BYTE 6 +#define PREVIOUSSATURATEDHEMOGLOBINPERCENTAGE_MASK 0x3FF0 +#define PREVIOUSSATURATEDHEMOGLOBINPERCENTAGE_SHIFT 4 +#define CURRENTSATURATEDHEMOGLOBINPERCENTAGE_LSB_BYTE 6 +#define CURRENTSATURATEDHEMOGLOBINPERCENTAGE_MSB_BYTE 7 +#define CURRENTSATURATEDHEMOGLOBINPERCENTAGE_MASK 0xFFC0 +#define CURRENTSATURATEDHEMOGLOBINPERCENTAGE_SHIFT 6 + +template +MuscleOxygenBaseMuscleOxygenData::MuscleOxygenBaseMuscleOxygenData() : CoreDataPage() {} + +template +uint8_t MuscleOxygenBaseMuscleOxygenData::getEventCount() { + return this->get8BitValue(EVENTCOUNT_BYTE); +} + +template +uint8_t MuscleOxygenBaseMuscleOxygenData::getNotifications() { + return this->get8BitValue(NOTIFICATIONS_BYTE); +} + +template +uint8_t MuscleOxygenBaseMuscleOxygenData::getAntFSSupport() { + return this->get8BitValue(CAPABILITIES_BYTE, ANTFSSUPPORT_MASK); +} + +template +uint8_t MuscleOxygenBaseMuscleOxygenData::getMeasurementInterval() { + return this->get8BitValue(CAPABILITIES_BYTE, + MEASUREMENTINTERVAL_MASK, + MEASUREMENTINTERVAL_SHIFT); +} + +template +uint16_t MuscleOxygenBaseMuscleOxygenData::getTotalHemoglobinConcentration() { + return this->get16BitValue(TOTALHEMOGLOBINCONCENTRATION_LSB_BYTE, + TOTALHEMOGLOBINCONCENTRATION_MSB_BYTE, + TOTALHEMOGLOBINCONCENTRATION_MASK); +} + +template +uint16_t MuscleOxygenBaseMuscleOxygenData::getPreviousSaturatedHemoglobinPercentage() { + return this->get16BitValue(PREVIOUSSATURATEDHEMOGLOBINPERCENTAGE_LSB_BYTE, + PREVIOUSSATURATEDHEMOGLOBINPERCENTAGE_MSB_BYTE, + PREVIOUSSATURATEDHEMOGLOBINPERCENTAGE_MASK, + PREVIOUSSATURATEDHEMOGLOBINPERCENTAGE_MASK); +} + +template +uint16_t MuscleOxygenBaseMuscleOxygenData::getCurrentSaturatedHemoglobinPercentage() { + return this->get16BitValue(CURRENTSATURATEDHEMOGLOBINPERCENTAGE_LSB_BYTE, + CURRENTSATURATEDHEMOGLOBINPERCENTAGE_MSB_BYTE, + CURRENTSATURATEDHEMOGLOBINPERCENTAGE_MASK, + CURRENTSATURATEDHEMOGLOBINPERCENTAGE_SHIFT); +} + +MuscleOxygenMuscleOxygenDataMsg::MuscleOxygenMuscleOxygenDataMsg() : + MuscleOxygenBaseMainDataPageMsg(ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_NUMBER), + MuscleOxygenBaseMuscleOxygenData() { + setTotalHemoglobinConcentration( + ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_TOTALHEMOGLOBINCONCENTRATION_INVALID); + setPreviousSaturatedHemoglobinPercentage( + ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_PREVIOUSSATURATEDHEMOGLOBINPERCENTAGE_INVALID); + setCurrentSaturatedHemoglobinPercentage( + ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_CURRENTSATURATEDHEMOGLOBINPERCENTAGE_INVALID); +} + +void MuscleOxygenMuscleOxygenDataMsg::setEventCount(uint8_t n) { + set8BitValue(n, EVENTCOUNT_BYTE); +} + +void MuscleOxygenMuscleOxygenDataMsg::setNotifications(uint8_t notifications) { + set8BitValue(notifications, NOTIFICATIONS_BYTE); +} + +void MuscleOxygenMuscleOxygenDataMsg::setAntFSSupport(uint8_t support) { + set8BitValue(support, CAPABILITIES_BYTE, ANTFSSUPPORT_MASK); +} + +void MuscleOxygenMuscleOxygenDataMsg::setMeasurementInterval(uint8_t interval) { + set8BitValue(interval, CAPABILITIES_BYTE, + MEASUREMENTINTERVAL_MASK, + MEASUREMENTINTERVAL_SHIFT); +} + +void MuscleOxygenMuscleOxygenDataMsg::setTotalHemoglobinConcentration(uint16_t concentration) { + set16BitValue(concentration, TOTALHEMOGLOBINCONCENTRATION_LSB_BYTE, + TOTALHEMOGLOBINCONCENTRATION_MSB_BYTE, + TOTALHEMOGLOBINCONCENTRATION_MASK); +} + +void MuscleOxygenMuscleOxygenDataMsg::setPreviousSaturatedHemoglobinPercentage(uint16_t percent) { + set16BitValue(percent, PREVIOUSSATURATEDHEMOGLOBINPERCENTAGE_LSB_BYTE, + PREVIOUSSATURATEDHEMOGLOBINPERCENTAGE_MSB_BYTE, + PREVIOUSSATURATEDHEMOGLOBINPERCENTAGE_MASK, + PREVIOUSSATURATEDHEMOGLOBINPERCENTAGE_SHIFT); +} + +void MuscleOxygenMuscleOxygenDataMsg::setCurrentSaturatedHemoglobinPercentage(uint16_t percent) { + set16BitValue(percent, CURRENTSATURATEDHEMOGLOBINPERCENTAGE_LSB_BYTE, + CURRENTSATURATEDHEMOGLOBINPERCENTAGE_MSB_BYTE, + CURRENTSATURATEDHEMOGLOBINPERCENTAGE_MASK, + CURRENTSATURATEDHEMOGLOBINPERCENTAGE_SHIFT); +} diff --git a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.h b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.h new file mode 100644 index 0000000..bcdf394 --- /dev/null +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.h @@ -0,0 +1,31 @@ +#ifndef ANTPLUS_MUSCLEOXYGENMUSCLEOXYGENDATA_h +#define ANTPLUS_MUSCLEOXYGENMUSCLEOXYGENDATA_h + +#include + +template +class MuscleOxygenBaseMuscleOxygenData : public virtual CoreDataPage { +public: + MuscleOxygenBaseMuscleOxygenData(); + uint8_t getEventCount(); + uint8_t getNotifications(); + uint8_t getAntFSSupport(); + uint8_t getMeasurementInterval(); + uint16_t getTotalHemoglobinConcentration(); + uint16_t getPreviousSaturatedHemoglobinPercentage(); + uint16_t getCurrentSaturatedHemoglobinPercentage(); +}; + +class MuscleOxygenMuscleOxygenDataMsg : public MuscleOxygenBaseMainDataPageMsg, public MuscleOxygenBaseMuscleOxygenData { +public: + MuscleOxygenMuscleOxygenDataMsg(); + void setEventCount(uint8_t n); + void setNotifications(uint8_t notficications); + void setAntFSSupport(uint8_t support); + void setMeasurementInterval(uint8_t interval); + void setTotalHemoglobinConcentration(uint16_t concentration); + void setPreviousSaturatedHemoglobinPercentage(uint16_t percent); + void setCurrentSaturatedHemoglobinPercentage(uint16_t percent); +}; + +#endif // ANTPLUS_MUSCLEOXYGENMUSCLEOXYGENDATA_h diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp new file mode 100644 index 0000000..77a1a92 --- /dev/null +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp @@ -0,0 +1,79 @@ +#include +#include +#include + +#define MONITOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT +#define MONITOR_TRANSMISSIONTYPE (TRANSMISSION_TYPE_INDEPENDENT | TRANSMISSION_TYPE_GLOBALDATAPGESUSED) + +ProfileMuscleOxygenMonitor::ProfileMuscleOxygenMonitor( uint16_t deviceNumber, uint8_t transmissionType, uint32_t flags) : + BaseMasterProfile(deviceNumber, + ANTPLUS_TRANSMISSION_SET_LSN( + transmissionType, MONITOR_TRANSMISSIONTYPE)) +{ + setChannelConfig(); + // change the background cycle loop size + _backgroundStepSize = 2 + ((flags & ANTPLUS_MUSCLEOXYGEN_FLAGS_BATTERYSTATUS_SUPPORTED) ? 1 : 0); +} + +void ProfileMuscleOxygenMonitor::setChannelConfig() { + setChannelType(MONITOR_CHANNELTYPE); + setDeviceType(ANTPLUS_MUSCLEOXYGEN_DEVICETYPE); + setChannelPeriod(MUSCLEOXYGEN_CHANNELPERIOD); + setSearchTimeout(MUSCLEOXYGEN_SEARCHTIMEOUT); +} + +bool ProfileMuscleOxygenMonitor::isDataPageValid(uint8_t dataPage) { + switch (dataPage) { + case ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER: + return true; + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER: + // TODO use callback + return _flags & ANTPLUS_MUSCLEOXYGEN_FLAGS_BATTERYSTATUS_SUPPORTED; + } + return false; +} + +void ProfileMuscleOxygenMonitor::transmitNextDataPage() { + if (_patternStep++ < 64) { + transmitMuscleOxygenMuscleOxygenDataMsg(); + } + else { + if (++_backgroundStep == _backgroundStepSize) { + _backgroundStep = 0; + } + if ((_backgroundStep % _backgroundStepSize) == 0) { + transmitManufacturerInformationMsg(); + } else if ((_backgroundStep % _backgroundStepSize) == 1) { + transmitProductInformationMsg(); + } else if (_flags & ANTPLUS_MUSCLEOXYGEN_FLAGS_BATTERYSTATUS_SUPPORTED) { + transmitBatteryStatusMsg(); + } + _patternStep = 0; + } +} + +void ProfileMuscleOxygenMonitor::transmitManufacturerInformationMsg() { + ManufacturersInformationMsg msg; + _createManufacturersInformationMsg.call(msg); + send(msg); +} + +void ProfileMuscleOxygenMonitor::transmitProductInformationMsg() { + ProductInformationMsg msg; + _createProductInformationMsg.call(msg); + send(msg); +} + +void ProfileMuscleOxygenMonitor::transmitMuscleOxygenMuscleOxygenDataMsg() { + MuscleOxygenMuscleOxygenDataMsg msg; + _createMuscleOxygenMuscleOxygenDataMsg.call(msg); + send(msg); +} + +void ProfileMuscleOxygenMonitor::transmitBatteryStatusMsg() { + BatteryStatusMsg msg; + _createBatteryStatusMsg.call(msg); + send(msg); +} diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h new file mode 100644 index 0000000..5ba8b9d --- /dev/null +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h @@ -0,0 +1,52 @@ +#ifndef ANTPLUS_PROFILEMUSCLEOXYGENMONITOR_h +#define ANTPLUS_PROFILEMUSCLEOXYGENMONITOR_h + +#include +#include +#include +#include + +class ProfileMuscleOxygenMonitor : public BaseMasterProfile { +public: + explicit ProfileMuscleOxygenMonitor(uint16_t deviceNumber, uint8_t transmissionType = 0, uint32_t flags = 0); + + /** + * Register callback to populate Muscle Oxygen data messages (Datapage 0x01) + */ + void createMuscleOxygenMuscleOxygenDataMsg(void(*func)(MuscleOxygenMuscleOxygenDataMsg&, uintptr_t), uintptr_t data = 0) { _createMuscleOxygenMuscleOxygenDataMsg.set(func, data); } + /** + * Register callback to populate manufacturer information data messages (Datapage 0x50) + */ + void createManufacturerInformationMsg(void(*func)(ManufacturersInformationMsg&, uintptr_t), uintptr_t data = 0) { _createManufacturersInformationMsg.set(func, data); } + /** + * Register callback to populate product information data messages (Datapage 0x51) + */ + void createProductInformationMsg(void(*func)(ProductInformationMsg&, uintptr_t), uintptr_t data = 0) { _createProductInformationMsg.set(func, data); } + /** + * Register callback to populate battery status data messages (Datapage 0x52) + */ + void createProductInformationMsg(void(*func)(BatteryStatusMsg&, uintptr_t), uintptr_t data = 0) { _createBatteryStatusMsg.set(func, data); } + +protected: + void transmitNextDataPage() override; + bool isDataPageValid(uint8_t dataPage) override; + +private: + void setChannelConfig(); + void transmitMuscleOxygenMuscleOxygenDataMsg(); + void transmitManufacturerInformationMsg(); + void transmitProductInformationMsg(); + void transmitBatteryStatusMsg(); + + uint8_t _patternStep = 0; + uint8_t _backgroundStep = 0; + uint8_t _backgroundStepSize = 0; + uint32_t _flags; + + AntCallback _createMuscleOxygenMuscleOxygenDataMsg = { .func = NULL }; + AntCallback _createManufacturersInformationMsg = { .func = NULL }; + AntCallback _createProductInformationMsg = { .func = NULL }; + AntCallback _createBatteryStatusMsg = { .func = NULL }; +}; + +#endif // ANTPLUS_PROFILEMUSCLEOXYGENMONITOR_h diff --git a/src/Profiles/Shifting/ANTPLUS_ProfileShiftingDataPages.h b/src/Profiles/Shifting/ANTPLUS_ProfileShiftingDataPages.h new file mode 100644 index 0000000..c555bb2 --- /dev/null +++ b/src/Profiles/Shifting/ANTPLUS_ProfileShiftingDataPages.h @@ -0,0 +1,6 @@ +#ifndef ANTPLUS_PROFILESHIFTINGDATAPAGES_h +#define ANTPLUS_PROFILESHIFTINGDATAPAGES_h + +#include + +#endif // ANTPLUS_PROFILESHIFTINGDATAPAGES_h diff --git a/src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h b/src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h new file mode 100644 index 0000000..aab6f43 --- /dev/null +++ b/src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h @@ -0,0 +1,39 @@ +#ifndef ANTPLUS_SHIFTINGPROFILEDEFINES_h +#define ANTPLUS_SHIFTINGPROFILEDEFINES_h + +#define ANTPLUS_SHIFTING_DEVICETYPE 34 + +/* Pages */ +#define ANTPLUS_SHIFTING_DATAPAGE_SHIFTSYSTEMSTATUS_NUMBER 1 + +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_SYSTEM 0 +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_FRONTDERAILLEUR 1 +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_REARDERAILLEUR 2 +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_LEFTSHIFTER 3 +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_RIGHTSHIFTER 4 +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_SHIFTER 5 +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_LEFTEXTENSIONSHIFTER 6 +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_RIGHTEXTENSIONSHIFTER 7 +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_EXTENSIONSHIFTER1 8 +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_LEFTEXTENSIONSHIFTER2 9 +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_RIGHTEXTENSIONSHIFTER2 10 +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_EXTENSIONSHIFTER2 11 +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_UNKNOWNIDENTIFIED 15 + +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_SYSTEM_FLAG (1 << ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_SYSTEM) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_FRONTDERAILLEUR_FLAG (1 << ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_FRONTDERAILLEUR) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_REARDERAILLEUR_FLAG (1 << ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_REARDERAILLEUR) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_LEFTSHIFTER_FLAG (1 << ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_LEFTSHIFTER) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_RIGHTSHIFTER_FLAG (1 << ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_RIGHTSHIFTER) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_SHIFTER_FLAG (1 << ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_SHIFTER) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_LEFTEXTENSIONSHIFTER_FLAG (1 << ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_LEFTEXTENSIONSHIFTER) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_RIGHTEXTENSIONSHIFTER_FLAG (1 << ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_RIGHTEXTENSIONSHIFTER) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_EXTENSIONSHIFTER1_FLAG (1 << ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_EXTENSIONSHIFTER1) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_LEFTEXTENSIONSHIFTER2_FLAG (1 << ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_LEFTEXTENSIONSHIFTER2) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_RIGHTEXTENSIONSHIFTER2_FLAG (1 << ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_RIGHTEXTENSIONSHIFTER2) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_EXTENSIONSHIFTER2_FLAG (1 << ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_EXTENSIONSHIFTER2) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_UNKNOWNIDENTIFIED_FLAG (1 << ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_UNKNOWNIDENTIFIED) + +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_NOTUSED 0xFF + +#endif // ANTPLUS_SHIFTINGPROFILEDEFINES_h diff --git a/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h b/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h new file mode 100644 index 0000000..d4be8db --- /dev/null +++ b/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h @@ -0,0 +1,13 @@ +#ifndef ANTPLUS_SHIFTINGPROFILEPRIVATEDEFINES_h +#define ANTPLUS_SHIFTINGPROFILEPRIVATEDEFINES_h + +/* Channel Config */ +#define SHIFTING_CHANNELPERIOD 8192 +// 30 / 2.5 = 12 +#define SHIFTING_SEARCHTIMEOUT 12 + +// Transmission pattern math +#define ANTPLUS_SHIFTING_BACKGROUNDPAGE_INTERLEAVEINTERVAL 260 +#define ANTPLUS_SHIFTING_NUMBERBACKGROUNDPAGES_PERCOMPONENT 3 + +#endif // ANTPLUS_SHIFTINGPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/Shifting/ANTPLUS_ShiftingProfile.h b/src/Profiles/Shifting/ANTPLUS_ShiftingProfile.h new file mode 100644 index 0000000..f1ef9db --- /dev/null +++ b/src/Profiles/Shifting/ANTPLUS_ShiftingProfile.h @@ -0,0 +1,13 @@ +#ifndef ANTPLUS_SHIFTINGPROFILE_h +#define ANTPLUS_SHIFTINGPROFILE_h + +// General Definitions +#include + +// Datapages +#include + +// Profile Classes +#include + +#endif // ANTPLUS_SHIFTINGPROFILE_h diff --git a/src/Profiles/Shifting/DataPages/ANTPLUS_ShiftingBaseMainDataPage.cpp b/src/Profiles/Shifting/DataPages/ANTPLUS_ShiftingBaseMainDataPage.cpp new file mode 100644 index 0000000..25168a2 --- /dev/null +++ b/src/Profiles/Shifting/DataPages/ANTPLUS_ShiftingBaseMainDataPage.cpp @@ -0,0 +1,13 @@ +#include +#include +#include + +ShiftingBaseMainDataPage::ShiftingBaseMainDataPage(AntRxDataResponse& dp) : + BaseDataPage(dp) {} + +ShiftingBaseMainDataPageMsg::ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber) : + BaseDataPageMsg() +{ + setDataBuffer(_buffer); + set8BitValue(dataPageNumber, ANTPLUS_DEFAULT_DATAPAGE_BYTE); +} diff --git a/src/Profiles/Shifting/DataPages/ANTPLUS_ShiftingBaseMainDataPage.h b/src/Profiles/Shifting/DataPages/ANTPLUS_ShiftingBaseMainDataPage.h new file mode 100644 index 0000000..c6b8dda --- /dev/null +++ b/src/Profiles/Shifting/DataPages/ANTPLUS_ShiftingBaseMainDataPage.h @@ -0,0 +1,19 @@ +#ifndef ANTPLUS_SHIFTINGBASEMAINDATAPAGE_h +#define ANTPLUS_SHIFTINGBASEMAINDATAPAGE_h + +#include +#include + +class ShiftingBaseMainDataPage : public BaseDataPage { +public: + explicit ShiftingBaseMainDataPage(AntRxDataResponse& dp); +}; + +class ShiftingBaseMainDataPageMsg : public BaseDataPageMsg { +public: + explicit ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber); +protected: + uint8_t _buffer[MESSAGE_SIZE] = {0}; +}; + +#endif // ANTPLUS_SHIFTINGBASEMAINDATAPAGE_h diff --git a/src/Profiles/Shifting/DataPages/ANTPLUS_ShiftingShiftSystemStatus.cpp b/src/Profiles/Shifting/DataPages/ANTPLUS_ShiftingShiftSystemStatus.cpp new file mode 100644 index 0000000..0ca1808 --- /dev/null +++ b/src/Profiles/Shifting/DataPages/ANTPLUS_ShiftingShiftSystemStatus.cpp @@ -0,0 +1,164 @@ +#include +#include + +#define EVENTCOUNT_BYTE 1 +#define RESERVED_BYTE 2 +#define RESERVED_VALUE 0xFF +#define CURRENTGEAR_BYTE 3 +#define CURRENTGEAR_REAR_MASK 0x1F +#define CURRENTGEAR_FRONT_MASK 0xE0 +#define CURRENTGEAR_FRONT_SHIFT 5 +#define TOTALNUMBEROFGEARS_BYTE 4 +#define TOTALNUMBEROFGEARS_REAR_MASK 0x1F +#define TOTALNUMBEROFGEARS_FRONT_MASK 0xE0 +#define TOTALNUMBEROFGEARS_FRONT_SHIFT 5 +#define INVALIDINBOARDSHIFTCOUNT_REAR_BYTE 5 +#define INVALIDINBOARDSHIFTCOUNT_REAR_MASK 0x0F +#define INVALIDOUTBOARDSHIFTCOUNT_REAR_BYTE 5 +#define INVALIDOUTBOARDSHIFTCOUNT_REAR_MASK 0xF0 +#define INVALIDOUTBOARDSHIFTCOUNT_REAR_SHIFT 4 +#define INVALIDINBOARDSHIFTCOUNT_FRONT_BYTE 6 +#define INVALIDINBOARDSHIFTCOUNT_FRONT_MASK 0x0F +#define INVALIDOUTBOARDSHIFTCOUNT_FRONT_BYTE 6 +#define INVALIDOUTBOARDSHIFTCOUNT_FRONT_MASK 0xF0 +#define INVALIDOUTBOARDSHIFTCOUNT_FRONT_SHIFT 4 +#define SHIFTFAILURECOUNT_BYTE 7 +#define SHIFTFAILURECOUNT_REAR_MASK 0x0F +#define SHIFTFAILURECOUNT_FRONT_MASK 0xF0 +#define SHIFTFAILURECOUNT_FRONT_SHIFT 4 + +template +ShiftingBaseShiftSystemStatus::ShiftingBaseShiftSystemStatus() : CoreDataPage() {} + +template +uint8_t ShiftingBaseShiftSystemStatus::getEventCount() { + return this->get8BitValue(EVENTCOUNT_BYTE); +} + +template +uint8_t ShiftingBaseShiftSystemStatus::getCurrentGearRear() { + return this->get8BitValue(CURRENTGEAR_BYTE, CURRENTGEAR_REAR_MASK); +} + +template +uint8_t ShiftingBaseShiftSystemStatus::getCurrentGearFront() { + return this->get8BitValue(CURRENTGEAR_BYTE, + CURRENTGEAR_FRONT_MASK, + CURRENTGEAR_FRONT_SHIFT); +} + +template +uint8_t ShiftingBaseShiftSystemStatus::getTotalNumbersGearRear() { + return this->get8BitValue(TOTALNUMBEROFGEARS_BYTE, TOTALNUMBEROFGEARS_REAR_MASK); +} + +template +uint8_t ShiftingBaseShiftSystemStatus::getTotalNumbersGearFront() { + return this->get8BitValue(TOTALNUMBEROFGEARS_BYTE, + TOTALNUMBEROFGEARS_FRONT_MASK, + TOTALNUMBEROFGEARS_FRONT_SHIFT); +} + +template +uint8_t ShiftingBaseShiftSystemStatus::getInvalidInboardShiftCountRear() { + return this->get8BitValue(INVALIDINBOARDSHIFTCOUNT_REAR_BYTE, + INVALIDINBOARDSHIFTCOUNT_REAR_MASK); +} + +template +uint8_t ShiftingBaseShiftSystemStatus::getInvalidOutboardShiftCountRear() { + return this->get8BitValue(INVALIDOUTBOARDSHIFTCOUNT_REAR_BYTE, + INVALIDOUTBOARDSHIFTCOUNT_REAR_MASK, + INVALIDOUTBOARDSHIFTCOUNT_REAR_SHIFT); +} + +template +uint8_t ShiftingBaseShiftSystemStatus::getInvalidInboardShiftCountFront() { + return this->get8BitValue(INVALIDINBOARDSHIFTCOUNT_FRONT_BYTE, + INVALIDINBOARDSHIFTCOUNT_FRONT_MASK); +} + +template +uint8_t ShiftingBaseShiftSystemStatus::getInvalidOutboardShiftCountFront() { + return this->get8BitValue(INVALIDOUTBOARDSHIFTCOUNT_FRONT_BYTE, + INVALIDOUTBOARDSHIFTCOUNT_FRONT_MASK, + INVALIDOUTBOARDSHIFTCOUNT_FRONT_SHIFT); +} + +template +uint8_t ShiftingBaseShiftSystemStatus::getShiftFailureCountRear() { + return this->get8BitValue(SHIFTFAILURECOUNT_BYTE, SHIFTFAILURECOUNT_REAR_MASK); +} + +template +uint8_t ShiftingBaseShiftSystemStatus::getShiftFailureCountFront() { + return this->get8BitValue(SHIFTFAILURECOUNT_BYTE, + SHIFTFAILURECOUNT_FRONT_MASK, + SHIFTFAILURECOUNT_FRONT_SHIFT); +} + +template class ShiftingBaseShiftSystemStatus; +template class ShiftingBaseShiftSystemStatus; + +ShiftingShiftSystemStatus::ShiftingShiftSystemStatus(AntRxDataResponse& dp) : + ShiftingBaseMainDataPage(dp), + ShiftingBaseShiftSystemStatus() {} + +ShiftingShiftSystemStatusMsg::ShiftingShiftSystemStatusMsg() : + ShiftingBaseMainDataPageMsg(ANTPLUS_SHIFTING_DATAPAGE_SHIFTSYSTEMSTATUS_NUMBER), + ShiftingBaseShiftSystemStatus() { + set8BitValue(RESERVED_VALUE, RESERVED_BYTE); +} + +void ShiftingShiftSystemStatusMsg::setEventCount(uint8_t n) { + set8BitValue(n, EVENTCOUNT_BYTE); +} + +void ShiftingShiftSystemStatusMsg::setCurrentGearRear(uint8_t cgr) { + set8BitValue(cgr, CURRENTGEAR_BYTE, CURRENTGEAR_REAR_MASK); +} + +void ShiftingShiftSystemStatusMsg::setCurrentGearFront(uint8_t cgf) { + set8BitValue(cgf, CURRENTGEAR_BYTE, CURRENTGEAR_FRONT_MASK, + CURRENTGEAR_FRONT_SHIFT); +} + +void ShiftingShiftSystemStatusMsg::setTotalNumbersGearRear(uint8_t tgr) { + set8BitValue(tgr, TOTALNUMBEROFGEARS_BYTE, TOTALNUMBEROFGEARS_REAR_MASK); +} + +void ShiftingShiftSystemStatusMsg::setTotalNumbersGearFront(uint8_t tgf) { + set8BitValue(tgf, TOTALNUMBEROFGEARS_BYTE, TOTALNUMBEROFGEARS_FRONT_MASK, + TOTALNUMBEROFGEARS_FRONT_SHIFT); +} + +void ShiftingShiftSystemStatusMsg::setInvalidInboardShiftCountRear(uint8_t isr) { + set8BitValue(isr, INVALIDINBOARDSHIFTCOUNT_REAR_BYTE, + INVALIDINBOARDSHIFTCOUNT_REAR_MASK); +} + +void ShiftingShiftSystemStatusMsg::setInvalidOutboardShiftCountRear(uint8_t osr) { + set8BitValue(osr, INVALIDOUTBOARDSHIFTCOUNT_REAR_BYTE, + INVALIDOUTBOARDSHIFTCOUNT_REAR_MASK, + INVALIDOUTBOARDSHIFTCOUNT_REAR_SHIFT); +} + +void ShiftingShiftSystemStatusMsg::setInvalidInboardShiftCountFront(uint8_t isf) { + set8BitValue(isf, INVALIDINBOARDSHIFTCOUNT_FRONT_BYTE, + INVALIDINBOARDSHIFTCOUNT_FRONT_MASK); +} + +void ShiftingShiftSystemStatusMsg::setInvalidOutboardShiftCountFront(uint8_t osf) { + set8BitValue(osf, INVALIDOUTBOARDSHIFTCOUNT_FRONT_BYTE, + INVALIDOUTBOARDSHIFTCOUNT_FRONT_MASK, + INVALIDOUTBOARDSHIFTCOUNT_FRONT_SHIFT); +} + +void ShiftingShiftSystemStatusMsg::setShiftFailureCountRear(uint8_t sfr) { + set8BitValue(sfr, SHIFTFAILURECOUNT_BYTE, SHIFTFAILURECOUNT_REAR_MASK); +} + +void ShiftingShiftSystemStatusMsg::setShiftFailureCountFront(uint8_t sff) { + set8BitValue(sff, SHIFTFAILURECOUNT_BYTE, SHIFTFAILURECOUNT_FRONT_MASK, + SHIFTFAILURECOUNT_FRONT_SHIFT); +} diff --git a/src/Profiles/Shifting/DataPages/ANTPLUS_ShiftingShiftSystemStatus.h b/src/Profiles/Shifting/DataPages/ANTPLUS_ShiftingShiftSystemStatus.h new file mode 100644 index 0000000..4ad920d --- /dev/null +++ b/src/Profiles/Shifting/DataPages/ANTPLUS_ShiftingShiftSystemStatus.h @@ -0,0 +1,44 @@ +#ifndef ANTPLUS_SHIFTINGSHIFTSYSTEMSTATUS_h +#define ANTPLUS_SHIFTINGSHIFTSYSTEMSTATUS_h + +#include + +template +class ShiftingBaseShiftSystemStatus : virtual public CoreDataPage { +public: + ShiftingBaseShiftSystemStatus(); + uint8_t getEventCount(); + uint8_t getCurrentGearRear(); + uint8_t getCurrentGearFront(); + uint8_t getTotalNumbersGearRear(); + uint8_t getTotalNumbersGearFront(); + uint8_t getInvalidInboardShiftCountRear(); + uint8_t getInvalidOutboardShiftCountRear(); + uint8_t getInvalidInboardShiftCountFront(); + uint8_t getInvalidOutboardShiftCountFront(); + uint8_t getShiftFailureCountRear(); + uint8_t getShiftFailureCountFront(); +}; + +class ShiftingShiftSystemStatus : public ShiftingBaseMainDataPage, public ShiftingBaseShiftSystemStatus { +public: + explicit ShiftingShiftSystemStatus(AntRxDataResponse& dp); +}; + +class ShiftingShiftSystemStatusMsg : public ShiftingBaseMainDataPageMsg, public ShiftingBaseShiftSystemStatus { +public: + ShiftingShiftSystemStatusMsg(); + void setEventCount(uint8_t n); + void setCurrentGearRear(uint8_t cgr); + void setCurrentGearFront(uint8_t cgf); + void setTotalNumbersGearRear(uint8_t tgr); + void setTotalNumbersGearFront(uint8_t tgf); + void setInvalidInboardShiftCountRear(uint8_t isr); + void setInvalidOutboardShiftCountRear(uint8_t osr); + void setInvalidInboardShiftCountFront(uint8_t isf); + void setInvalidOutboardShiftCountFront(uint8_t osf); + void setShiftFailureCountRear(uint8_t sfr); + void setShiftFailureCountFront(uint8_t sff); +}; + +#endif // ANTPLUS_SHIFTINGSHIFTSYSTEMSTATUS_h diff --git a/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingDisplay.cpp b/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingDisplay.cpp new file mode 100644 index 0000000..02b52c0 --- /dev/null +++ b/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingDisplay.cpp @@ -0,0 +1 @@ +#define ANTPLUS_SHIFTING_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE diff --git a/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.cpp b/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.cpp new file mode 100644 index 0000000..510f0d8 --- /dev/null +++ b/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.cpp @@ -0,0 +1,198 @@ +#include +#include +#include +#include + +#define SHIFTER_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT +#define SHIFTER_TRANSMISSIONTYPE (TRANSMISSION_TYPE_INDEPENDENT | TRANSMISSION_TYPE_GLOBALDATAPGESUSED) + +ProfileShiftingShifter::ProfileShiftingShifter(uint16_t deviceNumber, uint8_t transmissionType, uint16_t componentFlags) : + BaseMasterProfile(deviceNumber, + ANTPLUS_TRANSMISSION_SET_LSN( + transmissionType, SHIFTER_TRANSMISSIONTYPE)), + _componentFlags(componentFlags) +{ + setChannelConfig(); + setAckMessageUsage(false); + + if (isMultiComponentDevice()) { + // calculate interleave step + while (componentFlags) { + componentFlags &= (componentFlags - 1); + _componentCount++; + } + } else { + _componentCount = 1; + _componentState = 0xF; + } + _interleaveStep = ANTPLUS_SHIFTING_BACKGROUNDPAGE_INTERLEAVEINTERVAL / + (ANTPLUS_SHIFTING_NUMBERBACKGROUNDPAGES_PERCOMPONENT * _componentCount); +} + +void ProfileShiftingShifter::setChannelConfig() { + setChannelType(SHIFTER_CHANNELTYPE); + setDeviceType(ANTPLUS_SHIFTING_DEVICETYPE); + setChannelPeriod(SHIFTING_CHANNELPERIOD); + setSearchTimeout(SHIFTING_SEARCHTIMEOUT); +} + +bool ProfileShiftingShifter::isDataPageValid(uint8_t dataPage) +{ + switch (dataPage) { + case ANTPLUS_SHIFTING_DATAPAGE_SHIFTSYSTEMSTATUS_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER: + return true; + } + return false; +} + +void ProfileShiftingShifter::transmitNextDataPage() { + if (_patternStep++ < _interleaveStep || _shiftCounter--) { + transmitShiftingMainPageMsg(); + } else { + transmitBackgroundDataPage(); + _patternStep -= _interleaveStep; + } +} + +void ProfileShiftingShifter::transmitBackgroundDataPage() { + _backgroundStep += 1; + switch (_backgroundStep) { + case 0: + transmitMultiComponentSystemManufacturersInformationMsg(); + break; + case 1: + transmitMultiComponentSystemProductInformationMsg(); + break; + case 2: + transmitBatteryStatusMsg(); + // prevent roll overs + _backgroundStep = 0; + + // Don't adjust state if we are handling a request + if (isMultiComponentDevice() && !isRequestedPagePending()) { + // knock out component bit + _componentState &= (_componentState - 1); + + if (!_componentState) { + // reset back to first component + _componentState = _componentFlags; + } + } + break; + } +} + +void ProfileShiftingShifter::onBroadcastData(BroadcastData& msg) { + BaseDataPage dp(msg); + uint8_t dataPage = dp.getDataPageNumber(); + bool called = false; + + BaseMasterProfile::onBroadcastData(msg); + + switch (dataPage) { + // Display always should be using acknowledged messages + } + + if (!called) { + callOnOtherDataPage(msg); + } +} + +void ProfileShiftingShifter::onAcknowledgedData(AcknowledgedData& msg) { + BaseDataPage dp(msg); + uint8_t dataPage = dp.getDataPageNumber(); + bool called = false; + + BaseMasterProfile::onAcknowledgedData(msg); + + switch (dataPage) { + + case ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER: + called = handleRequestDataPage(dp); + break; + } + + if (!called) { + callOnOtherDataPage(msg); + } +} + +bool ProfileShiftingShifter::isMultiComponentDevice() { + return _componentFlags != ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_NOTUSED; +} + +bool ProfileShiftingShifter::isSupportedComponent(uint8_t id) { + return _componentFlags & (1 << id); +} + +uint8_t ProfileShiftingShifter::getLowestBitPosition(uint16_t id) { + uint16_t lowestBitUnset = id & (id - 1); + uint8_t count = 0; + id ^= lowestBitUnset; + while (id) { + id >>= 1; + count++; + } + return count - 1; +} + +void ProfileShiftingShifter::transmitMultiComponentSystemManufacturersInformationMsg() { + MultiComponentSystemManufacturersInformationMsg msg; + msg.setComponentIdentifier(getLowestBitPosition(_componentState)); + msg.setNumberOfComponents(_componentCount); + _createMultiComponentSystemManufacturersInformationMsg.call(msg); + transmitMsg(msg); +} + +void ProfileShiftingShifter::transmitMultiComponentSystemProductInformationMsg() { + MultiComponentSystemProductInformationMsg msg; + msg.setComponentIdentifier(getLowestBitPosition(_componentState)); + msg.setNumberOfComponents(_componentCount); + _createMultiComponentSystemProductInformationMsg.call(msg); + transmitMsg(msg); +} + +void ProfileShiftingShifter::transmitBatteryStatusMsg() { + BatteryStatusMsg msg; + msg.setBatteryIdentifier(getLowestBitPosition(_componentState)); + msg.setNumberOfBatteries(_componentCount); + _createBatteryStatusMsg.call(msg); + transmitMsg(msg); +} + +void ProfileShiftingShifter::transmitShiftingMainPageMsg() { + ShiftingShiftSystemStatusMsg msg; + _createShiftingShiftSystemStatusMsg.call(msg); + // TODO track shifting internally and adjust transmission pattern accodingly (if shifter _shiftCounter = 4); + transmitMsg(msg); +} + +bool ProfileShiftingShifter::handleRequestDataPage(BaseDataPage& dataPage) { + RequestDataPage dp(dataPage); + uint8_t dataPageRequestedNumber = dp.getRequestedPageNumber(); + + switch (dataPageRequestedNumber) { + case ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER: + break; + default: + // skip check if not multicomponent message + return _onRequestDataPage.call(dp); + } + + // invalidate invalid component requests + if (isMultiComponentDevice()) { + if (isSupportedComponent(dp.getDescriptorByte1())) { + // override transmission state, will automatically reset after + _componentState = 1 << dp.getDescriptorByte1(); + } else { + invalidateDataPageRequest(); + } + } + + return _onRequestDataPage.call(dp); +} diff --git a/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.h b/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.h new file mode 100644 index 0000000..0af25f3 --- /dev/null +++ b/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.h @@ -0,0 +1,70 @@ +#ifndef ANTPLUS_PROFILESHIFTINGSHIFTER_h +#define ANTPLUS_PROFILESHIFTINGSHIFTER_h + +#include +#include +#include +#include + +class ProfileShiftingShifter : public BaseMasterProfile { +public: + explicit ProfileShiftingShifter(uint16_t deviceNumber, + uint8_t transmissionType = 0, + uint16_t componentsSupported = ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_SYSTEM_FLAG); + /** + * Register callback to populate default data messages (Datapage 1) + */ + void createShiftingShiftSystemStatusMsg(void(*func)(ShiftingShiftSystemStatusMsg&, uintptr_t), uintptr_t data = 0) { _createShiftingShiftSystemStatusMsg.set(func, data); } + /** + * Register callback to populate multi component system manufacturer information data messages (Datapage 78) + */ + void createMultiComponentSystemManufacturersInformationMsg(void(*func)(MultiComponentSystemManufacturersInformationMsg&, uintptr_t), uintptr_t data = 0) { _createMultiComponentSystemManufacturersInformationMsg.set(func, data); } + /** + * Register callback to populate multi component system product information data messages (Datapage 79) + */ + void createMultiComponentSystemProductInformationMsg(void(*func)(MultiComponentSystemProductInformationMsg&, uintptr_t), uintptr_t data = 0) { _createMultiComponentSystemProductInformationMsg.set(func, data); } + /** + * Register callback to populate battery status data messages (Datapage 82) + */ + void createBatteryStatusMsg(void(*func)(BatteryStatusMsg&, uintptr_t), uintptr_t data = 0) { _createBatteryStatusMsg.set(func, data); } + /** + * Register callback to handle incoming request dataPage. The profile will automatically + * adjust the broadcast pattern, there is no need for you to do anything with this message. + */ + void onRequestDataPage(void (*func)(RequestDataPage&, uintptr_t), uintptr_t data = 0) { _onRequestDataPage.set(func, data); } + +protected: + virtual void transmitNextDataPage() override; + virtual bool isDataPageValid(uint8_t dataPage) override; + void onAcknowledgedData(AcknowledgedData& msg) override; + void onBroadcastData(BroadcastData& msg) override; + +private: + void transmitShiftingMainPageMsg(); + void transmitMultiComponentSystemManufacturersInformationMsg(); + void transmitMultiComponentSystemProductInformationMsg(); + void transmitBatteryStatusMsg(); + bool handleRequestDataPage(BaseDataPage& dataPage); + bool isSupportedComponent(uint8_t id); + bool isMultiComponentDevice(); + uint8_t getLowestBitPosition(uint16_t id); + + void transmitBackgroundDataPage(); + void setChannelConfig(); + + uint8_t _patternStep = 0; + uint8_t _backgroundStep = 0; + uint8_t _shiftCounter = 0; + uint8_t _componentState = 0; + uint16_t _componentFlags; + uint8_t _interleaveStep; + uint8_t _componentCount = 0; + + AntCallback _createShiftingShiftSystemStatusMsg = { .func = NULL }; + AntCallback _createMultiComponentSystemManufacturersInformationMsg = { .func = NULL }; + AntCallback _createMultiComponentSystemProductInformationMsg = { .func = NULL }; + AntCallback _createBatteryStatusMsg = { .func = NULL }; + AntCallback _onRequestDataPage = { .func = NULL }; +}; + +#endif // ANTPLUS_PROFILESHIFTINGSHIFTER_h