From edebe73b449a0ebc64b72cd612f3c48752e7cfae Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 13 Jan 2018 23:16:52 -0700 Subject: [PATCH 001/241] Add constructors --- .../Environment/Monitor/ANTPLUS_ProfileEnvironmentMonitor.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Profiles/Environment/Monitor/ANTPLUS_ProfileEnvironmentMonitor.h b/src/Profiles/Environment/Monitor/ANTPLUS_ProfileEnvironmentMonitor.h index 533aebc..2b874fc 100644 --- a/src/Profiles/Environment/Monitor/ANTPLUS_ProfileEnvironmentMonitor.h +++ b/src/Profiles/Environment/Monitor/ANTPLUS_ProfileEnvironmentMonitor.h @@ -8,6 +8,9 @@ class ProfileEnvironmentMonitor : BaseMasterProfile { public: // TODO + ProfileEnvironmentMonitor(); + ProfileEnvironmentMonitor(uint16_t deviceNumber); + ProfileEnvironmentMonitor(uint16_t deviceNumber, uint8_t transmissionType); }; #endif // ANTPLUS_PROFILEENVIRONMENTMONITOR_h From da59eb93c8754557b126273ae3265b624e03b7d8 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 21 Apr 2018 16:05:44 -0600 Subject: [PATCH 002/241] Typo in defines --- examples/BicycleSpeedDisplay/BicycleSpeedDisplay.ino | 12 ++++++------ .../BicycleSpeed/ANTPLUS_BicycleSpeedDefines.h | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/BicycleSpeedDisplay/BicycleSpeedDisplay.ino b/examples/BicycleSpeedDisplay/BicycleSpeedDisplay.ino index 4954243..6f925e3 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/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedDefines.h b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedDefines.h index ae07e3f..ce9bdc3 100644 --- a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedDefines.h +++ b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedDefines.h @@ -1,12 +1,12 @@ #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_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_FLAGS_STOPINDICATOR 1 From f84149415099b5b041860f17a5da5153341e5fb0 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 11 Jun 2019 22:45:59 -0700 Subject: [PATCH 003/241] BaseMaster: Handle request datapages in the base profile This will unpack the data and build it into the API so profiles can handle the patterns easier. --- src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp b/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp index aa0ecbc..b1f2f29 100644 --- a/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp +++ b/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp @@ -14,8 +14,21 @@ void BaseMasterProfile::onChannelEventResponse(ChannelEventResponse& msg) { } void BaseMasterProfile::onAcknowledgedData(AcknowledgedData& msg) { + BaseDataPage bdp(msg); + if (msg.getDataPageNumber() == ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER) { + RequestDataPage rdp(msg); + _requestedPage = rdp.getRequestedPageNumber(); + if (rdp.transmitTillAcknowledged()) { + _requestAcked = false; + } else if (rdp.getRequestedPageCount()) { + _requestedCount = rdp.getRequestedPageCount(); + } + _isRequestAcknowledged = rdp.getUseAcknowledgedMsgs(); + // TODO handle command type + } + // passthrough so any profiles that reset their broadcast pattern on a request can do so + // also the profile can handle the descriptor bytes if needed BaseProfile::onAcknowledgedData(msg); - // TODO handle requested dataPage } bool BaseMasterProfile::isRequestedPagePending() { From 91cb627701a1ea3791f0e5a451708512ffbafe07 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 11 Jun 2019 22:59:06 -0700 Subject: [PATCH 004/241] Travis: Missed a couple arguements in base master This should fix up everything. --- src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp b/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp index b1f2f29..5899424 100644 --- a/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp +++ b/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp @@ -1,4 +1,7 @@ +#include #include +#include +#include BaseMasterProfile::BaseMasterProfile(uint16_t deviceNumber, uint8_t transmissionType) : BaseProfile(deviceNumber, transmissionType) { } @@ -14,8 +17,8 @@ void BaseMasterProfile::onChannelEventResponse(ChannelEventResponse& msg) { } void BaseMasterProfile::onAcknowledgedData(AcknowledgedData& msg) { - BaseDataPage bdp(msg); - if (msg.getDataPageNumber() == ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER) { + BaseDataPage bdp(msg); + if (bdp.getDataPageNumber() == ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER) { RequestDataPage rdp(msg); _requestedPage = rdp.getRequestedPageNumber(); if (rdp.transmitTillAcknowledged()) { From d1cc986ba8e2276001322ebeabac3b7150dd8718 Mon Sep 17 00:00:00 2001 From: Sepp62 <33748087+Sepp62@users.noreply.github.com> Date: Thu, 13 Jun 2019 23:21:33 +0200 Subject: [PATCH 005/241] Shifting: First shot, not yet tested master channel Signed-off-by: Curtis Malainey --- examples/Shifting/Shifting.ino | 56 +++++++++++++++++++ src/Profiles/ANTPLUS_Profiles.h | 1 + .../Shifting/ANTPLUS_ShiftingPrivateDefines.h | 23 ++++++++ .../Shifting/ANTPLUS_ShiftingProfile.h | 13 +++++ .../ANTPLUS_ProfileShiftingDataPages.h | 13 +++++ .../ANTPLUS_ShiftingBaseMainDataPageMsg.cpp | 48 ++++++++++++++++ .../ANTPLUS_ShiftingBaseMainDataPageMsg.h | 32 +++++++++++ .../ANTPLUS_ProfileShiftingShifter.cpp | 50 +++++++++++++++++ .../Shifter/ANTPLUS_ProfileShiftingShifter.h | 33 +++++++++++ 9 files changed, 269 insertions(+) create mode 100644 examples/Shifting/Shifting.ino create mode 100644 src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h create mode 100644 src/Profiles/Shifting/ANTPLUS_ShiftingProfile.h create mode 100644 src/Profiles/Shifting/DataPages/ANTPLUS_ProfileShiftingDataPages.h create mode 100644 src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp create mode 100644 src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h create mode 100644 src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp create mode 100644 src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h diff --git a/examples/Shifting/Shifting.ino b/examples/Shifting/Shifting.ino new file mode 100644 index 0000000..98646d4 --- /dev/null +++ b/examples/Shifting/Shifting.ino @@ -0,0 +1,56 @@ +/********************************************** + * 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_1 0 + +const uint8_t NETWORK_KEY[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; + +AntWithCallbacks ant = AntWithCallbacks(); +AntPlusRouter router = AntPlusRouter(); +ProfileShiftingShifter shift = ProfileShiftingShifter( 7370 ); + +void shiftCreateMsgHandler(ShiftingBaseMainDataPageMsg& 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_1, &shift); + + Serial.begin(BAUD_RATE); + Serial.println("Running"); + + // setup shifting monitor + shift.createShiftingDataMsg(shiftCreateMsgHandler); + shift.begin(); + delay(100); // wait for module initialization +} + +void loop() { + router.loop(); +} + +void shiftCreateMsgHandler(ShiftingBaseMainDataPageMsg& msg, uintptr_t data) +{ + static int _gear = 0; + msg.setTotalNumbersGearFront(1); + msg.setTotalNumbersGearRear(10); + + msg.setCurrentGearFront( 1 ); + msg.setCurrentGearRear( _gear++ % 10 ); +} + diff --git a/src/Profiles/ANTPLUS_Profiles.h b/src/Profiles/ANTPLUS_Profiles.h index df0e4ef..6a4d79b 100644 --- a/src/Profiles/ANTPLUS_Profiles.h +++ b/src/Profiles/ANTPLUS_Profiles.h @@ -4,5 +4,6 @@ #include #include #include +#include #endif // ANTPLUS_ANTROUTER_h diff --git a/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h b/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h new file mode 100644 index 0000000..b9bb784 --- /dev/null +++ b/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h @@ -0,0 +1,23 @@ +#ifndef ANTPLUS_SHIFTINGPROFILEPRIVATEDEFINES_h +#define ANTPLUS_SHIFTINGPROFILEPRIVATEDEFINES_h + +/* Channel Config */ +#define ANTPLUS_SHIFTING_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE +#define ANTPLUS_SHIFTING_DEVICETYPE 34 +#define ANTPLUS_SHIFTING_CHANNELPERIOD 8192 +// Master channel +#define ANTPLUS_SHIFTING_MASTER_CHANNELTYPE 0x10 +#define ANTPLUS_SHIFTING_MASTER_TRANSMISSIONTYPE 5 +#define ANTPLUS_SHIFTING_MASTER_DEVICENUMBER 5 + +// 30 / 2.5 = 12 +#define ANTPLUS_SHIFTING_SEARCHTIMEOUT 12 + +/* Pages */ +#define ANTPLUS_SHIFTING_DATAPAGE_SHIFTSYSTEMSTATUS 1 + +// Base page */ +#define ANTPLUS_SHIFTING_DATAPAGEBASE_DATAPAGE_BYTE 0x00 + + +#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..ddba6f7 --- /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 +// ... + +#endif // ANTPLUS_SHIFTINGPROFILE_h diff --git a/src/Profiles/Shifting/DataPages/ANTPLUS_ProfileShiftingDataPages.h b/src/Profiles/Shifting/DataPages/ANTPLUS_ProfileShiftingDataPages.h new file mode 100644 index 0000000..3d3bf48 --- /dev/null +++ b/src/Profiles/Shifting/DataPages/ANTPLUS_ProfileShiftingDataPages.h @@ -0,0 +1,13 @@ +#ifndef ANTPLUS_PROFILESHIFTINGDATAPAGES_h +#define ANTPLUS_PROFILESHIFTINGDATAPAGES_h + +/* Base */ +#include + +/* RX */ +// ... + +/* TX */ +// ... + +#endif // ANTPLUS_PROFILESHIFTINGDATAPAGES_h \ No newline at end of file diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp new file mode 100644 index 0000000..22614cf --- /dev/null +++ b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp @@ -0,0 +1,48 @@ +#include +#include +#include + +ShiftingBaseGenericMsg::ShiftingBaseGenericMsg() : BaseDataPageMsg() +{ + memset(_buffer, 0, MESSAGE_SIZE); + _buffer[2] = 0xFF; + setDataBuffer(_buffer); +} + +ShiftingBaseMainDataPageMsg::ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber) : ShiftingBaseGenericMsg() +{ + _buffer[ANTPLUS_SHIFTING_DATAPAGEBASE_DATAPAGE_BYTE] = dataPageNumber; + + setTotalNumbersGearFront(1); + setTotalNumbersGearRear(10); +} + +void ShiftingBaseMainDataPageMsg::setEventCount( uint8_t n ) +{ + _buffer[1] = n; +} + +void ShiftingBaseMainDataPageMsg::setCurrentGearRear(uint8_t cgr) +{ + _buffer[3] &= ~0x1F; + _buffer[3] |= cgr & 0x1F; +} + +void ShiftingBaseMainDataPageMsg::setCurrentGearFront( uint8_t cgf ) +{ + _buffer[3] &= ~0xE0; + _buffer[3] |= cgf << 5; +} + +void ShiftingBaseMainDataPageMsg::setTotalNumbersGearRear(uint8_t tgr) +{ + _buffer[4] &= ~0x1F; + _buffer[4] |= tgr & 0x1F; +} + +void ShiftingBaseMainDataPageMsg::setTotalNumbersGearFront( uint8_t tgf ) +{ + _buffer[4] &= ~0xE0; + _buffer[4] |= tgf << 5; +} + diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h new file mode 100644 index 0000000..e73b83f --- /dev/null +++ b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h @@ -0,0 +1,32 @@ +#ifndef ANTPLUS_SHIFTINGBASEMAINDATAPAGEMSG_h +#define ANTPLUS_SHIFTINGBASEMAINDATAPAGEMSG_h + +#include +#include + +#include "ANT.h" + +class ShiftingBaseGenericMsg : public BaseDataPageMsg { +public: + ShiftingBaseGenericMsg(); + + void copyData(uint8_t * buf, size_t len) { memcpy(_buffer, buf, len); } + +protected: + uint8_t _buffer[MESSAGE_SIZE]; +}; + +class ShiftingBaseMainDataPageMsg : public ShiftingBaseGenericMsg { +public: + ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber = ANTPLUS_SHIFTING_DATAPAGE_SHIFTSYSTEMSTATUS); + + void setCurrentGearFront( uint8_t cgf ); + void setCurrentGearRear( uint8_t cgr ); + void setTotalNumbersGearFront( uint8_t tgr ); + void setTotalNumbersGearRear( uint8_t tgr ); + + // internal + void setEventCount(uint8_t n); +}; + +#endif // ANTPLUS_SHIFTINGBASEMAINDATAPAGEMSG_h diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp new file mode 100644 index 0000000..894150f --- /dev/null +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp @@ -0,0 +1,50 @@ +#include +#include + + +ProfileShiftingShifter::ProfileShiftingShifter( uint16_t deviceNumber, uint8_t transmissionType) : + BaseMasterProfile(deviceNumber, transmissionType), + _patternStep( 0 ), + _toggle(0), + _eventCount( 0 ) +{ + setChannelConfig(); +} + +void ProfileShiftingShifter::setChannelConfig() { + setChannelType(ANTPLUS_SHIFTING_MASTER_CHANNELTYPE); + setDeviceType(ANTPLUS_SHIFTING_DEVICETYPE); + setChannelPeriod(ANTPLUS_SHIFTING_CHANNELPERIOD); + setSearchTimeout(ANTPLUS_SHIFTING_SEARCHTIMEOUT); +} + +void ProfileShiftingShifter::transmitNextDataPage() { + + // some static aux messages (TODO preliminary solution) + const uint8_t manufacturer[] = { 0x50, 0xFF, 0xFF, 0x01, 0x0F, 0x00, 0x85, 0x83 }; + const uint8_t product[] = { 0x51, 0xFF, 0xFF, 0x01, 0x01, 0x00, 0x00, 0x00 }; + + if (_patternStep++ < 64) { + transmitShiftingMainPageMsg(); + } + else { + // TODO manufacturer and product handling + ShiftingBaseGenericMsg msg; + if (_toggle++ % 1 == 0) + msg.copyData((uint8_t*)manufacturer, MESSAGE_SIZE); + else + msg.copyData((uint8_t*)product, MESSAGE_SIZE); + send(msg); + _patternStep = 0; + } +} + +void ProfileShiftingShifter::transmitShiftingMainPageMsg() { + ShiftingBaseMainDataPageMsg msg; + msg.setEventCount(_eventCount); + if( _patternStep % 4 == 0 ) // TODO make event count time dependent + _eventCount++; + _createShiftingDataMsg.call(msg); + send(msg); +} + diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h new file mode 100644 index 0000000..9231a7e --- /dev/null +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h @@ -0,0 +1,33 @@ +#ifndef ANTPLUS_PROFILESHIFTINGSHIFTER_h +#define ANTPLUS_PROFILESHIFTINGSHIFTER_h + +#include +#include +#include +#include + +class ProfileShiftingShifter : public BaseMasterProfile { +public: + ProfileShiftingShifter(uint16_t deviceNumber, uint8_t transmissionType = ANTPLUS_SHIFTING_MASTER_TRANSMISSIONTYPE); + + /** + * Register callback to populate default data messages (Datapage 0) + */ + void createShiftingDataMsg(void(*func)(ShiftingBaseMainDataPageMsg&, uintptr_t), uintptr_t data = 0) { _createShiftingDataMsg.set(func, data); } + +protected: + virtual void transmitNextDataPage(); + virtual bool isDataPageValid(uint8_t dataPage) { return true; } + +private: + void setChannelConfig(); + void transmitShiftingMainPageMsg(); + + uint8_t _patternStep; + uint8_t _toggle; + uint8_t _eventCount; + + Callback _createShiftingDataMsg; +}; + +#endif // ANTPLUS_PROFILESHIFTINGSHIFTER_h From 4a424edcb9da7189b663d1cad02c5ed843dd1659 Mon Sep 17 00:00:00 2001 From: Sepp62 <33748087+Sepp62@users.noreply.github.com> Date: Fri, 14 Jun 2019 22:32:36 +0200 Subject: [PATCH 006/241] Shifting: Some correction after code review Signed-off-by: Curtis Malainey --- examples/Shifting/Shifting.ino | 6 ++++-- .../Shifting/ANTPLUS_ShiftingPrivateDefines.h | 11 +++++----- .../Shifting/ANTPLUS_ShiftingProfile.h | 4 ++-- .../ANTPLUS_ShiftingBaseMainDataPageMsg.h | 4 +--- .../ANTPLUS_ProfileShiftingShifter.cpp | 21 ++++++++++++------- .../Shifter/ANTPLUS_ProfileShiftingShifter.h | 5 ++--- 6 files changed, 28 insertions(+), 23 deletions(-) diff --git a/examples/Shifting/Shifting.ino b/examples/Shifting/Shifting.ino index 98646d4..cbcac13 100644 --- a/examples/Shifting/Shifting.ino +++ b/examples/Shifting/Shifting.ino @@ -12,7 +12,7 @@ #include "ANTPLUS.h" #define BAUD_RATE 9600 -#define CHANNEL_1 0 +#define CHANNEL_0 0 const uint8_t NETWORK_KEY[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; @@ -29,7 +29,7 @@ void setup() { router.setDriver(&ant); // never touch ant again router.setAntPlusNetworkKey(NETWORK_KEY); - router.setProfile(CHANNEL_1, &shift); + router.setProfile(CHANNEL_0, &shift); Serial.begin(BAUD_RATE); Serial.println("Running"); @@ -47,10 +47,12 @@ void loop() { void shiftCreateMsgHandler(ShiftingBaseMainDataPageMsg& msg, uintptr_t data) { static int _gear = 0; + static int _eventCount = 0; msg.setTotalNumbersGearFront(1); msg.setTotalNumbersGearRear(10); msg.setCurrentGearFront( 1 ); msg.setCurrentGearRear( _gear++ % 10 ); + msg.setEventCount(_eventCount); } diff --git a/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h b/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h index b9bb784..781b34f 100644 --- a/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h +++ b/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h @@ -2,19 +2,18 @@ #define ANTPLUS_SHIFTINGPROFILEPRIVATEDEFINES_h /* Channel Config */ -#define ANTPLUS_SHIFTING_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE +#define ANTPLUS_SHIFTING_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE #define ANTPLUS_SHIFTING_DEVICETYPE 34 #define ANTPLUS_SHIFTING_CHANNELPERIOD 8192 -// Master channel -#define ANTPLUS_SHIFTING_MASTER_CHANNELTYPE 0x10 -#define ANTPLUS_SHIFTING_MASTER_TRANSMISSIONTYPE 5 -#define ANTPLUS_SHIFTING_MASTER_DEVICENUMBER 5 +// Master channel (shifter) +#define ANTPLUS_SHIFTING_SHIFTER_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT +#define ANTPLUS_SHIFTING_SHIFTER_TRANSMISSIONTYPE 5 // 30 / 2.5 = 12 #define ANTPLUS_SHIFTING_SEARCHTIMEOUT 12 /* Pages */ -#define ANTPLUS_SHIFTING_DATAPAGE_SHIFTSYSTEMSTATUS 1 +#define ANTPLUS_SHIFTING_DATAPAGE_SHIFTSYSTEMSTATUS_NUMBER 1 // Base page */ #define ANTPLUS_SHIFTING_DATAPAGEBASE_DATAPAGE_BYTE 0x00 diff --git a/src/Profiles/Shifting/ANTPLUS_ShiftingProfile.h b/src/Profiles/Shifting/ANTPLUS_ShiftingProfile.h index ddba6f7..25c017a 100644 --- a/src/Profiles/Shifting/ANTPLUS_ShiftingProfile.h +++ b/src/Profiles/Shifting/ANTPLUS_ShiftingProfile.h @@ -2,12 +2,12 @@ #define ANTPLUS_SHIFTINGPROFILE_h // General Definitions -#include +//... // Datapages #include // Profile Classes -// ... +#include #endif // ANTPLUS_SHIFTINGPROFILE_h diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h index e73b83f..b4a61e8 100644 --- a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h +++ b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h @@ -18,14 +18,12 @@ class ShiftingBaseGenericMsg : public BaseDataPageMsg { class ShiftingBaseMainDataPageMsg : public ShiftingBaseGenericMsg { public: - ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber = ANTPLUS_SHIFTING_DATAPAGE_SHIFTSYSTEMSTATUS); + ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber = ANTPLUS_SHIFTING_DATAPAGE_SHIFTSYSTEMSTATUS_NUMBER); void setCurrentGearFront( uint8_t cgf ); void setCurrentGearRear( uint8_t cgr ); void setTotalNumbersGearFront( uint8_t tgr ); void setTotalNumbersGearRear( uint8_t tgr ); - - // internal void setEventCount(uint8_t n); }; diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp index 894150f..3baf3ff 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp @@ -5,19 +5,28 @@ ProfileShiftingShifter::ProfileShiftingShifter( uint16_t deviceNumber, uint8_t transmissionType) : BaseMasterProfile(deviceNumber, transmissionType), _patternStep( 0 ), - _toggle(0), - _eventCount( 0 ) + _toggle(0) { setChannelConfig(); } void ProfileShiftingShifter::setChannelConfig() { - setChannelType(ANTPLUS_SHIFTING_MASTER_CHANNELTYPE); + setChannelType(ANTPLUS_SHIFTING_SHIFTER_CHANNELTYPE); setDeviceType(ANTPLUS_SHIFTING_DEVICETYPE); setChannelPeriod(ANTPLUS_SHIFTING_CHANNELPERIOD); setSearchTimeout(ANTPLUS_SHIFTING_SEARCHTIMEOUT); } +bool ProfileShiftingShifter::isDataPageValid(uint8_t dataPage) +{ + switch (dataPage) { + case ANTPLUS_SHIFTING_DATAPAGE_SHIFTSYSTEMSTATUS_NUMBER: + return true; + // TODO other datapages + } + return false; +} + void ProfileShiftingShifter::transmitNextDataPage() { // some static aux messages (TODO preliminary solution) @@ -30,10 +39,11 @@ void ProfileShiftingShifter::transmitNextDataPage() { else { // TODO manufacturer and product handling ShiftingBaseGenericMsg msg; - if (_toggle++ % 1 == 0) + if (_toggle++ % 2 == 0) msg.copyData((uint8_t*)manufacturer, MESSAGE_SIZE); else msg.copyData((uint8_t*)product, MESSAGE_SIZE); + // TODO battery status send(msg); _patternStep = 0; } @@ -41,9 +51,6 @@ void ProfileShiftingShifter::transmitNextDataPage() { void ProfileShiftingShifter::transmitShiftingMainPageMsg() { ShiftingBaseMainDataPageMsg msg; - msg.setEventCount(_eventCount); - if( _patternStep % 4 == 0 ) // TODO make event count time dependent - _eventCount++; _createShiftingDataMsg.call(msg); send(msg); } diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h index 9231a7e..839265b 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h @@ -8,7 +8,7 @@ class ProfileShiftingShifter : public BaseMasterProfile { public: - ProfileShiftingShifter(uint16_t deviceNumber, uint8_t transmissionType = ANTPLUS_SHIFTING_MASTER_TRANSMISSIONTYPE); + ProfileShiftingShifter(uint16_t deviceNumber, uint8_t transmissionType = ANTPLUS_SHIFTING_SHIFTER_TRANSMISSIONTYPE); /** * Register callback to populate default data messages (Datapage 0) @@ -17,7 +17,7 @@ class ProfileShiftingShifter : public BaseMasterProfile { protected: virtual void transmitNextDataPage(); - virtual bool isDataPageValid(uint8_t dataPage) { return true; } + virtual bool isDataPageValid(uint8_t dataPage); private: void setChannelConfig(); @@ -25,7 +25,6 @@ class ProfileShiftingShifter : public BaseMasterProfile { uint8_t _patternStep; uint8_t _toggle; - uint8_t _eventCount; Callback _createShiftingDataMsg; }; From 8447fbc8198c3e1b58f48d9a47b151eecd66be6e Mon Sep 17 00:00:00 2001 From: Sepp62 <33748087+Sepp62@users.noreply.github.com> Date: Sat, 15 Jun 2019 19:26:20 +0200 Subject: [PATCH 007/241] Shifting: ShiftingBaseGenericMsg() base class removed Signed-off-by: Curtis Malainey --- .../ANTPLUS_ShiftingBaseMainDataPageMsg.cpp | 10 ++-------- .../Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h | 17 ++++++----------- .../Shifter/ANTPLUS_ProfileShiftingShifter.cpp | 9 +++++---- 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp index 22614cf..bc7fd61 100644 --- a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp +++ b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp @@ -2,16 +2,11 @@ #include #include -ShiftingBaseGenericMsg::ShiftingBaseGenericMsg() : BaseDataPageMsg() +ShiftingBaseMainDataPageMsg::ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber) : BaseDataPageMsg() { memset(_buffer, 0, MESSAGE_SIZE); - _buffer[2] = 0xFF; - setDataBuffer(_buffer); -} - -ShiftingBaseMainDataPageMsg::ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber) : ShiftingBaseGenericMsg() -{ _buffer[ANTPLUS_SHIFTING_DATAPAGEBASE_DATAPAGE_BYTE] = dataPageNumber; + _buffer[2] = 0xFF; setTotalNumbersGearFront(1); setTotalNumbersGearRear(10); @@ -45,4 +40,3 @@ void ShiftingBaseMainDataPageMsg::setTotalNumbersGearFront( uint8_t tgf ) _buffer[4] &= ~0xE0; _buffer[4] |= tgf << 5; } - diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h index b4a61e8..a7bd801 100644 --- a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h +++ b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h @@ -6,17 +6,7 @@ #include "ANT.h" -class ShiftingBaseGenericMsg : public BaseDataPageMsg { -public: - ShiftingBaseGenericMsg(); - - void copyData(uint8_t * buf, size_t len) { memcpy(_buffer, buf, len); } - -protected: - uint8_t _buffer[MESSAGE_SIZE]; -}; - -class ShiftingBaseMainDataPageMsg : public ShiftingBaseGenericMsg { +class ShiftingBaseMainDataPageMsg : public BaseDataPageMsg { public: ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber = ANTPLUS_SHIFTING_DATAPAGE_SHIFTSYSTEMSTATUS_NUMBER); @@ -25,6 +15,11 @@ class ShiftingBaseMainDataPageMsg : public ShiftingBaseGenericMsg { void setTotalNumbersGearFront( uint8_t tgr ); void setTotalNumbersGearRear( uint8_t tgr ); void setEventCount(uint8_t n); + + uint8_t * getBuffer() { return _buffer; } + +protected: + uint8_t _buffer[MESSAGE_SIZE]; }; #endif // ANTPLUS_SHIFTINGBASEMAINDATAPAGEMSG_h diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp index 3baf3ff..7727cc9 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp @@ -2,7 +2,7 @@ #include -ProfileShiftingShifter::ProfileShiftingShifter( uint16_t deviceNumber, uint8_t transmissionType) : +ProfileShiftingShifter::ProfileShiftingShifter( uint16_t deviceNumber, uint8_t transmissionType) : BaseMasterProfile(deviceNumber, transmissionType), _patternStep( 0 ), _toggle(0) @@ -38,11 +38,11 @@ void ProfileShiftingShifter::transmitNextDataPage() { } else { // TODO manufacturer and product handling - ShiftingBaseGenericMsg msg; + ShiftingBaseMainDataPageMsg msg; if (_toggle++ % 2 == 0) - msg.copyData((uint8_t*)manufacturer, MESSAGE_SIZE); + msg.setDataBuffer((uint8_t*)manufacturer ); else - msg.copyData((uint8_t*)product, MESSAGE_SIZE); + msg.setDataBuffer((uint8_t*)product); // TODO battery status send(msg); _patternStep = 0; @@ -52,6 +52,7 @@ void ProfileShiftingShifter::transmitNextDataPage() { void ProfileShiftingShifter::transmitShiftingMainPageMsg() { ShiftingBaseMainDataPageMsg msg; _createShiftingDataMsg.call(msg); + msg.setDataBuffer(msg.getBuffer()); send(msg); } From 7968f08b7620e278259999ed911f8f6f7051d301 Mon Sep 17 00:00:00 2001 From: Sepp62 <33748087+Sepp62@users.noreply.github.com> Date: Sat, 15 Jun 2019 19:36:47 +0200 Subject: [PATCH 008/241] Shifting: _eventCount bug removed Signed-off-by: Curtis Malainey --- examples/Shifting/Shifting.ino | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/Shifting/Shifting.ino b/examples/Shifting/Shifting.ino index cbcac13..d7ab40f 100644 --- a/examples/Shifting/Shifting.ino +++ b/examples/Shifting/Shifting.ino @@ -53,6 +53,5 @@ void shiftCreateMsgHandler(ShiftingBaseMainDataPageMsg& msg, uintptr_t data) msg.setCurrentGearFront( 1 ); msg.setCurrentGearRear( _gear++ % 10 ); - msg.setEventCount(_eventCount); + msg.setEventCount(_eventCount++); } - From b4f9f17afdef0e7063c7fcc1f1b3f394f6ed8de9 Mon Sep 17 00:00:00 2001 From: Sepp62 <33748087+Sepp62@users.noreply.github.com> Date: Fri, 21 Jun 2019 12:42:32 +0200 Subject: [PATCH 009/241] Shifting: Refactoring manufacturer and product information Signed-off-by: Curtis Malainey --- examples/Shifting/Shifting.ino | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/examples/Shifting/Shifting.ino b/examples/Shifting/Shifting.ino index d7ab40f..83c7aa0 100644 --- a/examples/Shifting/Shifting.ino +++ b/examples/Shifting/Shifting.ino @@ -21,6 +21,8 @@ AntPlusRouter router = AntPlusRouter(); ProfileShiftingShifter shift = ProfileShiftingShifter( 7370 ); void shiftCreateMsgHandler(ShiftingBaseMainDataPageMsg& msg, uintptr_t data); +void shiftCreateManufacturerInformationMsg(ManufacturersInformationMsg& msg, uintptr_t data); +void shiftCreateProductInformationMsg(ProductInformationMsg& msg, uintptr_t data); void setup() { Serial2.begin(BAUD_RATE); @@ -35,7 +37,9 @@ void setup() { Serial.println("Running"); // setup shifting monitor - shift.createShiftingDataMsg(shiftCreateMsgHandler); + shift.createShiftingSystemStatusMsg(shiftCreateMsgHandler); + shift.createShiftingManufacturerInformationMsg(shiftCreateManufacturerInformationMsg); + shift.createShiftingProductInformationMsg(shiftCreateProductInformationMsg); shift.begin(); delay(100); // wait for module initialization } @@ -55,3 +59,15 @@ void shiftCreateMsgHandler(ShiftingBaseMainDataPageMsg& msg, uintptr_t data) msg.setCurrentGearRear( _gear++ % 10 ); msg.setEventCount(_eventCount++); } + +void shiftCreateManufacturerInformationMsg(ManufacturersInformationMsg& msg, uintptr_t data) { + msg.setHWRevision(0x01); + msg.setManufacturerId(0x1234); + msg.setModelNumber(0x0002); +} + +void shiftCreateProductInformationMsg(ProductInformationMsg& msg, uintptr_t data) { + msg.setSerialNumber(0x12345678); + msg.setSWRevisionMain(0x01); + msg.setSWRevisionSupplemental(0x00); +} From 5f5a94447f38219e9e3dd4b716613c40d3880d63 Mon Sep 17 00:00:00 2001 From: Sepp62 <33748087+Sepp62@users.noreply.github.com> Date: Fri, 21 Jun 2019 17:49:33 +0200 Subject: [PATCH 010/241] Shifting: Some minor adaptions due to pull request conversation Signed-off-by: Curtis Malainey --- .../Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp | 8 +++----- .../Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h | 5 ++--- .../Shifter/ANTPLUS_ProfileShiftingShifter.cpp | 16 ++++++++-------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp index bc7fd61..5e402b2 100644 --- a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp +++ b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp @@ -2,14 +2,12 @@ #include #include -ShiftingBaseMainDataPageMsg::ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber) : BaseDataPageMsg() +ShiftingBaseMainDataPageMsg::ShiftingBaseMainDataPageMsg() : BaseDataPageMsg() { memset(_buffer, 0, MESSAGE_SIZE); - _buffer[ANTPLUS_SHIFTING_DATAPAGEBASE_DATAPAGE_BYTE] = dataPageNumber; + setDataBuffer(_buffer); + _buffer[ANTPLUS_SHIFTING_DATAPAGEBASE_DATAPAGE_BYTE] = ANTPLUS_SHIFTING_DATAPAGE_SHIFTSYSTEMSTATUS_NUMBER; _buffer[2] = 0xFF; - - setTotalNumbersGearFront(1); - setTotalNumbersGearRear(10); } void ShiftingBaseMainDataPageMsg::setEventCount( uint8_t n ) diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h index a7bd801..7114d65 100644 --- a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h +++ b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h @@ -8,15 +8,14 @@ class ShiftingBaseMainDataPageMsg : public BaseDataPageMsg { public: - ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber = ANTPLUS_SHIFTING_DATAPAGE_SHIFTSYSTEMSTATUS_NUMBER); + ShiftingBaseMainDataPageMsg(); void setCurrentGearFront( uint8_t cgf ); void setCurrentGearRear( uint8_t cgr ); void setTotalNumbersGearFront( uint8_t tgr ); void setTotalNumbersGearRear( uint8_t tgr ); void setEventCount(uint8_t n); - - uint8_t * getBuffer() { return _buffer; } + // TODO there are some more parameters... protected: uint8_t _buffer[MESSAGE_SIZE]; diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp index 7727cc9..89f73e8 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp @@ -37,14 +37,14 @@ void ProfileShiftingShifter::transmitNextDataPage() { transmitShiftingMainPageMsg(); } else { - // TODO manufacturer and product handling - ShiftingBaseMainDataPageMsg msg; - if (_toggle++ % 2 == 0) - msg.setDataBuffer((uint8_t*)manufacturer ); - else - msg.setDataBuffer((uint8_t*)product); - // TODO battery status - send(msg); + + if (_toggle++ % 2 == 0) { + transmitShiftingManufacturerInformationMsg(); + } + else { + transmitShiftingProductInformationMsg(); + } + // TODO battery status and some more pages: 78, 79, and 82 every 65 pages _patternStep = 0; } } From 89d3cd2fd3f64b1c03f58b1320f1124172f8254d Mon Sep 17 00:00:00 2001 From: Sepp62 <33748087+Sepp62@users.noreply.github.com> Date: Fri, 21 Jun 2019 12:23:43 +0200 Subject: [PATCH 011/241] Shifting: Refactoring Moxy and Shifting for product and manufacturer information Signed-off-by: Curtis Malainey Note(cujomalainey): Removed all MOxy when cherry-picking to isolate branch changes --- .../Shifting/ANTPLUS_ShiftingPrivateDefines.h | 1 - .../ANTPLUS_ProfileShiftingShifter.cpp | 20 ++++++++++++------- .../Shifter/ANTPLUS_ProfileShiftingShifter.h | 17 ++++++++++++++-- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h b/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h index 781b34f..380fd54 100644 --- a/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h +++ b/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h @@ -18,5 +18,4 @@ // Base page */ #define ANTPLUS_SHIFTING_DATAPAGEBASE_DATAPAGE_BYTE 0x00 - #endif // ANTPLUS_SHIFTINGPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp index 89f73e8..1032cc6 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp @@ -28,11 +28,6 @@ bool ProfileShiftingShifter::isDataPageValid(uint8_t dataPage) } void ProfileShiftingShifter::transmitNextDataPage() { - - // some static aux messages (TODO preliminary solution) - const uint8_t manufacturer[] = { 0x50, 0xFF, 0xFF, 0x01, 0x0F, 0x00, 0x85, 0x83 }; - const uint8_t product[] = { 0x51, 0xFF, 0xFF, 0x01, 0x01, 0x00, 0x00, 0x00 }; - if (_patternStep++ < 64) { transmitShiftingMainPageMsg(); } @@ -44,15 +39,26 @@ void ProfileShiftingShifter::transmitNextDataPage() { else { transmitShiftingProductInformationMsg(); } - // TODO battery status and some more pages: 78, 79, and 82 every 65 pages + // TODO battery status and some more pages _patternStep = 0; } } +void ProfileShiftingShifter::transmitShiftingManufacturerInformationMsg() { + ManufacturersInformationMsg msg; + _createShiftingManufacturerInformationMsg.call(msg); + send(msg); +} + +void ProfileShiftingShifter::transmitShiftingProductInformationMsg() { + ProductInformationMsg msg; + _createShiftingProductInformationMsg.call(msg); + send(msg); +} + void ProfileShiftingShifter::transmitShiftingMainPageMsg() { ShiftingBaseMainDataPageMsg msg; _createShiftingDataMsg.call(msg); - msg.setDataBuffer(msg.getBuffer()); send(msg); } diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h index 839265b..01f5ea8 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h @@ -13,12 +13,23 @@ class ProfileShiftingShifter : public BaseMasterProfile { /** * Register callback to populate default data messages (Datapage 0) */ - void createShiftingDataMsg(void(*func)(ShiftingBaseMainDataPageMsg&, uintptr_t), uintptr_t data = 0) { _createShiftingDataMsg.set(func, data); } + void createShiftingSystemStatusMsg(void(*func)(ShiftingBaseMainDataPageMsg&, uintptr_t), uintptr_t data = 0) { _createShiftingSystemStatusMsg.set(func, data); } + /** + * Register callback to populate manufacturer information data messages (Datapage 2) + */ + void createShiftingManufacturerInformationMsg(void(*func)(ManufacturersInformationMsg&, uintptr_t), uintptr_t data = 0) { _createShiftingManufacturerInformationMsg.set(func, data); } + /** + * Register callback to populate product information data messages (Datapage 3) + */ + void createShiftingProductInformationMsg(void(*func)(ProductInformationMsg&, uintptr_t), uintptr_t data = 0) { _createShiftingProductInformationMsg.set(func, data); } protected: virtual void transmitNextDataPage(); virtual bool isDataPageValid(uint8_t dataPage); + void transmitShiftingManufacturerInformationMsg(); + void transmitShiftingProductInformationMsg(); + private: void setChannelConfig(); void transmitShiftingMainPageMsg(); @@ -26,7 +37,9 @@ class ProfileShiftingShifter : public BaseMasterProfile { uint8_t _patternStep; uint8_t _toggle; - Callback _createShiftingDataMsg; + Callback _createShiftingSystemStatusMsg; + Callback _createShiftingManufacturerInformationMsg; + Callback _createShiftingProductInformationMsg; }; #endif // ANTPLUS_PROFILESHIFTINGSHIFTER_h From ad0e5390fb05141457e4407afda4c6113b5cb1d8 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 22 Jun 2019 15:17:50 -0700 Subject: [PATCH 012/241] Shifting: Merge conflict resolution error Grabbed the wrong name when dealing with merge conflicts. Oops. --- .../Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp index 1032cc6..5d81aa6 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp @@ -58,7 +58,7 @@ void ProfileShiftingShifter::transmitShiftingProductInformationMsg() { void ProfileShiftingShifter::transmitShiftingMainPageMsg() { ShiftingBaseMainDataPageMsg msg; - _createShiftingDataMsg.call(msg); + _createShiftingSystemStatusMsg.call(msg); send(msg); } From d5ff5e520d5ec17715c23c16b9d443c2042a561f Mon Sep 17 00:00:00 2001 From: Sepp62 <33748087+Sepp62@users.noreply.github.com> Date: Thu, 13 Jun 2019 23:48:26 +0200 Subject: [PATCH 013/241] MuscleOxygen: First shot of muscle oxygen monitor profile, rudimentarily tested Signed-off-by: Curtis Malainey --- .travis.yml | 2 +- .../MuscleOxygenMonitor.ino | 58 +++++++++++++++++++ src/Profiles/ANTPLUS_Profiles.h | 1 + .../ANTPLUS_MuscleOxygenPrivateDefines.h | 23 ++++++++ .../ANTPLUS_MuscleOxygenProfile.h | 13 +++++ .../ANTPLUS_ProfileMuscleOxygenDataPages.h | 13 +++++ ...NTPLUS_MuscleOxygenBaseMainDataPageMsg.cpp | 56 ++++++++++++++++++ .../ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h | 32 ++++++++++ .../ANTPLUS_ProfileMuscleOxygenMonitor.cpp | 56 ++++++++++++++++++ .../ANTPLUS_ProfileMuscleOxygenMonitor.h | 33 +++++++++++ 10 files changed, 286 insertions(+), 1 deletion(-) create mode 100644 examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino create mode 100644 src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h create mode 100644 src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenProfile.h create mode 100644 src/Profiles/MuscleOxygen/DataPages/ANTPLUS_ProfileMuscleOxygenDataPages.h create mode 100644 src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.cpp create mode 100644 src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h create mode 100644 src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp create mode 100644 src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h diff --git a/.travis.yml b/.travis.yml index ea04423..a35d090 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,7 @@ env: - PLATFORMIO_CI_SRC=examples/EnvironmentDisplay/EnvironmentDisplay.ino - PLATFORMIO_CI_SRC=examples/HeartRateDisplay/HeartRateDisplay.ino - PLATFORMIO_CI_SRC=examples/HeartRateMonitor/HeartRateMonitor.ino - + - PLATFORMIO_CI_SRC=examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino install: - pip install -U platformio diff --git a/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino b/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino new file mode 100644 index 0000000..bc3d9e5 --- /dev/null +++ b/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino @@ -0,0 +1,58 @@ +/********************************************** + * 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_1 0 + +const uint8_t NETWORK_KEY[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; + +AntWithCallbacks ant = AntWithCallbacks(); +AntPlusRouter router = AntPlusRouter(); +ProfileMuscleOxygenMonitor moxy = ProfileMuscleOxygenMonitor( 7369 ); + +void moxyCreateMsgHandler(MuscleOxygenBaseMainDataPageMsg& 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_1, &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.createMuscleOxygenDataMsg(moxyCreateMsgHandler); + moxy.begin(); +} + +void loop() { + router.loop(); +} + +void moxyCreateMsgHandler(MuscleOxygenBaseMainDataPageMsg& msg, uintptr_t data) +{ + const int lo = 500, hi = 2500; + static uint16_t c = lo; + + // fake data + msg.setTotalHemoglobinConcentration(c); + msg.setCurrentSaturatedHemoglobinPercentage(c++/4); + + if (c > hi) + c = lo; +} diff --git a/src/Profiles/ANTPLUS_Profiles.h b/src/Profiles/ANTPLUS_Profiles.h index df0e4ef..f9b8dfe 100644 --- a/src/Profiles/ANTPLUS_Profiles.h +++ b/src/Profiles/ANTPLUS_Profiles.h @@ -4,5 +4,6 @@ #include #include #include +#include #endif // ANTPLUS_ANTROUTER_h diff --git a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h new file mode 100644 index 0000000..e66e5e7 --- /dev/null +++ b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h @@ -0,0 +1,23 @@ +#ifndef ANTPLUS_MUSCLEOXYGENPROFILEPRIVATEDEFINES_h +#define ANTPLUS_MUSCLEOXYGENPROFILEPRIVATEDEFINES_h + +/* Channel Config */ +#define ANTPLUS_MUSCLEOXYGEN_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE +#define ANTPLUS_MUSCLEOXYGEN_DEVICETYPE 31 +#define ANTPLUS_MUSCLEOXYGEN_CHANNELPERIOD 8192 +// Master channel +#define ANTPLUS_MUSCLEOXYGEN_MASTER_CHANNELTYPE 0x10 +#define ANTPLUS_MUSCLEOXYGEN_MASTER_TRANSMISSIONTYPE 5 +#define ANTPLUS_MUSCLEOXYGEN_MASTER_DEVICENUMBER 5 + +// 30 / 2.5 = 12 +#define ANTPLUS_MUSCLEOXYGEN_SEARCHTIMEOUT 12 + +/* Pages */ +#define ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA 1 + +// Base page */ +#define ANTPLUS_MUSCLEOXYGEN_DATAPAGEBASE_DATAPAGE_BYTE 0x00 + + +#endif // ANTPLUS_MUSCLEOXYGENPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenProfile.h b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenProfile.h new file mode 100644 index 0000000..d4da4cf --- /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 +// ... + +#endif // ANTPLUS_MUSCLEOXYGENPROFILE_h diff --git a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_ProfileMuscleOxygenDataPages.h b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_ProfileMuscleOxygenDataPages.h new file mode 100644 index 0000000..55460f2 --- /dev/null +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_ProfileMuscleOxygenDataPages.h @@ -0,0 +1,13 @@ +#ifndef ANTPLUS_PROFILEMUSCLEOXYGENDATAPAGES_h +#define ANTPLUS_PROFILEMUSCLEOXYGENDATAPAGES_h + +/* Base */ +#include + +/* RX */ +// ... + +/* TX */ +// ... + +#endif // ANTPLUS_PROFILEMUSCLEOXYGENDATAPAGES_h \ No newline at end of file diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.cpp b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.cpp new file mode 100644 index 0000000..80b9cef --- /dev/null +++ b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.cpp @@ -0,0 +1,56 @@ +#include +#include +#include + + +MuscleOxygenBaseGenericMsg::MuscleOxygenBaseGenericMsg() : BaseDataPageMsg() +{ + memset(_buffer, 0, MESSAGE_SIZE); + setDataBuffer(_buffer); +} + +MuscleOxygenBaseMainDataPageMsg::MuscleOxygenBaseMainDataPageMsg(uint8_t dataPageNumber) : MuscleOxygenBaseGenericMsg() +{ + _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = dataPageNumber; + setCapabilities(); + setNotifications(); +} + +void MuscleOxygenBaseMainDataPageMsg::setEventCount( uint8_t n ) +{ + _buffer[1] = n; +} + +void MuscleOxygenBaseMainDataPageMsg::setNotifications( uint8_t n ) +{ + _buffer[2] = n; +} + +void MuscleOxygenBaseMainDataPageMsg::setCapabilities( uint8_t c ) +{ + _buffer[3] = c; +} + +void MuscleOxygenBaseMainDataPageMsg::setTotalHemoglobinConcentration( uint16_t tc ) +{ + _buffer[4] = (uint8_t)tc; + _buffer[5] &= ~0x0F; + _buffer[5] |= (tc >> 8) & 0x0F; +} + +/* TODO +void MuscleOxygenBaseMainDataPageMsg::setPreviousSaturatedHemoglobinPercentage( uint16_t pp ) +{ + _buffer[5] &= ~0xF0; + _buffer[5] |= (uint8_t)(pp << 4); + _buffer[6] &= ~0x3F; + _buffer[6] |= (pp >> 4) & 0x3F; +} +*/ + +void MuscleOxygenBaseMainDataPageMsg::setCurrentSaturatedHemoglobinPercentage( uint16_t cp ) +{ + _buffer[6] &= ~0xC0; + _buffer[6] |= (uint8_t)(cp << 6); + _buffer[7] = cp >> 2; +} diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h new file mode 100644 index 0000000..cd7034a --- /dev/null +++ b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h @@ -0,0 +1,32 @@ +#ifndef ANTPLUS_MUSCLEOXYGENBASEMAINDATAPAGEMSG_h +#define ANTPLUS_MUSCLEOXYGENBASEMAINDATAPAGEMSG_h + +#include +#include + +#include "ANT.h" + +class MuscleOxygenBaseGenericMsg : public BaseDataPageMsg { +public: + MuscleOxygenBaseGenericMsg(); + + void copyData(uint8_t * buf, size_t len) { memcpy(_buffer, buf, len); } + +protected: + uint8_t _buffer[MESSAGE_SIZE]; +}; + +class MuscleOxygenBaseMainDataPageMsg : public MuscleOxygenBaseGenericMsg { +public: + MuscleOxygenBaseMainDataPageMsg(uint8_t dataPageNumber = ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA); + + void setTotalHemoglobinConcentration( uint16_t tc ); + void setCurrentSaturatedHemoglobinPercentage(uint16_t cp); + + // internal + void setEventCount(uint8_t n); + void setNotifications(uint8_t n = 0x00); + void setCapabilities(uint8_t c = 0x06); +}; + +#endif // ANTPLUS_MUSCLEOXYGENBASEMAINDATAPAGEMSG_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..273a487 --- /dev/null +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp @@ -0,0 +1,56 @@ +#include +#include + + +ProfileMuscleOxygenMonitor::ProfileMuscleOxygenMonitor( uint16_t deviceNumber, uint8_t transmissionType) : + BaseMasterProfile(deviceNumber, transmissionType), + _patternStep(0), + _toggle(0), + _eventCount(0) + +{ + setChannelConfig(); +} + +void ProfileMuscleOxygenMonitor::setChannelConfig() { + setChannelType(ANTPLUS_MUSCLEOXYGEN_MASTER_CHANNELTYPE); + setDeviceType(ANTPLUS_MUSCLEOXYGEN_DEVICETYPE); + setChannelPeriod(ANTPLUS_MUSCLEOXYGEN_CHANNELPERIOD); + setSearchTimeout(ANTPLUS_MUSCLEOXYGEN_SEARCHTIMEOUT); +} + +void ProfileMuscleOxygenMonitor::transmitNextDataPage() { + // some static aux messages + const uint8_t manufacturer[] = { 0x50, 0xFF, 0xFF, 0x01, 0x0F, 0x00, 0x85, 0x83 }; + const uint8_t product[] = { 0x51, 0xFF, 0xFF, 0x01, 0x01, 0x00, 0x00, 0x00 }; + + if (_patternStep++ < 64) { + transmitMuscleOxygenMainPageMsg(); + } + else { + MuscleOxygenBaseGenericMsg msg; + if (_toggle++ % 1 == 0) + msg.copyData((uint8_t*)manufacturer, MESSAGE_SIZE); + else + msg.copyData((uint8_t*)product, MESSAGE_SIZE); + send(msg); + _patternStep = 0; + + // debug + /* + for (int i = 0; i < msg.getDataLength(); i++) { + Serial.print(msg.getData(i), HEX); Serial.print(" "); + } + Serial.println("");*/ + } +} + +void ProfileMuscleOxygenMonitor::transmitMuscleOxygenMainPageMsg() { + MuscleOxygenBaseMainDataPageMsg msg; + msg.setEventCount( _eventCount ); + if( _patternStep % 4 == 0 ) + _eventCount++; + _createMuscleOxygenDataMsg.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..fdd57ab --- /dev/null +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h @@ -0,0 +1,33 @@ +#ifndef ANTPLUS_PROFILEMUSCLEOXYGENMONITOR_h +#define ANTPLUS_PROFILEMUSCLEOXYGENMONITOR_h + +#include +#include +#include +#include + +class ProfileMuscleOxygenMonitor : public BaseMasterProfile { +public: + ProfileMuscleOxygenMonitor(uint16_t deviceNumber, uint8_t transmissionType = ANTPLUS_MUSCLEOXYGEN_MASTER_TRANSMISSIONTYPE); + + /** + * Register callback to populate default data messages (Datapage 0) + */ + void createMuscleOxygenDataMsg(void(*func)(MuscleOxygenBaseMainDataPageMsg&, uintptr_t), uintptr_t data = 0) { _createMuscleOxygenDataMsg.set(func, data); } + +protected: + virtual void transmitNextDataPage(); + virtual bool isDataPageValid(uint8_t dataPage) { return true; } + +private: + void setChannelConfig(); + void transmitMuscleOxygenMainPageMsg(); + + uint8_t _patternStep; + uint8_t _toggle; + uint8_t _eventCount; + + Callback _createMuscleOxygenDataMsg; +}; + +#endif // ANTPLUS_PROFILEMUSCLEOXYGENMONITOR_h From c70740f9c5a0350dba20086836d3490051cea40e Mon Sep 17 00:00:00 2001 From: Sepp62 <33748087+Sepp62@users.noreply.github.com> Date: Sat, 15 Jun 2019 20:30:18 +0200 Subject: [PATCH 014/241] MuscleOxygen: Refactoring consistent to "shifter" Signed-off-by: Curtis Malainey --- .../MuscleOxygenMonitor.ino | 18 +++++++------ .../ANTPLUS_MuscleOxygenPrivateDefines.h | 7 +++--- ...NTPLUS_MuscleOxygenBaseMainDataPageMsg.cpp | 6 +---- .../ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h | 22 ++++++---------- .../ANTPLUS_ProfileMuscleOxygenMonitor.cpp | 25 ++++++------------- .../ANTPLUS_ProfileMuscleOxygenMonitor.h | 3 +-- 6 files changed, 29 insertions(+), 52 deletions(-) diff --git a/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino b/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino index bc3d9e5..275a492 100644 --- a/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino +++ b/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino @@ -12,7 +12,7 @@ #include "ANTPLUS.h" #define BAUD_RATE 9600 -#define CHANNEL_1 0 +#define CHANNEL_0 0 const uint8_t NETWORK_KEY[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; @@ -29,7 +29,7 @@ void setup() { router.setDriver(&ant); // never touch ant again router.setAntPlusNetworkKey(NETWORK_KEY); - router.setProfile(CHANNEL_1, &moxy); + router.setProfile(CHANNEL_0, &moxy); // Delay after initial setup to wait for user to connect on serial Serial.begin(BAUD_RATE); @@ -47,12 +47,14 @@ void loop() { void moxyCreateMsgHandler(MuscleOxygenBaseMainDataPageMsg& msg, uintptr_t data) { const int lo = 500, hi = 2500; - static uint16_t c = lo; + static uint16_t _c = lo; + static uint8_t _eventCount = 0; - // fake data - msg.setTotalHemoglobinConcentration(c); - msg.setCurrentSaturatedHemoglobinPercentage(c++/4); + // demo data + msg.setTotalHemoglobinConcentration(_c); + msg.setCurrentSaturatedHemoglobinPercentage(_c++/4); + msg.setEventCount(_eventCount++); - if (c > hi) - c = lo; + if (_c > hi) + _c = lo; } diff --git a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h index e66e5e7..3fb5d2e 100644 --- a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h +++ b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h @@ -6,15 +6,14 @@ #define ANTPLUS_MUSCLEOXYGEN_DEVICETYPE 31 #define ANTPLUS_MUSCLEOXYGEN_CHANNELPERIOD 8192 // Master channel -#define ANTPLUS_MUSCLEOXYGEN_MASTER_CHANNELTYPE 0x10 -#define ANTPLUS_MUSCLEOXYGEN_MASTER_TRANSMISSIONTYPE 5 -#define ANTPLUS_MUSCLEOXYGEN_MASTER_DEVICENUMBER 5 +#define ANTPLUS_MUSCLEOXYGEN_MONITOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT +#define ANTPLUS_MUSCLEOXYGEN_MONITOR_TRANSMISSIONTYPE 5 // 30 / 2.5 = 12 #define ANTPLUS_MUSCLEOXYGEN_SEARCHTIMEOUT 12 /* Pages */ -#define ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA 1 +#define ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_NUMBER 1 // Base page */ #define ANTPLUS_MUSCLEOXYGEN_DATAPAGEBASE_DATAPAGE_BYTE 0x00 diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.cpp b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.cpp index 80b9cef..a6958bc 100644 --- a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.cpp +++ b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.cpp @@ -3,14 +3,10 @@ #include -MuscleOxygenBaseGenericMsg::MuscleOxygenBaseGenericMsg() : BaseDataPageMsg() +MuscleOxygenBaseMainDataPageMsg::MuscleOxygenBaseMainDataPageMsg(uint8_t dataPageNumber) : BaseDataPageMsg() { memset(_buffer, 0, MESSAGE_SIZE); setDataBuffer(_buffer); -} - -MuscleOxygenBaseMainDataPageMsg::MuscleOxygenBaseMainDataPageMsg(uint8_t dataPageNumber) : MuscleOxygenBaseGenericMsg() -{ _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = dataPageNumber; setCapabilities(); setNotifications(); diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h index cd7034a..ed8f4fe 100644 --- a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h +++ b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h @@ -6,27 +6,19 @@ #include "ANT.h" -class MuscleOxygenBaseGenericMsg : public BaseDataPageMsg { +class MuscleOxygenBaseMainDataPageMsg : public BaseDataPageMsg { public: - MuscleOxygenBaseGenericMsg(); - - void copyData(uint8_t * buf, size_t len) { memcpy(_buffer, buf, len); } - -protected: - uint8_t _buffer[MESSAGE_SIZE]; -}; - -class MuscleOxygenBaseMainDataPageMsg : public MuscleOxygenBaseGenericMsg { -public: - MuscleOxygenBaseMainDataPageMsg(uint8_t dataPageNumber = ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA); + MuscleOxygenBaseMainDataPageMsg(uint8_t dataPageNumber = ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_NUMBER); void setTotalHemoglobinConcentration( uint16_t tc ); void setCurrentSaturatedHemoglobinPercentage(uint16_t cp); - - // internal - void setEventCount(uint8_t n); void setNotifications(uint8_t n = 0x00); void setCapabilities(uint8_t c = 0x06); + void setEventCount(uint8_t n); + uint8_t * getBuffer() { return _buffer; } + +protected: + uint8_t _buffer[MESSAGE_SIZE]; }; #endif // ANTPLUS_MUSCLEOXYGENBASEMAINDATAPAGEMSG_h diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp index 273a487..bb002bb 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp @@ -5,15 +5,13 @@ ProfileMuscleOxygenMonitor::ProfileMuscleOxygenMonitor( uint16_t deviceNumber, uint8_t transmissionType) : BaseMasterProfile(deviceNumber, transmissionType), _patternStep(0), - _toggle(0), - _eventCount(0) - + _toggle(0) { setChannelConfig(); } void ProfileMuscleOxygenMonitor::setChannelConfig() { - setChannelType(ANTPLUS_MUSCLEOXYGEN_MASTER_CHANNELTYPE); + setChannelType(ANTPLUS_MUSCLEOXYGEN_MONITOR_CHANNELTYPE); setDeviceType(ANTPLUS_MUSCLEOXYGEN_DEVICETYPE); setChannelPeriod(ANTPLUS_MUSCLEOXYGEN_CHANNELPERIOD); setSearchTimeout(ANTPLUS_MUSCLEOXYGEN_SEARCHTIMEOUT); @@ -28,29 +26,20 @@ void ProfileMuscleOxygenMonitor::transmitNextDataPage() { transmitMuscleOxygenMainPageMsg(); } else { - MuscleOxygenBaseGenericMsg msg; - if (_toggle++ % 1 == 0) - msg.copyData((uint8_t*)manufacturer, MESSAGE_SIZE); + MuscleOxygenBaseMainDataPageMsg msg; + if (_toggle++ % 2 == 0) + msg.setDataBuffer((uint8_t*)manufacturer); else - msg.copyData((uint8_t*)product, MESSAGE_SIZE); + msg.setDataBuffer((uint8_t*)product); send(msg); _patternStep = 0; - - // debug - /* - for (int i = 0; i < msg.getDataLength(); i++) { - Serial.print(msg.getData(i), HEX); Serial.print(" "); - } - Serial.println("");*/ } } void ProfileMuscleOxygenMonitor::transmitMuscleOxygenMainPageMsg() { MuscleOxygenBaseMainDataPageMsg msg; - msg.setEventCount( _eventCount ); - if( _patternStep % 4 == 0 ) - _eventCount++; _createMuscleOxygenDataMsg.call(msg); + msg.setDataBuffer(msg.getBuffer()); send(msg); } diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h index fdd57ab..124fe67 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h @@ -8,7 +8,7 @@ class ProfileMuscleOxygenMonitor : public BaseMasterProfile { public: - ProfileMuscleOxygenMonitor(uint16_t deviceNumber, uint8_t transmissionType = ANTPLUS_MUSCLEOXYGEN_MASTER_TRANSMISSIONTYPE); + ProfileMuscleOxygenMonitor(uint16_t deviceNumber, uint8_t transmissionType = ANTPLUS_MUSCLEOXYGEN_MONITOR_TRANSMISSIONTYPE); /** * Register callback to populate default data messages (Datapage 0) @@ -25,7 +25,6 @@ class ProfileMuscleOxygenMonitor : public BaseMasterProfile { uint8_t _patternStep; uint8_t _toggle; - uint8_t _eventCount; Callback _createMuscleOxygenDataMsg; }; From 5384e613ec6834d62de30d5b7843cb4fe672d46f Mon Sep 17 00:00:00 2001 From: Sepp62 <33748087+Sepp62@users.noreply.github.com> Date: Sat, 15 Jun 2019 21:13:13 +0200 Subject: [PATCH 015/241] MuscleOxygen: isDataPageValid() changed Signed-off-by: Curtis Malainey --- .../Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp | 9 +++++++++ .../Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp index bb002bb..b3e0b40 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp @@ -17,6 +17,15 @@ void ProfileMuscleOxygenMonitor::setChannelConfig() { setSearchTimeout(ANTPLUS_MUSCLEOXYGEN_SEARCHTIMEOUT); } +bool ProfileMuscleOxygenMonitor::isDataPageValid(uint8_t dataPage) { + switch (dataPage) { + case ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_NUMBER: + return true; + // TODO other datapages + } + return false; +} + void ProfileMuscleOxygenMonitor::transmitNextDataPage() { // some static aux messages const uint8_t manufacturer[] = { 0x50, 0xFF, 0xFF, 0x01, 0x0F, 0x00, 0x85, 0x83 }; diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h index 124fe67..2bed7a2 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h @@ -17,7 +17,7 @@ class ProfileMuscleOxygenMonitor : public BaseMasterProfile { protected: virtual void transmitNextDataPage(); - virtual bool isDataPageValid(uint8_t dataPage) { return true; } + virtual bool isDataPageValid(uint8_t dataPage); private: void setChannelConfig(); From d5f3740a1e35d56e1e16ac6a5ccd7bfbda0d4d56 Mon Sep 17 00:00:00 2001 From: Sepp62 <33748087+Sepp62@users.noreply.github.com> Date: Fri, 21 Jun 2019 10:46:45 +0200 Subject: [PATCH 016/241] MOxy: Adapted to new msg balse classes for manufacturer and product Signed-off-by: Curtis Malainey --- .../ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h | 1 - .../ANTPLUS_ProfileMuscleOxygenMonitor.cpp | 21 +++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h index ed8f4fe..1aa2288 100644 --- a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h +++ b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h @@ -15,7 +15,6 @@ class MuscleOxygenBaseMainDataPageMsg : public BaseDataPageMsg void setNotifications(uint8_t n = 0x00); void setCapabilities(uint8_t c = 0x06); void setEventCount(uint8_t n); - uint8_t * getBuffer() { return _buffer; } protected: uint8_t _buffer[MESSAGE_SIZE]; diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp index b3e0b40..6c8c0f8 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp @@ -27,19 +27,23 @@ bool ProfileMuscleOxygenMonitor::isDataPageValid(uint8_t dataPage) { } void ProfileMuscleOxygenMonitor::transmitNextDataPage() { - // some static aux messages - const uint8_t manufacturer[] = { 0x50, 0xFF, 0xFF, 0x01, 0x0F, 0x00, 0x85, 0x83 }; - const uint8_t product[] = { 0x51, 0xFF, 0xFF, 0x01, 0x01, 0x00, 0x00, 0x00 }; - if (_patternStep++ < 64) { transmitMuscleOxygenMainPageMsg(); } else { MuscleOxygenBaseMainDataPageMsg msg; - if (_toggle++ % 2 == 0) - msg.setDataBuffer((uint8_t*)manufacturer); - else - msg.setDataBuffer((uint8_t*)product); + if (_toggle++ % 2 == 0) { + ProductInformationMsg msg; + msg.setSerialNumber(0x12345678); + msg.setSWRevisionMain(1); + msg.setSWRevisionSupplemental(1); + } + else { + ManufacturersInformationMsg msg; + msg.setHWRevision(1); + msg.setManufacturerId(0x1234); + msg.setModelNumber(0x5678); + } send(msg); _patternStep = 0; } @@ -51,4 +55,3 @@ void ProfileMuscleOxygenMonitor::transmitMuscleOxygenMainPageMsg() { msg.setDataBuffer(msg.getBuffer()); send(msg); } - From 72941b57f15b70f1fcc1a759e1dfbf77532c582f Mon Sep 17 00:00:00 2001 From: Sepp62 <33748087+Sepp62@users.noreply.github.com> Date: Fri, 21 Jun 2019 12:23:43 +0200 Subject: [PATCH 017/241] MOxy: Refactoring Moxy and Shifting for product and manufacturer information Signed-off-by: Curtis Malainey Note(cujomalainey): Removed shifting profile content to keep branches isolated till merge back --- .../ANTPLUS_MuscleOxygenPrivateDefines.h | 3 +-- .../ANTPLUS_ProfileMuscleOxygenMonitor.cpp | 24 +++++++++++-------- .../ANTPLUS_ProfileMuscleOxygenMonitor.h | 13 ++++++++++ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h index 3fb5d2e..a4de1a8 100644 --- a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h +++ b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h @@ -2,7 +2,7 @@ #define ANTPLUS_MUSCLEOXYGENPROFILEPRIVATEDEFINES_h /* Channel Config */ -#define ANTPLUS_MUSCLEOXYGEN_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE +#define ANTPLUS_MUSCLEOXYGEN_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE #define ANTPLUS_MUSCLEOXYGEN_DEVICETYPE 31 #define ANTPLUS_MUSCLEOXYGEN_CHANNELPERIOD 8192 // Master channel @@ -18,5 +18,4 @@ // Base page */ #define ANTPLUS_MUSCLEOXYGEN_DATAPAGEBASE_DATAPAGE_BYTE 0x00 - #endif // ANTPLUS_MUSCLEOXYGENPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp index 6c8c0f8..9e9501e 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp @@ -31,24 +31,28 @@ void ProfileMuscleOxygenMonitor::transmitNextDataPage() { transmitMuscleOxygenMainPageMsg(); } else { - MuscleOxygenBaseMainDataPageMsg msg; if (_toggle++ % 2 == 0) { - ProductInformationMsg msg; - msg.setSerialNumber(0x12345678); - msg.setSWRevisionMain(1); - msg.setSWRevisionSupplemental(1); + transmitMuscleOxygenManufacturerInformationMsg(); } else { - ManufacturersInformationMsg msg; - msg.setHWRevision(1); - msg.setManufacturerId(0x1234); - msg.setModelNumber(0x5678); + transmitMuscleOxygenProductInformationMsg(); } - send(msg); _patternStep = 0; } } +void ProfileMuscleOxygenMonitor::transmitMuscleOxygenManufacturerInformationMsg() { + ManufacturersInformationMsg msg; + _createMuscleOxygenManufacturerInformationMsg.call(msg); + send(msg); +} + +void ProfileMuscleOxygenMonitor::transmitMuscleOxygenProductInformationMsg() { + ProductInformationMsg msg; + _createMuscleOxygenProductInformationMsg.call(msg); + send(msg); +} + void ProfileMuscleOxygenMonitor::transmitMuscleOxygenMainPageMsg() { MuscleOxygenBaseMainDataPageMsg msg; _createMuscleOxygenDataMsg.call(msg); diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h index 2bed7a2..69f3410 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h @@ -14,11 +14,22 @@ class ProfileMuscleOxygenMonitor : public BaseMasterProfile { * Register callback to populate default data messages (Datapage 0) */ void createMuscleOxygenDataMsg(void(*func)(MuscleOxygenBaseMainDataPageMsg&, uintptr_t), uintptr_t data = 0) { _createMuscleOxygenDataMsg.set(func, data); } + /** + * Register callback to populate manufacturer information data messages (Datapage 2) + */ + void createMuscleOxygenManufacturerInformationMsg(void(*func)(ManufacturersInformationMsg&, uintptr_t), uintptr_t data = 0) { _createMuscleOxygenManufacturerInformationMsg.set(func, data); } + /** + * Register callback to populate product information data messages (Datapage 3) + */ + void createMuscleOxygenProductInformationMsg(void(*func)(ProductInformationMsg&, uintptr_t), uintptr_t data = 0) { _createMuscleOxygenProductInformationMsg.set(func, data); } protected: virtual void transmitNextDataPage(); virtual bool isDataPageValid(uint8_t dataPage); + void transmitMuscleOxygenManufacturerInformationMsg(); + void transmitMuscleOxygenProductInformationMsg(); + private: void setChannelConfig(); void transmitMuscleOxygenMainPageMsg(); @@ -27,6 +38,8 @@ class ProfileMuscleOxygenMonitor : public BaseMasterProfile { uint8_t _toggle; Callback _createMuscleOxygenDataMsg; + Callback _createMuscleOxygenManufacturerInformationMsg; + Callback _createMuscleOxygenProductInformationMsg; }; #endif // ANTPLUS_PROFILEMUSCLEOXYGENMONITOR_h From ea4ed6d702ea0995e91ac3622462245fda2dd7e7 Mon Sep 17 00:00:00 2001 From: Sepp62 <33748087+Sepp62@users.noreply.github.com> Date: Fri, 21 Jun 2019 12:57:35 +0200 Subject: [PATCH 018/241] MOxy: Refactoring manufacturer and product information Signed-off-by: Curtis Malainey --- .../MuscleOxygenMonitor/MuscleOxygenMonitor.ino | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino b/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino index 275a492..6a9ecfa 100644 --- a/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino +++ b/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino @@ -21,6 +21,8 @@ AntPlusRouter router = AntPlusRouter(); ProfileMuscleOxygenMonitor moxy = ProfileMuscleOxygenMonitor( 7369 ); void moxyCreateMsgHandler(MuscleOxygenBaseMainDataPageMsg& msg, uintptr_t data); +void moxyCreateManufacturerInformationMsg(ManufacturersInformationMsg& msg, uintptr_t data); +void moxyCreateProductInformationMsg(ProductInformationMsg& msg, uintptr_t data); void setup() { Serial2.begin(BAUD_RATE); @@ -37,6 +39,8 @@ void setup() { // setup muscle oxygen monitor moxy.createMuscleOxygenDataMsg(moxyCreateMsgHandler); + moxy.createMuscleOxygenManufacturerInformationMsg(moxyCreateManufacturerInformationMsg); + moxy.createMuscleOxygenProductInformationMsg(moxyCreateProductInformationMsg); moxy.begin(); } @@ -58,3 +62,15 @@ void moxyCreateMsgHandler(MuscleOxygenBaseMainDataPageMsg& msg, uintptr_t data) if (_c > hi) _c = lo; } + +void moxyCreateManufacturerInformationMsg(ManufacturersInformationMsg& msg, uintptr_t data) { + msg.setHWRevision(0x01); + msg.setManufacturerId(0x1234); + msg.setModelNumber(0x0001); +} + +void moxyCreateProductInformationMsg(ProductInformationMsg& msg, uintptr_t data) { + msg.setSerialNumber(0x12345678); + msg.setSWRevisionMain(0x01); + msg.setSWRevisionSupplemental(0x00); +} From 467199c3b5dcaf4ebe6b9bb65ed242d8d5b24bed Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 22 Jun 2019 15:58:42 -0700 Subject: [PATCH 019/241] MOxy: Merge conflict cleanup Handle cases where the rebase merged badly and conlicts were not handled correctly --- .../MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp index 9e9501e..7b82b11 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp @@ -56,6 +56,5 @@ void ProfileMuscleOxygenMonitor::transmitMuscleOxygenProductInformationMsg() { void ProfileMuscleOxygenMonitor::transmitMuscleOxygenMainPageMsg() { MuscleOxygenBaseMainDataPageMsg msg; _createMuscleOxygenDataMsg.call(msg); - msg.setDataBuffer(msg.getBuffer()); send(msg); } From cf9c119264ac551a5b04860707a4e009dc33ee4c Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Fri, 28 Jun 2019 08:15:03 -0700 Subject: [PATCH 020/241] Environment: Display: use generic callback for generic details Don't copy paste code, this is much better --- .../EnvironmentDisplay/EnvironmentDisplay.ino | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/examples/EnvironmentDisplay/EnvironmentDisplay.ino b/examples/EnvironmentDisplay/EnvironmentDisplay.ino index 5dde807..3237dc5 100644 --- a/examples/EnvironmentDisplay/EnvironmentDisplay.ino +++ b/examples/EnvironmentDisplay/EnvironmentDisplay.ino @@ -20,6 +20,7 @@ AntWithCallbacks ant = AntWithCallbacks(); AntPlusRouter router = AntPlusRouter(); ProfileEnvironmentDisplay env = ProfileEnvironmentDisplay(); +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: "); From 6008fedd9072237fec89b2a6eb97fb46f701b33d Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 6 Aug 2019 21:03:04 -0600 Subject: [PATCH 021/241] Shifting: Datapages: Refactor to new structure Move datapages to the new core/base format in preparation for changing to the new get/set api, this should also futureproof the profile --- examples/Shifting/Shifting.ino | 6 +- .../Shifting/ANTPLUS_ShiftingPrivateDefines.h | 2 +- .../ANTPLUS_ProfileShiftingDataPages.h | 7 +-- .../ANTPLUS_ShiftingBaseMainDataPageMsg.cpp | 33 +--------- .../ANTPLUS_ShiftingBaseMainDataPageMsg.h | 14 +---- .../ANTPLUS_ShiftingBaseShiftSystemStatus.cpp | 63 +++++++++++++++++++ .../ANTPLUS_ShiftingBaseShiftSystemStatus.h | 25 ++++++++ .../Base/ANTPLUS_ShiftingCoreMainDataPage.cpp | 14 +++++ .../Base/ANTPLUS_ShiftingCoreMainDataPage.h | 15 +++++ .../ANTPLUS_ShiftingShiftSystemStatusMsg.cpp | 49 +++++++++++++++ .../TX/ANTPLUS_ShiftingShiftSystemStatusMsg.h | 25 ++++++++ .../ANTPLUS_ProfileShiftingShifter.cpp | 4 +- .../Shifter/ANTPLUS_ProfileShiftingShifter.h | 4 +- 13 files changed, 206 insertions(+), 55 deletions(-) create mode 100644 src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseShiftSystemStatus.cpp create mode 100644 src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseShiftSystemStatus.h create mode 100644 src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingCoreMainDataPage.cpp create mode 100644 src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingCoreMainDataPage.h create mode 100644 src/Profiles/Shifting/DataPages/TX/ANTPLUS_ShiftingShiftSystemStatusMsg.cpp create mode 100644 src/Profiles/Shifting/DataPages/TX/ANTPLUS_ShiftingShiftSystemStatusMsg.h diff --git a/examples/Shifting/Shifting.ino b/examples/Shifting/Shifting.ino index 83c7aa0..cefb482 100644 --- a/examples/Shifting/Shifting.ino +++ b/examples/Shifting/Shifting.ino @@ -20,7 +20,7 @@ AntWithCallbacks ant = AntWithCallbacks(); AntPlusRouter router = AntPlusRouter(); ProfileShiftingShifter shift = ProfileShiftingShifter( 7370 ); -void shiftCreateMsgHandler(ShiftingBaseMainDataPageMsg& msg, uintptr_t data); +void shiftCreateMsgHandler(ShiftingShiftSystemStatusMsg& msg, uintptr_t data); void shiftCreateManufacturerInformationMsg(ManufacturersInformationMsg& msg, uintptr_t data); void shiftCreateProductInformationMsg(ProductInformationMsg& msg, uintptr_t data); @@ -37,7 +37,7 @@ void setup() { Serial.println("Running"); // setup shifting monitor - shift.createShiftingSystemStatusMsg(shiftCreateMsgHandler); + shift.createShiftingShiftSystemStatusMsg(shiftCreateMsgHandler); shift.createShiftingManufacturerInformationMsg(shiftCreateManufacturerInformationMsg); shift.createShiftingProductInformationMsg(shiftCreateProductInformationMsg); shift.begin(); @@ -48,7 +48,7 @@ void loop() { router.loop(); } -void shiftCreateMsgHandler(ShiftingBaseMainDataPageMsg& msg, uintptr_t data) +void shiftCreateMsgHandler(ShiftingShiftSystemStatusMsg& msg, uintptr_t data) { static int _gear = 0; static int _eventCount = 0; diff --git a/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h b/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h index 380fd54..2ba832c 100644 --- a/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h +++ b/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h @@ -2,7 +2,7 @@ #define ANTPLUS_SHIFTINGPROFILEPRIVATEDEFINES_h /* Channel Config */ -#define ANTPLUS_SHIFTING_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE +#define ANTPLUS_SHIFTING_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE #define ANTPLUS_SHIFTING_DEVICETYPE 34 #define ANTPLUS_SHIFTING_CHANNELPERIOD 8192 // Master channel (shifter) diff --git a/src/Profiles/Shifting/DataPages/ANTPLUS_ProfileShiftingDataPages.h b/src/Profiles/Shifting/DataPages/ANTPLUS_ProfileShiftingDataPages.h index 3d3bf48..07bc2ab 100644 --- a/src/Profiles/Shifting/DataPages/ANTPLUS_ProfileShiftingDataPages.h +++ b/src/Profiles/Shifting/DataPages/ANTPLUS_ProfileShiftingDataPages.h @@ -1,13 +1,10 @@ #ifndef ANTPLUS_PROFILESHIFTINGDATAPAGES_h #define ANTPLUS_PROFILESHIFTINGDATAPAGES_h -/* Base */ -#include - /* RX */ // ... /* TX */ -// ... +#include -#endif // ANTPLUS_PROFILESHIFTINGDATAPAGES_h \ No newline at end of file +#endif // ANTPLUS_PROFILESHIFTINGDATAPAGES_h diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp index 5e402b2..31773e3 100644 --- a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp +++ b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp @@ -2,39 +2,10 @@ #include #include -ShiftingBaseMainDataPageMsg::ShiftingBaseMainDataPageMsg() : BaseDataPageMsg() +ShiftingBaseMainDataPageMsg::ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber) : BaseDataPageMsg() { memset(_buffer, 0, MESSAGE_SIZE); setDataBuffer(_buffer); - _buffer[ANTPLUS_SHIFTING_DATAPAGEBASE_DATAPAGE_BYTE] = ANTPLUS_SHIFTING_DATAPAGE_SHIFTSYSTEMSTATUS_NUMBER; + set8BitValue(dataPageNumber, ANTPLUS_SHIFTING_DATAPAGEBASE_DATAPAGE_BYTE); _buffer[2] = 0xFF; } - -void ShiftingBaseMainDataPageMsg::setEventCount( uint8_t n ) -{ - _buffer[1] = n; -} - -void ShiftingBaseMainDataPageMsg::setCurrentGearRear(uint8_t cgr) -{ - _buffer[3] &= ~0x1F; - _buffer[3] |= cgr & 0x1F; -} - -void ShiftingBaseMainDataPageMsg::setCurrentGearFront( uint8_t cgf ) -{ - _buffer[3] &= ~0xE0; - _buffer[3] |= cgf << 5; -} - -void ShiftingBaseMainDataPageMsg::setTotalNumbersGearRear(uint8_t tgr) -{ - _buffer[4] &= ~0x1F; - _buffer[4] |= tgr & 0x1F; -} - -void ShiftingBaseMainDataPageMsg::setTotalNumbersGearFront( uint8_t tgf ) -{ - _buffer[4] &= ~0xE0; - _buffer[4] |= tgf << 5; -} diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h index 7114d65..1d31e0f 100644 --- a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h +++ b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h @@ -2,21 +2,13 @@ #define ANTPLUS_SHIFTINGBASEMAINDATAPAGEMSG_h #include -#include +#include #include "ANT.h" -class ShiftingBaseMainDataPageMsg : public BaseDataPageMsg { +class ShiftingBaseMainDataPageMsg : public BaseDataPageMsg, public ShiftingCoreMainDataPage { public: - ShiftingBaseMainDataPageMsg(); - - void setCurrentGearFront( uint8_t cgf ); - void setCurrentGearRear( uint8_t cgr ); - void setTotalNumbersGearFront( uint8_t tgr ); - void setTotalNumbersGearRear( uint8_t tgr ); - void setEventCount(uint8_t n); - // TODO there are some more parameters... - + ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber); protected: uint8_t _buffer[MESSAGE_SIZE]; }; diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseShiftSystemStatus.cpp b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseShiftSystemStatus.cpp new file mode 100644 index 0000000..38c529a --- /dev/null +++ b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseShiftSystemStatus.cpp @@ -0,0 +1,63 @@ +#include +#include + +template +ShiftingBaseShiftSystemStatus::ShiftingBaseShiftSystemStatus() : CoreDataPage() { +} + +template +uint8_t ShiftingBaseShiftSystemStatus::getEventCount() { + return this->get8BitValue(1); +} + +template +uint8_t ShiftingBaseShiftSystemStatus::getCurrentGearRear() { + return this->get8BitValue(3, 0x1F); +} + +template +uint8_t ShiftingBaseShiftSystemStatus::getCurrentGearFront() { + return this->get8BitValue(3, 0xE0, 5); +} + +template +uint8_t ShiftingBaseShiftSystemStatus::getTotalNumbersGearRear() { + return this->get8BitValue(4, 0x1F); +} + +template +uint8_t ShiftingBaseShiftSystemStatus::getTotalNumbersGearFront() { + return this->get8BitValue(4, 0xE0, 5); +} + +template +uint8_t ShiftingBaseShiftSystemStatus::getInvalidInboardShiftCountRear() { + return this->get8BitValue(5, 0x0F); +} + +template +uint8_t ShiftingBaseShiftSystemStatus::getInvalidOutboardShiftCountRear() { + return this->get8BitValue(5, 0xF0, 4); +} + +template +uint8_t ShiftingBaseShiftSystemStatus::getInvalidInboardShiftCountFront() { + return this->get8BitValue(6, 0x0F); +} + +template +uint8_t ShiftingBaseShiftSystemStatus::getInvalidOutboardShiftCountFront() { + return this->get8BitValue(6, 0xF0, 4); +} + +template +uint8_t ShiftingBaseShiftSystemStatus::getShiftFailureCountRear() { + return this->get8BitValue(7, 0x0F); +} + +template +uint8_t ShiftingBaseShiftSystemStatus::getShiftFailureCountFront() { + return this->get8BitValue(7, 0xF0, 4); +} + +template class ShiftingBaseShiftSystemStatus; diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseShiftSystemStatus.h b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseShiftSystemStatus.h new file mode 100644 index 0000000..8acd3db --- /dev/null +++ b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseShiftSystemStatus.h @@ -0,0 +1,25 @@ +#ifndef ANTPLUS_SHIFTINGBASESHIFTSYSTEMSTATUS_h +#define ANTPLUS_SHIFTINGBASESHIFTSYSTEMSTATUS_h + +#include + +#include "ANT.h" + +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(); +}; + +#endif // ANTPLUS_SHIFTINGBASESHIFTSYSTEMSTATUS_h diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingCoreMainDataPage.cpp b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingCoreMainDataPage.cpp new file mode 100644 index 0000000..41a3bf6 --- /dev/null +++ b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingCoreMainDataPage.cpp @@ -0,0 +1,14 @@ +#include +#include + +template +ShiftingCoreMainDataPage::ShiftingCoreMainDataPage() : CoreDataPage() { +} + +template +uint8_t ShiftingCoreMainDataPage::getDataPageNumber() { + return this->get8BitValue(ANTPLUS_SHIFTING_DATAPAGEBASE_DATAPAGE_BYTE); +} + +template class ShiftingCoreMainDataPage; +template class ShiftingCoreMainDataPage; diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingCoreMainDataPage.h b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingCoreMainDataPage.h new file mode 100644 index 0000000..54b4d27 --- /dev/null +++ b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingCoreMainDataPage.h @@ -0,0 +1,15 @@ +#ifndef ANTPLUS_SHIFTINGCOREMAINDATAPAGEMSG_h +#define ANTPLUS_SHIFTINGCOREMAINDATAPAGEMSG_h + +#include + +#include "ANT.h" + +template +class ShiftingCoreMainDataPage : virtual public CoreDataPage { +public: + ShiftingCoreMainDataPage(); + uint8_t getDataPageNumber(); +}; + +#endif // ANTPLUS_SHIFTINGCOREMAINDATAPAGEMSG_h diff --git a/src/Profiles/Shifting/DataPages/TX/ANTPLUS_ShiftingShiftSystemStatusMsg.cpp b/src/Profiles/Shifting/DataPages/TX/ANTPLUS_ShiftingShiftSystemStatusMsg.cpp new file mode 100644 index 0000000..c2b22aa --- /dev/null +++ b/src/Profiles/Shifting/DataPages/TX/ANTPLUS_ShiftingShiftSystemStatusMsg.cpp @@ -0,0 +1,49 @@ +#include +#include + +ShiftingShiftSystemStatusMsg::ShiftingShiftSystemStatusMsg() : ShiftingBaseMainDataPageMsg(ANTPLUS_SHIFTING_DATAPAGE_SHIFTSYSTEMSTATUS_NUMBER), ShiftingBaseShiftSystemStatus() { +} + +void ShiftingShiftSystemStatusMsg::setEventCount(uint8_t n) { + set8BitValue(n, 1); +} + +void ShiftingShiftSystemStatusMsg::setCurrentGearRear(uint8_t cgr) { + set8BitValue(cgr, 3, 0x1F); +} + +void ShiftingShiftSystemStatusMsg::setCurrentGearFront(uint8_t cgf) { + set8BitValue(cgf, 3, 0xE0, 5); +} + +void ShiftingShiftSystemStatusMsg::setTotalNumbersGearRear(uint8_t tgr) { + set8BitValue(tgr, 4, 0x1F); +} + +void ShiftingShiftSystemStatusMsg::setTotalNumbersGearFront(uint8_t tgf) { + set8BitValue(tgf, 4, 0xE0, 5); +} + +void ShiftingShiftSystemStatusMsg::setInvalidInboardShiftCountRear(uint8_t isr) { + set8BitValue(isr, 5, 0x0F); +} + +void ShiftingShiftSystemStatusMsg::setInvalidOutboardShiftCountRear(uint8_t osr) { + set8BitValue(osr, 0xF0, 4); +} + +void ShiftingShiftSystemStatusMsg::setInvalidInboardShiftCountFront(uint8_t isf) { + set8BitValue(isf, 6, 0x0F); +} + +void ShiftingShiftSystemStatusMsg::setInvalidOutboardShiftCountFront(uint8_t osf) { + set8BitValue(osf, 6, 0xF0, 4); +} + +void ShiftingShiftSystemStatusMsg::setShiftFailureCountRear(uint8_t sfr) { + set8BitValue(sfr, 7, 0x0F); +} + +void ShiftingShiftSystemStatusMsg::setShiftFailureCountFront(uint8_t sff) { + set8BitValue(sff, 7, 0xF0, 4); +} diff --git a/src/Profiles/Shifting/DataPages/TX/ANTPLUS_ShiftingShiftSystemStatusMsg.h b/src/Profiles/Shifting/DataPages/TX/ANTPLUS_ShiftingShiftSystemStatusMsg.h new file mode 100644 index 0000000..d6cd7ab --- /dev/null +++ b/src/Profiles/Shifting/DataPages/TX/ANTPLUS_ShiftingShiftSystemStatusMsg.h @@ -0,0 +1,25 @@ +#ifndef ANTPLUS_SHIFTINGSHIFTSYSTEMSTATUSMSG_h +#define ANTPLUS_SHIFTINGSHIFTSYSTEMSTATUSMSG_h + +#include +#include + +#include "ANT.h" + +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_SHIFTINGSHIFTSYSTEMSTATUSMSG_h diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp index 5d81aa6..7565500 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp @@ -57,8 +57,8 @@ void ProfileShiftingShifter::transmitShiftingProductInformationMsg() { } void ProfileShiftingShifter::transmitShiftingMainPageMsg() { - ShiftingBaseMainDataPageMsg msg; - _createShiftingSystemStatusMsg.call(msg); + ShiftingShiftSystemStatusMsg msg; + _createShiftingShiftSystemStatusMsg.call(msg); send(msg); } diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h index 01f5ea8..4751af5 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h @@ -13,7 +13,7 @@ class ProfileShiftingShifter : public BaseMasterProfile { /** * Register callback to populate default data messages (Datapage 0) */ - void createShiftingSystemStatusMsg(void(*func)(ShiftingBaseMainDataPageMsg&, uintptr_t), uintptr_t data = 0) { _createShiftingSystemStatusMsg.set(func, data); } + void createShiftingSystemStatusMsg(void(*func)(ShiftingShiftSystemStatusMsg&, uintptr_t), uintptr_t data = 0) { _createShiftingShiftSystemStatusMsg.set(func, data); } /** * Register callback to populate manufacturer information data messages (Datapage 2) */ @@ -37,7 +37,7 @@ class ProfileShiftingShifter : public BaseMasterProfile { uint8_t _patternStep; uint8_t _toggle; - Callback _createShiftingSystemStatusMsg; + Callback _createShiftingShiftSystemStatusMsg; Callback _createShiftingManufacturerInformationMsg; Callback _createShiftingProductInformationMsg; }; From 5ffaf91c51559dcb029f015d5c7f91ef18a20803 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 6 Aug 2019 21:24:20 -0600 Subject: [PATCH 022/241] CommonDataPages: Fix include Make header include more direct, minor optimization --- src/CommonDataPages/Base/ANTPLUS_BaseProductInformation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CommonDataPages/Base/ANTPLUS_BaseProductInformation.cpp b/src/CommonDataPages/Base/ANTPLUS_BaseProductInformation.cpp index 8e0d100..5cad09d 100644 --- a/src/CommonDataPages/Base/ANTPLUS_BaseProductInformation.cpp +++ b/src/CommonDataPages/Base/ANTPLUS_BaseProductInformation.cpp @@ -1,4 +1,4 @@ -#include +#include #include template From c88a08072ba62beb144c6689d43728d0ea1a07f5 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Wed, 14 Aug 2019 20:52:53 -0700 Subject: [PATCH 023/241] CommonDataPages: Add BatteryStatus Implemented both TX and RX --- .../ANTPLUS_CommonDataPagePrivateDefines.h | 21 +++++++ .../Base/ANTPLUS_BaseBatteryStatus.cpp | 60 +++++++++++++++++++ .../Base/ANTPLUS_BaseBatteryStatus.h | 23 +++++++ .../RX/ANTPLUS_BatteryStatus.cpp | 5 +- .../RX/ANTPLUS_BatteryStatus.h | 18 +++++- .../TX/ANTPLUS_BatteryStatusMsg.cpp | 53 +++++++++++++++- .../TX/ANTPLUS_BatteryStatusMsg.h | 24 +++++++- 7 files changed, 198 insertions(+), 6 deletions(-) create mode 100644 src/CommonDataPages/Base/ANTPLUS_BaseBatteryStatus.cpp create mode 100644 src/CommonDataPages/Base/ANTPLUS_BaseBatteryStatus.h diff --git a/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h b/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h index ba2fbd0..abfc59d 100644 --- a/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h +++ b/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h @@ -47,4 +47,25 @@ #define ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SERIALNUMBER_LSB_BYTE 4 #define ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SERIALNUMBER_MSB_BYTE 7 +/* Battery Status */ +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER 82 + +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_BYTE 2 +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_NUMBEROFBATTERIES_MASK 0x0F +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_IDENTIFIER_MASK 0xF0 +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_IDENTIFIER_SHIFT 4 + +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIME_LSB_BYTE 3 +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIME_MSB_BYTE 5 + +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE 6 + +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE 7 +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_COARSEBATTERYVOLTAGE_MASK 0x0F +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BATTERYSTATUS_MASK 0x70 +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BATTERYSTATUS_SHIFT 4 +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_MASK 0x80 +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_SHIFT 7 + + #endif // ANTPLUS_COMMONDATAPAGEPRIVATEDEFINES_h diff --git a/src/CommonDataPages/Base/ANTPLUS_BaseBatteryStatus.cpp b/src/CommonDataPages/Base/ANTPLUS_BaseBatteryStatus.cpp new file mode 100644 index 0000000..a47cc99 --- /dev/null +++ b/src/CommonDataPages/Base/ANTPLUS_BaseBatteryStatus.cpp @@ -0,0 +1,60 @@ +#include +#include + +template +BaseBatteryStatus::BaseBatteryStatus() : CoreDataPage() { +} + +template +uint8_t BaseBatteryStatus::getNumberOfBatteries() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_NUMBEROFBATTERIES_MASK); +} + +template +uint8_t BaseBatteryStatus::getBatteryIdentifier() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_IDENTIFIER_MASK, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_IDENTIFIER_SHIFT); +} + +template +uint32_t BaseBatteryStatus::getCumulativeOperatingTime() { + return this->get24BitValue( + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIME_LSB_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIME_MSB_BYTE); +} + +template +uint8_t BaseBatteryStatus::getFractionalBatteryVoltage() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE); +} + +template +uint8_t BaseBatteryStatus::getCoarseBatteryVoltage() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_COARSEBATTERYVOLTAGE_MASK); +} + +template +uint8_t BaseBatteryStatus::getBatteryStatus() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BATTERYSTATUS_MASK, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BATTERYSTATUS_SHIFT); +} + +template +uint8_t BaseBatteryStatus::getCumulativeOperatingTimeResolution() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_MASK, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_SHIFT); +} + +template class BaseBatteryStatus; +template class BaseBatteryStatus; diff --git a/src/CommonDataPages/Base/ANTPLUS_BaseBatteryStatus.h b/src/CommonDataPages/Base/ANTPLUS_BaseBatteryStatus.h new file mode 100644 index 0000000..1513edf --- /dev/null +++ b/src/CommonDataPages/Base/ANTPLUS_BaseBatteryStatus.h @@ -0,0 +1,23 @@ +#ifndef ANTPLUS_BASEBATTERYSTATUS_h +#define ANTPLUS_BASEBATTERYSTATUS_h + +#include + +#include "ANT.h" + +// 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(); +}; + +#endif // ANTPLUS_BASEBATTERYSTATUS_h diff --git a/src/CommonDataPages/RX/ANTPLUS_BatteryStatus.cpp b/src/CommonDataPages/RX/ANTPLUS_BatteryStatus.cpp index 0ffdd02..0e690f0 100644 --- a/src/CommonDataPages/RX/ANTPLUS_BatteryStatus.cpp +++ b/src/CommonDataPages/RX/ANTPLUS_BatteryStatus.cpp @@ -1 +1,4 @@ -// TODO \ No newline at end of file +#include + +BatteryStatus::BatteryStatus(AntRxDataResponse& dp) : BaseDataPage(dp), BaseBatteryStatus() { +} diff --git a/src/CommonDataPages/RX/ANTPLUS_BatteryStatus.h b/src/CommonDataPages/RX/ANTPLUS_BatteryStatus.h index 04c978c..a8e12e6 100644 --- a/src/CommonDataPages/RX/ANTPLUS_BatteryStatus.h +++ b/src/CommonDataPages/RX/ANTPLUS_BatteryStatus.h @@ -1,2 +1,16 @@ -// Common Page 82 -// TODO \ No newline at end of file +#ifndef ANTPLUS_BATTERYSTATUS_h +#define ANTPLUS_BATTERYSTATUS_h + +#include +#include + +#include "ANT.h" + +// Common page 82 + +class BatteryStatus : public BaseDataPage, public BaseBatteryStatus { +public: + BatteryStatus(AntRxDataResponse& dp); +}; + +#endif // ANTPLUS_BATTERYSTATUS_h diff --git a/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.cpp index 0ffdd02..1675291 100644 --- a/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.cpp +++ b/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.cpp @@ -1 +1,52 @@ -// TODO \ No newline at end of file +#include +#include +#include + +BatteryStatusMsg::BatteryStatusMsg() : BaseDataPageMsg(), BaseBatteryStatus() { + set8BitValue(ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER, + ANTPLUS_DEFAULT_DATAPAGE_BYTE); +} + +void BatteryStatusMsg::setNumberOfBatteries(uint8_t num) { + set8BitValue(num, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_NUMBEROFBATTERIES_MASK); +} + +void BatteryStatusMsg::setBatteryIdentifier(uint8_t id) { + set8BitValue(id, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_IDENTIFIER_MASK, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_IDENTIFIER_SHIFT); +} + +void BatteryStatusMsg::setCumulativeOperatingTime(uint32_t time) { + set24BitValue(time, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIME_LSB_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIME_MSB_BYTE); +} + +void BatteryStatusMsg::setFractionalBatteryVoltage(uint8_t voltage) { + set8BitValue(voltage, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE); +} + +void BatteryStatusMsg::setCoarseBatteryVoltage(uint8_t voltage) { + set8BitValue(voltage, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_COARSEBATTERYVOLTAGE_MASK); +} + +void BatteryStatusMsg::setBatteryStatus(uint8_t status) { + set8BitValue(status, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BATTERYSTATUS_MASK, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BATTERYSTATUS_SHIFT); +} + +void BatteryStatusMsg::setCumulativeOperatingTimeResolution(uint8_t resolution) { + set8BitValue(resolution, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_MASK, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_SHIFT); +} diff --git a/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.h b/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.h index 04c978c..c0ca20d 100644 --- a/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.h +++ b/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.h @@ -1,2 +1,22 @@ -// Common Page 82 -// TODO \ No newline at end of file +#ifndef ANTPLUS_BATTERYSTATUSMSG_h +#define ANTPLUS_BATTERYSTATUSMSG_h + +#include +#include + +#include "ANT.h" + +// Common page 82 + +class BatteryStatusMsg : public BaseDataPageMsg, public BaseBatteryStatus { + 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); +}; + +#endif // ANTPLUS_BATTERYSTATUSMSG_h From f888a1be8f38e418f489ebad694b40f009a82f34 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Wed, 14 Aug 2019 21:09:41 -0700 Subject: [PATCH 024/241] CommonDataPages: Refactor RequestDataPageMsg Move to new set api --- .../TX/ANTPLUS_RequestDataPageMsg.cpp | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/CommonDataPages/TX/ANTPLUS_RequestDataPageMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_RequestDataPageMsg.cpp index 8c84e74..2e41cb9 100644 --- a/src/CommonDataPages/TX/ANTPLUS_RequestDataPageMsg.cpp +++ b/src/CommonDataPages/TX/ANTPLUS_RequestDataPageMsg.cpp @@ -7,40 +7,48 @@ RequestDataPageMsg::RequestDataPageMsg() : BaseDataPageMsg(), BaseRequestDataPag 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; + set8BitValue(ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER, + ANTPLUS_DEFAULT_DATAPAGE_BYTE); } void RequestDataPageMsg::setSlaveSerialNumber(uint16_t serialNumber) { - this->set16BitValue(serialNumber, + 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; + set8BitValue(descriptorByte, + ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE1_BYTE); } void RequestDataPageMsg::setDescriptorByte2(uint8_t descriptorByte) { - _buffer[ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE2_BYTE] = descriptorByte; + set8BitValue(descriptorByte, + ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE2_BYTE); } 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); + set8BitValue(count, + ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_BYTE, + 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); + set8BitValue(useAcknowledged ? 1 : 0, + ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_BYTE, + ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_MASK, + ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_SHIFT); } void RequestDataPageMsg::setRequestedPageNumber(uint8_t pageNumber) { - _buffer[ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDPAGENUMBER_BYTE] = pageNumber; + set8BitValue(pageNumber, + ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDPAGENUMBER_BYTE); } 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; + set8BitValue(commandType, + ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_COMMANDTYPE_BYTE); } From cd5873dadfe6894b0054c3d732a2e3c090afcb93 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Wed, 14 Aug 2019 22:00:08 -0700 Subject: [PATCH 025/241] CommonDataPages: Add MultiComponentSystemProductInformation datapage Add both TX and RX --- .../ANTPLUS_CommonDataPagePrivateDefines.h | 15 +++++++ ...MultiComponentSystemProductInformation.cpp | 43 +++++++++++++++++++ ...seMultiComponentSystemProductInformation.h | 21 +++++++++ ...MultiComponentSystemProductInformation.cpp | 5 ++- ...S_MultiComponentSystemProductInformation.h | 18 +++++++- ...tiComponentSystemProductInformationMsg.cpp | 36 +++++++++++++++- ...ultiComponentSystemProductInformationMsg.h | 22 +++++++++- 7 files changed, 154 insertions(+), 6 deletions(-) create mode 100644 src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemProductInformation.cpp create mode 100644 src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemProductInformation.h diff --git a/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h b/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h index abfc59d..1986b1f 100644 --- a/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h +++ b/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h @@ -26,6 +26,21 @@ #define ANTPLUS_COMMON_DATAPAGE_MODESETTINGS_SPORTSMODE_BYTE 7 +/* Multi-Component System Product Information */ +#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER 79 + +#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_BYTE 1 +#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_NUMBEROFCOMPONENTS_MASK 0x0F +#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_MASK 0xF0 +#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_SHIFT 4 + +#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SWREVISIONSUPPLEMENTAL_BYTE 2 + +#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SWREVISIONMAIN_BYTE 3 + +#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SERIALNUMBER_LSB_BYTE 4 +#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SERIALNUMBER_MSB_BYTE 7 + /* Manufacturers Information */ #define ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER 80 diff --git a/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemProductInformation.cpp b/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemProductInformation.cpp new file mode 100644 index 0000000..2ba388d --- /dev/null +++ b/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemProductInformation.cpp @@ -0,0 +1,43 @@ +#include +#include + +template +BaseMultiComponentSystemProductInformation::BaseMultiComponentSystemProductInformation() : CoreDataPage() { +} + +template +uint8_t BaseMultiComponentSystemProductInformation::getNumberOfComponents() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_NUMBEROFCOMPONENTS_MASK); +} + +template +uint8_t BaseMultiComponentSystemProductInformation::getComponentIdentifier() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_MASK, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); +} + +template +uint8_t BaseMultiComponentSystemProductInformation::getSWRevisionSupplemental() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SWREVISIONSUPPLEMENTAL_BYTE); +} + +template +uint8_t BaseMultiComponentSystemProductInformation::getSWRevisionMain() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SWREVISIONMAIN_BYTE); +} + +template +uint32_t BaseMultiComponentSystemProductInformation::getSerialNumber() { + return this->get32BitValue( + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SERIALNUMBER_LSB_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SERIALNUMBER_MSB_BYTE); +} + +template class BaseMultiComponentSystemProductInformation; +template class BaseMultiComponentSystemProductInformation; diff --git a/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemProductInformation.h b/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemProductInformation.h new file mode 100644 index 0000000..3ebd3e8 --- /dev/null +++ b/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemProductInformation.h @@ -0,0 +1,21 @@ +#ifndef ANTPLUS_BASEMULTICOMPONENTSYSTEMPRODUCTINFORMATION_h +#define ANTPLUS_BASEMULTICOMPONENTSYSTEMPRODUCTINFORMATION_h + +#include + +#include "ANT.h" + +// 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(); +}; + +#endif // ANTPLUS_BASEMULTICOMPONENTSYSTEMPRODUCTINFORMATION_h diff --git a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.cpp b/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.cpp index 0ffdd02..0ab0418 100644 --- a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.cpp +++ b/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.cpp @@ -1 +1,4 @@ -// TODO \ No newline at end of file +#include + +MultiComponentSystemProductInformation::MultiComponentSystemProductInformation(AntRxDataResponse& dp) : BaseDataPage(dp), BaseMultiComponentSystemProductInformation() { +} diff --git a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.h b/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.h index b9bfbf9..b860016 100644 --- a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.h +++ b/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.h @@ -1,2 +1,16 @@ -// Common Page 79 -// TODO \ No newline at end of file +#ifndef ANTPLUS_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_h +#define ANTPLUS_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_h + +#include +#include + +#include "ANT.h" + +// Common page 79 + +class MultiComponentSystemProductInformation : public BaseDataPage, public BaseMultiComponentSystemProductInformation { +public: + MultiComponentSystemProductInformation(AntRxDataResponse& dp); +}; + +#endif // ANTPLUS_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_h diff --git a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.cpp index 0ffdd02..92bbe9f 100644 --- a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.cpp +++ b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.cpp @@ -1 +1,35 @@ -// TODO \ No newline at end of file +#include +#include +#include + +MultiComponentSystemProductInformationMsg::MultiComponentSystemProductInformationMsg() : BaseDataPageMsg(), BaseMultiComponentSystemProductInformation() { +} + +void MultiComponentSystemProductInformationMsg::setNumberOfComponents(uint8_t count) { + set8BitValue(count, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_NUMBEROFCOMPONENTS_MASK); +} + +void MultiComponentSystemProductInformationMsg::setComponentIdentifier(uint8_t identifier) { + set8BitValue(identifier, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_MASK, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); +} + +void MultiComponentSystemProductInformationMsg::setSWRevisionSupplemental(uint8_t revision) { + set8BitValue(revision, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SWREVISIONSUPPLEMENTAL_BYTE); +} + +void MultiComponentSystemProductInformationMsg::setSWRevisionMain(uint8_t revision) { + set8BitValue(revision, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SWREVISIONMAIN_BYTE); +} + +void MultiComponentSystemProductInformationMsg::setSerialNumber(uint32_t serialNumber) { + set32BitValue(serialNumber, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SERIALNUMBER_LSB_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SERIALNUMBER_MSB_BYTE); +} diff --git a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.h b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.h index b9bfbf9..b79ada5 100644 --- a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.h +++ b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.h @@ -1,2 +1,20 @@ -// Common Page 79 -// TODO \ No newline at end of file +#ifndef ANTPLUS_MULTICOMPONENTSYSTEMPRODUCTINFORMATIONMSG_h +#define ANTPLUS_MULTICOMPONENTSYSTEMPRODUCTINFORMATIONMSG_h + +#include +#include + +#include "ANT.h" + +// Common page 79 + +class MultiComponentSystemProductInformationMsg : public BaseDataPageMsg, public BaseMultiComponentSystemProductInformation { + 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); +}; + +#endif // ANTPLUS_MULTICOMPONENTSYSTEMPRODUCTINFORMATIONMSG_h From f09e4633ecdefe63a1ea92e31231d626d8668d9f Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 24 Aug 2019 14:40:24 -0700 Subject: [PATCH 026/241] CommonDataPages: Add Multi Component System Manufacturers Information Add datapage 78 --- .../ANTPLUS_CommonDataPagePrivateDefines.h | 16 +++++++ ...omponentSystemManufacturersInformation.cpp | 44 +++++++++++++++++++ ...iComponentSystemManufacturersInformation.h | 21 +++++++++ ...omponentSystemManufacturersInformation.cpp | 6 ++- ...iComponentSystemManufacturersInformation.h | 18 +++++++- ...onentSystemManufacturersInformationMsg.cpp | 37 +++++++++++++++- ...mponentSystemManufacturersInformationMsg.h | 22 +++++++++- 7 files changed, 156 insertions(+), 8 deletions(-) create mode 100644 src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemManufacturersInformation.cpp create mode 100644 src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemManufacturersInformation.h diff --git a/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h b/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h index 1986b1f..0cb1ce1 100644 --- a/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h +++ b/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h @@ -26,6 +26,22 @@ #define ANTPLUS_COMMON_DATAPAGE_MODESETTINGS_SPORTSMODE_BYTE 7 +/* Multi-Component System Manufacturer's Information */ +#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER 78 + +#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_BYTE 2 +#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_NUMBERCOMPONENTS_MASK 0x0F +#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_MASK 0xF0 +#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_SHIFT 4 + +#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_HWREVISION_BYTE 3 + +#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_LSB_BYTE 4 +#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_MSB_BYTE 5 + +#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MODELNUMBER_LSB_BYTE 6 +#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MODELNUMBER_MSB_BYTE 7 + /* Multi-Component System Product Information */ #define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER 79 diff --git a/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemManufacturersInformation.cpp b/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemManufacturersInformation.cpp new file mode 100644 index 0000000..1b78e39 --- /dev/null +++ b/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemManufacturersInformation.cpp @@ -0,0 +1,44 @@ +#include +#include + +template +BaseMultiComponentSystemManufacturersInformation::BaseMultiComponentSystemManufacturersInformation() : CoreDataPage() { +} + +template +uint8_t BaseMultiComponentSystemManufacturersInformation::getNumberOfComponents() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_NUMBERCOMPONENTS_MASK); +} + +template +uint8_t BaseMultiComponentSystemManufacturersInformation::getComponentIdentifier() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_MASK, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); +} + +template +uint8_t BaseMultiComponentSystemManufacturersInformation::getHWRevision() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_HWREVISION_BYTE); +} + +template +uint16_t BaseMultiComponentSystemManufacturersInformation::getManufacturerID() { + return this->get16BitValue( + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_LSB_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_MSB_BYTE); +} + +template +uint16_t BaseMultiComponentSystemManufacturersInformation::getModelNumber() { + return this->get16BitValue( + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MODELNUMBER_LSB_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MODELNUMBER_MSB_BYTE); +} + +template class BaseMultiComponentSystemManufacturersInformation; +template class BaseMultiComponentSystemManufacturersInformation; diff --git a/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemManufacturersInformation.h b/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemManufacturersInformation.h new file mode 100644 index 0000000..0ebf4fc --- /dev/null +++ b/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemManufacturersInformation.h @@ -0,0 +1,21 @@ +#ifndef ANTPLUS_BASEMULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_h +#define ANTPLUS_BASEMULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_h + +#include + +#include "ANT.h" + +// 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(); +}; + +#endif // ANTPLUS_BASEMULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_h diff --git a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp b/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp index 219841a..a89f9ec 100644 --- a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp +++ b/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp @@ -1,2 +1,4 @@ -// Common page 78 -// TODO \ No newline at end of file +#include + +MultiComponentSystemManufacturersInformation::MultiComponentSystemManufacturersInformation(AntRxDataResponse& dp) : BaseDataPage(dp), BaseMultiComponentSystemManufacturersInformation() { +} diff --git a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.h b/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.h index b9bfbf9..847b237 100644 --- a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.h +++ b/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.h @@ -1,2 +1,16 @@ -// Common Page 79 -// TODO \ No newline at end of file +#ifndef ANTPLUS_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_h +#define ANTPLUS_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_h + +#include +#include + +#include "ANT.h" + +// Common page 78 + +class MultiComponentSystemManufacturersInformation : public BaseDataPage, public BaseMultiComponentSystemManufacturersInformation { +public: + MultiComponentSystemManufacturersInformation(AntRxDataResponse& dp); +}; + +#endif // ANTPLUS_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_h diff --git a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp index 219841a..0f97053 100644 --- a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp +++ b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp @@ -1,2 +1,35 @@ -// Common page 78 -// TODO \ No newline at end of file +#include +#include + +MultiComponentSystemManufacturersInformationMsg::MultiComponentSystemManufacturersInformationMsg() : BaseDataPageMsg(), BaseMultiComponentSystemManufacturersInformation() { +} + +void MultiComponentSystemManufacturersInformationMsg::setNumberOfComponents(uint8_t count) { + return set8BitValue(count, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_NUMBERCOMPONENTS_MASK); +} + +void MultiComponentSystemManufacturersInformationMsg::setComponentIdentifier(uint8_t identifier) { + set8BitValue(identifier, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_MASK, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); +} + +void MultiComponentSystemManufacturersInformationMsg::setHWRevision(uint8_t rev) { + set8BitValue(rev, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_HWREVISION_BYTE); +} + +void MultiComponentSystemManufacturersInformationMsg::setManufacturerID(uint16_t id) { + set16BitValue(id, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_LSB_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_MSB_BYTE); +} + +void MultiComponentSystemManufacturersInformationMsg::setModelNumber(uint16_t model) { + set16BitValue(model, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MODELNUMBER_LSB_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MODELNUMBER_MSB_BYTE); +} diff --git a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h index b9bfbf9..3da679f 100644 --- a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h +++ b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h @@ -1,2 +1,20 @@ -// Common Page 79 -// TODO \ No newline at end of file +#ifndef ANTPLUS_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATIONMSG_h +#define ANTPLUS_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATIONMSG_h + +#include +#include + +#include "ANT.h" + +// Common page 78 + +class MultiComponentSystemManufacturersInformationMsg : public BaseDataPageMsg, public BaseMultiComponentSystemManufacturersInformation { + 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); +}; + +#endif // ANTPLUS_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATIONMSG_h From 20ce74e9e07717136bec475cff1643780385b8dd Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 24 Aug 2019 15:57:36 -0700 Subject: [PATCH 027/241] Shifting: Shifter: Add todo about transmission pattern quirk --- src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp index 7565500..24cd6fc 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp @@ -28,6 +28,7 @@ bool ProfileShiftingShifter::isDataPageValid(uint8_t dataPage) } void ProfileShiftingShifter::transmitNextDataPage() { + // TODO the pattern needs to adjust in when a shift event occurs if (_patternStep++ < 64) { transmitShiftingMainPageMsg(); } From 8475143ed2284f38f2589c163b3a5780dd4abfd0 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 25 Aug 2019 14:29:12 -0700 Subject: [PATCH 028/241] CommonDataPages: Add missing public declarations Kinda need this to instantiate the objects --- src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.h | 1 + .../TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h | 1 + .../TX/ANTPLUS_MultiComponentSystemProductInformationMsg.h | 1 + 3 files changed, 3 insertions(+) diff --git a/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.h b/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.h index c0ca20d..727afbb 100644 --- a/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.h +++ b/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.h @@ -9,6 +9,7 @@ // Common page 82 class BatteryStatusMsg : public BaseDataPageMsg, public BaseBatteryStatus { +public: BatteryStatusMsg(); void setNumberOfBatteries(uint8_t num); void setBatteryIdentifier(uint8_t id); diff --git a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h index 3da679f..bfe7edc 100644 --- a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h +++ b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h @@ -9,6 +9,7 @@ // Common page 78 class MultiComponentSystemManufacturersInformationMsg : public BaseDataPageMsg, public BaseMultiComponentSystemManufacturersInformation { +public: MultiComponentSystemManufacturersInformationMsg(); void setNumberOfComponents(uint8_t count); void setComponentIdentifier(uint8_t identifier); diff --git a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.h b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.h index b79ada5..8b46354 100644 --- a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.h +++ b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.h @@ -9,6 +9,7 @@ // Common page 79 class MultiComponentSystemProductInformationMsg : public BaseDataPageMsg, public BaseMultiComponentSystemProductInformation { +public: MultiComponentSystemProductInformationMsg(); void setNumberOfComponents(uint8_t count); void setComponentIdentifier(uint8_t identifier); From ff208d7bf3b907f202ad4f59d2302f38a36f6be1 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 25 Aug 2019 14:36:10 -0700 Subject: [PATCH 029/241] Shifting: Shifter: Initial cleanup Cleanup style Use new transmit function Add missing datapages Replace incorrect data pages Fix up transsmission pattern code --- .../ANTPLUS_ProfileShiftingShifter.cpp | 60 ++++++++++++------- .../Shifter/ANTPLUS_ProfileShiftingShifter.h | 31 ++++++---- 2 files changed, 57 insertions(+), 34 deletions(-) diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp index 24cd6fc..8a8321f 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp @@ -1,11 +1,12 @@ #include #include +#define INTERLEAVE_STEP 65 -ProfileShiftingShifter::ProfileShiftingShifter( uint16_t deviceNumber, uint8_t transmissionType) : +ProfileShiftingShifter::ProfileShiftingShifter(uint16_t deviceNumber, uint8_t transmissionType) : BaseMasterProfile(deviceNumber, transmissionType), - _patternStep( 0 ), - _toggle(0) + _patternStep(0), + _backgroundStep(0) { setChannelConfig(); } @@ -29,37 +30,52 @@ bool ProfileShiftingShifter::isDataPageValid(uint8_t dataPage) void ProfileShiftingShifter::transmitNextDataPage() { // TODO the pattern needs to adjust in when a shift event occurs - if (_patternStep++ < 64) { + if (_patternStep++ < INTERLEAVE_STEP) { transmitShiftingMainPageMsg(); + } else { + transmitBackgroundDataPage(); + _patternStep = 0; } - else { +} - if (_toggle++ % 2 == 0) { - transmitShiftingManufacturerInformationMsg(); - } - else { - transmitShiftingProductInformationMsg(); - } - // TODO battery status and some more pages - _patternStep = 0; +void ProfileShiftingShifter::transmitBackgroundDataPage() { + _backgroundStep += 1; + switch (_backgroundStep) { + case 0: + transmitMultiComponentSystemManufacturersInformationMsg(); + break; + case 1: + transmitMultiComponentSystemProductInformationMsg(); + break; + case 2: + transmitBatteryStatusMsg(); + // prevent roll overs + _backgroundStep = 0; + break; } } -void ProfileShiftingShifter::transmitShiftingManufacturerInformationMsg() { - ManufacturersInformationMsg msg; - _createShiftingManufacturerInformationMsg.call(msg); - send(msg); +void ProfileShiftingShifter::transmitMultiComponentSystemManufacturersInformationMsg() { + MultiComponentSystemManufacturersInformationMsg msg; + _createMultiComponentSystemManufacturersInformationMsg.call(msg); + transmitMsg(msg); +} + +void ProfileShiftingShifter::transmitMultiComponentSystemProductInformationMsg() { + MultiComponentSystemProductInformationMsg msg; + _createMultiComponentSystemProductInformationMsg.call(msg); + transmitMsg(msg); } -void ProfileShiftingShifter::transmitShiftingProductInformationMsg() { - ProductInformationMsg msg; - _createShiftingProductInformationMsg.call(msg); - send(msg); +void ProfileShiftingShifter::transmitBatteryStatusMsg() { + BatteryStatusMsg msg; + _createBatteryStatusMsg.call(msg); + transmitMsg(msg); } void ProfileShiftingShifter::transmitShiftingMainPageMsg() { ShiftingShiftSystemStatusMsg msg; _createShiftingShiftSystemStatusMsg.call(msg); - send(msg); + transmitMsg(msg); } diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h index 4751af5..e5f2c9e 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h @@ -11,35 +11,42 @@ class ProfileShiftingShifter : public BaseMasterProfile { ProfileShiftingShifter(uint16_t deviceNumber, uint8_t transmissionType = ANTPLUS_SHIFTING_SHIFTER_TRANSMISSIONTYPE); /** - * Register callback to populate default data messages (Datapage 0) + * Register callback to populate default data messages (Datapage 1) */ void createShiftingSystemStatusMsg(void(*func)(ShiftingShiftSystemStatusMsg&, uintptr_t), uintptr_t data = 0) { _createShiftingShiftSystemStatusMsg.set(func, data); } /** - * Register callback to populate manufacturer information data messages (Datapage 2) + * Register callback to populate multi component system manufacturer information data messages (Datapage 78) */ - void createShiftingManufacturerInformationMsg(void(*func)(ManufacturersInformationMsg&, uintptr_t), uintptr_t data = 0) { _createShiftingManufacturerInformationMsg.set(func, data); } + void createMultiComponentSystemManufacturersInformationMsg(void(*func)(MultiComponentSystemManufacturersInformationMsg&, uintptr_t), uintptr_t data = 0) { _createMultiComponentSystemManufacturersInformationMsg.set(func, data); } /** - * Register callback to populate product information data messages (Datapage 3) + * Register callback to populate multi component system product information data messages (Datapage 79) */ - void createShiftingProductInformationMsg(void(*func)(ProductInformationMsg&, uintptr_t), uintptr_t data = 0) { _createShiftingProductInformationMsg.set(func, data); } + 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); } protected: virtual void transmitNextDataPage(); virtual bool isDataPageValid(uint8_t dataPage); - void transmitShiftingManufacturerInformationMsg(); - void transmitShiftingProductInformationMsg(); - private: - void setChannelConfig(); void transmitShiftingMainPageMsg(); + void transmitMultiComponentSystemManufacturersInformationMsg(); + void transmitMultiComponentSystemProductInformationMsg(); + void transmitBatteryStatusMsg(); + + void transmitBackgroundDataPage(); + void setChannelConfig(); uint8_t _patternStep; - uint8_t _toggle; + uint8_t _backgroundStep; Callback _createShiftingShiftSystemStatusMsg; - Callback _createShiftingManufacturerInformationMsg; - Callback _createShiftingProductInformationMsg; + Callback _createMultiComponentSystemManufacturersInformationMsg; + Callback _createMultiComponentSystemProductInformationMsg; + Callback _createBatteryStatusMsg; }; #endif // ANTPLUS_PROFILESHIFTINGSHIFTER_h From 5acd516ab8c43b744d5e2b7a1ff988551b09ee8b Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 25 Aug 2019 15:24:18 -0700 Subject: [PATCH 030/241] Shifting: Shifter: Add additional datapges to callback Install all datapages supported as valid --- .../Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp index 8a8321f..acfd820 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp @@ -22,8 +22,10 @@ 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; - // TODO other datapages } return false; } From c9d3bd59f9b3bb092e83f57cc3979238a1fd2009 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 25 Aug 2019 15:25:16 -0700 Subject: [PATCH 031/241] Shifting: Shifter: Add shift counter for transmission pattern This will track shift event counts since on any shift event datapage 1 must be transmitted 4 times in a row. This will override any background datapages. Tracking of shift changes still needs to happen. --- .../Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp | 9 +++++---- .../Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp index acfd820..42704af 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp @@ -6,7 +6,8 @@ ProfileShiftingShifter::ProfileShiftingShifter(uint16_t deviceNumber, uint8_t transmissionType) : BaseMasterProfile(deviceNumber, transmissionType), _patternStep(0), - _backgroundStep(0) + _backgroundStep(0), + _shiftCounter(0) { setChannelConfig(); } @@ -31,12 +32,11 @@ bool ProfileShiftingShifter::isDataPageValid(uint8_t dataPage) } void ProfileShiftingShifter::transmitNextDataPage() { - // TODO the pattern needs to adjust in when a shift event occurs - if (_patternStep++ < INTERLEAVE_STEP) { + if (_patternStep++ < INTERLEAVE_STEP || _shiftCounter--) { transmitShiftingMainPageMsg(); } else { transmitBackgroundDataPage(); - _patternStep = 0; + _patternStep -= INTERLEAVE_STEP; } } @@ -78,6 +78,7 @@ void ProfileShiftingShifter::transmitBatteryStatusMsg() { void ProfileShiftingShifter::transmitShiftingMainPageMsg() { ShiftingShiftSystemStatusMsg msg; _createShiftingShiftSystemStatusMsg.call(msg); + // TODO track shifting internally and adjust transmission pattern accodingly (if shifter _shiftCounter = 4); transmitMsg(msg); } diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h index e5f2c9e..d25df71 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h @@ -42,6 +42,7 @@ class ProfileShiftingShifter : public BaseMasterProfile { uint8_t _patternStep; uint8_t _backgroundStep; + uint8_t _shiftCounter; Callback _createShiftingShiftSystemStatusMsg; Callback _createMultiComponentSystemManufacturersInformationMsg; From 48f59c284f0b168d02e6fe3ba3c2be7e4bc42d7b Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 25 Aug 2019 15:53:41 -0700 Subject: [PATCH 032/241] Shifting: Shifter: Add datapage callbacks Handle incoming messages from the display accordingly and allow the user to see all messages should they choose to use them --- .../ANTPLUS_ProfileShiftingShifter.cpp | 40 +++++++++++++++++++ .../Shifter/ANTPLUS_ProfileShiftingShifter.h | 9 +++++ 2 files changed, 49 insertions(+) diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp index 42704af..7e57fb0 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp @@ -57,6 +57,41 @@ void ProfileShiftingShifter::transmitBackgroundDataPage() { } } +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); + } +} + void ProfileShiftingShifter::transmitMultiComponentSystemManufacturersInformationMsg() { MultiComponentSystemManufacturersInformationMsg msg; _createMultiComponentSystemManufacturersInformationMsg.call(msg); @@ -82,3 +117,8 @@ void ProfileShiftingShifter::transmitShiftingMainPageMsg() { transmitMsg(msg); } +bool ProfileShiftingShifter::handleRequestDataPage(BaseDataPage& dataPage) { + RequestDataPage dp(dataPage); + // TODO disable use of ack messages as per spec + return _onRequestDataPage.call(dp); +} diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h index d25df71..fe1c252 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h @@ -26,16 +26,24 @@ class ProfileShiftingShifter : public BaseMasterProfile { * 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(); virtual bool isDataPageValid(uint8_t dataPage); + void onAcknowledgedData(AcknowledgedData& msg); + void onBroadcastData(BroadcastData& msg); private: void transmitShiftingMainPageMsg(); void transmitMultiComponentSystemManufacturersInformationMsg(); void transmitMultiComponentSystemProductInformationMsg(); void transmitBatteryStatusMsg(); + bool handleRequestDataPage(BaseDataPage& dataPage); void transmitBackgroundDataPage(); void setChannelConfig(); @@ -48,6 +56,7 @@ class ProfileShiftingShifter : public BaseMasterProfile { Callback _createMultiComponentSystemManufacturersInformationMsg; Callback _createMultiComponentSystemProductInformationMsg; Callback _createBatteryStatusMsg; + Callback _onRequestDataPage; }; #endif // ANTPLUS_PROFILESHIFTINGSHIFTER_h From f0452d0ce9156f909a4bd5c69bb63feb10f3aa27 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 27 Aug 2019 20:27:51 -0700 Subject: [PATCH 033/241] examples: ShiftingShifter: rename example move example to match which side of the profile it represents --- .../Shifting.ino => ShiftingShifter/ShiftingShifter.ino} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/{Shifting/Shifting.ino => ShiftingShifter/ShiftingShifter.ino} (100%) diff --git a/examples/Shifting/Shifting.ino b/examples/ShiftingShifter/ShiftingShifter.ino similarity index 100% rename from examples/Shifting/Shifting.ino rename to examples/ShiftingShifter/ShiftingShifter.ino From 1903989552f9bb39ebab83bd07928aabce2b314c Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 27 Aug 2019 20:29:34 -0700 Subject: [PATCH 034/241] Shifting: Shifter: Add example to travis this is likely going to break --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 92fac86..733e3ba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,6 +39,7 @@ env: - PLATFORMIO_CI_SRC=examples/HeartRateDisplay/HeartRateDisplay.ino - PLATFORMIO_CI_SRC=examples/HeartRateMonitor/HeartRateMonitor.ino - PLATFORMIO_CI_SRC=examples/LEVDisplay/LEVDisplay.ino + - PLATFORMIO_CI_SRC=examples/ShiftingShifter/ShiftingShifter.ino install: - pip install -U platformio From 48a8fafecc0ed351234ecbce008873f58ed6dc29 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 27 Aug 2019 20:34:59 -0700 Subject: [PATCH 035/241] Shifting: Shifter: Fix callback name profile name + msg name --- src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h index fe1c252..1bd6e76 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h @@ -13,7 +13,7 @@ class ProfileShiftingShifter : public BaseMasterProfile { /** * Register callback to populate default data messages (Datapage 1) */ - void createShiftingSystemStatusMsg(void(*func)(ShiftingShiftSystemStatusMsg&, uintptr_t), uintptr_t data = 0) { _createShiftingShiftSystemStatusMsg.set(func, data); } + 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) */ From cef619b3cc6a16546dacafe8e4a87fd687a59e3a Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 27 Aug 2019 20:44:49 -0700 Subject: [PATCH 036/241] examples:ShiftingShifter: Fix callback types and add missing callback add battery status callback and move to multi component data pages --- examples/ShiftingShifter/ShiftingShifter.ino | 24 ++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/examples/ShiftingShifter/ShiftingShifter.ino b/examples/ShiftingShifter/ShiftingShifter.ino index cefb482..0c95838 100644 --- a/examples/ShiftingShifter/ShiftingShifter.ino +++ b/examples/ShiftingShifter/ShiftingShifter.ino @@ -14,15 +14,16 @@ #define BAUD_RATE 9600 #define CHANNEL_0 0 -const uint8_t NETWORK_KEY[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; +const uint8_t NETWORK_KEY[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; // get this from thisisant.com AntWithCallbacks ant = AntWithCallbacks(); AntPlusRouter router = AntPlusRouter(); ProfileShiftingShifter shift = ProfileShiftingShifter( 7370 ); -void shiftCreateMsgHandler(ShiftingShiftSystemStatusMsg& msg, uintptr_t data); -void shiftCreateManufacturerInformationMsg(ManufacturersInformationMsg& msg, uintptr_t data); -void shiftCreateProductInformationMsg(ProductInformationMsg& msg, uintptr_t data); +void shiftSystemStatusMsgHandler(ShiftingShiftSystemStatusMsg& msg, uintptr_t data); +void multiComponentSystemManufacturersInformationMsgHandler(MultiComponentSystemManufacturersInformationMsg& msg, uintptr_t data); +void multiComponentSystemProductInformationMsgHandler(MultiComponentSystemProductInformationMsg& msg, uintptr_t data); +void batteryStatusMsgHandler(batteryStatusMsgHandler& msg, uintptr_t data); void setup() { Serial2.begin(BAUD_RATE); @@ -37,9 +38,10 @@ void setup() { Serial.println("Running"); // setup shifting monitor - shift.createShiftingShiftSystemStatusMsg(shiftCreateMsgHandler); - shift.createShiftingManufacturerInformationMsg(shiftCreateManufacturerInformationMsg); - shift.createShiftingProductInformationMsg(shiftCreateProductInformationMsg); + shift.createShiftingShiftSystemStatusMsg(shiftSystemStatusMsgHandler); + shift.createMultiComponentSystemManufacturerInformationMsg(multiComponentSystemManufacturersInformationMsgHandler); + shift.createMultiComponentSystemProductInformationMsg(multiComponentSystemProductInformationMsgHandler); + shift.createBatteryStatusMsg(batteryStatusMsgHandler); shift.begin(); delay(100); // wait for module initialization } @@ -60,14 +62,18 @@ void shiftCreateMsgHandler(ShiftingShiftSystemStatusMsg& msg, uintptr_t data) msg.setEventCount(_eventCount++); } -void shiftCreateManufacturerInformationMsg(ManufacturersInformationMsg& msg, uintptr_t data) { +void multiComponentSystemManufacturersInformationMsgHandler(MultiComponentSystemManufacturersInformationMsg& msg, uintptr_t data) { msg.setHWRevision(0x01); msg.setManufacturerId(0x1234); msg.setModelNumber(0x0002); } -void shiftCreateProductInformationMsg(ProductInformationMsg& msg, uintptr_t data) { +void multiComponentSystemProductInformationMsgHandler(MultiComponentSystemProductInformationMsg& msg, uintptr_t data) { msg.setSerialNumber(0x12345678); msg.setSWRevisionMain(0x01); msg.setSWRevisionSupplemental(0x00); } + +void batteryStatusMsgHandler(BatteryStatusMsg& msg, uintptr_t data) { + // TODO +} From ef4f80008f73b4691f990d638fe69e6f160ed377 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 27 Aug 2019 23:30:39 -0700 Subject: [PATCH 037/241] shifting: datapages: fix naming adjust naming to match other datapages --- examples/ShiftingShifter/ShiftingShifter.ino | 2 +- ...ANTPLUS_BaseMultiComponentSystemManufacturersInformation.cpp | 2 +- .../ANTPLUS_BaseMultiComponentSystemManufacturersInformation.h | 2 +- .../ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp | 2 +- .../ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/ShiftingShifter/ShiftingShifter.ino b/examples/ShiftingShifter/ShiftingShifter.ino index 0c95838..f48e051 100644 --- a/examples/ShiftingShifter/ShiftingShifter.ino +++ b/examples/ShiftingShifter/ShiftingShifter.ino @@ -23,7 +23,7 @@ ProfileShiftingShifter shift = ProfileShiftingShifter( 7370 ); void shiftSystemStatusMsgHandler(ShiftingShiftSystemStatusMsg& msg, uintptr_t data); void multiComponentSystemManufacturersInformationMsgHandler(MultiComponentSystemManufacturersInformationMsg& msg, uintptr_t data); void multiComponentSystemProductInformationMsgHandler(MultiComponentSystemProductInformationMsg& msg, uintptr_t data); -void batteryStatusMsgHandler(batteryStatusMsgHandler& msg, uintptr_t data); +void batteryStatusMsgHandler(BatteryStatusMsg& msg, uintptr_t data); void setup() { Serial2.begin(BAUD_RATE); diff --git a/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemManufacturersInformation.cpp b/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemManufacturersInformation.cpp index 1b78e39..69ed76a 100644 --- a/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemManufacturersInformation.cpp +++ b/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemManufacturersInformation.cpp @@ -27,7 +27,7 @@ uint8_t BaseMultiComponentSystemManufacturersInformation::getHWRevision() { } template -uint16_t BaseMultiComponentSystemManufacturersInformation::getManufacturerID() { +uint16_t BaseMultiComponentSystemManufacturersInformation::getManufacturerId() { return this->get16BitValue( ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_LSB_BYTE, ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_MSB_BYTE); diff --git a/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemManufacturersInformation.h b/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemManufacturersInformation.h index 0ebf4fc..d5b8e70 100644 --- a/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemManufacturersInformation.h +++ b/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemManufacturersInformation.h @@ -14,7 +14,7 @@ class BaseMultiComponentSystemManufacturersInformation : virtual public CoreData uint8_t getNumberOfComponents(); uint8_t getComponentIdentifier(); uint8_t getHWRevision(); - uint16_t getManufacturerID(); + uint16_t getManufacturerId(); uint16_t getModelNumber(); }; diff --git a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp index 0f97053..9bc6191 100644 --- a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp +++ b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp @@ -22,7 +22,7 @@ void MultiComponentSystemManufacturersInformationMsg::setHWRevision(uint8_t rev) ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_HWREVISION_BYTE); } -void MultiComponentSystemManufacturersInformationMsg::setManufacturerID(uint16_t id) { +void MultiComponentSystemManufacturersInformationMsg::setManufacturerId(uint16_t id) { set16BitValue(id, ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_LSB_BYTE, ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_MSB_BYTE); diff --git a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h index bfe7edc..defdc89 100644 --- a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h +++ b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h @@ -14,7 +14,7 @@ class MultiComponentSystemManufacturersInformationMsg : public BaseDataPageMsg Date: Tue, 27 Aug 2019 23:31:23 -0700 Subject: [PATCH 038/241] examples: ShiftingShifter: fix callback ManufacturerS --- examples/ShiftingShifter/ShiftingShifter.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ShiftingShifter/ShiftingShifter.ino b/examples/ShiftingShifter/ShiftingShifter.ino index f48e051..ae74c6c 100644 --- a/examples/ShiftingShifter/ShiftingShifter.ino +++ b/examples/ShiftingShifter/ShiftingShifter.ino @@ -39,7 +39,7 @@ void setup() { // setup shifting monitor shift.createShiftingShiftSystemStatusMsg(shiftSystemStatusMsgHandler); - shift.createMultiComponentSystemManufacturerInformationMsg(multiComponentSystemManufacturersInformationMsgHandler); + shift.createMultiComponentSystemManufacturersInformationMsg(multiComponentSystemManufacturersInformationMsgHandler); shift.createMultiComponentSystemProductInformationMsg(multiComponentSystemProductInformationMsgHandler); shift.createBatteryStatusMsg(batteryStatusMsgHandler); shift.begin(); From c03d486f3765364c910fb4ca54ac1b72efbd835c Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 27 Aug 2019 23:35:33 -0700 Subject: [PATCH 039/241] CommonDataPages: remove unneeded return void doesn't return anything --- .../ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp index 9bc6191..4d72687 100644 --- a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp +++ b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp @@ -5,7 +5,7 @@ MultiComponentSystemManufacturersInformationMsg::MultiComponentSystemManufacture } void MultiComponentSystemManufacturersInformationMsg::setNumberOfComponents(uint8_t count) { - return set8BitValue(count, + set8BitValue(count, ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_BYTE, ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_NUMBERCOMPONENTS_MASK); } From aa51cc2a558b8c3632bb89c6fb7c2e6587301c1e Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 27 Aug 2019 23:37:03 -0700 Subject: [PATCH 040/241] examples: ShiftingShifter: fix function naming declaration should match definition --- examples/ShiftingShifter/ShiftingShifter.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ShiftingShifter/ShiftingShifter.ino b/examples/ShiftingShifter/ShiftingShifter.ino index ae74c6c..ce77008 100644 --- a/examples/ShiftingShifter/ShiftingShifter.ino +++ b/examples/ShiftingShifter/ShiftingShifter.ino @@ -50,7 +50,7 @@ void loop() { router.loop(); } -void shiftCreateMsgHandler(ShiftingShiftSystemStatusMsg& msg, uintptr_t data) +void shiftSystemStatusMsgHandler(ShiftingShiftSystemStatusMsg& msg, uintptr_t data) { static int _gear = 0; static int _eventCount = 0; From 7c9f92ef3c9577a299d0ebd4100bf7deac82cc8a Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 2 Sep 2019 15:48:56 -0700 Subject: [PATCH 041/241] MuscleOxygen: DataPages: Begin refactor Move to new common data access API, fix names and style, create empty target files --- .../ANTPLUS_ProfileMuscleOxygenDataPages.h | 9 ++-- .../Base/ANTPLUS_MuscleOxygenBaseCommands.cpp | 0 .../Base/ANTPLUS_MuscleOxygenBaseCommands.h | 0 .../ANTPLUS_MuscleOxygenBaseMainDataPage.cpp | 0 .../ANTPLUS_MuscleOxygenBaseMainDataPage.h | 0 ...NTPLUS_MuscleOxygenBaseMainDataPageMsg.cpp | 48 +------------------ .../ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h | 10 +--- ...TPLUS_MuscleOxygenBaseMuscleOxygenData.cpp | 0 ...ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h | 0 .../RX/ANTPLUS_MuscleOxygenCommands.cpp | 0 .../RX/ANTPLUS_MuscleOxygenCommands.h | 0 ...NTPLUS_MuscleOxygenMuscleOxygenDataMsg.cpp | 33 +++++++++++++ .../ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.h | 20 ++++++++ .../ANTPLUS_ProfileMuscleOxygenMonitor.cpp | 4 +- .../ANTPLUS_ProfileMuscleOxygenMonitor.h | 8 ++-- 15 files changed, 65 insertions(+), 67 deletions(-) create mode 100644 src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseCommands.cpp create mode 100644 src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseCommands.h create mode 100644 src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPage.cpp create mode 100644 src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPage.h create mode 100644 src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.cpp create mode 100644 src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h create mode 100644 src/Profiles/MuscleOxygen/DataPages/RX/ANTPLUS_MuscleOxygenCommands.cpp create mode 100644 src/Profiles/MuscleOxygen/DataPages/RX/ANTPLUS_MuscleOxygenCommands.h create mode 100644 src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.cpp create mode 100644 src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.h diff --git a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_ProfileMuscleOxygenDataPages.h b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_ProfileMuscleOxygenDataPages.h index 55460f2..0b3d125 100644 --- a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_ProfileMuscleOxygenDataPages.h +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_ProfileMuscleOxygenDataPages.h @@ -1,13 +1,10 @@ #ifndef ANTPLUS_PROFILEMUSCLEOXYGENDATAPAGES_h #define ANTPLUS_PROFILEMUSCLEOXYGENDATAPAGES_h -/* Base */ -#include - /* RX */ -// ... +#include /* TX */ -// ... +#include -#endif // ANTPLUS_PROFILEMUSCLEOXYGENDATAPAGES_h \ No newline at end of file +#endif // ANTPLUS_PROFILEMUSCLEOXYGENDATAPAGES_h diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseCommands.cpp b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseCommands.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseCommands.h b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseCommands.h new file mode 100644 index 0000000..e69de29 diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPage.cpp b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPage.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPage.h b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPage.h new file mode 100644 index 0000000..e69de29 diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.cpp b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.cpp index a6958bc..7327850 100644 --- a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.cpp +++ b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.cpp @@ -1,52 +1,8 @@ #include -#include #include - -MuscleOxygenBaseMainDataPageMsg::MuscleOxygenBaseMainDataPageMsg(uint8_t dataPageNumber) : BaseDataPageMsg() -{ +MuscleOxygenBaseMainDataPageMsg::MuscleOxygenBaseMainDataPageMsg(uint8_t dataPageNumber) : BaseDataPageMsg() { memset(_buffer, 0, MESSAGE_SIZE); setDataBuffer(_buffer); - _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = dataPageNumber; - setCapabilities(); - setNotifications(); -} - -void MuscleOxygenBaseMainDataPageMsg::setEventCount( uint8_t n ) -{ - _buffer[1] = n; -} - -void MuscleOxygenBaseMainDataPageMsg::setNotifications( uint8_t n ) -{ - _buffer[2] = n; -} - -void MuscleOxygenBaseMainDataPageMsg::setCapabilities( uint8_t c ) -{ - _buffer[3] = c; -} - -void MuscleOxygenBaseMainDataPageMsg::setTotalHemoglobinConcentration( uint16_t tc ) -{ - _buffer[4] = (uint8_t)tc; - _buffer[5] &= ~0x0F; - _buffer[5] |= (tc >> 8) & 0x0F; -} - -/* TODO -void MuscleOxygenBaseMainDataPageMsg::setPreviousSaturatedHemoglobinPercentage( uint16_t pp ) -{ - _buffer[5] &= ~0xF0; - _buffer[5] |= (uint8_t)(pp << 4); - _buffer[6] &= ~0x3F; - _buffer[6] |= (pp >> 4) & 0x3F; -} -*/ - -void MuscleOxygenBaseMainDataPageMsg::setCurrentSaturatedHemoglobinPercentage( uint16_t cp ) -{ - _buffer[6] &= ~0xC0; - _buffer[6] |= (uint8_t)(cp << 6); - _buffer[7] = cp >> 2; + set8BitValue(dataPageNumber, ANTPLUS_DEFAULT_DATAPAGE_BYTE); } diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h index 1aa2288..7e455c7 100644 --- a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h +++ b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h @@ -2,20 +2,12 @@ #define ANTPLUS_MUSCLEOXYGENBASEMAINDATAPAGEMSG_h #include -#include #include "ANT.h" class MuscleOxygenBaseMainDataPageMsg : public BaseDataPageMsg { public: - MuscleOxygenBaseMainDataPageMsg(uint8_t dataPageNumber = ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_NUMBER); - - void setTotalHemoglobinConcentration( uint16_t tc ); - void setCurrentSaturatedHemoglobinPercentage(uint16_t cp); - void setNotifications(uint8_t n = 0x00); - void setCapabilities(uint8_t c = 0x06); - void setEventCount(uint8_t n); - + MuscleOxygenBaseMainDataPageMsg(uint8_t dataPageNumber); protected: uint8_t _buffer[MESSAGE_SIZE]; }; diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.cpp b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h new file mode 100644 index 0000000..e69de29 diff --git a/src/Profiles/MuscleOxygen/DataPages/RX/ANTPLUS_MuscleOxygenCommands.cpp b/src/Profiles/MuscleOxygen/DataPages/RX/ANTPLUS_MuscleOxygenCommands.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/Profiles/MuscleOxygen/DataPages/RX/ANTPLUS_MuscleOxygenCommands.h b/src/Profiles/MuscleOxygen/DataPages/RX/ANTPLUS_MuscleOxygenCommands.h new file mode 100644 index 0000000..e69de29 diff --git a/src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.cpp b/src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.cpp new file mode 100644 index 0000000..ca7f02c --- /dev/null +++ b/src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.cpp @@ -0,0 +1,33 @@ +#include +#include + + +MuscleOxygenMuscleOxygenDataMsg::MuscleOxygenMuscleOxygenDataMsg() : MuscleOxygenBaseMainDataPageMsg(0) { + setTotalHemoglobinConcentration(0xFFF); + setPreviousSaturatedHemoglobinPercentage(0x3FF); + setCurrentSaturatedHemoglobinPercentage(0x3FF); +} + +void MuscleOxygenMuscleOxygenDataMsg::setEventCount(uint8_t n) { + set8BitValue(n, 1); +} + +void MuscleOxygenMuscleOxygenDataMsg::setNotifications(uint8_t notifications) { + set8BitValue(notifications, 2); +} + +void MuscleOxygenMuscleOxygenDataMsg::setCapabilities(uint8_t capabilities) { + set8BitValue(capabilities, 3); +} + +void MuscleOxygenMuscleOxygenDataMsg::setTotalHemoglobinConcentration(uint16_t concentration) { + set16BitValue(concentration, 4, 5, 0x0FFF); +} + +void MuscleOxygenMuscleOxygenDataMsg::setPreviousSaturatedHemoglobinPercentage(uint16_t percent) { + set16BitValue(percent, 5, 6, 0x3FF0, 4); +} + +void MuscleOxygenMuscleOxygenDataMsg::setCurrentSaturatedHemoglobinPercentage(uint16_t percent) { + set16BitValue(percent, 6, 7, 0xFFC0, 6); +} diff --git a/src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.h b/src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.h new file mode 100644 index 0000000..9bc43c2 --- /dev/null +++ b/src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.h @@ -0,0 +1,20 @@ +#ifndef ANTPLUS_MUSCLEOXYGENMUSCLEOXYGENDATAMSG_h +#define ANTPLUS_MUSCLEOXYGENMUSCLEOXYGENDATAMSG_h + +#include + +#include "ANT.h" + +class MuscleOxygenMuscleOxygenDataMsg : public MuscleOxygenBaseMainDataPageMsg { +public: + MuscleOxygenMuscleOxygenDataMsg(); + + void setEventCount(uint8_t n); + void setNotifications(uint8_t notficications); + void setCapabilities(uint8_t capabilities); + void setTotalHemoglobinConcentration(uint16_t concentration); + void setPreviousSaturatedHemoglobinPercentage(uint16_t percent); + void setCurrentSaturatedHemoglobinPercentage(uint16_t percent); +}; + +#endif // ANTPLUS_MUSCLEOXYGENMUSCLEOXYGENDATAMSG_h diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp index 7b82b11..7ed6ce3 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp @@ -54,7 +54,7 @@ void ProfileMuscleOxygenMonitor::transmitMuscleOxygenProductInformationMsg() { } void ProfileMuscleOxygenMonitor::transmitMuscleOxygenMainPageMsg() { - MuscleOxygenBaseMainDataPageMsg msg; - _createMuscleOxygenDataMsg.call(msg); + MuscleOxygenMuscleOxygenDataMsg msg; + _createMuscleOxygenMuscleOxygenDataMsg.call(msg); send(msg); } diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h index 69f3410..4d375f7 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h @@ -11,9 +11,9 @@ class ProfileMuscleOxygenMonitor : public BaseMasterProfile { ProfileMuscleOxygenMonitor(uint16_t deviceNumber, uint8_t transmissionType = ANTPLUS_MUSCLEOXYGEN_MONITOR_TRANSMISSIONTYPE); /** - * Register callback to populate default data messages (Datapage 0) + * Register callback to populate Muscle Oxygen data messages (Datapage 0) */ - void createMuscleOxygenDataMsg(void(*func)(MuscleOxygenBaseMainDataPageMsg&, uintptr_t), uintptr_t data = 0) { _createMuscleOxygenDataMsg.set(func, data); } + void createMuscleOxygenMuscleOxygenDataMsg(void(*func)(MuscleOxygenBaseMainDataPageMsg&, uintptr_t), uintptr_t data = 0) { _createMuscleOxygenMuscleOxygenDataMsg.set(func, data); } /** * Register callback to populate manufacturer information data messages (Datapage 2) */ @@ -33,11 +33,11 @@ class ProfileMuscleOxygenMonitor : public BaseMasterProfile { private: void setChannelConfig(); void transmitMuscleOxygenMainPageMsg(); - + uint8_t _patternStep; uint8_t _toggle; - Callback _createMuscleOxygenDataMsg; + Callback _createMuscleOxygenMuscleOxygenDataMsg; Callback _createMuscleOxygenManufacturerInformationMsg; Callback _createMuscleOxygenProductInformationMsg; }; From 2f03d1d2030c001fbe7ea5bc3c632db79003dc8e Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 8 Sep 2019 14:55:20 -0700 Subject: [PATCH 042/241] CommonDataPages: Add databuffer for messages Can't send a buffer you don't have. Fixes BatteryStatus, MultiComp* --- src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.cpp | 1 + src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.h | 2 ++ .../ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp | 1 + .../ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h | 2 ++ .../TX/ANTPLUS_MultiComponentSystemProductInformationMsg.cpp | 1 + .../TX/ANTPLUS_MultiComponentSystemProductInformationMsg.h | 2 ++ 6 files changed, 9 insertions(+) diff --git a/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.cpp index 1675291..94e278b 100644 --- a/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.cpp +++ b/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.cpp @@ -3,6 +3,7 @@ #include BatteryStatusMsg::BatteryStatusMsg() : BaseDataPageMsg(), BaseBatteryStatus() { + setDataBuffer(_buffer); set8BitValue(ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); } diff --git a/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.h b/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.h index 727afbb..2df3c1f 100644 --- a/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.h +++ b/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.h @@ -18,6 +18,8 @@ class BatteryStatusMsg : public BaseDataPageMsg, public BaseBa void setCoarseBatteryVoltage(uint8_t voltage); void setBatteryStatus(uint8_t status); void setCumulativeOperatingTimeResolution(uint8_t resolution); +private: + uint8_t _buffer[MESSAGE_SIZE]; }; #endif // ANTPLUS_BATTERYSTATUSMSG_h diff --git a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp index 4d72687..bd74ce0 100644 --- a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp +++ b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp @@ -2,6 +2,7 @@ #include MultiComponentSystemManufacturersInformationMsg::MultiComponentSystemManufacturersInformationMsg() : BaseDataPageMsg(), BaseMultiComponentSystemManufacturersInformation() { + setDataBuffer(_buffer); } void MultiComponentSystemManufacturersInformationMsg::setNumberOfComponents(uint8_t count) { diff --git a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h index defdc89..ed2b1ad 100644 --- a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h +++ b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h @@ -16,6 +16,8 @@ class MultiComponentSystemManufacturersInformationMsg : public BaseDataPageMsg MultiComponentSystemProductInformationMsg::MultiComponentSystemProductInformationMsg() : BaseDataPageMsg(), BaseMultiComponentSystemProductInformation() { + setDataBuffer(_buffer); } void MultiComponentSystemProductInformationMsg::setNumberOfComponents(uint8_t count) { diff --git a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.h b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.h index 8b46354..d038461 100644 --- a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.h +++ b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.h @@ -16,6 +16,8 @@ class MultiComponentSystemProductInformationMsg : public BaseDataPageMsg Date: Sun, 8 Sep 2019 14:58:29 -0700 Subject: [PATCH 043/241] Shifting: Shifter: Update example Add missing calls and add more prints --- examples/ShiftingShifter/ShiftingShifter.ino | 40 +++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/examples/ShiftingShifter/ShiftingShifter.ino b/examples/ShiftingShifter/ShiftingShifter.ino index ce77008..1ef7875 100644 --- a/examples/ShiftingShifter/ShiftingShifter.ino +++ b/examples/ShiftingShifter/ShiftingShifter.ino @@ -14,11 +14,11 @@ #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 +const uint8_t NETWORK_KEY[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}; // get this from thisisant.com AntWithCallbacks ant = AntWithCallbacks(); AntPlusRouter router = AntPlusRouter(); -ProfileShiftingShifter shift = ProfileShiftingShifter( 7370 ); +ProfileShiftingShifter shift = ProfileShiftingShifter(7370); void shiftSystemStatusMsgHandler(ShiftingShiftSystemStatusMsg& msg, uintptr_t data); void multiComponentSystemManufacturersInformationMsgHandler(MultiComponentSystemManufacturersInformationMsg& msg, uintptr_t data); @@ -26,9 +26,9 @@ void multiComponentSystemProductInformationMsgHandler(MultiComponentSystemProduc void batteryStatusMsgHandler(BatteryStatusMsg& msg, uintptr_t data); void setup() { - Serial2.begin(BAUD_RATE); - ant.setSerial(Serial2); - delay(1000); + Serial1.begin(BAUD_RATE); + ant.setSerial(Serial1); + delay(3000); router.setDriver(&ant); // never touch ant again router.setAntPlusNetworkKey(NETWORK_KEY); @@ -50,30 +50,50 @@ void loop() { router.loop(); } -void shiftSystemStatusMsgHandler(ShiftingShiftSystemStatusMsg& msg, uintptr_t data) -{ +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.setCurrentGearFront(1); + msg.setCurrentGearRear(_gear++ % 10); msg.setEventCount(_eventCount++); } 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) { - // TODO + printDpMsg(82, "Battery Status"); + msg.setNumberOfBatteries(3); + msg.setBatteryIdentifier(1); + msg.setCumulativeOperatingTime(123); + msg.setFractionalBatteryVoltage(12); + msg.setCoarseBatteryVoltage(12); + msg.setBatteryStatus(0); // TODO defines? + msg.setCumulativeOperatingTimeResolution(12); } From 64a76fa8834a11b2c1c32bde1995990748c0b3a3 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 8 Sep 2019 15:02:31 -0700 Subject: [PATCH 044/241] Shifting: Shifter: Remove init delay Not needed since all we do after is wait for messages and respond accordingly --- examples/ShiftingShifter/ShiftingShifter.ino | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/ShiftingShifter/ShiftingShifter.ino b/examples/ShiftingShifter/ShiftingShifter.ino index 1ef7875..aabdea4 100644 --- a/examples/ShiftingShifter/ShiftingShifter.ino +++ b/examples/ShiftingShifter/ShiftingShifter.ino @@ -43,7 +43,6 @@ void setup() { shift.createMultiComponentSystemProductInformationMsg(multiComponentSystemProductInformationMsgHandler); shift.createBatteryStatusMsg(batteryStatusMsgHandler); shift.begin(); - delay(100); // wait for module initialization } void loop() { From 7e95ed35967c3b1be31a5b2764c3addf391df5ee Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 12 Oct 2019 17:39:27 -0700 Subject: [PATCH 045/241] CommonDataPages: BatteryStatus: Add missing defines and set reserved Reserved byte needs to be set properly, also add propery public defines so reserved values are not accidentally set --- src/CommonDataPages/ANTPLUS_CommonDataPageDefines.h | 8 ++++++++ .../ANTPLUS_CommonDataPagePrivateDefines.h | 3 +++ src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.cpp | 6 +++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/CommonDataPages/ANTPLUS_CommonDataPageDefines.h b/src/CommonDataPages/ANTPLUS_CommonDataPageDefines.h index 9d99c0e..164d065 100644 --- a/src/CommonDataPages/ANTPLUS_CommonDataPageDefines.h +++ b/src/CommonDataPages/ANTPLUS_CommonDataPageDefines.h @@ -21,4 +21,12 @@ #define ANTPLUS_COMMON_DATAPAGE_MODESETTINGS_SPORTSMODE_CYCLING 2 #define ANTPLUS_COMMON_DATAPAGE_MODESETTINGS_SPORTSMODE_SWIMMING 5 +/* Battery Status */ +#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 + #endif // ANTPLUS_COMMONDATAPAGEDEFINES_h diff --git a/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h b/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h index 0cb1ce1..8972dce 100644 --- a/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h +++ b/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h @@ -81,6 +81,9 @@ /* Battery Status */ #define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER 82 +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_RESERVED_BYTE 1 +#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_RESERVED_VALUE 0xFF + #define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_BYTE 2 #define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_NUMBEROFBATTERIES_MASK 0x0F #define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_IDENTIFIER_MASK 0xF0 diff --git a/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.cpp index 94e278b..1675534 100644 --- a/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.cpp +++ b/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.cpp @@ -4,8 +4,12 @@ BatteryStatusMsg::BatteryStatusMsg() : BaseDataPageMsg(), BaseBatteryStatus() { setDataBuffer(_buffer); - set8BitValue(ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER, + set8BitValue( + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); + set8BitValue( + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_RESERVED_VALUE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_RESERVED_BYTE); } void BatteryStatusMsg::setNumberOfBatteries(uint8_t num) { From 70a3b60e327fa7c5cc15ade3b98e4e66daaebb33 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 12 Oct 2019 17:41:31 -0700 Subject: [PATCH 046/241] CommonDataPages: ManufacturersInformation: Remove unneeded header This is not used --- src/CommonDataPages/TX/ANTPLUS_ManufacturersInformationMsg.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/CommonDataPages/TX/ANTPLUS_ManufacturersInformationMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_ManufacturersInformationMsg.cpp index 230cc85..f7245d2 100644 --- a/src/CommonDataPages/TX/ANTPLUS_ManufacturersInformationMsg.cpp +++ b/src/CommonDataPages/TX/ANTPLUS_ManufacturersInformationMsg.cpp @@ -1,6 +1,5 @@ #include #include -#include #include // TODO Magic numbers From 3f8f559946b4d28131b9dbba80fbfaa5869b4d3d Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 13 Oct 2019 12:56:00 -0700 Subject: [PATCH 047/241] CommonDataPages: MultiComponent: Set datapage number Fix unintialized datapage number byte --- ...NTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp | 4 ++++ .../TX/ANTPLUS_MultiComponentSystemProductInformationMsg.cpp | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp index bd74ce0..257bd7e 100644 --- a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp +++ b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp @@ -1,8 +1,12 @@ #include #include +#include MultiComponentSystemManufacturersInformationMsg::MultiComponentSystemManufacturersInformationMsg() : BaseDataPageMsg(), BaseMultiComponentSystemManufacturersInformation() { setDataBuffer(_buffer); + set8BitValue( + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER, + ANTPLUS_DEFAULT_DATAPAGE_BYTE); } void MultiComponentSystemManufacturersInformationMsg::setNumberOfComponents(uint8_t count) { diff --git a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.cpp index df05606..2b7fa6f 100644 --- a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.cpp +++ b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.cpp @@ -4,6 +4,9 @@ MultiComponentSystemProductInformationMsg::MultiComponentSystemProductInformationMsg() : BaseDataPageMsg(), BaseMultiComponentSystemProductInformation() { setDataBuffer(_buffer); + set8BitValue( + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER, + ANTPLUS_DEFAULT_DATAPAGE_BYTE); } void MultiComponentSystemProductInformationMsg::setNumberOfComponents(uint8_t count) { From 2c7affbce66b06f4a0fd97b1761834c72d7b34f3 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 13 Oct 2019 17:08:19 -0700 Subject: [PATCH 048/241] Shifting: Defines: Add component identifier defines Shifting profile defines which identifier corresponds to which component, lets add those for easy access --- .../Shifting/ANTPLUS_ShiftingDefines.h | 18 ++++++++++++++++++ .../Shifting/ANTPLUS_ShiftingProfile.h | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h diff --git a/src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h b/src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h new file mode 100644 index 0000000..2035a58 --- /dev/null +++ b/src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h @@ -0,0 +1,18 @@ +#ifndef ANTPLUS_SHIFTINGPROFILEDEFINES_h +#define ANTPLUS_SHIFTINGPROFILEDEFINES_h + +#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 + +#endif // ANTPLUS_SHIFTINGPROFILEDEFINES_h diff --git a/src/Profiles/Shifting/ANTPLUS_ShiftingProfile.h b/src/Profiles/Shifting/ANTPLUS_ShiftingProfile.h index 25c017a..37b724e 100644 --- a/src/Profiles/Shifting/ANTPLUS_ShiftingProfile.h +++ b/src/Profiles/Shifting/ANTPLUS_ShiftingProfile.h @@ -2,7 +2,7 @@ #define ANTPLUS_SHIFTINGPROFILE_h // General Definitions -//... +#include // Datapages #include From 89a88c2c0871b0a2b1a22036312e3d7e6ae87de3 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 13 Oct 2019 17:21:05 -0700 Subject: [PATCH 049/241] Shifting: Shifter: Refactor Multi-component datapage mechanisms The multi component messages need to be populated for each component, therefore lets rework the background transmission code and a method to check which component index is being populated so the user doesn't have to track. --- .../Shifting/ANTPLUS_ShiftingDefines.h | 16 +++++ .../Shifting/ANTPLUS_ShiftingPrivateDefines.h | 4 ++ .../ANTPLUS_ProfileShiftingShifter.cpp | 63 ++++++++++++++++--- .../Shifter/ANTPLUS_ProfileShiftingShifter.h | 15 +++-- 4 files changed, 86 insertions(+), 12 deletions(-) diff --git a/src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h b/src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h index 2035a58..35aaf1f 100644 --- a/src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h +++ b/src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h @@ -15,4 +15,20 @@ #define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_EXTENSIONSHIFTER2 11 #define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_UNKNOWNIDENTIFIED 15 +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_SYSTEM_FLAG (1 << 0) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_FRONTDERAILLEUR_FLAG (1 << 1) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_REARDERAILLEUR_FLAG (1 << 2) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_LEFTSHIFTER_FLAG (1 << 3) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_RIGHTSHIFTER_FLAG (1 << 4) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_SHIFTER_FLAG (1 << 5) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_LEFTEXTENSIONSHIFTER_FLAG (1 << 6) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_RIGHTEXTENSIONSHIFTER_FLAG (1 << 7) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_EXTENSIONSHIFTER1_FLAG (1 << 8) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_LEFTEXTENSIONSHIFTER2_FLAG (1 << 9) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_RIGHTEXTENSIONSHIFTER2_FLAG (1 << 10) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_EXTENSIONSHIFTER2_FLAG (1 << 11) +#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_UNKNOWNIDENTIFIED_FLAG (1 << 15) + +#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 index 2ba832c..f24a371 100644 --- a/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h +++ b/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h @@ -12,6 +12,10 @@ // 30 / 2.5 = 12 #define ANTPLUS_SHIFTING_SEARCHTIMEOUT 12 +// Transmission pattern math +#define ANTPLUS_SHIFTING_BACKGROUNDPAGE_INTERLEAVEINTERVAL 260 +#define ANTPLUS_SHIFTING_NUMBERBACKGROUNDPAGES_PERCOMPONENT 3 + /* Pages */ #define ANTPLUS_SHIFTING_DATAPAGE_SHIFTSYSTEMSTATUS_NUMBER 1 diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp index 7e57fb0..edde171 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp @@ -1,15 +1,25 @@ #include #include +#include -#define INTERLEAVE_STEP 65 - -ProfileShiftingShifter::ProfileShiftingShifter(uint16_t deviceNumber, uint8_t transmissionType) : +ProfileShiftingShifter::ProfileShiftingShifter(uint16_t deviceNumber, uint8_t transmissionType, uint16_t componentFlags) : BaseMasterProfile(deviceNumber, transmissionType), - _patternStep(0), - _backgroundStep(0), - _shiftCounter(0) + _componentFlags(componentFlags) { setChannelConfig(); + + 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() { @@ -32,11 +42,11 @@ bool ProfileShiftingShifter::isDataPageValid(uint8_t dataPage) } void ProfileShiftingShifter::transmitNextDataPage() { - if (_patternStep++ < INTERLEAVE_STEP || _shiftCounter--) { + if (_patternStep++ < _interleaveStep || _shiftCounter--) { transmitShiftingMainPageMsg(); } else { transmitBackgroundDataPage(); - _patternStep -= INTERLEAVE_STEP; + _patternStep -= _interleaveStep; } } @@ -53,6 +63,16 @@ void ProfileShiftingShifter::transmitBackgroundDataPage() { transmitBatteryStatusMsg(); // prevent roll overs _backgroundStep = 0; + + if (isMultiComponentDevice()) { + // knock out component bit + _componentState &= (_componentState - 1); + + if (!_componentState) { + // reset back to first component + _componentState = _componentFlags; + } + } break; } } @@ -92,20 +112,46 @@ void ProfileShiftingShifter::onAcknowledgedData(AcknowledgedData& 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); } @@ -120,5 +166,6 @@ void ProfileShiftingShifter::transmitShiftingMainPageMsg() { bool ProfileShiftingShifter::handleRequestDataPage(BaseDataPage& dataPage) { RequestDataPage dp(dataPage); // TODO disable use of ack messages as per spec + // TODO handle descriptor byte if background datapage requested (need mechanism to cancel the request if component is not supported) return _onRequestDataPage.call(dp); } diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h index 1bd6e76..e2897b5 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h @@ -8,7 +8,7 @@ class ProfileShiftingShifter : public BaseMasterProfile { public: - ProfileShiftingShifter(uint16_t deviceNumber, uint8_t transmissionType = ANTPLUS_SHIFTING_SHIFTER_TRANSMISSIONTYPE); + ProfileShiftingShifter(uint16_t deviceNumber, uint8_t transmissionType = ANTPLUS_SHIFTING_SHIFTER_TRANSMISSIONTYPE, uint16_t componentsSupported = 0x1); /** * Register callback to populate default data messages (Datapage 1) @@ -44,13 +44,20 @@ class ProfileShiftingShifter : public BaseMasterProfile { 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; - uint8_t _backgroundStep; - uint8_t _shiftCounter; + 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; Callback _createShiftingShiftSystemStatusMsg; Callback _createMultiComponentSystemManufacturersInformationMsg; From 8389ea92dd35a40b1a0317b6b534a58991c47e6b Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 26 Dec 2019 15:24:14 -0800 Subject: [PATCH 050/241] BaseClasses: Add additional BaseMaster Utils allow invalidation of requests and disable ack messages --- src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp | 11 ++++++++++- src/BaseClasses/ANTPLUS_BaseMasterProfile.h | 11 +++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp b/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp index fe0b18f..50b15d9 100644 --- a/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp +++ b/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp @@ -50,7 +50,7 @@ uint8_t BaseMasterProfile::getRequestedPage() { } bool BaseMasterProfile::isRequestedPageAcknowledged() { - return _isRequestAcknowledged; + return _isRequestAcknowledged && _ackMessagesAllowed; } void BaseMasterProfile::begin() { @@ -59,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; }; From f3a3cdf10e3111201503060bac22d5cf1c70a440 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 26 Dec 2019 15:41:38 -0800 Subject: [PATCH 051/241] shifting: Ignore invalid component requests Also ignore requests for messages in ack formats shifter is banned from sending them per spec --- .../ANTPLUS_ProfileShiftingShifter.cpp | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp index edde171..fc084c3 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp @@ -7,6 +7,7 @@ ProfileShiftingShifter::ProfileShiftingShifter(uint16_t deviceNumber, uint8_t tr _componentFlags(componentFlags) { setChannelConfig(); + setAckMessageUsage(false); if (isMultiComponentDevice()) { // calculate interleave step @@ -165,7 +166,22 @@ void ProfileShiftingShifter::transmitShiftingMainPageMsg() { bool ProfileShiftingShifter::handleRequestDataPage(BaseDataPage& dataPage) { RequestDataPage dp(dataPage); - // TODO disable use of ack messages as per spec - // TODO handle descriptor byte if background datapage requested (need mechanism to cancel the request if component is not supported) + 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() && !isSupportedComponent(dp.getDescriptorByte1())) { + invalidateDataPageRequest(); + } + return _onRequestDataPage.call(dp); } From a7e287e5b5609a624cf4e62359be3c840f2e7b22 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 26 Dec 2019 15:50:02 -0800 Subject: [PATCH 052/241] shifting: shifter: Handle descriptor byte from requests Make sure component is supported before we let the system respond --- .../Shifter/ANTPLUS_ProfileShiftingShifter.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp index fc084c3..22ff2d8 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp @@ -65,7 +65,8 @@ void ProfileShiftingShifter::transmitBackgroundDataPage() { // prevent roll overs _backgroundStep = 0; - if (isMultiComponentDevice()) { + // Don't adjust state if we are handling a request + if (isMultiComponentDevice() && !isRequestedPagePending()) { // knock out component bit _componentState &= (_componentState - 1); @@ -117,7 +118,6 @@ bool ProfileShiftingShifter::isMultiComponentDevice() { return _componentFlags != ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_NOTUSED; } - bool ProfileShiftingShifter::isSupportedComponent(uint8_t id) { return _componentFlags & (1 << id); } @@ -179,8 +179,13 @@ bool ProfileShiftingShifter::handleRequestDataPage(BaseDataPage Date: Mon, 18 May 2020 21:23:20 -0700 Subject: [PATCH 053/241] FEC and BicyclePower profile --- .gitignore | 3 + .../ANTPLUS_BicyclePowerDefines.h | 4 + .../ANTPLUS_BicyclePowerPrivateDefines.h | 32 ++++ .../ANTPLUS_BicyclePowerProfile.h | 14 ++ .../ANTPLUS_ProfileBicyclePowerDataPages.h | 17 ++ ...TPLUS_BicyclePowerStdPowerOnlyDataPage.cpp | 30 ++++ ...ANTPLUS_BicyclePowerStdPowerOnlyDataPage.h | 19 +++ ...US_BicyclePowerStdPowerOnlyDataPageMsg.cpp | 24 +++ ...PLUS_BicyclePowerStdPowerOnlyDataPageMsg.h | 18 ++ .../ANTPLUS_ProfileBicyclePowerSensor.cpp | 159 ++++++++++++++++++ .../ANTPLUS_ProfileBicyclePowerSensor.h | 36 ++++ src/Profiles/FEC/ANTPLUS_FECDefines.h | 24 +++ src/Profiles/FEC/ANTPLUS_FECPrivateDefines.h | 41 +++++ src/Profiles/FEC/ANTPLUS_FECProfile.h | 14 ++ .../DataPages/ANTPLUS_ProfileFECDataPages.h | 9 + .../Base/ANTPLUS_FECFEMainDataPage.cpp | 9 + .../Base/ANTPLUS_FECFEMainDataPage.h | 14 ++ .../Base/ANTPLUS_FECGeneralMainDataPage.cpp | 58 +++++++ .../Base/ANTPLUS_FECGeneralMainDataPage.h | 22 +++ .../Base/ANTPLUS_FECTrainerDataPage.cpp | 59 +++++++ .../Base/ANTPLUS_FECTrainerDataPage.h | 22 +++ .../DataPages/RX/ANTPLUS_FECTrainerData.cpp | 5 + .../FEC/DataPages/RX/ANTPLUS_FECTrainerData.h | 12 ++ .../FEC/Display/ANTPLUS_ProfileFECDisplay.cpp | 59 +++++++ .../FEC/Display/ANTPLUS_ProfileFECDisplay.h | 28 +++ 25 files changed, 732 insertions(+) create mode 100644 src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h create mode 100644 src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h create mode 100644 src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h create mode 100644 src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h create mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPage.cpp create mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPage.h create mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPageMsg.cpp create mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPageMsg.h create mode 100644 src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp create mode 100644 src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h create mode 100644 src/Profiles/FEC/ANTPLUS_FECDefines.h create mode 100644 src/Profiles/FEC/ANTPLUS_FECPrivateDefines.h create mode 100644 src/Profiles/FEC/ANTPLUS_FECProfile.h create mode 100644 src/Profiles/FEC/DataPages/ANTPLUS_ProfileFECDataPages.h create mode 100644 src/Profiles/FEC/DataPages/Base/ANTPLUS_FECFEMainDataPage.cpp create mode 100644 src/Profiles/FEC/DataPages/Base/ANTPLUS_FECFEMainDataPage.h create mode 100644 src/Profiles/FEC/DataPages/Base/ANTPLUS_FECGeneralMainDataPage.cpp create mode 100644 src/Profiles/FEC/DataPages/Base/ANTPLUS_FECGeneralMainDataPage.h create mode 100644 src/Profiles/FEC/DataPages/Base/ANTPLUS_FECTrainerDataPage.cpp create mode 100644 src/Profiles/FEC/DataPages/Base/ANTPLUS_FECTrainerDataPage.h create mode 100644 src/Profiles/FEC/DataPages/RX/ANTPLUS_FECTrainerData.cpp create mode 100644 src/Profiles/FEC/DataPages/RX/ANTPLUS_FECTrainerData.h create mode 100644 src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.cpp create mode 100644 src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.h diff --git a/.gitignore b/.gitignore index 068fc6d..930fb5f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ .piolibdeps .ycm* *.swp +.DS_Store +*.DS_Store # used for testing src/main.cpp @@ -9,3 +11,4 @@ src/main.cpp .tags* tags .pio +*-e diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h new file mode 100644 index 0000000..bcf635f --- /dev/null +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h @@ -0,0 +1,4 @@ +#ifndef ANTPLUS_BICYCLEPOWERPROFILEDEFINES_h +#define ANTPLUS_BICYCLEPOWERPROFILEDEFINES_h + +#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..4fc987b --- /dev/null +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h @@ -0,0 +1,32 @@ +#ifndef ANTPLUS_BICYCLEPOWERPROFILEPRIVATEDEFINES_h +#define ANTPLUS_BICYCLEPOWERPROFILEPRIVATEDEFINES_h + +/* Channel Config */ +#define ANTPLUS_BICYCLEPOWER_SENSOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT +#define ANTPLUS_BICYCLEPOWER_DEVICETYPE 11 +#define ANTPLUS_BICYCLEPOWER_CHANNELPERIOD 8182 +// 30 / 2.5 = 12 +#define ANTPLUS_BICYCLEPOWER_SEARCHTIMEOUT 12 + +/* Base DataPage */ +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_DATAPAGE_BYTE 0 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_UPDATE_EVENT_COUNT_BYTE 1 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_PEDAL_POWER_BYTE 2 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_INSTANTANEOUS_CADENCE_BYTE 3 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_CUMULATIVEPOWERLSB_BYTE 4 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_CUMULATIVEPOWERMSB_BYTE 5 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_INSTANTANEOUSPOWERLSB_BYTE 6 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_INSTANTANEOUSPOWERMSB_BYTE 7 + +#define ANTPLUS_BICYCLEPOWER_DATAPAGEBASE_DATAPAGE_MASK 0x7F +#define ANTPLUS_BICYCLEPOWER_DATAPAGEBASE_TOGGLE_MASK 0x80 + +#define ANTPLUS_BICYCLEPOWER_DATAPAGEBASE_TOGGLE_SHIFT 7 +#define ANTPLUS_BICYCLEPOWER_DATAPAGEBASE_BIKESPEEDEVENTTIMEMSB_SHIFT 8 +#define ANTPLUS_BICYCLEPOWER_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNTMSB_SHIFT 8 + +/* Default Page */ +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_DATAPAGE_NUMBER 0x10 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DEFAULT_NUMBER ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_DATAPAGE_NUMBER + +#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..d9cb805 --- /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_ProfileBicyclePowerDataPages.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h new file mode 100644 index 0000000..dbc5d5c --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h @@ -0,0 +1,17 @@ +#ifndef ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h +#define ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h + +#include +#include +/* RX */ +/*#include +#include +#include +#include +#include +#include +*/ + +/* TX */ + +#endif // ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPage.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPage.cpp new file mode 100644 index 0000000..b610e27 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPage.cpp @@ -0,0 +1,30 @@ +#include +#include + +BicyclePowerStdPowerOnlyDataPage::BicyclePowerStdPowerOnlyDataPage(AntRxDataResponse& dp) : BaseDataPage(dp) { + +} + +uint8_t BicyclePowerStdPowerOnlyDataPage::getDataPageNumber() { + return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_DATAPAGE_BYTE); +} + +uint8_t BicyclePowerStdPowerOnlyDataPage::getUpdateEventCount() { + return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_UPDATE_EVENT_COUNT_BYTE); +} +uint8_t BicyclePowerStdPowerOnlyDataPage::getPedalPower() { + return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_PEDAL_POWER_BYTE); +} +uint8_t BicyclePowerStdPowerOnlyDataPage::getInstantaneousCacence() { + return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_INSTANTANEOUS_CADENCE_BYTE); +} + +uint16_t BicyclePowerStdPowerOnlyDataPage::getCumulativePowerCount() { + return (getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_CUMULATIVEPOWERMSB_BYTE) << 8) | + getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_CUMULATIVEPOWERLSB_BYTE); +} + +uint16_t BicyclePowerStdPowerOnlyDataPage::getInstataneousPowerCount() { + return (getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_INSTANTANEOUSPOWERMSB_BYTE) << 8) | + getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_INSTANTANEOUSPOWERLSB_BYTE); +} diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPage.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPage.h new file mode 100644 index 0000000..afbe38f --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPage.h @@ -0,0 +1,19 @@ +#ifndef ANTPLUS_BICYCLEPOWERBASEMAINDATAPAGE_h +#define ANTPLUS_BICYCLEPOWERBASEMAINDATAPAGE_h + +#include + +#include "ANT.h" + +class BicyclePowerStdPowerOnlyDataPage : public BaseDataPage { +public: + BicyclePowerStdPowerOnlyDataPage(AntRxDataResponse& dp); + uint8_t getDataPageNumber(); + uint8_t getUpdateEventCount(); + uint8_t getPedalPower(); + uint8_t getInstantaneousCacence(); + uint16_t getCumulativePowerCount(); + uint16_t getInstataneousPowerCount(); +}; + +#endif // ANTPLUS_BICYCLEPOWERBASEMAINDATAPAGE_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPageMsg.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPageMsg.cpp new file mode 100644 index 0000000..e6fe7fb --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPageMsg.cpp @@ -0,0 +1,24 @@ +#include +#include +#include + +BicyclePowerStdPowerOnlyDataPageMsg::BicyclePowerStdPowerOnlyDataPageMsg() : BaseDataPageMsg() { + setDataBuffer(_buffer); + _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_DATAPAGE_NUMBER; + _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_PEDAL_POWER_BYTE] = 0xFF; + _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_INSTANTANEOUS_CADENCE_BYTE] = 0xFF; +} + +void BicyclePowerStdPowerOnlyDataPageMsg::setUpdateEventCount(uint8_t eventCount) { + _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_UPDATE_EVENT_COUNT_BYTE] = eventCount; +} + +void BicyclePowerStdPowerOnlyDataPageMsg::setCumulativePowerCount(uint16_t accPower) { + _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_CUMULATIVEPOWERMSB_BYTE] = accPower >> 8; + _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_CUMULATIVEPOWERLSB_BYTE] = accPower & ANTPLUS_DEFAULT_BYTE_MASK; +} + +void BicyclePowerStdPowerOnlyDataPageMsg::setInstataneousPowerCount(uint16_t power) { + _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_INSTANTANEOUSPOWERMSB_BYTE] = power >> 8; + _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_INSTANTANEOUSPOWERLSB_BYTE] = power & ANTPLUS_DEFAULT_BYTE_MASK; +} diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPageMsg.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPageMsg.h new file mode 100644 index 0000000..2c55a30 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPageMsg.h @@ -0,0 +1,18 @@ +#ifndef ANTPLUS_BIKEPOWERSTDPOWERONLYDATAPAGEMSG_h +#define ANTPLUS_BIKEPOWERSTDPOWERONLYDATAPAGEMSG_h + +#include + +#include "ANT.h" + +class BicyclePowerStdPowerOnlyDataPageMsg : public BaseDataPageMsg { +public: + BicyclePowerStdPowerOnlyDataPageMsg(void); + void setUpdateEventCount(uint8_t eventCount); + void setCumulativePowerCount(uint16_t accPower); + void setInstataneousPowerCount(uint16_t power); +protected: + uint8_t _buffer[MESSAGE_SIZE]; +}; + +#endif // ANTPLUS_BIKEPOWERSTDPOWERONLYDATAPAGEMSG_h diff --git a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp new file mode 100644 index 0000000..d7cd176 --- /dev/null +++ b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -0,0 +1,159 @@ +#include +#include +#include +#include + +ProfileBicyclePowerSensor::ProfileBicyclePowerSensor( + uint16_t deviceNumber, + uint8_t transmissionType) : + BaseMasterProfile(deviceNumber, transmissionType), + //_nextBackgroundPage(ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER), + _flags(0) { + setChannelConfig(); +} + +ProfileBicyclePowerSensor::ProfileBicyclePowerSensor( + uint16_t deviceNumber, + uint8_t transmissionType, + uint32_t flags) : + BaseMasterProfile(deviceNumber, transmissionType), + //_nextBackgroundPage(ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER), + _flags(flags) { + setChannelConfig(); +} + +void ProfileBicyclePowerSensor::onBroadcastData(BroadcastData& msg) { + Serial.println("!!!!!!!"); + BicyclePowerStdPowerOnlyDataPage dp = BicyclePowerStdPowerOnlyDataPage(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) { + BicyclePowerStdPowerOnlyDataPage dp = BicyclePowerStdPowerOnlyDataPage(msg); + uint8_t dataPage = dp.getDataPageNumber(); + bool called = false; + + BaseMasterProfile::onAcknowledgedData(msg); +#if 0 + switch (dataPage) { + + case ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER: + called = handleRequestDataPage(dp); + break; + case ANTPLUS_COMMON_DATAPAGE_MODESETTINGS_NUMBER: + called = handleModeSettings(dp); + break; + } +#endif + if (!called) { + callOnOtherDataPage(msg); + } +} + +void ProfileBicyclePowerSensor::transmitNextDataPage() { +#if 0 + if (isRequestedPagePending()) { + transmitRequestedDataPage(); + } else { + if (_patternStep++ < 64) { + transmitPrimaryDataPage(); + } else { + transmitBackgroundDataPage(); + if (_patternStep > 67) { + _nextBackgroundPage = getNextBackgroundPage(_nextBackgroundPage); + _patternStep = 0; + } + } + } +#else + transmitPrimaryDataPage(); +#endif +} + +void ProfileBicyclePowerSensor::transmitPrimaryDataPage() { + transmitBicyclePowerDefaultMsg(); +} + +void ProfileBicyclePowerSensor::transmitBackgroundDataPage() { +#if 0 + switch (_nextBackgroundPage) { + case ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER: + transmitBicyclePowerCumulativeOperatingTimeMsg(); + break; + case ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER: + transmitBicyclePowerManufacturerInformationMsg(); + break; + case ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_NUMBER: + transmitBicyclePowerProductInformationMsg(); + break; + case ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_NUMBER: + transmitBicyclePowerBatteryStatusMsg(); + break; + case ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_NUMBER: + transmitBicyclePowerCapabilitiesMsg(); + break; + } +#endif +} + +uint8_t ProfileBicyclePowerSensor::getNextBackgroundPage(uint8_t currentPage) { +#if 0 + 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; + } else { + // Reached end of the loop, start again + return getNextBackgroundPage(0); + } +#else + return 0; +#endif +} + +void ProfileBicyclePowerSensor::transmitRequestedDataPage() { + uint8_t requestedPage = getRequestedPage(); + switch (requestedPage) { + case ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_DATAPAGE_NUMBER: + transmitBicyclePowerDefaultMsg(); + break; + } +} + +void ProfileBicyclePowerSensor::transmitBicyclePowerDefaultMsg() { + BicyclePowerStdPowerOnlyDataPageMsg msg; + _createBicyclePowerStdPowerOnlyDataPageMsg.call(msg); + transmitBicycleStdPowerOnlyMsg(msg); +} + +void ProfileBicyclePowerSensor::transmitBicycleStdPowerOnlyMsg(BicyclePowerStdPowerOnlyDataPageMsg& msg) { + send(msg); +} + +void ProfileBicyclePowerSensor::setChannelConfig() { + setChannelType(ANTPLUS_BICYCLEPOWER_SENSOR_CHANNELTYPE); + setDeviceType(ANTPLUS_BICYCLEPOWER_DEVICETYPE); + setChannelPeriod(ANTPLUS_BICYCLEPOWER_CHANNELPERIOD); + setSearchTimeout(ANTPLUS_BICYCLEPOWER_SEARCHTIMEOUT); +} + +bool ProfileBicyclePowerSensor::isDataPageValid(uint8_t dataPage) { + return true; +} diff --git a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h new file mode 100644 index 0000000..65897f1 --- /dev/null +++ b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h @@ -0,0 +1,36 @@ +#ifndef ANTPLUS_PROFILEBICYCLEPOWERSENSOR_h +#define ANTPLUS_PROFILEBICYCLEPOWERSENSOR_h + +#include +#include +#include + +class ProfileBicyclePowerSensor : public BaseMasterProfile { +public: + ProfileBicyclePowerSensor(uint16_t deviceNumber, uint8_t transmissionType); + ProfileBicyclePowerSensor(uint16_t deviceNumber, uint8_t transmissionType, uint32_t flags); + /** + * Register callback to populate default data messages (Datapage 0) + */ + void createBicyclePowerStdPowerOnlyDataPageMsg(void (*func)(BicyclePowerStdPowerOnlyDataPageMsg&, uintptr_t), uintptr_t data = 0) { _createBicyclePowerStdPowerOnlyDataPageMsg.set(func, data); } + +protected: + void transmitNextDataPage(); + void onAcknowledgedData(AcknowledgedData& msg); + void onBroadcastData(BroadcastData& msg); + bool isDataPageValid(uint8_t dataPage); +private: + void setChannelConfig(); + void transmitPrimaryDataPage(); + void transmitBackgroundDataPage(); + void transmitRequestedDataPage(); + void transmitBicyclePowerDefaultMsg(); + void transmitBicycleStdPowerOnlyMsg(BicyclePowerStdPowerOnlyDataPageMsg& msg); + uint8_t getNextBackgroundPage(uint8_t currentPage); + Callback _createBicyclePowerStdPowerOnlyDataPageMsg; + uint8_t _nextBackgroundPage; + uint8_t _patternStep = 0; + uint32_t _flags = 0; +}; + +#endif // ANTPLUS_PROFILEBICYCLEPOWERSENSOR_h diff --git a/src/Profiles/FEC/ANTPLUS_FECDefines.h b/src/Profiles/FEC/ANTPLUS_FECDefines.h new file mode 100644 index 0000000..ec80d18 --- /dev/null +++ b/src/Profiles/FEC/ANTPLUS_FECDefines.h @@ -0,0 +1,24 @@ +#ifndef ANTPLUS_FECPROFILEDEFINES_h +#define ANTPLUS_FECPROFILEDEFINES_h + +#define ANTPLUS_FEC_DEVICETYPE 17 + +#define ANTPLUS_FEC_FLAGS_CUMULATIVEOPERATINGTIME_SUPPORTED (1 << 0) +#define ANTPLUS_FEC_FLAGS_PREVIOUSHEARTBEAT_SUPPORTED (1 << 1) +#define ANTPLUS_FEC_FLAGS_EXTENTED_FEATURES (1 << 2) +#define ANTPLUS_FEC_FLAGS_BATTERYSTATUS_SUPPORTED (1 << 3) + +#define ANTPLUS_FEC_DATAPAGE_CAPABILITIES_FEATURES_EXTENDEDRUNNING 0x01 +#define ANTPLUS_FEC_DATAPAGE_CAPABILITIES_FEATURES_EXTENDEDCYCLING 0x02 +#define ANTPLUS_FEC_DATAPAGE_CAPABILITIES_FEATURES_EXTENDEDSWIMMING 0x04 +#define ANTPLUS_FEC_DATAPAGE_CAPABILITIES_FEATURES_MANUFACTURER1 0x40 +#define ANTPLUS_FEC_DATAPAGE_CAPABILITIES_FEATURES_MANUFACTURER2 0x80 + +// TODO all below defines need to be added to example +#define ANTPLUS_FEC_DATAPAGE_PREVIOUSHEARTBEAT_MANUFACTURERSPECIFIC_INVALID 0xFF + +#define ANTPLUS_FEC_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALAVERAGEFEC_INVALID 0 +#define ANTPLUS_FEC_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALMAXIMUMFEC_INVALID 0 +#define ANTPLUS_FEC_DATAPAGE_SWIMINTERVALSUMMARY_SESSIONAVERAGEFEC_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..f70cc10 --- /dev/null +++ b/src/Profiles/FEC/ANTPLUS_FECPrivateDefines.h @@ -0,0 +1,41 @@ +#ifndef ANTPLUS_FECPROFILEPRIVATEDEFINES_h +#define ANTPLUS_FECPROFILEPRIVATEDEFINES_h + +/* Channel Config */ +#define ANTPLUS_FEC_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE +#define ANTPLUS_FEC_MONITOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT +#define ANTPLUS_FEC_CHANNELPERIOD 8192 +// 30 / 2.5 = 12 +#define ANTPLUS_FEC_SEARCHTIMEOUT 12 + +/* General Main DataPage */ +#define ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_DATAPAGE_BYTE 0 +#define ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_EQUIPMENT_TYPE_BIT_BYTE 1 +#define ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_ELAPSED_TIME_BYTE 2 +#define ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_DISTANCE_TRAVELED_BYTE 3 +#define ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_SPEED_LSB_BYTE 4 +#define ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_SPEED_MSB_BYTE 5 +#define ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_HEARTRATE_BYTE 6 +#define ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_CAPBILITY_FESTATE_BIT_BYTE 7 + +/* FE Main DataPage */ +#define ANTPLUS_FEC_DATAPAGE_FE_MAIN_DATAPAGE_BYTE 0 +#define ANTPLUS_FEC_DATAPAGE_FE_MAIN_CADENCE_BYTE 4 +#define ANTPLUS_FEC_DATAPAGE_FE_MAIN_NEGTIVE_VERTICAL_DISTANCE_BYTE 5 + +/* Trainer Data DataPage */ +#define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_DATAPAGE_BYTE 0 +#define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_UPDATE_EVENT_COUNT_BYTE 1 +#define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_INSTANTANEOUS_CADENCE_BYTE 2 +#define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_ACCUMULATED_POWER_LSB_BYTE 3 +#define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_ACCUMULATED_POWER_MSB_BYTE 4 +#define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_INSTANTANEOUS_POWER_LSB_BYTE 5 +#define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_INSTANTANEOUS_POWER_MSB_BYTE 6 +#define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_TRAINER_STATUS_BYTE 6 +#define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_FLAGS_FESTATE_BIT_BYTE 7 + +/* Default DataPage */ +#define ANTPLUS_FEC_DATAPAGE_DEFAULT_NUMBER 0 +#define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_NUMBER 25 + +#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..995e37a --- /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_ProfileFECDataPages.h b/src/Profiles/FEC/DataPages/ANTPLUS_ProfileFECDataPages.h new file mode 100644 index 0000000..002598c --- /dev/null +++ b/src/Profiles/FEC/DataPages/ANTPLUS_ProfileFECDataPages.h @@ -0,0 +1,9 @@ +#ifndef ANTPLUS_PROFILEFECDATAPAGES_h +#define ANTPLUS_PROFILEFECDATAPAGES_h + +/* RX */ +#include + +/* TX */ + +#endif // ANTPLUS_PROFILEFECDATAPAGES_h diff --git a/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECFEMainDataPage.cpp b/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECFEMainDataPage.cpp new file mode 100644 index 0000000..893424a --- /dev/null +++ b/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECFEMainDataPage.cpp @@ -0,0 +1,9 @@ +#include +#include + +template +FECFEMainDataPage::FECFEMainDataPage() : CoreDataPage() { +} + +template class FECFEMainDataPage; +template class FECFEMainDataPage; diff --git a/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECFEMainDataPage.h b/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECFEMainDataPage.h new file mode 100644 index 0000000..967e456 --- /dev/null +++ b/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECFEMainDataPage.h @@ -0,0 +1,14 @@ +#ifndef ANTPLUS_FECFEEMAINDATAPAGE_h +#define ANTPLUS_FECFEEMAINDATAPAGE_h + +#include + +#include "ANT.h" + +template +class FECFEMainDataPage : virtual public CoreDataPage { +public: + FECFEMainDataPage(); +}; + +#endif // ANTPLUS_FECFEEMAINDATAPAGE_h diff --git a/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECGeneralMainDataPage.cpp b/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECGeneralMainDataPage.cpp new file mode 100644 index 0000000..f3fb46f --- /dev/null +++ b/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECGeneralMainDataPage.cpp @@ -0,0 +1,58 @@ +#include +#include + +template +FECGeneralMainDataPage::FECGeneralMainDataPage() : CoreDataPage() { +} + +template +uint8_t FECGeneralMainDataPage::getDataPageNumber() { + return this->get8BitValue( + ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_DATAPAGE_BYTE); +} + +template +uint8_t FECGeneralMainDataPage::getEquipmentTypeBits() { + return this->get8BitValue( + ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_EQUIPMENT_TYPE_BIT_BYTE); +} + +template +uint8_t FECGeneralMainDataPage::getElapsedTime() { + return this->get8BitValue( + ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_ELAPSED_TIME_BYTE); +} + +template +uint8_t FECGeneralMainDataPage::getDistanceTraveled() { + return this->get8BitValue( + ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_DISTANCE_TRAVELED_BYTE); +} + +template +uint8_t FECGeneralMainDataPage::getHeartRate() { + return this->get8BitValue( + ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_HEARTRATE_BYTE); +} + +template +uint8_t FECGeneralMainDataPage::getCapabilitiesBits() { + return this->get8BitValue( + ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_CAPBILITY_FESTATE_BIT_BYTE) & 0x0F; +} + +template +uint8_t FECGeneralMainDataPage::getFEStateBits() { + return (this->get8BitValue( + ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_CAPBILITY_FESTATE_BIT_BYTE) & 0xF0) >> 4; +} + +template +uint16_t FECGeneralMainDataPage::getSpeed() { + return this->get16BitValue( + ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_SPEED_LSB_BYTE, + ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_SPEED_MSB_BYTE); +} + +template class FECGeneralMainDataPage; +template class FECGeneralMainDataPage; diff --git a/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECGeneralMainDataPage.h b/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECGeneralMainDataPage.h new file mode 100644 index 0000000..1060f49 --- /dev/null +++ b/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECGeneralMainDataPage.h @@ -0,0 +1,22 @@ +#ifndef ANTPLUS_FECCOREMAINDATAPAGE_h +#define ANTPLUS_FECCOREMAINDATAPAGE_h + +#include + +#include "ANT.h" + +template +class FECGeneralMainDataPage : virtual public CoreDataPage { +public: + FECGeneralMainDataPage(); + uint8_t getDataPageNumber(); + uint8_t getEquipmentTypeBits(); + uint8_t getElapsedTime(); + uint8_t getDistanceTraveled(); + uint16_t getSpeed(); + uint8_t getHeartRate(); + uint8_t getCapabilitiesBits(); + uint8_t getFEStateBits(); +}; + +#endif // ANTPLUS_FECCOREMAINDATAPAGE_h diff --git a/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECTrainerDataPage.cpp b/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECTrainerDataPage.cpp new file mode 100644 index 0000000..7df6597 --- /dev/null +++ b/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECTrainerDataPage.cpp @@ -0,0 +1,59 @@ +#include +#include + +template +FECTrainerDataPage::FECTrainerDataPage() : CoreDataPage() { +} + +template +uint8_t FECTrainerDataPage::getDataPageNumber() { + return this->get8BitValue( + ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_DATAPAGE_BYTE); +} + +template +uint8_t FECTrainerDataPage::getUpdateEventCount() { + return this->get8BitValue( + ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_UPDATE_EVENT_COUNT_BYTE); +} + +template +uint8_t FECTrainerDataPage::getInstantaneousCadence() { + return this->get8BitValue( + ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_INSTANTANEOUS_CADENCE_BYTE); +} + +template +uint8_t FECTrainerDataPage::getFlagsBits() { + return this->get8BitValue( + ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_FLAGS_FESTATE_BIT_BYTE) & 0x0F; +} + +template +uint8_t FECTrainerDataPage::getFEStateBits() { + return (this->get8BitValue( + ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_CAPBILITY_FESTATE_BIT_BYTE) & 0xF0) >> 4; +} + +template +uint16_t FECTrainerDataPage::getAccumulatedPower() { + return this->get16BitValue( + ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_ACCUMULATED_POWER_LSB_BYTE, + ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_ACCUMULATED_POWER_MSB_BYTE); +} + +template +uint16_t FECTrainerDataPage::getInstantaneousPower() { + return this->get16BitValue( + ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_INSTANTANEOUS_POWER_LSB_BYTE, + ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_INSTANTANEOUS_POWER_MSB_BYTE) & 0x0FFF; +} + +template +uint8_t FECTrainerDataPage::getTrainerStatusBits() { + return (this->get8BitValue( + ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_TRAINER_STATUS_BYTE) & 0xF0) >> 4; +} + +template class FECTrainerDataPage; +template class FECTrainerDataPage; diff --git a/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECTrainerDataPage.h b/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECTrainerDataPage.h new file mode 100644 index 0000000..67d1dfb --- /dev/null +++ b/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECTrainerDataPage.h @@ -0,0 +1,22 @@ +#ifndef ANTPLUS_FECTRAINERDATAPAGE_h +#define ANTPLUS_FECTRAINERDATAPAGE_h + +#include + +#include "ANT.h" + +template +class FECTrainerDataPage : virtual public CoreDataPage { +public: + FECTrainerDataPage(); + uint8_t getDataPageNumber(); + uint8_t getUpdateEventCount(); + uint8_t getInstantaneousCadence(); + uint16_t getAccumulatedPower(); + uint16_t getInstantaneousPower(); + uint8_t getTrainerStatusBits(); + uint8_t getFlagsBits(); + uint8_t getFEStateBits(); +}; + +#endif // ANTPLUS_FECTRAINERDATAPAGE_h diff --git a/src/Profiles/FEC/DataPages/RX/ANTPLUS_FECTrainerData.cpp b/src/Profiles/FEC/DataPages/RX/ANTPLUS_FECTrainerData.cpp new file mode 100644 index 0000000..ce645ab --- /dev/null +++ b/src/Profiles/FEC/DataPages/RX/ANTPLUS_FECTrainerData.cpp @@ -0,0 +1,5 @@ +#include + +FECTrainerData::FECTrainerData(AntRxDataResponse& dp) : BaseDataPage(dp), FECTrainerDataPage() { + +} diff --git a/src/Profiles/FEC/DataPages/RX/ANTPLUS_FECTrainerData.h b/src/Profiles/FEC/DataPages/RX/ANTPLUS_FECTrainerData.h new file mode 100644 index 0000000..7617ffa --- /dev/null +++ b/src/Profiles/FEC/DataPages/RX/ANTPLUS_FECTrainerData.h @@ -0,0 +1,12 @@ +#ifndef ANTPLUS_FECTRAINERDATA_h +#define ANTPLUS_FECTRAINERDATA_h + +#include +#include + +class FECTrainerData : public BaseDataPage, public FECTrainerDataPage { +public: + FECTrainerData(AntRxDataResponse& dp); +}; + +#endif // ANTPLUS_FECTRAINERDATA_h diff --git a/src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.cpp b/src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.cpp new file mode 100644 index 0000000..7b1c9c6 --- /dev/null +++ b/src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.cpp @@ -0,0 +1,59 @@ +#include +#include +#include +#include +#include + +ProfileFECDisplay::ProfileFECDisplay() : BaseSlaveProfile() { + setChannelConfig(); +} + +ProfileFECDisplay::ProfileFECDisplay(uint16_t deviceNumber) : BaseSlaveProfile(deviceNumber) { + setChannelConfig(); +} + +ProfileFECDisplay::ProfileFECDisplay(uint16_t deviceNumber, uint8_t transmissionType) : BaseSlaveProfile(deviceNumber, transmissionType) { + setChannelConfig(); +} + +void ProfileFECDisplay::onBroadcastData(BroadcastData& msg) { + BaseDataPage dp = BaseDataPage(msg); + BaseSlaveProfile::onBroadcastData(msg); + if (!handleDataPage(dp)) { + callOnOtherDataPage(msg); + } +} + +bool ProfileFECDisplay::handleDataPage(BaseDataPage& dp) { + uint8_t dataPage = dp.getDataPageNumber(); + bool called = false; + + switch (dataPage) { + case ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_NUMBER: + called = handleTrainerData(dp); + break; + } + + return called; +} + +void ProfileFECDisplay::onAcknowledgedData(AcknowledgedData& msg) { + BaseDataPage dp = BaseDataPage(msg); + BaseSlaveProfile::onAcknowledgedData(msg); + if (!handleDataPage(dp)) { + callOnOtherDataPage(msg); + } +} + + +void ProfileFECDisplay::setChannelConfig() { + setChannelType(ANTPLUS_FEC_DISPLAY_CHANNELTYPE); + setDeviceType(ANTPLUS_FEC_DEVICETYPE); + setChannelPeriod(ANTPLUS_FEC_CHANNELPERIOD); + setSearchTimeout(ANTPLUS_FEC_SEARCHTIMEOUT); +} + +bool ProfileFECDisplay::handleTrainerData(BaseDataPage& dataPage) { + FECTrainerData dp = FECTrainerData(dataPage); + return _onFECTrainerData.call(dp); +} \ No newline at end of file diff --git a/src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.h b/src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.h new file mode 100644 index 0000000..6a64b13 --- /dev/null +++ b/src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.h @@ -0,0 +1,28 @@ +#ifndef ANTPLUS_PROFILEFECDISPLAY_h +#define ANTPLUS_PROFILEFECDISPLAY_h + +#include +#include +#include + +#include "ANT.h" + +class ProfileFECDisplay : public BaseSlaveProfile { +public: + ProfileFECDisplay(); + ProfileFECDisplay(uint16_t deviceNumber); + ProfileFECDisplay(uint16_t deviceNumber, uint8_t transmissionType); + void onFECTrainerData(void (*func)(FECTrainerData&, uintptr_t), uintptr_t data = 0) { _onFECTrainerData.set(func, data); } + +private: + void setChannelConfig(); + void onBroadcastData(BroadcastData& msg); + void onAcknowledgedData(AcknowledgedData& msg); + + bool handleDataPage(BaseDataPage& dp); + + bool handleTrainerData(BaseDataPage& dataPage); + Callback _onFECTrainerData; +}; + +#endif // ANTPLUS_PROFILEFECDISPLAY_h From d7b35d0f153003298f6e982b6094463165ad2de7 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 25 Oct 2020 23:44:05 -0700 Subject: [PATCH 054/241] BicyclePower: Remove if 0's Enable code to see what CI is finding Also fix callback --- .../Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp | 10 ---------- .../Sensor/ANTPLUS_ProfileBicyclePowerSensor.h | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp index d7cd176..7d1504a 100644 --- a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -45,7 +45,6 @@ void ProfileBicyclePowerSensor::onAcknowledgedData(AcknowledgedData& msg) { bool called = false; BaseMasterProfile::onAcknowledgedData(msg); -#if 0 switch (dataPage) { case ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER: @@ -55,14 +54,12 @@ void ProfileBicyclePowerSensor::onAcknowledgedData(AcknowledgedData& msg) { called = handleModeSettings(dp); break; } -#endif if (!called) { callOnOtherDataPage(msg); } } void ProfileBicyclePowerSensor::transmitNextDataPage() { -#if 0 if (isRequestedPagePending()) { transmitRequestedDataPage(); } else { @@ -76,9 +73,7 @@ void ProfileBicyclePowerSensor::transmitNextDataPage() { } } } -#else transmitPrimaryDataPage(); -#endif } void ProfileBicyclePowerSensor::transmitPrimaryDataPage() { @@ -86,7 +81,6 @@ void ProfileBicyclePowerSensor::transmitPrimaryDataPage() { } void ProfileBicyclePowerSensor::transmitBackgroundDataPage() { -#if 0 switch (_nextBackgroundPage) { case ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER: transmitBicyclePowerCumulativeOperatingTimeMsg(); @@ -104,11 +98,9 @@ void ProfileBicyclePowerSensor::transmitBackgroundDataPage() { transmitBicyclePowerCapabilitiesMsg(); break; } -#endif } uint8_t ProfileBicyclePowerSensor::getNextBackgroundPage(uint8_t currentPage) { -#if 0 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) { @@ -123,9 +115,7 @@ uint8_t ProfileBicyclePowerSensor::getNextBackgroundPage(uint8_t currentPage) { // Reached end of the loop, start again return getNextBackgroundPage(0); } -#else return 0; -#endif } void ProfileBicyclePowerSensor::transmitRequestedDataPage() { diff --git a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h index 65897f1..629371b 100644 --- a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h +++ b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h @@ -27,7 +27,7 @@ class ProfileBicyclePowerSensor : public BaseMasterProfile { void transmitBicyclePowerDefaultMsg(); void transmitBicycleStdPowerOnlyMsg(BicyclePowerStdPowerOnlyDataPageMsg& msg); uint8_t getNextBackgroundPage(uint8_t currentPage); - Callback _createBicyclePowerStdPowerOnlyDataPageMsg; + AntCallback _createBicyclePowerStdPowerOnlyDataPageMsg; uint8_t _nextBackgroundPage; uint8_t _patternStep = 0; uint32_t _flags = 0; From c53d5147cd6941c0a448652f008eeba4fbdfd184 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 25 Oct 2020 23:54:50 -0700 Subject: [PATCH 055/241] BicyclePower: minor cleanup debug and extranous C++ --- .../Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp index 7d1504a..fa0df0d 100644 --- a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -23,8 +23,7 @@ ProfileBicyclePowerSensor::ProfileBicyclePowerSensor( } void ProfileBicyclePowerSensor::onBroadcastData(BroadcastData& msg) { - Serial.println("!!!!!!!"); - BicyclePowerStdPowerOnlyDataPage dp = BicyclePowerStdPowerOnlyDataPage(msg); + BicyclePowerStdPowerOnlyDataPage dp(msg); uint8_t dataPage = dp.getDataPageNumber(); bool called = false; @@ -40,7 +39,7 @@ void ProfileBicyclePowerSensor::onBroadcastData(BroadcastData& msg) { } void ProfileBicyclePowerSensor::onAcknowledgedData(AcknowledgedData& msg) { - BicyclePowerStdPowerOnlyDataPage dp = BicyclePowerStdPowerOnlyDataPage(msg); + BicyclePowerStdPowerOnlyDataPage dp(msg); uint8_t dataPage = dp.getDataPageNumber(); bool called = false; From bcd570507b3654e78f2f0486c8b096fad263c910 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 26 Oct 2020 00:06:13 -0700 Subject: [PATCH 056/241] BicyclePower: Add missing handle request function System was defaulting to parent private class func and failing to compile --- .../Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp | 5 +++++ .../BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp index fa0df0d..bbddd3c 100644 --- a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -75,6 +75,11 @@ void ProfileBicyclePowerSensor::transmitNextDataPage() { transmitPrimaryDataPage(); } +bool ProfileBicyclePowerSensor::handleRequestDataPage(BicyclePowerStdPowerOnlyDataPage& dataPage) { + RequestDataPage dp(dataPage); + return _onRequestDataPage.call(dp); +} + void ProfileBicyclePowerSensor::transmitPrimaryDataPage() { transmitBicyclePowerDefaultMsg(); } diff --git a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h index 629371b..b55cf82 100644 --- a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h +++ b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h @@ -26,7 +26,9 @@ class ProfileBicyclePowerSensor : public BaseMasterProfile { void transmitRequestedDataPage(); void transmitBicyclePowerDefaultMsg(); void transmitBicycleStdPowerOnlyMsg(BicyclePowerStdPowerOnlyDataPageMsg& msg); + bool handleRequestDataPage(BicyclePowerStdPowerOnlyDataPage& dataPage); uint8_t getNextBackgroundPage(uint8_t currentPage); + AntCallback _onRequestDataPage; AntCallback _createBicyclePowerStdPowerOnlyDataPageMsg; uint8_t _nextBackgroundPage; uint8_t _patternStep = 0; From 09c49e8e45989a350633362938c4622d073f8e40 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 26 Oct 2020 00:13:55 -0700 Subject: [PATCH 057/241] BicyclePower: remove mode settings its not part of the profile --- .../BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp index bbddd3c..994368c 100644 --- a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -49,9 +49,6 @@ void ProfileBicyclePowerSensor::onAcknowledgedData(AcknowledgedData& msg) { case ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER: called = handleRequestDataPage(dp); break; - case ANTPLUS_COMMON_DATAPAGE_MODESETTINGS_NUMBER: - called = handleModeSettings(dp); - break; } if (!called) { callOnOtherDataPage(msg); From 75b400a38d230853be87b6806a33c4701ae2a1cd Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 26 Oct 2020 20:32:45 -0700 Subject: [PATCH 058/241] BicyclePower: factor out heart rate defines Expand power defines and fixup names --- .../ANTPLUS_BicyclePowerPrivateDefines.h | 33 ++++++++------- ...TPLUS_BicyclePowerStdPowerOnlyDataPage.cpp | 16 ++++---- ...US_BicyclePowerStdPowerOnlyDataPageMsg.cpp | 16 ++++---- .../ANTPLUS_ProfileBicyclePowerSensor.cpp | 41 ++++++++++--------- 4 files changed, 54 insertions(+), 52 deletions(-) diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h index 4fc987b..9e89d89 100644 --- a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h @@ -8,25 +8,24 @@ // 30 / 2.5 = 12 #define ANTPLUS_BICYCLEPOWER_SEARCHTIMEOUT 12 -/* Base DataPage */ -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_DATAPAGE_BYTE 0 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_UPDATE_EVENT_COUNT_BYTE 1 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_PEDAL_POWER_BYTE 2 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_INSTANTANEOUS_CADENCE_BYTE 3 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_CUMULATIVEPOWERLSB_BYTE 4 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_CUMULATIVEPOWERMSB_BYTE 5 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_INSTANTANEOUSPOWERLSB_BYTE 6 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_INSTANTANEOUSPOWERMSB_BYTE 7 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_BYTE 0 -#define ANTPLUS_BICYCLEPOWER_DATAPAGEBASE_DATAPAGE_MASK 0x7F -#define ANTPLUS_BICYCLEPOWER_DATAPAGEBASE_TOGGLE_MASK 0x80 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDCRANKTORQUE_NUMBER 0x12 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER 0x13 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKTORQUEFREQUENCY_NUMBER 0x20 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_GENERALCALIBRATION_NUMBER 0x01 -#define ANTPLUS_BICYCLEPOWER_DATAPAGEBASE_TOGGLE_SHIFT 7 -#define ANTPLUS_BICYCLEPOWER_DATAPAGEBASE_BIKESPEEDEVENTTIMEMSB_SHIFT 8 -#define ANTPLUS_BICYCLEPOWER_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNTMSB_SHIFT 8 +/* Standard Power-Only */ +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_NUMBER 0x10 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_UPDATEEVENTCOUNT_BYTE 1 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_PEDALPOWER_BYTE 2 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSCADENCE_BYTE 3 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWERLSB_BYTE 4 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWERMSB_BYTE 5 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWERLSB_BYTE 6 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWERMSB_BYTE 7 -/* Default Page */ -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_DATAPAGE_NUMBER 0x10 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DEFAULT_NUMBER ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_DATAPAGE_NUMBER +/* Standard Wheel Torque */ +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDWHEELTORQUE_NUMBER 0x11 #endif // ANTPLUS_BICYCLEPOWERPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPage.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPage.cpp index b610e27..a3616e3 100644 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPage.cpp +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPage.cpp @@ -6,25 +6,25 @@ BicyclePowerStdPowerOnlyDataPage::BicyclePowerStdPowerOnlyDataPage(AntRxDataResp } uint8_t BicyclePowerStdPowerOnlyDataPage::getDataPageNumber() { - return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_DATAPAGE_BYTE); + return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_BYTE); } uint8_t BicyclePowerStdPowerOnlyDataPage::getUpdateEventCount() { - return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_UPDATE_EVENT_COUNT_BYTE); + return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_UPDATEEVENTCOUNT_BYTE); } uint8_t BicyclePowerStdPowerOnlyDataPage::getPedalPower() { - return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_PEDAL_POWER_BYTE); + return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_PEDALPOWER_BYTE); } uint8_t BicyclePowerStdPowerOnlyDataPage::getInstantaneousCacence() { - return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_INSTANTANEOUS_CADENCE_BYTE); + return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSCADENCE_BYTE); } uint16_t BicyclePowerStdPowerOnlyDataPage::getCumulativePowerCount() { - return (getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_CUMULATIVEPOWERMSB_BYTE) << 8) | - getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_CUMULATIVEPOWERLSB_BYTE); + return (getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWERMSB_BYTE) << 8) | + getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWERLSB_BYTE); } uint16_t BicyclePowerStdPowerOnlyDataPage::getInstataneousPowerCount() { - return (getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_INSTANTANEOUSPOWERMSB_BYTE) << 8) | - getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_INSTANTANEOUSPOWERLSB_BYTE); + return (getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWERMSB_BYTE) << 8) | + getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWERLSB_BYTE); } diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPageMsg.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPageMsg.cpp index e6fe7fb..898f95b 100644 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPageMsg.cpp +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPageMsg.cpp @@ -4,21 +4,21 @@ BicyclePowerStdPowerOnlyDataPageMsg::BicyclePowerStdPowerOnlyDataPageMsg() : BaseDataPageMsg() { setDataBuffer(_buffer); - _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_DATAPAGE_NUMBER; - _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_PEDAL_POWER_BYTE] = 0xFF; - _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_INSTANTANEOUS_CADENCE_BYTE] = 0xFF; + _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_NUMBER; + _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_PEDALPOWER_BYTE] = 0xFF; + _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSCADENCE_BYTE] = 0xFF; } void BicyclePowerStdPowerOnlyDataPageMsg::setUpdateEventCount(uint8_t eventCount) { - _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_UPDATE_EVENT_COUNT_BYTE] = eventCount; + _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_UPDATEEVENTCOUNT_BYTE] = eventCount; } void BicyclePowerStdPowerOnlyDataPageMsg::setCumulativePowerCount(uint16_t accPower) { - _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_CUMULATIVEPOWERMSB_BYTE] = accPower >> 8; - _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_CUMULATIVEPOWERLSB_BYTE] = accPower & ANTPLUS_DEFAULT_BYTE_MASK; + _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWERMSB_BYTE] = accPower >> 8; + _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWERLSB_BYTE] = accPower & ANTPLUS_DEFAULT_BYTE_MASK; } void BicyclePowerStdPowerOnlyDataPageMsg::setInstataneousPowerCount(uint16_t power) { - _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_INSTANTANEOUSPOWERMSB_BYTE] = power >> 8; - _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_INSTANTANEOUSPOWERLSB_BYTE] = power & ANTPLUS_DEFAULT_BYTE_MASK; + _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWERMSB_BYTE] = power >> 8; + _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWERLSB_BYTE] = power & ANTPLUS_DEFAULT_BYTE_MASK; } diff --git a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp index 994368c..b8871ed 100644 --- a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -49,6 +49,9 @@ void ProfileBicyclePowerSensor::onAcknowledgedData(AcknowledgedData& msg) { case ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER: called = handleRequestDataPage(dp); break; + case ANTPLUS_BICYCLEPOWER_DATAPAGE_GENERALCALIBRATION_NUMBER: + called = handleGeneralCalibrationRequest(dp); + break; } if (!called) { callOnOtherDataPage(msg); @@ -83,20 +86,23 @@ void ProfileBicyclePowerSensor::transmitPrimaryDataPage() { void ProfileBicyclePowerSensor::transmitBackgroundDataPage() { switch (_nextBackgroundPage) { - case ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER: - transmitBicyclePowerCumulativeOperatingTimeMsg(); + case ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_NUMBER: + transmitBicyclePowerStandardPowerOnlyMsg(); + break; + case ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDWHEELTORQUE_NUMBER: + transmitBicyclePowerStandardWheelTorqueMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER: - transmitBicyclePowerManufacturerInformationMsg(); + case ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDCRANKTORQUE_NUMBER: + transmitBicyclePowerStandardCrankTorqueMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_NUMBER: - transmitBicyclePowerProductInformationMsg(); + case ANTPLUS_BICYCLEPOWER_DATAPAGE_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: + transmitBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_NUMBER: - transmitBicyclePowerBatteryStatusMsg(); + case ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKTORQUEFREQUENCY_NUMBER: + transmitBicyclePowerCrankTorqueFrequencyMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_NUMBER: - transmitBicyclePowerCapabilitiesMsg(); + case ANTPLUS_BICYCLEPOWER_DATAPAGE_GENERALCALIBRATION_NUMBER: + transmistBicyclePowerGeneralCalibrationResponse(); break; } } @@ -122,20 +128,16 @@ uint8_t ProfileBicyclePowerSensor::getNextBackgroundPage(uint8_t currentPage) { void ProfileBicyclePowerSensor::transmitRequestedDataPage() { uint8_t requestedPage = getRequestedPage(); switch (requestedPage) { - case ANTPLUS_BICYCLEPOWER_DATAPAGE_STD_POWERONLY_MAIN_DATAPAGE_NUMBER: + case ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_NUMBER: transmitBicyclePowerDefaultMsg(); break; } } -void ProfileBicyclePowerSensor::transmitBicyclePowerDefaultMsg() { - BicyclePowerStdPowerOnlyDataPageMsg msg; - _createBicyclePowerStdPowerOnlyDataPageMsg.call(msg); - transmitBicycleStdPowerOnlyMsg(msg); -} - -void ProfileBicyclePowerSensor::transmitBicycleStdPowerOnlyMsg(BicyclePowerStdPowerOnlyDataPageMsg& msg) { - send(msg); +void ProfileBicyclePowerSensor::transmitBicyclePowerOnlyMsg() { + BicyclePowerStandardPowerOnlyMsg msg; + _createBicyclePowerStandardPowerOnlyMsg.call(msg); + transmitMsg(msg); } void ProfileBicyclePowerSensor::setChannelConfig() { @@ -146,5 +148,6 @@ void ProfileBicyclePowerSensor::setChannelConfig() { } bool ProfileBicyclePowerSensor::isDataPageValid(uint8_t dataPage) { + // TODO return true; } From 94208d544e5a0fc54d9cfeb2d9992807d2160e58 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 27 Oct 2020 01:02:41 -0700 Subject: [PATCH 059/241] BicyclePower: Stub out data page functions To be implemented later, just to fix CI --- .../ANTPLUS_ProfileBicyclePowerSensor.cpp | 31 ++++++++++++++++++- .../ANTPLUS_ProfileBicyclePowerSensor.h | 7 +++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp index b8871ed..087079f 100644 --- a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -50,7 +50,7 @@ void ProfileBicyclePowerSensor::onAcknowledgedData(AcknowledgedData& msg) { called = handleRequestDataPage(dp); break; case ANTPLUS_BICYCLEPOWER_DATAPAGE_GENERALCALIBRATION_NUMBER: - called = handleGeneralCalibrationRequest(dp); + called = handleGeneralCalibration(dp); break; } if (!called) { @@ -80,6 +80,11 @@ bool ProfileBicyclePowerSensor::handleRequestDataPage(BicyclePowerStdPowerOnlyDa return _onRequestDataPage.call(dp); } +bool ProfileBicyclePowerSensor::handleGeneralCalibration(BicyclePowerStdPowerOnlyDataPage& dataPage) { + // TODO + return false; +} + void ProfileBicyclePowerSensor::transmitPrimaryDataPage() { transmitBicyclePowerDefaultMsg(); } @@ -107,6 +112,30 @@ void ProfileBicyclePowerSensor::transmitBackgroundDataPage() { } } +void ProfileBicyclePowerSensor::transmitBicyclePowerStandardPowerOnlyMsg() { + // TODO +} + +void ProfileBicyclePowerSensor::transmitBicyclePowerStandardWheelTorqueMsg() { + // TODO +} + +void ProfileBicyclePowerSensor::transmitBicyclePowerStandardCrankTorqueMsg() { + // TODO +} + +void ProfileBicyclePowerSensor::transmitBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg() { + // TODO +} + +void ProfileBicyclePowerSensor::transmitBicyclePowerCrankTorqueFrequencyMsg() { + // TODO +} + +void ProfileBicyclePowerSensor::transmistBicyclePowerGeneralCalibrationResponse() { + // TODO +} + uint8_t ProfileBicyclePowerSensor::getNextBackgroundPage(uint8_t currentPage) { if ((currentPage < ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER) && (_flags & ANTPLUS_HEARTRATE_FLAGS_CUMULATIVEOPERATINGTIME_SUPPORTED)) { return ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER; diff --git a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h index b55cf82..0b9b306 100644 --- a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h +++ b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h @@ -26,7 +26,14 @@ class ProfileBicyclePowerSensor : public BaseMasterProfile { void transmitRequestedDataPage(); void transmitBicyclePowerDefaultMsg(); void transmitBicycleStdPowerOnlyMsg(BicyclePowerStdPowerOnlyDataPageMsg& msg); + void transmitBicyclePowerStandardPowerOnlyMsg(); + void transmitBicyclePowerStandardWheelTorqueMsg(); + void transmitBicyclePowerStandardCrankTorqueMsg(); + void transmitBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg(); + void transmitBicyclePowerCrankTorqueFrequencyMsg(); + void transmistBicyclePowerGeneralCalibrationResponse(); bool handleRequestDataPage(BicyclePowerStdPowerOnlyDataPage& dataPage); + bool handleGeneralCalibration(BicyclePowerStdPowerOnlyDataPage& dataPage); uint8_t getNextBackgroundPage(uint8_t currentPage); AntCallback _onRequestDataPage; AntCallback _createBicyclePowerStdPowerOnlyDataPageMsg; From 96b0aeefccb2ff40cd2d78dbbd3195500a23d6be Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 27 Oct 2020 01:06:00 -0700 Subject: [PATCH 060/241] BicyclePower: remove datapage state machine Its not implemented so lets just remove it and leave a TODO --- .../Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp index 087079f..8583af3 100644 --- a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -137,20 +137,7 @@ void ProfileBicyclePowerSensor::transmistBicyclePowerGeneralCalibrationResponse( } uint8_t ProfileBicyclePowerSensor::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; - } else { - // Reached end of the loop, start again - return getNextBackgroundPage(0); - } + // TODO return 0; } From 71422cc0cb68a874e35113114612e1381dbb64c9 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 27 Oct 2020 22:15:11 -0700 Subject: [PATCH 061/241] BicyclePower: Refactor msg names to match datasheet Drop datapage as its duplicate --- .../ANTPLUS_ProfileBicyclePowerDataPages.h | 14 +++++--------- ...TPLUS_BicyclePowerStdPowerOnlyDataPageMsg.h | 18 ------------------ .../ANTPLUS_BicyclePowerStandardPowerOnly.cpp} | 17 ++++++++--------- .../ANTPLUS_BicyclePowerStandardPowerOnly.h} | 10 +++++----- ...TPLUS_BicyclePowerStandardPowerOnlyMsg.cpp} | 10 +++++----- .../ANTPLUS_BicyclePowerStandardPowerOnlyMsg.h | 18 ++++++++++++++++++ .../ANTPLUS_ProfileBicyclePowerSensor.cpp | 17 +++++++---------- .../Sensor/ANTPLUS_ProfileBicyclePowerSensor.h | 10 +++++----- 8 files changed, 53 insertions(+), 61 deletions(-) delete mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPageMsg.h rename src/Profiles/BicyclePower/DataPages/{Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPage.cpp => RX/ANTPLUS_BicyclePowerStandardPowerOnly.cpp} (56%) rename src/Profiles/BicyclePower/DataPages/{Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPage.h => RX/ANTPLUS_BicyclePowerStandardPowerOnly.h} (51%) rename src/Profiles/BicyclePower/DataPages/{Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPageMsg.cpp => TX/ANTPLUS_BicyclePowerStandardPowerOnlyMsg.cpp} (67%) create mode 100644 src/Profiles/BicyclePower/DataPages/TX/ANTPLUS_BicyclePowerStandardPowerOnlyMsg.h diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h index dbc5d5c..7280cf8 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h @@ -1,16 +1,12 @@ #ifndef ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h #define ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h -#include -#include /* RX */ -/*#include -#include -#include -#include -#include -#include -*/ +#include + +/* TX */ +#include + /* TX */ diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPageMsg.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPageMsg.h deleted file mode 100644 index 2c55a30..0000000 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPageMsg.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef ANTPLUS_BIKEPOWERSTDPOWERONLYDATAPAGEMSG_h -#define ANTPLUS_BIKEPOWERSTDPOWERONLYDATAPAGEMSG_h - -#include - -#include "ANT.h" - -class BicyclePowerStdPowerOnlyDataPageMsg : public BaseDataPageMsg { -public: - BicyclePowerStdPowerOnlyDataPageMsg(void); - void setUpdateEventCount(uint8_t eventCount); - void setCumulativePowerCount(uint16_t accPower); - void setInstataneousPowerCount(uint16_t power); -protected: - uint8_t _buffer[MESSAGE_SIZE]; -}; - -#endif // ANTPLUS_BIKEPOWERSTDPOWERONLYDATAPAGEMSG_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPage.cpp b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardPowerOnly.cpp similarity index 56% rename from src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPage.cpp rename to src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardPowerOnly.cpp index a3616e3..98cc9f5 100644 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPage.cpp +++ b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardPowerOnly.cpp @@ -1,30 +1,29 @@ -#include +#include #include -BicyclePowerStdPowerOnlyDataPage::BicyclePowerStdPowerOnlyDataPage(AntRxDataResponse& dp) : BaseDataPage(dp) { - +BicyclePowerStandardPowerOnly::BicyclePowerStandardPowerOnly(AntRxDataResponse& dp) : BaseDataPage(dp) { } -uint8_t BicyclePowerStdPowerOnlyDataPage::getDataPageNumber() { +uint8_t BicyclePowerStandardPowerOnly::getDataPageNumber() { return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_BYTE); } -uint8_t BicyclePowerStdPowerOnlyDataPage::getUpdateEventCount() { +uint8_t BicyclePowerStandardPowerOnly::getUpdateEventCount() { return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_UPDATEEVENTCOUNT_BYTE); } -uint8_t BicyclePowerStdPowerOnlyDataPage::getPedalPower() { +uint8_t BicyclePowerStandardPowerOnly::getPedalPower() { return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_PEDALPOWER_BYTE); } -uint8_t BicyclePowerStdPowerOnlyDataPage::getInstantaneousCacence() { +uint8_t BicyclePowerStandardPowerOnly::getInstantaneousCacence() { return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSCADENCE_BYTE); } -uint16_t BicyclePowerStdPowerOnlyDataPage::getCumulativePowerCount() { +uint16_t BicyclePowerStandardPowerOnly::getCumulativePowerCount() { return (getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWERMSB_BYTE) << 8) | getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWERLSB_BYTE); } -uint16_t BicyclePowerStdPowerOnlyDataPage::getInstataneousPowerCount() { +uint16_t BicyclePowerStandardPowerOnly::getInstataneousPowerCount() { return (getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWERMSB_BYTE) << 8) | getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWERLSB_BYTE); } diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPage.h b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardPowerOnly.h similarity index 51% rename from src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPage.h rename to src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardPowerOnly.h index afbe38f..813635d 100644 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPage.h +++ b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardPowerOnly.h @@ -1,13 +1,13 @@ -#ifndef ANTPLUS_BICYCLEPOWERBASEMAINDATAPAGE_h -#define ANTPLUS_BICYCLEPOWERBASEMAINDATAPAGE_h +#ifndef ANTPLUS_BICYCLEPOWERSTANDARDPOWERONLY_h +#define ANTPLUS_BICYCLEPOWERSTANDARDPOWERONLY_h #include #include "ANT.h" -class BicyclePowerStdPowerOnlyDataPage : public BaseDataPage { +class BicyclePowerStandardPowerOnly : public BaseDataPage { public: - BicyclePowerStdPowerOnlyDataPage(AntRxDataResponse& dp); + BicyclePowerStandardPowerOnly(AntRxDataResponse& dp); uint8_t getDataPageNumber(); uint8_t getUpdateEventCount(); uint8_t getPedalPower(); @@ -16,4 +16,4 @@ class BicyclePowerStdPowerOnlyDataPage : public BaseDataPage { uint16_t getInstataneousPowerCount(); }; -#endif // ANTPLUS_BICYCLEPOWERBASEMAINDATAPAGE_h +#endif // ANTPLUS_BICYCLEPOWERSTANDARDPOWERONLY_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPageMsg.cpp b/src/Profiles/BicyclePower/DataPages/TX/ANTPLUS_BicyclePowerStandardPowerOnlyMsg.cpp similarity index 67% rename from src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPageMsg.cpp rename to src/Profiles/BicyclePower/DataPages/TX/ANTPLUS_BicyclePowerStandardPowerOnlyMsg.cpp index 898f95b..f0b3a4a 100644 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerStdPowerOnlyDataPageMsg.cpp +++ b/src/Profiles/BicyclePower/DataPages/TX/ANTPLUS_BicyclePowerStandardPowerOnlyMsg.cpp @@ -1,24 +1,24 @@ -#include +#include #include #include -BicyclePowerStdPowerOnlyDataPageMsg::BicyclePowerStdPowerOnlyDataPageMsg() : BaseDataPageMsg() { +BicyclePowerStandardPowerOnlyMsg::BicyclePowerStandardPowerOnlyMsg() : BaseDataPageMsg() { setDataBuffer(_buffer); _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_NUMBER; _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_PEDALPOWER_BYTE] = 0xFF; _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSCADENCE_BYTE] = 0xFF; } -void BicyclePowerStdPowerOnlyDataPageMsg::setUpdateEventCount(uint8_t eventCount) { +void BicyclePowerStandardPowerOnlyMsg::setUpdateEventCount(uint8_t eventCount) { _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_UPDATEEVENTCOUNT_BYTE] = eventCount; } -void BicyclePowerStdPowerOnlyDataPageMsg::setCumulativePowerCount(uint16_t accPower) { +void BicyclePowerStandardPowerOnlyMsg::setCumulativePowerCount(uint16_t accPower) { _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWERMSB_BYTE] = accPower >> 8; _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWERLSB_BYTE] = accPower & ANTPLUS_DEFAULT_BYTE_MASK; } -void BicyclePowerStdPowerOnlyDataPageMsg::setInstataneousPowerCount(uint16_t power) { +void BicyclePowerStandardPowerOnlyMsg::setInstataneousPowerCount(uint16_t power) { _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWERMSB_BYTE] = power >> 8; _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWERLSB_BYTE] = power & ANTPLUS_DEFAULT_BYTE_MASK; } diff --git a/src/Profiles/BicyclePower/DataPages/TX/ANTPLUS_BicyclePowerStandardPowerOnlyMsg.h b/src/Profiles/BicyclePower/DataPages/TX/ANTPLUS_BicyclePowerStandardPowerOnlyMsg.h new file mode 100644 index 0000000..d3dde60 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/TX/ANTPLUS_BicyclePowerStandardPowerOnlyMsg.h @@ -0,0 +1,18 @@ +#ifndef ANTPLUS_BIKEPOWERSTANDARDPOWERONLYMSG_h +#define ANTPLUS_BIKEPOWERSTANDARDPOWERONLYMSG_h + +#include + +#include "ANT.h" + +class BicyclePowerStandardPowerOnlyMsg : public BaseDataPageMsg { +public: + BicyclePowerStandardPowerOnlyMsg(void); + void setUpdateEventCount(uint8_t eventCount); + void setCumulativePowerCount(uint16_t accPower); + void setInstataneousPowerCount(uint16_t power); +protected: + uint8_t _buffer[MESSAGE_SIZE]; +}; + +#endif // ANTPLUS_BIKEPOWERSTANDARDPOWERONLYMSG_h diff --git a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp index 8583af3..b89441a 100644 --- a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -23,7 +23,7 @@ ProfileBicyclePowerSensor::ProfileBicyclePowerSensor( } void ProfileBicyclePowerSensor::onBroadcastData(BroadcastData& msg) { - BicyclePowerStdPowerOnlyDataPage dp(msg); + BicyclePowerStandardPowerOnly dp(msg); uint8_t dataPage = dp.getDataPageNumber(); bool called = false; @@ -39,7 +39,7 @@ void ProfileBicyclePowerSensor::onBroadcastData(BroadcastData& msg) { } void ProfileBicyclePowerSensor::onAcknowledgedData(AcknowledgedData& msg) { - BicyclePowerStdPowerOnlyDataPage dp(msg); + BicyclePowerStandardPowerOnly dp(msg); uint8_t dataPage = dp.getDataPageNumber(); bool called = false; @@ -75,12 +75,12 @@ void ProfileBicyclePowerSensor::transmitNextDataPage() { transmitPrimaryDataPage(); } -bool ProfileBicyclePowerSensor::handleRequestDataPage(BicyclePowerStdPowerOnlyDataPage& dataPage) { +bool ProfileBicyclePowerSensor::handleRequestDataPage(BicyclePowerStandardPowerOnly& dataPage) { RequestDataPage dp(dataPage); return _onRequestDataPage.call(dp); } -bool ProfileBicyclePowerSensor::handleGeneralCalibration(BicyclePowerStdPowerOnlyDataPage& dataPage) { +bool ProfileBicyclePowerSensor::handleGeneralCalibration(BicyclePowerStandardPowerOnly& dataPage) { // TODO return false; } @@ -114,6 +114,9 @@ void ProfileBicyclePowerSensor::transmitBackgroundDataPage() { void ProfileBicyclePowerSensor::transmitBicyclePowerStandardPowerOnlyMsg() { // TODO + BicyclePowerStandardPowerOnlyMsg msg; + _createBicyclePowerStandardPowerOnlyMsg.call(msg); + transmitMsg(msg); } void ProfileBicyclePowerSensor::transmitBicyclePowerStandardWheelTorqueMsg() { @@ -150,12 +153,6 @@ void ProfileBicyclePowerSensor::transmitRequestedDataPage() { } } -void ProfileBicyclePowerSensor::transmitBicyclePowerOnlyMsg() { - BicyclePowerStandardPowerOnlyMsg msg; - _createBicyclePowerStandardPowerOnlyMsg.call(msg); - transmitMsg(msg); -} - void ProfileBicyclePowerSensor::setChannelConfig() { setChannelType(ANTPLUS_BICYCLEPOWER_SENSOR_CHANNELTYPE); setDeviceType(ANTPLUS_BICYCLEPOWER_DEVICETYPE); diff --git a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h index 0b9b306..05014db 100644 --- a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h +++ b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h @@ -12,7 +12,7 @@ class ProfileBicyclePowerSensor : public BaseMasterProfile { /** * Register callback to populate default data messages (Datapage 0) */ - void createBicyclePowerStdPowerOnlyDataPageMsg(void (*func)(BicyclePowerStdPowerOnlyDataPageMsg&, uintptr_t), uintptr_t data = 0) { _createBicyclePowerStdPowerOnlyDataPageMsg.set(func, data); } + void createBicyclePowerStandardPowerOnlyMsg(void (*func)(BicyclePowerStandardPowerOnlyMsg&, uintptr_t), uintptr_t data = 0) { _createBicyclePowerStandardPowerOnlyMsg.set(func, data); } protected: void transmitNextDataPage(); @@ -25,18 +25,18 @@ class ProfileBicyclePowerSensor : public BaseMasterProfile { void transmitBackgroundDataPage(); void transmitRequestedDataPage(); void transmitBicyclePowerDefaultMsg(); - void transmitBicycleStdPowerOnlyMsg(BicyclePowerStdPowerOnlyDataPageMsg& msg); + void transmitBicycleStandardPowerOnlyMsg(BicyclePowerStandardPowerOnlyMsg& msg); void transmitBicyclePowerStandardPowerOnlyMsg(); void transmitBicyclePowerStandardWheelTorqueMsg(); void transmitBicyclePowerStandardCrankTorqueMsg(); void transmitBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg(); void transmitBicyclePowerCrankTorqueFrequencyMsg(); void transmistBicyclePowerGeneralCalibrationResponse(); - bool handleRequestDataPage(BicyclePowerStdPowerOnlyDataPage& dataPage); - bool handleGeneralCalibration(BicyclePowerStdPowerOnlyDataPage& dataPage); + bool handleRequestDataPage(BicyclePowerStandardPowerOnly& dataPage); + bool handleGeneralCalibration(BicyclePowerStandardPowerOnly& dataPage); uint8_t getNextBackgroundPage(uint8_t currentPage); AntCallback _onRequestDataPage; - AntCallback _createBicyclePowerStdPowerOnlyDataPageMsg; + AntCallback _createBicyclePowerStandardPowerOnlyMsg; uint8_t _nextBackgroundPage; uint8_t _patternStep = 0; uint32_t _flags = 0; From 37ea4cb6b1cc4fe8e06929dae95cab5e9c90fd9b Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 27 Oct 2020 22:17:06 -0700 Subject: [PATCH 062/241] FEC: fix callback name use Ant abstacted one --- src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.h b/src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.h index 6a64b13..a2fccb9 100644 --- a/src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.h +++ b/src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.h @@ -22,7 +22,7 @@ class ProfileFECDisplay : public BaseSlaveProfile { bool handleDataPage(BaseDataPage& dp); bool handleTrainerData(BaseDataPage& dataPage); - Callback _onFECTrainerData; + AntCallback _onFECTrainerData; }; #endif // ANTPLUS_PROFILEFECDISPLAY_h From edc448dd9fc631db38c0dd05d9c5c93958266056 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 27 Oct 2020 22:26:02 -0700 Subject: [PATCH 063/241] BicyclePower: remove undefined function Remove unneeded function --- .../BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp index b89441a..71fcf63 100644 --- a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -86,7 +86,7 @@ bool ProfileBicyclePowerSensor::handleGeneralCalibration(BicyclePowerStandardPow } void ProfileBicyclePowerSensor::transmitPrimaryDataPage() { - transmitBicyclePowerDefaultMsg(); + // TODO } void ProfileBicyclePowerSensor::transmitBackgroundDataPage() { @@ -148,7 +148,7 @@ void ProfileBicyclePowerSensor::transmitRequestedDataPage() { uint8_t requestedPage = getRequestedPage(); switch (requestedPage) { case ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_NUMBER: - transmitBicyclePowerDefaultMsg(); + // TODO break; } } From 4e56701510d3594a7f3e1b80baf978f95079272f Mon Sep 17 00:00:00 2001 From: sporkfly <76623094+sporkfly@users.noreply.github.com> Date: Sat, 26 Dec 2020 11:12:09 -0500 Subject: [PATCH 064/241] Added Bicycle Power Added Bicycle Power profile initial draft, working with Favero Assioma Duo pedals. Most measurements will require post-processing, but data is received. Didn't see that there was already development work on this profile otherwise I would have started from existing work. --- .../ANTPLUS_BicyclePowerDefines.h | 13 ++ .../ANTPLUS_BicyclePowerPrivateDefines.h | 119 ++++++++++++++++++ .../ANTPLUS_BicyclePowerProfile.h | 13 ++ .../ANTPLUS_ProfileBicyclePowerDataPages.h | 14 +++ .../ANTPLUS_BicyclePowerBaseBatteryStatus.cpp | 30 +++++ .../ANTPLUS_BicyclePowerBaseBatteryStatus.h | 17 +++ .../ANTPLUS_BicyclePowerBaseCrankTorque.cpp | 35 ++++++ .../ANTPLUS_BicyclePowerBaseCrankTorque.h | 18 +++ ...icyclePowerBaseCumulativeOperatingTime.cpp | 16 +++ ..._BicyclePowerBaseCumulativeOperatingTime.h | 15 +++ .../ANTPLUS_BicyclePowerBaseMainDataPage.cpp | 14 +++ .../ANTPLUS_BicyclePowerBaseMainDataPage.h | 16 +++ ...ANTPLUS_BicyclePowerBaseManufacturerID.cpp | 29 +++++ .../ANTPLUS_BicyclePowerBaseManufacturerID.h | 17 +++ ...NTPLUS_BicyclePowerBasePedalSmoothness.cpp | 33 +++++ .../ANTPLUS_BicyclePowerBasePedalSmoothness.h | 18 +++ .../ANTPLUS_BicyclePowerBasePowerOnly.cpp | 35 ++++++ .../Base/ANTPLUS_BicyclePowerBasePowerOnly.h | 18 +++ .../ANTPLUS_BicyclePowerBaseProductID.cpp | 28 +++++ .../Base/ANTPLUS_BicyclePowerBaseProductID.h | 18 +++ .../ANTPLUS_BicyclePowerBaseWheelTorque.cpp | 35 ++++++ .../ANTPLUS_BicyclePowerBaseWheelTorque.h | 18 +++ .../RX/ANTPLUS_BicyclePowerBatteryStatus.cpp | 5 + .../RX/ANTPLUS_BicyclePowerBatteryStatus.h | 12 ++ .../RX/ANTPLUS_BicyclePowerCrankTorque.cpp | 5 + .../RX/ANTPLUS_BicyclePowerCrankTorque.h | 12 ++ ...US_BicyclePowerCumulativeOperatingTime.cpp | 4 + ...PLUS_BicyclePowerCumulativeOperatingTime.h | 12 ++ .../RX/ANTPLUS_BicyclePowerManufacturerID.cpp | 4 + .../RX/ANTPLUS_BicyclePowerManufacturerID.h | 12 ++ .../ANTPLUS_BicyclePowerPedalSmoothness.cpp | 5 + .../RX/ANTPLUS_BicyclePowerPedalSmoothness.h | 12 ++ .../RX/ANTPLUS_BicyclePowerPowerOnly.cpp | 5 + .../RX/ANTPLUS_BicyclePowerPowerOnly.h | 12 ++ .../RX/ANTPLUS_BicyclePowerProductID.cpp | 4 + .../RX/ANTPLUS_BicyclePowerProductID.h | 12 ++ .../RX/ANTPLUS_BicyclePowerWheelTorque.cpp | 5 + .../RX/ANTPLUS_BicyclePowerWheelTorque.h | 12 ++ .../ANTPLUS_ProfileBicyclePowerDisplay.cpp | 111 ++++++++++++++++ .../ANTPLUS_ProfileBicyclePowerDisplay.h | 49 ++++++++ 40 files changed, 862 insertions(+) create mode 100644 src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h create mode 100644 src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h create mode 100644 src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h create mode 100644 src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h create mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseBatteryStatus.cpp create mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseBatteryStatus.h create mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCrankTorque.cpp create mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCrankTorque.h create mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCumulativeOperatingTime.cpp create mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCumulativeOperatingTime.h create mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.cpp create mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.h create mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseManufacturerID.cpp create mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseManufacturerID.h create mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePedalSmoothness.cpp create mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePedalSmoothness.h create mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePowerOnly.cpp create mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePowerOnly.h create mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseProductID.cpp create mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseProductID.h create mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseWheelTorque.cpp create mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseWheelTorque.h create mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerBatteryStatus.cpp create mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerBatteryStatus.h create mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCrankTorque.cpp create mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCrankTorque.h create mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCumulativeOperatingTime.cpp create mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCumulativeOperatingTime.h create mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerManufacturerID.cpp create mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerManufacturerID.h create mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerPedalSmoothness.cpp create mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerPedalSmoothness.h create mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerPowerOnly.cpp create mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerPowerOnly.h create mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerProductID.cpp create mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerProductID.h create mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerWheelTorque.cpp create mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerWheelTorque.h create mode 100644 src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.cpp create mode 100644 src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h new file mode 100644 index 0000000..72102e6 --- /dev/null +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h @@ -0,0 +1,13 @@ +#ifndef ANTPLUS_BICYCLEPOWERPROFILEDEFINES_h +#define ANTPLUS_BICYCLEPOWERPROFILEDEFINES_h + +#define ANTPLUS_BICYCLEPOWER_DEVICETYPE 11 + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_NEW 1 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_GOOD 2 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_OK 3 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_LOW 4 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_CRITICAL 5 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_INVALID 7 + +#endif // diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h new file mode 100644 index 0000000..07c7ec9 --- /dev/null +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h @@ -0,0 +1,119 @@ +#ifndef ANTPLUS_BICYCLEPOWERDEFINES_h +#define ANTPLUS_BICYCLEPOWERDEFINES_h + +/* Channel Config */ +#define ANTPLUS_BICYCLEPOWER_DEVICETYPE 11 +#define ANTPLUS_BICYCLEPOWER_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE +#define ANTPLUS_BICYCLEPOWER_MONITOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT +#define ANTPLUS_BICYCLEPOWER_CHANNELPERIOD 8182 + +#define ANTPLUS_BICYCLEPOWER_SEARCHTIMEOUT 12 + +/* Fixed Bytes */ +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_BYTE 0 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_UPDATEEVENTCOUNT_BYTE 1 + +/* Power Only Main Data Page */ +/* DataPage for Power Only, CTF does not need to support. + * Note: Currently not writing any of this with CTF in mind. + * CTF support needs to be added (not in scope for my project. + */ +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_POWERONLY_NUMBER 0x10 // Changed, update throughout + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PEDALPOWER_POWERONLY_BYTE 2 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_POWERONLY_BYTE 3 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDPOWERLSB_POWERONLY_BYTE 4 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDPOWERMSB_POWERONLY_BYTE 5 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_INSTANTPOWERLSB_POWERONLY_BYTE 6 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_INSTANTPOWERMSB_POWERONLY_BYTE 7 + +/* Wheel Torque Main Data Page */ + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_WHEELTORQUE_NUMBER 0x11 // New + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELTICKS_WHEELTORQUE_BYTE 2 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_WHEELTORQUE_BYTE 3 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELPERIODLSB_WHEELTORQUE_BYTE 4 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELPERIODMSB_WHEELTORQUE_BYTE 5 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUELSB_WHEELTORQUE_BYTE 6 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUEMSB_WHEELTORQUE_BYTE 7 // New + +/* Standard Crank Torque Main Data Page */ + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_CRANKTORQUE_NUMBER 0x12 // New + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKTICKS_CRANKTORQUE_BYTE 2 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_CRANKTORQUE_BYTE 3 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKPERIODLSB_CRANKTORQUE_BYTE 4 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKPERIODMSB_CRANKTORQUE_BYTE 5 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUELSB_CRANKTORQUE_BYTE 6 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUEMSB_CRANKTORQUE_BYTE 7 // New + +/* Pedal Smoothness Main Data Page */ + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_PEDALSMOOTHNESS_NUMBER 0x13 // New + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_LEFTEFFECTIVENESS_PEDALSMOOTHNESS_BYTE 2 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_RIGHTEFFECTIVENESS_PEDALSMOOTHNESS_BYTE 3 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_LEFTSMOOTHNESS_PEDALSMOOTHNESS_BYTE 4 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_RIGHTSMOOTHNESS_PEDALSMOOTHNESS_BYTE 5 // New + +/* Crank Torque Frequency Main Data Page + +NOTE: CTF messages are big endian. The byte order for multi-byte +fields in these messages is reversed with respect to standard ANT+ messages + +Not implemented. +*/ + +/* +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_CTF_NUMBER 0x20 // New + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_SLOPEMSB_CTF_BYTE 2 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_SLOPELSB_CTF_BYTE 3 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TIMESTAMPMSB_CTF_BYTE 4 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TIMESTAMPLSB_CTF_BYTE 5 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TORQUETICKSTAMPMSB_CTF_BYTE 6 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TORQUETICKSTAMPLSB_CTF_BYTE 7 // New +*/ + +/* Manufacturer Information */ +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_NUMBER 0x50 + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_HARDWAREVERSION_BYTE 3 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MANUFACTURERIDLSB_BYTE 4 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MANUFACTURERIDMSB_BYTE 5 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MODELNUMBERLSB_BYTE 6 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MODELNUMBERMSB_BYTE 7 + + +/* Product Information */ +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_NUMBER 0x51 + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SOFTWAREVERSIONSUPP_BYTE 2 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SOFTWAREVERSION_BYTE 3 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SERIALNUMBERLSB_BYTE 4 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SERIALNUMBERMSB_BYTE 7 + +/* Battery Status */ +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_NUMBER 0x52 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER 52 + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_IDENTIFIER_BYTE 2 + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CUMULATIVEOPERATINGTIME_TIMELSB_BYTE 3 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CUMULATIVEOPERATINGTIME_TIMEMSB_BYTE 5 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE 6 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_BYTE 7 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_BYTE 7 + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_MASK 0x0F +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_MASK 0x70 + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_SHIFT 4 + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_SHIFT 4 + + + +#endif diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h new file mode 100644 index 0000000..fb97a92 --- /dev/null +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h @@ -0,0 +1,13 @@ +#ifndef ANTPLUS_BICYCLEPOWERPROFILE_h +#define ANTPLUS_BICYCLEPOWERPROFILE_h + +// General Definitions +#include + +// Datapages +#include + +// Profile Classes +#include + +#endif // ANTPLUS_BICYCLEPOWERPROFILE_h diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h new file mode 100644 index 0000000..543a226 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h @@ -0,0 +1,14 @@ +#ifndef ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h +#define ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h + +/* RX */ +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseBatteryStatus.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseBatteryStatus.cpp new file mode 100644 index 0000000..6f253a4 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseBatteryStatus.cpp @@ -0,0 +1,30 @@ +#include +#include + +template +BicyclePowerBaseBatteryStatus::BicyclePowerBaseBatteryStatus() : CoreDataPage() { +} + +template +uint8_t BicyclePowerBaseBatteryStatus::getFractionalBatteryVoltage() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE); +} + +template +uint8_t BicyclePowerBaseBatteryStatus::getCoarseBatteryVoltage() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_BYTE, + ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_MASK); +} + +template +uint8_t BicyclePowerBaseBatteryStatus::getBatteryStatus() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_BYTE, + ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_MASK, + ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_SHIFT); +} + +template class BicyclePowerBaseBatteryStatus; +template class BicyclePowerBaseBatteryStatus; diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseBatteryStatus.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseBatteryStatus.h new file mode 100644 index 0000000..a613b22 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseBatteryStatus.h @@ -0,0 +1,17 @@ +#ifndef ANTPLUS_BICYCLEPOWERBASEBATTERYSTATUS_h +#define ANTPLUS_BICYCLEPOWERBASEBATTERYSTATUS_h + +#include + +#include "ANT.h" + +template +class BicyclePowerBaseBatteryStatus : virtual public CoreDataPage { +public: + BicyclePowerBaseBatteryStatus(); + uint8_t getFractionalBatteryVoltage(); + uint8_t getCoarseBatteryVoltage(); + uint8_t getBatteryStatus(); +}; + +#endif // ANTPLUS_BICYCLEPOWERBASEBATTERYSTATUS_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCrankTorque.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCrankTorque.cpp new file mode 100644 index 0000000..186fb01 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCrankTorque.cpp @@ -0,0 +1,35 @@ +#include +#include + +template +BicyclePowerBaseCrankTorque::BicyclePowerBaseCrankTorque() : CoreDataPage() { +} + +template +uint8_t BicyclePowerBaseCrankTorque::getCrankTicks() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKTICKS_CRANKTORQUE_BYTE); +} + +template +uint8_t BicyclePowerBaseCrankTorque::getInstantCadence() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_CRANKTORQUE_BYTE); +} + +template +uint16_t BicyclePowerBaseCrankTorque::getCrankPeriod() { + return this->get16BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKPERIODLSB_CRANKTORQUE_BYTE, + ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKPERIODMSB_CRANKTORQUE_BYTE); +} + +template +uint16_t BicyclePowerBaseCrankTorque::getAccumulatedTorque() { + return this->get16BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUELSB_CRANKTORQUE_BYTE, + ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUEMSB_CRANKTORQUE_BYTE); +} + +template class BicyclePowerBaseCrankTorque; +template class BicyclePowerBaseCrankTorque; diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCrankTorque.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCrankTorque.h new file mode 100644 index 0000000..ffc98eb --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCrankTorque.h @@ -0,0 +1,18 @@ +#ifndef ANTPLUS_BICYCLEPOWERBASECRANKTORQUE_h +#define ANTPLUS_BICYCLEPOWERBASECRANKTORQUE_h + +#include + +#include "ANT.h" + +template +class BicyclePowerBaseCrankTorque : virtual public CoreDataPage { +public: + BicyclePowerBaseCrankTorque(); + uint8_t getCrankTicks(); + uint8_t getInstantCadence(); // May not be available, 0xFF indicates invalid + uint16_t getCrankPeriod(); + uint16_t getAccumulatedTorque(); +}; + +#endif // ANTPLUS_BICYCLEPOWERBASECRANKTORQUE_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCumulativeOperatingTime.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCumulativeOperatingTime.cpp new file mode 100644 index 0000000..4185ef1 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCumulativeOperatingTime.cpp @@ -0,0 +1,16 @@ +#include +#include + +template +BicyclePowerBaseCumulativeOperatingTime::BicyclePowerBaseCumulativeOperatingTime() : CoreDataPage() { +} + +template +uint32_t BicyclePowerBaseCumulativeOperatingTime::getCumulativeOperatingTime() { + return this->get24BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_CUMULATIVEOPERATINGTIME_TIMELSB_BYTE, + ANTPLUS_BICYCLEPOWER_DATAPAGE_CUMULATIVEOPERATINGTIME_TIMEMSB_BYTE); +} + +template class BicyclePowerBaseCumulativeOperatingTime; +template class BicyclePowerBaseCumulativeOperatingTime; diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCumulativeOperatingTime.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCumulativeOperatingTime.h new file mode 100644 index 0000000..42d0b91 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCumulativeOperatingTime.h @@ -0,0 +1,15 @@ +#ifndef ANTPLUS_BICYCLEPOWERBASECUMULITIVEOPERATINGTIME_h +#define ANTPLUS_BICYCLEPOWERBASECUMULITIVEOPERATINGTIME_h + +#include + +#include "ANT.h" + +template +class BicyclePowerBaseCumulativeOperatingTime : virtual public CoreDataPage { +public: + BicyclePowerBaseCumulativeOperatingTime(); + uint32_t getCumulativeOperatingTime(); // only 24 bits +}; + +#endif // ANTPLUS_BICYCLEPOWERBASECUMULITIVEOPERATINGTIME_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.cpp new file mode 100644 index 0000000..46a838b --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.cpp @@ -0,0 +1,14 @@ +#include +#include + +BicyclePowerBaseMainDataPage::BicyclePowerBaseMainDataPage(AntRxDataResponse& dp) : BaseDataPage(dp) { + +} + +uint8_t BicyclePowerBaseMainDataPage::getDataPageNumber() { + return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_BYTE); +} + +uint8_t BicyclePowerBaseMainDataPage::getUpdateEventCount() { + return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_UPDATEEVENTCOUNT_BYTE); +} diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.h new file mode 100644 index 0000000..9f220a0 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.h @@ -0,0 +1,16 @@ +#ifndef ANTPLUS_BICYCLEPOWERBASEMAINDATAPAGE_h +#define ANTPLUS_BICYCLEPOWERBASEMAINDATAPAGE_h + +#include + +#include "ANT.h" + +class BicyclePowerBaseMainDataPage : public BaseDataPage { +public: + BicyclePowerBaseMainDataPage(AntRxDataResponse& dp); + uint8_t getDataPageNumber() override; + uint8_t getUpdateEventCount(); + +}; + +#endif // ANTPLUS_BICYCLEPOWERPOWERONLYDATAPAGE_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseManufacturerID.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseManufacturerID.cpp new file mode 100644 index 0000000..77b2cc9 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseManufacturerID.cpp @@ -0,0 +1,29 @@ +#include +#include + +template +BicyclePowerBaseManufacturerID::BicyclePowerBaseManufacturerID() : CoreDataPage() { +} + +template +uint8_t BicyclePowerBaseManufacturerID::getHardwareVersion() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_HARDWAREVERSION_BYTE); +} + +template +uint16_t BicyclePowerBaseManufacturerID::getManufacturerId() { + return this->get16BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MANUFACTURERIDLSB_BYTE, + ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MANUFACTURERIDMSB_BYTE); +} + +template +uint16_t BicyclePowerBaseManufacturerID::getModelNumber() { + return this->get16BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MODELNUMBERLSB_BYTE, + ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MODELNUMBERMSB_BYTE); +} + +template class BicyclePowerBaseManufacturerID; +template class BicyclePowerBaseManufacturerID; diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseManufacturerID.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseManufacturerID.h new file mode 100644 index 0000000..3ad4a08 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseManufacturerID.h @@ -0,0 +1,17 @@ +#ifndef ANTPLUS_BICYCLEPOWERBASEMANUFACTURERINFORMATION_h +#define ANTPLUS_BICYCLEPOWERBASEMANUFACTURERINFORMATION_h + +#include + +#include "ANT.h" + +template +class BicyclePowerBaseManufacturerID : virtual public CoreDataPage { +public: + BicyclePowerBaseManufacturerID(); + uint8_t getHardwareVersion(); + uint16_t getManufacturerId(); + uint16_t getModelNumber(); +}; + +#endif // ANTPLUS_BICYCLEPOWERBASEMANUFACTURERINFORMATION_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePedalSmoothness.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePedalSmoothness.cpp new file mode 100644 index 0000000..c5c4183 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePedalSmoothness.cpp @@ -0,0 +1,33 @@ +#include +#include + +template +BicyclePowerBasePedalSmoothness::BicyclePowerBasePedalSmoothness() : CoreDataPage() { +} + +template +uint8_t BicyclePowerBasePedalSmoothness::getLeftTorqueEffectiveness() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_LEFTEFFECTIVENESS_PEDALSMOOTHNESS_BYTE); +} + +template +uint8_t BicyclePowerBasePedalSmoothness::getRightTorqueEffectiveness() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_RIGHTEFFECTIVENESS_PEDALSMOOTHNESS_BYTE); +} + +template +uint8_t BicyclePowerBasePedalSmoothness::getLeftPedalSmoothness() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_LEFTSMOOTHNESS_PEDALSMOOTHNESS_BYTE); +} + +template +uint8_t BicyclePowerBasePedalSmoothness::getRightPedalSmoothness() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_RIGHTSMOOTHNESS_PEDALSMOOTHNESS_BYTE); +} + +template class BicyclePowerBasePedalSmoothness; +template class BicyclePowerBasePedalSmoothness; diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePedalSmoothness.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePedalSmoothness.h new file mode 100644 index 0000000..11d7160 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePedalSmoothness.h @@ -0,0 +1,18 @@ +#ifndef ANTPLUS_BICYCLEPOWERBASEPEDALSMOOTHNESS_h +#define ANTPLUS_BICYCLEPOWERBASEPEDALSMOOTHNESS_h + +#include + +#include "ANT.h" + +template +class BicyclePowerBasePedalSmoothness : virtual public CoreDataPage { +public: + BicyclePowerBasePedalSmoothness(); + uint8_t getLeftTorqueEffectiveness(); + uint8_t getRightTorqueEffectiveness(); + uint8_t getLeftPedalSmoothness(); + uint8_t getRightPedalSmoothness(); +}; + +#endif // ANTPLUS_BICYCLEPOWERBASEPEDALSMOOTHNESS_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePowerOnly.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePowerOnly.cpp new file mode 100644 index 0000000..4906a73 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePowerOnly.cpp @@ -0,0 +1,35 @@ +#include +#include + +template +BicyclePowerBasePowerOnly::BicyclePowerBasePowerOnly() : CoreDataPage() { +} + +template +uint8_t BicyclePowerBasePowerOnly::getPedalBalance() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_PEDALPOWER_POWERONLY_BYTE); +} + +template +uint8_t BicyclePowerBasePowerOnly::getInstantCadence() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_POWERONLY_BYTE); +} + +template +uint16_t BicyclePowerBasePowerOnly::getAccumulatedPower() { + return this->get16BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDPOWERLSB_POWERONLY_BYTE, + ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDPOWERMSB_POWERONLY_BYTE); +} + +template +uint16_t BicyclePowerBasePowerOnly::getInstantPower() { + return this->get16BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_INSTANTPOWERLSB_POWERONLY_BYTE, + ANTPLUS_BICYCLEPOWER_DATAPAGE_INSTANTPOWERMSB_POWERONLY_BYTE); +} + +template class BicyclePowerBasePowerOnly; +template class BicyclePowerBasePowerOnly; diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePowerOnly.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePowerOnly.h new file mode 100644 index 0000000..5bc7157 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePowerOnly.h @@ -0,0 +1,18 @@ +#ifndef ANTPLUS_BICYCLEPOWERBASEPOWERONLY_h +#define ANTPLUS_BICYCLEPOWERBASEPOWERONLY_h + +#include + +#include "ANT.h" + +template +class BicyclePowerBasePowerOnly : virtual public CoreDataPage { +public: + BicyclePowerBasePowerOnly(); + uint8_t getPedalBalance(); + uint8_t getInstantCadence(); + uint16_t getAccumulatedPower(); + uint16_t getInstantPower(); +}; + +#endif // ANTPLUS_BICYCLEPOWERBASEPOWERONLY_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseProductID.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseProductID.cpp new file mode 100644 index 0000000..543f9bc --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseProductID.cpp @@ -0,0 +1,28 @@ +#include +#include + +template +BicyclePowerBaseProductID::BicyclePowerBaseProductID() : CoreDataPage() { +} + +template +uint8_t BicyclePowerBaseProductID::getSoftwareVersionSupplemental() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SOFTWAREVERSIONSUPP_BYTE); +} + +template +uint8_t BicyclePowerBaseProductID::getSoftwareVersion() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SOFTWAREVERSION_BYTE); +} + +template +uint32_t BicyclePowerBaseProductID::getSerialNumber() { + return this->get32BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SERIALNUMBERLSB_BYTE, + ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SERIALNUMBERMSB_BYTE); +} + +template class BicyclePowerBaseProductID; +template class BicyclePowerBaseProductID; diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseProductID.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseProductID.h new file mode 100644 index 0000000..7d62bab --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseProductID.h @@ -0,0 +1,18 @@ +#ifndef ANTPLUS_BICYCLEPOWERBASEPRODUCTID_h +#define ANTPLUS_BICYCLEPOWERBASEPRODUCTID_h + +#include + +#include "ANT.h" + +template +class BicyclePowerBaseProductID : virtual public CoreDataPage { +public: + BicyclePowerBaseProductID(); + uint8_t getSoftwareVersionSupplemental(); + uint8_t getSoftwareVersion(); + uint8_t getModelNumber(); + uint32_t getSerialNumber(); +}; + +#endif // ANTPLUS_BICYCLEPOWERBASEPRODUCTIONINFORMATION_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseWheelTorque.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseWheelTorque.cpp new file mode 100644 index 0000000..ff121fa --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseWheelTorque.cpp @@ -0,0 +1,35 @@ +#include +#include + +template +BicyclePowerBaseWheelTorque::BicyclePowerBaseWheelTorque() : CoreDataPage() { +} + +template +uint8_t BicyclePowerBaseWheelTorque::getWheelTicks() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELTICKS_WHEELTORQUE_BYTE); +} + +template +uint8_t BicyclePowerBaseWheelTorque::getInstantCadence() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_WHEELTORQUE_BYTE); +} + +template +uint16_t BicyclePowerBaseWheelTorque::getWheelPeriod() { + return this->get16BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELPERIODLSB_WHEELTORQUE_BYTE, + ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELPERIODMSB_WHEELTORQUE_BYTE); +} + +template +uint16_t BicyclePowerBaseWheelTorque::getAccumulatedTorque() { + return this->get16BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUELSB_WHEELTORQUE_BYTE, + ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUEMSB_WHEELTORQUE_BYTE); +} + +template class BicyclePowerBaseWheelTorque; +template class BicyclePowerBaseWheelTorque; diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseWheelTorque.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseWheelTorque.h new file mode 100644 index 0000000..7b85a85 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseWheelTorque.h @@ -0,0 +1,18 @@ +#ifndef ANTPLUS_BICYCLEPOWERBASEWHEELTORQUE_h +#define ANTPLUS_BICYCLEPOWERBASEWHEELTORQUE_h + +#include + +#include "ANT.h" + +template +class BicyclePowerBaseWheelTorque : virtual public CoreDataPage { +public: + BicyclePowerBaseWheelTorque(); + uint8_t getWheelTicks(); + uint8_t getInstantCadence(); // May not be available, 0xFF indicates invalid + uint16_t getWheelPeriod(); + uint16_t getAccumulatedTorque(); +}; + +#endif // ANTPLUS_BICYCLEPOWERBASEWHEELTORQUE_h diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerBatteryStatus.cpp b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerBatteryStatus.cpp new file mode 100644 index 0000000..6c29d8b --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerBatteryStatus.cpp @@ -0,0 +1,5 @@ +#include + +BicyclePowerBatteryStatus::BicyclePowerBatteryStatus(AntRxDataResponse& dp) : BicyclePowerBaseMainDataPage(dp), BicyclePowerBaseBatteryStatus() { + +} diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerBatteryStatus.h b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerBatteryStatus.h new file mode 100644 index 0000000..7ecc994 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerBatteryStatus.h @@ -0,0 +1,12 @@ +#ifndef ANTPLUS_BICYCLEPOWERBATTERYSTATUS_h +#define ANTPLUS_BICYCLEPOWERBATTERYSTATUS_h + +#include +#include + +class BicyclePowerBatteryStatus : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseBatteryStatus { +public: + BicyclePowerBatteryStatus(AntRxDataResponse& dp); +}; + +#endif // ANTPLUS_BICYCLEPOWERBATTERYSTATUS_h diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCrankTorque.cpp b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCrankTorque.cpp new file mode 100644 index 0000000..84879fc --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCrankTorque.cpp @@ -0,0 +1,5 @@ +#include + +BicyclePowerCrankTorque::BicyclePowerCrankTorque(AntRxDataResponse& dp) : BicyclePowerBaseMainDataPage(dp), BicyclePowerBaseCrankTorque() { + +} diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCrankTorque.h b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCrankTorque.h new file mode 100644 index 0000000..f94bcfc --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCrankTorque.h @@ -0,0 +1,12 @@ +#ifndef ANTPLUS_BICYCLEPOWERCRANKTORQUE_h +#define ANTPLUS_BICYCLEPOWERCRANKTORQUE_h + +#include +#include + +class BicyclePowerCrankTorque : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseCrankTorque { +public: + BicyclePowerCrankTorque(AntRxDataResponse& dp); +}; + +#endif // ANTPLUS_BICYCLEPOWERCRANKTORQUE_h diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCumulativeOperatingTime.cpp b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCumulativeOperatingTime.cpp new file mode 100644 index 0000000..f708fd1 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCumulativeOperatingTime.cpp @@ -0,0 +1,4 @@ +#include + +BicyclePowerCumulativeOperatingTime::BicyclePowerCumulativeOperatingTime(AntRxDataResponse& dp) : BicyclePowerBaseMainDataPage(dp) { +} diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCumulativeOperatingTime.h b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCumulativeOperatingTime.h new file mode 100644 index 0000000..98b3584 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCumulativeOperatingTime.h @@ -0,0 +1,12 @@ +#ifndef ANTPLUS_BICYCLEPOWERCUMULATIVEOPERATINGTIME_h +#define ANTPLUS_BICYCLEPOWERCUMUATIVEOPERATINGTIME_h + +#include +#include + +class BicyclePowerCumulativeOperatingTime : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseCumulativeOperatingTime { +public: + BicyclePowerCumulativeOperatingTime(AntRxDataResponse& dp); +}; + +#endif // ANTPLUS_BICYCLEPOWERCUMULITIVEOPERATINGTIME_h diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerManufacturerID.cpp b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerManufacturerID.cpp new file mode 100644 index 0000000..a816cf7 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerManufacturerID.cpp @@ -0,0 +1,4 @@ +#include + +BicyclePowerManufacturerID::BicyclePowerManufacturerID(AntRxDataResponse& dp) : BicyclePowerBaseMainDataPage(dp), BicyclePowerBaseManufacturerID() { +} diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerManufacturerID.h b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerManufacturerID.h new file mode 100644 index 0000000..173c1f1 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerManufacturerID.h @@ -0,0 +1,12 @@ +#ifndef ANTPLUS_BICYCLEPOWERMANUFACTURERID_h +#define ANTPLUS_BICYCLEPOWERMANUFACTURERID_h + +#include +#include + +class BicyclePowerManufacturerID : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseManufacturerID { +public: + BicyclePowerManufacturerID(AntRxDataResponse& dp); +}; + +#endif // ANTPLUS_BICYCLEPOWERMANUFACTURERID_h diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerPedalSmoothness.cpp b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerPedalSmoothness.cpp new file mode 100644 index 0000000..c5fb9ab --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerPedalSmoothness.cpp @@ -0,0 +1,5 @@ +#include + +BicyclePowerPedalSmoothness::BicyclePowerPedalSmoothness(AntRxDataResponse& dp) : BicyclePowerBaseMainDataPage(dp), BicyclePowerBasePedalSmoothness() { + +} diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerPedalSmoothness.h b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerPedalSmoothness.h new file mode 100644 index 0000000..b06ca43 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerPedalSmoothness.h @@ -0,0 +1,12 @@ +#ifndef ANTPLUS_BICYCLEPOWERPEDALSMOOTHNESS_h +#define ANTPLUS_BICYCLEPOWERPEDALSMOOTHNESS_h + +#include +#include + +class BicyclePowerPedalSmoothness : public BicyclePowerBaseMainDataPage, public BicyclePowerBasePedalSmoothness { +public: + BicyclePowerPedalSmoothness(AntRxDataResponse& dp); +}; + +#endif // ANTPLUS_BICYCLEPOWERPEDALSMOOTHNESS_h diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerPowerOnly.cpp b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerPowerOnly.cpp new file mode 100644 index 0000000..992816b --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerPowerOnly.cpp @@ -0,0 +1,5 @@ +#include + +BicyclePowerPowerOnly::BicyclePowerPowerOnly(AntRxDataResponse& dp) : BicyclePowerBaseMainDataPage(dp), BicyclePowerBasePowerOnly() { + +} diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerPowerOnly.h b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerPowerOnly.h new file mode 100644 index 0000000..7970f7d --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerPowerOnly.h @@ -0,0 +1,12 @@ +#ifndef ANTPLUS_BICYCLEPOWERPOWERONLY_h +#define ANTPLUS_BICYCLEPOWERPOWERONLY_h + +#include +#include + +class BicyclePowerPowerOnly : public BicyclePowerBaseMainDataPage, public BicyclePowerBasePowerOnly { +public: + BicyclePowerPowerOnly(AntRxDataResponse& dp); +}; + +#endif // ANTPLUS_BICYCLEPOWERPOWERONLY_h diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerProductID.cpp b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerProductID.cpp new file mode 100644 index 0000000..a51df55 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerProductID.cpp @@ -0,0 +1,4 @@ +#include + +BicyclePowerProductID::BicyclePowerProductID(AntRxDataResponse& dp) : BicyclePowerBaseMainDataPage(dp), BicyclePowerBaseProductID() { +} diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerProductID.h b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerProductID.h new file mode 100644 index 0000000..86c9ee6 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerProductID.h @@ -0,0 +1,12 @@ +#ifndef ANTPLUS_BICYCLEPOWERPRODUCTIONID_h +#define ANTPLUS_BICYCLEPOWERPRODUCTIONID_h + +#include +#include + +class BicyclePowerProductID : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseProductID { +public: + BicyclePowerProductID(AntRxDataResponse& dp); +}; + +#endif // ANTPLUS_BICYCLEPOWERPRODUCTIONID_h diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerWheelTorque.cpp b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerWheelTorque.cpp new file mode 100644 index 0000000..4d1d8a8 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerWheelTorque.cpp @@ -0,0 +1,5 @@ +#include + +BicyclePowerWheelTorque::BicyclePowerWheelTorque(AntRxDataResponse& dp) : BicyclePowerBaseMainDataPage(dp), BicyclePowerBaseWheelTorque() { + +} diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerWheelTorque.h b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerWheelTorque.h new file mode 100644 index 0000000..c7cded1 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerWheelTorque.h @@ -0,0 +1,12 @@ +#ifndef ANTPLUS_BICYCLEPOWERWHEELTORQUE_h +#define ANTPLUS_BICYCLEPOWERWHEELTORQUE_h + +#include +#include + +class BicyclePowerWheelTorque : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseWheelTorque { +public: + BicyclePowerWheelTorque(AntRxDataResponse& dp); +}; + +#endif // ANTPLUS_BICYCLEPOWERWHEELTORQUE_h diff --git a/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.cpp b/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.cpp new file mode 100644 index 0000000..706115a --- /dev/null +++ b/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.cpp @@ -0,0 +1,111 @@ +#include +#include +#include +#include + +ProfileBicyclePowerDisplay::ProfileBicyclePowerDisplay() : BaseSlaveProfile() { + setChannelConfig(); +} + +ProfileBicyclePowerDisplay::ProfileBicyclePowerDisplay(uint16_t deviceNumber) : BaseSlaveProfile(deviceNumber) { + setChannelConfig(); +} + +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_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_NUMBER: + called = handleManufacturerID(dp); + break; + case ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_NUMBER: + called = handleProductID(dp); + break; + case ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_NUMBER: + called = handleBatteryStatus(dp); + break; + case ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_POWERONLY_NUMBER: + called = handlePowerOnly(dp); + break; + case ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_CRANKTORQUE_NUMBER: + called = handleCrankTorque(dp); + break; + case ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_WHEELTORQUE_NUMBER: + called = handleWheelTorque(dp); + break; + case ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_PEDALSMOOTHNESS_NUMBER: + called = handlePedalSmoothness(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(ANTPLUS_BICYCLEPOWER_DISPLAY_CHANNELTYPE); + setDeviceType(ANTPLUS_BICYCLEPOWER_DEVICETYPE); + setChannelPeriod(ANTPLUS_BICYCLEPOWER_CHANNELPERIOD); + setSearchTimeout(ANTPLUS_BICYCLEPOWER_SEARCHTIMEOUT); +} + +bool ProfileBicyclePowerDisplay::handleBatteryStatus(BicyclePowerBaseMainDataPage& dataPage) { + BicyclePowerBatteryStatus dp = BicyclePowerBatteryStatus(dataPage); + return _onBicyclePowerBatteryStatus.call(dp); +} + +bool ProfileBicyclePowerDisplay::handleCumulativeOperatingTime(BicyclePowerBaseMainDataPage& dataPage) { + BicyclePowerCumulativeOperatingTime dp = BicyclePowerCumulativeOperatingTime(dataPage); + return _onBicyclePowerCumulativeOperatingTime.call(dp); +} + +bool ProfileBicyclePowerDisplay::handleManufacturerID(BicyclePowerBaseMainDataPage& dataPage) { + BicyclePowerManufacturerID dp = BicyclePowerManufacturerID(dataPage); + return _onBicyclePowerManufacturerID.call(dp); +} + +bool ProfileBicyclePowerDisplay::handleProductID(BicyclePowerBaseMainDataPage& dataPage) { + BicyclePowerProductID dp = BicyclePowerProductID(dataPage); + return _onBicyclePowerProductID.call(dp); +} + +bool ProfileBicyclePowerDisplay::handlePowerOnly(BicyclePowerBaseMainDataPage& dataPage) { + BicyclePowerPowerOnly dp = BicyclePowerPowerOnly(dataPage); + return _onBicyclePowerPowerOnly.call(dp); +} + +bool ProfileBicyclePowerDisplay::handleCrankTorque(BicyclePowerBaseMainDataPage& dataPage) { + BicyclePowerCrankTorque dp = BicyclePowerCrankTorque(dataPage); + return _onBicyclePowerCrankTorque.call(dp); +} + +bool ProfileBicyclePowerDisplay::handleWheelTorque(BicyclePowerBaseMainDataPage& dataPage) { + BicyclePowerWheelTorque dp = BicyclePowerWheelTorque(dataPage); + return _onBicyclePowerWheelTorque.call(dp); +} + +bool ProfileBicyclePowerDisplay::handlePedalSmoothness(BicyclePowerBaseMainDataPage& dataPage) { + BicyclePowerPedalSmoothness dp = BicyclePowerPedalSmoothness(dataPage); + return _onBicyclePowerPedalSmoothness.call(dp); +} diff --git a/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h b/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h new file mode 100644 index 0000000..3e6b708 --- /dev/null +++ b/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h @@ -0,0 +1,49 @@ +#ifndef ANTPLUS_PROFILEBICYCLEPOWERDISPLAY_h +#define ANTPLUS_PROFILEBICYCLEPOWERDISPLAY_h + +#include +#include +#include + +#include "ANT.h" + +class ProfileBicyclePowerDisplay : public BaseSlaveProfile { +public: + ProfileBicyclePowerDisplay(); + ProfileBicyclePowerDisplay(uint16_t deviceNumber); + ProfileBicyclePowerDisplay(uint16_t deviceNumber, uint8_t transmissionType); + void onBicyclePowerBatteryStatus(void (*func)(BicyclePowerBatteryStatus&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerBatteryStatus.set(func, data); } + void onBicyclePowerCumulativeOperatingTime(void (*func)(BicyclePowerCumulativeOperatingTime&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerCumulativeOperatingTime.set(func, data); } + void onBicyclePowerManufacturerID(void (*func)(BicyclePowerManufacturerID&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerManufacturerID.set(func, data); } + void onBicyclePowerProductID(void (*func)(BicyclePowerProductID&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerProductID.set(func, data); } + void onBicyclePowerPowerOnly(void (*func)(BicyclePowerPowerOnly&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerPowerOnly.set(func, data); } + void onBicyclePowerCrankTorque(void (*func)(BicyclePowerCrankTorque&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerCrankTorque.set(func, data); } + void onBicyclePowerWheelTorque(void (*func)(BicyclePowerWheelTorque&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerWheelTorque.set(func, data); } + void onBicyclePowerPedalSmoothness(void (*func)(BicyclePowerPedalSmoothness&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerPedalSmoothness.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 handleCumulativeOperatingTime(BicyclePowerBaseMainDataPage& dataPage); + bool handleManufacturerID(BicyclePowerBaseMainDataPage& dataPage); + bool handleProductID(BicyclePowerBaseMainDataPage& dataPage); + bool handlePowerOnly(BicyclePowerBaseMainDataPage& dataPage); + bool handleCrankTorque(BicyclePowerBaseMainDataPage& dataPage); + bool handleWheelTorque(BicyclePowerBaseMainDataPage& dataPage); + bool handlePedalSmoothness(BicyclePowerBaseMainDataPage& dataPage); + AntCallback _onBicyclePowerBatteryStatus; + AntCallback _onBicyclePowerCumulativeOperatingTime; + AntCallback _onBicyclePowerManufacturerID; + AntCallback _onBicyclePowerProductID; + AntCallback _onBicyclePowerPowerOnly; + AntCallback _onBicyclePowerCrankTorque; + AntCallback _onBicyclePowerWheelTorque; + AntCallback _onBicyclePowerPedalSmoothness; +}; + +#endif // ANTPLUS_PROFILEBICYCLEPOWERDISPLAY_h From 9dbd81b06cc9af59d2906a00a307827e2393acc6 Mon Sep 17 00:00:00 2001 From: sporkfly <76623094+sporkfly@users.noreply.github.com> Date: Sat, 26 Dec 2020 11:18:00 -0500 Subject: [PATCH 065/241] Added example for Bicycle Power Display --- .../BicyclePowerDisplay.ino | 231 ++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 examples/BicyclePowerDisplay/BicyclePowerDisplay.ino diff --git a/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino new file mode 100644 index 0000000..0ea734e --- /dev/null +++ b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino @@ -0,0 +1,231 @@ +/*********************************** + * 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" + +#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 + +// ************************************* +// 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; +const int TX_PIN = 17; +const int RX_PIN = 16; + +HardwareSerial antSerial(2); + +// ************************************* + +ArduinoSerialAntWithCallbacks ant; +AntPlusRouter router; +ProfileBicyclePowerDisplay bikePower; + +void bicyclePowerBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data); +void batteryStatusDataPageHandler(BicyclePowerBatteryStatus& msg, uintptr_t data); +void cumulativeOperatingTimeDataPageHandler(BicyclePowerCumulativeOperatingTime& msg, uintptr_t data); +void manufacturerIDDataPageHandler(BicyclePowerManufacturerID& msg, uintptr_t data); +void productIDDataPageHandler(BicyclePowerProductID& msg, uintptr_t data); +void powerOnlyDataPageHandler(BicyclePowerPowerOnly& msg, uintptr_t data); +void crankTorqueDataPageHandler(BicyclePowerCrankTorque& msg, uintptr_t data); +void wheelTorqueDataPageHandler(BicyclePowerWheelTorque& msg, uintptr_t data); +void pedalSmoothnessDataPageHandler(BicyclePowerPedalSmoothness& 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(15000); + + 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.onBicyclePowerBatteryStatus(batteryStatusDataPageHandler); + bikePower.onBicyclePowerCumulativeOperatingTime(cumulativeOperatingTimeDataPageHandler); + bikePower.onBicyclePowerManufacturerID(manufacturerIDDataPageHandler); + bikePower.onBicyclePowerProductID(productIDDataPageHandler); + bikePower.onBicyclePowerPowerOnly(powerOnlyDataPageHandler); + bikePower.onBicyclePowerCrankTorque(crankTorqueDataPageHandler); + bikePower.onBicyclePowerWheelTorque(wheelTorqueDataPageHandler); + bikePower.onBicyclePowerPedalSmoothness(pedalSmoothnessDataPageHandler); + 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 batteryStatusDataPageHandler(BicyclePowerBatteryStatus& msg, uintptr_t data) { + Serial.print("Fractional Battery Voltage: "); + Serial.println(msg.getFractionalBatteryVoltage()); + Serial.print("Battery Status: "); + bicyclePowerBatteryStatus(msg.getBatteryStatus()); +} + +void cumulativeOperatingTimeDataPageHandler(BicyclePowerCumulativeOperatingTime& msg, uintptr_t data) { + Serial.print("Cumulative Operating Time: "); + Serial.println(msg.getCumulativeOperatingTime()); +} + +void manufacturerIDDataPageHandler(BicyclePowerManufacturerID& msg, uintptr_t data) { + Serial.print("Hardware ID: "); + Serial.println(msg.getHardwareVersion()); + Serial.print("Manufacturer ID: "); + Serial.println(msg.getManufacturerId()); + Serial.print("Model Number: "); + Serial.println(msg.getModelNumber()); +} + +void productIDDataPageHandler(BicyclePowerProductID& msg, uintptr_t data) { + Serial.print("Software Version Supplemental: "); + Serial.println(msg.getSoftwareVersionSupplemental()); + Serial.print("Software Version: "); + Serial.println(msg.getSoftwareVersion()); + 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()); + Serial.print("Bike Power Event Count: "); + Serial.println(dp.getUpdateEventCount()); +} + +void powerOnlyDataPageHandler(BicyclePowerPowerOnly& msg, uintptr_t data) { + Serial.print("Pedal Balance: "); + Serial.println(msg.getPedalBalance()); + Serial.print("Instant Cadence: "); + Serial.println(msg.getInstantCadence()); + Serial.print("Accumulated Power: "); + Serial.println(msg.getAccumulatedPower()); + Serial.print("Instant Power: "); + Serial.println(msg.getInstantPower()); +} + +void crankTorqueDataPageHandler(BicyclePowerCrankTorque& msg, uintptr_t data) { + Serial.print("Crank Ticks: "); + Serial.println(msg.getCrankTicks()); + Serial.print("Instant Cadence: "); + Serial.println(msg.getInstantCadence()); + Serial.print("Crank Period: "); + Serial.println(msg.getCrankPeriod()); + Serial.print("Accumulated Torque: "); + Serial.println(msg.getAccumulatedTorque()); +} + +void wheelTorqueDataPageHandler(BicyclePowerWheelTorque& msg, uintptr_t data) { + Serial.print("Wheel Ticks: "); + Serial.println(msg.getWheelTicks()); + Serial.print("Instant Cadence: "); + Serial.println(msg.getInstantCadence()); + Serial.print("Wheel Period: "); + Serial.println(msg.getWheelPeriod()); + Serial.print("Accumulated Torque: "); + Serial.println(msg.getAccumulatedTorque()); +} + +void pedalSmoothnessDataPageHandler(BicyclePowerPedalSmoothness& msg, uintptr_t data) { + Serial.print("Left Torque Effectiveness: "); + Serial.println(msg.getLeftTorqueEffectiveness()); + Serial.print("Right Torque Effectiveness: "); + Serial.println(msg.getRightTorqueEffectiveness()); + Serial.print("Left Pedal Smoothness: "); + Serial.println(msg.getLeftPedalSmoothness()); + Serial.print("Right Pedal Smoothness: "); + Serial.println(msg.getRightPedalSmoothness()); +} + +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_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_NEW: + Serial.println("New"); + break; + case ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_GOOD: + Serial.println("Good"); + break; + case ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_OK: + Serial.println("Ok"); + break; + case ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_LOW: + Serial.println("Low"); + break; + case ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_CRITICAL: + Serial.println("Critical"); + break; + case ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_INVALID: + Serial.println("Invalid"); + break; + default: + Serial.println("Reserved/Unknown"); + break; + } +} From cb8d52c4916f72dff1817ba8645b8f6c0702d700 Mon Sep 17 00:00:00 2001 From: sporkfly <76623094+sporkfly@users.noreply.github.com> Date: Sat, 26 Dec 2020 14:34:24 -0500 Subject: [PATCH 066/241] Update BicyclePowerDisplay.ino --- examples/BicyclePowerDisplay/BicyclePowerDisplay.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino index 0ea734e..b67d6ea 100644 --- a/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino +++ b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino @@ -14,6 +14,7 @@ #include #include "ANT.h" #include "ANTPLUS.h" +#include #define BAUD_RATE 9600 #define CHANNEL_0 0 From f5a8e0d129ec3961f55e9a3be5d9fbbcbae7e8e9 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 10 Jan 2021 11:42:00 -0800 Subject: [PATCH 067/241] travis: add bicycle power example best to build the examples to get an idea if they work --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 692bbfa..1ca12ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,6 +34,7 @@ cache: - "~/.platformio" env: + - PLATFORMIO_CI_SRC=examples/BicyclePowerDisplay/BicyclePowerDisplay.ino - PLATFORMIO_CI_SRC=examples/BicycleSpeedDisplay/BicycleSpeedDisplay.ino - PLATFORMIO_CI_SRC=examples/DeviceSearch/DeviceSearch.ino - PLATFORMIO_CI_SRC=examples/DynamicProfiles/DynamicProfiles.ino From b11e44902faa9512d40c3c9477dffc253b6d6024 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 10 Jan 2021 11:53:49 -0800 Subject: [PATCH 068/241] power: fixup travis build failures for display example missing install into main headers and invalid serial declare --- examples/BicyclePowerDisplay/BicyclePowerDisplay.ino | 5 +---- src/Profiles/ANTPLUS_Profiles.h | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino index b67d6ea..46f6a06 100644 --- a/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino +++ b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino @@ -18,6 +18,7 @@ #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 @@ -27,10 +28,6 @@ const int RTS_PIN = 23; const int SUSPEND_PIN = 22; const int SLEEP_PIN = 19; const int RESET_PIN = 2; -const int TX_PIN = 17; -const int RX_PIN = 16; - -HardwareSerial antSerial(2); // ************************************* diff --git a/src/Profiles/ANTPLUS_Profiles.h b/src/Profiles/ANTPLUS_Profiles.h index 6d96a05..bf69c48 100644 --- a/src/Profiles/ANTPLUS_Profiles.h +++ b/src/Profiles/ANTPLUS_Profiles.h @@ -1,6 +1,7 @@ #ifndef ANTPLUS_PROFILES_h #define ANTPLUS_PROFILES_h +#include #include #include #include From 3fd57cf34c0079fd777f5d22b79131eb1ac90fff Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 10 Jan 2021 12:54:08 -0800 Subject: [PATCH 069/241] power: convert to unix line endings CRLF -> LF --- .../ANTPLUS_BicyclePowerDefines.h | 26 +- .../ANTPLUS_BicyclePowerPrivateDefines.h | 238 +++++++++--------- .../ANTPLUS_BicyclePowerProfile.h | 26 +- .../ANTPLUS_ProfileBicyclePowerDataPages.h | 28 +-- .../ANTPLUS_BicyclePowerBaseCrankTorque.cpp | 70 +++--- .../ANTPLUS_BicyclePowerBaseCrankTorque.h | 36 +-- .../ANTPLUS_BicyclePowerBaseMainDataPage.cpp | 28 +-- .../ANTPLUS_BicyclePowerBaseMainDataPage.h | 32 +-- ...NTPLUS_BicyclePowerBasePedalSmoothness.cpp | 66 ++--- .../ANTPLUS_BicyclePowerBasePedalSmoothness.h | 36 +-- .../ANTPLUS_BicyclePowerBasePowerOnly.cpp | 70 +++--- .../Base/ANTPLUS_BicyclePowerBasePowerOnly.h | 36 +-- .../ANTPLUS_BicyclePowerBaseWheelTorque.cpp | 70 +++--- .../ANTPLUS_BicyclePowerBaseWheelTorque.h | 36 +-- .../ANTPLUS_ProfileBicyclePowerDisplay.h | 98 ++++---- 15 files changed, 448 insertions(+), 448 deletions(-) diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h index 72102e6..b85280e 100644 --- a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h @@ -1,13 +1,13 @@ -#ifndef ANTPLUS_BICYCLEPOWERPROFILEDEFINES_h -#define ANTPLUS_BICYCLEPOWERPROFILEDEFINES_h - -#define ANTPLUS_BICYCLEPOWER_DEVICETYPE 11 - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_NEW 1 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_GOOD 2 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_OK 3 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_LOW 4 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_CRITICAL 5 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_INVALID 7 - -#endif // +#ifndef ANTPLUS_BICYCLEPOWERPROFILEDEFINES_h +#define ANTPLUS_BICYCLEPOWERPROFILEDEFINES_h + +#define ANTPLUS_BICYCLEPOWER_DEVICETYPE 11 + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_NEW 1 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_GOOD 2 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_OK 3 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_LOW 4 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_CRITICAL 5 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_INVALID 7 + +#endif // diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h index 07c7ec9..2e637f8 100644 --- a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h @@ -1,119 +1,119 @@ -#ifndef ANTPLUS_BICYCLEPOWERDEFINES_h -#define ANTPLUS_BICYCLEPOWERDEFINES_h - -/* Channel Config */ -#define ANTPLUS_BICYCLEPOWER_DEVICETYPE 11 -#define ANTPLUS_BICYCLEPOWER_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE -#define ANTPLUS_BICYCLEPOWER_MONITOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT -#define ANTPLUS_BICYCLEPOWER_CHANNELPERIOD 8182 - -#define ANTPLUS_BICYCLEPOWER_SEARCHTIMEOUT 12 - -/* Fixed Bytes */ -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_BYTE 0 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_UPDATEEVENTCOUNT_BYTE 1 - -/* Power Only Main Data Page */ -/* DataPage for Power Only, CTF does not need to support. - * Note: Currently not writing any of this with CTF in mind. - * CTF support needs to be added (not in scope for my project. - */ -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_POWERONLY_NUMBER 0x10 // Changed, update throughout - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PEDALPOWER_POWERONLY_BYTE 2 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_POWERONLY_BYTE 3 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDPOWERLSB_POWERONLY_BYTE 4 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDPOWERMSB_POWERONLY_BYTE 5 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_INSTANTPOWERLSB_POWERONLY_BYTE 6 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_INSTANTPOWERMSB_POWERONLY_BYTE 7 - -/* Wheel Torque Main Data Page */ - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_WHEELTORQUE_NUMBER 0x11 // New - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELTICKS_WHEELTORQUE_BYTE 2 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_WHEELTORQUE_BYTE 3 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELPERIODLSB_WHEELTORQUE_BYTE 4 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELPERIODMSB_WHEELTORQUE_BYTE 5 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUELSB_WHEELTORQUE_BYTE 6 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUEMSB_WHEELTORQUE_BYTE 7 // New - -/* Standard Crank Torque Main Data Page */ - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_CRANKTORQUE_NUMBER 0x12 // New - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKTICKS_CRANKTORQUE_BYTE 2 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_CRANKTORQUE_BYTE 3 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKPERIODLSB_CRANKTORQUE_BYTE 4 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKPERIODMSB_CRANKTORQUE_BYTE 5 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUELSB_CRANKTORQUE_BYTE 6 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUEMSB_CRANKTORQUE_BYTE 7 // New - -/* Pedal Smoothness Main Data Page */ - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_PEDALSMOOTHNESS_NUMBER 0x13 // New - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_LEFTEFFECTIVENESS_PEDALSMOOTHNESS_BYTE 2 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_RIGHTEFFECTIVENESS_PEDALSMOOTHNESS_BYTE 3 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_LEFTSMOOTHNESS_PEDALSMOOTHNESS_BYTE 4 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_RIGHTSMOOTHNESS_PEDALSMOOTHNESS_BYTE 5 // New - -/* Crank Torque Frequency Main Data Page - -NOTE: CTF messages are big endian. The byte order for multi-byte -fields in these messages is reversed with respect to standard ANT+ messages - -Not implemented. -*/ - -/* -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_CTF_NUMBER 0x20 // New - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_SLOPEMSB_CTF_BYTE 2 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_SLOPELSB_CTF_BYTE 3 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TIMESTAMPMSB_CTF_BYTE 4 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TIMESTAMPLSB_CTF_BYTE 5 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TORQUETICKSTAMPMSB_CTF_BYTE 6 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TORQUETICKSTAMPLSB_CTF_BYTE 7 // New -*/ - -/* Manufacturer Information */ -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_NUMBER 0x50 - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_HARDWAREVERSION_BYTE 3 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MANUFACTURERIDLSB_BYTE 4 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MANUFACTURERIDMSB_BYTE 5 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MODELNUMBERLSB_BYTE 6 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MODELNUMBERMSB_BYTE 7 - - -/* Product Information */ -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_NUMBER 0x51 - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SOFTWAREVERSIONSUPP_BYTE 2 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SOFTWAREVERSION_BYTE 3 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SERIALNUMBERLSB_BYTE 4 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SERIALNUMBERMSB_BYTE 7 - -/* Battery Status */ -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_NUMBER 0x52 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER 52 - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_IDENTIFIER_BYTE 2 - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CUMULATIVEOPERATINGTIME_TIMELSB_BYTE 3 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CUMULATIVEOPERATINGTIME_TIMEMSB_BYTE 5 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE 6 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_BYTE 7 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_BYTE 7 - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_MASK 0x0F -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_MASK 0x70 - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_SHIFT 4 - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_SHIFT 4 - - - -#endif +#ifndef ANTPLUS_BICYCLEPOWERDEFINES_h +#define ANTPLUS_BICYCLEPOWERDEFINES_h + +/* Channel Config */ +#define ANTPLUS_BICYCLEPOWER_DEVICETYPE 11 +#define ANTPLUS_BICYCLEPOWER_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE +#define ANTPLUS_BICYCLEPOWER_MONITOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT +#define ANTPLUS_BICYCLEPOWER_CHANNELPERIOD 8182 + +#define ANTPLUS_BICYCLEPOWER_SEARCHTIMEOUT 12 + +/* Fixed Bytes */ +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_BYTE 0 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_UPDATEEVENTCOUNT_BYTE 1 + +/* Power Only Main Data Page */ +/* DataPage for Power Only, CTF does not need to support. + * Note: Currently not writing any of this with CTF in mind. + * CTF support needs to be added (not in scope for my project. + */ +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_POWERONLY_NUMBER 0x10 // Changed, update throughout + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PEDALPOWER_POWERONLY_BYTE 2 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_POWERONLY_BYTE 3 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDPOWERLSB_POWERONLY_BYTE 4 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDPOWERMSB_POWERONLY_BYTE 5 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_INSTANTPOWERLSB_POWERONLY_BYTE 6 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_INSTANTPOWERMSB_POWERONLY_BYTE 7 + +/* Wheel Torque Main Data Page */ + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_WHEELTORQUE_NUMBER 0x11 // New + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELTICKS_WHEELTORQUE_BYTE 2 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_WHEELTORQUE_BYTE 3 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELPERIODLSB_WHEELTORQUE_BYTE 4 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELPERIODMSB_WHEELTORQUE_BYTE 5 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUELSB_WHEELTORQUE_BYTE 6 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUEMSB_WHEELTORQUE_BYTE 7 // New + +/* Standard Crank Torque Main Data Page */ + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_CRANKTORQUE_NUMBER 0x12 // New + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKTICKS_CRANKTORQUE_BYTE 2 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_CRANKTORQUE_BYTE 3 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKPERIODLSB_CRANKTORQUE_BYTE 4 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKPERIODMSB_CRANKTORQUE_BYTE 5 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUELSB_CRANKTORQUE_BYTE 6 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUEMSB_CRANKTORQUE_BYTE 7 // New + +/* Pedal Smoothness Main Data Page */ + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_PEDALSMOOTHNESS_NUMBER 0x13 // New + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_LEFTEFFECTIVENESS_PEDALSMOOTHNESS_BYTE 2 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_RIGHTEFFECTIVENESS_PEDALSMOOTHNESS_BYTE 3 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_LEFTSMOOTHNESS_PEDALSMOOTHNESS_BYTE 4 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_RIGHTSMOOTHNESS_PEDALSMOOTHNESS_BYTE 5 // New + +/* Crank Torque Frequency Main Data Page + +NOTE: CTF messages are big endian. The byte order for multi-byte +fields in these messages is reversed with respect to standard ANT+ messages + +Not implemented. +*/ + +/* +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_CTF_NUMBER 0x20 // New + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_SLOPEMSB_CTF_BYTE 2 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_SLOPELSB_CTF_BYTE 3 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TIMESTAMPMSB_CTF_BYTE 4 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TIMESTAMPLSB_CTF_BYTE 5 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TORQUETICKSTAMPMSB_CTF_BYTE 6 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TORQUETICKSTAMPLSB_CTF_BYTE 7 // New +*/ + +/* Manufacturer Information */ +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_NUMBER 0x50 + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_HARDWAREVERSION_BYTE 3 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MANUFACTURERIDLSB_BYTE 4 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MANUFACTURERIDMSB_BYTE 5 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MODELNUMBERLSB_BYTE 6 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MODELNUMBERMSB_BYTE 7 + + +/* Product Information */ +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_NUMBER 0x51 + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SOFTWAREVERSIONSUPP_BYTE 2 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SOFTWAREVERSION_BYTE 3 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SERIALNUMBERLSB_BYTE 4 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SERIALNUMBERMSB_BYTE 7 + +/* Battery Status */ +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_NUMBER 0x52 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER 52 + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_IDENTIFIER_BYTE 2 + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CUMULATIVEOPERATINGTIME_TIMELSB_BYTE 3 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CUMULATIVEOPERATINGTIME_TIMEMSB_BYTE 5 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE 6 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_BYTE 7 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_BYTE 7 + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_MASK 0x0F +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_MASK 0x70 + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_SHIFT 4 + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_SHIFT 4 + + + +#endif diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h index fb97a92..847e102 100644 --- a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h @@ -1,13 +1,13 @@ -#ifndef ANTPLUS_BICYCLEPOWERPROFILE_h -#define ANTPLUS_BICYCLEPOWERPROFILE_h - -// General Definitions -#include - -// Datapages -#include - -// Profile Classes -#include - -#endif // ANTPLUS_BICYCLEPOWERPROFILE_h +#ifndef ANTPLUS_BICYCLEPOWERPROFILE_h +#define ANTPLUS_BICYCLEPOWERPROFILE_h + +// General Definitions +#include + +// Datapages +#include + +// Profile Classes +#include + +#endif // ANTPLUS_BICYCLEPOWERPROFILE_h diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h index 543a226..17f13b6 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h @@ -1,14 +1,14 @@ -#ifndef ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h -#define ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h - -/* RX */ -#include -#include -#include -#include -#include -#include -#include -#include - -#endif // ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h +#ifndef ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h +#define ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h + +/* RX */ +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCrankTorque.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCrankTorque.cpp index 186fb01..6cda283 100644 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCrankTorque.cpp +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCrankTorque.cpp @@ -1,35 +1,35 @@ -#include -#include - -template -BicyclePowerBaseCrankTorque::BicyclePowerBaseCrankTorque() : CoreDataPage() { -} - -template -uint8_t BicyclePowerBaseCrankTorque::getCrankTicks() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKTICKS_CRANKTORQUE_BYTE); -} - -template -uint8_t BicyclePowerBaseCrankTorque::getInstantCadence() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_CRANKTORQUE_BYTE); -} - -template -uint16_t BicyclePowerBaseCrankTorque::getCrankPeriod() { - return this->get16BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKPERIODLSB_CRANKTORQUE_BYTE, - ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKPERIODMSB_CRANKTORQUE_BYTE); -} - -template -uint16_t BicyclePowerBaseCrankTorque::getAccumulatedTorque() { - return this->get16BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUELSB_CRANKTORQUE_BYTE, - ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUEMSB_CRANKTORQUE_BYTE); -} - -template class BicyclePowerBaseCrankTorque; -template class BicyclePowerBaseCrankTorque; +#include +#include + +template +BicyclePowerBaseCrankTorque::BicyclePowerBaseCrankTorque() : CoreDataPage() { +} + +template +uint8_t BicyclePowerBaseCrankTorque::getCrankTicks() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKTICKS_CRANKTORQUE_BYTE); +} + +template +uint8_t BicyclePowerBaseCrankTorque::getInstantCadence() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_CRANKTORQUE_BYTE); +} + +template +uint16_t BicyclePowerBaseCrankTorque::getCrankPeriod() { + return this->get16BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKPERIODLSB_CRANKTORQUE_BYTE, + ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKPERIODMSB_CRANKTORQUE_BYTE); +} + +template +uint16_t BicyclePowerBaseCrankTorque::getAccumulatedTorque() { + return this->get16BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUELSB_CRANKTORQUE_BYTE, + ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUEMSB_CRANKTORQUE_BYTE); +} + +template class BicyclePowerBaseCrankTorque; +template class BicyclePowerBaseCrankTorque; diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCrankTorque.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCrankTorque.h index ffc98eb..9fd63ba 100644 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCrankTorque.h +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCrankTorque.h @@ -1,18 +1,18 @@ -#ifndef ANTPLUS_BICYCLEPOWERBASECRANKTORQUE_h -#define ANTPLUS_BICYCLEPOWERBASECRANKTORQUE_h - -#include - -#include "ANT.h" - -template -class BicyclePowerBaseCrankTorque : virtual public CoreDataPage { -public: - BicyclePowerBaseCrankTorque(); - uint8_t getCrankTicks(); - uint8_t getInstantCadence(); // May not be available, 0xFF indicates invalid - uint16_t getCrankPeriod(); - uint16_t getAccumulatedTorque(); -}; - -#endif // ANTPLUS_BICYCLEPOWERBASECRANKTORQUE_h +#ifndef ANTPLUS_BICYCLEPOWERBASECRANKTORQUE_h +#define ANTPLUS_BICYCLEPOWERBASECRANKTORQUE_h + +#include + +#include "ANT.h" + +template +class BicyclePowerBaseCrankTorque : virtual public CoreDataPage { +public: + BicyclePowerBaseCrankTorque(); + uint8_t getCrankTicks(); + uint8_t getInstantCadence(); // May not be available, 0xFF indicates invalid + uint16_t getCrankPeriod(); + uint16_t getAccumulatedTorque(); +}; + +#endif // ANTPLUS_BICYCLEPOWERBASECRANKTORQUE_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.cpp index 46a838b..3d62d71 100644 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.cpp +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.cpp @@ -1,14 +1,14 @@ -#include -#include - -BicyclePowerBaseMainDataPage::BicyclePowerBaseMainDataPage(AntRxDataResponse& dp) : BaseDataPage(dp) { - -} - -uint8_t BicyclePowerBaseMainDataPage::getDataPageNumber() { - return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_BYTE); -} - -uint8_t BicyclePowerBaseMainDataPage::getUpdateEventCount() { - return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_UPDATEEVENTCOUNT_BYTE); -} +#include +#include + +BicyclePowerBaseMainDataPage::BicyclePowerBaseMainDataPage(AntRxDataResponse& dp) : BaseDataPage(dp) { + +} + +uint8_t BicyclePowerBaseMainDataPage::getDataPageNumber() { + return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_BYTE); +} + +uint8_t BicyclePowerBaseMainDataPage::getUpdateEventCount() { + return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_UPDATEEVENTCOUNT_BYTE); +} diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.h index 9f220a0..c3ccec5 100644 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.h +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.h @@ -1,16 +1,16 @@ -#ifndef ANTPLUS_BICYCLEPOWERBASEMAINDATAPAGE_h -#define ANTPLUS_BICYCLEPOWERBASEMAINDATAPAGE_h - -#include - -#include "ANT.h" - -class BicyclePowerBaseMainDataPage : public BaseDataPage { -public: - BicyclePowerBaseMainDataPage(AntRxDataResponse& dp); - uint8_t getDataPageNumber() override; - uint8_t getUpdateEventCount(); - -}; - -#endif // ANTPLUS_BICYCLEPOWERPOWERONLYDATAPAGE_h +#ifndef ANTPLUS_BICYCLEPOWERBASEMAINDATAPAGE_h +#define ANTPLUS_BICYCLEPOWERBASEMAINDATAPAGE_h + +#include + +#include "ANT.h" + +class BicyclePowerBaseMainDataPage : public BaseDataPage { +public: + BicyclePowerBaseMainDataPage(AntRxDataResponse& dp); + uint8_t getDataPageNumber() override; + uint8_t getUpdateEventCount(); + +}; + +#endif // ANTPLUS_BICYCLEPOWERPOWERONLYDATAPAGE_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePedalSmoothness.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePedalSmoothness.cpp index c5c4183..ce73a43 100644 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePedalSmoothness.cpp +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePedalSmoothness.cpp @@ -1,33 +1,33 @@ -#include -#include - -template -BicyclePowerBasePedalSmoothness::BicyclePowerBasePedalSmoothness() : CoreDataPage() { -} - -template -uint8_t BicyclePowerBasePedalSmoothness::getLeftTorqueEffectiveness() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_LEFTEFFECTIVENESS_PEDALSMOOTHNESS_BYTE); -} - -template -uint8_t BicyclePowerBasePedalSmoothness::getRightTorqueEffectiveness() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_RIGHTEFFECTIVENESS_PEDALSMOOTHNESS_BYTE); -} - -template -uint8_t BicyclePowerBasePedalSmoothness::getLeftPedalSmoothness() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_LEFTSMOOTHNESS_PEDALSMOOTHNESS_BYTE); -} - -template -uint8_t BicyclePowerBasePedalSmoothness::getRightPedalSmoothness() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_RIGHTSMOOTHNESS_PEDALSMOOTHNESS_BYTE); -} - -template class BicyclePowerBasePedalSmoothness; -template class BicyclePowerBasePedalSmoothness; +#include +#include + +template +BicyclePowerBasePedalSmoothness::BicyclePowerBasePedalSmoothness() : CoreDataPage() { +} + +template +uint8_t BicyclePowerBasePedalSmoothness::getLeftTorqueEffectiveness() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_LEFTEFFECTIVENESS_PEDALSMOOTHNESS_BYTE); +} + +template +uint8_t BicyclePowerBasePedalSmoothness::getRightTorqueEffectiveness() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_RIGHTEFFECTIVENESS_PEDALSMOOTHNESS_BYTE); +} + +template +uint8_t BicyclePowerBasePedalSmoothness::getLeftPedalSmoothness() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_LEFTSMOOTHNESS_PEDALSMOOTHNESS_BYTE); +} + +template +uint8_t BicyclePowerBasePedalSmoothness::getRightPedalSmoothness() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_RIGHTSMOOTHNESS_PEDALSMOOTHNESS_BYTE); +} + +template class BicyclePowerBasePedalSmoothness; +template class BicyclePowerBasePedalSmoothness; diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePedalSmoothness.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePedalSmoothness.h index 11d7160..6ffd75f 100644 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePedalSmoothness.h +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePedalSmoothness.h @@ -1,18 +1,18 @@ -#ifndef ANTPLUS_BICYCLEPOWERBASEPEDALSMOOTHNESS_h -#define ANTPLUS_BICYCLEPOWERBASEPEDALSMOOTHNESS_h - -#include - -#include "ANT.h" - -template -class BicyclePowerBasePedalSmoothness : virtual public CoreDataPage { -public: - BicyclePowerBasePedalSmoothness(); - uint8_t getLeftTorqueEffectiveness(); - uint8_t getRightTorqueEffectiveness(); - uint8_t getLeftPedalSmoothness(); - uint8_t getRightPedalSmoothness(); -}; - -#endif // ANTPLUS_BICYCLEPOWERBASEPEDALSMOOTHNESS_h +#ifndef ANTPLUS_BICYCLEPOWERBASEPEDALSMOOTHNESS_h +#define ANTPLUS_BICYCLEPOWERBASEPEDALSMOOTHNESS_h + +#include + +#include "ANT.h" + +template +class BicyclePowerBasePedalSmoothness : virtual public CoreDataPage { +public: + BicyclePowerBasePedalSmoothness(); + uint8_t getLeftTorqueEffectiveness(); + uint8_t getRightTorqueEffectiveness(); + uint8_t getLeftPedalSmoothness(); + uint8_t getRightPedalSmoothness(); +}; + +#endif // ANTPLUS_BICYCLEPOWERBASEPEDALSMOOTHNESS_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePowerOnly.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePowerOnly.cpp index 4906a73..0b58f4b 100644 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePowerOnly.cpp +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePowerOnly.cpp @@ -1,35 +1,35 @@ -#include -#include - -template -BicyclePowerBasePowerOnly::BicyclePowerBasePowerOnly() : CoreDataPage() { -} - -template -uint8_t BicyclePowerBasePowerOnly::getPedalBalance() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_PEDALPOWER_POWERONLY_BYTE); -} - -template -uint8_t BicyclePowerBasePowerOnly::getInstantCadence() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_POWERONLY_BYTE); -} - -template -uint16_t BicyclePowerBasePowerOnly::getAccumulatedPower() { - return this->get16BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDPOWERLSB_POWERONLY_BYTE, - ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDPOWERMSB_POWERONLY_BYTE); -} - -template -uint16_t BicyclePowerBasePowerOnly::getInstantPower() { - return this->get16BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_INSTANTPOWERLSB_POWERONLY_BYTE, - ANTPLUS_BICYCLEPOWER_DATAPAGE_INSTANTPOWERMSB_POWERONLY_BYTE); -} - -template class BicyclePowerBasePowerOnly; -template class BicyclePowerBasePowerOnly; +#include +#include + +template +BicyclePowerBasePowerOnly::BicyclePowerBasePowerOnly() : CoreDataPage() { +} + +template +uint8_t BicyclePowerBasePowerOnly::getPedalBalance() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_PEDALPOWER_POWERONLY_BYTE); +} + +template +uint8_t BicyclePowerBasePowerOnly::getInstantCadence() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_POWERONLY_BYTE); +} + +template +uint16_t BicyclePowerBasePowerOnly::getAccumulatedPower() { + return this->get16BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDPOWERLSB_POWERONLY_BYTE, + ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDPOWERMSB_POWERONLY_BYTE); +} + +template +uint16_t BicyclePowerBasePowerOnly::getInstantPower() { + return this->get16BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_INSTANTPOWERLSB_POWERONLY_BYTE, + ANTPLUS_BICYCLEPOWER_DATAPAGE_INSTANTPOWERMSB_POWERONLY_BYTE); +} + +template class BicyclePowerBasePowerOnly; +template class BicyclePowerBasePowerOnly; diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePowerOnly.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePowerOnly.h index 5bc7157..c7742f4 100644 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePowerOnly.h +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBasePowerOnly.h @@ -1,18 +1,18 @@ -#ifndef ANTPLUS_BICYCLEPOWERBASEPOWERONLY_h -#define ANTPLUS_BICYCLEPOWERBASEPOWERONLY_h - -#include - -#include "ANT.h" - -template -class BicyclePowerBasePowerOnly : virtual public CoreDataPage { -public: - BicyclePowerBasePowerOnly(); - uint8_t getPedalBalance(); - uint8_t getInstantCadence(); - uint16_t getAccumulatedPower(); - uint16_t getInstantPower(); -}; - -#endif // ANTPLUS_BICYCLEPOWERBASEPOWERONLY_h +#ifndef ANTPLUS_BICYCLEPOWERBASEPOWERONLY_h +#define ANTPLUS_BICYCLEPOWERBASEPOWERONLY_h + +#include + +#include "ANT.h" + +template +class BicyclePowerBasePowerOnly : virtual public CoreDataPage { +public: + BicyclePowerBasePowerOnly(); + uint8_t getPedalBalance(); + uint8_t getInstantCadence(); + uint16_t getAccumulatedPower(); + uint16_t getInstantPower(); +}; + +#endif // ANTPLUS_BICYCLEPOWERBASEPOWERONLY_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseWheelTorque.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseWheelTorque.cpp index ff121fa..6232c97 100644 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseWheelTorque.cpp +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseWheelTorque.cpp @@ -1,35 +1,35 @@ -#include -#include - -template -BicyclePowerBaseWheelTorque::BicyclePowerBaseWheelTorque() : CoreDataPage() { -} - -template -uint8_t BicyclePowerBaseWheelTorque::getWheelTicks() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELTICKS_WHEELTORQUE_BYTE); -} - -template -uint8_t BicyclePowerBaseWheelTorque::getInstantCadence() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_WHEELTORQUE_BYTE); -} - -template -uint16_t BicyclePowerBaseWheelTorque::getWheelPeriod() { - return this->get16BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELPERIODLSB_WHEELTORQUE_BYTE, - ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELPERIODMSB_WHEELTORQUE_BYTE); -} - -template -uint16_t BicyclePowerBaseWheelTorque::getAccumulatedTorque() { - return this->get16BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUELSB_WHEELTORQUE_BYTE, - ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUEMSB_WHEELTORQUE_BYTE); -} - -template class BicyclePowerBaseWheelTorque; -template class BicyclePowerBaseWheelTorque; +#include +#include + +template +BicyclePowerBaseWheelTorque::BicyclePowerBaseWheelTorque() : CoreDataPage() { +} + +template +uint8_t BicyclePowerBaseWheelTorque::getWheelTicks() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELTICKS_WHEELTORQUE_BYTE); +} + +template +uint8_t BicyclePowerBaseWheelTorque::getInstantCadence() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_WHEELTORQUE_BYTE); +} + +template +uint16_t BicyclePowerBaseWheelTorque::getWheelPeriod() { + return this->get16BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELPERIODLSB_WHEELTORQUE_BYTE, + ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELPERIODMSB_WHEELTORQUE_BYTE); +} + +template +uint16_t BicyclePowerBaseWheelTorque::getAccumulatedTorque() { + return this->get16BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUELSB_WHEELTORQUE_BYTE, + ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUEMSB_WHEELTORQUE_BYTE); +} + +template class BicyclePowerBaseWheelTorque; +template class BicyclePowerBaseWheelTorque; diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseWheelTorque.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseWheelTorque.h index 7b85a85..0e3cb9e 100644 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseWheelTorque.h +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseWheelTorque.h @@ -1,18 +1,18 @@ -#ifndef ANTPLUS_BICYCLEPOWERBASEWHEELTORQUE_h -#define ANTPLUS_BICYCLEPOWERBASEWHEELTORQUE_h - -#include - -#include "ANT.h" - -template -class BicyclePowerBaseWheelTorque : virtual public CoreDataPage { -public: - BicyclePowerBaseWheelTorque(); - uint8_t getWheelTicks(); - uint8_t getInstantCadence(); // May not be available, 0xFF indicates invalid - uint16_t getWheelPeriod(); - uint16_t getAccumulatedTorque(); -}; - -#endif // ANTPLUS_BICYCLEPOWERBASEWHEELTORQUE_h +#ifndef ANTPLUS_BICYCLEPOWERBASEWHEELTORQUE_h +#define ANTPLUS_BICYCLEPOWERBASEWHEELTORQUE_h + +#include + +#include "ANT.h" + +template +class BicyclePowerBaseWheelTorque : virtual public CoreDataPage { +public: + BicyclePowerBaseWheelTorque(); + uint8_t getWheelTicks(); + uint8_t getInstantCadence(); // May not be available, 0xFF indicates invalid + uint16_t getWheelPeriod(); + uint16_t getAccumulatedTorque(); +}; + +#endif // ANTPLUS_BICYCLEPOWERBASEWHEELTORQUE_h diff --git a/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h b/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h index 3e6b708..0ce62fb 100644 --- a/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h +++ b/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h @@ -1,49 +1,49 @@ -#ifndef ANTPLUS_PROFILEBICYCLEPOWERDISPLAY_h -#define ANTPLUS_PROFILEBICYCLEPOWERDISPLAY_h - -#include -#include -#include - -#include "ANT.h" - -class ProfileBicyclePowerDisplay : public BaseSlaveProfile { -public: - ProfileBicyclePowerDisplay(); - ProfileBicyclePowerDisplay(uint16_t deviceNumber); - ProfileBicyclePowerDisplay(uint16_t deviceNumber, uint8_t transmissionType); - void onBicyclePowerBatteryStatus(void (*func)(BicyclePowerBatteryStatus&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerBatteryStatus.set(func, data); } - void onBicyclePowerCumulativeOperatingTime(void (*func)(BicyclePowerCumulativeOperatingTime&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerCumulativeOperatingTime.set(func, data); } - void onBicyclePowerManufacturerID(void (*func)(BicyclePowerManufacturerID&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerManufacturerID.set(func, data); } - void onBicyclePowerProductID(void (*func)(BicyclePowerProductID&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerProductID.set(func, data); } - void onBicyclePowerPowerOnly(void (*func)(BicyclePowerPowerOnly&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerPowerOnly.set(func, data); } - void onBicyclePowerCrankTorque(void (*func)(BicyclePowerCrankTorque&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerCrankTorque.set(func, data); } - void onBicyclePowerWheelTorque(void (*func)(BicyclePowerWheelTorque&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerWheelTorque.set(func, data); } - void onBicyclePowerPedalSmoothness(void (*func)(BicyclePowerPedalSmoothness&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerPedalSmoothness.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 handleCumulativeOperatingTime(BicyclePowerBaseMainDataPage& dataPage); - bool handleManufacturerID(BicyclePowerBaseMainDataPage& dataPage); - bool handleProductID(BicyclePowerBaseMainDataPage& dataPage); - bool handlePowerOnly(BicyclePowerBaseMainDataPage& dataPage); - bool handleCrankTorque(BicyclePowerBaseMainDataPage& dataPage); - bool handleWheelTorque(BicyclePowerBaseMainDataPage& dataPage); - bool handlePedalSmoothness(BicyclePowerBaseMainDataPage& dataPage); - AntCallback _onBicyclePowerBatteryStatus; - AntCallback _onBicyclePowerCumulativeOperatingTime; - AntCallback _onBicyclePowerManufacturerID; - AntCallback _onBicyclePowerProductID; - AntCallback _onBicyclePowerPowerOnly; - AntCallback _onBicyclePowerCrankTorque; - AntCallback _onBicyclePowerWheelTorque; - AntCallback _onBicyclePowerPedalSmoothness; -}; - -#endif // ANTPLUS_PROFILEBICYCLEPOWERDISPLAY_h +#ifndef ANTPLUS_PROFILEBICYCLEPOWERDISPLAY_h +#define ANTPLUS_PROFILEBICYCLEPOWERDISPLAY_h + +#include +#include +#include + +#include "ANT.h" + +class ProfileBicyclePowerDisplay : public BaseSlaveProfile { +public: + ProfileBicyclePowerDisplay(); + ProfileBicyclePowerDisplay(uint16_t deviceNumber); + ProfileBicyclePowerDisplay(uint16_t deviceNumber, uint8_t transmissionType); + void onBicyclePowerBatteryStatus(void (*func)(BicyclePowerBatteryStatus&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerBatteryStatus.set(func, data); } + void onBicyclePowerCumulativeOperatingTime(void (*func)(BicyclePowerCumulativeOperatingTime&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerCumulativeOperatingTime.set(func, data); } + void onBicyclePowerManufacturerID(void (*func)(BicyclePowerManufacturerID&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerManufacturerID.set(func, data); } + void onBicyclePowerProductID(void (*func)(BicyclePowerProductID&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerProductID.set(func, data); } + void onBicyclePowerPowerOnly(void (*func)(BicyclePowerPowerOnly&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerPowerOnly.set(func, data); } + void onBicyclePowerCrankTorque(void (*func)(BicyclePowerCrankTorque&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerCrankTorque.set(func, data); } + void onBicyclePowerWheelTorque(void (*func)(BicyclePowerWheelTorque&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerWheelTorque.set(func, data); } + void onBicyclePowerPedalSmoothness(void (*func)(BicyclePowerPedalSmoothness&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerPedalSmoothness.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 handleCumulativeOperatingTime(BicyclePowerBaseMainDataPage& dataPage); + bool handleManufacturerID(BicyclePowerBaseMainDataPage& dataPage); + bool handleProductID(BicyclePowerBaseMainDataPage& dataPage); + bool handlePowerOnly(BicyclePowerBaseMainDataPage& dataPage); + bool handleCrankTorque(BicyclePowerBaseMainDataPage& dataPage); + bool handleWheelTorque(BicyclePowerBaseMainDataPage& dataPage); + bool handlePedalSmoothness(BicyclePowerBaseMainDataPage& dataPage); + AntCallback _onBicyclePowerBatteryStatus; + AntCallback _onBicyclePowerCumulativeOperatingTime; + AntCallback _onBicyclePowerManufacturerID; + AntCallback _onBicyclePowerProductID; + AntCallback _onBicyclePowerPowerOnly; + AntCallback _onBicyclePowerCrankTorque; + AntCallback _onBicyclePowerWheelTorque; + AntCallback _onBicyclePowerPedalSmoothness; +}; + +#endif // ANTPLUS_PROFILEBICYCLEPOWERDISPLAY_h From 5e3c047f08605f86c75c3279ed448f93fa6dbb3c Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 11 Jan 2021 10:29:54 -0800 Subject: [PATCH 070/241] power: switch tabs to spaces and remove unneeded comments --- .../ANTPLUS_BicyclePowerPrivateDefines.h | 110 +++++++++--------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h index 8563568..802377a 100644 --- a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h @@ -4,18 +4,18 @@ #include /* Channel Config */ -#define ANTPLUS_BICYCLEPOWER_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE -#define ANTPLUS_BICYCLEPOWER_SENSOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT -#define ANTPLUS_BICYCLEPOWER_DEVICETYPE 11 -#define ANTPLUS_BICYCLEPOWER_CHANNELPERIOD 8182 +#define ANTPLUS_BICYCLEPOWER_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE +#define ANTPLUS_BICYCLEPOWER_SENSOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT +#define ANTPLUS_BICYCLEPOWER_DEVICETYPE 11 +#define ANTPLUS_BICYCLEPOWER_CHANNELPERIOD 8182 // 30 / 2.5 = 12 -#define ANTPLUS_BICYCLEPOWER_SEARCHTIMEOUT 12 +#define ANTPLUS_BICYCLEPOWER_SEARCHTIMEOUT 12 /* Fixed Bytes */ -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_BYTE 0 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_UPDATEEVENTCOUNT_BYTE 1 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_BYTE 0 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_UPDATEEVENTCOUNT_BYTE 1 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_GENERALCALIBRATION_NUMBER 0x01 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_GENERALCALIBRATION_NUMBER 0x01 /* Power Only Main Data Page */ /* DataPage for Power Only, CTF does not need to support. * Note: Currently not writing any of this with CTF in mind. @@ -36,32 +36,32 @@ #define ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDWHEELTORQUE_NUMBER 0x11 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELTICKS_WHEELTORQUE_BYTE 2 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_WHEELTORQUE_BYTE 3 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELPERIODLSB_WHEELTORQUE_BYTE 4 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELPERIODMSB_WHEELTORQUE_BYTE 5 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUELSB_WHEELTORQUE_BYTE 6 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUEMSB_WHEELTORQUE_BYTE 7 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELTICKS_WHEELTORQUE_BYTE 2 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_WHEELTORQUE_BYTE 3 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELPERIODLSB_WHEELTORQUE_BYTE 4 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELPERIODMSB_WHEELTORQUE_BYTE 5 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUELSB_WHEELTORQUE_BYTE 6 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUEMSB_WHEELTORQUE_BYTE 7 /* Standard Crank Torque Main Data Page */ #define ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDCRANKTORQUE_NUMBER 0x12 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKTICKS_CRANKTORQUE_BYTE 2 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_CRANKTORQUE_BYTE 3 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKPERIODLSB_CRANKTORQUE_BYTE 4 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKPERIODMSB_CRANKTORQUE_BYTE 5 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUELSB_CRANKTORQUE_BYTE 6 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUEMSB_CRANKTORQUE_BYTE 7 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKTICKS_CRANKTORQUE_BYTE 2 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_CRANKTORQUE_BYTE 3 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKPERIODLSB_CRANKTORQUE_BYTE 4 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKPERIODMSB_CRANKTORQUE_BYTE 5 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUELSB_CRANKTORQUE_BYTE 6 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUEMSB_CRANKTORQUE_BYTE 7 /* Pedal Smoothness Main Data Page */ #define ANTPLUS_BICYCLEPOWER_DATAPAGE_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER 0x13 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_LEFTEFFECTIVENESS_PEDALSMOOTHNESS_BYTE 2 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_RIGHTEFFECTIVENESS_PEDALSMOOTHNESS_BYTE 3 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_LEFTSMOOTHNESS_PEDALSMOOTHNESS_BYTE 4 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_RIGHTSMOOTHNESS_PEDALSMOOTHNESS_BYTE 5 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_LEFTEFFECTIVENESS_PEDALSMOOTHNESS_BYTE 2 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_RIGHTEFFECTIVENESS_PEDALSMOOTHNESS_BYTE 3 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_LEFTSMOOTHNESS_PEDALSMOOTHNESS_BYTE 4 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_RIGHTSMOOTHNESS_PEDALSMOOTHNESS_BYTE 5 #define ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKTORQUEFREQUENCY_NUMBER 0x20 /* Crank Torque Frequency Main Data Page @@ -73,51 +73,51 @@ Not implemented. */ /* -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_CTF_NUMBER 0x20 // New - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_SLOPEMSB_CTF_BYTE 2 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_SLOPELSB_CTF_BYTE 3 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TIMESTAMPMSB_CTF_BYTE 4 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TIMESTAMPLSB_CTF_BYTE 5 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TORQUETICKSTAMPMSB_CTF_BYTE 6 // New -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TORQUETICKSTAMPLSB_CTF_BYTE 7 // New +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_CTF_NUMBER 0x20 + +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_SLOPEMSB_CTF_BYTE 2 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_SLOPELSB_CTF_BYTE 3 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TIMESTAMPMSB_CTF_BYTE 4 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TIMESTAMPLSB_CTF_BYTE 5 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TORQUETICKSTAMPMSB_CTF_BYTE 6 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TORQUETICKSTAMPLSB_CTF_BYTE 7 */ /* Manufacturer Information */ -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_NUMBER 0x50 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_NUMBER 0x50 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_HARDWAREVERSION_BYTE 3 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MANUFACTURERIDLSB_BYTE 4 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MANUFACTURERIDMSB_BYTE 5 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MODELNUMBERLSB_BYTE 6 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MODELNUMBERMSB_BYTE 7 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_HARDWAREVERSION_BYTE 3 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MANUFACTURERIDLSB_BYTE 4 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MANUFACTURERIDMSB_BYTE 5 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MODELNUMBERLSB_BYTE 6 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MODELNUMBERMSB_BYTE 7 /* Product Information */ -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_NUMBER 0x51 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_NUMBER 0x51 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SOFTWAREVERSIONSUPP_BYTE 2 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SOFTWAREVERSION_BYTE 3 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SERIALNUMBERLSB_BYTE 4 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SERIALNUMBERMSB_BYTE 7 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SOFTWAREVERSIONSUPP_BYTE 2 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SOFTWAREVERSION_BYTE 3 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SERIALNUMBERLSB_BYTE 4 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SERIALNUMBERMSB_BYTE 7 /* Battery Status */ -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_NUMBER 0x52 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER 52 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_NUMBER 0x52 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER 52 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_IDENTIFIER_BYTE 2 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_IDENTIFIER_BYTE 2 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CUMULATIVEOPERATINGTIME_TIMELSB_BYTE 3 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CUMULATIVEOPERATINGTIME_TIMEMSB_BYTE 5 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE 6 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_BYTE 7 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_BYTE 7 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CUMULATIVEOPERATINGTIME_TIMELSB_BYTE 3 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CUMULATIVEOPERATINGTIME_TIMEMSB_BYTE 5 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE 6 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_BYTE 7 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_BYTE 7 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_MASK 0x0F -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_MASK 0x70 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_MASK 0x0F +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_MASK 0x70 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_SHIFT 4 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_SHIFT 4 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_SHIFT 4 +#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_SHIFT 4 #endif // ANTPLUS_BICYCLEPOWERPROFILEPRIVATEDEFINES_h From ddeaf40cab05c8ab4fc35aeade32b00a91fe16e8 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 11 Jan 2021 23:04:33 -0800 Subject: [PATCH 071/241] shifting: update callbacks Add proxy allbacks for various rtos Also update example types --- examples/ShiftingShifter/ShiftingShifter.ino | 6 +++--- .../Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/ShiftingShifter/ShiftingShifter.ino b/examples/ShiftingShifter/ShiftingShifter.ino index aabdea4..150e4f6 100644 --- a/examples/ShiftingShifter/ShiftingShifter.ino +++ b/examples/ShiftingShifter/ShiftingShifter.ino @@ -16,9 +16,9 @@ const uint8_t NETWORK_KEY[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}; // get this from thisisant.com -AntWithCallbacks ant = AntWithCallbacks(); -AntPlusRouter router = AntPlusRouter(); -ProfileShiftingShifter shift = ProfileShiftingShifter(7370); +ArduinoSerialAntWithCallbacks ant; +AntPlusRouter router; +ProfileShiftingShifter shift(7370); void shiftSystemStatusMsgHandler(ShiftingShiftSystemStatusMsg& msg, uintptr_t data); void multiComponentSystemManufacturersInformationMsgHandler(MultiComponentSystemManufacturersInformationMsg& msg, uintptr_t data); diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h index e2897b5..341a79a 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h @@ -59,11 +59,11 @@ class ProfileShiftingShifter : public BaseMasterProfile { uint8_t _interleaveStep; uint8_t _componentCount = 0; - Callback _createShiftingShiftSystemStatusMsg; - Callback _createMultiComponentSystemManufacturersInformationMsg; - Callback _createMultiComponentSystemProductInformationMsg; - Callback _createBatteryStatusMsg; - Callback _onRequestDataPage; + AntCallback _createShiftingShiftSystemStatusMsg; + AntCallback _createMultiComponentSystemManufacturersInformationMsg; + AntCallback _createMultiComponentSystemProductInformationMsg; + AntCallback _createBatteryStatusMsg; + AntCallback _onRequestDataPage; }; #endif // ANTPLUS_PROFILESHIFTINGSHIFTER_h From 63a6f44b2835b4fec84fdbf1094920c9f827afe6 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 11 Jan 2021 23:26:15 -0800 Subject: [PATCH 072/241] dynamic profiles: fix typo thanks travis --- examples/DynamicProfiles/DynamicProfiles.ino | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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: From cf5b443be898c4e00738143a6f9f66c1e0b0deda Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 11 Jan 2021 23:29:21 -0800 Subject: [PATCH 073/241] travis: uprade python version seems like time to do it --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 959ff1d..fef403f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ language: python python: - - "3.6" + - "3.9" sudo: false cache: From 95d221c7e109c2c0cbf4c49cbbe7ebf34efedbc5 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 12 Jan 2021 00:27:23 -0800 Subject: [PATCH 074/241] FEC: enable display profile its going to be in next release so might as well add it --- src/Profiles/ANTPLUS_Profiles.h | 1 + src/Profiles/FEC/ANTPLUS_FECProfile.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Profiles/ANTPLUS_Profiles.h b/src/Profiles/ANTPLUS_Profiles.h index 1eee463..f9b0506 100644 --- a/src/Profiles/ANTPLUS_Profiles.h +++ b/src/Profiles/ANTPLUS_Profiles.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include diff --git a/src/Profiles/FEC/ANTPLUS_FECProfile.h b/src/Profiles/FEC/ANTPLUS_FECProfile.h index 995e37a..58ac1e1 100644 --- a/src/Profiles/FEC/ANTPLUS_FECProfile.h +++ b/src/Profiles/FEC/ANTPLUS_FECProfile.h @@ -9,6 +9,6 @@ // Profile Classes #include -#include +// #include #endif // ANTPLUS_FECPROFILE_h From 60c4d8c6e9ec92f6ccb8c45f914f9e8bf1543296 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 10 Jan 2021 12:04:18 -0800 Subject: [PATCH 075/241] power: switch battery status to common data page use common code to reduce size, also remove cumulative operating datapage as it looks like a potentional mistake. There is no datapge 52 and batterystatus is 0x52 which has a cumulative opertating time field. --- .../BicyclePowerDisplay.ino | 25 ++++++---------- .../ANTPLUS_BicyclePowerDefines.h | 7 ----- .../ANTPLUS_BicyclePowerPrivateDefines.h | 19 ------------ .../ANTPLUS_ProfileBicyclePowerDataPages.h | 2 -- .../ANTPLUS_BicyclePowerBaseBatteryStatus.cpp | 30 ------------------- .../ANTPLUS_BicyclePowerBaseBatteryStatus.h | 17 ----------- ...icyclePowerBaseCumulativeOperatingTime.cpp | 16 ---------- ..._BicyclePowerBaseCumulativeOperatingTime.h | 15 ---------- .../RX/ANTPLUS_BicyclePowerBatteryStatus.cpp | 5 ---- .../RX/ANTPLUS_BicyclePowerBatteryStatus.h | 12 -------- ...US_BicyclePowerCumulativeOperatingTime.cpp | 4 --- ...PLUS_BicyclePowerCumulativeOperatingTime.h | 12 -------- .../ANTPLUS_ProfileBicyclePowerDisplay.cpp | 11 ++----- .../ANTPLUS_ProfileBicyclePowerDisplay.h | 7 ++--- 14 files changed, 14 insertions(+), 168 deletions(-) delete mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseBatteryStatus.cpp delete mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseBatteryStatus.h delete mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCumulativeOperatingTime.cpp delete mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCumulativeOperatingTime.h delete mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerBatteryStatus.cpp delete mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerBatteryStatus.h delete mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCumulativeOperatingTime.cpp delete mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCumulativeOperatingTime.h diff --git a/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino index 5dc0a1f..aa603e5 100644 --- a/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino +++ b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino @@ -36,8 +36,7 @@ AntPlusRouter router; ProfileBicyclePowerDisplay bikePower; void bicyclePowerBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data); -void batteryStatusDataPageHandler(BicyclePowerBatteryStatus& msg, uintptr_t data); -void cumulativeOperatingTimeDataPageHandler(BicyclePowerCumulativeOperatingTime& msg, uintptr_t data); +void batteryStatusDataPageHandler(BatteryStatus& msg, uintptr_t data); void manufacturerIDDataPageHandler(BicyclePowerManufacturerID& msg, uintptr_t data); void productIDDataPageHandler(BicyclePowerProductID& msg, uintptr_t data); void powerOnlyDataPageHandler(BicyclePowerStandardPowerOnly& msg, uintptr_t data); @@ -77,8 +76,7 @@ void setup() { Serial.begin(BAUD_RATE); Serial.println("Running"); bikePower.onDataPage(bicyclePowerBaseDataPageHandler); - bikePower.onBicyclePowerBatteryStatus(batteryStatusDataPageHandler); - bikePower.onBicyclePowerCumulativeOperatingTime(cumulativeOperatingTimeDataPageHandler); + bikePower.onBatteryStatus(batteryStatusDataPageHandler); bikePower.onBicyclePowerManufacturerID(manufacturerIDDataPageHandler); bikePower.onBicyclePowerProductID(productIDDataPageHandler); bikePower.onBicyclePowerStandardPowerOnly(powerOnlyDataPageHandler); @@ -101,18 +99,13 @@ void loop() { router.loop(); } -void batteryStatusDataPageHandler(BicyclePowerBatteryStatus& msg, uintptr_t data) { +void batteryStatusDataPageHandler(BatteryStatus& msg, uintptr_t data) { Serial.print("Fractional Battery Voltage: "); Serial.println(msg.getFractionalBatteryVoltage()); Serial.print("Battery Status: "); bicyclePowerBatteryStatus(msg.getBatteryStatus()); } -void cumulativeOperatingTimeDataPageHandler(BicyclePowerCumulativeOperatingTime& msg, uintptr_t data) { - Serial.print("Cumulative Operating Time: "); - Serial.println(msg.getCumulativeOperatingTime()); -} - void manufacturerIDDataPageHandler(BicyclePowerManufacturerID& msg, uintptr_t data) { Serial.print("Hardware ID: "); Serial.println(msg.getHardwareVersion()); @@ -204,22 +197,22 @@ void printStatus(uint8_t status) { void bicyclePowerBatteryStatus(uint8_t flags) { switch (flags) { - case ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_NEW: + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_NEW: Serial.println("New"); break; - case ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_GOOD: + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_GOOD: Serial.println("Good"); break; - case ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_OK: + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_OK: Serial.println("Ok"); break; - case ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_LOW: + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_LOW: Serial.println("Low"); break; - case ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_CRITICAL: + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_CRITICAL: Serial.println("Critical"); break; - case ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_INVALID: + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_INVALID: Serial.println("Invalid"); break; default: diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h index 76eeffc..8fe74ed 100644 --- a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h @@ -3,11 +3,4 @@ #define ANTPLUS_BICYCLEPOWER_DEVICETYPE 11 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_NEW 1 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_GOOD 2 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_OK 3 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_LOW 4 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_CRITICAL 5 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_INVALID 7 - #endif // ANTPLUS_BICYCLEPOWERPROFILEDEFINES_h diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h index 802377a..a116862 100644 --- a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h @@ -101,23 +101,4 @@ Not implemented. #define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SERIALNUMBERLSB_BYTE 4 #define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SERIALNUMBERMSB_BYTE 7 -/* Battery Status */ -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_NUMBER 0x52 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER 52 - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_IDENTIFIER_BYTE 2 - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CUMULATIVEOPERATINGTIME_TIMELSB_BYTE 3 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CUMULATIVEOPERATINGTIME_TIMEMSB_BYTE 5 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE 6 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_BYTE 7 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_BYTE 7 - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_MASK 0x0F -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_MASK 0x70 - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_SHIFT 4 - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_SHIFT 4 - #endif // ANTPLUS_BICYCLEPOWERPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h index 2af3a09..77c82fd 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h @@ -2,8 +2,6 @@ #define ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h /* RX */ -#include -#include #include #include #include diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseBatteryStatus.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseBatteryStatus.cpp deleted file mode 100644 index 6f253a4..0000000 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseBatteryStatus.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -template -BicyclePowerBaseBatteryStatus::BicyclePowerBaseBatteryStatus() : CoreDataPage() { -} - -template -uint8_t BicyclePowerBaseBatteryStatus::getFractionalBatteryVoltage() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE); -} - -template -uint8_t BicyclePowerBaseBatteryStatus::getCoarseBatteryVoltage() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_BYTE, - ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_MASK); -} - -template -uint8_t BicyclePowerBaseBatteryStatus::getBatteryStatus() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_BYTE, - ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_MASK, - ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_SHIFT); -} - -template class BicyclePowerBaseBatteryStatus; -template class BicyclePowerBaseBatteryStatus; diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseBatteryStatus.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseBatteryStatus.h deleted file mode 100644 index a613b22..0000000 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseBatteryStatus.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef ANTPLUS_BICYCLEPOWERBASEBATTERYSTATUS_h -#define ANTPLUS_BICYCLEPOWERBASEBATTERYSTATUS_h - -#include - -#include "ANT.h" - -template -class BicyclePowerBaseBatteryStatus : virtual public CoreDataPage { -public: - BicyclePowerBaseBatteryStatus(); - uint8_t getFractionalBatteryVoltage(); - uint8_t getCoarseBatteryVoltage(); - uint8_t getBatteryStatus(); -}; - -#endif // ANTPLUS_BICYCLEPOWERBASEBATTERYSTATUS_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCumulativeOperatingTime.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCumulativeOperatingTime.cpp deleted file mode 100644 index 4185ef1..0000000 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCumulativeOperatingTime.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -template -BicyclePowerBaseCumulativeOperatingTime::BicyclePowerBaseCumulativeOperatingTime() : CoreDataPage() { -} - -template -uint32_t BicyclePowerBaseCumulativeOperatingTime::getCumulativeOperatingTime() { - return this->get24BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_CUMULATIVEOPERATINGTIME_TIMELSB_BYTE, - ANTPLUS_BICYCLEPOWER_DATAPAGE_CUMULATIVEOPERATINGTIME_TIMEMSB_BYTE); -} - -template class BicyclePowerBaseCumulativeOperatingTime; -template class BicyclePowerBaseCumulativeOperatingTime; diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCumulativeOperatingTime.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCumulativeOperatingTime.h deleted file mode 100644 index 42d0b91..0000000 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseCumulativeOperatingTime.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef ANTPLUS_BICYCLEPOWERBASECUMULITIVEOPERATINGTIME_h -#define ANTPLUS_BICYCLEPOWERBASECUMULITIVEOPERATINGTIME_h - -#include - -#include "ANT.h" - -template -class BicyclePowerBaseCumulativeOperatingTime : virtual public CoreDataPage { -public: - BicyclePowerBaseCumulativeOperatingTime(); - uint32_t getCumulativeOperatingTime(); // only 24 bits -}; - -#endif // ANTPLUS_BICYCLEPOWERBASECUMULITIVEOPERATINGTIME_h diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerBatteryStatus.cpp b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerBatteryStatus.cpp deleted file mode 100644 index 6c29d8b..0000000 --- a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerBatteryStatus.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -BicyclePowerBatteryStatus::BicyclePowerBatteryStatus(AntRxDataResponse& dp) : BicyclePowerBaseMainDataPage(dp), BicyclePowerBaseBatteryStatus() { - -} diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerBatteryStatus.h b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerBatteryStatus.h deleted file mode 100644 index 7ecc994..0000000 --- a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerBatteryStatus.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_BICYCLEPOWERBATTERYSTATUS_h -#define ANTPLUS_BICYCLEPOWERBATTERYSTATUS_h - -#include -#include - -class BicyclePowerBatteryStatus : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseBatteryStatus { -public: - BicyclePowerBatteryStatus(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_BICYCLEPOWERBATTERYSTATUS_h diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCumulativeOperatingTime.cpp b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCumulativeOperatingTime.cpp deleted file mode 100644 index f708fd1..0000000 --- a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCumulativeOperatingTime.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include - -BicyclePowerCumulativeOperatingTime::BicyclePowerCumulativeOperatingTime(AntRxDataResponse& dp) : BicyclePowerBaseMainDataPage(dp) { -} diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCumulativeOperatingTime.h b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCumulativeOperatingTime.h deleted file mode 100644 index 98b3584..0000000 --- a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerCumulativeOperatingTime.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_BICYCLEPOWERCUMULATIVEOPERATINGTIME_h -#define ANTPLUS_BICYCLEPOWERCUMUATIVEOPERATINGTIME_h - -#include -#include - -class BicyclePowerCumulativeOperatingTime : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseCumulativeOperatingTime { -public: - BicyclePowerCumulativeOperatingTime(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_BICYCLEPOWERCUMULITIVEOPERATINGTIME_h diff --git a/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.cpp b/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.cpp index db38263..461488a 100644 --- a/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.cpp +++ b/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.cpp @@ -34,7 +34,7 @@ bool ProfileBicyclePowerDisplay::handleDataPage(BicyclePowerBaseMainDataPage& dp case ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_NUMBER: called = handleProductID(dp); break; - case ANTPLUS_BICYCLEPOWER_DATAPAGE_BATTERYSTATUS_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER: called = handleBatteryStatus(dp); break; case ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_NUMBER: @@ -71,13 +71,8 @@ void ProfileBicyclePowerDisplay::setChannelConfig() { } bool ProfileBicyclePowerDisplay::handleBatteryStatus(BicyclePowerBaseMainDataPage& dataPage) { - BicyclePowerBatteryStatus dp = BicyclePowerBatteryStatus(dataPage); - return _onBicyclePowerBatteryStatus.call(dp); -} - -bool ProfileBicyclePowerDisplay::handleCumulativeOperatingTime(BicyclePowerBaseMainDataPage& dataPage) { - BicyclePowerCumulativeOperatingTime dp(dataPage); - return _onBicyclePowerCumulativeOperatingTime.call(dp); + BatteryStatus dp(dataPage); + return _onBatteryStatus.call(dp); } bool ProfileBicyclePowerDisplay::handleManufacturerID(BicyclePowerBaseMainDataPage& dataPage) { diff --git a/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h b/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h index 1127a76..267682d 100644 --- a/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h +++ b/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h @@ -12,8 +12,7 @@ class ProfileBicyclePowerDisplay : public BaseSlaveProfile { ProfileBicyclePowerDisplay(); ProfileBicyclePowerDisplay(uint16_t deviceNumber); ProfileBicyclePowerDisplay(uint16_t deviceNumber, uint8_t transmissionType); - void onBicyclePowerBatteryStatus(void (*func)(BicyclePowerBatteryStatus&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerBatteryStatus.set(func, data); } - void onBicyclePowerCumulativeOperatingTime(void (*func)(BicyclePowerCumulativeOperatingTime&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerCumulativeOperatingTime.set(func, data); } + void onBatteryStatus(void (*func)(BatteryStatus&, uintptr_t), uintptr_t data = 0) { _onBatteryStatus.set(func, data); } void onBicyclePowerManufacturerID(void (*func)(BicyclePowerManufacturerID&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerManufacturerID.set(func, data); } void onBicyclePowerProductID(void (*func)(BicyclePowerProductID&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerProductID.set(func, data); } void onBicyclePowerStandardPowerOnly(void (*func)(BicyclePowerStandardPowerOnly&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerStandardPowerOnly.set(func, data); } @@ -29,15 +28,13 @@ class ProfileBicyclePowerDisplay : public BaseSlaveProfile { bool handleDataPage(BicyclePowerBaseMainDataPage& dp); bool handleBatteryStatus(BicyclePowerBaseMainDataPage& dataPage); - bool handleCumulativeOperatingTime(BicyclePowerBaseMainDataPage& dataPage); bool handleManufacturerID(BicyclePowerBaseMainDataPage& dataPage); bool handleProductID(BicyclePowerBaseMainDataPage& dataPage); bool handleStandardPowerOnly(BicyclePowerBaseMainDataPage& dataPage); bool handleStandardCrankTorque(BicyclePowerBaseMainDataPage& dataPage); bool handleStandardWheelTorque(BicyclePowerBaseMainDataPage& dataPage); bool handleTorqueEffectivenessAndPedalSmoothness(BicyclePowerBaseMainDataPage& dataPage); - AntCallback _onBicyclePowerBatteryStatus; - AntCallback _onBicyclePowerCumulativeOperatingTime; + AntCallback _onBatteryStatus; AntCallback _onBicyclePowerManufacturerID; AntCallback _onBicyclePowerProductID; AntCallback _onBicyclePowerStandardPowerOnly; From 6c978938a266fae2e94b1911b6d4f63aebfdeb64 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 12 Jan 2021 23:54:34 -0800 Subject: [PATCH 076/241] power: switch to common manufacturersinformatino datapage common code for less lines :) --- .../BicyclePowerDisplay.ino | 10 +++---- .../ANTPLUS_BicyclePowerPrivateDefines.h | 10 ------- .../ANTPLUS_ProfileBicyclePowerDataPages.h | 1 - ...ANTPLUS_BicyclePowerBaseManufacturerID.cpp | 29 ------------------- .../ANTPLUS_BicyclePowerBaseManufacturerID.h | 17 ----------- .../RX/ANTPLUS_BicyclePowerManufacturerID.cpp | 4 --- .../RX/ANTPLUS_BicyclePowerManufacturerID.h | 12 -------- .../ANTPLUS_ProfileBicyclePowerDisplay.cpp | 10 +++---- .../ANTPLUS_ProfileBicyclePowerDisplay.h | 6 ++-- 9 files changed, 13 insertions(+), 86 deletions(-) delete mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseManufacturerID.cpp delete mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseManufacturerID.h delete mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerManufacturerID.cpp delete mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerManufacturerID.h diff --git a/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino index aa603e5..c6ce1d9 100644 --- a/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino +++ b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino @@ -37,7 +37,7 @@ ProfileBicyclePowerDisplay bikePower; void bicyclePowerBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data); void batteryStatusDataPageHandler(BatteryStatus& msg, uintptr_t data); -void manufacturerIDDataPageHandler(BicyclePowerManufacturerID& msg, uintptr_t data); +void manufacturerIDDataPageHandler(ManufacturersInformation& msg, uintptr_t data); void productIDDataPageHandler(BicyclePowerProductID& msg, uintptr_t data); void powerOnlyDataPageHandler(BicyclePowerStandardPowerOnly& msg, uintptr_t data); void crankTorqueDataPageHandler(BicyclePowerStandardCrankTorque& msg, uintptr_t data); @@ -77,7 +77,7 @@ void setup() { Serial.println("Running"); bikePower.onDataPage(bicyclePowerBaseDataPageHandler); bikePower.onBatteryStatus(batteryStatusDataPageHandler); - bikePower.onBicyclePowerManufacturerID(manufacturerIDDataPageHandler); + bikePower.onManufacturersInformation(manufacturerIDDataPageHandler); bikePower.onBicyclePowerProductID(productIDDataPageHandler); bikePower.onBicyclePowerStandardPowerOnly(powerOnlyDataPageHandler); bikePower.onBicyclePowerStandardCrankTorque(crankTorqueDataPageHandler); @@ -106,11 +106,11 @@ void batteryStatusDataPageHandler(BatteryStatus& msg, uintptr_t data) { bicyclePowerBatteryStatus(msg.getBatteryStatus()); } -void manufacturerIDDataPageHandler(BicyclePowerManufacturerID& msg, uintptr_t data) { +void manufacturerIDDataPageHandler(ManufacturersInformation& msg, uintptr_t data) { Serial.print("Hardware ID: "); - Serial.println(msg.getHardwareVersion()); + Serial.println(msg.getHWRevision()); Serial.print("Manufacturer ID: "); - Serial.println(msg.getManufacturerId()); + Serial.println(msg.getManufacturerID()); Serial.print("Model Number: "); Serial.println(msg.getModelNumber()); } diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h index a116862..3079674 100644 --- a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h @@ -83,16 +83,6 @@ Not implemented. #define ANTPLUS_BICYCLEPOWER_DATAPAGE_TORQUETICKSTAMPLSB_CTF_BYTE 7 */ -/* Manufacturer Information */ -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_NUMBER 0x50 - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_HARDWAREVERSION_BYTE 3 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MANUFACTURERIDLSB_BYTE 4 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MANUFACTURERIDMSB_BYTE 5 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MODELNUMBERLSB_BYTE 6 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MODELNUMBERMSB_BYTE 7 - - /* Product Information */ #define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_NUMBER 0x51 diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h index 77c82fd..f3d0ebd 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h @@ -2,7 +2,6 @@ #define ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h /* RX */ -#include #include #include #include diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseManufacturerID.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseManufacturerID.cpp deleted file mode 100644 index 77b2cc9..0000000 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseManufacturerID.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -template -BicyclePowerBaseManufacturerID::BicyclePowerBaseManufacturerID() : CoreDataPage() { -} - -template -uint8_t BicyclePowerBaseManufacturerID::getHardwareVersion() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_HARDWAREVERSION_BYTE); -} - -template -uint16_t BicyclePowerBaseManufacturerID::getManufacturerId() { - return this->get16BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MANUFACTURERIDLSB_BYTE, - ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MANUFACTURERIDMSB_BYTE); -} - -template -uint16_t BicyclePowerBaseManufacturerID::getModelNumber() { - return this->get16BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MODELNUMBERLSB_BYTE, - ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_MODELNUMBERMSB_BYTE); -} - -template class BicyclePowerBaseManufacturerID; -template class BicyclePowerBaseManufacturerID; diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseManufacturerID.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseManufacturerID.h deleted file mode 100644 index 3ad4a08..0000000 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseManufacturerID.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef ANTPLUS_BICYCLEPOWERBASEMANUFACTURERINFORMATION_h -#define ANTPLUS_BICYCLEPOWERBASEMANUFACTURERINFORMATION_h - -#include - -#include "ANT.h" - -template -class BicyclePowerBaseManufacturerID : virtual public CoreDataPage { -public: - BicyclePowerBaseManufacturerID(); - uint8_t getHardwareVersion(); - uint16_t getManufacturerId(); - uint16_t getModelNumber(); -}; - -#endif // ANTPLUS_BICYCLEPOWERBASEMANUFACTURERINFORMATION_h diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerManufacturerID.cpp b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerManufacturerID.cpp deleted file mode 100644 index a816cf7..0000000 --- a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerManufacturerID.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include - -BicyclePowerManufacturerID::BicyclePowerManufacturerID(AntRxDataResponse& dp) : BicyclePowerBaseMainDataPage(dp), BicyclePowerBaseManufacturerID() { -} diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerManufacturerID.h b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerManufacturerID.h deleted file mode 100644 index 173c1f1..0000000 --- a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerManufacturerID.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_BICYCLEPOWERMANUFACTURERID_h -#define ANTPLUS_BICYCLEPOWERMANUFACTURERID_h - -#include -#include - -class BicyclePowerManufacturerID : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseManufacturerID { -public: - BicyclePowerManufacturerID(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_BICYCLEPOWERMANUFACTURERID_h diff --git a/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.cpp b/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.cpp index 461488a..d6e2b13 100644 --- a/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.cpp +++ b/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.cpp @@ -28,8 +28,8 @@ bool ProfileBicyclePowerDisplay::handleDataPage(BicyclePowerBaseMainDataPage& dp bool called = false; switch (dataPage) { - case ANTPLUS_BICYCLEPOWER_DATAPAGE_MANUFACTURERID_NUMBER: - called = handleManufacturerID(dp); + case ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER: + called = handleManufacturersInformation(dp); break; case ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_NUMBER: called = handleProductID(dp); @@ -75,9 +75,9 @@ bool ProfileBicyclePowerDisplay::handleBatteryStatus(BicyclePowerBaseMainDataPag return _onBatteryStatus.call(dp); } -bool ProfileBicyclePowerDisplay::handleManufacturerID(BicyclePowerBaseMainDataPage& dataPage) { - BicyclePowerManufacturerID dp(dataPage); - return _onBicyclePowerManufacturerID.call(dp); +bool ProfileBicyclePowerDisplay::handleManufacturersInformation(BicyclePowerBaseMainDataPage& dataPage) { + ManufacturersInformation dp(dataPage); + return _onManufacturersInformation.call(dp); } bool ProfileBicyclePowerDisplay::handleProductID(BicyclePowerBaseMainDataPage& dataPage) { diff --git a/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h b/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h index 267682d..1c78c55 100644 --- a/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h +++ b/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h @@ -13,7 +13,7 @@ class ProfileBicyclePowerDisplay : public BaseSlaveProfile { ProfileBicyclePowerDisplay(uint16_t deviceNumber); ProfileBicyclePowerDisplay(uint16_t deviceNumber, uint8_t transmissionType); void onBatteryStatus(void (*func)(BatteryStatus&, uintptr_t), uintptr_t data = 0) { _onBatteryStatus.set(func, data); } - void onBicyclePowerManufacturerID(void (*func)(BicyclePowerManufacturerID&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerManufacturerID.set(func, data); } + void onManufacturersInformation(void (*func)(ManufacturersInformation&, uintptr_t), uintptr_t data = 0) { _onManufacturersInformation.set(func, data); } void onBicyclePowerProductID(void (*func)(BicyclePowerProductID&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerProductID.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); } @@ -28,14 +28,14 @@ class ProfileBicyclePowerDisplay : public BaseSlaveProfile { bool handleDataPage(BicyclePowerBaseMainDataPage& dp); bool handleBatteryStatus(BicyclePowerBaseMainDataPage& dataPage); - bool handleManufacturerID(BicyclePowerBaseMainDataPage& dataPage); + bool handleManufacturersInformation(BicyclePowerBaseMainDataPage& dataPage); bool handleProductID(BicyclePowerBaseMainDataPage& dataPage); bool handleStandardPowerOnly(BicyclePowerBaseMainDataPage& dataPage); bool handleStandardCrankTorque(BicyclePowerBaseMainDataPage& dataPage); bool handleStandardWheelTorque(BicyclePowerBaseMainDataPage& dataPage); bool handleTorqueEffectivenessAndPedalSmoothness(BicyclePowerBaseMainDataPage& dataPage); AntCallback _onBatteryStatus; - AntCallback _onBicyclePowerManufacturerID; + AntCallback _onManufacturersInformation; AntCallback _onBicyclePowerProductID; AntCallback _onBicyclePowerStandardPowerOnly; AntCallback _onBicyclePowerStandardCrankTorque; From 3c0da2c95f38819770b751a37bb3bf470a0906d8 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Wed, 13 Jan 2021 00:05:56 -0800 Subject: [PATCH 077/241] power: use common product_id datapage use common datapage and save some code :) --- .../BicyclePowerDisplay.ino | 10 +++---- .../ANTPLUS_BicyclePowerPrivateDefines.h | 8 ------ .../ANTPLUS_ProfileBicyclePowerDataPages.h | 1 - .../ANTPLUS_BicyclePowerBaseProductID.cpp | 28 ------------------- .../Base/ANTPLUS_BicyclePowerBaseProductID.h | 18 ------------ .../RX/ANTPLUS_BicyclePowerProductID.cpp | 4 --- .../RX/ANTPLUS_BicyclePowerProductID.h | 12 -------- .../ANTPLUS_ProfileBicyclePowerDisplay.cpp | 10 +++---- .../ANTPLUS_ProfileBicyclePowerDisplay.h | 6 ++-- 9 files changed, 13 insertions(+), 84 deletions(-) delete mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseProductID.cpp delete mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseProductID.h delete mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerProductID.cpp delete mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerProductID.h diff --git a/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino index c6ce1d9..b27f9d6 100644 --- a/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino +++ b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino @@ -38,7 +38,7 @@ 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(BicyclePowerProductID& 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); @@ -78,7 +78,7 @@ void setup() { bikePower.onDataPage(bicyclePowerBaseDataPageHandler); bikePower.onBatteryStatus(batteryStatusDataPageHandler); bikePower.onManufacturersInformation(manufacturerIDDataPageHandler); - bikePower.onBicyclePowerProductID(productIDDataPageHandler); + bikePower.onProductInformation(productIDDataPageHandler); bikePower.onBicyclePowerStandardPowerOnly(powerOnlyDataPageHandler); bikePower.onBicyclePowerStandardCrankTorque(crankTorqueDataPageHandler); bikePower.onBicyclePowerStandardWheelTorque(wheelTorqueDataPageHandler); @@ -115,11 +115,11 @@ void manufacturerIDDataPageHandler(ManufacturersInformation& msg, uintptr_t data Serial.println(msg.getModelNumber()); } -void productIDDataPageHandler(BicyclePowerProductID& msg, uintptr_t data) { +void productIDDataPageHandler(ProductInformation& msg, uintptr_t data) { Serial.print("Software Version Supplemental: "); - Serial.println(msg.getSoftwareVersionSupplemental()); + Serial.println(msg.getSWRevisionSupplemental()); Serial.print("Software Version: "); - Serial.println(msg.getSoftwareVersion()); + Serial.println(msg.getSWRevisionMain()); Serial.print("Serial Number: "); Serial.println(msg.getSerialNumber()); } diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h index 3079674..a4370b5 100644 --- a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h @@ -83,12 +83,4 @@ Not implemented. #define ANTPLUS_BICYCLEPOWER_DATAPAGE_TORQUETICKSTAMPLSB_CTF_BYTE 7 */ -/* Product Information */ -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_NUMBER 0x51 - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SOFTWAREVERSIONSUPP_BYTE 2 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SOFTWAREVERSION_BYTE 3 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SERIALNUMBERLSB_BYTE 4 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SERIALNUMBERMSB_BYTE 7 - #endif // ANTPLUS_BICYCLEPOWERPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h index f3d0ebd..cd7bf10 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h @@ -2,7 +2,6 @@ #define ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h /* RX */ -#include #include #include #include diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseProductID.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseProductID.cpp deleted file mode 100644 index 543f9bc..0000000 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseProductID.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include - -template -BicyclePowerBaseProductID::BicyclePowerBaseProductID() : CoreDataPage() { -} - -template -uint8_t BicyclePowerBaseProductID::getSoftwareVersionSupplemental() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SOFTWAREVERSIONSUPP_BYTE); -} - -template -uint8_t BicyclePowerBaseProductID::getSoftwareVersion() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SOFTWAREVERSION_BYTE); -} - -template -uint32_t BicyclePowerBaseProductID::getSerialNumber() { - return this->get32BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SERIALNUMBERLSB_BYTE, - ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_SERIALNUMBERMSB_BYTE); -} - -template class BicyclePowerBaseProductID; -template class BicyclePowerBaseProductID; diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseProductID.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseProductID.h deleted file mode 100644 index 7d62bab..0000000 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseProductID.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef ANTPLUS_BICYCLEPOWERBASEPRODUCTID_h -#define ANTPLUS_BICYCLEPOWERBASEPRODUCTID_h - -#include - -#include "ANT.h" - -template -class BicyclePowerBaseProductID : virtual public CoreDataPage { -public: - BicyclePowerBaseProductID(); - uint8_t getSoftwareVersionSupplemental(); - uint8_t getSoftwareVersion(); - uint8_t getModelNumber(); - uint32_t getSerialNumber(); -}; - -#endif // ANTPLUS_BICYCLEPOWERBASEPRODUCTIONINFORMATION_h diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerProductID.cpp b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerProductID.cpp deleted file mode 100644 index a51df55..0000000 --- a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerProductID.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include - -BicyclePowerProductID::BicyclePowerProductID(AntRxDataResponse& dp) : BicyclePowerBaseMainDataPage(dp), BicyclePowerBaseProductID() { -} diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerProductID.h b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerProductID.h deleted file mode 100644 index 86c9ee6..0000000 --- a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerProductID.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_BICYCLEPOWERPRODUCTIONID_h -#define ANTPLUS_BICYCLEPOWERPRODUCTIONID_h - -#include -#include - -class BicyclePowerProductID : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseProductID { -public: - BicyclePowerProductID(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_BICYCLEPOWERPRODUCTIONID_h diff --git a/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.cpp b/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.cpp index d6e2b13..e190f09 100644 --- a/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.cpp +++ b/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.cpp @@ -31,8 +31,8 @@ bool ProfileBicyclePowerDisplay::handleDataPage(BicyclePowerBaseMainDataPage& dp case ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER: called = handleManufacturersInformation(dp); break; - case ANTPLUS_BICYCLEPOWER_DATAPAGE_PRODUCTID_NUMBER: - called = handleProductID(dp); + case ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER: + called = handleProductInformation(dp); break; case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER: called = handleBatteryStatus(dp); @@ -80,9 +80,9 @@ bool ProfileBicyclePowerDisplay::handleManufacturersInformation(BicyclePowerBase return _onManufacturersInformation.call(dp); } -bool ProfileBicyclePowerDisplay::handleProductID(BicyclePowerBaseMainDataPage& dataPage) { - BicyclePowerProductID dp(dataPage); - return _onBicyclePowerProductID.call(dp); +bool ProfileBicyclePowerDisplay::handleProductInformation(BicyclePowerBaseMainDataPage& dataPage) { + ProductInformation dp(dataPage); + return _onProductInformation.call(dp); } bool ProfileBicyclePowerDisplay::handleStandardPowerOnly(BicyclePowerBaseMainDataPage& dataPage) { diff --git a/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h b/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h index 1c78c55..7beee96 100644 --- a/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h +++ b/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h @@ -14,7 +14,7 @@ class ProfileBicyclePowerDisplay : public BaseSlaveProfile { ProfileBicyclePowerDisplay(uint16_t deviceNumber, uint8_t transmissionType); 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 onBicyclePowerProductID(void (*func)(BicyclePowerProductID&, uintptr_t), uintptr_t data = 0) { _onBicyclePowerProductID.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); } @@ -29,14 +29,14 @@ class ProfileBicyclePowerDisplay : public BaseSlaveProfile { bool handleBatteryStatus(BicyclePowerBaseMainDataPage& dataPage); bool handleManufacturersInformation(BicyclePowerBaseMainDataPage& dataPage); - bool handleProductID(BicyclePowerBaseMainDataPage& dataPage); + bool handleProductInformation(BicyclePowerBaseMainDataPage& dataPage); bool handleStandardPowerOnly(BicyclePowerBaseMainDataPage& dataPage); bool handleStandardCrankTorque(BicyclePowerBaseMainDataPage& dataPage); bool handleStandardWheelTorque(BicyclePowerBaseMainDataPage& dataPage); bool handleTorqueEffectivenessAndPedalSmoothness(BicyclePowerBaseMainDataPage& dataPage); AntCallback _onBatteryStatus; AntCallback _onManufacturersInformation; - AntCallback _onBicyclePowerProductID; + AntCallback _onProductInformation; AntCallback _onBicyclePowerStandardPowerOnly; AntCallback _onBicyclePowerStandardCrankTorque; AntCallback _onBicyclePowerStandardWheelTorque; From bf560e6dc619f41000a353e3c58e3551e13c13df Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Wed, 13 Jan 2021 00:44:38 -0800 Subject: [PATCH 078/241] moxy: add muscle oxygen data message --- ...TPLUS_MuscleOxygenBaseMuscleOxygenData.cpp | 36 +++++++++++++++++++ ...ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h | 18 ++++++++++ ...NTPLUS_MuscleOxygenMuscleOxygenDataMsg.cpp | 1 + .../ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.h | 1 - 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.cpp b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.cpp index e69de29..1921d1d 100644 --- a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.cpp +++ b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.cpp @@ -0,0 +1,36 @@ +#include + +// TODO Magic numbers +template +MuscleOxygenBaseMuscleOxygenData::MuscleOxygenBaseMuscleOxygenData() { +} + +template +uint8_t MuscleOxygenBaseMuscleOxygenData::getEventCount() { + return this->get8BitValue(1); +} + +template +uint8_t MuscleOxygenBaseMuscleOxygenData::getNotifications() { + return this->get8BitValue(2); +} + +template +uint8_t MuscleOxygenBaseMuscleOxygenData::getCapabilities() { + return this->get8BitValue(3); +} + +template +uint16_t MuscleOxygenBaseMuscleOxygenData::getTotalHemoglobinConcentration() { + return this->get16BitValue(4, 5, 0x0FFF); +} + +template +uint16_t MuscleOxygenBaseMuscleOxygenData::getPreviousSaturatedHemoglobinPercentage() { + return this->get16BitValue(5, 6, 0x3FF0, 4); +} + +template +uint16_t MuscleOxygenBaseMuscleOxygenData::getCurrentSaturatedHemoglobinPercentage() { + return this->get16BitValue(6, 7, 0xFFC0, 6); +} diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h index e69de29..decf9e9 100644 --- a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h +++ b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h @@ -0,0 +1,18 @@ +#ifndef ANTPLUS_MUSCLEOXYGENBASEMUSCLEOXYGENDATA_h +#define ANTPLUS_MUSCLEOXYGENBASEMUSCLEOXYGENDATA_h + +#include + +template +class MuscleOxygenBaseMuscleOxygenData : public virtual CoreDataPage { +public: + MuscleOxygenBaseMuscleOxygenData(); + uint8_t getEventCount(); + uint8_t getNotifications(); + uint8_t getCapabilities(); + uint16_t getTotalHemoglobinConcentration(); + uint16_t getPreviousSaturatedHemoglobinPercentage(); + uint16_t getCurrentSaturatedHemoglobinPercentage(); +}; + +#endif // ANTPLUS_MUSCLEOXYGENBASEMUSCLEOXYGENDATA_h diff --git a/src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.cpp b/src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.cpp index ca7f02c..8a3e041 100644 --- a/src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.cpp +++ b/src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.cpp @@ -2,6 +2,7 @@ #include +// TODO magic numbers MuscleOxygenMuscleOxygenDataMsg::MuscleOxygenMuscleOxygenDataMsg() : MuscleOxygenBaseMainDataPageMsg(0) { setTotalHemoglobinConcentration(0xFFF); setPreviousSaturatedHemoglobinPercentage(0x3FF); diff --git a/src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.h b/src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.h index 9bc43c2..7ce3261 100644 --- a/src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.h +++ b/src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.h @@ -8,7 +8,6 @@ class MuscleOxygenMuscleOxygenDataMsg : public MuscleOxygenBaseMainDataPageMsg { public: MuscleOxygenMuscleOxygenDataMsg(); - void setEventCount(uint8_t n); void setNotifications(uint8_t notficications); void setCapabilities(uint8_t capabilities); From b8960b4702d7ccfffb71e2cff64db42899d8b8ba Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Wed, 13 Jan 2021 00:45:34 -0800 Subject: [PATCH 079/241] moxy: fixup transmission pattern push code more towards final state machine design --- .../ANTPLUS_ProfileMuscleOxygenMonitor.cpp | 17 ++++++++------ .../ANTPLUS_ProfileMuscleOxygenMonitor.h | 23 ++++++++++--------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp index 7ed6ce3..5ef8a61 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp @@ -5,7 +5,7 @@ ProfileMuscleOxygenMonitor::ProfileMuscleOxygenMonitor( uint16_t deviceNumber, uint8_t transmissionType) : BaseMasterProfile(deviceNumber, transmissionType), _patternStep(0), - _toggle(0) + _backgroundStep(0) { setChannelConfig(); } @@ -31,7 +31,7 @@ void ProfileMuscleOxygenMonitor::transmitNextDataPage() { transmitMuscleOxygenMainPageMsg(); } else { - if (_toggle++ % 2 == 0) { + if (_backgroundStep++ % 2 == 0) { transmitMuscleOxygenManufacturerInformationMsg(); } else { @@ -41,20 +41,23 @@ void ProfileMuscleOxygenMonitor::transmitNextDataPage() { } } -void ProfileMuscleOxygenMonitor::transmitMuscleOxygenManufacturerInformationMsg() { +void ProfileMuscleOxygenMonitor::transmitManufacturerInformationMsg() { ManufacturersInformationMsg msg; - _createMuscleOxygenManufacturerInformationMsg.call(msg); + _createManufacturerInformationMsg.call(msg); send(msg); } -void ProfileMuscleOxygenMonitor::transmitMuscleOxygenProductInformationMsg() { +void ProfileMuscleOxygenMonitor::transmitProductInformationMsg() { ProductInformationMsg msg; - _createMuscleOxygenProductInformationMsg.call(msg); + _createProductInformationMsg.call(msg); send(msg); } -void ProfileMuscleOxygenMonitor::transmitMuscleOxygenMainPageMsg() { +void ProfileMuscleOxygenMonitor::transmitMuscleOxygenMuscleOxygenDataMsg() { MuscleOxygenMuscleOxygenDataMsg msg; _createMuscleOxygenMuscleOxygenDataMsg.call(msg); send(msg); } + +void ProfileMuscleOxygenMonitor::transmitBatteryStatusMsg() { +} diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h index 4d375f7..6fbe9a3 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h @@ -17,29 +17,30 @@ class ProfileMuscleOxygenMonitor : public BaseMasterProfile { /** * Register callback to populate manufacturer information data messages (Datapage 2) */ - void createMuscleOxygenManufacturerInformationMsg(void(*func)(ManufacturersInformationMsg&, uintptr_t), uintptr_t data = 0) { _createMuscleOxygenManufacturerInformationMsg.set(func, data); } + void createMuscleOxygenManufacturerInformationMsg(void(*func)(ManufacturersInformationMsg&, uintptr_t), uintptr_t data = 0) { _createManufacturersInformationMsg.set(func, data); } /** * Register callback to populate product information data messages (Datapage 3) */ - void createMuscleOxygenProductInformationMsg(void(*func)(ProductInformationMsg&, uintptr_t), uintptr_t data = 0) { _createMuscleOxygenProductInformationMsg.set(func, data); } + void createMuscleOxygenProductInformationMsg(void(*func)(ProductInformationMsg&, uintptr_t), uintptr_t data = 0) { _createProductInformationMsg.set(func, data); } protected: - virtual void transmitNextDataPage(); - virtual bool isDataPageValid(uint8_t dataPage); - - void transmitMuscleOxygenManufacturerInformationMsg(); - void transmitMuscleOxygenProductInformationMsg(); + void transmitNextDataPage(); + bool isDataPageValid(uint8_t dataPage); private: void setChannelConfig(); - void transmitMuscleOxygenMainPageMsg(); + void transmitMuscleOxygenMuscleOxygenDataMsg(); + void transmitManufacturerInformationMsg(); + void transmitProductInformationMsg(); + void transmitBatteryStatusMsg(); uint8_t _patternStep; - uint8_t _toggle; + uint8_t _backgroundStep; Callback _createMuscleOxygenMuscleOxygenDataMsg; - Callback _createMuscleOxygenManufacturerInformationMsg; - Callback _createMuscleOxygenProductInformationMsg; + Callback _createManufacturersInformationMsg; + Callback _createProductInformationMsg; + Callback _createBatteryStatusMsg; }; #endif // ANTPLUS_PROFILEMUSCLEOXYGENMONITOR_h From cd54786a2471995d1c38e0a933df41c220e2d002 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Wed, 13 Jan 2021 00:46:37 -0800 Subject: [PATCH 080/241] moxy: update callbacks for new driver arch --- .../Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h index 6fbe9a3..4c857a0 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h @@ -37,10 +37,10 @@ class ProfileMuscleOxygenMonitor : public BaseMasterProfile { uint8_t _patternStep; uint8_t _backgroundStep; - Callback _createMuscleOxygenMuscleOxygenDataMsg; - Callback _createManufacturersInformationMsg; - Callback _createProductInformationMsg; - Callback _createBatteryStatusMsg; + AntCallback _createMuscleOxygenMuscleOxygenDataMsg; + AntCallback _createManufacturersInformationMsg; + AntCallback _createProductInformationMsg; + AntCallback _createBatteryStatusMsg; }; #endif // ANTPLUS_PROFILEMUSCLEOXYGENMONITOR_h From c2de1f838812ecf055e6d4bcbe23e9a9fe0278ac Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Wed, 13 Jan 2021 01:12:47 -0800 Subject: [PATCH 081/241] moxy: fix header path error thanks travis --- .../DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h index decf9e9..5bab111 100644 --- a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h +++ b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h @@ -1,7 +1,7 @@ #ifndef ANTPLUS_MUSCLEOXYGENBASEMUSCLEOXYGENDATA_h #define ANTPLUS_MUSCLEOXYGENBASEMUSCLEOXYGENDATA_h -#include +#include template class MuscleOxygenBaseMuscleOxygenData : public virtual CoreDataPage { From 54c5ec5dbb92520533a0827f228422111122a087 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Wed, 13 Jan 2021 08:40:06 -0800 Subject: [PATCH 082/241] moxy: fix header include for oxygend data --- .../DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h index 5bab111..5c2e890 100644 --- a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h +++ b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h @@ -1,7 +1,7 @@ #ifndef ANTPLUS_MUSCLEOXYGENBASEMUSCLEOXYGENDATA_h #define ANTPLUS_MUSCLEOXYGENBASEMUSCLEOXYGENDATA_h -#include +#include template class MuscleOxygenBaseMuscleOxygenData : public virtual CoreDataPage { From bf963def4cb915c8c4d52ad6a760aca42ae07bfe Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Wed, 13 Jan 2021 08:50:32 -0800 Subject: [PATCH 083/241] moxy: fix datapage calls random name mismatches, this is what i get for merging a wip without compile testing --- .../Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp index 5ef8a61..bac2a6e 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp @@ -28,14 +28,14 @@ bool ProfileMuscleOxygenMonitor::isDataPageValid(uint8_t dataPage) { void ProfileMuscleOxygenMonitor::transmitNextDataPage() { if (_patternStep++ < 64) { - transmitMuscleOxygenMainPageMsg(); + transmitMuscleOxygenMuscleOxygenDataMsg(); } else { if (_backgroundStep++ % 2 == 0) { - transmitMuscleOxygenManufacturerInformationMsg(); + transmitManufacturerInformationMsg(); } else { - transmitMuscleOxygenProductInformationMsg(); + transmitProductInformationMsg(); } _patternStep = 0; } @@ -43,7 +43,7 @@ void ProfileMuscleOxygenMonitor::transmitNextDataPage() { void ProfileMuscleOxygenMonitor::transmitManufacturerInformationMsg() { ManufacturersInformationMsg msg; - _createManufacturerInformationMsg.call(msg); + _createManufacturersInformationMsg.call(msg); send(msg); } From 900b225e74041ce2a9b3ec1656d6db51543e7788 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Wed, 13 Jan 2021 11:16:27 -0800 Subject: [PATCH 084/241] moxy: fixup monitor example with new ant-arduino types also fix a trailing whitespace --- examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino | 6 +++--- .../MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino b/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino index 6a9ecfa..4ee5a56 100644 --- a/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino +++ b/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino @@ -16,9 +16,9 @@ const uint8_t NETWORK_KEY[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; -AntWithCallbacks ant = AntWithCallbacks(); -AntPlusRouter router = AntPlusRouter(); -ProfileMuscleOxygenMonitor moxy = ProfileMuscleOxygenMonitor( 7369 ); +ArduinoSerialAntWithCallbacks ant; +AntPlusRouter router; +ProfileMuscleOxygenMonitor moxy(123); void moxyCreateMsgHandler(MuscleOxygenBaseMainDataPageMsg& msg, uintptr_t data); void moxyCreateManufacturerInformationMsg(ManufacturersInformationMsg& msg, uintptr_t data); diff --git a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h index a4de1a8..4d5ad96 100644 --- a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h +++ b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h @@ -2,7 +2,7 @@ #define ANTPLUS_MUSCLEOXYGENPROFILEPRIVATEDEFINES_h /* Channel Config */ -#define ANTPLUS_MUSCLEOXYGEN_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE +#define ANTPLUS_MUSCLEOXYGEN_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE #define ANTPLUS_MUSCLEOXYGEN_DEVICETYPE 31 #define ANTPLUS_MUSCLEOXYGEN_CHANNELPERIOD 8192 // Master channel From 18faa332955bfda52c325b393a01dcda5430a687 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Wed, 13 Jan 2021 11:29:58 -0800 Subject: [PATCH 085/241] moxy: fixup callbacks We should not be calling base classes for callbacks --- examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino | 12 ++++++------ .../Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino b/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino index 4ee5a56..22ed4e8 100644 --- a/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino +++ b/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino @@ -20,7 +20,7 @@ ArduinoSerialAntWithCallbacks ant; AntPlusRouter router; ProfileMuscleOxygenMonitor moxy(123); -void moxyCreateMsgHandler(MuscleOxygenBaseMainDataPageMsg& msg, uintptr_t data); +void moxyCreateMsgHandler(MuscleOxygenMuscleOxygenDataMsg& msg, uintptr_t data); void moxyCreateManufacturerInformationMsg(ManufacturersInformationMsg& msg, uintptr_t data); void moxyCreateProductInformationMsg(ProductInformationMsg& msg, uintptr_t data); @@ -38,9 +38,9 @@ void setup() { Serial.println("Running"); // setup muscle oxygen monitor - moxy.createMuscleOxygenDataMsg(moxyCreateMsgHandler); - moxy.createMuscleOxygenManufacturerInformationMsg(moxyCreateManufacturerInformationMsg); - moxy.createMuscleOxygenProductInformationMsg(moxyCreateProductInformationMsg); + moxy.createMuscleOxygenMuscleOxygenDataMsg(moxyCreateMsgHandler); + moxy.createManufacturerInformationMsg(moxyCreateManufacturerInformationMsg); + moxy.createProductInformationMsg(moxyCreateProductInformationMsg); moxy.begin(); } @@ -48,13 +48,13 @@ void loop() { router.loop(); } -void moxyCreateMsgHandler(MuscleOxygenBaseMainDataPageMsg& msg, uintptr_t data) +void moxyCreateMsgHandler(MuscleOxygenMuscleOxygenDataMsg& msg, uintptr_t data) { const int lo = 500, hi = 2500; static uint16_t _c = lo; static uint8_t _eventCount = 0; - // demo data + // demo data msg.setTotalHemoglobinConcentration(_c); msg.setCurrentSaturatedHemoglobinPercentage(_c++/4); msg.setEventCount(_eventCount++); diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h index 4c857a0..6c05bac 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h @@ -13,15 +13,15 @@ class ProfileMuscleOxygenMonitor : public BaseMasterProfile { /** * Register callback to populate Muscle Oxygen data messages (Datapage 0) */ - void createMuscleOxygenMuscleOxygenDataMsg(void(*func)(MuscleOxygenBaseMainDataPageMsg&, uintptr_t), uintptr_t data = 0) { _createMuscleOxygenMuscleOxygenDataMsg.set(func, data); } + void createMuscleOxygenMuscleOxygenDataMsg(void(*func)(MuscleOxygenMuscleOxygenDataMsg&, uintptr_t), uintptr_t data = 0) { _createMuscleOxygenMuscleOxygenDataMsg.set(func, data); } /** * Register callback to populate manufacturer information data messages (Datapage 2) */ - void createMuscleOxygenManufacturerInformationMsg(void(*func)(ManufacturersInformationMsg&, uintptr_t), uintptr_t data = 0) { _createManufacturersInformationMsg.set(func, data); } + void createManufacturerInformationMsg(void(*func)(ManufacturersInformationMsg&, uintptr_t), uintptr_t data = 0) { _createManufacturersInformationMsg.set(func, data); } /** * Register callback to populate product information data messages (Datapage 3) */ - void createMuscleOxygenProductInformationMsg(void(*func)(ProductInformationMsg&, uintptr_t), uintptr_t data = 0) { _createProductInformationMsg.set(func, data); } + void createProductInformationMsg(void(*func)(ProductInformationMsg&, uintptr_t), uintptr_t data = 0) { _createProductInformationMsg.set(func, data); } protected: void transmitNextDataPage(); @@ -37,7 +37,7 @@ class ProfileMuscleOxygenMonitor : public BaseMasterProfile { uint8_t _patternStep; uint8_t _backgroundStep; - AntCallback _createMuscleOxygenMuscleOxygenDataMsg; + AntCallback _createMuscleOxygenMuscleOxygenDataMsg; AntCallback _createManufacturersInformationMsg; AntCallback _createProductInformationMsg; AntCallback _createBatteryStatusMsg; From 21ec87e1ddf20e7d2695df48606f2b1cb2172071 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Wed, 13 Jan 2021 11:46:25 -0800 Subject: [PATCH 086/241] baseprofile: init all members satisfy cppcheck medium warnings --- src/BaseClasses/ANTPLUS_BaseProfile.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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; From 14c894fe3f0d9b827c7e832970490419e02c7179 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Fri, 15 Jan 2021 23:53:51 -0800 Subject: [PATCH 087/241] cppcheck: fixup missing explicit keywords --- src/BaseClasses/ANTPLUS_BaseDataPage.h | 2 +- src/CommonDataPages/RX/ANTPLUS_ManufacturersInformation.h | 2 +- src/CommonDataPages/RX/ANTPLUS_ModeSettings.h | 2 +- .../RX/ANTPLUS_MultiComponentSystemManufacturersInformation.h | 2 +- .../RX/ANTPLUS_MultiComponentSystemProductInformation.h | 2 +- src/CommonDataPages/RX/ANTPLUS_ProductInformation.h | 2 +- src/CommonDataPages/RX/ANTPLUS_RequestDataPage.h | 2 +- src/MainClasses/ANTPLUS_AntPlusRouter.h | 4 ++-- .../DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.h | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) 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/CommonDataPages/RX/ANTPLUS_ManufacturersInformation.h b/src/CommonDataPages/RX/ANTPLUS_ManufacturersInformation.h index 274c469..f7c432e 100644 --- a/src/CommonDataPages/RX/ANTPLUS_ManufacturersInformation.h +++ b/src/CommonDataPages/RX/ANTPLUS_ManufacturersInformation.h @@ -10,7 +10,7 @@ class ManufacturersInformation : public BaseDataPage, public BaseManufacturersInformation { public: - ManufacturersInformation(AntRxDataResponse& dp); + explicit ManufacturersInformation(AntRxDataResponse& dp); }; #endif // ANTPLUS_MANUFACTURERSINFORMATION_h diff --git a/src/CommonDataPages/RX/ANTPLUS_ModeSettings.h b/src/CommonDataPages/RX/ANTPLUS_ModeSettings.h index f4444e7..dc19550 100644 --- a/src/CommonDataPages/RX/ANTPLUS_ModeSettings.h +++ b/src/CommonDataPages/RX/ANTPLUS_ModeSettings.h @@ -10,7 +10,7 @@ class ModeSettings : public BaseDataPage, public BaseModeSettings { public: - ModeSettings(AntRxDataResponse& dp); + explicit ModeSettings(AntRxDataResponse& dp); }; #endif // ANTPLUS_MODESETTINGS_h diff --git a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.h b/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.h index 847b237..203ed1d 100644 --- a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.h +++ b/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.h @@ -10,7 +10,7 @@ class MultiComponentSystemManufacturersInformation : public BaseDataPage, public BaseMultiComponentSystemManufacturersInformation { public: - MultiComponentSystemManufacturersInformation(AntRxDataResponse& dp); + explicit MultiComponentSystemManufacturersInformation(AntRxDataResponse& dp); }; #endif // ANTPLUS_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_h diff --git a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.h b/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.h index b860016..c72be58 100644 --- a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.h +++ b/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.h @@ -10,7 +10,7 @@ class MultiComponentSystemProductInformation : public BaseDataPage, public BaseMultiComponentSystemProductInformation { public: - MultiComponentSystemProductInformation(AntRxDataResponse& dp); + explicit MultiComponentSystemProductInformation(AntRxDataResponse& dp); }; #endif // ANTPLUS_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_h diff --git a/src/CommonDataPages/RX/ANTPLUS_ProductInformation.h b/src/CommonDataPages/RX/ANTPLUS_ProductInformation.h index c6864db..93733dd 100644 --- a/src/CommonDataPages/RX/ANTPLUS_ProductInformation.h +++ b/src/CommonDataPages/RX/ANTPLUS_ProductInformation.h @@ -10,7 +10,7 @@ class ProductInformation : public BaseDataPage, public BaseProductInformation { public: - ProductInformation(AntRxDataResponse& dp); + explicit ProductInformation(AntRxDataResponse& dp); }; #endif // ANTPLUS_PRODUCTINFORMATION_h diff --git a/src/CommonDataPages/RX/ANTPLUS_RequestDataPage.h b/src/CommonDataPages/RX/ANTPLUS_RequestDataPage.h index 64b4c8f..8792bc4 100644 --- a/src/CommonDataPages/RX/ANTPLUS_RequestDataPage.h +++ b/src/CommonDataPages/RX/ANTPLUS_RequestDataPage.h @@ -10,7 +10,7 @@ class RequestDataPage : public BaseDataPage, public BaseRequestDataPage { public: - RequestDataPage(AntRxDataResponse& dp); + explicit RequestDataPage(AntRxDataResponse& dp); }; #endif // ANTPLUS_REQUESTDATAPAGE_h diff --git a/src/MainClasses/ANTPLUS_AntPlusRouter.h b/src/MainClasses/ANTPLUS_AntPlusRouter.h index 0b131b9..c77469a 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) */ diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.h index c3ccec5..9b5f8ad 100644 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.h +++ b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.h @@ -7,7 +7,7 @@ class BicyclePowerBaseMainDataPage : public BaseDataPage { public: - BicyclePowerBaseMainDataPage(AntRxDataResponse& dp); + explicit BicyclePowerBaseMainDataPage(AntRxDataResponse& dp); uint8_t getDataPageNumber() override; uint8_t getUpdateEventCount(); From 7dcff87a9b911f0e23d072f993d07db8906dc81f Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 16 Jan 2021 00:09:56 -0800 Subject: [PATCH 088/241] cppcheck: add explicit to construtors just fixing low hanging fruit --- .../DataPages/RX/ANTPLUS_BicyclePowerStandardCrankTorque.h | 2 +- .../DataPages/RX/ANTPLUS_BicyclePowerStandardPowerOnly.h | 2 +- .../DataPages/RX/ANTPLUS_BicyclePowerStandardWheelTorque.h | 2 +- ...NTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.h | 2 +- .../DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPage.h | 2 +- .../DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPageMsg.h | 2 +- .../DataPages/RX/ANTPLUS_BicycleSpeedBatteryStatus.h | 2 +- .../RX/ANTPLUS_BicycleSpeedCumulativeOperatingTime.h | 2 +- .../BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedDefault.h | 2 +- .../DataPages/RX/ANTPLUS_BicycleSpeedManufacturerID.h | 2 +- .../DataPages/RX/ANTPLUS_BicycleSpeedMotionAndSpeed.h | 2 +- .../BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedProductID.h | 2 +- .../BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.h | 4 ++-- .../DataPages/Base/ANTPLUS_EnvironmentBaseDataPage.h | 2 +- .../DataPages/RX/ANTPLUS_EnvironmentGeneralInformation.h | 2 +- .../Environment/DataPages/RX/ANTPLUS_EnvironmentTemperature.h | 2 +- .../Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.h | 4 ++-- src/Profiles/FEC/DataPages/RX/ANTPLUS_FECTrainerData.h | 2 +- .../DataPages/Base/ANTPLUS_HeartRateBaseMainDataPage.h | 2 +- .../DataPages/Base/ANTPLUS_HeartRateBaseMainDataPageMsg.h | 2 +- .../HeartRate/DataPages/RX/ANTPLUS_HeartRateBatteryStatus.h | 2 +- .../HeartRate/DataPages/RX/ANTPLUS_HeartRateCapabilities.h | 2 +- .../DataPages/RX/ANTPLUS_HeartRateCumulativeOperatingTime.h | 2 +- .../HeartRate/DataPages/RX/ANTPLUS_HeartRateDefault.h | 4 ++-- .../DataPages/RX/ANTPLUS_HeartRateManufacturerInformation.h | 2 +- .../DataPages/RX/ANTPLUS_HeartRatePreviousHeartBeat.h | 2 +- .../DataPages/RX/ANTPLUS_HeartRateProductInformation.h | 2 +- .../DataPages/RX/ANTPLUS_HeartRateSwimIntervalSummary.h | 2 +- .../HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.h | 4 ++-- src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPage.h | 2 +- .../Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPageMsg.h | 2 +- .../DataPages/Base/ANTPLUS_LevBaseSpeedSystemInformation.h | 2 +- .../Lev/DataPages/RX/ANTPLUS_LevAltSpeedDistanceInformation.h | 2 +- src/Profiles/Lev/DataPages/RX/ANTPLUS_LevBatteryInformation.h | 2 +- src/Profiles/Lev/DataPages/RX/ANTPLUS_LevCapabilities.h | 2 +- .../Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation1.h | 2 +- .../Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation2.h | 2 +- src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.h | 4 ++-- .../DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h | 2 +- .../MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h | 2 +- .../Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h | 2 +- 41 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardCrankTorque.h b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardCrankTorque.h index 274c744..94e6a3b 100644 --- a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardCrankTorque.h +++ b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardCrankTorque.h @@ -6,7 +6,7 @@ class BicyclePowerStandardCrankTorque : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseStandardCrankTorque { public: - BicyclePowerStandardCrankTorque(AntRxDataResponse& dp); + explicit BicyclePowerStandardCrankTorque(AntRxDataResponse& dp); }; #endif // ANTPLUS_BICYCLEPOWERSTANDARDCRANKTORQUE_h diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardPowerOnly.h b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardPowerOnly.h index b3dbbea..b6f2ce9 100644 --- a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardPowerOnly.h +++ b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardPowerOnly.h @@ -6,7 +6,7 @@ class BicyclePowerStandardPowerOnly : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseStandardPowerOnly { public: - BicyclePowerStandardPowerOnly(AntRxDataResponse& dp); + explicit BicyclePowerStandardPowerOnly(AntRxDataResponse& dp); }; #endif // ANTPLUS_BICYCLEPOWERSTANDARDPOWERONLY_h diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardWheelTorque.h b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardWheelTorque.h index 7deabb6..9708728 100644 --- a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardWheelTorque.h +++ b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardWheelTorque.h @@ -6,7 +6,7 @@ class BicyclePowerStandardWheelTorque : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseStandardWheelTorque { public: - BicyclePowerStandardWheelTorque(AntRxDataResponse& dp); + explicit BicyclePowerStandardWheelTorque(AntRxDataResponse& dp); }; #endif // ANTPLUS_BICYCLEPOWERSTANDARDWHEELTORQUE_h diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.h b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.h index 6a15008..162d722 100644 --- a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.h +++ b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.h @@ -6,7 +6,7 @@ class BicyclePowerTorqueEffectivenessAndPedalSmoothness : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness { public: - BicyclePowerTorqueEffectivenessAndPedalSmoothness(AntRxDataResponse& dp); + explicit BicyclePowerTorqueEffectivenessAndPedalSmoothness(AntRxDataResponse& dp); }; #endif // ANTPLUS_BICYCLEPOWERPEDALSMOOTHNESS_h diff --git a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPage.h b/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPage.h index d101c9d..5a62323 100644 --- a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPage.h +++ b/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPage.h @@ -7,7 +7,7 @@ class BicycleSpeedBaseMainDataPage : public BaseDataPage { public: - BicycleSpeedBaseMainDataPage(AntRxDataResponse& dp); + explicit BicycleSpeedBaseMainDataPage(AntRxDataResponse& dp); uint8_t getDataPageNumber() override; uint8_t getPageChangeToggle(); uint16_t getBikeSpeedEventTime(); diff --git a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPageMsg.h b/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPageMsg.h index a7221e3..aeaad0f 100644 --- a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPageMsg.h +++ b/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPageMsg.h @@ -7,7 +7,7 @@ class BicycleSpeedBaseMainDataPageMsg : public BaseDataPageMsg { public: - BicycleSpeedBaseMainDataPageMsg(uint8_t dataPageNumber); + explicit BicycleSpeedBaseMainDataPageMsg(uint8_t dataPageNumber); uint8_t getPageChangeToggle(); uint16_t getBikeSpeedEventTime(); uint16_t getCumulativeSpeedRevolutionCount(); diff --git a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedBatteryStatus.h b/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedBatteryStatus.h index a97fb1c..456ef71 100644 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedBatteryStatus.h +++ b/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedBatteryStatus.h @@ -6,7 +6,7 @@ class BicycleSpeedBatteryStatus : public BicycleSpeedBaseMainDataPage, public BicycleSpeedBaseBatteryStatus { public: - BicycleSpeedBatteryStatus(AntRxDataResponse& dp); + explicit BicycleSpeedBatteryStatus(AntRxDataResponse& dp); }; #endif // ANTPLUS_BICYCLESPEEDBATTERYSTATUS_h diff --git a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedCumulativeOperatingTime.h b/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedCumulativeOperatingTime.h index a6427f9..7258a9a 100644 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedCumulativeOperatingTime.h +++ b/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedCumulativeOperatingTime.h @@ -6,7 +6,7 @@ class BicycleSpeedCumulativeOperatingTime : public BicycleSpeedBaseMainDataPage, public BicycleSpeedBaseCumulativeOperatingTime { public: - BicycleSpeedCumulativeOperatingTime(AntRxDataResponse& dp); + explicit BicycleSpeedCumulativeOperatingTime(AntRxDataResponse& dp); }; #endif // ANTPLUS_BICYCLESPEEDCUMULITIVEOPERATINGTIME_h diff --git a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedDefault.h b/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedDefault.h index 3130a62..902382c 100644 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedDefault.h +++ b/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedDefault.h @@ -5,7 +5,7 @@ class BicycleSpeedDefault : public BicycleSpeedBaseMainDataPage { public: - BicycleSpeedDefault(AntRxDataResponse& dp); + explicit BicycleSpeedDefault(AntRxDataResponse& dp); }; #endif // ANTPLUS_BICYCLESPEEDDEFAULT_h diff --git a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedManufacturerID.h b/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedManufacturerID.h index 885f0ae..98380aa 100644 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedManufacturerID.h +++ b/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedManufacturerID.h @@ -6,7 +6,7 @@ class BicycleSpeedManufacturerID : public BicycleSpeedBaseMainDataPage, public BicycleSpeedBaseManufacturerID { public: - BicycleSpeedManufacturerID(AntRxDataResponse& dp); + explicit BicycleSpeedManufacturerID(AntRxDataResponse& dp); }; #endif // ANTPLUS_BICYCLESPEEDMANUFACTURERID_h diff --git a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedMotionAndSpeed.h b/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedMotionAndSpeed.h index 2357e2f..eb1472f 100644 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedMotionAndSpeed.h +++ b/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedMotionAndSpeed.h @@ -6,7 +6,7 @@ class BicycleSpeedMotionAndSpeed : public BicycleSpeedBaseMainDataPage, public BicycleSpeedBaseMotionAndSpeed { public: - BicycleSpeedMotionAndSpeed(AntRxDataResponse& dp); + explicit BicycleSpeedMotionAndSpeed(AntRxDataResponse& dp); }; #endif // ANTPLUS_BICYCLESPEEDMOTIONANDSPEED_h diff --git a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedProductID.h b/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedProductID.h index b849b77..4d57330 100644 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedProductID.h +++ b/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedProductID.h @@ -6,7 +6,7 @@ class BicycleSpeedProductID : public BicycleSpeedBaseMainDataPage, public BicycleSpeedBaseProductID { public: - BicycleSpeedProductID(AntRxDataResponse& dp); + explicit BicycleSpeedProductID(AntRxDataResponse& dp); }; #endif // ANTPLUS_BICYCLESPEEDPRODUCTIONID_h diff --git a/src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.h b/src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.h index 13aaf82..91866eb 100644 --- a/src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.h +++ b/src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.h @@ -10,8 +10,8 @@ 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); } diff --git a/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseDataPage.h b/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseDataPage.h index f8fb62d..4b3a232 100644 --- a/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseDataPage.h +++ b/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseDataPage.h @@ -7,7 +7,7 @@ class EnvironmentBaseDataPage : public BaseDataPage { public: - EnvironmentBaseDataPage(AntRxDataResponse& dp); + explicit EnvironmentBaseDataPage(AntRxDataResponse& dp); }; #endif // ANTPLUS_ENVIRONMENTBASEMAINDATAPAGE_h diff --git a/src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentGeneralInformation.h b/src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentGeneralInformation.h index c208172..e59f703 100644 --- a/src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentGeneralInformation.h +++ b/src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentGeneralInformation.h @@ -6,7 +6,7 @@ class EnvironmentGeneralInformation : public EnvironmentBaseDataPage, public EnvironmentBaseGeneralInformation { public: - EnvironmentGeneralInformation(AntRxDataResponse& dp); + explicit EnvironmentGeneralInformation(AntRxDataResponse& dp); }; #endif // ANTPLUS_ENVIRONMENTGENERALINFORMATION_h diff --git a/src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentTemperature.h b/src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentTemperature.h index d3f48b6..23459b8 100644 --- a/src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentTemperature.h +++ b/src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentTemperature.h @@ -6,7 +6,7 @@ class EnvironmentTemperature : public EnvironmentBaseDataPage, public EnvironmentBaseTemperature { public: - EnvironmentTemperature(AntRxDataResponse& dp); + explicit EnvironmentTemperature(AntRxDataResponse& dp); }; #endif // ANTPLUS_ENVIRONMENTTEMPERATURE_h diff --git a/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.h b/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.h index 8f1360e..139cf30 100644 --- a/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.h +++ b/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.h @@ -10,8 +10,8 @@ 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); } diff --git a/src/Profiles/FEC/DataPages/RX/ANTPLUS_FECTrainerData.h b/src/Profiles/FEC/DataPages/RX/ANTPLUS_FECTrainerData.h index 7617ffa..1dd42d3 100644 --- a/src/Profiles/FEC/DataPages/RX/ANTPLUS_FECTrainerData.h +++ b/src/Profiles/FEC/DataPages/RX/ANTPLUS_FECTrainerData.h @@ -6,7 +6,7 @@ class FECTrainerData : public BaseDataPage, public FECTrainerDataPage { public: - FECTrainerData(AntRxDataResponse& dp); + explicit FECTrainerData(AntRxDataResponse& dp); }; #endif // ANTPLUS_FECTRAINERDATA_h diff --git a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPage.h b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPage.h index 6a45de4..1b44f13 100644 --- a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPage.h +++ b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPage.h @@ -8,7 +8,7 @@ class HeartRateBaseMainDataPage : public BaseDataPage, public HeartRateCoreMainDataPage { public: - HeartRateBaseMainDataPage(AntRxDataResponse& dp); + explicit HeartRateBaseMainDataPage(AntRxDataResponse& dp); }; #endif // ANTPLUS_HEARTRATEBASEMAINDATAPAGE_h diff --git a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPageMsg.h b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPageMsg.h index 0c411e4..e5c2e58 100644 --- a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPageMsg.h +++ b/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPageMsg.h @@ -8,7 +8,7 @@ class HeartRateBaseMainDataPageMsg : public BaseDataPageMsg, public HeartRateCoreMainDataPage { public: - HeartRateBaseMainDataPageMsg(uint8_t dataPageNumber); + explicit HeartRateBaseMainDataPageMsg(uint8_t dataPageNumber); void setPageChangeToggle(uint8_t toggle); void setHeartBeatEventTime(uint16_t time); void setHeartBeatCount(uint8_t count); diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateBatteryStatus.h b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateBatteryStatus.h index 3ef54d1..7613ef6 100644 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateBatteryStatus.h +++ b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateBatteryStatus.h @@ -6,7 +6,7 @@ class HeartRateBatteryStatus : public HeartRateBaseMainDataPage, public HeartRateBaseBatteryStatus { public: - HeartRateBatteryStatus(AntRxDataResponse& dp); + explicit HeartRateBatteryStatus(AntRxDataResponse& dp); }; #endif // ANTPLUS_HEARTRATEBATTERYSTATUS_h diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCapabilities.h b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCapabilities.h index 77cad66..d743a1b 100644 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCapabilities.h +++ b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCapabilities.h @@ -6,7 +6,7 @@ class HeartRateCapabilities : public HeartRateBaseMainDataPage, public HeartRateBaseCapabilities { public: - HeartRateCapabilities(AntRxDataResponse& dp); + explicit HeartRateCapabilities(AntRxDataResponse& dp); }; #endif // ANTPLUS_HEARTRATECAPABILITIES_h diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCumulativeOperatingTime.h b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCumulativeOperatingTime.h index 29d6990..fdb3f58 100644 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCumulativeOperatingTime.h +++ b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCumulativeOperatingTime.h @@ -6,7 +6,7 @@ class HeartRateCumulativeOperatingTime : public HeartRateBaseMainDataPage, public HeartRateBaseCumulativeOperatingTime { public: - HeartRateCumulativeOperatingTime(AntRxDataResponse& dp); + explicit HeartRateCumulativeOperatingTime(AntRxDataResponse& dp); }; #endif // ANTPLUS_HEARTRATECUMULITIVEOPERATINGTIME_h diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateDefault.h b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateDefault.h index b3fb62a..a78845a 100644 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateDefault.h +++ b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateDefault.h @@ -5,7 +5,7 @@ class HeartRateDefault : public HeartRateBaseMainDataPage { public: - HeartRateDefault(AntRxDataResponse& dp); + explicit HeartRateDefault(AntRxDataResponse& dp); }; -#endif // ANTPLUS_HEARTRATEDEFAULT_h \ No newline at end of file +#endif // ANTPLUS_HEARTRATEDEFAULT_h diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateManufacturerInformation.h b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateManufacturerInformation.h index 0e65a03..6fcdadf 100644 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateManufacturerInformation.h +++ b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateManufacturerInformation.h @@ -6,7 +6,7 @@ class HeartRateManufacturerInformation : public HeartRateBaseMainDataPage, public HeartRateBaseManufacturerInformation { public: - HeartRateManufacturerInformation(AntRxDataResponse& dp); + explicit HeartRateManufacturerInformation(AntRxDataResponse& dp); }; #endif // ANTPLUS_HEARTRATEMANUFACTURERINFORMATION_h diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRatePreviousHeartBeat.h b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRatePreviousHeartBeat.h index 8a53ba7..e45adf7 100644 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRatePreviousHeartBeat.h +++ b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRatePreviousHeartBeat.h @@ -6,7 +6,7 @@ class HeartRatePreviousHeartBeat : public HeartRateBaseMainDataPage, public HeartRateBasePreviousHeartBeat { public: - HeartRatePreviousHeartBeat(AntRxDataResponse& dp); + explicit HeartRatePreviousHeartBeat(AntRxDataResponse& dp); }; #endif // ANTPLUS_HEARTRATEPREVIOUSHEARTBEAT_h diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateProductInformation.h b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateProductInformation.h index 357ad9a..b1376b6 100644 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateProductInformation.h +++ b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateProductInformation.h @@ -6,7 +6,7 @@ class HeartRateProductInformation : public HeartRateBaseMainDataPage, public HeartRateBaseProductInformation { public: - HeartRateProductInformation(AntRxDataResponse& dp); + explicit HeartRateProductInformation(AntRxDataResponse& dp); }; #endif // ANTPLUS_HEARTRATEPRODUCTIONINFORMATION_h diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateSwimIntervalSummary.h b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateSwimIntervalSummary.h index 2dc07e6..b2c7660 100644 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateSwimIntervalSummary.h +++ b/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateSwimIntervalSummary.h @@ -6,7 +6,7 @@ class HeartRateSwimIntervalSummary : public HeartRateBaseMainDataPage, public HeartRateBaseSwimIntervalSummary { public: - HeartRateSwimIntervalSummary(AntRxDataResponse& dp); + explicit HeartRateSwimIntervalSummary(AntRxDataResponse& dp); }; #endif // ANTPLUS_HEARTRATESWIMINTERVALSUMMARY_h diff --git a/src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.h b/src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.h index 7d8b8e0..dd1b3bb 100644 --- a/src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.h +++ b/src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.h @@ -10,8 +10,8 @@ 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); } diff --git a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPage.h b/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPage.h index e66f57c..e76d7ed 100644 --- a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPage.h +++ b/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPage.h @@ -7,7 +7,7 @@ class LevBaseMainDataPage : public BaseDataPage { public: - LevBaseMainDataPage(AntRxDataResponse& dp); + explicit LevBaseMainDataPage(AntRxDataResponse& dp); }; #endif // ANTPLUS_LEVBASEMAINDATAPAGE_h diff --git a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPageMsg.h b/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPageMsg.h index f3db147..35590e8 100644 --- a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPageMsg.h +++ b/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPageMsg.h @@ -7,7 +7,7 @@ class LevBaseMainDataPageMsg : public BaseDataPageMsg { public: - LevBaseMainDataPageMsg(uint8_t dataPageNumber); + explicit LevBaseMainDataPageMsg(uint8_t dataPageNumber); protected: uint8_t _buffer[MESSAGE_SIZE]; }; diff --git a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedSystemInformation.h b/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedSystemInformation.h index c9f8b58..73bda52 100644 --- a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedSystemInformation.h +++ b/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedSystemInformation.h @@ -5,7 +5,7 @@ class LevBaseSpeedSystemInformation : public LevBaseMainDataPage { public: - LevBaseSpeedSystemInformation(AntRxDataResponse& dp); + explicit LevBaseSpeedSystemInformation(AntRxDataResponse& dp); uint8_t getCurrentRegenerativeLevel(); uint8_t getCurrentAssistLevel(); uint8_t getSystemState(); diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevAltSpeedDistanceInformation.h b/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevAltSpeedDistanceInformation.h index 4e6aa87..e01f1df 100644 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevAltSpeedDistanceInformation.h +++ b/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevAltSpeedDistanceInformation.h @@ -5,7 +5,7 @@ class LevAltSpeedDistanceInformation : public LevBaseSpeedDistanceInformation { public: - LevAltSpeedDistanceInformation(AntRxDataResponse& dp); + explicit LevAltSpeedDistanceInformation(AntRxDataResponse& dp); uint16_t getFuelConsumption(); // in Wh/km }; diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevBatteryInformation.h b/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevBatteryInformation.h index b9d997f..86f75de 100644 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevBatteryInformation.h +++ b/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevBatteryInformation.h @@ -5,7 +5,7 @@ class LevBatteryInformation : public LevBaseMainDataPage { public: - LevBatteryInformation(AntRxDataResponse& dp); + explicit LevBatteryInformation(AntRxDataResponse& dp); uint16_t getChargingCycleCount(); uint16_t getFuelConsumption(); uint8_t getBatteryVoltage(); diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevCapabilities.h b/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevCapabilities.h index 67a4cbd..19adecd 100644 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevCapabilities.h +++ b/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevCapabilities.h @@ -5,7 +5,7 @@ class LevCapabilities : public LevBaseMainDataPage { public: - LevCapabilities(AntRxDataResponse& dp); + explicit LevCapabilities(AntRxDataResponse& dp); uint8_t getNumberOfAssistModesSupported(); uint8_t getNumberOfRegenerativeModesSupported(); uint16_t getWheelCircumference(); diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation1.h b/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation1.h index 6c3f72d..e12ddaa 100644 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation1.h +++ b/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation1.h @@ -5,7 +5,7 @@ class LevSpeedSystemInformation1 : public LevBaseSpeedSystemInformation { public: - LevSpeedSystemInformation1(AntRxDataResponse& dp); + explicit LevSpeedSystemInformation1(AntRxDataResponse& dp); uint8_t getBatteryTemperatureState(); uint8_t getBatteryTemperatureAlert(); uint8_t getMotorTemperatureState(); diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation2.h b/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation2.h index 533a7e2..9c15c6a 100644 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation2.h +++ b/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation2.h @@ -5,7 +5,7 @@ class LevSpeedSystemInformation2 : public LevBaseSpeedSystemInformation { public: - LevSpeedSystemInformation2(AntRxDataResponse& dp); + explicit LevSpeedSystemInformation2(AntRxDataResponse& dp); uint8_t getBatterySOC(); uint8_t getBatteryEmptyWarning(); uint8_t getPercentAssist(); diff --git a/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.h b/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.h index debd74e..2b5b74b 100644 --- a/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.h +++ b/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.h @@ -10,8 +10,8 @@ class ProfileLevDisplay : public BaseSlaveProfile { public: ProfileLevDisplay(); - ProfileLevDisplay(uint16_t deviceNumber); - ProfileLevDisplay(uint16_t deviceNumber, uint8_t transmissionType); + explicit ProfileLevDisplay(uint16_t deviceNumber); + explicit ProfileLevDisplay(uint16_t deviceNumber, uint8_t transmissionType); 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); } diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h index 7e455c7..58b2169 100644 --- a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h +++ b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h @@ -7,7 +7,7 @@ class MuscleOxygenBaseMainDataPageMsg : public BaseDataPageMsg { public: - MuscleOxygenBaseMainDataPageMsg(uint8_t dataPageNumber); + explicit MuscleOxygenBaseMainDataPageMsg(uint8_t dataPageNumber); protected: uint8_t _buffer[MESSAGE_SIZE]; }; diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h index 6c05bac..1d022b3 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h @@ -8,7 +8,7 @@ class ProfileMuscleOxygenMonitor : public BaseMasterProfile { public: - ProfileMuscleOxygenMonitor(uint16_t deviceNumber, uint8_t transmissionType = ANTPLUS_MUSCLEOXYGEN_MONITOR_TRANSMISSIONTYPE); + explicit ProfileMuscleOxygenMonitor(uint16_t deviceNumber, uint8_t transmissionType = ANTPLUS_MUSCLEOXYGEN_MONITOR_TRANSMISSIONTYPE); /** * Register callback to populate Muscle Oxygen data messages (Datapage 0) diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h index 341a79a..bd67553 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h @@ -8,7 +8,7 @@ class ProfileShiftingShifter : public BaseMasterProfile { public: - ProfileShiftingShifter(uint16_t deviceNumber, uint8_t transmissionType = ANTPLUS_SHIFTING_SHIFTER_TRANSMISSIONTYPE, uint16_t componentsSupported = 0x1); + explicit ProfileShiftingShifter(uint16_t deviceNumber, uint8_t transmissionType = ANTPLUS_SHIFTING_SHIFTER_TRANSMISSIONTYPE, uint16_t componentsSupported = 0x1); /** * Register callback to populate default data messages (Datapage 1) From 57e44a3b89f22d930de1db6feb63ae4a17c4675e Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 16 Jan 2021 01:09:55 -0800 Subject: [PATCH 089/241] heartrate: refactor datapages with core datapages i realized splitting the datapges into three files was borderline obnoxious, so lets collapse everything back down. This is step 1 of 2 of the refactor this profile. Second step is to trim down defines by moving them where needed which will be done in the follwing commit. This whole changewill lead to an overall text and code reduction. --- .../HeartRate/ANTPLUS_HeartRateProfile.h | 2 +- .../ANTPLUS_ProfileHeartRateDataPages.h | 14 ++++ ... => ANTPLUS_HeartRateBaseMainDataPage.cpp} | 34 +++++++++- .../ANTPLUS_HeartRateBaseMainDataPage.h | 37 +++++++++++ .../ANTPLUS_HeartRateBatteryStatus.cpp | 64 +++++++++++++++++++ .../ANTPLUS_HeartRateBatteryStatus.h | 30 +++++++++ .../ANTPLUS_HeartRateCapabilities.cpp | 36 +++++++++++ .../DataPages/ANTPLUS_HeartRateCapabilities.h | 26 ++++++++ ...TPLUS_HeartRateCumulativeOperatingTime.cpp | 27 ++++++++ ...ANTPLUS_HeartRateCumulativeOperatingTime.h | 24 +++++++ ...ltMsg.cpp => ANTPLUS_HeartRateDefault.cpp} | 5 +- .../{RX => }/ANTPLUS_HeartRateDefault.h | 7 +- ...TPLUS_HeartRateManufacturerInformation.cpp | 39 +++++++++++ ...ANTPLUS_HeartRateManufacturerInformation.h | 26 ++++++++ .../ANTPLUS_HeartRatePreviousHeartBeat.cpp | 40 ++++++++++++ .../ANTPLUS_HeartRatePreviousHeartBeat.h | 26 ++++++++ .../ANTPLUS_HeartRateProductInformation.cpp | 42 ++++++++++++ .../ANTPLUS_HeartRateProductInformation.h | 28 ++++++++ ... ANTPLUS_HeartRateSwimIntervalSummary.cpp} | 30 ++++++++- .../ANTPLUS_HeartRateSwimIntervalSummary.h | 29 +++++++++ .../ANTPLUS_ProfileHeartRateDataPages.h | 24 ------- .../ANTPLUS_HeartRateBaseBatteryStatus.cpp | 36 ----------- .../Base/ANTPLUS_HeartRateBaseBatteryStatus.h | 18 ------ .../ANTPLUS_HeartRateBaseCapabilities.cpp | 21 ------ .../Base/ANTPLUS_HeartRateBaseCapabilities.h | 16 ----- ...S_HeartRateBaseCumulativeOperatingTime.cpp | 16 ----- ...LUS_HeartRateBaseCumulativeOperatingTime.h | 15 ----- .../ANTPLUS_HeartRateBaseMainDataPage.cpp | 5 -- .../Base/ANTPLUS_HeartRateBaseMainDataPage.h | 14 ---- .../ANTPLUS_HeartRateBaseMainDataPageMsg.cpp | 31 --------- .../ANTPLUS_HeartRateBaseMainDataPageMsg.h | 20 ------ ...S_HeartRateBaseManufacturerInformation.cpp | 22 ------- ...LUS_HeartRateBaseManufacturerInformation.h | 16 ----- ...ANTPLUS_HeartRateBasePreviousHeartBeat.cpp | 22 ------- .../ANTPLUS_HeartRateBasePreviousHeartBeat.h | 16 ----- ...NTPLUS_HeartRateBaseProductInformation.cpp | 27 -------- .../ANTPLUS_HeartRateBaseProductInformation.h | 17 ----- ...TPLUS_HeartRateBaseSwimIntervalSummary.cpp | 27 -------- ...ANTPLUS_HeartRateBaseSwimIntervalSummary.h | 17 ----- .../Base/ANTPLUS_HeartRateCoreMainDataPage.h | 19 ------ .../RX/ANTPLUS_HeartRateBatteryStatus.cpp | 5 -- .../RX/ANTPLUS_HeartRateBatteryStatus.h | 12 ---- .../RX/ANTPLUS_HeartRateCapabilities.cpp | 4 -- .../RX/ANTPLUS_HeartRateCapabilities.h | 12 ---- ...TPLUS_HeartRateCumulativeOperatingTime.cpp | 4 -- ...ANTPLUS_HeartRateCumulativeOperatingTime.h | 12 ---- .../DataPages/RX/ANTPLUS_HeartRateDefault.cpp | 4 -- ...TPLUS_HeartRateManufacturerInformation.cpp | 4 -- ...ANTPLUS_HeartRateManufacturerInformation.h | 12 ---- .../RX/ANTPLUS_HeartRatePreviousHeartBeat.cpp | 4 -- .../RX/ANTPLUS_HeartRatePreviousHeartBeat.h | 12 ---- .../ANTPLUS_HeartRateProductInformation.cpp | 4 -- .../RX/ANTPLUS_HeartRateProductInformation.h | 12 ---- .../ANTPLUS_HeartRateSwimIntervalSummary.cpp | 4 -- .../RX/ANTPLUS_HeartRateSwimIntervalSummary.h | 12 ---- .../TX/ANTPLUS_HeartRateBatteryStatusMsg.cpp | 28 -------- .../TX/ANTPLUS_HeartRateBatteryStatusMsg.h | 16 ----- .../TX/ANTPLUS_HeartRateCapabilitiesMsg.cpp | 17 ----- .../TX/ANTPLUS_HeartRateCapabilitiesMsg.h | 14 ---- ...US_HeartRateCumulativeOperatingTimeMsg.cpp | 11 ---- ...PLUS_HeartRateCumulativeOperatingTimeMsg.h | 13 ---- .../TX/ANTPLUS_HeartRateDefaultMsg.h | 11 ---- ...US_HeartRateManufacturerInformationMsg.cpp | 16 ----- ...PLUS_HeartRateManufacturerInformationMsg.h | 14 ---- .../ANTPLUS_HeartRatePreviousHeartBeatMsg.cpp | 18 ------ .../ANTPLUS_HeartRatePreviousHeartBeatMsg.h | 14 ---- ...ANTPLUS_HeartRateProductInformationMsg.cpp | 18 ------ .../ANTPLUS_HeartRateProductInformationMsg.h | 15 ----- .../ANTPLUS_HeartRateSwimIntervalSummaryMsg.h | 15 ----- .../Display/ANTPLUS_ProfileHeartRateDisplay.h | 4 +- .../Monitor/ANTPLUS_ProfileHeartRateMonitor.h | 2 +- 71 files changed, 563 insertions(+), 745 deletions(-) create mode 100644 src/Profiles/HeartRate/ANTPLUS_ProfileHeartRateDataPages.h rename src/Profiles/HeartRate/DataPages/{Base/ANTPLUS_HeartRateCoreMainDataPage.cpp => ANTPLUS_HeartRateBaseMainDataPage.cpp} (50%) create mode 100644 src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.h create mode 100644 src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBatteryStatus.cpp create mode 100644 src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBatteryStatus.h create mode 100644 src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCapabilities.cpp create mode 100644 src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCapabilities.h create mode 100644 src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCumulativeOperatingTime.cpp create mode 100644 src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCumulativeOperatingTime.h rename src/Profiles/HeartRate/DataPages/{TX/ANTPLUS_HeartRateDefaultMsg.cpp => ANTPLUS_HeartRateDefault.cpp} (63%) rename src/Profiles/HeartRate/DataPages/{RX => }/ANTPLUS_HeartRateDefault.h (56%) create mode 100644 src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateManufacturerInformation.cpp create mode 100644 src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateManufacturerInformation.h create mode 100644 src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRatePreviousHeartBeat.cpp create mode 100644 src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRatePreviousHeartBeat.h create mode 100644 src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateProductInformation.cpp create mode 100644 src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateProductInformation.h rename src/Profiles/HeartRate/DataPages/{TX/ANTPLUS_HeartRateSwimIntervalSummaryMsg.cpp => ANTPLUS_HeartRateSwimIntervalSummary.cpp} (53%) create mode 100644 src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateSwimIntervalSummary.h delete mode 100644 src/Profiles/HeartRate/DataPages/ANTPLUS_ProfileHeartRateDataPages.h delete mode 100644 src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseBatteryStatus.cpp delete mode 100644 src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseBatteryStatus.h delete mode 100644 src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseCapabilities.cpp delete mode 100644 src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseCapabilities.h delete mode 100644 src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseCumulativeOperatingTime.cpp delete mode 100644 src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseCumulativeOperatingTime.h delete mode 100644 src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPage.cpp delete mode 100644 src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPage.h delete mode 100644 src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPageMsg.cpp delete mode 100644 src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseMainDataPageMsg.h delete mode 100644 src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseManufacturerInformation.cpp delete mode 100644 src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseManufacturerInformation.h delete mode 100644 src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBasePreviousHeartBeat.cpp delete mode 100644 src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBasePreviousHeartBeat.h delete mode 100644 src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseProductInformation.cpp delete mode 100644 src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseProductInformation.h delete mode 100644 src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseSwimIntervalSummary.cpp delete mode 100644 src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateBaseSwimIntervalSummary.h delete mode 100644 src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateCoreMainDataPage.h delete mode 100644 src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateBatteryStatus.cpp delete mode 100644 src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateBatteryStatus.h delete mode 100644 src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCapabilities.cpp delete mode 100644 src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCapabilities.h delete mode 100644 src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCumulativeOperatingTime.cpp delete mode 100644 src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateCumulativeOperatingTime.h delete mode 100644 src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateDefault.cpp delete mode 100644 src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateManufacturerInformation.cpp delete mode 100644 src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateManufacturerInformation.h delete mode 100644 src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRatePreviousHeartBeat.cpp delete mode 100644 src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRatePreviousHeartBeat.h delete mode 100644 src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateProductInformation.cpp delete mode 100644 src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateProductInformation.h delete mode 100644 src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateSwimIntervalSummary.cpp delete mode 100644 src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateSwimIntervalSummary.h delete mode 100644 src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateBatteryStatusMsg.cpp delete mode 100644 src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateBatteryStatusMsg.h delete mode 100644 src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateCapabilitiesMsg.cpp delete mode 100644 src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateCapabilitiesMsg.h delete mode 100644 src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateCumulativeOperatingTimeMsg.cpp delete mode 100644 src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateCumulativeOperatingTimeMsg.h delete mode 100644 src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateDefaultMsg.h delete mode 100644 src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateManufacturerInformationMsg.cpp delete mode 100644 src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateManufacturerInformationMsg.h delete mode 100644 src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRatePreviousHeartBeatMsg.cpp delete mode 100644 src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRatePreviousHeartBeatMsg.h delete mode 100644 src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateProductInformationMsg.cpp delete mode 100644 src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateProductInformationMsg.h delete mode 100644 src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateSwimIntervalSummaryMsg.h diff --git a/src/Profiles/HeartRate/ANTPLUS_HeartRateProfile.h b/src/Profiles/HeartRate/ANTPLUS_HeartRateProfile.h index bffbd4f..6a11d58 100644 --- a/src/Profiles/HeartRate/ANTPLUS_HeartRateProfile.h +++ b/src/Profiles/HeartRate/ANTPLUS_HeartRateProfile.h @@ -5,7 +5,7 @@ #include // Datapages -#include +#include // Profile Classes #include diff --git a/src/Profiles/HeartRate/ANTPLUS_ProfileHeartRateDataPages.h b/src/Profiles/HeartRate/ANTPLUS_ProfileHeartRateDataPages.h new file mode 100644 index 0000000..adb9157 --- /dev/null +++ b/src/Profiles/HeartRate/ANTPLUS_ProfileHeartRateDataPages.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/DataPages/Base/ANTPLUS_HeartRateCoreMainDataPage.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.cpp similarity index 50% rename from src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateCoreMainDataPage.cpp rename to src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.cpp index 6b2cbd6..9636b74 100644 --- a/src/Profiles/HeartRate/DataPages/Base/ANTPLUS_HeartRateCoreMainDataPage.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.cpp @@ -1,5 +1,6 @@ -#include +#include #include +#include template HeartRateCoreMainDataPage::HeartRateCoreMainDataPage() : CoreDataPage() { @@ -41,3 +42,34 @@ uint8_t HeartRateCoreMainDataPage::getComputedHeartRate() { template class HeartRateCoreMainDataPage; template class HeartRateCoreMainDataPage; + +HeartRateBaseMainDataPage::HeartRateBaseMainDataPage(AntRxDataResponse& dp) : BaseDataPage(dp), HeartRateCoreMainDataPage() { +} + +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/ANTPLUS_HeartRateBaseMainDataPage.h b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.h new file mode 100644 index 0000000..7c12f98 --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.h @@ -0,0 +1,37 @@ +#ifndef ANTPLUS_HEARTRATEBASEMAINDATAPAGE_h +#define ANTPLUS_HEARTRATEBASEMAINDATAPAGE_h + +#include +#include +#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(); +}; + +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]; +}; + +#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..8206862 --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBatteryStatus.cpp @@ -0,0 +1,64 @@ +#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; + +HeartRateBatteryStatus::HeartRateBatteryStatus(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp), HeartRateBaseBatteryStatus() {} + +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/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..4fd9ef1 --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCapabilities.cpp @@ -0,0 +1,36 @@ +#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; + +HeartRateCapabilities::HeartRateCapabilities(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp), HeartRateBaseCapabilities() {} + +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/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..b96bb53 --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCumulativeOperatingTime.cpp @@ -0,0 +1,27 @@ +#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; + +HeartRateCumulativeOperatingTime::HeartRateCumulativeOperatingTime(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp), HeartRateBaseCumulativeOperatingTime() {} + +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/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/TX/ANTPLUS_HeartRateDefaultMsg.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.cpp similarity index 63% rename from src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateDefaultMsg.cpp rename to src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.cpp index 5ab11e2..b0786e7 100644 --- a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateDefaultMsg.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.cpp @@ -1,6 +1,9 @@ -#include +#include #include +HeartRateDefault::HeartRateDefault(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp) { +} + HeartRateDefaultMsg::HeartRateDefaultMsg() : HeartRateBaseMainDataPageMsg(ANTPLUS_HEARTRATE_DATAPAGE_DEFAULT_NUMBER) { // TODO magic numbers _buffer[1] = 0xFF; diff --git a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateDefault.h b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.h similarity index 56% rename from src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateDefault.h rename to src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.h index a78845a..95f8129 100644 --- a/src/Profiles/HeartRate/DataPages/RX/ANTPLUS_HeartRateDefault.h +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.h @@ -1,11 +1,16 @@ #ifndef ANTPLUS_HEARTRATEDEFAULT_h #define ANTPLUS_HEARTRATEDEFAULT_h -#include +#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..199b7ea --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateManufacturerInformation.cpp @@ -0,0 +1,39 @@ +#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; + +HeartRateManufacturerInformation::HeartRateManufacturerInformation(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp), HeartRateBaseManufacturerInformation() { +} + +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/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..324a615 --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRatePreviousHeartBeat.cpp @@ -0,0 +1,40 @@ +#include +#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; + +HeartRatePreviousHeartBeat::HeartRatePreviousHeartBeat(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp), HeartRateBasePreviousHeartBeat() {} + +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/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..e6c4715 --- /dev/null +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateProductInformation.cpp @@ -0,0 +1,42 @@ +#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; + +HeartRateProductInformation::HeartRateProductInformation(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp), HeartRateBaseProductInformation() {} + +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/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/TX/ANTPLUS_HeartRateSwimIntervalSummaryMsg.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateSwimIntervalSummary.cpp similarity index 53% rename from src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateSwimIntervalSummaryMsg.cpp rename to src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateSwimIntervalSummary.cpp index a91f8df..517a663 100644 --- a/src/Profiles/HeartRate/DataPages/TX/ANTPLUS_HeartRateSwimIntervalSummaryMsg.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateSwimIntervalSummary.cpp @@ -1,7 +1,34 @@ -#include +#include #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; + +HeartRateSwimIntervalSummary::HeartRateSwimIntervalSummary(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp), HeartRateBaseSwimIntervalSummary() {} + HeartRateSwimIntervalSummaryMsg::HeartRateSwimIntervalSummaryMsg() : HeartRateBaseMainDataPageMsg(ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_NUMBER), HeartRateBaseSwimIntervalSummary() { setIntervalAverageHeartRate(ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALAVERAGEHEARTRATE_INVALID); setIntervalMaximumHeartRate(ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALMAXIMUMHEARTRATE_INVALID); @@ -22,3 +49,4 @@ void HeartRateSwimIntervalSummaryMsg::setSessionAverageHeartRate(uint8_t session set8BitValue(sessionAverage, ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_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 1b44f13..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: - explicit 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 e5c2e58..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: - 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]; -}; - -#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.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 7613ef6..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: - explicit 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 d743a1b..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: - explicit 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 fdb3f58..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: - explicit 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_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 6fcdadf..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: - explicit 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 e45adf7..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: - explicit 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 b1376b6..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: - explicit 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 b2c7660..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: - explicit 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.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.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.h b/src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.h index dd1b3bb..f4c4c8b 100644 --- a/src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.h +++ b/src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.h @@ -2,11 +2,9 @@ #define ANTPLUS_PROFILEHEARTRATEDISPLAY_h #include -#include +#include #include -#include "ANT.h" - class ProfileHeartRateDisplay : public BaseSlaveProfile { public: ProfileHeartRateDisplay(); diff --git a/src/Profiles/HeartRate/Monitor/ANTPLUS_ProfileHeartRateMonitor.h b/src/Profiles/HeartRate/Monitor/ANTPLUS_ProfileHeartRateMonitor.h index bb2516a..d4ab0cc 100644 --- a/src/Profiles/HeartRate/Monitor/ANTPLUS_ProfileHeartRateMonitor.h +++ b/src/Profiles/HeartRate/Monitor/ANTPLUS_ProfileHeartRateMonitor.h @@ -2,7 +2,7 @@ #define ANTPLUS_PROFILEHEARTRATEMONITOR_h #include -#include +#include #include #include From 52b815c0fc8e9cfdd11d13db6334f662904cebf5 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 16 Jan 2021 01:53:59 -0800 Subject: [PATCH 090/241] heartrate: move defines into datapages now that datapages are consolidated we can stop writing mile long defines, things are private as they are no longer in a header as well. Also new diff is jsut sub -50 on line count. Added a couple todos but I will be doing this refactor on the other profiles as well this year. --- .../ANTPLUS_HeartRatePrivateDefines.h | 81 +++---------------- .../ANTPLUS_HeartRateBaseMainDataPage.cpp | 51 +++++------- .../ANTPLUS_HeartRateBatteryStatus.cpp | 47 +++++------ .../ANTPLUS_HeartRateCapabilities.cpp | 29 ++++--- ...TPLUS_HeartRateCumulativeOperatingTime.cpp | 17 ++-- .../DataPages/ANTPLUS_HeartRateDefault.cpp | 7 +- ...TPLUS_HeartRateManufacturerInformation.cpp | 32 ++++---- .../ANTPLUS_HeartRatePreviousHeartBeat.cpp | 34 +++++--- .../ANTPLUS_HeartRateProductInformation.cpp | 31 ++++--- .../ANTPLUS_HeartRateSwimIntervalSummary.cpp | 31 +++---- .../ANTPLUS_ProfileHeartRateDisplay.cpp | 20 ++--- .../ANTPLUS_ProfileHeartRateMonitor.cpp | 71 ++++++++-------- 12 files changed, 203 insertions(+), 248 deletions(-) diff --git a/src/Profiles/HeartRate/ANTPLUS_HeartRatePrivateDefines.h b/src/Profiles/HeartRate/ANTPLUS_HeartRatePrivateDefines.h index 1bfecc4..e63a26a 100644 --- a/src/Profiles/HeartRate/ANTPLUS_HeartRatePrivateDefines.h +++ b/src/Profiles/HeartRate/ANTPLUS_HeartRatePrivateDefines.h @@ -2,81 +2,18 @@ #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 // 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 +/* DataPage Numbers */ +#define DEFAULT_NUMBER 0 +#define CUMULATIVEOPERATINGTIME_NUMBER 1 +#define MANUFACTURERINFORMATION_NUMBER 2 +#define PRODUCTINFORMATION_NUMBER 3 +#define PREVIOUSHEARTBEAT_NUMBER 4 +#define SWIMINTERVALSUMMARY_NUMBER 5 +#define CAPABILITIES_NUMBER 6 +#define BATTERYSTATUS_NUMBER 7 #endif // ANTPLUS_HEARTRATEPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.cpp index 9636b74..06b1a5e 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.cpp @@ -2,74 +2,67 @@ #include #include +#define DATAPAGE_BYTE 0 +#define TOGGLE_BYTE 0 +#define HEARTBEATEVENTTIMELSB_BYTE 4 +#define HEARTBEATEVENTTIMEMSB_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() { -} +HeartRateCoreMainDataPage::HeartRateCoreMainDataPage() : CoreDataPage() {} template uint8_t HeartRateCoreMainDataPage::getDataPageNumber() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGEBASE_DATAPAGE_BYTE, - ANTPLUS_HEARTRATE_DATAPAGEBASE_DATAPAGE_MASK); + return this->get8BitValue(DATAPAGE_BYTE, 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); + return this->get8BitValue(TOGGLE_BYTE, TOGGLE_MASK, TOGGLE_SHIFT); } template uint16_t HeartRateCoreMainDataPage::getHeartBeatEventTime() { - return this->get16BitValue( - ANTPLUS_HEARTRATE_DATAPAGEBASE_HEARTBEATEVENTTIMELSB_BYTE, - ANTPLUS_HEARTRATE_DATAPAGEBASE_HEARTBEATEVENTTIMEMSB_BYTE); + return this->get16BitValue(HEARTBEATEVENTTIMELSB_BYTE, HEARTBEATEVENTTIMEMSB_BYTE); } template uint8_t HeartRateCoreMainDataPage::getHeartBeatCount() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGEBASE_HEARTBEATCOUNT_BYTE); + return this->get8BitValue(HEARTBEATCOUNT_BYTE); } template uint8_t HeartRateCoreMainDataPage::getComputedHeartRate() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGEBASE_COMPUTEDHEARTRATE_BYTE); + return this->get8BitValue(COMPUTEDHEARTRATE_BYTE); } template class HeartRateCoreMainDataPage; template class HeartRateCoreMainDataPage; -HeartRateBaseMainDataPage::HeartRateBaseMainDataPage(AntRxDataResponse& dp) : BaseDataPage(dp), HeartRateCoreMainDataPage() { -} +HeartRateBaseMainDataPage::HeartRateBaseMainDataPage(AntRxDataResponse& dp) : BaseDataPage(dp), HeartRateCoreMainDataPage() {} HeartRateBaseMainDataPageMsg::HeartRateBaseMainDataPageMsg(uint8_t dataPageNumber) : BaseDataPageMsg(), HeartRateCoreMainDataPage() { setDataBuffer(_buffer); + // TODO fixup to set data api _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); + set8BitValue(toggle ? 1 : 0, TOGGLE_BYTE, TOGGLE_MASK, TOGGLE_SHIFT); } void HeartRateBaseMainDataPageMsg::setHeartBeatEventTime(uint16_t time) { - set16BitValue(time, - ANTPLUS_HEARTRATE_DATAPAGEBASE_HEARTBEATEVENTTIMELSB_BYTE, - ANTPLUS_HEARTRATE_DATAPAGEBASE_HEARTBEATEVENTTIMEMSB_BYTE); + set16BitValue(time, HEARTBEATEVENTTIMELSB_BYTE, HEARTBEATEVENTTIMEMSB_BYTE); } void HeartRateBaseMainDataPageMsg::setHeartBeatCount(uint8_t count) { - set8BitValue(count, - ANTPLUS_HEARTRATE_DATAPAGEBASE_HEARTBEATCOUNT_BYTE); + set8BitValue(count, HEARTBEATCOUNT_BYTE); } void HeartRateBaseMainDataPageMsg::setComputedHeartRate(uint8_t heartRate) { - set8BitValue(heartRate, - ANTPLUS_HEARTRATE_DATAPAGEBASE_COMPUTEDHEARTRATE_BYTE); + set8BitValue(heartRate, COMPUTEDHEARTRATE_BYTE); } diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBatteryStatus.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBatteryStatus.cpp index 8206862..3b10458 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBatteryStatus.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBatteryStatus.cpp @@ -1,64 +1,65 @@ #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() { -} +HeartRateBaseBatteryStatus::HeartRateBaseBatteryStatus() : + CoreDataPage() {} template uint8_t HeartRateBaseBatteryStatus::getBatteryLevel() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYLEVEL_BYTE); + return this->get8BitValue(BATTERYLEVEL_BYTE); } template uint8_t HeartRateBaseBatteryStatus::getFractionalBatteryVoltage() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE); + return this->get8BitValue(FRACTIONALBATTERYVOLTAGE_BYTE); } template uint8_t HeartRateBaseBatteryStatus::getCoarseBatteryVoltage() { return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_BYTE, - ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_MASK); + COARSEBATTERYVOLTAGE_BYTE, 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); + BATTERYSTATUS_BYTE, BATTERYSTATUS_MASK, BATTERYSTATUS_SHIFT); } template class HeartRateBaseBatteryStatus; template class HeartRateBaseBatteryStatus; -HeartRateBatteryStatus::HeartRateBatteryStatus(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp), HeartRateBaseBatteryStatus() {} +HeartRateBatteryStatus::HeartRateBatteryStatus(AntRxDataResponse& dp) : + HeartRateBaseMainDataPage(dp), + HeartRateBaseBatteryStatus() {} -HeartRateBatteryStatusMsg::HeartRateBatteryStatusMsg() : HeartRateBaseMainDataPageMsg(ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_NUMBER), HeartRateBaseBatteryStatus() { +HeartRateBatteryStatusMsg::HeartRateBatteryStatusMsg() : + HeartRateBaseMainDataPageMsg(BATTERYSTATUS_NUMBER), + HeartRateBaseBatteryStatus() { } void HeartRateBatteryStatusMsg::setBatteryLevel(uint8_t level) { - set8BitValue(level, - ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_BATTERYLEVEL_BYTE); + set8BitValue(level, BATTERYLEVEL_BYTE); } void HeartRateBatteryStatusMsg::setFractionalBatteryVoltage(uint8_t voltage) { - set8BitValue(voltage, - ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE); + set8BitValue(voltage, FRACTIONALBATTERYVOLTAGE_BYTE); } void HeartRateBatteryStatusMsg::setCoarseBatteryVolage(uint8_t voltage) { - set8BitValue(voltage, - ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_BYTE, - ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_MASK); + set8BitValue(voltage, COARSEBATTERYVOLTAGE_BYTE, 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); + BATTERYSTATUS_BYTE, BATTERYSTATUS_MASK, BATTERYSTATUS_SHIFT); } diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCapabilities.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCapabilities.cpp index 4fd9ef1..2e219a6 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCapabilities.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCapabilities.cpp @@ -1,36 +1,39 @@ #include #include +#define FEATURESSUPPORTED_BYTE 2 +#define FEATURESENABLED_BYTE 3 +#define FEATURES_MASK 0xC7 + template -HeartRateBaseCapabilities::HeartRateBaseCapabilities() : CoreDataPage() {} +HeartRateBaseCapabilities::HeartRateBaseCapabilities() : + CoreDataPage() {} template uint8_t HeartRateBaseCapabilities::getFeaturesSupported() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURESSUPPORTED_BYTE); + return this->get8BitValue(FEATURESSUPPORTED_BYTE); } template uint8_t HeartRateBaseCapabilities::getFeaturesEnabled() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURESENABLED_BYTE); + return this->get8BitValue(FEATURESENABLED_BYTE); } template class HeartRateBaseCapabilities; template class HeartRateBaseCapabilities; -HeartRateCapabilities::HeartRateCapabilities(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp), HeartRateBaseCapabilities() {} +HeartRateCapabilities::HeartRateCapabilities(AntRxDataResponse& dp) : + HeartRateBaseMainDataPage(dp), + HeartRateBaseCapabilities() {} -HeartRateCapabilitiesMsg::HeartRateCapabilitiesMsg() : HeartRateBaseMainDataPageMsg(ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_NUMBER), HeartRateBaseCapabilities() {} +HeartRateCapabilitiesMsg::HeartRateCapabilitiesMsg() : + HeartRateBaseMainDataPageMsg(CAPABILITIES_NUMBER), + HeartRateBaseCapabilities() {} void HeartRateCapabilitiesMsg::setFeaturesSupported(uint8_t supported) { - set8BitValue(supported, - ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURESSUPPORTED_BYTE, - ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURES_MASK); + set8BitValue(supported, FEATURESSUPPORTED_BYTE, FEATURES_MASK); } void HeartRateCapabilitiesMsg::setFeaturesEnabled(uint8_t enabled) { - set8BitValue(enabled, - ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURESENABLED_BYTE, - ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURES_MASK); + set8BitValue(enabled, FEATURESENABLED_BYTE, FEATURES_MASK); } diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCumulativeOperatingTime.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCumulativeOperatingTime.cpp index b96bb53..135792e 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCumulativeOperatingTime.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCumulativeOperatingTime.cpp @@ -1,15 +1,15 @@ #include #include +#define TIME_LSB_BYTE 1 +#define TIME_MSB_BYTE 3 + template -HeartRateBaseCumulativeOperatingTime::HeartRateBaseCumulativeOperatingTime() : CoreDataPage() { -} +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); + return this->get24BitValue(TIME_LSB_BYTE, TIME_MSB_BYTE); } template class HeartRateBaseCumulativeOperatingTime; @@ -17,11 +17,8 @@ template class HeartRateBaseCumulativeOperatingTime; HeartRateCumulativeOperatingTime::HeartRateCumulativeOperatingTime(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp), HeartRateBaseCumulativeOperatingTime() {} -HeartRateCumulativeOperatingTimeMsg::HeartRateCumulativeOperatingTimeMsg() : HeartRateBaseMainDataPageMsg(ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER), HeartRateBaseCumulativeOperatingTime() { -} +HeartRateCumulativeOperatingTimeMsg::HeartRateCumulativeOperatingTimeMsg() : HeartRateBaseMainDataPageMsg(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); + set24BitValue(time, TIME_LSB_BYTE, TIME_MSB_BYTE); } diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.cpp index b0786e7..d838bfe 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.cpp @@ -1,10 +1,11 @@ #include #include -HeartRateDefault::HeartRateDefault(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp) { -} +HeartRateDefault::HeartRateDefault(AntRxDataResponse& dp) : + HeartRateBaseMainDataPage(dp) {} -HeartRateDefaultMsg::HeartRateDefaultMsg() : HeartRateBaseMainDataPageMsg(ANTPLUS_HEARTRATE_DATAPAGE_DEFAULT_NUMBER) { +HeartRateDefaultMsg::HeartRateDefaultMsg() : + HeartRateBaseMainDataPageMsg(DEFAULT_NUMBER) { // TODO magic numbers _buffer[1] = 0xFF; _buffer[2] = 0xFF; diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateManufacturerInformation.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateManufacturerInformation.cpp index 199b7ea..37bc729 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateManufacturerInformation.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateManufacturerInformation.cpp @@ -1,39 +1,39 @@ #include #include +#define MANUFACTUREREIDLSB_BYTE 1 +#define SERIALNUMBERLSB_BYTE 2 +#define SERIALNUMBERMSB_BYTE 3 + template -HeartRateBaseManufacturerInformation::HeartRateBaseManufacturerInformation() : CoreDataPage() { -} +HeartRateBaseManufacturerInformation::HeartRateBaseManufacturerInformation() : + CoreDataPage() {} template uint8_t HeartRateBaseManufacturerInformation::getManufacturerIdLsb() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_MANUFACTUREREIDLSB_BYTE); + return this->get8BitValue(MANUFACTUREREIDLSB_BYTE); } template uint16_t HeartRateBaseManufacturerInformation::getSerialNumber() { - return this->get16BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_SERIALNUMBERLSB_BYTE, - ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_SERIALNUMBERMSB_BYTE); + return this->get16BitValue(SERIALNUMBERLSB_BYTE, SERIALNUMBERMSB_BYTE); } template class HeartRateBaseManufacturerInformation; template class HeartRateBaseManufacturerInformation; -HeartRateManufacturerInformation::HeartRateManufacturerInformation(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp), HeartRateBaseManufacturerInformation() { -} +HeartRateManufacturerInformation::HeartRateManufacturerInformation(AntRxDataResponse& dp) : + HeartRateBaseMainDataPage(dp), + HeartRateBaseManufacturerInformation() {} -HeartRateManufacturerInformationMsg::HeartRateManufacturerInformationMsg() : HeartRateBaseMainDataPageMsg(ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER), HeartRateBaseManufacturerInformation() { -} +HeartRateManufacturerInformationMsg::HeartRateManufacturerInformationMsg() : + HeartRateBaseMainDataPageMsg(MANUFACTURERINFORMATION_NUMBER), + HeartRateBaseManufacturerInformation() {} void HeartRateManufacturerInformationMsg::setManufacturerIdLsb(uint8_t id) { - set8BitValue(id, - ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_MANUFACTUREREIDLSB_BYTE); + set8BitValue(id, MANUFACTUREREIDLSB_BYTE); } void HeartRateManufacturerInformationMsg::setSerialNumber(uint16_t serialNumber) { - set16BitValue(serialNumber, - ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_SERIALNUMBERLSB_BYTE, - ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_SERIALNUMBERMSB_BYTE); + set16BitValue(serialNumber, SERIALNUMBERLSB_BYTE, SERIALNUMBERMSB_BYTE); } diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRatePreviousHeartBeat.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRatePreviousHeartBeat.cpp index 324a615..16948e3 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRatePreviousHeartBeat.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRatePreviousHeartBeat.cpp @@ -2,39 +2,47 @@ #include #include +#define MANUFACTURERSPECIFIC_BYTE 1 +#define PREVIOUSHEARTBEATEVENTTIME_LSB_BYTE 2 +#define PREVIOUSHEARTBEATEVENTTIME_MSB_BYTE 3 + template -HeartRateBasePreviousHeartBeat::HeartRateBasePreviousHeartBeat() : CoreDataPage() { -} +HeartRateBasePreviousHeartBeat::HeartRateBasePreviousHeartBeat() : + CoreDataPage() {} template uint8_t HeartRateBasePreviousHeartBeat::getManufacturerSpecific() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_MANUFACTURERSPECIFIC_BYTE); + return this->get8BitValue(MANUFACTURERSPECIFIC_BYTE); } template uint16_t HeartRateBasePreviousHeartBeat::getPreviousHeartBeatEventTime() { return this->get16BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_PREVIOUSHEARTBEATEVENTTIMELSB_BYTE, - ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_PREVIOUSHEARTBEATEVENTTIMEMSB_BYTE); + PREVIOUSHEARTBEATEVENTTIME_LSB_BYTE, + PREVIOUSHEARTBEATEVENTTIME_MSB_BYTE); } template class HeartRateBasePreviousHeartBeat; template class HeartRateBasePreviousHeartBeat; -HeartRatePreviousHeartBeat::HeartRatePreviousHeartBeat(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp), HeartRateBasePreviousHeartBeat() {} +HeartRatePreviousHeartBeat::HeartRatePreviousHeartBeat(AntRxDataResponse& dp) : + HeartRateBaseMainDataPage(dp), + HeartRateBasePreviousHeartBeat() {} -HeartRatePreviousHeartBeatMsg::HeartRatePreviousHeartBeatMsg() : HeartRateBaseMainDataPageMsg(ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_NUMBER), HeartRateBasePreviousHeartBeat() { - setManufacturerSpecific(ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_MANUFACTURERSPECIFIC_INVALID); +// TODO add isValid method to manufactueres byte +HeartRatePreviousHeartBeatMsg::HeartRatePreviousHeartBeatMsg() : + HeartRateBaseMainDataPageMsg(PREVIOUSHEARTBEAT_NUMBER), + HeartRateBasePreviousHeartBeat() { + setManufacturerSpecific( + ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_MANUFACTURERSPECIFIC_INVALID); } void HeartRatePreviousHeartBeatMsg::setManufacturerSpecific(uint8_t specificByte) { - set8BitValue(specificByte, - ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_MANUFACTURERSPECIFIC_BYTE); + set8BitValue(specificByte, MANUFACTURERSPECIFIC_BYTE); } void HeartRatePreviousHeartBeatMsg::setPreviousHeartBeatEventTime(uint16_t eventTime) { set16BitValue(eventTime, - ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_PREVIOUSHEARTBEATEVENTTIMELSB_BYTE, - ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_PREVIOUSHEARTBEATEVENTTIMEMSB_BYTE); + PREVIOUSHEARTBEATEVENTTIME_LSB_BYTE, + PREVIOUSHEARTBEATEVENTTIME_MSB_BYTE); } diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateProductInformation.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateProductInformation.cpp index e6c4715..222b154 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateProductInformation.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateProductInformation.cpp @@ -1,42 +1,49 @@ #include #include +#define HARDWAREVERSION_BYTE 1 +#define SOFTWAREVERSION_BYTE 2 +#define MODELNUMBER_BYTE 3 + template -HeartRateBaseProductInformation::HeartRateBaseProductInformation() : CoreDataPage() {} +HeartRateBaseProductInformation::HeartRateBaseProductInformation() : + CoreDataPage() {} template uint8_t HeartRateBaseProductInformation::getHardwareVersion() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_HARDWAREVERSION_BYTE); + return this->get8BitValue(HARDWAREVERSION_BYTE); } template uint8_t HeartRateBaseProductInformation::getSoftwareVersion() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_SOFTWAREVERSION_BYTE); + return this->get8BitValue(SOFTWAREVERSION_BYTE); } template uint8_t HeartRateBaseProductInformation::getModelNumber() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_MODELNUMBER_BYTE); + return this->get8BitValue(MODELNUMBER_BYTE); } template class HeartRateBaseProductInformation; template class HeartRateBaseProductInformation; -HeartRateProductInformation::HeartRateProductInformation(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp), HeartRateBaseProductInformation() {} +HeartRateProductInformation::HeartRateProductInformation(AntRxDataResponse& dp) : + HeartRateBaseMainDataPage(dp), + HeartRateBaseProductInformation() {} -HeartRateProductInformationMsg::HeartRateProductInformationMsg() : HeartRateBaseMainDataPageMsg(ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_NUMBER) {} +HeartRateProductInformationMsg::HeartRateProductInformationMsg() : + HeartRateBaseMainDataPageMsg(PRODUCTINFORMATION_NUMBER), + HeartRateBaseProductInformation() {} +// TODO set to product information API void HeartRateProductInformationMsg::setHardwareVersion(uint8_t hwVersion) { - _buffer[ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_HARDWAREVERSION_BYTE] = hwVersion; + _buffer[HARDWAREVERSION_BYTE] = hwVersion; } void HeartRateProductInformationMsg::setSoftwareVersion(uint8_t swVersion) { - _buffer[ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_SOFTWAREVERSION_BYTE] = swVersion; + _buffer[SOFTWAREVERSION_BYTE] = swVersion; } void HeartRateProductInformationMsg::setModelNumber(uint8_t modelNumber) { - _buffer[ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_MODELNUMBER_BYTE] = modelNumber; + _buffer[MODELNUMBER_BYTE] = modelNumber; } diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateSwimIntervalSummary.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateSwimIntervalSummary.cpp index 517a663..19b6575 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateSwimIntervalSummary.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateSwimIntervalSummary.cpp @@ -2,51 +2,54 @@ #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( - ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALAVERAGEHEARTRATE_BYTE); + return this->get8BitValue(INTERVALAVERAGEHEARTRATE_BYTE); } template uint8_t HeartRateBaseSwimIntervalSummary::getIntervalMaximumHeartRate() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALMAXIMUMHEARTRATE_BYTE); + return this->get8BitValue(INTERVALMAXIMUMHEARTRATE_BYTE); } template uint8_t HeartRateBaseSwimIntervalSummary::getSessionAverageHeartRate() { - return this->get8BitValue( - ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_SESSIONAVERAGEHEARTRATE_BYTE); + return this->get8BitValue(SESSIONAVERAGEHEARTRATE_BYTE); } template class HeartRateBaseSwimIntervalSummary; template class HeartRateBaseSwimIntervalSummary; -HeartRateSwimIntervalSummary::HeartRateSwimIntervalSummary(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp), HeartRateBaseSwimIntervalSummary() {} +HeartRateSwimIntervalSummary::HeartRateSwimIntervalSummary(AntRxDataResponse& dp) : + HeartRateBaseMainDataPage(dp), + HeartRateBaseSwimIntervalSummary() {} -HeartRateSwimIntervalSummaryMsg::HeartRateSwimIntervalSummaryMsg() : HeartRateBaseMainDataPageMsg(ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_NUMBER), HeartRateBaseSwimIntervalSummary() { +// TODO add isValid methods +HeartRateSwimIntervalSummaryMsg::HeartRateSwimIntervalSummaryMsg() : + HeartRateBaseMainDataPageMsg(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); + set8BitValue(intervalAverage, INTERVALAVERAGEHEARTRATE_BYTE); } void HeartRateSwimIntervalSummaryMsg::setIntervalMaximumHeartRate(uint8_t intervalMaximum) { - set8BitValue(intervalMaximum, - ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALMAXIMUMHEARTRATE_BYTE); + set8BitValue(intervalMaximum, INTERVALMAXIMUMHEARTRATE_BYTE); } void HeartRateSwimIntervalSummaryMsg::setSessionAverageHeartRate(uint8_t sessionAverage) { - set8BitValue(sessionAverage, - ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_SESSIONAVERAGEHEARTRATE_BYTE); + set8BitValue(sessionAverage, SESSIONAVERAGEHEARTRATE_BYTE); } diff --git a/src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.cpp b/src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.cpp index 0efa5b2..9a0849a 100644 --- a/src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.cpp +++ b/src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.cpp @@ -4,6 +4,8 @@ #include #include +#define DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE + ProfileHeartRateDisplay::ProfileHeartRateDisplay() : BaseSlaveProfile() { setChannelConfig(); } @@ -29,28 +31,28 @@ bool ProfileHeartRateDisplay::handleDataPage(HeartRateBaseMainDataPage& dp) { bool called = false; switch (dataPage) { - case ANTPLUS_HEARTRATE_DATAPAGE_DEFAULT_NUMBER: + case DEFAULT_NUMBER: called = handleDefault(dp); break; - case ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER: + case CUMULATIVEOPERATINGTIME_NUMBER: called = handleCumulativeOperatingTime(dp); break; - case ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER: + case MANUFACTURERINFORMATION_NUMBER: called = handleManufacturerInformation(dp); break; - case ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_NUMBER: + case PRODUCTINFORMATION_NUMBER: called = handleProductInformation(dp); break; - case ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_NUMBER: + case PREVIOUSHEARTBEAT_NUMBER: called = handlePreviousHeartBeat(dp); break; - case ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_NUMBER: + case SWIMINTERVALSUMMARY_NUMBER: called = handleSwimIntervalSummary(dp); break; - case ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_NUMBER: + case BATTERYSTATUS_NUMBER: called = handleBatteryStatus(dp); break; - case ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_NUMBER: + case CAPABILITIES_NUMBER: called = handleCapabilities(dp); break; } @@ -68,7 +70,7 @@ 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); diff --git a/src/Profiles/HeartRate/Monitor/ANTPLUS_ProfileHeartRateMonitor.cpp b/src/Profiles/HeartRate/Monitor/ANTPLUS_ProfileHeartRateMonitor.cpp index 875450e..59bc529 100644 --- a/src/Profiles/HeartRate/Monitor/ANTPLUS_ProfileHeartRateMonitor.cpp +++ b/src/Profiles/HeartRate/Monitor/ANTPLUS_ProfileHeartRateMonitor.cpp @@ -3,11 +3,13 @@ #include #include +#define MONITOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT + ProfileHeartRateMonitor::ProfileHeartRateMonitor( uint16_t deviceNumber, uint8_t transmissionType) : BaseMasterProfile(deviceNumber, transmissionType), - _nextBackgroundPage(ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER), + _nextBackgroundPage(MANUFACTURERINFORMATION_NUMBER), _flags(0) { setChannelConfig(); } @@ -17,7 +19,7 @@ ProfileHeartRateMonitor::ProfileHeartRateMonitor( uint8_t transmissionType, uint32_t flags) : BaseMasterProfile(deviceNumber, transmissionType), - _nextBackgroundPage(ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER), + _nextBackgroundPage(MANUFACTURERINFORMATION_NUMBER), _flags(flags) { setChannelConfig(); } @@ -90,35 +92,35 @@ void ProfileHeartRateMonitor::transmitPrimaryDataPage() { void ProfileHeartRateMonitor::transmitBackgroundDataPage() { switch (_nextBackgroundPage) { - case ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER: + case CUMULATIVEOPERATINGTIME_NUMBER: transmitHeartRateCumulativeOperatingTimeMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER: + case MANUFACTURERINFORMATION_NUMBER: transmitHeartRateManufacturerInformationMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_NUMBER: + case PRODUCTINFORMATION_NUMBER: transmitHeartRateProductInformationMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_NUMBER: + case BATTERYSTATUS_NUMBER: transmitHeartRateBatteryStatusMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_NUMBER: + case 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 < CUMULATIVEOPERATINGTIME_NUMBER) && (_flags & ANTPLUS_HEARTRATE_FLAGS_CUMULATIVEOPERATINGTIME_SUPPORTED)) { + return CUMULATIVEOPERATINGTIME_NUMBER; + } else if (currentPage < MANUFACTURERINFORMATION_NUMBER) { + return MANUFACTURERINFORMATION_NUMBER; + } else if (currentPage < PRODUCTINFORMATION_NUMBER) { + return PRODUCTINFORMATION_NUMBER; + } else if ((currentPage < CAPABILITIES_NUMBER) && (_flags & ANTPLUS_HEARTRATE_FLAGS_EXTENTED_FEATURES)) { + return CAPABILITIES_NUMBER; + } else if ((currentPage < BATTERYSTATUS_NUMBER) && (_flags & ANTPLUS_HEARTRATE_FLAGS_BATTERYSTATUS_SUPPORTED)) { + return BATTERYSTATUS_NUMBER; } else { // Reached end of the loop, start again return getNextBackgroundPage(0); @@ -128,28 +130,28 @@ uint8_t ProfileHeartRateMonitor::getNextBackgroundPage(uint8_t currentPage) { void ProfileHeartRateMonitor::transmitRequestedDataPage() { uint8_t requestedPage = getRequestedPage(); switch (requestedPage) { - case ANTPLUS_HEARTRATE_DATAPAGE_DEFAULT_NUMBER: + case DEFAULT_NUMBER: transmitHeartRateDefaultMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER: + case CUMULATIVEOPERATINGTIME_NUMBER: transmitHeartRateCumulativeOperatingTimeMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER: + case MANUFACTURERINFORMATION_NUMBER: transmitHeartRateManufacturerInformationMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_NUMBER: + case PRODUCTINFORMATION_NUMBER: transmitHeartRateProductInformationMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_NUMBER: + case PREVIOUSHEARTBEAT_NUMBER: transmitHeartRatePreviousHeartBeatMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_NUMBER: + case SWIMINTERVALSUMMARY_NUMBER: transmitHeartRateSwimIntervalSummaryMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_NUMBER: + case CAPABILITIES_NUMBER: transmitHeartRateCapabilitiesMsg(); break; - case ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_NUMBER: + case BATTERYSTATUS_NUMBER: transmitHeartRateBatteryStatusMsg(); break; } @@ -213,19 +215,20 @@ void ProfileHeartRateMonitor::transmitHeartRateMsg(HeartRateBaseMainDataPageMsg& bool ProfileHeartRateMonitor::isDataPageValid(uint8_t dataPage) { switch (dataPage) { - case ANTPLUS_HEARTRATE_DATAPAGE_DEFAULT_NUMBER: + case DEFAULT_NUMBER: + // TODO double check this is correct that dp 4 is only needed if imlemented return !(_flags & ANTPLUS_HEARTRATE_FLAGS_PREVIOUSHEARTBEAT_SUPPORTED); - case ANTPLUS_HEARTRATE_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER: + case CUMULATIVEOPERATINGTIME_NUMBER: return _flags & ANTPLUS_HEARTRATE_FLAGS_CUMULATIVEOPERATINGTIME_SUPPORTED; - case ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER: - case ANTPLUS_HEARTRATE_DATAPAGE_PRODUCTINFORMATION_NUMBER: + case MANUFACTURERINFORMATION_NUMBER: + case PRODUCTINFORMATION_NUMBER: return true; - case ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_NUMBER: + case PREVIOUSHEARTBEAT_NUMBER: return _flags & ANTPLUS_HEARTRATE_FLAGS_PREVIOUSHEARTBEAT_SUPPORTED; - case ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_NUMBER: - case ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_NUMBER: + case SWIMINTERVALSUMMARY_NUMBER: + case CAPABILITIES_NUMBER: return _flags & ANTPLUS_HEARTRATE_FLAGS_EXTENTED_FEATURES; - case ANTPLUS_HEARTRATE_DATAPAGE_BATTERYSTATUS_NUMBER: + case BATTERYSTATUS_NUMBER: return _flags & ANTPLUS_HEARTRATE_FLAGS_BATTERYSTATUS_SUPPORTED; default: return false; @@ -243,7 +246,7 @@ 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); From b033b463aa645b3274654bd3dceea6d07fc357a3 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 16 Jan 2021 02:24:46 -0800 Subject: [PATCH 091/241] heartrate: move profile implementations into common folder there is no reason for a header and cpp file to have their own folder --- src/Profiles/HeartRate/ANTPLUS_HeartRateProfile.h | 4 ++-- .../{Display => Profiles}/ANTPLUS_ProfileHeartRateDisplay.cpp | 2 +- .../{Display => Profiles}/ANTPLUS_ProfileHeartRateDisplay.h | 0 .../{Monitor => Profiles}/ANTPLUS_ProfileHeartRateMonitor.cpp | 2 +- .../{Monitor => Profiles}/ANTPLUS_ProfileHeartRateMonitor.h | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename src/Profiles/HeartRate/{Display => Profiles}/ANTPLUS_ProfileHeartRateDisplay.cpp (98%) rename src/Profiles/HeartRate/{Display => Profiles}/ANTPLUS_ProfileHeartRateDisplay.h (100%) rename src/Profiles/HeartRate/{Monitor => Profiles}/ANTPLUS_ProfileHeartRateMonitor.cpp (99%) rename src/Profiles/HeartRate/{Monitor => Profiles}/ANTPLUS_ProfileHeartRateMonitor.h (100%) diff --git a/src/Profiles/HeartRate/ANTPLUS_HeartRateProfile.h b/src/Profiles/HeartRate/ANTPLUS_HeartRateProfile.h index 6a11d58..4612807 100644 --- a/src/Profiles/HeartRate/ANTPLUS_HeartRateProfile.h +++ b/src/Profiles/HeartRate/ANTPLUS_HeartRateProfile.h @@ -8,7 +8,7 @@ #include // Profile Classes -#include -#include +#include +#include #endif // ANTPLUS_HEARTRATEPROFILE_h diff --git a/src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.cpp b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp similarity index 98% rename from src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.cpp rename to src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp index 9a0849a..ea3b148 100644 --- a/src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.cpp +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.h b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.h similarity index 100% rename from src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.h rename to src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.h diff --git a/src/Profiles/HeartRate/Monitor/ANTPLUS_ProfileHeartRateMonitor.cpp b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp similarity index 99% rename from src/Profiles/HeartRate/Monitor/ANTPLUS_ProfileHeartRateMonitor.cpp rename to src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp index 59bc529..91e9f4a 100644 --- a/src/Profiles/HeartRate/Monitor/ANTPLUS_ProfileHeartRateMonitor.cpp +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/src/Profiles/HeartRate/Monitor/ANTPLUS_ProfileHeartRateMonitor.h b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.h similarity index 100% rename from src/Profiles/HeartRate/Monitor/ANTPLUS_ProfileHeartRateMonitor.h rename to src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.h From 7e96df99272e8f9e3ea19efae59533cc02c05cf6 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 16 Jan 2021 13:52:19 -0800 Subject: [PATCH 092/241] power: refactor datapages step 1 consolidate pages, dividing number of files almost by 3 --- .../ANTPLUS_BicyclePowerProfile.h | 2 +- .../ANTPLUS_ProfileBicyclePowerDataPages.h | 9 +++ .../ANTPLUS_BicyclePowerBaseMainDataPage.cpp | 21 +++++++ .../ANTPLUS_BicyclePowerBaseMainDataPage.h | 9 ++- ...TPLUS_BicyclePowerStandardCrankTorque.cpp} | 10 ++- .../ANTPLUS_BicyclePowerStandardCrankTorque.h | 21 +++++++ .../ANTPLUS_BicyclePowerStandardPowerOnly.cpp | 61 +++++++++++++++++++ .../ANTPLUS_BicyclePowerStandardPowerOnly.h | 31 ++++++++++ ...TPLUS_BicyclePowerStandardWheelTorque.cpp} | 10 ++- .../ANTPLUS_BicyclePowerStandardWheelTorque.h | 21 +++++++ ...TorqueEffectivenessAndPedalSmoothness.cpp} | 6 +- ...werTorqueEffectivenessAndPedalSmoothness.h | 21 +++++++ .../ANTPLUS_ProfileBicyclePowerDataPages.h | 13 ---- .../ANTPLUS_BicyclePowerBaseMainDataPage.cpp | 14 ----- ...PLUS_BicyclePowerBaseStandardCrankTorque.h | 18 ------ ...PLUS_BicyclePowerBaseStandardPowerOnly.cpp | 35 ----------- ...NTPLUS_BicyclePowerBaseStandardPowerOnly.h | 18 ------ ...PLUS_BicyclePowerBaseStandardWheelTorque.h | 18 ------ ...aseTorqueEffectivenessAndPedalSmoothness.h | 18 ------ ...NTPLUS_BicyclePowerStandardCrankTorque.cpp | 3 - .../ANTPLUS_BicyclePowerStandardCrankTorque.h | 12 ---- .../ANTPLUS_BicyclePowerStandardPowerOnly.cpp | 6 -- .../ANTPLUS_BicyclePowerStandardPowerOnly.h | 14 ----- ...NTPLUS_BicyclePowerStandardWheelTorque.cpp | 3 - .../ANTPLUS_BicyclePowerStandardWheelTorque.h | 12 ---- ...rTorqueEffectivenessAndPedalSmoothness.cpp | 4 -- ...werTorqueEffectivenessAndPedalSmoothness.h | 12 ---- ...TPLUS_BicyclePowerStandardPowerOnlyMsg.cpp | 24 -------- ...ANTPLUS_BicyclePowerStandardPowerOnlyMsg.h | 18 ------ .../ANTPLUS_ProfileBicyclePowerDisplay.h | 2 +- .../ANTPLUS_ProfileBicyclePowerSensor.h | 2 +- 31 files changed, 214 insertions(+), 254 deletions(-) create mode 100644 src/Profiles/BicyclePower/ANTPLUS_ProfileBicyclePowerDataPages.h create mode 100644 src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.cpp rename src/Profiles/BicyclePower/DataPages/{Base => }/ANTPLUS_BicyclePowerBaseMainDataPage.h (61%) rename src/Profiles/BicyclePower/DataPages/{Base/ANTPLUS_BicyclePowerBaseStandardCrankTorque.cpp => ANTPLUS_BicyclePowerStandardCrankTorque.cpp} (80%) create mode 100644 src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.h create mode 100644 src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp create mode 100644 src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.h rename src/Profiles/BicyclePower/DataPages/{Base/ANTPLUS_BicyclePowerBaseStandardWheelTorque.cpp => ANTPLUS_BicyclePowerStandardWheelTorque.cpp} (80%) create mode 100644 src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.h rename src/Profiles/BicyclePower/DataPages/{Base/ANTPLUS_BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness.cpp => ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.cpp} (79%) create mode 100644 src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.h delete mode 100644 src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h delete mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.cpp delete mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseStandardCrankTorque.h delete mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseStandardPowerOnly.cpp delete mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseStandardPowerOnly.h delete mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseStandardWheelTorque.h delete mode 100644 src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness.h delete mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardCrankTorque.cpp delete mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardCrankTorque.h delete mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardPowerOnly.cpp delete mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardPowerOnly.h delete mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardWheelTorque.cpp delete mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardWheelTorque.h delete mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.cpp delete mode 100644 src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.h delete mode 100644 src/Profiles/BicyclePower/DataPages/TX/ANTPLUS_BicyclePowerStandardPowerOnlyMsg.cpp delete mode 100644 src/Profiles/BicyclePower/DataPages/TX/ANTPLUS_BicyclePowerStandardPowerOnlyMsg.h diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h index d9cb805..53b24b2 100644 --- a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h @@ -5,7 +5,7 @@ #include // Datapages -#include +#include // Profile Classes #include diff --git a/src/Profiles/BicyclePower/ANTPLUS_ProfileBicyclePowerDataPages.h b/src/Profiles/BicyclePower/ANTPLUS_ProfileBicyclePowerDataPages.h new file mode 100644 index 0000000..36fe808 --- /dev/null +++ b/src/Profiles/BicyclePower/ANTPLUS_ProfileBicyclePowerDataPages.h @@ -0,0 +1,9 @@ +#ifndef ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h +#define ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h + +#include +#include +#include +#include + +#endif // ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_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..555773e --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +BicyclePowerBaseMainDataPage::BicyclePowerBaseMainDataPage(AntRxDataResponse& dp) : + BaseDataPage(dp) {} + +// TODO move down since this isn't common to all classes +uint8_t BicyclePowerBaseMainDataPage::getDataPageNumber() { + return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_BYTE); +} + +uint8_t BicyclePowerBaseMainDataPage::getUpdateEventCount() { + return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_UPDATEEVENTCOUNT_BYTE); +} + +BicyclePowerBaseMainDataPageMsg::BicyclePowerBaseMainDataPageMsg(uint8_t dataPageNumber) : + BaseDataPageMsg() { + setDataBuffer(_buffer); + set8BitValue(dataPageNumber, ANTPLUS_DEFAULT_DATAPAGE_BYTE); +}; diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.h similarity index 61% rename from src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.h rename to src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.h index 9b5f8ad..269c2a5 100644 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.h +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.h @@ -2,15 +2,20 @@ #define ANTPLUS_BICYCLEPOWERBASEMAINDATAPAGE_h #include - -#include "ANT.h" +#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); +protected: + uint8_t _buffer[MESSAGE_SIZE]; }; #endif // ANTPLUS_BICYCLEPOWERPOWERONLYDATAPAGE_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseStandardCrankTorque.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.cpp similarity index 80% rename from src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseStandardCrankTorque.cpp rename to src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.cpp index ebfd8cc..a2d1925 100644 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseStandardCrankTorque.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.cpp @@ -1,9 +1,9 @@ -#include +#include #include template -BicyclePowerBaseStandardCrankTorque::BicyclePowerBaseStandardCrankTorque() : CoreDataPage() { -} +BicyclePowerBaseStandardCrankTorque::BicyclePowerBaseStandardCrankTorque() : + CoreDataPage() {} template uint8_t BicyclePowerBaseStandardCrankTorque::getCrankTicks() { @@ -33,3 +33,7 @@ uint16_t BicyclePowerBaseStandardCrankTorque::getAccumulatedTorque() { template class BicyclePowerBaseStandardCrankTorque; template class BicyclePowerBaseStandardCrankTorque; + +BicyclePowerStandardCrankTorque::BicyclePowerStandardCrankTorque(AntRxDataResponse& dp) : + BicyclePowerBaseMainDataPage(dp), + BicyclePowerBaseStandardCrankTorque() {} diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.h new file mode 100644 index 0000000..30aa934 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.h @@ -0,0 +1,21 @@ +#ifndef ANTPLUS_BICYCLEPOWERSTANDARDCRANKTORQUE_h +#define ANTPLUS_BICYCLEPOWERSTANDARDCRANKTORQUE_h + +#include + +template +class BicyclePowerBaseStandardCrankTorque : virtual public CoreDataPage { +public: + BicyclePowerBaseStandardCrankTorque(); + uint8_t getCrankTicks(); + uint8_t getInstantCadence(); // May not be available, 0xFF indicates invalid + uint16_t getCrankPeriod(); + uint16_t getAccumulatedTorque(); +}; + +class BicyclePowerStandardCrankTorque : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseStandardCrankTorque { +public: + explicit BicyclePowerStandardCrankTorque(AntRxDataResponse& dp); +}; + +#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..a7e5be5 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp @@ -0,0 +1,61 @@ +#include +#include +#include + +template +BicyclePowerBaseStandardPowerOnly::BicyclePowerBaseStandardPowerOnly() : + CoreDataPage() {} + +template +uint8_t BicyclePowerBaseStandardPowerOnly::getPedalPower() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_PEDALPOWER_BYTE); +} + +template +uint8_t BicyclePowerBaseStandardPowerOnly::getInstantaneousCadence() { + return this->get8BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSCADENCE_BYTE); +} + +template +uint16_t BicyclePowerBaseStandardPowerOnly::getAccumulatedPower() { + return this->get16BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWER_LSB_BYTE, + ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWER_MSB_BYTE); +} + +template +uint16_t BicyclePowerBaseStandardPowerOnly::getInstantaneousPower() { + return this->get16BitValue( + ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWER_LSB_BYTE, + ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWER_MSB_BYTE); +} + +template class BicyclePowerBaseStandardPowerOnly; +template class BicyclePowerBaseStandardPowerOnly; + +BicyclePowerStandardPowerOnly::BicyclePowerStandardPowerOnly(AntRxDataResponse& dp) : + BicyclePowerBaseMainDataPage(dp), + BicyclePowerBaseStandardPowerOnly() {} + +BicyclePowerStandardPowerOnlyMsg::BicyclePowerStandardPowerOnlyMsg() : + BicyclePowerBaseMainDataPageMsg(ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_NUMBER), + BicyclePowerBaseStandardPowerOnly() { + _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_PEDALPOWER_BYTE] = 0xFF; + _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSCADENCE_BYTE] = 0xFF; +} + +void BicyclePowerStandardPowerOnlyMsg::setUpdateEventCount(uint8_t eventCount) { + _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_UPDATEEVENTCOUNT_BYTE] = eventCount; +} + +void BicyclePowerStandardPowerOnlyMsg::setCumulativePowerCount(uint16_t accPower) { + _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWER_MSB_BYTE] = accPower >> 8; + _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWER_LSB_BYTE] = accPower & ANTPLUS_DEFAULT_BYTE_MASK; +} + +void BicyclePowerStandardPowerOnlyMsg::setInstataneousPowerCount(uint16_t power) { + _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWER_MSB_BYTE] = power >> 8; + _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWER_LSB_BYTE] = power & ANTPLUS_DEFAULT_BYTE_MASK; +} diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.h new file mode 100644 index 0000000..7e1cd67 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.h @@ -0,0 +1,31 @@ +#ifndef ANTPLUS_BICYCLEPOWERSTANDARDPOWERONLY_h +#define ANTPLUS_BICYCLEPOWERSTANDARDPOWERONLY_h + +#include + +template +class BicyclePowerBaseStandardPowerOnly : virtual public CoreDataPage { +public: + BicyclePowerBaseStandardPowerOnly(); + uint8_t getPedalPower(); + 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 setUpdateEventCount(uint8_t eventCount); + void setCumulativePowerCount(uint16_t accPower); + void setInstataneousPowerCount(uint16_t power); +protected: + uint8_t _buffer[MESSAGE_SIZE]; +}; + +#endif // ANTPLUS_BICYCLEPOWERSTANDARDPOWERONLY_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseStandardWheelTorque.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.cpp similarity index 80% rename from src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseStandardWheelTorque.cpp rename to src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.cpp index 317e3ad..56aa52a 100644 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseStandardWheelTorque.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.cpp @@ -1,9 +1,9 @@ -#include +#include #include template -BicyclePowerBaseStandardWheelTorque::BicyclePowerBaseStandardWheelTorque() : CoreDataPage() { -} +BicyclePowerBaseStandardWheelTorque::BicyclePowerBaseStandardWheelTorque() : + CoreDataPage() {} template uint8_t BicyclePowerBaseStandardWheelTorque::getWheelTicks() { @@ -33,3 +33,7 @@ uint16_t BicyclePowerBaseStandardWheelTorque::getAccumulatedTorque() { template class BicyclePowerBaseStandardWheelTorque; template class BicyclePowerBaseStandardWheelTorque; + +BicyclePowerStandardWheelTorque::BicyclePowerStandardWheelTorque(AntRxDataResponse& dp) : + BicyclePowerBaseMainDataPage(dp), + BicyclePowerBaseStandardWheelTorque() {} diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.h new file mode 100644 index 0000000..4832c48 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.h @@ -0,0 +1,21 @@ +#ifndef ANTPLUS_BICYCLEPOWERSTANDARDWHEELTORQUE_h +#define ANTPLUS_BICYCLEPOWERSTANDARDWHEELTORQUE_h + +#include + +template +class BicyclePowerBaseStandardWheelTorque : virtual public CoreDataPage { +public: + BicyclePowerBaseStandardWheelTorque(); + uint8_t getWheelTicks(); + uint8_t getInstantCadence(); // May not be available, 0xFF indicates invalid + uint16_t getWheelPeriod(); + uint16_t getAccumulatedTorque(); +}; + +class BicyclePowerStandardWheelTorque : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseStandardWheelTorque { +public: + explicit BicyclePowerStandardWheelTorque(AntRxDataResponse& dp); +}; + +#endif // ANTPLUS_BICYCLEPOWERSTANDARDWHEELTORQUE_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.cpp similarity index 79% rename from src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness.cpp rename to src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.cpp index ee21c72..c6a322f 100644 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.cpp @@ -1,4 +1,4 @@ -#include +#include #include template @@ -31,3 +31,7 @@ uint8_t BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness::getRightPedalS template class BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness; template class BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness; + +BicyclePowerTorqueEffectivenessAndPedalSmoothness::BicyclePowerTorqueEffectivenessAndPedalSmoothness(AntRxDataResponse& dp) : + BicyclePowerBaseMainDataPage(dp), + BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness() {} diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.h new file mode 100644 index 0000000..63bb954 --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.h @@ -0,0 +1,21 @@ +#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); +}; + +#endif // ANTPLUS_BICYCLEPOWERPEDALSMOOTHNESS_h diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h deleted file mode 100644 index cd7bf10..0000000 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_ProfileBicyclePowerDataPages.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h -#define ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h - -/* RX */ -#include -#include -#include -#include - -/* TX */ -#include - -#endif // ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.cpp deleted file mode 100644 index 3d62d71..0000000 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseMainDataPage.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include - -BicyclePowerBaseMainDataPage::BicyclePowerBaseMainDataPage(AntRxDataResponse& dp) : BaseDataPage(dp) { - -} - -uint8_t BicyclePowerBaseMainDataPage::getDataPageNumber() { - return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_BYTE); -} - -uint8_t BicyclePowerBaseMainDataPage::getUpdateEventCount() { - return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_UPDATEEVENTCOUNT_BYTE); -} diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseStandardCrankTorque.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseStandardCrankTorque.h deleted file mode 100644 index 64f92a3..0000000 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseStandardCrankTorque.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef ANTPLUS_BICYCLEPOWERBASECRANKTORQUE_h -#define ANTPLUS_BICYCLEPOWERBASECRANKTORQUE_h - -#include - -#include "ANT.h" - -template -class BicyclePowerBaseStandardCrankTorque : virtual public CoreDataPage { -public: - BicyclePowerBaseStandardCrankTorque(); - uint8_t getCrankTicks(); - uint8_t getInstantCadence(); // May not be available, 0xFF indicates invalid - uint16_t getCrankPeriod(); - uint16_t getAccumulatedTorque(); -}; - -#endif // ANTPLUS_BICYCLEPOWERBASECRANKTORQUE_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseStandardPowerOnly.cpp b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseStandardPowerOnly.cpp deleted file mode 100644 index 34e31cb..0000000 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseStandardPowerOnly.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include - -template -BicyclePowerBaseStandardPowerOnly::BicyclePowerBaseStandardPowerOnly() : CoreDataPage() { -} - -template -uint8_t BicyclePowerBaseStandardPowerOnly::getPedalPower() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_PEDALPOWER_BYTE); -} - -template -uint8_t BicyclePowerBaseStandardPowerOnly::getInstantaneousCadence() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSCADENCE_BYTE); -} - -template -uint16_t BicyclePowerBaseStandardPowerOnly::getAccumulatedPower() { - return this->get16BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWER_LSB_BYTE, - ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWER_MSB_BYTE); -} - -template -uint16_t BicyclePowerBaseStandardPowerOnly::getInstantaneousPower() { - return this->get16BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWER_LSB_BYTE, - ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWER_MSB_BYTE); -} - -template class BicyclePowerBaseStandardPowerOnly; -template class BicyclePowerBaseStandardPowerOnly; diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseStandardPowerOnly.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseStandardPowerOnly.h deleted file mode 100644 index cd7138f..0000000 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseStandardPowerOnly.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef ANTPLUS_BICYCLEPOWERBASEPOWERONLY_h -#define ANTPLUS_BICYCLEPOWERBASEPOWERONLY_h - -#include - -#include "ANT.h" - -template -class BicyclePowerBaseStandardPowerOnly : virtual public CoreDataPage { -public: - BicyclePowerBaseStandardPowerOnly(); - uint8_t getPedalPower(); - uint8_t getInstantaneousCadence(); - uint16_t getAccumulatedPower(); - uint16_t getInstantaneousPower(); -}; - -#endif // ANTPLUS_BICYCLEPOWERBASEPOWERONLY_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseStandardWheelTorque.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseStandardWheelTorque.h deleted file mode 100644 index c831a72..0000000 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseStandardWheelTorque.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef ANTPLUS_BICYCLEPOWERBASEWHEELTORQUE_h -#define ANTPLUS_BICYCLEPOWERBASEWHEELTORQUE_h - -#include - -#include "ANT.h" - -template -class BicyclePowerBaseStandardWheelTorque : virtual public CoreDataPage { -public: - BicyclePowerBaseStandardWheelTorque(); - uint8_t getWheelTicks(); - uint8_t getInstantCadence(); // May not be available, 0xFF indicates invalid - uint16_t getWheelPeriod(); - uint16_t getAccumulatedTorque(); -}; - -#endif // ANTPLUS_BICYCLEPOWERBASEWHEELTORQUE_h diff --git a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness.h b/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness.h deleted file mode 100644 index 66f32fc..0000000 --- a/src/Profiles/BicyclePower/DataPages/Base/ANTPLUS_BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef ANTPLUS_BICYCLEPOWERBASEPEDALSMOOTHNESS_h -#define ANTPLUS_BICYCLEPOWERBASEPEDALSMOOTHNESS_h - -#include - -#include "ANT.h" - -template -class BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness : virtual public CoreDataPage { -public: - BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness(); - uint8_t getLeftTorqueEffectiveness(); - uint8_t getRightTorqueEffectiveness(); - uint8_t getLeftPedalSmoothness(); - uint8_t getRightPedalSmoothness(); -}; - -#endif // ANTPLUS_BICYCLEPOWERBASEPEDALSMOOTHNESS_h diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardCrankTorque.cpp b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardCrankTorque.cpp deleted file mode 100644 index bf86720..0000000 --- a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardCrankTorque.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include - -BicyclePowerStandardCrankTorque::BicyclePowerStandardCrankTorque(AntRxDataResponse& dp) : BicyclePowerBaseMainDataPage(dp), BicyclePowerBaseStandardCrankTorque() { } diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardCrankTorque.h b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardCrankTorque.h deleted file mode 100644 index 94e6a3b..0000000 --- a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardCrankTorque.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_BICYCLEPOWERSTANDARDCRANKTORQUE_h -#define ANTPLUS_BICYCLEPOWERSTANDARDCRANKTORQUE_h - -#include -#include - -class BicyclePowerStandardCrankTorque : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseStandardCrankTorque { -public: - explicit BicyclePowerStandardCrankTorque(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_BICYCLEPOWERSTANDARDCRANKTORQUE_h diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardPowerOnly.cpp b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardPowerOnly.cpp deleted file mode 100644 index 57a5d60..0000000 --- a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardPowerOnly.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include - -BicyclePowerStandardPowerOnly::BicyclePowerStandardPowerOnly(AntRxDataResponse& dp) : BicyclePowerBaseMainDataPage(dp), BicyclePowerBaseStandardPowerOnly() { -} - diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardPowerOnly.h b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardPowerOnly.h deleted file mode 100644 index b6f2ce9..0000000 --- a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardPowerOnly.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef ANTPLUS_BICYCLEPOWERSTANDARDPOWERONLY_h -#define ANTPLUS_BICYCLEPOWERSTANDARDPOWERONLY_h - -#include -#include - -class BicyclePowerStandardPowerOnly : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseStandardPowerOnly { -public: - explicit BicyclePowerStandardPowerOnly(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_BICYCLEPOWERSTANDARDPOWERONLY_h - - diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardWheelTorque.cpp b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardWheelTorque.cpp deleted file mode 100644 index 509918f..0000000 --- a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardWheelTorque.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include - -BicyclePowerStandardWheelTorque::BicyclePowerStandardWheelTorque(AntRxDataResponse& dp) : BicyclePowerBaseMainDataPage(dp), BicyclePowerBaseStandardWheelTorque() { } diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardWheelTorque.h b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardWheelTorque.h deleted file mode 100644 index 9708728..0000000 --- a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerStandardWheelTorque.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_BICYCLEPOWERSTANDARDWHEELTORQUE_h -#define ANTPLUS_BICYCLEPOWERSTANDARDWHEELTORQUE_h - -#include -#include - -class BicyclePowerStandardWheelTorque : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseStandardWheelTorque { -public: - explicit BicyclePowerStandardWheelTorque(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_BICYCLEPOWERSTANDARDWHEELTORQUE_h diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.cpp b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.cpp deleted file mode 100644 index bdf8301..0000000 --- a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include - -BicyclePowerTorqueEffectivenessAndPedalSmoothness::BicyclePowerTorqueEffectivenessAndPedalSmoothness(AntRxDataResponse& dp) : BicyclePowerBaseMainDataPage(dp), BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness() { -} diff --git a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.h b/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.h deleted file mode 100644 index 162d722..0000000 --- a/src/Profiles/BicyclePower/DataPages/RX/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_BICYCLEPOWERPEDALSMOOTHNESS_h -#define ANTPLUS_BICYCLEPOWERPEDALSMOOTHNESS_h - -#include -#include - -class BicyclePowerTorqueEffectivenessAndPedalSmoothness : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness { -public: - explicit BicyclePowerTorqueEffectivenessAndPedalSmoothness(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_BICYCLEPOWERPEDALSMOOTHNESS_h diff --git a/src/Profiles/BicyclePower/DataPages/TX/ANTPLUS_BicyclePowerStandardPowerOnlyMsg.cpp b/src/Profiles/BicyclePower/DataPages/TX/ANTPLUS_BicyclePowerStandardPowerOnlyMsg.cpp deleted file mode 100644 index be88ee6..0000000 --- a/src/Profiles/BicyclePower/DataPages/TX/ANTPLUS_BicyclePowerStandardPowerOnlyMsg.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include -#include - -BicyclePowerStandardPowerOnlyMsg::BicyclePowerStandardPowerOnlyMsg() : BaseDataPageMsg() { - setDataBuffer(_buffer); - _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_NUMBER; - _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_PEDALPOWER_BYTE] = 0xFF; - _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSCADENCE_BYTE] = 0xFF; -} - -void BicyclePowerStandardPowerOnlyMsg::setUpdateEventCount(uint8_t eventCount) { - _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_UPDATEEVENTCOUNT_BYTE] = eventCount; -} - -void BicyclePowerStandardPowerOnlyMsg::setCumulativePowerCount(uint16_t accPower) { - _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWER_MSB_BYTE] = accPower >> 8; - _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWER_LSB_BYTE] = accPower & ANTPLUS_DEFAULT_BYTE_MASK; -} - -void BicyclePowerStandardPowerOnlyMsg::setInstataneousPowerCount(uint16_t power) { - _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWER_MSB_BYTE] = power >> 8; - _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWER_LSB_BYTE] = power & ANTPLUS_DEFAULT_BYTE_MASK; -} diff --git a/src/Profiles/BicyclePower/DataPages/TX/ANTPLUS_BicyclePowerStandardPowerOnlyMsg.h b/src/Profiles/BicyclePower/DataPages/TX/ANTPLUS_BicyclePowerStandardPowerOnlyMsg.h deleted file mode 100644 index d3dde60..0000000 --- a/src/Profiles/BicyclePower/DataPages/TX/ANTPLUS_BicyclePowerStandardPowerOnlyMsg.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef ANTPLUS_BIKEPOWERSTANDARDPOWERONLYMSG_h -#define ANTPLUS_BIKEPOWERSTANDARDPOWERONLYMSG_h - -#include - -#include "ANT.h" - -class BicyclePowerStandardPowerOnlyMsg : public BaseDataPageMsg { -public: - BicyclePowerStandardPowerOnlyMsg(void); - void setUpdateEventCount(uint8_t eventCount); - void setCumulativePowerCount(uint16_t accPower); - void setInstataneousPowerCount(uint16_t power); -protected: - uint8_t _buffer[MESSAGE_SIZE]; -}; - -#endif // ANTPLUS_BIKEPOWERSTANDARDPOWERONLYMSG_h diff --git a/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h b/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h index 7beee96..157515a 100644 --- a/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h +++ b/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h @@ -2,7 +2,7 @@ #define ANTPLUS_PROFILEBICYCLEPOWERDISPLAY_h #include -#include +#include #include #include "ANT.h" diff --git a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h index 05014db..53ffbfc 100644 --- a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h +++ b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h @@ -2,7 +2,7 @@ #define ANTPLUS_PROFILEBICYCLEPOWERSENSOR_h #include -#include +#include #include class ProfileBicyclePowerSensor : public BaseMasterProfile { From 6edf626ad47a5f30ac3d22c556887573c39c51e2 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 16 Jan 2021 14:50:49 -0800 Subject: [PATCH 093/241] power: move defines out step 2 of refactor, also fixup some naming issues and mark some comments for missing code and future design --- .../ANTPLUS_BicyclePowerPrivateDefines.h | 84 ++----------------- .../ANTPLUS_BicyclePowerBaseMainDataPage.cpp | 8 +- ...TPLUS_BicyclePowerCrankTorqueFrequency.cpp | 8 ++ ...ANTPLUS_BicyclePowerCrankTorqueFrequency.h | 0 ...NTPLUS_BicyclePowerStandardCrankTorque.cpp | 22 ++--- .../ANTPLUS_BicyclePowerStandardCrankTorque.h | 2 +- .../ANTPLUS_BicyclePowerStandardPowerOnly.cpp | 37 ++++---- ...NTPLUS_BicyclePowerStandardWheelTorque.cpp | 21 +++-- .../ANTPLUS_BicyclePowerStandardWheelTorque.h | 2 +- ...rTorqueEffectivenessAndPedalSmoothness.cpp | 21 ++--- .../ANTPLUS_ProfileBicyclePowerDisplay.cpp | 16 ++-- .../ANTPLUS_ProfileBicyclePowerSensor.cpp | 24 +++--- 12 files changed, 102 insertions(+), 143 deletions(-) create mode 100644 src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.cpp create mode 100644 src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.h diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h index a4370b5..7ae6426 100644 --- a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h @@ -4,83 +4,17 @@ #include /* Channel Config */ -#define ANTPLUS_BICYCLEPOWER_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE -#define ANTPLUS_BICYCLEPOWER_SENSOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT -#define ANTPLUS_BICYCLEPOWER_DEVICETYPE 11 -#define ANTPLUS_BICYCLEPOWER_CHANNELPERIOD 8182 +#define CHANNELPERIOD 8182 // 30 / 2.5 = 12 -#define ANTPLUS_BICYCLEPOWER_SEARCHTIMEOUT 12 +#define SEARCHTIMEOUT 12 -/* Fixed Bytes */ -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_BYTE 0 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_UPDATEEVENTCOUNT_BYTE 1 - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_GENERALCALIBRATION_NUMBER 0x01 -/* Power Only Main Data Page */ -/* DataPage for Power Only, CTF does not need to support. - * Note: Currently not writing any of this with CTF in mind. - * CTF support needs to be added (not in scope for my project. - */ -/* Standard Power-Only */ -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_NUMBER 0x10 - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_UPDATEEVENTCOUNT_BYTE 1 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_PEDALPOWER_BYTE 2 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSCADENCE_BYTE 3 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWER_LSB_BYTE 4 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWER_MSB_BYTE 5 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWER_LSB_BYTE 6 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWER_MSB_BYTE 7 - -/* Wheel Torque Main Data Page */ - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDWHEELTORQUE_NUMBER 0x11 - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELTICKS_WHEELTORQUE_BYTE 2 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_WHEELTORQUE_BYTE 3 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELPERIODLSB_WHEELTORQUE_BYTE 4 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELPERIODMSB_WHEELTORQUE_BYTE 5 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUELSB_WHEELTORQUE_BYTE 6 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUEMSB_WHEELTORQUE_BYTE 7 - -/* Standard Crank Torque Main Data Page */ - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDCRANKTORQUE_NUMBER 0x12 - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKTICKS_CRANKTORQUE_BYTE 2 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_CRANKTORQUE_BYTE 3 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKPERIODLSB_CRANKTORQUE_BYTE 4 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKPERIODMSB_CRANKTORQUE_BYTE 5 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUELSB_CRANKTORQUE_BYTE 6 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUEMSB_CRANKTORQUE_BYTE 7 +#define GENERALCALIBRATION_NUMBER 0x01 +#define STANDARDPOWERONLY_NUMBER 0x10 +#define STANDARDWHEELTORQUE_NUMBER 0x11 +#define STANDARDCRANKTORQUE_NUMBER 0x12 +#define TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER 0x13 +#define CRANKTORQUEFREQUENCY_NUMBER 0x20 -/* Pedal Smoothness Main Data Page */ - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER 0x13 - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_LEFTEFFECTIVENESS_PEDALSMOOTHNESS_BYTE 2 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_RIGHTEFFECTIVENESS_PEDALSMOOTHNESS_BYTE 3 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_LEFTSMOOTHNESS_PEDALSMOOTHNESS_BYTE 4 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_RIGHTSMOOTHNESS_PEDALSMOOTHNESS_BYTE 5 - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKTORQUEFREQUENCY_NUMBER 0x20 -/* Crank Torque Frequency Main Data Page - -NOTE: CTF messages are big endian. The byte order for multi-byte -fields in these messages is reversed with respect to standard ANT+ messages - -Not implemented. -*/ - -/* -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_CTF_NUMBER 0x20 - -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_SLOPEMSB_CTF_BYTE 2 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_SLOPELSB_CTF_BYTE 3 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TIMESTAMPMSB_CTF_BYTE 4 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TIMESTAMPLSB_CTF_BYTE 5 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TORQUETICKSTAMPMSB_CTF_BYTE 6 -#define ANTPLUS_BICYCLEPOWER_DATAPAGE_TORQUETICKSTAMPLSB_CTF_BYTE 7 -*/ +/* Fixed Bytes */ #endif // ANTPLUS_BICYCLEPOWERPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.cpp index 555773e..1477d28 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.cpp @@ -2,16 +2,18 @@ #include #include +// TODO make second base class for callibration messages +#define UPDATEEVENTCOUNT_BYTE 1 + BicyclePowerBaseMainDataPage::BicyclePowerBaseMainDataPage(AntRxDataResponse& dp) : BaseDataPage(dp) {} -// TODO move down since this isn't common to all classes uint8_t BicyclePowerBaseMainDataPage::getDataPageNumber() { - return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_DATAPAGE_BYTE); + return getData(ANTPLUS_DEFAULT_DATAPAGE_BYTE); } uint8_t BicyclePowerBaseMainDataPage::getUpdateEventCount() { - return getData(ANTPLUS_BICYCLEPOWER_DATAPAGE_UPDATEEVENTCOUNT_BYTE); + return getData(UPDATEEVENTCOUNT_BYTE); } BicyclePowerBaseMainDataPageMsg::BicyclePowerBaseMainDataPageMsg(uint8_t dataPageNumber) : diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.cpp new file mode 100644 index 0000000..1c9e36d --- /dev/null +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.cpp @@ -0,0 +1,8 @@ +#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 + +// TODO diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.h new file mode 100644 index 0000000..e69de29 diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.cpp index a2d1925..ee1a4b9 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.cpp @@ -1,34 +1,36 @@ #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( - ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKTICKS_CRANKTORQUE_BYTE); + return this->get8BitValue(CRANKTICKS_BYTE); } template -uint8_t BicyclePowerBaseStandardCrankTorque::getInstantCadence() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_CRANKTORQUE_BYTE); +uint8_t BicyclePowerBaseStandardCrankTorque::getInstantaneousCadence() { + return this->get8BitValue(INSTANTANEOUSCADENCE_BYTE); } template uint16_t BicyclePowerBaseStandardCrankTorque::getCrankPeriod() { - return this->get16BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKPERIODLSB_CRANKTORQUE_BYTE, - ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKPERIODMSB_CRANKTORQUE_BYTE); + return this->get16BitValue(PERIOD_LSB_BYTE, PERIOD_MSB_BYTE); } template uint16_t BicyclePowerBaseStandardCrankTorque::getAccumulatedTorque() { return this->get16BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUELSB_CRANKTORQUE_BYTE, - ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUEMSB_CRANKTORQUE_BYTE); + ACCUMULATEDTORQUE_LSB_BYTE, ACCUMULATEDTORQUE_MSB_BYTE); } template class BicyclePowerBaseStandardCrankTorque; diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.h index 30aa934..f93cc23 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.h +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.h @@ -8,7 +8,7 @@ class BicyclePowerBaseStandardCrankTorque : virtual public CoreDataPage { public: BicyclePowerBaseStandardCrankTorque(); uint8_t getCrankTicks(); - uint8_t getInstantCadence(); // May not be available, 0xFF indicates invalid + uint8_t getInstantaneousCadence(); //TODO is vaid check, May not be available, 0xFF indicates invalid uint16_t getCrankPeriod(); uint16_t getAccumulatedTorque(); }; diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp index a7e5be5..f52c1a3 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp @@ -2,34 +2,38 @@ #include #include +#define UPDATEEVENTCOUNT_BYTE 1 +#define PEDALPOWER_BYTE 2 +#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( - ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_PEDALPOWER_BYTE); + return this->get8BitValue(PEDALPOWER_BYTE); } template uint8_t BicyclePowerBaseStandardPowerOnly::getInstantaneousCadence() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSCADENCE_BYTE); + return this->get8BitValue(INSTANTANEOUSCADENCE_BYTE); } template uint16_t BicyclePowerBaseStandardPowerOnly::getAccumulatedPower() { return this->get16BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWER_LSB_BYTE, - ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWER_MSB_BYTE); + ACCUMULATEDPOWER_LSB_BYTE, ACCUMULATEDPOWER_MSB_BYTE); } template uint16_t BicyclePowerBaseStandardPowerOnly::getInstantaneousPower() { return this->get16BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWER_LSB_BYTE, - ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWER_MSB_BYTE); + INSTANTANEOUSPOWER_LSB_BYTE, INSTANTANEOUSPOWER_MSB_BYTE); } template class BicyclePowerBaseStandardPowerOnly; @@ -40,22 +44,23 @@ BicyclePowerStandardPowerOnly::BicyclePowerStandardPowerOnly(AntRxDataResponse& BicyclePowerBaseStandardPowerOnly() {} BicyclePowerStandardPowerOnlyMsg::BicyclePowerStandardPowerOnlyMsg() : - BicyclePowerBaseMainDataPageMsg(ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_NUMBER), + BicyclePowerBaseMainDataPageMsg(STANDARDPOWERONLY_NUMBER), BicyclePowerBaseStandardPowerOnly() { - _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_PEDALPOWER_BYTE] = 0xFF; - _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSCADENCE_BYTE] = 0xFF; + // TODO magic nums also using buffer directly + _buffer[PEDALPOWER_BYTE] = 0xFF; + _buffer[INSTANTANEOUSCADENCE_BYTE] = 0xFF; } void BicyclePowerStandardPowerOnlyMsg::setUpdateEventCount(uint8_t eventCount) { - _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_UPDATEEVENTCOUNT_BYTE] = eventCount; + _buffer[UPDATEEVENTCOUNT_BYTE] = eventCount; } void BicyclePowerStandardPowerOnlyMsg::setCumulativePowerCount(uint16_t accPower) { - _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWER_MSB_BYTE] = accPower >> 8; - _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_ACCUMULATEDPOWER_LSB_BYTE] = accPower & ANTPLUS_DEFAULT_BYTE_MASK; + _buffer[ACCUMULATEDPOWER_MSB_BYTE] = accPower >> 8; + _buffer[ACCUMULATEDPOWER_LSB_BYTE] = accPower & ANTPLUS_DEFAULT_BYTE_MASK; } void BicyclePowerStandardPowerOnlyMsg::setInstataneousPowerCount(uint16_t power) { - _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWER_MSB_BYTE] = power >> 8; - _buffer[ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_INSTANTANEOUSPOWER_LSB_BYTE] = power & ANTPLUS_DEFAULT_BYTE_MASK; + _buffer[INSTANTANEOUSPOWER_MSB_BYTE] = power >> 8; + _buffer[INSTANTANEOUSPOWER_LSB_BYTE] = power & ANTPLUS_DEFAULT_BYTE_MASK; } diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.cpp index 56aa52a..923c75d 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.cpp @@ -1,34 +1,37 @@ #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( - ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELTICKS_WHEELTORQUE_BYTE); + return this->get8BitValue(WHEELTICKS_BYTE); } template -uint8_t BicyclePowerBaseStandardWheelTorque::getInstantCadence() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_CADENCE_WHEELTORQUE_BYTE); +uint8_t BicyclePowerBaseStandardWheelTorque::getInstantaneousCadence() { + return this->get8BitValue(INSTANTANEOUSCADENCE_BYTE); } template uint16_t BicyclePowerBaseStandardWheelTorque::getWheelPeriod() { return this->get16BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELPERIODLSB_WHEELTORQUE_BYTE, - ANTPLUS_BICYCLEPOWER_DATAPAGE_WHEELPERIODMSB_WHEELTORQUE_BYTE); + WHEELPERIOD_LSB_BYTE, WHEELPERIOD_MSB_BYTE); } template uint16_t BicyclePowerBaseStandardWheelTorque::getAccumulatedTorque() { return this->get16BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUELSB_WHEELTORQUE_BYTE, - ANTPLUS_BICYCLEPOWER_DATAPAGE_ACCUMULATEDTORQUEMSB_WHEELTORQUE_BYTE); + ACCUMULATEDTORQUE_LSB_BYTE, ACCUMULATEDTORQUE_MSB_BYTE); } template class BicyclePowerBaseStandardWheelTorque; diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.h index 4832c48..84c9dac 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.h +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.h @@ -8,7 +8,7 @@ class BicyclePowerBaseStandardWheelTorque : virtual public CoreDataPage { public: BicyclePowerBaseStandardWheelTorque(); uint8_t getWheelTicks(); - uint8_t getInstantCadence(); // May not be available, 0xFF indicates invalid + uint8_t getInstantaneousCadence(); // TODO(is valid check) May not be available, 0xFF indicates invalid uint16_t getWheelPeriod(); uint16_t getAccumulatedTorque(); }; diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.cpp index c6a322f..d70ea18 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.cpp @@ -1,32 +1,33 @@ #include #include +#define LEFTEFFECTIVENESS_BYTE 2 +#define RIGHTEFFECTIVENESS_BYTE 3 +#define LEFTSMOOTHNESS_BYTE 4 +#define RIGHTSMOOTHNESS_BYTE 5 + template -BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness::BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness() : CoreDataPage() { -} +BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness::BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness() : + CoreDataPage() {} template uint8_t BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness::getLeftTorqueEffectiveness() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_LEFTEFFECTIVENESS_PEDALSMOOTHNESS_BYTE); + return this->get8BitValue(LEFTEFFECTIVENESS_BYTE); } template uint8_t BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness::getRightTorqueEffectiveness() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_RIGHTEFFECTIVENESS_PEDALSMOOTHNESS_BYTE); + return this->get8BitValue(RIGHTEFFECTIVENESS_BYTE); } template uint8_t BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness::getLeftPedalSmoothness() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_LEFTSMOOTHNESS_PEDALSMOOTHNESS_BYTE); + return this->get8BitValue(LEFTSMOOTHNESS_BYTE); } template uint8_t BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness::getRightPedalSmoothness() { - return this->get8BitValue( - ANTPLUS_BICYCLEPOWER_DATAPAGE_RIGHTSMOOTHNESS_PEDALSMOOTHNESS_BYTE); + return this->get8BitValue(RIGHTSMOOTHNESS_BYTE); } template class BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness; diff --git a/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.cpp b/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.cpp index e190f09..f17195b 100644 --- a/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.cpp +++ b/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.cpp @@ -3,6 +3,8 @@ #include #include +#define DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE + ProfileBicyclePowerDisplay::ProfileBicyclePowerDisplay() : BaseSlaveProfile() { setChannelConfig(); } @@ -37,16 +39,16 @@ bool ProfileBicyclePowerDisplay::handleDataPage(BicyclePowerBaseMainDataPage& dp case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER: called = handleBatteryStatus(dp); break; - case ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_NUMBER: + case STANDARDPOWERONLY_NUMBER: called = handleStandardPowerOnly(dp); break; - case ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDCRANKTORQUE_NUMBER: + case STANDARDCRANKTORQUE_NUMBER: called = handleStandardCrankTorque(dp); break; - case ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDWHEELTORQUE_NUMBER: + case STANDARDWHEELTORQUE_NUMBER: called = handleStandardWheelTorque(dp); break; - case ANTPLUS_BICYCLEPOWER_DATAPAGE_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: + case TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: called = handleTorqueEffectivenessAndPedalSmoothness(dp); break; } @@ -64,10 +66,10 @@ void ProfileBicyclePowerDisplay::onAcknowledgedData(AcknowledgedData& msg) { void ProfileBicyclePowerDisplay::setChannelConfig() { - setChannelType(ANTPLUS_BICYCLEPOWER_DISPLAY_CHANNELTYPE); + setChannelType(DISPLAY_CHANNELTYPE); setDeviceType(ANTPLUS_BICYCLEPOWER_DEVICETYPE); - setChannelPeriod(ANTPLUS_BICYCLEPOWER_CHANNELPERIOD); - setSearchTimeout(ANTPLUS_BICYCLEPOWER_SEARCHTIMEOUT); + setChannelPeriod(CHANNELPERIOD); + setSearchTimeout(SEARCHTIMEOUT); } bool ProfileBicyclePowerDisplay::handleBatteryStatus(BicyclePowerBaseMainDataPage& dataPage) { diff --git a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp index 71fcf63..c8d62ee 100644 --- a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -3,6 +3,8 @@ #include #include +#define SENSOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT + ProfileBicyclePowerSensor::ProfileBicyclePowerSensor( uint16_t deviceNumber, uint8_t transmissionType) : @@ -49,7 +51,7 @@ void ProfileBicyclePowerSensor::onAcknowledgedData(AcknowledgedData& msg) { case ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER: called = handleRequestDataPage(dp); break; - case ANTPLUS_BICYCLEPOWER_DATAPAGE_GENERALCALIBRATION_NUMBER: + case GENERALCALIBRATION_NUMBER: called = handleGeneralCalibration(dp); break; } @@ -91,22 +93,22 @@ void ProfileBicyclePowerSensor::transmitPrimaryDataPage() { void ProfileBicyclePowerSensor::transmitBackgroundDataPage() { switch (_nextBackgroundPage) { - case ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_NUMBER: + case STANDARDPOWERONLY_NUMBER: transmitBicyclePowerStandardPowerOnlyMsg(); break; - case ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDWHEELTORQUE_NUMBER: + case STANDARDWHEELTORQUE_NUMBER: transmitBicyclePowerStandardWheelTorqueMsg(); break; - case ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDCRANKTORQUE_NUMBER: + case STANDARDCRANKTORQUE_NUMBER: transmitBicyclePowerStandardCrankTorqueMsg(); break; - case ANTPLUS_BICYCLEPOWER_DATAPAGE_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: + case TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: transmitBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg(); break; - case ANTPLUS_BICYCLEPOWER_DATAPAGE_CRANKTORQUEFREQUENCY_NUMBER: + case CRANKTORQUEFREQUENCY_NUMBER: transmitBicyclePowerCrankTorqueFrequencyMsg(); break; - case ANTPLUS_BICYCLEPOWER_DATAPAGE_GENERALCALIBRATION_NUMBER: + case GENERALCALIBRATION_NUMBER: // TODO (check is this part of the background transmission, seems sus) transmistBicyclePowerGeneralCalibrationResponse(); break; } @@ -147,17 +149,17 @@ uint8_t ProfileBicyclePowerSensor::getNextBackgroundPage(uint8_t currentPage) { void ProfileBicyclePowerSensor::transmitRequestedDataPage() { uint8_t requestedPage = getRequestedPage(); switch (requestedPage) { - case ANTPLUS_BICYCLEPOWER_DATAPAGE_STANDARDPOWERONLY_NUMBER: + case STANDARDPOWERONLY_NUMBER: // TODO break; } } void ProfileBicyclePowerSensor::setChannelConfig() { - setChannelType(ANTPLUS_BICYCLEPOWER_SENSOR_CHANNELTYPE); + setChannelType(SENSOR_CHANNELTYPE); setDeviceType(ANTPLUS_BICYCLEPOWER_DEVICETYPE); - setChannelPeriod(ANTPLUS_BICYCLEPOWER_CHANNELPERIOD); - setSearchTimeout(ANTPLUS_BICYCLEPOWER_SEARCHTIMEOUT); + setChannelPeriod(CHANNELPERIOD); + setSearchTimeout(SEARCHTIMEOUT); } bool ProfileBicyclePowerSensor::isDataPageValid(uint8_t dataPage) { From 7bea54b6a54689242b51a7e8f2442e2e9acdbf16 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 16 Jan 2021 14:53:48 -0800 Subject: [PATCH 094/241] power: move to common profiles folder step 3 of refactor, power refactor is now complete --- src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h | 4 ++-- .../ANTPLUS_ProfileBicyclePowerDisplay.cpp | 2 +- .../ANTPLUS_ProfileBicyclePowerDisplay.h | 0 .../ANTPLUS_ProfileBicyclePowerSensor.cpp | 2 +- .../{Sensor => Profiles}/ANTPLUS_ProfileBicyclePowerSensor.h | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename src/Profiles/BicyclePower/{Display => Profiles}/ANTPLUS_ProfileBicyclePowerDisplay.cpp (98%) rename src/Profiles/BicyclePower/{Display => Profiles}/ANTPLUS_ProfileBicyclePowerDisplay.h (100%) rename src/Profiles/BicyclePower/{Sensor => Profiles}/ANTPLUS_ProfileBicyclePowerSensor.cpp (98%) rename src/Profiles/BicyclePower/{Sensor => Profiles}/ANTPLUS_ProfileBicyclePowerSensor.h (100%) diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h index 53b24b2..27c8ed7 100644 --- a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h @@ -8,7 +8,7 @@ #include // Profile Classes -#include -#include +#include +#include #endif // ANTPLUS_BICYCLEPOWERPROFILE_h diff --git a/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp similarity index 98% rename from src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.cpp rename to src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp index f17195b..c9abbdb 100644 --- a/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.cpp +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.h similarity index 100% rename from src/Profiles/BicyclePower/Display/ANTPLUS_ProfileBicyclePowerDisplay.h rename to src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.h diff --git a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp similarity index 98% rename from src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp rename to src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp index c8d62ee..7c66369 100644 --- a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h similarity index 100% rename from src/Profiles/BicyclePower/Sensor/ANTPLUS_ProfileBicyclePowerSensor.h rename to src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h From ee99d2cc0aeed2bfd04c8749b35b6686956d65e4 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 16 Jan 2021 14:56:14 -0800 Subject: [PATCH 095/241] shifting: add todo marker --- .../DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp index 31773e3..c9c90b0 100644 --- a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp +++ b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp @@ -7,5 +7,6 @@ ShiftingBaseMainDataPageMsg::ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber) memset(_buffer, 0, MESSAGE_SIZE); setDataBuffer(_buffer); set8BitValue(dataPageNumber, ANTPLUS_SHIFTING_DATAPAGEBASE_DATAPAGE_BYTE); + // TODO magic numbers _buffer[2] = 0xFF; } From 0d96366c598048b7d8ac100f622e52361968bf27 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 16 Jan 2021 14:54:41 -0800 Subject: [PATCH 096/241] heartrate: remove unneeded header ANT really shouldnt be included anywhere in the profiles since all base types reference it --- .../HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.h b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.h index 7c12f98..975a190 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.h +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.h @@ -5,8 +5,6 @@ #include #include -#include "ANT.h" - template class HeartRateCoreMainDataPage : virtual public CoreDataPage { public: From ddfbbf06b4cee2c72ab1cd2af8e9d78697f45649 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 16 Jan 2021 21:38:23 -0800 Subject: [PATCH 097/241] power: fixup example fix method names --- examples/BicyclePowerDisplay/BicyclePowerDisplay.ino | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino index b27f9d6..d9cb8de 100644 --- a/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino +++ b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino @@ -136,19 +136,19 @@ void bicyclePowerBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data) { void powerOnlyDataPageHandler(BicyclePowerStandardPowerOnly& msg, uintptr_t data) { Serial.print("Pedal Balance: "); Serial.println(msg.getPedalPower()); - Serial.print("Instant Cadence: "); + Serial.print("Instantaneous Cadence: "); Serial.println(msg.getInstantaneousCadence()); Serial.print("Accumulated Power: "); Serial.println(msg.getAccumulatedPower()); - Serial.print("Instant Power: "); + 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("Instant Cadence: "); - Serial.println(msg.getInstantCadence()); + Serial.print("Instantaneous Cadence: "); + Serial.println(msg.getInstantaneousCadence()); Serial.print("Crank Period: "); Serial.println(msg.getCrankPeriod()); Serial.print("Accumulated Torque: "); @@ -158,8 +158,8 @@ void crankTorqueDataPageHandler(BicyclePowerStandardCrankTorque& msg, uintptr_t void wheelTorqueDataPageHandler(BicyclePowerStandardWheelTorque& msg, uintptr_t data) { Serial.print("Wheel Ticks: "); Serial.println(msg.getWheelTicks()); - Serial.print("Instant Cadence: "); - Serial.println(msg.getInstantCadence()); + Serial.print("Instantaneous Cadence: "); + Serial.println(msg.getInstantaneousCadence()); Serial.print("Wheel Period: "); Serial.println(msg.getWheelPeriod()); Serial.print("Accumulated Torque: "); From a9a6863047ef86661f8c9f46928e91894e15d8a0 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 17 Jan 2021 15:29:46 -0800 Subject: [PATCH 098/241] CommonDataPages: refactor step 1 Consolidating datapages, reduce files by 2/3 and remove 20% of lines --- src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp | 2 +- .../{RX => }/ANTPLUS_ANTFSClientBeacon.cpp | 0 .../{RX => }/ANTPLUS_ANTFSClientBeacon.h | 0 src/CommonDataPages/ANTPLUS_BatteryStatus.cpp | 121 ++++++++++++++++++ src/CommonDataPages/ANTPLUS_BatteryStatus.h | 41 ++++++ .../{RX => }/ANTPLUS_CommandStatus.cpp | 0 .../{RX => }/ANTPLUS_CommandStatus.h | 0 src/CommonDataPages/ANTPLUS_CommonDataPages.h | 50 +++----- .../{RX => }/ANTPLUS_ErrorDescription.cpp | 0 .../{RX => }/ANTPLUS_ErrorDescription.h | 0 .../{RX => }/ANTPLUS_GenericCommand.cpp | 0 .../{RX => }/ANTPLUS_GenericCommand.h | 0 .../ANTPLUS_ManufacturersInformation.cpp | 61 +++++++++ .../ANTPLUS_ManufacturersInformation.h | 33 +++++ .../{RX => }/ANTPLUS_MemoryLevel.cpp | 0 .../{RX => }/ANTPLUS_MemoryLevel.h | 0 ...eSettings.cpp => ANTPLUS_ModeSettings.cpp} | 6 +- .../{RX => }/ANTPLUS_ModeSettings.h | 15 ++- ...omponentSystemManufacturersInformation.cpp | 88 +++++++++++++ ...iComponentSystemManufacturersInformation.h | 37 ++++++ ...MultiComponentSystemProductInformation.cpp | 86 +++++++++++++ ...S_MultiComponentSystemProductInformation.h | 37 ++++++ .../{RX => }/ANTPLUS_OpenChannelCommand.cpp | 0 .../{RX => }/ANTPLUS_OpenChannelCommand.h | 0 .../{RX => }/ANTPLUS_PairedDevices.cpp | 0 .../{RX => }/ANTPLUS_PairedDevices.h | 0 .../ANTPLUS_ProductInformation.cpp | 57 +++++++++ .../ANTPLUS_ProductInformation.h | 33 +++++ .../ANTPLUS_RequestDataPage.cpp | 119 +++++++++++++++++ src/CommonDataPages/ANTPLUS_RequestDataPage.h | 42 ++++++ .../{RX => }/ANTPLUS_SubfieldData.cpp | 0 .../{RX => }/ANTPLUS_SubfieldData.h | 0 .../{RX => }/ANTPLUS_TimeAndDate.cpp | 0 .../{RX => }/ANTPLUS_TimeAndDate.h | 0 .../Base/ANTPLUS_BaseBatteryStatus.cpp | 60 --------- .../Base/ANTPLUS_BaseBatteryStatus.h | 23 ---- .../ANTPLUS_BaseManufacturersInformation.cpp | 29 ----- .../ANTPLUS_BaseManufacturersInformation.h | 19 --- .../Base/ANTPLUS_BaseModeSettings.h | 17 --- ...omponentSystemManufacturersInformation.cpp | 44 ------- ...iComponentSystemManufacturersInformation.h | 21 --- ...MultiComponentSystemProductInformation.cpp | 43 ------- ...seMultiComponentSystemProductInformation.h | 21 --- .../Base/ANTPLUS_BaseProductInformation.cpp | 28 ---- .../Base/ANTPLUS_BaseProductInformation.h | 19 --- .../Base/ANTPLUS_BaseRequestDataPage.cpp | 61 --------- .../Base/ANTPLUS_BaseRequestDataPage.h | 24 ---- .../RX/ANTPLUS_BatteryStatus.cpp | 4 - .../RX/ANTPLUS_BatteryStatus.h | 16 --- .../RX/ANTPLUS_ManufacturersInformation.cpp | 5 - .../RX/ANTPLUS_ManufacturersInformation.h | 16 --- .../RX/ANTPLUS_ModeSettings.cpp | 4 - ...omponentSystemManufacturersInformation.cpp | 4 - ...iComponentSystemManufacturersInformation.h | 16 --- ...MultiComponentSystemProductInformation.cpp | 4 - ...S_MultiComponentSystemProductInformation.h | 16 --- .../RX/ANTPLUS_ProductInformation.cpp | 4 - .../RX/ANTPLUS_ProductInformation.h | 16 --- .../RX/ANTPLUS_RequestDataPage.cpp | 4 - .../RX/ANTPLUS_RequestDataPage.h | 16 --- .../TX/ANTPLUS_ANTFSClientBeaconMsg.cpp | 1 - .../TX/ANTPLUS_ANTFSClientBeaconMsg.h | 2 - .../TX/ANTPLUS_BatteryStatusMsg.cpp | 57 --------- .../TX/ANTPLUS_BatteryStatusMsg.h | 25 ---- .../TX/ANTPLUS_CommandStatusMsg.cpp | 1 - .../TX/ANTPLUS_CommandStatusMsg.h | 2 - .../TX/ANTPLUS_ErrorDescriptionMsg.cpp | 1 - .../TX/ANTPLUS_ErrorDescriptionMsg.h | 2 - .../TX/ANTPLUS_GenericCommandMsg.cpp | 1 - .../TX/ANTPLUS_GenericCommandMsg.h | 2 - .../ANTPLUS_ManufacturersInformationMsg.cpp | 28 ---- .../TX/ANTPLUS_ManufacturersInformationMsg.h | 21 --- .../TX/ANTPLUS_MemoryLevelMsg.cpp | 1 - .../TX/ANTPLUS_MemoryLevelMsg.h | 2 - .../TX/ANTPLUS_ModeSettingsMsg.cpp | 1 - .../TX/ANTPLUS_ModeSettingsMsg.h | 14 -- ...onentSystemManufacturersInformationMsg.cpp | 40 ------ ...mponentSystemManufacturersInformationMsg.h | 23 ---- ...tiComponentSystemProductInformationMsg.cpp | 39 ------ ...ultiComponentSystemProductInformationMsg.h | 23 ---- .../TX/ANTPLUS_OpenChannelCommandMsg.cpp | 1 - .../TX/ANTPLUS_OpenChannelCommandMsg.h | 2 - .../TX/ANTPLUS_PairedDevicesMsg.cpp | 1 - .../TX/ANTPLUS_PairedDevicesMsg.h | 2 - .../TX/ANTPLUS_ProductInformationMsg.cpp | 26 ---- .../TX/ANTPLUS_ProductInformationMsg.h | 21 --- .../TX/ANTPLUS_RequestDataPageMsg.cpp | 54 -------- .../TX/ANTPLUS_RequestDataPageMsg.h | 25 ---- .../TX/ANTPLUS_SubfieldDataMsg.cpp | 1 - .../TX/ANTPLUS_SubfieldDataMsg.h | 2 - .../TX/ANTPLUS_TimeAndDateMsg.cpp | 1 - .../TX/ANTPLUS_TimeAndDateMsg.h | 2 - .../ANTPLUS_ProfileBicyclePowerDisplay.cpp | 2 +- .../ANTPLUS_ProfileBicycleSpeedDisplay.cpp | 2 +- .../FEC/Display/ANTPLUS_ProfileFECDisplay.cpp | 4 +- .../ANTPLUS_ProfileHeartRateDisplay.cpp | 2 +- .../Lev/Display/ANTPLUS_ProfileLevDisplay.cpp | 1 - 97 files changed, 793 insertions(+), 1004 deletions(-) rename src/CommonDataPages/{RX => }/ANTPLUS_ANTFSClientBeacon.cpp (100%) rename src/CommonDataPages/{RX => }/ANTPLUS_ANTFSClientBeacon.h (100%) create mode 100644 src/CommonDataPages/ANTPLUS_BatteryStatus.cpp create mode 100644 src/CommonDataPages/ANTPLUS_BatteryStatus.h rename src/CommonDataPages/{RX => }/ANTPLUS_CommandStatus.cpp (100%) rename src/CommonDataPages/{RX => }/ANTPLUS_CommandStatus.h (100%) rename src/CommonDataPages/{RX => }/ANTPLUS_ErrorDescription.cpp (100%) rename src/CommonDataPages/{RX => }/ANTPLUS_ErrorDescription.h (100%) rename src/CommonDataPages/{RX => }/ANTPLUS_GenericCommand.cpp (100%) rename src/CommonDataPages/{RX => }/ANTPLUS_GenericCommand.h (100%) create mode 100644 src/CommonDataPages/ANTPLUS_ManufacturersInformation.cpp create mode 100644 src/CommonDataPages/ANTPLUS_ManufacturersInformation.h rename src/CommonDataPages/{RX => }/ANTPLUS_MemoryLevel.cpp (100%) rename src/CommonDataPages/{RX => }/ANTPLUS_MemoryLevel.h (100%) rename src/CommonDataPages/{Base/ANTPLUS_BaseModeSettings.cpp => ANTPLUS_ModeSettings.cpp} (69%) rename src/CommonDataPages/{RX => }/ANTPLUS_ModeSettings.h (51%) create mode 100644 src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp create mode 100644 src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.h create mode 100644 src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.cpp create mode 100644 src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.h rename src/CommonDataPages/{RX => }/ANTPLUS_OpenChannelCommand.cpp (100%) rename src/CommonDataPages/{RX => }/ANTPLUS_OpenChannelCommand.h (100%) rename src/CommonDataPages/{RX => }/ANTPLUS_PairedDevices.cpp (100%) rename src/CommonDataPages/{RX => }/ANTPLUS_PairedDevices.h (100%) create mode 100644 src/CommonDataPages/ANTPLUS_ProductInformation.cpp create mode 100644 src/CommonDataPages/ANTPLUS_ProductInformation.h create mode 100644 src/CommonDataPages/ANTPLUS_RequestDataPage.cpp create mode 100644 src/CommonDataPages/ANTPLUS_RequestDataPage.h rename src/CommonDataPages/{RX => }/ANTPLUS_SubfieldData.cpp (100%) rename src/CommonDataPages/{RX => }/ANTPLUS_SubfieldData.h (100%) rename src/CommonDataPages/{RX => }/ANTPLUS_TimeAndDate.cpp (100%) rename src/CommonDataPages/{RX => }/ANTPLUS_TimeAndDate.h (100%) delete mode 100644 src/CommonDataPages/Base/ANTPLUS_BaseBatteryStatus.cpp delete mode 100644 src/CommonDataPages/Base/ANTPLUS_BaseBatteryStatus.h delete mode 100644 src/CommonDataPages/Base/ANTPLUS_BaseManufacturersInformation.cpp delete mode 100644 src/CommonDataPages/Base/ANTPLUS_BaseManufacturersInformation.h delete mode 100644 src/CommonDataPages/Base/ANTPLUS_BaseModeSettings.h delete mode 100644 src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemManufacturersInformation.cpp delete mode 100644 src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemManufacturersInformation.h delete mode 100644 src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemProductInformation.cpp delete mode 100644 src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemProductInformation.h delete mode 100644 src/CommonDataPages/Base/ANTPLUS_BaseProductInformation.cpp delete mode 100644 src/CommonDataPages/Base/ANTPLUS_BaseProductInformation.h delete mode 100644 src/CommonDataPages/Base/ANTPLUS_BaseRequestDataPage.cpp delete mode 100644 src/CommonDataPages/Base/ANTPLUS_BaseRequestDataPage.h delete mode 100644 src/CommonDataPages/RX/ANTPLUS_BatteryStatus.cpp delete mode 100644 src/CommonDataPages/RX/ANTPLUS_BatteryStatus.h delete mode 100644 src/CommonDataPages/RX/ANTPLUS_ManufacturersInformation.cpp delete mode 100644 src/CommonDataPages/RX/ANTPLUS_ManufacturersInformation.h delete mode 100644 src/CommonDataPages/RX/ANTPLUS_ModeSettings.cpp delete mode 100644 src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp delete mode 100644 src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.h delete mode 100644 src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.cpp delete mode 100644 src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.h delete mode 100644 src/CommonDataPages/RX/ANTPLUS_ProductInformation.cpp delete mode 100644 src/CommonDataPages/RX/ANTPLUS_ProductInformation.h delete mode 100644 src/CommonDataPages/RX/ANTPLUS_RequestDataPage.cpp delete mode 100644 src/CommonDataPages/RX/ANTPLUS_RequestDataPage.h delete mode 100644 src/CommonDataPages/TX/ANTPLUS_ANTFSClientBeaconMsg.cpp delete mode 100644 src/CommonDataPages/TX/ANTPLUS_ANTFSClientBeaconMsg.h delete mode 100644 src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.cpp delete mode 100644 src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.h delete mode 100644 src/CommonDataPages/TX/ANTPLUS_CommandStatusMsg.cpp delete mode 100644 src/CommonDataPages/TX/ANTPLUS_CommandStatusMsg.h delete mode 100644 src/CommonDataPages/TX/ANTPLUS_ErrorDescriptionMsg.cpp delete mode 100644 src/CommonDataPages/TX/ANTPLUS_ErrorDescriptionMsg.h delete mode 100644 src/CommonDataPages/TX/ANTPLUS_GenericCommandMsg.cpp delete mode 100644 src/CommonDataPages/TX/ANTPLUS_GenericCommandMsg.h delete mode 100644 src/CommonDataPages/TX/ANTPLUS_ManufacturersInformationMsg.cpp delete mode 100644 src/CommonDataPages/TX/ANTPLUS_ManufacturersInformationMsg.h delete mode 100644 src/CommonDataPages/TX/ANTPLUS_MemoryLevelMsg.cpp delete mode 100644 src/CommonDataPages/TX/ANTPLUS_MemoryLevelMsg.h delete mode 100644 src/CommonDataPages/TX/ANTPLUS_ModeSettingsMsg.cpp delete mode 100644 src/CommonDataPages/TX/ANTPLUS_ModeSettingsMsg.h delete mode 100644 src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp delete mode 100644 src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h delete mode 100644 src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.cpp delete mode 100644 src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.h delete mode 100644 src/CommonDataPages/TX/ANTPLUS_OpenChannelCommandMsg.cpp delete mode 100644 src/CommonDataPages/TX/ANTPLUS_OpenChannelCommandMsg.h delete mode 100644 src/CommonDataPages/TX/ANTPLUS_PairedDevicesMsg.cpp delete mode 100644 src/CommonDataPages/TX/ANTPLUS_PairedDevicesMsg.h delete mode 100644 src/CommonDataPages/TX/ANTPLUS_ProductInformationMsg.cpp delete mode 100644 src/CommonDataPages/TX/ANTPLUS_ProductInformationMsg.h delete mode 100644 src/CommonDataPages/TX/ANTPLUS_RequestDataPageMsg.cpp delete mode 100644 src/CommonDataPages/TX/ANTPLUS_RequestDataPageMsg.h delete mode 100644 src/CommonDataPages/TX/ANTPLUS_SubfieldDataMsg.cpp delete mode 100644 src/CommonDataPages/TX/ANTPLUS_SubfieldDataMsg.h delete mode 100644 src/CommonDataPages/TX/ANTPLUS_TimeAndDateMsg.cpp delete mode 100644 src/CommonDataPages/TX/ANTPLUS_TimeAndDateMsg.h diff --git a/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp b/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp index 5b99557..9350293 100644 --- a/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp +++ b/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include BaseMasterProfile::BaseMasterProfile(uint16_t deviceNumber, uint8_t transmissionType) : BaseProfile(deviceNumber, transmissionType) { } 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..3f18820 --- /dev/null +++ b/src/CommonDataPages/ANTPLUS_BatteryStatus.cpp @@ -0,0 +1,121 @@ +#include +#include +#include + + +template +BaseBatteryStatus::BaseBatteryStatus() : CoreDataPage() {} + +template +uint8_t BaseBatteryStatus::getNumberOfBatteries() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_NUMBEROFBATTERIES_MASK); +} + +template +uint8_t BaseBatteryStatus::getBatteryIdentifier() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_IDENTIFIER_MASK, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_IDENTIFIER_SHIFT); +} + +template +uint32_t BaseBatteryStatus::getCumulativeOperatingTime() { + return this->get24BitValue( + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIME_LSB_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIME_MSB_BYTE); +} + +template +uint8_t BaseBatteryStatus::getFractionalBatteryVoltage() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE); +} + +template +uint8_t BaseBatteryStatus::getCoarseBatteryVoltage() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_COARSEBATTERYVOLTAGE_MASK); +} + +template +uint8_t BaseBatteryStatus::getBatteryStatus() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BATTERYSTATUS_MASK, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BATTERYSTATUS_SHIFT); +} + +template +uint8_t BaseBatteryStatus::getCumulativeOperatingTimeResolution() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_MASK, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_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( + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_RESERVED_VALUE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_RESERVED_BYTE); +} + +void BatteryStatusMsg::setNumberOfBatteries(uint8_t num) { + set8BitValue(num, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_NUMBEROFBATTERIES_MASK); +} + +void BatteryStatusMsg::setBatteryIdentifier(uint8_t id) { + set8BitValue(id, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_IDENTIFIER_MASK, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_IDENTIFIER_SHIFT); +} + +void BatteryStatusMsg::setCumulativeOperatingTime(uint32_t time) { + set24BitValue(time, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIME_LSB_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIME_MSB_BYTE); +} + +void BatteryStatusMsg::setFractionalBatteryVoltage(uint8_t voltage) { + set8BitValue(voltage, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE); +} + +void BatteryStatusMsg::setCoarseBatteryVoltage(uint8_t voltage) { + set8BitValue(voltage, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_COARSEBATTERYVOLTAGE_MASK); +} + +void BatteryStatusMsg::setBatteryStatus(uint8_t status) { + set8BitValue(status, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BATTERYSTATUS_MASK, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BATTERYSTATUS_SHIFT); +} + +void BatteryStatusMsg::setCumulativeOperatingTimeResolution(uint8_t resolution) { + set8BitValue(resolution, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_MASK, + ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_SHIFT); +} diff --git a/src/CommonDataPages/ANTPLUS_BatteryStatus.h b/src/CommonDataPages/ANTPLUS_BatteryStatus.h new file mode 100644 index 0000000..c218102 --- /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: + 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]; +}; + +#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_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..0e7d239 --- /dev/null +++ b/src/CommonDataPages/ANTPLUS_ManufacturersInformation.cpp @@ -0,0 +1,61 @@ +#include +#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; + +ManufacturersInformation::ManufacturersInformation(AntRxDataResponse& dp) : + BaseDataPage(dp), + BaseManufacturersInformation() {} + +// 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/ANTPLUS_ManufacturersInformation.h b/src/CommonDataPages/ANTPLUS_ManufacturersInformation.h new file mode 100644 index 0000000..5fbbe32 --- /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]; +}; + +#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/Base/ANTPLUS_BaseModeSettings.cpp b/src/CommonDataPages/ANTPLUS_ModeSettings.cpp similarity index 69% rename from src/CommonDataPages/Base/ANTPLUS_BaseModeSettings.cpp rename to src/CommonDataPages/ANTPLUS_ModeSettings.cpp index 91c8de8..17994b3 100644 --- a/src/CommonDataPages/Base/ANTPLUS_BaseModeSettings.cpp +++ b/src/CommonDataPages/ANTPLUS_ModeSettings.cpp @@ -1,4 +1,4 @@ -#include +#include #include template @@ -13,3 +13,7 @@ uint8_t BaseModeSettings::getSportMode() { template class BaseModeSettings; template class BaseModeSettings; + +ModeSettings::ModeSettings(AntRxDataResponse& dp) : + BaseDataPage(dp), + BaseModeSettings() {} diff --git a/src/CommonDataPages/RX/ANTPLUS_ModeSettings.h b/src/CommonDataPages/ANTPLUS_ModeSettings.h similarity index 51% rename from src/CommonDataPages/RX/ANTPLUS_ModeSettings.h rename to src/CommonDataPages/ANTPLUS_ModeSettings.h index dc19550..438c129 100644 --- a/src/CommonDataPages/RX/ANTPLUS_ModeSettings.h +++ b/src/CommonDataPages/ANTPLUS_ModeSettings.h @@ -2,15 +2,24 @@ #define ANTPLUS_MODESETTINGS_h #include -#include - -#include "ANT.h" +#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 { +// TODO +}; + #endif // ANTPLUS_MODESETTINGS_h diff --git a/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp b/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp new file mode 100644 index 0000000..9b6a776 --- /dev/null +++ b/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp @@ -0,0 +1,88 @@ +#include +#include +#include + +template +BaseMultiComponentSystemManufacturersInformation::BaseMultiComponentSystemManufacturersInformation() : + CoreDataPage() {} + +template +uint8_t BaseMultiComponentSystemManufacturersInformation::getNumberOfComponents() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_NUMBERCOMPONENTS_MASK); +} + +template +uint8_t BaseMultiComponentSystemManufacturersInformation::getComponentIdentifier() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_MASK, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); +} + +template +uint8_t BaseMultiComponentSystemManufacturersInformation::getHWRevision() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_HWREVISION_BYTE); +} + +template +uint16_t BaseMultiComponentSystemManufacturersInformation::getManufacturerId() { + return this->get16BitValue( + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_LSB_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_MSB_BYTE); +} + +template +uint16_t BaseMultiComponentSystemManufacturersInformation::getModelNumber() { + return this->get16BitValue( + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MODELNUMBER_LSB_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_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); +} + +void MultiComponentSystemManufacturersInformationMsg::setNumberOfComponents(uint8_t count) { + set8BitValue(count, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_NUMBERCOMPONENTS_MASK); +} + +void MultiComponentSystemManufacturersInformationMsg::setComponentIdentifier(uint8_t identifier) { + set8BitValue(identifier, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_MASK, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); +} + +void MultiComponentSystemManufacturersInformationMsg::setHWRevision(uint8_t rev) { + set8BitValue(rev, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_HWREVISION_BYTE); +} + +void MultiComponentSystemManufacturersInformationMsg::setManufacturerId(uint16_t id) { + set16BitValue(id, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_LSB_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_MSB_BYTE); +} + +void MultiComponentSystemManufacturersInformationMsg::setModelNumber(uint16_t model) { + set16BitValue(model, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MODELNUMBER_LSB_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MODELNUMBER_MSB_BYTE); +} diff --git a/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.h b/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.h new file mode 100644 index 0000000..6c34685 --- /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]; +}; + +#endif // ANTPLUS_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_h diff --git a/src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.cpp b/src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.cpp new file mode 100644 index 0000000..4ba3ea2 --- /dev/null +++ b/src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.cpp @@ -0,0 +1,86 @@ +#include +#include +#include + +template +BaseMultiComponentSystemProductInformation::BaseMultiComponentSystemProductInformation() : + CoreDataPage() {} + +template +uint8_t BaseMultiComponentSystemProductInformation::getNumberOfComponents() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_NUMBEROFCOMPONENTS_MASK); +} + +template +uint8_t BaseMultiComponentSystemProductInformation::getComponentIdentifier() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_MASK, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); +} + +template +uint8_t BaseMultiComponentSystemProductInformation::getSWRevisionSupplemental() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SWREVISIONSUPPLEMENTAL_BYTE); +} + +template +uint8_t BaseMultiComponentSystemProductInformation::getSWRevisionMain() { + return this->get8BitValue( + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SWREVISIONMAIN_BYTE); +} + +template +uint32_t BaseMultiComponentSystemProductInformation::getSerialNumber() { + return this->get32BitValue( + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SERIALNUMBER_LSB_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_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, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_NUMBEROFCOMPONENTS_MASK); +} + +void MultiComponentSystemProductInformationMsg::setComponentIdentifier(uint8_t identifier) { + set8BitValue(identifier, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_MASK, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); +} + +void MultiComponentSystemProductInformationMsg::setSWRevisionSupplemental(uint8_t revision) { + set8BitValue(revision, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SWREVISIONSUPPLEMENTAL_BYTE); +} + +void MultiComponentSystemProductInformationMsg::setSWRevisionMain(uint8_t revision) { + set8BitValue(revision, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SWREVISIONMAIN_BYTE); +} + +void MultiComponentSystemProductInformationMsg::setSerialNumber(uint32_t serialNumber) { + set32BitValue(serialNumber, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SERIALNUMBER_LSB_BYTE, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SERIALNUMBER_MSB_BYTE); +} diff --git a/src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.h b/src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.h new file mode 100644 index 0000000..3736f92 --- /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]; +}; + +#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..c541c4a --- /dev/null +++ b/src/CommonDataPages/ANTPLUS_ProductInformation.cpp @@ -0,0 +1,57 @@ +#include +#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; + +ProductInformation::ProductInformation(AntRxDataResponse& dp) : + BaseDataPage(dp), + BaseProductInformation() {} + +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/ANTPLUS_ProductInformation.h b/src/CommonDataPages/ANTPLUS_ProductInformation.h new file mode 100644 index 0000000..5a94ddb --- /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]; +}; + +#endif // ANTPLUS_PRODUCTINFORMATION_h diff --git a/src/CommonDataPages/ANTPLUS_RequestDataPage.cpp b/src/CommonDataPages/ANTPLUS_RequestDataPage.cpp new file mode 100644 index 0000000..575db85 --- /dev/null +++ b/src/CommonDataPages/ANTPLUS_RequestDataPage.cpp @@ -0,0 +1,119 @@ +#include +#include +#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; + +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, + ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_SLAVESERIALNUMBER_LSB_BYTE, + ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_SLAVESERIALNUMBER_MSB_BYTE); +} + +void RequestDataPageMsg::setDescriptorByte1(uint8_t descriptorByte) { + set8BitValue(descriptorByte, + ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE1_BYTE); +} + +void RequestDataPageMsg::setDescriptorByte2(uint8_t descriptorByte) { + set8BitValue(descriptorByte, + ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE2_BYTE); +} + +void RequestDataPageMsg::setRequestedTransmissionResponseCount(uint8_t count) { + set8BitValue(count, + ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_BYTE, + ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_COUNT_MASK); +} + +void RequestDataPageMsg::setRequestedTransmissionUseAcknowledged(uint8_t useAcknowledged) { + set8BitValue(useAcknowledged ? 1 : 0, + ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_BYTE, + ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_MASK, + ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_SHIFT); +} + +void RequestDataPageMsg::setRequestedPageNumber(uint8_t pageNumber) { + set8BitValue(pageNumber, + ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_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, + ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_COMMANDTYPE_BYTE); +} diff --git a/src/CommonDataPages/ANTPLUS_RequestDataPage.h b/src/CommonDataPages/ANTPLUS_RequestDataPage.h new file mode 100644 index 0000000..14358b8 --- /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 getRequestedPageCount(); + uint8_t getUseAcknowledgedMsgs(); + 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]; +}; + +#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_BaseBatteryStatus.cpp b/src/CommonDataPages/Base/ANTPLUS_BaseBatteryStatus.cpp deleted file mode 100644 index a47cc99..0000000 --- a/src/CommonDataPages/Base/ANTPLUS_BaseBatteryStatus.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include - -template -BaseBatteryStatus::BaseBatteryStatus() : CoreDataPage() { -} - -template -uint8_t BaseBatteryStatus::getNumberOfBatteries() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_NUMBEROFBATTERIES_MASK); -} - -template -uint8_t BaseBatteryStatus::getBatteryIdentifier() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_IDENTIFIER_MASK, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_IDENTIFIER_SHIFT); -} - -template -uint32_t BaseBatteryStatus::getCumulativeOperatingTime() { - return this->get24BitValue( - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIME_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIME_MSB_BYTE); -} - -template -uint8_t BaseBatteryStatus::getFractionalBatteryVoltage() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE); -} - -template -uint8_t BaseBatteryStatus::getCoarseBatteryVoltage() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_COARSEBATTERYVOLTAGE_MASK); -} - -template -uint8_t BaseBatteryStatus::getBatteryStatus() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BATTERYSTATUS_MASK, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BATTERYSTATUS_SHIFT); -} - -template -uint8_t BaseBatteryStatus::getCumulativeOperatingTimeResolution() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_MASK, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_SHIFT); -} - -template class BaseBatteryStatus; -template class BaseBatteryStatus; diff --git a/src/CommonDataPages/Base/ANTPLUS_BaseBatteryStatus.h b/src/CommonDataPages/Base/ANTPLUS_BaseBatteryStatus.h deleted file mode 100644 index 1513edf..0000000 --- a/src/CommonDataPages/Base/ANTPLUS_BaseBatteryStatus.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef ANTPLUS_BASEBATTERYSTATUS_h -#define ANTPLUS_BASEBATTERYSTATUS_h - -#include - -#include "ANT.h" - -// 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(); -}; - -#endif // ANTPLUS_BASEBATTERYSTATUS_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.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_BaseMultiComponentSystemManufacturersInformation.cpp b/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemManufacturersInformation.cpp deleted file mode 100644 index 69ed76a..0000000 --- a/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemManufacturersInformation.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include - -template -BaseMultiComponentSystemManufacturersInformation::BaseMultiComponentSystemManufacturersInformation() : CoreDataPage() { -} - -template -uint8_t BaseMultiComponentSystemManufacturersInformation::getNumberOfComponents() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_NUMBERCOMPONENTS_MASK); -} - -template -uint8_t BaseMultiComponentSystemManufacturersInformation::getComponentIdentifier() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_MASK, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); -} - -template -uint8_t BaseMultiComponentSystemManufacturersInformation::getHWRevision() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_HWREVISION_BYTE); -} - -template -uint16_t BaseMultiComponentSystemManufacturersInformation::getManufacturerId() { - return this->get16BitValue( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_MSB_BYTE); -} - -template -uint16_t BaseMultiComponentSystemManufacturersInformation::getModelNumber() { - return this->get16BitValue( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MODELNUMBER_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MODELNUMBER_MSB_BYTE); -} - -template class BaseMultiComponentSystemManufacturersInformation; -template class BaseMultiComponentSystemManufacturersInformation; diff --git a/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemManufacturersInformation.h b/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemManufacturersInformation.h deleted file mode 100644 index d5b8e70..0000000 --- a/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemManufacturersInformation.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef ANTPLUS_BASEMULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_h -#define ANTPLUS_BASEMULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_h - -#include - -#include "ANT.h" - -// 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(); -}; - -#endif // ANTPLUS_BASEMULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_h diff --git a/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemProductInformation.cpp b/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemProductInformation.cpp deleted file mode 100644 index 2ba388d..0000000 --- a/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemProductInformation.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include - -template -BaseMultiComponentSystemProductInformation::BaseMultiComponentSystemProductInformation() : CoreDataPage() { -} - -template -uint8_t BaseMultiComponentSystemProductInformation::getNumberOfComponents() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_NUMBEROFCOMPONENTS_MASK); -} - -template -uint8_t BaseMultiComponentSystemProductInformation::getComponentIdentifier() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_MASK, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); -} - -template -uint8_t BaseMultiComponentSystemProductInformation::getSWRevisionSupplemental() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SWREVISIONSUPPLEMENTAL_BYTE); -} - -template -uint8_t BaseMultiComponentSystemProductInformation::getSWRevisionMain() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SWREVISIONMAIN_BYTE); -} - -template -uint32_t BaseMultiComponentSystemProductInformation::getSerialNumber() { - return this->get32BitValue( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SERIALNUMBER_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SERIALNUMBER_MSB_BYTE); -} - -template class BaseMultiComponentSystemProductInformation; -template class BaseMultiComponentSystemProductInformation; diff --git a/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemProductInformation.h b/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemProductInformation.h deleted file mode 100644 index 3ebd3e8..0000000 --- a/src/CommonDataPages/Base/ANTPLUS_BaseMultiComponentSystemProductInformation.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef ANTPLUS_BASEMULTICOMPONENTSYSTEMPRODUCTINFORMATION_h -#define ANTPLUS_BASEMULTICOMPONENTSYSTEMPRODUCTINFORMATION_h - -#include - -#include "ANT.h" - -// 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(); -}; - -#endif // ANTPLUS_BASEMULTICOMPONENTSYSTEMPRODUCTINFORMATION_h diff --git a/src/CommonDataPages/Base/ANTPLUS_BaseProductInformation.cpp b/src/CommonDataPages/Base/ANTPLUS_BaseProductInformation.cpp deleted file mode 100644 index 5cad09d..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 0e690f0..0000000 --- a/src/CommonDataPages/RX/ANTPLUS_BatteryStatus.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include - -BatteryStatus::BatteryStatus(AntRxDataResponse& dp) : BaseDataPage(dp), BaseBatteryStatus() { -} diff --git a/src/CommonDataPages/RX/ANTPLUS_BatteryStatus.h b/src/CommonDataPages/RX/ANTPLUS_BatteryStatus.h deleted file mode 100644 index a8e12e6..0000000 --- a/src/CommonDataPages/RX/ANTPLUS_BatteryStatus.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef ANTPLUS_BATTERYSTATUS_h -#define ANTPLUS_BATTERYSTATUS_h - -#include -#include - -#include "ANT.h" - -// Common page 82 - -class BatteryStatus : public BaseDataPage, public BaseBatteryStatus { -public: - BatteryStatus(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_BATTERYSTATUS_h 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 f7c432e..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: - explicit 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_MultiComponentSystemManufacturersInformation.cpp b/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp deleted file mode 100644 index a89f9ec..0000000 --- a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include - -MultiComponentSystemManufacturersInformation::MultiComponentSystemManufacturersInformation(AntRxDataResponse& dp) : BaseDataPage(dp), BaseMultiComponentSystemManufacturersInformation() { -} diff --git a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.h b/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.h deleted file mode 100644 index 203ed1d..0000000 --- a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemManufacturersInformation.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef ANTPLUS_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_h -#define ANTPLUS_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_h - -#include -#include - -#include "ANT.h" - -// Common page 78 - -class MultiComponentSystemManufacturersInformation : public BaseDataPage, public BaseMultiComponentSystemManufacturersInformation { -public: - explicit MultiComponentSystemManufacturersInformation(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_h diff --git a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.cpp b/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.cpp deleted file mode 100644 index 0ab0418..0000000 --- a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include - -MultiComponentSystemProductInformation::MultiComponentSystemProductInformation(AntRxDataResponse& dp) : BaseDataPage(dp), BaseMultiComponentSystemProductInformation() { -} diff --git a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.h b/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.h deleted file mode 100644 index c72be58..0000000 --- a/src/CommonDataPages/RX/ANTPLUS_MultiComponentSystemProductInformation.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef ANTPLUS_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_h -#define ANTPLUS_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_h - -#include -#include - -#include "ANT.h" - -// Common page 79 - -class MultiComponentSystemProductInformation : public BaseDataPage, public BaseMultiComponentSystemProductInformation { -public: - explicit MultiComponentSystemProductInformation(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_h 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 93733dd..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: - explicit 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 8792bc4..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: - explicit 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 1675534..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include -#include - -BatteryStatusMsg::BatteryStatusMsg() : BaseDataPageMsg(), BaseBatteryStatus() { - setDataBuffer(_buffer); - set8BitValue( - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER, - ANTPLUS_DEFAULT_DATAPAGE_BYTE); - set8BitValue( - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_RESERVED_VALUE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_RESERVED_BYTE); -} - -void BatteryStatusMsg::setNumberOfBatteries(uint8_t num) { - set8BitValue(num, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_NUMBEROFBATTERIES_MASK); -} - -void BatteryStatusMsg::setBatteryIdentifier(uint8_t id) { - set8BitValue(id, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_IDENTIFIER_MASK, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_IDENTIFIER_SHIFT); -} - -void BatteryStatusMsg::setCumulativeOperatingTime(uint32_t time) { - set24BitValue(time, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIME_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIME_MSB_BYTE); -} - -void BatteryStatusMsg::setFractionalBatteryVoltage(uint8_t voltage) { - set8BitValue(voltage, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE); -} - -void BatteryStatusMsg::setCoarseBatteryVoltage(uint8_t voltage) { - set8BitValue(voltage, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_COARSEBATTERYVOLTAGE_MASK); -} - -void BatteryStatusMsg::setBatteryStatus(uint8_t status) { - set8BitValue(status, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BATTERYSTATUS_MASK, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BATTERYSTATUS_SHIFT); -} - -void BatteryStatusMsg::setCumulativeOperatingTimeResolution(uint8_t resolution) { - set8BitValue(resolution, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_MASK, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_SHIFT); -} diff --git a/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.h b/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.h deleted file mode 100644 index 2df3c1f..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_BatteryStatusMsg.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef ANTPLUS_BATTERYSTATUSMSG_h -#define ANTPLUS_BATTERYSTATUSMSG_h - -#include -#include - -#include "ANT.h" - -// Common page 82 - -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]; -}; - -#endif // ANTPLUS_BATTERYSTATUSMSG_h 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 f7245d2..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_ManufacturersInformationMsg.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#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 257bd7e..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include -#include - -MultiComponentSystemManufacturersInformationMsg::MultiComponentSystemManufacturersInformationMsg() : BaseDataPageMsg(), BaseMultiComponentSystemManufacturersInformation() { - setDataBuffer(_buffer); - set8BitValue( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER, - ANTPLUS_DEFAULT_DATAPAGE_BYTE); -} - -void MultiComponentSystemManufacturersInformationMsg::setNumberOfComponents(uint8_t count) { - set8BitValue(count, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_NUMBERCOMPONENTS_MASK); -} - -void MultiComponentSystemManufacturersInformationMsg::setComponentIdentifier(uint8_t identifier) { - set8BitValue(identifier, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_MASK, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); -} - -void MultiComponentSystemManufacturersInformationMsg::setHWRevision(uint8_t rev) { - set8BitValue(rev, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_HWREVISION_BYTE); -} - -void MultiComponentSystemManufacturersInformationMsg::setManufacturerId(uint16_t id) { - set16BitValue(id, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_MSB_BYTE); -} - -void MultiComponentSystemManufacturersInformationMsg::setModelNumber(uint16_t model) { - set16BitValue(model, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MODELNUMBER_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MODELNUMBER_MSB_BYTE); -} diff --git a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h deleted file mode 100644 index ed2b1ad..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemManufacturersInformationMsg.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef ANTPLUS_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATIONMSG_h -#define ANTPLUS_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATIONMSG_h - -#include -#include - -#include "ANT.h" - -// Common page 78 - -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]; -}; - -#endif // ANTPLUS_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATIONMSG_h diff --git a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.cpp b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.cpp deleted file mode 100644 index 2b7fa6f..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include - -MultiComponentSystemProductInformationMsg::MultiComponentSystemProductInformationMsg() : BaseDataPageMsg(), BaseMultiComponentSystemProductInformation() { - setDataBuffer(_buffer); - set8BitValue( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER, - ANTPLUS_DEFAULT_DATAPAGE_BYTE); -} - -void MultiComponentSystemProductInformationMsg::setNumberOfComponents(uint8_t count) { - set8BitValue(count, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_NUMBEROFCOMPONENTS_MASK); -} - -void MultiComponentSystemProductInformationMsg::setComponentIdentifier(uint8_t identifier) { - set8BitValue(identifier, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_MASK, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); -} - -void MultiComponentSystemProductInformationMsg::setSWRevisionSupplemental(uint8_t revision) { - set8BitValue(revision, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SWREVISIONSUPPLEMENTAL_BYTE); -} - -void MultiComponentSystemProductInformationMsg::setSWRevisionMain(uint8_t revision) { - set8BitValue(revision, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SWREVISIONMAIN_BYTE); -} - -void MultiComponentSystemProductInformationMsg::setSerialNumber(uint32_t serialNumber) { - set32BitValue(serialNumber, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SERIALNUMBER_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SERIALNUMBER_MSB_BYTE); -} diff --git a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.h b/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.h deleted file mode 100644 index d038461..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_MultiComponentSystemProductInformationMsg.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef ANTPLUS_MULTICOMPONENTSYSTEMPRODUCTINFORMATIONMSG_h -#define ANTPLUS_MULTICOMPONENTSYSTEMPRODUCTINFORMATIONMSG_h - -#include -#include - -#include "ANT.h" - -// Common page 79 - -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]; -}; - -#endif // ANTPLUS_MULTICOMPONENTSYSTEMPRODUCTINFORMATIONMSG_h 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 2e41cb9..0000000 --- a/src/CommonDataPages/TX/ANTPLUS_RequestDataPageMsg.cpp +++ /dev/null @@ -1,54 +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); - set8BitValue(ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER, - ANTPLUS_DEFAULT_DATAPAGE_BYTE); -} - -void RequestDataPageMsg::setSlaveSerialNumber(uint16_t serialNumber) { - set16BitValue(serialNumber, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_SLAVESERIALNUMBER_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_SLAVESERIALNUMBER_MSB_BYTE); -} - -void RequestDataPageMsg::setDescriptorByte1(uint8_t descriptorByte) { - set8BitValue(descriptorByte, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE1_BYTE); -} - -void RequestDataPageMsg::setDescriptorByte2(uint8_t descriptorByte) { - set8BitValue(descriptorByte, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE2_BYTE); -} - -void RequestDataPageMsg::setRequestedTransmissionResponseCount(uint8_t count) { - set8BitValue(count, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_BYTE, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_COUNT_MASK); -} - -void RequestDataPageMsg::setRequestedTransmissionUseAcknowledged(uint8_t useAcknowledged) { - set8BitValue(useAcknowledged ? 1 : 0, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_BYTE, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_MASK, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_SHIFT); -} - -void RequestDataPageMsg::setRequestedPageNumber(uint8_t pageNumber) { - set8BitValue(pageNumber, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_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, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_COMMANDTYPE_BYTE); -} 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/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp index c9abbdb..aea7ff0 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #define DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE diff --git a/src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.cpp b/src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.cpp index 3727088..b5b5675 100644 --- a/src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.cpp +++ b/src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include ProfileBicycleSpeedDisplay::ProfileBicycleSpeedDisplay() : BaseSlaveProfile() { diff --git a/src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.cpp b/src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.cpp index 7b1c9c6..f2ad990 100644 --- a/src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.cpp +++ b/src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.cpp @@ -1,8 +1,6 @@ #include #include #include -#include -#include ProfileFECDisplay::ProfileFECDisplay() : BaseSlaveProfile() { setChannelConfig(); @@ -56,4 +54,4 @@ void ProfileFECDisplay::setChannelConfig() { bool ProfileFECDisplay::handleTrainerData(BaseDataPage& dataPage) { FECTrainerData dp = FECTrainerData(dataPage); return _onFECTrainerData.call(dp); -} \ No newline at end of file +} diff --git a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp index ea3b148..d2cb475 100644 --- a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #define DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE diff --git a/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.cpp b/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.cpp index 29886a3..d55c66c 100644 --- a/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.cpp +++ b/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include ProfileLevDisplay::ProfileLevDisplay() : BaseSlaveProfile() { From 60c5ca4ad1b2bacc43bb827aac7fde4390c49215 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 17 Jan 2021 16:36:23 -0800 Subject: [PATCH 099/241] CommonDataPages: refactor step 2 move all defines out to their local files, reduce this oversized define sillyness --- src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp | 2 +- src/CommonDataPages/ANTPLUS_BatteryStatus.cpp | 101 ++++++++--------- .../ANTPLUS_CommonDataPagePrivateDefines.h | 107 ++---------------- .../ANTPLUS_ManufacturersInformation.cpp | 31 +++-- src/CommonDataPages/ANTPLUS_ModeSettings.cpp | 10 +- ...omponentSystemManufacturersInformation.cpp | 58 +++++----- ...MultiComponentSystemProductInformation.cpp | 56 +++++---- .../ANTPLUS_ProductInformation.cpp | 27 ++--- .../ANTPLUS_RequestDataPage.cpp | 70 ++++++------ .../ANTPLUS_ProfileBicyclePowerDisplay.cpp | 6 +- .../ANTPLUS_ProfileBicyclePowerSensor.cpp | 2 +- .../ANTPLUS_ProfileEnvironmentDisplay.cpp | 4 +- .../ANTPLUS_ProfileHeartRateMonitor.cpp | 4 +- .../Lev/Display/ANTPLUS_ProfileLevDisplay.cpp | 4 +- .../ANTPLUS_ProfileShiftingShifter.cpp | 14 +-- 15 files changed, 194 insertions(+), 302 deletions(-) diff --git a/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp b/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp index 9350293..7f6e0de 100644 --- a/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp +++ b/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp @@ -20,7 +20,7 @@ void BaseMasterProfile::onAcknowledgedData(AcknowledgedData& msg) { BaseProfile::onAcknowledgedData(msg); BaseDataPage dp(msg); - if (dp.getDataPageNumber() == ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER) { + if (dp.getDataPageNumber() == REQUESTDATAPAGE_NUMBER) { handleRequestDataPage(msg); } } diff --git a/src/CommonDataPages/ANTPLUS_BatteryStatus.cpp b/src/CommonDataPages/ANTPLUS_BatteryStatus.cpp index 3f18820..33b10e6 100644 --- a/src/CommonDataPages/ANTPLUS_BatteryStatus.cpp +++ b/src/CommonDataPages/ANTPLUS_BatteryStatus.cpp @@ -2,59 +2,68 @@ #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( - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_NUMBEROFBATTERIES_MASK); + return this->get8BitValue(BATTERYIDENTIFIER_BYTE, + BATTERYIDENTIFIER_NUMBEROFBATTERIES_MASK); } template uint8_t BaseBatteryStatus::getBatteryIdentifier() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_IDENTIFIER_MASK, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_IDENTIFIER_SHIFT); + return this->get8BitValue(BATTERYIDENTIFIER_BYTE, + BATTERYIDENTIFIER_IDENTIFIER_MASK, + BATTERYIDENTIFIER_IDENTIFIER_SHIFT); } template uint32_t BaseBatteryStatus::getCumulativeOperatingTime() { - return this->get24BitValue( - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIME_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIME_MSB_BYTE); + return this->get24BitValue(CUMULATIVEOPERATINGTIME_LSB_BYTE, + CUMULATIVEOPERATINGTIME_MSB_BYTE); } template uint8_t BaseBatteryStatus::getFractionalBatteryVoltage() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE); + return this->get8BitValue(FRACTIONALBATTERYVOLTAGE_BYTE); } template uint8_t BaseBatteryStatus::getCoarseBatteryVoltage() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_COARSEBATTERYVOLTAGE_MASK); + return this->get8BitValue(DESCRIPTIVEBITFIELD_BYTE, + DESCRIPTIVEBITFIELD_COARSEBATTERYVOLTAGE_MASK); } template uint8_t BaseBatteryStatus::getBatteryStatus() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BATTERYSTATUS_MASK, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BATTERYSTATUS_SHIFT); + return this->get8BitValue(DESCRIPTIVEBITFIELD_BYTE, + DESCRIPTIVEBITFIELD_BATTERYSTATUS_MASK, + DESCRIPTIVEBITFIELD_BATTERYSTATUS_SHIFT); } template uint8_t BaseBatteryStatus::getCumulativeOperatingTimeResolution() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_MASK, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_SHIFT); + return this->get8BitValue(DESCRIPTIVEBITFIELD_BYTE, + DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_MASK, + DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_SHIFT); } template class BaseBatteryStatus; @@ -68,54 +77,42 @@ BatteryStatusMsg::BatteryStatusMsg() : BaseDataPageMsg(), BaseBatteryStatus() { setDataBuffer(_buffer); - set8BitValue( - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER, - ANTPLUS_DEFAULT_DATAPAGE_BYTE); - set8BitValue( - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_RESERVED_VALUE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_RESERVED_BYTE); + set8BitValue(BATTERYSTATUS_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); + set8BitValue(RESERVED_VALUE, RESERVED_BYTE); } void BatteryStatusMsg::setNumberOfBatteries(uint8_t num) { - set8BitValue(num, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_NUMBEROFBATTERIES_MASK); + set8BitValue(num, BATTERYIDENTIFIER_BYTE, + BATTERYIDENTIFIER_NUMBEROFBATTERIES_MASK); } void BatteryStatusMsg::setBatteryIdentifier(uint8_t id) { - set8BitValue(id, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_IDENTIFIER_MASK, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_IDENTIFIER_SHIFT); + set8BitValue(id, BATTERYIDENTIFIER_BYTE, BATTERYIDENTIFIER_IDENTIFIER_MASK, + BATTERYIDENTIFIER_IDENTIFIER_SHIFT); } void BatteryStatusMsg::setCumulativeOperatingTime(uint32_t time) { - set24BitValue(time, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIME_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIME_MSB_BYTE); + set24BitValue(time, CUMULATIVEOPERATINGTIME_LSB_BYTE, + CUMULATIVEOPERATINGTIME_MSB_BYTE); } void BatteryStatusMsg::setFractionalBatteryVoltage(uint8_t voltage) { - set8BitValue(voltage, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE); + set8BitValue(voltage, FRACTIONALBATTERYVOLTAGE_BYTE); } void BatteryStatusMsg::setCoarseBatteryVoltage(uint8_t voltage) { - set8BitValue(voltage, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_COARSEBATTERYVOLTAGE_MASK); + set8BitValue(voltage, DESCRIPTIVEBITFIELD_BYTE, + DESCRIPTIVEBITFIELD_COARSEBATTERYVOLTAGE_MASK); } void BatteryStatusMsg::setBatteryStatus(uint8_t status) { - set8BitValue(status, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BATTERYSTATUS_MASK, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BATTERYSTATUS_SHIFT); + set8BitValue(status, DESCRIPTIVEBITFIELD_BYTE, + DESCRIPTIVEBITFIELD_BATTERYSTATUS_MASK, + DESCRIPTIVEBITFIELD_BATTERYSTATUS_SHIFT); } void BatteryStatusMsg::setCumulativeOperatingTimeResolution(uint8_t resolution) { - set8BitValue(resolution, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_MASK, - ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_SHIFT); + set8BitValue(resolution, DESCRIPTIVEBITFIELD_BYTE, + DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_MASK, + DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_SHIFT); } diff --git a/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h b/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h index 8972dce..2b537e8 100644 --- a/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h +++ b/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h @@ -1,105 +1,12 @@ #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 - -/* Multi-Component System Manufacturer's Information */ -#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER 78 - -#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_BYTE 2 -#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_NUMBERCOMPONENTS_MASK 0x0F -#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_MASK 0xF0 -#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_SHIFT 4 - -#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_HWREVISION_BYTE 3 - -#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_LSB_BYTE 4 -#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_MSB_BYTE 5 - -#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MODELNUMBER_LSB_BYTE 6 -#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MODELNUMBER_MSB_BYTE 7 - -/* Multi-Component System Product Information */ -#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER 79 - -#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_BYTE 1 -#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_NUMBEROFCOMPONENTS_MASK 0x0F -#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_MASK 0xF0 -#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_SHIFT 4 - -#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SWREVISIONSUPPLEMENTAL_BYTE 2 - -#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SWREVISIONMAIN_BYTE 3 - -#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SERIALNUMBER_LSB_BYTE 4 -#define ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SERIALNUMBER_MSB_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 - -/* Battery Status */ -#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER 82 - -#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_RESERVED_BYTE 1 -#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_RESERVED_VALUE 0xFF - -#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_BYTE 2 -#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_NUMBEROFBATTERIES_MASK 0x0F -#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_IDENTIFIER_MASK 0xF0 -#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYIDENTIFIER_IDENTIFIER_SHIFT 4 - -#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIME_LSB_BYTE 3 -#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIME_MSB_BYTE 5 - -#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE 6 - -#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BYTE 7 -#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_COARSEBATTERYVOLTAGE_MASK 0x0F -#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BATTERYSTATUS_MASK 0x70 -#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_BATTERYSTATUS_SHIFT 4 -#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_MASK 0x80 -#define ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_DESCRIPTIVEBITFIELD_CUMULATIVEOPERATINGTIMERESOLUTION_SHIFT 7 - +#define REQUESTDATAPAGE_NUMBER 70 +#define MODESETTINGS_NUMBER 76 +#define MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER 78 +#define MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER 79 +#define MANUFACTURERSINFORMATION_NUMBER 80 +#define PRODUCTINFORMATION_NUMBER 81 +#define BATTERYSTATUS_NUMBER 82 #endif // ANTPLUS_COMMONDATAPAGEPRIVATEDEFINES_h diff --git a/src/CommonDataPages/ANTPLUS_ManufacturersInformation.cpp b/src/CommonDataPages/ANTPLUS_ManufacturersInformation.cpp index 0e7d239..8f2887d 100644 --- a/src/CommonDataPages/ANTPLUS_ManufacturersInformation.cpp +++ b/src/CommonDataPages/ANTPLUS_ManufacturersInformation.cpp @@ -2,28 +2,30 @@ #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 + template BaseManufacturersInformation::BaseManufacturersInformation() : CoreDataPage() {} template uint8_t BaseManufacturersInformation::getHWRevision() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_HWREVISION_BYTE); + return this->get8BitValue(HWREVISION_BYTE); } template uint16_t BaseManufacturersInformation::getManufacturerID() { - return this->get16BitValue( - ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_MANUFACTURERID_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_MANUFACTURERID_MSB_BYTE); + return this->get16BitValue(MANUFACTURERID_LSB_BYTE, + 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); + return this->get16BitValue( MODELNUMBER_LSB_BYTE, MODELNUMBER_MSB_BYTE); } template class BaseManufacturersInformation; @@ -38,24 +40,19 @@ ManufacturersInformationMsg::ManufacturersInformationMsg() : BaseDataPageMsg(), BaseManufacturersInformation() { setDataBuffer(_buffer); - _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER; + _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = MANUFACTURERSINFORMATION_NUMBER; _buffer[1] = 0xFF; _buffer[2] = 0xFF; } void ManufacturersInformationMsg::setHWRevision(uint8_t revision) { - set8BitValue(revision, - ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_HWREVISION_BYTE); + set8BitValue(revision, HWREVISION_BYTE); } void ManufacturersInformationMsg::setManufacturerId(uint16_t id) { - set16BitValue(id, - ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_MANUFACTURERID_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_MANUFACTURERID_MSB_BYTE); + set16BitValue(id, MANUFACTURERID_LSB_BYTE, 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); + set16BitValue(modelNumber, MODELNUMBER_LSB_BYTE, MODELNUMBER_MSB_BYTE); } diff --git a/src/CommonDataPages/ANTPLUS_ModeSettings.cpp b/src/CommonDataPages/ANTPLUS_ModeSettings.cpp index 17994b3..610a544 100644 --- a/src/CommonDataPages/ANTPLUS_ModeSettings.cpp +++ b/src/CommonDataPages/ANTPLUS_ModeSettings.cpp @@ -1,14 +1,14 @@ #include #include +#define SPORTSMODE_BYTE 7 + template -BaseModeSettings::BaseModeSettings() : CoreDataPage() { -} +BaseModeSettings::BaseModeSettings() : CoreDataPage() {} template uint8_t BaseModeSettings::getSportMode() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_MODESETTINGS_SPORTSMODE_BYTE); + return this->get8BitValue(SPORTSMODE_BYTE); } template class BaseModeSettings; @@ -17,3 +17,5 @@ template class BaseModeSettings; ModeSettings::ModeSettings(AntRxDataResponse& dp) : BaseDataPage(dp), BaseModeSettings() {} + +// TODO ModeSettingsMsg diff --git a/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp b/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp index 9b6a776..6455e8b 100644 --- a/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp +++ b/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp @@ -2,43 +2,46 @@ #include #include +#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( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_NUMBERCOMPONENTS_MASK); + return this->get8BitValue(COMPONENTIDENTIFIER_BYTE, + COMPONENTIDENTIFIER_NUMBERCOMPONENTS_MASK); } template uint8_t BaseMultiComponentSystemManufacturersInformation::getComponentIdentifier() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_MASK, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); + return this->get8BitValue(COMPONENTIDENTIFIER_BYTE, + COMPONENTIDENTIFIER_IDENTIFIER_MASK, + COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); } template uint8_t BaseMultiComponentSystemManufacturersInformation::getHWRevision() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_HWREVISION_BYTE); + return this->get8BitValue(HWREVISION_BYTE); } template uint16_t BaseMultiComponentSystemManufacturersInformation::getManufacturerId() { - return this->get16BitValue( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_MSB_BYTE); + return this->get16BitValue(MANUFACTURERID_LSB_BYTE, MANUFACTURERID_MSB_BYTE); } template uint16_t BaseMultiComponentSystemManufacturersInformation::getModelNumber() { - return this->get16BitValue( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MODELNUMBER_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MODELNUMBER_MSB_BYTE); + return this->get16BitValue(MODELNUMBER_LSB_BYTE, MODELNUMBER_MSB_BYTE); } template class BaseMultiComponentSystemManufacturersInformation; @@ -53,36 +56,29 @@ MultiComponentSystemManufacturersInformationMsg::MultiComponentSystemManufacture BaseMultiComponentSystemManufacturersInformation() { setDataBuffer(_buffer); set8BitValue( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER, + MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); } void MultiComponentSystemManufacturersInformationMsg::setNumberOfComponents(uint8_t count) { - set8BitValue(count, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_NUMBERCOMPONENTS_MASK); + set8BitValue(count, COMPONENTIDENTIFIER_BYTE, + COMPONENTIDENTIFIER_NUMBERCOMPONENTS_MASK); } void MultiComponentSystemManufacturersInformationMsg::setComponentIdentifier(uint8_t identifier) { - set8BitValue(identifier, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_MASK, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); + set8BitValue(identifier, COMPONENTIDENTIFIER_BYTE, + COMPONENTIDENTIFIER_IDENTIFIER_MASK, + COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); } void MultiComponentSystemManufacturersInformationMsg::setHWRevision(uint8_t rev) { - set8BitValue(rev, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_HWREVISION_BYTE); + set8BitValue(rev, HWREVISION_BYTE); } void MultiComponentSystemManufacturersInformationMsg::setManufacturerId(uint16_t id) { - set16BitValue(id, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MANUFACTURERID_MSB_BYTE); + set16BitValue(id, MANUFACTURERID_LSB_BYTE, MANUFACTURERID_MSB_BYTE); } void MultiComponentSystemManufacturersInformationMsg::setModelNumber(uint16_t model) { - set16BitValue(model, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MODELNUMBER_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_MODELNUMBER_MSB_BYTE); + set16BitValue(model, MODELNUMBER_LSB_BYTE, MODELNUMBER_MSB_BYTE); } diff --git a/src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.cpp b/src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.cpp index 4ba3ea2..456fa84 100644 --- a/src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.cpp +++ b/src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.cpp @@ -2,42 +2,45 @@ #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( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_NUMBEROFCOMPONENTS_MASK); + return this->get8BitValue(COMPONENTIDENTIFIER_BYTE, + COMPONENTIDENTIFIER_NUMBEROFCOMPONENTS_MASK); } template uint8_t BaseMultiComponentSystemProductInformation::getComponentIdentifier() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_MASK, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); + return this->get8BitValue(COMPONENTIDENTIFIER_BYTE, + COMPONENTIDENTIFIER_IDENTIFIER_MASK, + COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); } template uint8_t BaseMultiComponentSystemProductInformation::getSWRevisionSupplemental() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SWREVISIONSUPPLEMENTAL_BYTE); + return this->get8BitValue(SWREVISIONSUPPLEMENTAL_BYTE); } template uint8_t BaseMultiComponentSystemProductInformation::getSWRevisionMain() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SWREVISIONMAIN_BYTE); + return this->get8BitValue(SWREVISIONMAIN_BYTE); } template uint32_t BaseMultiComponentSystemProductInformation::getSerialNumber() { - return this->get32BitValue( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SERIALNUMBER_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SERIALNUMBER_MSB_BYTE); + return this->get32BitValue(SERIALNUMBER_LSB_BYTE, SERIALNUMBER_MSB_BYTE); } template class BaseMultiComponentSystemProductInformation; @@ -51,36 +54,29 @@ MultiComponentSystemProductInformationMsg::MultiComponentSystemProductInformatio BaseDataPageMsg(), BaseMultiComponentSystemProductInformation() { setDataBuffer(_buffer); - set8BitValue( - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER, + set8BitValue(MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); } void MultiComponentSystemProductInformationMsg::setNumberOfComponents(uint8_t count) { - set8BitValue(count, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_NUMBEROFCOMPONENTS_MASK); + set8BitValue(count, COMPONENTIDENTIFIER_BYTE, + COMPONENTIDENTIFIER_NUMBEROFCOMPONENTS_MASK); } void MultiComponentSystemProductInformationMsg::setComponentIdentifier(uint8_t identifier) { - set8BitValue(identifier, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_MASK, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); + set8BitValue(identifier, COMPONENTIDENTIFIER_BYTE, + COMPONENTIDENTIFIER_IDENTIFIER_MASK, + COMPONENTIDENTIFIER_IDENTIFIER_SHIFT); } void MultiComponentSystemProductInformationMsg::setSWRevisionSupplemental(uint8_t revision) { - set8BitValue(revision, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SWREVISIONSUPPLEMENTAL_BYTE); + set8BitValue(revision, SWREVISIONSUPPLEMENTAL_BYTE); } void MultiComponentSystemProductInformationMsg::setSWRevisionMain(uint8_t revision) { - set8BitValue(revision, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SWREVISIONMAIN_BYTE); + set8BitValue(revision, SWREVISIONMAIN_BYTE); } void MultiComponentSystemProductInformationMsg::setSerialNumber(uint32_t serialNumber) { - set32BitValue(serialNumber, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SERIALNUMBER_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_SERIALNUMBER_MSB_BYTE); + set32BitValue(serialNumber, SERIALNUMBER_LSB_BYTE, SERIALNUMBER_MSB_BYTE); } diff --git a/src/CommonDataPages/ANTPLUS_ProductInformation.cpp b/src/CommonDataPages/ANTPLUS_ProductInformation.cpp index c541c4a..067d05a 100644 --- a/src/CommonDataPages/ANTPLUS_ProductInformation.cpp +++ b/src/CommonDataPages/ANTPLUS_ProductInformation.cpp @@ -2,26 +2,27 @@ #include #include +#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( - ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SWREVISIONSUPPLEMENTAL_BYTE); + return this->get8BitValue(SWREVISIONSUPPLEMENTAL_BYTE); } template uint8_t BaseProductInformation::getSWRevisionMain() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SWREVISIONMAIN_BYTE); + return this->get8BitValue(SWREVISIONMAIN_BYTE); } template uint32_t BaseProductInformation::getSerialNumber() { - return this->get32BitValue( - ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SERIALNUMBER_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SERIALNUMBER_MSB_BYTE); + return this->get32BitValue(SERIALNUMBER_LSB_BYTE, SERIALNUMBER_MSB_BYTE); } template class BaseProductInformation; @@ -36,22 +37,18 @@ ProductInformationMsg::ProductInformationMsg() : BaseProductInformation() { // TODO set default values setDataBuffer(_buffer); - _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER; + _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = PRODUCTINFORMATION_NUMBER; _buffer[1] = 0xFF; } void ProductInformationMsg::setSWRevisionSupplemental(uint8_t revision) { - set8BitValue(revision, - ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SWREVISIONSUPPLEMENTAL_BYTE); + set8BitValue(revision, SWREVISIONSUPPLEMENTAL_BYTE); } void ProductInformationMsg::setSWRevisionMain(uint8_t revision) { - set8BitValue(revision, - ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SWREVISIONMAIN_BYTE); + set8BitValue(revision, SWREVISIONMAIN_BYTE); } void ProductInformationMsg::setSerialNumber(uint32_t serialNumber) { - set32BitValue(serialNumber, - ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SERIALNUMBER_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_SERIALNUMBER_MSB_BYTE); + set32BitValue(serialNumber, SERIALNUMBER_LSB_BYTE, SERIALNUMBER_MSB_BYTE); } diff --git a/src/CommonDataPages/ANTPLUS_RequestDataPage.cpp b/src/CommonDataPages/ANTPLUS_RequestDataPage.cpp index 575db85..01c16fe 100644 --- a/src/CommonDataPages/ANTPLUS_RequestDataPage.cpp +++ b/src/CommonDataPages/ANTPLUS_RequestDataPage.cpp @@ -3,6 +3,18 @@ #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() {} @@ -10,53 +22,48 @@ BaseRequestDataPage::BaseRequestDataPage() : template uint16_t BaseRequestDataPage::getSlaveSerialNumber() { return this->get16BitValue( - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_SLAVESERIALNUMBER_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_SLAVESERIALNUMBER_MSB_BYTE); + SLAVESERIALNUMBER_LSB_BYTE, SLAVESERIALNUMBER_MSB_BYTE); } template uint8_t BaseRequestDataPage::getDescriptorByte1() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE1_BYTE); + return this->get8BitValue(DESCRIPTORBYTE1_BYTE); } template uint8_t BaseRequestDataPage::getDescriptorByte2() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE2_BYTE); + return this->get8BitValue(DESCRIPTORBYTE2_BYTE); } template uint8_t BaseRequestDataPage::getRequestedPageCount() { return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_BYTE, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_COUNT_MASK); + REQUESTEDTRANSMISSIONRESPONSE_BYTE, + 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); + REQUESTEDTRANSMISSIONRESPONSE_BYTE, + REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_MASK, + REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_SHIFT); } template uint8_t BaseRequestDataPage::transmitTillAcknowledged() { - return this->get8BitValue(ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_BYTE) - == ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_TRANSMITTILLACKNOWLEDGED_VALUE; + return this->get8BitValue(REQUESTEDTRANSMISSIONRESPONSE_BYTE) + == REQUESTEDTRANSMISSIONRESPONSE_TRANSMITTILLACKNOWLEDGED_VALUE; } template uint8_t BaseRequestDataPage::getRequestedPageNumber() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDPAGENUMBER_BYTE); + return this->get8BitValue(REQUESTEDPAGENUMBER_BYTE); } template uint8_t BaseRequestDataPage::getCommandType() { - return this->get8BitValue( - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_COMMANDTYPE_BYTE); + return this->get8BitValue(COMMANDTYPE_BYTE); } template class BaseRequestDataPage; @@ -72,48 +79,41 @@ RequestDataPageMsg::RequestDataPageMsg() : 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); + set8BitValue(REQUESTDATAPAGE_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); } void RequestDataPageMsg::setSlaveSerialNumber(uint16_t serialNumber) { set16BitValue(serialNumber, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_SLAVESERIALNUMBER_LSB_BYTE, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_SLAVESERIALNUMBER_MSB_BYTE); + SLAVESERIALNUMBER_LSB_BYTE, SLAVESERIALNUMBER_MSB_BYTE); } void RequestDataPageMsg::setDescriptorByte1(uint8_t descriptorByte) { - set8BitValue(descriptorByte, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE1_BYTE); + set8BitValue(descriptorByte, DESCRIPTORBYTE1_BYTE); } void RequestDataPageMsg::setDescriptorByte2(uint8_t descriptorByte) { - set8BitValue(descriptorByte, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE2_BYTE); + set8BitValue(descriptorByte, DESCRIPTORBYTE2_BYTE); } void RequestDataPageMsg::setRequestedTransmissionResponseCount(uint8_t count) { set8BitValue(count, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_BYTE, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_COUNT_MASK); + REQUESTEDTRANSMISSIONRESPONSE_BYTE, + REQUESTEDTRANSMISSIONRESPONSE_COUNT_MASK); } void RequestDataPageMsg::setRequestedTransmissionUseAcknowledged(uint8_t useAcknowledged) { - set8BitValue(useAcknowledged ? 1 : 0, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_BYTE, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_MASK, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_SHIFT); + set8BitValue(useAcknowledged ? 1 : 0, REQUESTEDTRANSMISSIONRESPONSE_BYTE, + REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_MASK, + REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_SHIFT); } void RequestDataPageMsg::setRequestedPageNumber(uint8_t pageNumber) { - set8BitValue(pageNumber, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_REQUESTEDPAGENUMBER_BYTE); + 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, - ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_COMMANDTYPE_BYTE); + set8BitValue(commandType, COMMANDTYPE_BYTE); } diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp index aea7ff0..5a9038f 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp @@ -30,13 +30,13 @@ bool ProfileBicyclePowerDisplay::handleDataPage(BicyclePowerBaseMainDataPage& dp bool called = false; switch (dataPage) { - case ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER: + case MANUFACTURERSINFORMATION_NUMBER: called = handleManufacturersInformation(dp); break; - case ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER: + case PRODUCTINFORMATION_NUMBER: called = handleProductInformation(dp); break; - case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER: + case BATTERYSTATUS_NUMBER: called = handleBatteryStatus(dp); break; case STANDARDPOWERONLY_NUMBER: diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp index 7c66369..af63bcf 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -48,7 +48,7 @@ void ProfileBicyclePowerSensor::onAcknowledgedData(AcknowledgedData& msg) { BaseMasterProfile::onAcknowledgedData(msg); switch (dataPage) { - case ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER: + case REQUESTDATAPAGE_NUMBER: called = handleRequestDataPage(dp); break; case GENERALCALIBRATION_NUMBER: diff --git a/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.cpp b/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.cpp index b77fc32..57872bb 100644 --- a/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.cpp +++ b/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.cpp @@ -33,11 +33,11 @@ bool ProfileEnvironmentDisplay::handleDataPage(EnvironmentBaseDataPage& dp) { case ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_NUMBER: called = handleTemperature(dp); break; - case ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER: + case MANUFACTURERSINFORMATION_NUMBER: // Called Manufacturers Identification in Environment Profile PDF called = handleManufacturersInformation(dp); break; - case ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER: + case PRODUCTINFORMATION_NUMBER: called = handleProductInformation(dp); break; } diff --git a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp index 91e9f4a..8e76b2e 100644 --- a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp @@ -49,10 +49,10 @@ void ProfileHeartRateMonitor::onAcknowledgedData(AcknowledgedData& msg) { switch (dataPage) { - case ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER: + case REQUESTDATAPAGE_NUMBER: called = handleRequestDataPage(dp); break; - case ANTPLUS_COMMON_DATAPAGE_MODESETTINGS_NUMBER: + case MODESETTINGS_NUMBER: called = handleModeSettings(dp); break; } diff --git a/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.cpp b/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.cpp index d55c66c..f71a0a9 100644 --- a/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.cpp +++ b/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.cpp @@ -62,10 +62,10 @@ bool ProfileLevDisplay::handleDataPage(LevBaseMainDataPage& dp) { case ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_NUMBER: called = handleCapabilities(dp); break; - case ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER: + case MANUFACTURERSINFORMATION_NUMBER: called = handleManufacturersInformation(dp); break; - case ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER: + case PRODUCTINFORMATION_NUMBER: called = handleProductInformation(dp); break; } diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp index 22ff2d8..20748d7 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp @@ -34,9 +34,9 @@ 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: + case MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER: + case MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER: + case BATTERYSTATUS_NUMBER: return true; } return false; @@ -104,7 +104,7 @@ void ProfileShiftingShifter::onAcknowledgedData(AcknowledgedData& msg) { switch (dataPage) { - case ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER: + case REQUESTDATAPAGE_NUMBER: called = handleRequestDataPage(dp); break; } @@ -169,9 +169,9 @@ bool ProfileShiftingShifter::handleRequestDataPage(BaseDataPage Date: Mon, 18 Jan 2021 13:17:48 -0800 Subject: [PATCH 100/241] BicycleSpeed: refactor step 1 converge datapage files, reduce code bloat --- .../ANTPLUS_BicycleSpeedPrivateDefines.h | 10 ++- .../ANTPLUS_BicycleSpeedProfile.h | 2 +- .../ANTPLUS_ProfileBicycleSpeedDataPages.h | 11 ++++ .../ANTPLUS_BicycleSpeedBaseMainDataPage.cpp | 63 +++++++++++++++++++ .../ANTPLUS_BicycleSpeedBaseMainDataPage.h | 32 ++++++++++ ... => ANTPLUS_BicycleSpeedBatteryStatus.cpp} | 10 ++- .../ANTPLUS_BicycleSpeedBatteryStatus.h | 12 +++- ...S_BicycleSpeedCumulativeOperatingTime.cpp} | 9 ++- ...PLUS_BicycleSpeedCumulativeOperatingTime.h | 10 ++- .../{RX => }/ANTPLUS_BicycleSpeedDefault.cpp | 2 +- .../{RX => }/ANTPLUS_BicycleSpeedDefault.h | 2 +- ...=> ANTPLUS_BicycleSpeedManufacturerID.cpp} | 10 ++- .../ANTPLUS_BicycleSpeedManufacturerID.h | 11 +++- ...=> ANTPLUS_BicycleSpeedMotionAndSpeed.cpp} | 10 ++- .../ANTPLUS_BicycleSpeedMotionAndSpeed.h | 10 ++- ....cpp => ANTPLUS_BicycleSpeedProductID.cpp} | 9 ++- .../{RX => }/ANTPLUS_BicycleSpeedProductID.h | 12 +++- .../ANTPLUS_ProfileBicycleSpeedDataPages.h | 14 ----- .../ANTPLUS_BicycleSpeedBaseBatteryStatus.h | 17 ----- ..._BicycleSpeedBaseCumulativeOperatingTime.h | 15 ----- .../ANTPLUS_BicycleSpeedBaseMainDataPage.cpp | 22 ------- .../ANTPLUS_BicycleSpeedBaseMainDataPage.h | 17 ----- ...NTPLUS_BicycleSpeedBaseMainDataPageMsg.cpp | 35 ----------- .../ANTPLUS_BicycleSpeedBaseMainDataPageMsg.h | 21 ------- .../ANTPLUS_BicycleSpeedBaseManufacturerID.h | 16 ----- .../ANTPLUS_BicycleSpeedBaseMotionAndSpeed.h | 15 ----- .../Base/ANTPLUS_BicycleSpeedBaseProductID.h | 17 ----- .../RX/ANTPLUS_BicycleSpeedBatteryStatus.cpp | 4 -- ...US_BicycleSpeedCumulativeOperatingTime.cpp | 4 -- .../RX/ANTPLUS_BicycleSpeedManufacturerID.cpp | 4 -- .../RX/ANTPLUS_BicycleSpeedMotionAndSpeed.cpp | 4 -- .../RX/ANTPLUS_BicycleSpeedProductID.cpp | 4 -- .../ANTPLUS_ProfileBicycleSpeedDisplay.h | 2 +- .../ANTPLUS_ProfileBicycleSpeedSensor.h | 2 +- 34 files changed, 193 insertions(+), 245 deletions(-) create mode 100644 src/Profiles/BicycleSpeed/ANTPLUS_ProfileBicycleSpeedDataPages.h create mode 100644 src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.cpp create mode 100644 src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.h rename src/Profiles/BicycleSpeed/DataPages/{Base/ANTPLUS_BicycleSpeedBaseBatteryStatus.cpp => ANTPLUS_BicycleSpeedBatteryStatus.cpp} (80%) rename src/Profiles/BicycleSpeed/DataPages/{RX => }/ANTPLUS_BicycleSpeedBatteryStatus.h (50%) rename src/Profiles/BicycleSpeed/DataPages/{Base/ANTPLUS_BicycleSpeedBaseCumulativeOperatingTime.cpp => ANTPLUS_BicycleSpeedCumulativeOperatingTime.cpp} (64%) rename src/Profiles/BicycleSpeed/DataPages/{RX => }/ANTPLUS_BicycleSpeedCumulativeOperatingTime.h (56%) rename src/Profiles/BicycleSpeed/DataPages/{RX => }/ANTPLUS_BicycleSpeedDefault.cpp (57%) rename src/Profiles/BicycleSpeed/DataPages/{RX => }/ANTPLUS_BicycleSpeedDefault.h (74%) rename src/Profiles/BicycleSpeed/DataPages/{Base/ANTPLUS_BicycleSpeedBaseManufacturerID.cpp => ANTPLUS_BicycleSpeedManufacturerID.cpp} (73%) rename src/Profiles/BicycleSpeed/DataPages/{RX => }/ANTPLUS_BicycleSpeedManufacturerID.h (54%) rename src/Profiles/BicycleSpeed/DataPages/{Base/ANTPLUS_BicycleSpeedBaseMotionAndSpeed.cpp => ANTPLUS_BicycleSpeedMotionAndSpeed.cpp} (61%) rename src/Profiles/BicycleSpeed/DataPages/{RX => }/ANTPLUS_BicycleSpeedMotionAndSpeed.h (58%) rename src/Profiles/BicycleSpeed/DataPages/{Base/ANTPLUS_BicycleSpeedBaseProductID.cpp => ANTPLUS_BicycleSpeedProductID.cpp} (77%) rename src/Profiles/BicycleSpeed/DataPages/{RX => }/ANTPLUS_BicycleSpeedProductID.h (50%) delete mode 100644 src/Profiles/BicycleSpeed/DataPages/ANTPLUS_ProfileBicycleSpeedDataPages.h delete mode 100644 src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseBatteryStatus.h delete mode 100644 src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseCumulativeOperatingTime.h delete mode 100644 src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPage.cpp delete mode 100644 src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPage.h delete mode 100644 src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPageMsg.cpp delete mode 100644 src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPageMsg.h delete mode 100644 src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseManufacturerID.h delete mode 100644 src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMotionAndSpeed.h delete mode 100644 src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseProductID.h delete mode 100644 src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedBatteryStatus.cpp delete mode 100644 src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedCumulativeOperatingTime.cpp delete mode 100644 src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedManufacturerID.cpp delete mode 100644 src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedMotionAndSpeed.cpp delete mode 100644 src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedProductID.cpp diff --git a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedPrivateDefines.h b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedPrivateDefines.h index c3df331..fc8eae8 100644 --- a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedPrivateDefines.h +++ b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedPrivateDefines.h @@ -11,17 +11,15 @@ /* 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_BIKESPEEDEVENTTIME_LSB_BYTE 4 +#define ANTPLUS_BICYCLESPEED_DATAPAGEBASE_BIKESPEEDEVENTTIME_MSB_BYTE 5 +#define ANTPLUS_BICYCLESPEED_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNT_LSB_BYTE 6 +#define ANTPLUS_BICYCLESPEED_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNT_MSB_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 diff --git a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedProfile.h b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedProfile.h index 23ac74f..2f66863 100644 --- a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedProfile.h +++ b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedProfile.h @@ -5,7 +5,7 @@ #include // Datapages -#include +#include // Profile Classes #include diff --git a/src/Profiles/BicycleSpeed/ANTPLUS_ProfileBicycleSpeedDataPages.h b/src/Profiles/BicycleSpeed/ANTPLUS_ProfileBicycleSpeedDataPages.h new file mode 100644 index 0000000..995e436 --- /dev/null +++ b/src/Profiles/BicycleSpeed/ANTPLUS_ProfileBicycleSpeedDataPages.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/DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.cpp b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.cpp new file mode 100644 index 0000000..d2ae743 --- /dev/null +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.cpp @@ -0,0 +1,63 @@ +#include +#include +#include + +template +BicycleSpeedCoreMainDataPage::BicycleSpeedCoreMainDataPage() : CoreDataPage() {} + +template +uint8_t BicycleSpeedCoreMainDataPage::getDataPageNumber() { + return this->get8BitValue( + ANTPLUS_BICYCLESPEED_DATAPAGEBASE_DATAPAGE_BYTE, + ANTPLUS_BICYCLESPEED_DATAPAGEBASE_DATAPAGE_MASK); +} + +template +uint8_t BicycleSpeedCoreMainDataPage::getPageChangeToggle() { + return this->get8BitValue(ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_BYTE, + ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_MASK, + ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_SHIFT); +} + +template +uint16_t BicycleSpeedCoreMainDataPage::getBikeSpeedEventTime() { + return this->get16BitValue( + ANTPLUS_BICYCLESPEED_DATAPAGEBASE_BIKESPEEDEVENTTIME_LSB_BYTE, + ANTPLUS_BICYCLESPEED_DATAPAGEBASE_BIKESPEEDEVENTTIME_MSB_BYTE); +} + +template +uint16_t BicycleSpeedCoreMainDataPage::getCumulativeSpeedRevolutionCount() { + return this->get16BitValue( + ANTPLUS_BICYCLESPEED_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNT_LSB_BYTE, + ANTPLUS_BICYCLESPEED_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNT_MSB_BYTE); +} + +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 ? ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_MASK : 0, + ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_BYTE, + ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_MASK); +} + +void BicycleSpeedBaseMainDataPageMsg::setBikeSpeedEventTime(uint16_t time) { + set16BitValue(time, + ANTPLUS_BICYCLESPEED_DATAPAGEBASE_BIKESPEEDEVENTTIME_LSB_BYTE, + ANTPLUS_BICYCLESPEED_DATAPAGEBASE_BIKESPEEDEVENTTIME_MSB_BYTE); +} + +void BicycleSpeedBaseMainDataPageMsg::setCumulativeSpeedRevolutionCount(uint16_t count) { + set16BitValue(count, + ANTPLUS_BICYCLESPEED_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNT_LSB_BYTE, + ANTPLUS_BICYCLESPEED_DATAPAGEBASE_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..47b9262 --- /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]; +}; + +#endif // ANTPLUS_BICYCLESPEEDBASEMAINDATAPAGE_h diff --git a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseBatteryStatus.cpp b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBatteryStatus.cpp similarity index 80% rename from src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseBatteryStatus.cpp rename to src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBatteryStatus.cpp index b740cb2..be0ac0d 100644 --- a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseBatteryStatus.cpp +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBatteryStatus.cpp @@ -1,9 +1,9 @@ -#include +#include #include template -BicycleSpeedBaseBatteryStatus::BicycleSpeedBaseBatteryStatus() : CoreDataPage() { -} +BicycleSpeedBaseBatteryStatus::BicycleSpeedBaseBatteryStatus() : + CoreDataPage() {} template uint8_t BicycleSpeedBaseBatteryStatus::getFractionalBatteryVoltage() { @@ -28,3 +28,7 @@ uint8_t BicycleSpeedBaseBatteryStatus::getBatteryStatus() { template class BicycleSpeedBaseBatteryStatus; template class BicycleSpeedBaseBatteryStatus; + +BicycleSpeedBatteryStatus::BicycleSpeedBatteryStatus(AntRxDataResponse& dp) : + BicycleSpeedBaseMainDataPage(dp), + BicycleSpeedBaseBatteryStatus() {} diff --git a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedBatteryStatus.h b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBatteryStatus.h similarity index 50% rename from src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedBatteryStatus.h rename to src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBatteryStatus.h index 456ef71..62aa65f 100644 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedBatteryStatus.h +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBatteryStatus.h @@ -1,8 +1,16 @@ #ifndef ANTPLUS_BICYCLESPEEDBATTERYSTATUS_h #define ANTPLUS_BICYCLESPEEDBATTERYSTATUS_h -#include -#include +#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: diff --git a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseCumulativeOperatingTime.cpp b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedCumulativeOperatingTime.cpp similarity index 64% rename from src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseCumulativeOperatingTime.cpp rename to src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedCumulativeOperatingTime.cpp index 52870cf..20492eb 100644 --- a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseCumulativeOperatingTime.cpp +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedCumulativeOperatingTime.cpp @@ -1,9 +1,9 @@ -#include +#include #include template -BicycleSpeedBaseCumulativeOperatingTime::BicycleSpeedBaseCumulativeOperatingTime() : CoreDataPage() { -} +BicycleSpeedBaseCumulativeOperatingTime::BicycleSpeedBaseCumulativeOperatingTime() : + CoreDataPage() {} template uint32_t BicycleSpeedBaseCumulativeOperatingTime::getCumulativeOperatingTime() { @@ -14,3 +14,6 @@ uint32_t BicycleSpeedBaseCumulativeOperatingTime::getCumulativeOperatingTime( template class BicycleSpeedBaseCumulativeOperatingTime; template class BicycleSpeedBaseCumulativeOperatingTime; + +BicycleSpeedCumulativeOperatingTime::BicycleSpeedCumulativeOperatingTime(AntRxDataResponse& dp) : + BicycleSpeedBaseMainDataPage(dp), BicycleSpeedBaseCumulativeOperatingTime() {} diff --git a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedCumulativeOperatingTime.h b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedCumulativeOperatingTime.h similarity index 56% rename from src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedCumulativeOperatingTime.h rename to src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedCumulativeOperatingTime.h index 7258a9a..71925a9 100644 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedCumulativeOperatingTime.h +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedCumulativeOperatingTime.h @@ -1,8 +1,14 @@ #ifndef ANTPLUS_BICYCLESPEEDCUMULITIVEOPERATINGTIME_h #define ANTPLUS_BICYCLESPEEDCUMULITIVEOPERATINGTIME_h -#include -#include +#include + +template +class BicycleSpeedBaseCumulativeOperatingTime : virtual public CoreDataPage { +public: + BicycleSpeedBaseCumulativeOperatingTime(); + uint32_t getCumulativeOperatingTime(); // only 24 bits +}; class BicycleSpeedCumulativeOperatingTime : public BicycleSpeedBaseMainDataPage, public BicycleSpeedBaseCumulativeOperatingTime { public: 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 74% rename from src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedDefault.h rename to src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedDefault.h index 902382c..49e36e6 100644 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedDefault.h +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedDefault.h @@ -1,7 +1,7 @@ #ifndef ANTPLUS_BICYCLESPEEDDEFAULT_h #define ANTPLUS_BICYCLESPEEDDEFAULT_h -#include +#include class BicycleSpeedDefault : public BicycleSpeedBaseMainDataPage { public: diff --git a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseManufacturerID.cpp b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedManufacturerID.cpp similarity index 73% rename from src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseManufacturerID.cpp rename to src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedManufacturerID.cpp index 0150e28..573bcae 100644 --- a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseManufacturerID.cpp +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedManufacturerID.cpp @@ -1,9 +1,9 @@ -#include +#include #include template -BicycleSpeedBaseManufacturerID::BicycleSpeedBaseManufacturerID() : CoreDataPage() { -} +BicycleSpeedBaseManufacturerID::BicycleSpeedBaseManufacturerID() : + CoreDataPage() {} template uint8_t BicycleSpeedBaseManufacturerID::getManufacturerId() { @@ -20,3 +20,7 @@ uint16_t BicycleSpeedBaseManufacturerID::getSerialNumber() { template class BicycleSpeedBaseManufacturerID; template class BicycleSpeedBaseManufacturerID; + +BicycleSpeedManufacturerID::BicycleSpeedManufacturerID(AntRxDataResponse& dp) : + BicycleSpeedBaseMainDataPage(dp), + BicycleSpeedBaseManufacturerID() {} diff --git a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedManufacturerID.h b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedManufacturerID.h similarity index 54% rename from src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedManufacturerID.h rename to src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedManufacturerID.h index 98380aa..9f1fa2d 100644 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedManufacturerID.h +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedManufacturerID.h @@ -1,8 +1,15 @@ #ifndef ANTPLUS_BICYCLESPEEDMANUFACTURERID_h #define ANTPLUS_BICYCLESPEEDMANUFACTURERID_h -#include -#include +#include + +template +class BicycleSpeedBaseManufacturerID : virtual public CoreDataPage { +public: + BicycleSpeedBaseManufacturerID(); + uint8_t getManufacturerId(); + uint16_t getSerialNumber(); +}; class BicycleSpeedManufacturerID : public BicycleSpeedBaseMainDataPage, public BicycleSpeedBaseManufacturerID { public: diff --git a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMotionAndSpeed.cpp b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedMotionAndSpeed.cpp similarity index 61% rename from src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMotionAndSpeed.cpp rename to src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedMotionAndSpeed.cpp index c70f0a8..eaa6d75 100644 --- a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMotionAndSpeed.cpp +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedMotionAndSpeed.cpp @@ -1,9 +1,9 @@ -#include +#include #include template -BicycleSpeedBaseMotionAndSpeed::BicycleSpeedBaseMotionAndSpeed() : CoreDataPage() { -} +BicycleSpeedBaseMotionAndSpeed::BicycleSpeedBaseMotionAndSpeed() : + CoreDataPage() {} template uint8_t BicycleSpeedBaseMotionAndSpeed::getFlags() { @@ -13,3 +13,7 @@ uint8_t BicycleSpeedBaseMotionAndSpeed::getFlags() { template class BicycleSpeedBaseMotionAndSpeed; template class BicycleSpeedBaseMotionAndSpeed; + +BicycleSpeedMotionAndSpeed::BicycleSpeedMotionAndSpeed(AntRxDataResponse& dp) : + BicycleSpeedBaseMainDataPage(dp), + BicycleSpeedBaseMotionAndSpeed() {} diff --git a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedMotionAndSpeed.h b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedMotionAndSpeed.h similarity index 58% rename from src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedMotionAndSpeed.h rename to src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedMotionAndSpeed.h index eb1472f..97e66f0 100644 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedMotionAndSpeed.h +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedMotionAndSpeed.h @@ -1,8 +1,14 @@ #ifndef ANTPLUS_BICYCLESPEEDMOTIONANDSPEED_h #define ANTPLUS_BICYCLESPEEDMOTIONANDSPEED_h -#include -#include +#include + +template +class BicycleSpeedBaseMotionAndSpeed : virtual public CoreDataPage { +public: + BicycleSpeedBaseMotionAndSpeed(); + uint8_t getFlags(); +}; class BicycleSpeedMotionAndSpeed : public BicycleSpeedBaseMainDataPage, public BicycleSpeedBaseMotionAndSpeed { public: diff --git a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseProductID.cpp b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedProductID.cpp similarity index 77% rename from src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseProductID.cpp rename to src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedProductID.cpp index 4dcfe1b..780d058 100644 --- a/src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseProductID.cpp +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedProductID.cpp @@ -1,9 +1,8 @@ -#include +#include #include template -BicycleSpeedBaseProductID::BicycleSpeedBaseProductID() : CoreDataPage() { -} +BicycleSpeedBaseProductID::BicycleSpeedBaseProductID() : CoreDataPage() {} template uint8_t BicycleSpeedBaseProductID::getHardwareVersion() { @@ -25,3 +24,7 @@ uint8_t BicycleSpeedBaseProductID::getModelNumber() { template class BicycleSpeedBaseProductID; template class BicycleSpeedBaseProductID; + +BicycleSpeedProductID::BicycleSpeedProductID(AntRxDataResponse& dp) : + BicycleSpeedBaseMainDataPage(dp), + BicycleSpeedBaseProductID() {} diff --git a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedProductID.h b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedProductID.h similarity index 50% rename from src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedProductID.h rename to src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedProductID.h index 4d57330..a8bc40d 100644 --- a/src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedProductID.h +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedProductID.h @@ -1,8 +1,16 @@ #ifndef ANTPLUS_BICYCLESPEEDPRODUCTIONID_h #define ANTPLUS_BICYCLESPEEDPRODUCTIONID_h -#include -#include +#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: 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.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.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 5a62323..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: - explicit 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 aeaad0f..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: - explicit 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.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_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_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_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_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/Display/ANTPLUS_ProfileBicycleSpeedDisplay.h b/src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.h index 91866eb..15de07a 100644 --- a/src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.h +++ b/src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.h @@ -2,7 +2,7 @@ #define ANTPLUS_PROFILEBICYCLESPEEDDISPLAY_h #include -#include +#include #include #include "ANT.h" diff --git a/src/Profiles/BicycleSpeed/Sensor/ANTPLUS_ProfileBicycleSpeedSensor.h b/src/Profiles/BicycleSpeed/Sensor/ANTPLUS_ProfileBicycleSpeedSensor.h index 5c924de..650582a 100644 --- a/src/Profiles/BicycleSpeed/Sensor/ANTPLUS_ProfileBicycleSpeedSensor.h +++ b/src/Profiles/BicycleSpeed/Sensor/ANTPLUS_ProfileBicycleSpeedSensor.h @@ -2,7 +2,7 @@ #define ANTPLUS_PROFILEBICYCLESPEEDSENSOR_h #include -#include +#include #include class ProfileBicycleSpeedSensor : BaseMasterProfile { From 902ff27f8d2cf291a191964e1a94bc7307017097 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 18 Jan 2021 13:25:45 -0800 Subject: [PATCH 101/241] heartrate: fix up some formating --- .../ANTPLUS_HeartRateBaseMainDataPage.cpp | 17 +++++++++++------ .../ANTPLUS_HeartRateBaseMainDataPage.h | 1 - 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.cpp index 06b1a5e..6a70b02 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.cpp @@ -4,8 +4,8 @@ #define DATAPAGE_BYTE 0 #define TOGGLE_BYTE 0 -#define HEARTBEATEVENTTIMELSB_BYTE 4 -#define HEARTBEATEVENTTIMEMSB_BYTE 5 +#define HEARTBEATEVENTTIME_LSB_BYTE 4 +#define HEARTBEATEVENTTIME_MSB_BYTE 5 #define HEARTBEATCOUNT_BYTE 6 #define COMPUTEDHEARTRATE_BYTE 7 #define DATAPAGE_MASK 0x7F @@ -27,7 +27,7 @@ uint8_t HeartRateCoreMainDataPage::getPageChangeToggle() { template uint16_t HeartRateCoreMainDataPage::getHeartBeatEventTime() { - return this->get16BitValue(HEARTBEATEVENTTIMELSB_BYTE, HEARTBEATEVENTTIMEMSB_BYTE); + return this->get16BitValue(HEARTBEATEVENTTIME_LSB_BYTE, HEARTBEATEVENTTIME_MSB_BYTE); } template @@ -43,9 +43,13 @@ uint8_t HeartRateCoreMainDataPage::getComputedHeartRate() { template class HeartRateCoreMainDataPage; template class HeartRateCoreMainDataPage; -HeartRateBaseMainDataPage::HeartRateBaseMainDataPage(AntRxDataResponse& dp) : BaseDataPage(dp), HeartRateCoreMainDataPage() {} +HeartRateBaseMainDataPage::HeartRateBaseMainDataPage(AntRxDataResponse& dp) : + BaseDataPage(dp), + HeartRateCoreMainDataPage() {} -HeartRateBaseMainDataPageMsg::HeartRateBaseMainDataPageMsg(uint8_t dataPageNumber) : BaseDataPageMsg(), HeartRateCoreMainDataPage() { +HeartRateBaseMainDataPageMsg::HeartRateBaseMainDataPageMsg(uint8_t dataPageNumber) : + BaseDataPageMsg(), + HeartRateCoreMainDataPage() { setDataBuffer(_buffer); // TODO fixup to set data api _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = dataPageNumber; @@ -56,7 +60,8 @@ void HeartRateBaseMainDataPageMsg::setPageChangeToggle(uint8_t toggle) { } void HeartRateBaseMainDataPageMsg::setHeartBeatEventTime(uint16_t time) { - set16BitValue(time, HEARTBEATEVENTTIMELSB_BYTE, HEARTBEATEVENTTIMEMSB_BYTE); + set16BitValue(time, HEARTBEATEVENTTIME_LSB_BYTE, + HEARTBEATEVENTTIME_MSB_BYTE); } void HeartRateBaseMainDataPageMsg::setHeartBeatCount(uint8_t count) { diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.h b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.h index 975a190..7f5dca2 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.h +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.h @@ -1,7 +1,6 @@ #ifndef ANTPLUS_HEARTRATEBASEMAINDATAPAGE_h #define ANTPLUS_HEARTRATEBASEMAINDATAPAGE_h -#include #include #include From 1ed244270bfc234fe5d06965d26f0679322ba390 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 18 Jan 2021 15:52:48 -0800 Subject: [PATCH 102/241] Scale back generalization of datapage numbers Too many profiles have common names that may conflict with common, so specify their origin so we know where they came from and don't have conflicts. --- src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp | 2 +- src/CommonDataPages/ANTPLUS_BatteryStatus.cpp | 2 +- .../ANTPLUS_CommonDataPagePrivateDefines.h | 14 ++-- .../ANTPLUS_ManufacturersInformation.cpp | 2 +- ...omponentSystemManufacturersInformation.cpp | 2 +- ...MultiComponentSystemProductInformation.cpp | 2 +- .../ANTPLUS_ProductInformation.cpp | 2 +- .../ANTPLUS_RequestDataPage.cpp | 2 +- .../ANTPLUS_BicyclePowerPrivateDefines.h | 12 +-- .../ANTPLUS_BicyclePowerStandardPowerOnly.cpp | 2 +- .../ANTPLUS_ProfileBicyclePowerDisplay.cpp | 14 ++-- .../ANTPLUS_ProfileBicyclePowerSensor.cpp | 18 ++--- .../ANTPLUS_ProfileEnvironmentDisplay.cpp | 4 +- .../ANTPLUS_HeartRatePrivateDefines.h | 16 ++-- .../ANTPLUS_HeartRateBatteryStatus.cpp | 2 +- .../ANTPLUS_HeartRateCapabilities.cpp | 2 +- ...TPLUS_HeartRateCumulativeOperatingTime.cpp | 11 ++- .../DataPages/ANTPLUS_HeartRateDefault.cpp | 2 +- ...TPLUS_HeartRateManufacturerInformation.cpp | 10 +-- .../ANTPLUS_HeartRatePreviousHeartBeat.cpp | 2 +- .../ANTPLUS_HeartRateProductInformation.cpp | 2 +- .../ANTPLUS_HeartRateSwimIntervalSummary.cpp | 6 +- .../ANTPLUS_ProfileHeartRateDisplay.cpp | 16 ++-- .../ANTPLUS_ProfileHeartRateMonitor.cpp | 75 ++++++++++--------- .../Lev/Display/ANTPLUS_ProfileLevDisplay.cpp | 4 +- .../ANTPLUS_ProfileShiftingShifter.cpp | 14 ++-- 26 files changed, 124 insertions(+), 116 deletions(-) diff --git a/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp b/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp index 7f6e0de..b87da1d 100644 --- a/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp +++ b/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp @@ -20,7 +20,7 @@ void BaseMasterProfile::onAcknowledgedData(AcknowledgedData& msg) { BaseProfile::onAcknowledgedData(msg); BaseDataPage dp(msg); - if (dp.getDataPageNumber() == REQUESTDATAPAGE_NUMBER) { + if (dp.getDataPageNumber() == COMMON_REQUESTDATAPAGE_NUMBER) { handleRequestDataPage(msg); } } diff --git a/src/CommonDataPages/ANTPLUS_BatteryStatus.cpp b/src/CommonDataPages/ANTPLUS_BatteryStatus.cpp index 33b10e6..9f66c7b 100644 --- a/src/CommonDataPages/ANTPLUS_BatteryStatus.cpp +++ b/src/CommonDataPages/ANTPLUS_BatteryStatus.cpp @@ -77,7 +77,7 @@ BatteryStatusMsg::BatteryStatusMsg() : BaseDataPageMsg(), BaseBatteryStatus() { setDataBuffer(_buffer); - set8BitValue(BATTERYSTATUS_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); + set8BitValue(COMMON_BATTERYSTATUS_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); set8BitValue(RESERVED_VALUE, RESERVED_BYTE); } diff --git a/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h b/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h index 2b537e8..79315d4 100644 --- a/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h +++ b/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h @@ -1,12 +1,12 @@ #ifndef ANTPLUS_COMMONDATAPAGEPRIVATEDEFINES_h #define ANTPLUS_COMMONDATAPAGEPRIVATEDEFINES_h -#define REQUESTDATAPAGE_NUMBER 70 -#define MODESETTINGS_NUMBER 76 -#define MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER 78 -#define MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER 79 -#define MANUFACTURERSINFORMATION_NUMBER 80 -#define PRODUCTINFORMATION_NUMBER 81 -#define BATTERYSTATUS_NUMBER 82 +#define COMMON_REQUESTDATAPAGE_NUMBER 70 +#define COMMON_MODESETTINGS_NUMBER 76 +#define COMMON_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER 78 +#define COMMON_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER 79 +#define COMMON_MANUFACTURERSINFORMATION_NUMBER 80 +#define COMMON_PRODUCTINFORMATION_NUMBER 81 +#define COMMON_BATTERYSTATUS_NUMBER 82 #endif // ANTPLUS_COMMONDATAPAGEPRIVATEDEFINES_h diff --git a/src/CommonDataPages/ANTPLUS_ManufacturersInformation.cpp b/src/CommonDataPages/ANTPLUS_ManufacturersInformation.cpp index 8f2887d..75f3430 100644 --- a/src/CommonDataPages/ANTPLUS_ManufacturersInformation.cpp +++ b/src/CommonDataPages/ANTPLUS_ManufacturersInformation.cpp @@ -40,7 +40,7 @@ ManufacturersInformationMsg::ManufacturersInformationMsg() : BaseDataPageMsg(), BaseManufacturersInformation() { setDataBuffer(_buffer); - _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = MANUFACTURERSINFORMATION_NUMBER; + _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = COMMON_MANUFACTURERSINFORMATION_NUMBER; _buffer[1] = 0xFF; _buffer[2] = 0xFF; } diff --git a/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp b/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp index 6455e8b..02988dc 100644 --- a/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp +++ b/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp @@ -56,7 +56,7 @@ MultiComponentSystemManufacturersInformationMsg::MultiComponentSystemManufacture BaseMultiComponentSystemManufacturersInformation() { setDataBuffer(_buffer); set8BitValue( - MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER, + COMMON_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); } diff --git a/src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.cpp b/src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.cpp index 456fa84..86b97a0 100644 --- a/src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.cpp +++ b/src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.cpp @@ -54,7 +54,7 @@ MultiComponentSystemProductInformationMsg::MultiComponentSystemProductInformatio BaseDataPageMsg(), BaseMultiComponentSystemProductInformation() { setDataBuffer(_buffer); - set8BitValue(MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER, + set8BitValue(COMMON_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); } diff --git a/src/CommonDataPages/ANTPLUS_ProductInformation.cpp b/src/CommonDataPages/ANTPLUS_ProductInformation.cpp index 067d05a..a0db10d 100644 --- a/src/CommonDataPages/ANTPLUS_ProductInformation.cpp +++ b/src/CommonDataPages/ANTPLUS_ProductInformation.cpp @@ -37,7 +37,7 @@ ProductInformationMsg::ProductInformationMsg() : BaseProductInformation() { // TODO set default values setDataBuffer(_buffer); - _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = PRODUCTINFORMATION_NUMBER; + _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = COMMON_PRODUCTINFORMATION_NUMBER; _buffer[1] = 0xFF; } diff --git a/src/CommonDataPages/ANTPLUS_RequestDataPage.cpp b/src/CommonDataPages/ANTPLUS_RequestDataPage.cpp index 01c16fe..84f9fc7 100644 --- a/src/CommonDataPages/ANTPLUS_RequestDataPage.cpp +++ b/src/CommonDataPages/ANTPLUS_RequestDataPage.cpp @@ -79,7 +79,7 @@ RequestDataPageMsg::RequestDataPageMsg() : setDataBuffer(_buffer); setDescriptorByte1(ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE1_INVALID); setDescriptorByte2(ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE2_INVALID); - set8BitValue(REQUESTDATAPAGE_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); + set8BitValue(COMMON_REQUESTDATAPAGE_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); } void RequestDataPageMsg::setSlaveSerialNumber(uint16_t serialNumber) { diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h index 7ae6426..26ec07a 100644 --- a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h @@ -8,12 +8,12 @@ // 30 / 2.5 = 12 #define SEARCHTIMEOUT 12 -#define GENERALCALIBRATION_NUMBER 0x01 -#define STANDARDPOWERONLY_NUMBER 0x10 -#define STANDARDWHEELTORQUE_NUMBER 0x11 -#define STANDARDCRANKTORQUE_NUMBER 0x12 -#define TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER 0x13 -#define CRANKTORQUEFREQUENCY_NUMBER 0x20 +#define BICYCLEPOWER_GENERALCALIBRATION_NUMBER 0x01 +#define BICYCLEPOWER_STANDARDPOWERONLY_NUMBER 0x10 +#define BICYCLEPOWER_STANDARDWHEELTORQUE_NUMBER 0x11 +#define BICYCLEPOWER_STANDARDCRANKTORQUE_NUMBER 0x12 +#define BICYCLEPOWER_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER 0x13 +#define BICYCLEPOWER_CRANKTORQUEFREQUENCY_NUMBER 0x20 /* Fixed Bytes */ diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp index f52c1a3..00fa922 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp @@ -44,7 +44,7 @@ BicyclePowerStandardPowerOnly::BicyclePowerStandardPowerOnly(AntRxDataResponse& BicyclePowerBaseStandardPowerOnly() {} BicyclePowerStandardPowerOnlyMsg::BicyclePowerStandardPowerOnlyMsg() : - BicyclePowerBaseMainDataPageMsg(STANDARDPOWERONLY_NUMBER), + BicyclePowerBaseMainDataPageMsg(BICYCLEPOWER_STANDARDPOWERONLY_NUMBER), BicyclePowerBaseStandardPowerOnly() { // TODO magic nums also using buffer directly _buffer[PEDALPOWER_BYTE] = 0xFF; diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp index 5a9038f..d0b7052 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp @@ -30,25 +30,25 @@ bool ProfileBicyclePowerDisplay::handleDataPage(BicyclePowerBaseMainDataPage& dp bool called = false; switch (dataPage) { - case MANUFACTURERSINFORMATION_NUMBER: + case COMMON_MANUFACTURERSINFORMATION_NUMBER: called = handleManufacturersInformation(dp); break; - case PRODUCTINFORMATION_NUMBER: + case COMMON_PRODUCTINFORMATION_NUMBER: called = handleProductInformation(dp); break; - case BATTERYSTATUS_NUMBER: + case COMMON_BATTERYSTATUS_NUMBER: called = handleBatteryStatus(dp); break; - case STANDARDPOWERONLY_NUMBER: + case BICYCLEPOWER_STANDARDPOWERONLY_NUMBER: called = handleStandardPowerOnly(dp); break; - case STANDARDCRANKTORQUE_NUMBER: + case BICYCLEPOWER_STANDARDCRANKTORQUE_NUMBER: called = handleStandardCrankTorque(dp); break; - case STANDARDWHEELTORQUE_NUMBER: + case BICYCLEPOWER_STANDARDWHEELTORQUE_NUMBER: called = handleStandardWheelTorque(dp); break; - case TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: + case BICYCLEPOWER_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: called = handleTorqueEffectivenessAndPedalSmoothness(dp); break; } diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp index af63bcf..a7c6000 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -48,10 +48,10 @@ void ProfileBicyclePowerSensor::onAcknowledgedData(AcknowledgedData& msg) { BaseMasterProfile::onAcknowledgedData(msg); switch (dataPage) { - case REQUESTDATAPAGE_NUMBER: + case COMMON_REQUESTDATAPAGE_NUMBER: called = handleRequestDataPage(dp); break; - case GENERALCALIBRATION_NUMBER: + case BICYCLEPOWER_GENERALCALIBRATION_NUMBER: called = handleGeneralCalibration(dp); break; } @@ -93,22 +93,22 @@ void ProfileBicyclePowerSensor::transmitPrimaryDataPage() { void ProfileBicyclePowerSensor::transmitBackgroundDataPage() { switch (_nextBackgroundPage) { - case STANDARDPOWERONLY_NUMBER: + case BICYCLEPOWER_STANDARDPOWERONLY_NUMBER: transmitBicyclePowerStandardPowerOnlyMsg(); break; - case STANDARDWHEELTORQUE_NUMBER: + case BICYCLEPOWER_STANDARDWHEELTORQUE_NUMBER: transmitBicyclePowerStandardWheelTorqueMsg(); break; - case STANDARDCRANKTORQUE_NUMBER: + case BICYCLEPOWER_STANDARDCRANKTORQUE_NUMBER: transmitBicyclePowerStandardCrankTorqueMsg(); break; - case TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: + case BICYCLEPOWER_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: transmitBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg(); break; - case CRANKTORQUEFREQUENCY_NUMBER: + case BICYCLEPOWER_CRANKTORQUEFREQUENCY_NUMBER: transmitBicyclePowerCrankTorqueFrequencyMsg(); break; - case GENERALCALIBRATION_NUMBER: // TODO (check is this part of the background transmission, seems sus) + case BICYCLEPOWER_GENERALCALIBRATION_NUMBER: // TODO (check is this part of the background transmission, seems sus) transmistBicyclePowerGeneralCalibrationResponse(); break; } @@ -149,7 +149,7 @@ uint8_t ProfileBicyclePowerSensor::getNextBackgroundPage(uint8_t currentPage) { void ProfileBicyclePowerSensor::transmitRequestedDataPage() { uint8_t requestedPage = getRequestedPage(); switch (requestedPage) { - case STANDARDPOWERONLY_NUMBER: + case BICYCLEPOWER_STANDARDPOWERONLY_NUMBER: // TODO break; } diff --git a/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.cpp b/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.cpp index 57872bb..4279416 100644 --- a/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.cpp +++ b/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.cpp @@ -33,11 +33,11 @@ bool ProfileEnvironmentDisplay::handleDataPage(EnvironmentBaseDataPage& dp) { case ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_NUMBER: called = handleTemperature(dp); break; - case MANUFACTURERSINFORMATION_NUMBER: + case COMMON_MANUFACTURERSINFORMATION_NUMBER: // Called Manufacturers Identification in Environment Profile PDF called = handleManufacturersInformation(dp); break; - case PRODUCTINFORMATION_NUMBER: + case COMMON_PRODUCTINFORMATION_NUMBER: called = handleProductInformation(dp); break; } diff --git a/src/Profiles/HeartRate/ANTPLUS_HeartRatePrivateDefines.h b/src/Profiles/HeartRate/ANTPLUS_HeartRatePrivateDefines.h index e63a26a..558d1c0 100644 --- a/src/Profiles/HeartRate/ANTPLUS_HeartRatePrivateDefines.h +++ b/src/Profiles/HeartRate/ANTPLUS_HeartRatePrivateDefines.h @@ -7,13 +7,13 @@ #define ANTPLUS_HEARTRATE_SEARCHTIMEOUT 12 /* DataPage Numbers */ -#define DEFAULT_NUMBER 0 -#define CUMULATIVEOPERATINGTIME_NUMBER 1 -#define MANUFACTURERINFORMATION_NUMBER 2 -#define PRODUCTINFORMATION_NUMBER 3 -#define PREVIOUSHEARTBEAT_NUMBER 4 -#define SWIMINTERVALSUMMARY_NUMBER 5 -#define CAPABILITIES_NUMBER 6 -#define BATTERYSTATUS_NUMBER 7 +#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/DataPages/ANTPLUS_HeartRateBatteryStatus.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBatteryStatus.cpp index 3b10458..b36f3f3 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBatteryStatus.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBatteryStatus.cpp @@ -43,7 +43,7 @@ HeartRateBatteryStatus::HeartRateBatteryStatus(AntRxDataResponse& dp) : HeartRateBaseBatteryStatus() {} HeartRateBatteryStatusMsg::HeartRateBatteryStatusMsg() : - HeartRateBaseMainDataPageMsg(BATTERYSTATUS_NUMBER), + HeartRateBaseMainDataPageMsg(HEARTRATE_BATTERYSTATUS_NUMBER), HeartRateBaseBatteryStatus() { } diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCapabilities.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCapabilities.cpp index 2e219a6..c81582d 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCapabilities.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCapabilities.cpp @@ -27,7 +27,7 @@ HeartRateCapabilities::HeartRateCapabilities(AntRxDataResponse& dp) : HeartRateBaseCapabilities() {} HeartRateCapabilitiesMsg::HeartRateCapabilitiesMsg() : - HeartRateBaseMainDataPageMsg(CAPABILITIES_NUMBER), + HeartRateBaseMainDataPageMsg(HEARTRATE_CAPABILITIES_NUMBER), HeartRateBaseCapabilities() {} void HeartRateCapabilitiesMsg::setFeaturesSupported(uint8_t supported) { diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCumulativeOperatingTime.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCumulativeOperatingTime.cpp index 135792e..1c83022 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCumulativeOperatingTime.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCumulativeOperatingTime.cpp @@ -5,7 +5,8 @@ #define TIME_MSB_BYTE 3 template -HeartRateBaseCumulativeOperatingTime::HeartRateBaseCumulativeOperatingTime() : CoreDataPage() {} +HeartRateBaseCumulativeOperatingTime::HeartRateBaseCumulativeOperatingTime() : + CoreDataPage() {} template uint32_t HeartRateBaseCumulativeOperatingTime::getCumulativeOperatingTime() { @@ -15,9 +16,13 @@ uint32_t HeartRateBaseCumulativeOperatingTime::getCumulativeOperatingTime() { template class HeartRateBaseCumulativeOperatingTime; template class HeartRateBaseCumulativeOperatingTime; -HeartRateCumulativeOperatingTime::HeartRateCumulativeOperatingTime(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp), HeartRateBaseCumulativeOperatingTime() {} +HeartRateCumulativeOperatingTime::HeartRateCumulativeOperatingTime(AntRxDataResponse& dp) : + HeartRateBaseMainDataPage(dp), + HeartRateBaseCumulativeOperatingTime() {} -HeartRateCumulativeOperatingTimeMsg::HeartRateCumulativeOperatingTimeMsg() : HeartRateBaseMainDataPageMsg(CUMULATIVEOPERATINGTIME_NUMBER), 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_HeartRateDefault.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.cpp index d838bfe..d72f7c2 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.cpp @@ -5,7 +5,7 @@ HeartRateDefault::HeartRateDefault(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp) {} HeartRateDefaultMsg::HeartRateDefaultMsg() : - HeartRateBaseMainDataPageMsg(DEFAULT_NUMBER) { + HeartRateBaseMainDataPageMsg(HEARTRATE_DEFAULT_NUMBER) { // TODO magic numbers _buffer[1] = 0xFF; _buffer[2] = 0xFF; diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateManufacturerInformation.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateManufacturerInformation.cpp index 37bc729..03f3ee9 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateManufacturerInformation.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateManufacturerInformation.cpp @@ -2,8 +2,8 @@ #include #define MANUFACTUREREIDLSB_BYTE 1 -#define SERIALNUMBERLSB_BYTE 2 -#define SERIALNUMBERMSB_BYTE 3 +#define SERIALNUMBER_LSB_BYTE 2 +#define SERIALNUMBER_MSB_BYTE 3 template HeartRateBaseManufacturerInformation::HeartRateBaseManufacturerInformation() : @@ -16,7 +16,7 @@ uint8_t HeartRateBaseManufacturerInformation::getManufacturerIdLsb() { template uint16_t HeartRateBaseManufacturerInformation::getSerialNumber() { - return this->get16BitValue(SERIALNUMBERLSB_BYTE, SERIALNUMBERMSB_BYTE); + return this->get16BitValue(SERIALNUMBER_LSB_BYTE, SERIALNUMBER_MSB_BYTE); } template class HeartRateBaseManufacturerInformation; @@ -27,7 +27,7 @@ HeartRateManufacturerInformation::HeartRateManufacturerInformation(AntRxDataResp HeartRateBaseManufacturerInformation() {} HeartRateManufacturerInformationMsg::HeartRateManufacturerInformationMsg() : - HeartRateBaseMainDataPageMsg(MANUFACTURERINFORMATION_NUMBER), + HeartRateBaseMainDataPageMsg(HEARTRATE_MANUFACTURERINFORMATION_NUMBER), HeartRateBaseManufacturerInformation() {} void HeartRateManufacturerInformationMsg::setManufacturerIdLsb(uint8_t id) { @@ -35,5 +35,5 @@ void HeartRateManufacturerInformationMsg::setManufacturerIdLsb(uint8_t id) { } void HeartRateManufacturerInformationMsg::setSerialNumber(uint16_t serialNumber) { - set16BitValue(serialNumber, SERIALNUMBERLSB_BYTE, SERIALNUMBERMSB_BYTE); + set16BitValue(serialNumber, SERIALNUMBER_LSB_BYTE, SERIALNUMBER_MSB_BYTE); } diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRatePreviousHeartBeat.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRatePreviousHeartBeat.cpp index 16948e3..10990a7 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRatePreviousHeartBeat.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRatePreviousHeartBeat.cpp @@ -31,7 +31,7 @@ HeartRatePreviousHeartBeat::HeartRatePreviousHeartBeat(AntRxDataResponse& dp) : // TODO add isValid method to manufactueres byte HeartRatePreviousHeartBeatMsg::HeartRatePreviousHeartBeatMsg() : - HeartRateBaseMainDataPageMsg(PREVIOUSHEARTBEAT_NUMBER), + HeartRateBaseMainDataPageMsg(HEARTRATE_PREVIOUSHEARTBEAT_NUMBER), HeartRateBasePreviousHeartBeat() { setManufacturerSpecific( ANTPLUS_HEARTRATE_DATAPAGE_PREVIOUSHEARTBEAT_MANUFACTURERSPECIFIC_INVALID); diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateProductInformation.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateProductInformation.cpp index 222b154..8ca939b 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateProductInformation.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateProductInformation.cpp @@ -32,7 +32,7 @@ HeartRateProductInformation::HeartRateProductInformation(AntRxDataResponse& dp) HeartRateBaseProductInformation() {} HeartRateProductInformationMsg::HeartRateProductInformationMsg() : - HeartRateBaseMainDataPageMsg(PRODUCTINFORMATION_NUMBER), + HeartRateBaseMainDataPageMsg(HEARTRATE_PRODUCTINFORMATION_NUMBER), HeartRateBaseProductInformation() {} // TODO set to product information API diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateSwimIntervalSummary.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateSwimIntervalSummary.cpp index 19b6575..ce7d958 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateSwimIntervalSummary.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateSwimIntervalSummary.cpp @@ -7,8 +7,8 @@ #define SESSIONAVERAGEHEARTRATE_BYTE 3 template -HeartRateBaseSwimIntervalSummary::HeartRateBaseSwimIntervalSummary() : CoreDataPage() { -} +HeartRateBaseSwimIntervalSummary::HeartRateBaseSwimIntervalSummary() : + CoreDataPage() {} template uint8_t HeartRateBaseSwimIntervalSummary::getIntervalAverageHeartRate() { @@ -34,7 +34,7 @@ HeartRateSwimIntervalSummary::HeartRateSwimIntervalSummary(AntRxDataResponse& dp // TODO add isValid methods HeartRateSwimIntervalSummaryMsg::HeartRateSwimIntervalSummaryMsg() : - HeartRateBaseMainDataPageMsg(SWIMINTERVALSUMMARY_NUMBER), + HeartRateBaseMainDataPageMsg(HEARTRATE_SWIMINTERVALSUMMARY_NUMBER), HeartRateBaseSwimIntervalSummary() { setIntervalAverageHeartRate(ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALAVERAGEHEARTRATE_INVALID); setIntervalMaximumHeartRate(ANTPLUS_HEARTRATE_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALMAXIMUMHEARTRATE_INVALID); diff --git a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp index d2cb475..4c8aeda 100644 --- a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp @@ -31,28 +31,28 @@ bool ProfileHeartRateDisplay::handleDataPage(HeartRateBaseMainDataPage& dp) { bool called = false; switch (dataPage) { - case DEFAULT_NUMBER: + case HEARTRATE_DEFAULT_NUMBER: called = handleDefault(dp); break; - case CUMULATIVEOPERATINGTIME_NUMBER: + case HEARTRATE_CUMULATIVEOPERATINGTIME_NUMBER: called = handleCumulativeOperatingTime(dp); break; - case MANUFACTURERINFORMATION_NUMBER: + case HEARTRATE_MANUFACTURERINFORMATION_NUMBER: called = handleManufacturerInformation(dp); break; - case PRODUCTINFORMATION_NUMBER: + case HEARTRATE_PRODUCTINFORMATION_NUMBER: called = handleProductInformation(dp); break; - case PREVIOUSHEARTBEAT_NUMBER: + case HEARTRATE_PREVIOUSHEARTBEAT_NUMBER: called = handlePreviousHeartBeat(dp); break; - case SWIMINTERVALSUMMARY_NUMBER: + case HEARTRATE_SWIMINTERVALSUMMARY_NUMBER: called = handleSwimIntervalSummary(dp); break; - case BATTERYSTATUS_NUMBER: + case HEARTRATE_BATTERYSTATUS_NUMBER: called = handleBatteryStatus(dp); break; - case CAPABILITIES_NUMBER: + case HEARTRATE_CAPABILITIES_NUMBER: called = handleCapabilities(dp); break; } diff --git a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp index 8e76b2e..e52e892 100644 --- a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp @@ -9,7 +9,7 @@ ProfileHeartRateMonitor::ProfileHeartRateMonitor( uint16_t deviceNumber, uint8_t transmissionType) : BaseMasterProfile(deviceNumber, transmissionType), - _nextBackgroundPage(MANUFACTURERINFORMATION_NUMBER), + _nextBackgroundPage(HEARTRATE_MANUFACTURERINFORMATION_NUMBER), _flags(0) { setChannelConfig(); } @@ -19,7 +19,7 @@ ProfileHeartRateMonitor::ProfileHeartRateMonitor( uint8_t transmissionType, uint32_t flags) : BaseMasterProfile(deviceNumber, transmissionType), - _nextBackgroundPage(MANUFACTURERINFORMATION_NUMBER), + _nextBackgroundPage(HEARTRATE_MANUFACTURERINFORMATION_NUMBER), _flags(flags) { setChannelConfig(); } @@ -49,10 +49,10 @@ void ProfileHeartRateMonitor::onAcknowledgedData(AcknowledgedData& msg) { switch (dataPage) { - case REQUESTDATAPAGE_NUMBER: + case COMMON_REQUESTDATAPAGE_NUMBER: called = handleRequestDataPage(dp); break; - case MODESETTINGS_NUMBER: + case COMMON_MODESETTINGS_NUMBER: called = handleModeSettings(dp); break; } @@ -92,35 +92,38 @@ void ProfileHeartRateMonitor::transmitPrimaryDataPage() { void ProfileHeartRateMonitor::transmitBackgroundDataPage() { switch (_nextBackgroundPage) { - case CUMULATIVEOPERATINGTIME_NUMBER: + case HEARTRATE_CUMULATIVEOPERATINGTIME_NUMBER: transmitHeartRateCumulativeOperatingTimeMsg(); break; - case MANUFACTURERINFORMATION_NUMBER: + case HEARTRATE_MANUFACTURERINFORMATION_NUMBER: transmitHeartRateManufacturerInformationMsg(); break; - case PRODUCTINFORMATION_NUMBER: + case HEARTRATE_PRODUCTINFORMATION_NUMBER: transmitHeartRateProductInformationMsg(); break; - case BATTERYSTATUS_NUMBER: + case HEARTRATE_BATTERYSTATUS_NUMBER: transmitHeartRateBatteryStatusMsg(); break; - case CAPABILITIES_NUMBER: + case HEARTRATE_CAPABILITIES_NUMBER: transmitHeartRateCapabilitiesMsg(); break; } } uint8_t ProfileHeartRateMonitor::getNextBackgroundPage(uint8_t currentPage) { - if ((currentPage < CUMULATIVEOPERATINGTIME_NUMBER) && (_flags & ANTPLUS_HEARTRATE_FLAGS_CUMULATIVEOPERATINGTIME_SUPPORTED)) { - return CUMULATIVEOPERATINGTIME_NUMBER; - } else if (currentPage < MANUFACTURERINFORMATION_NUMBER) { - return MANUFACTURERINFORMATION_NUMBER; - } else if (currentPage < PRODUCTINFORMATION_NUMBER) { - return PRODUCTINFORMATION_NUMBER; - } else if ((currentPage < CAPABILITIES_NUMBER) && (_flags & ANTPLUS_HEARTRATE_FLAGS_EXTENTED_FEATURES)) { - return CAPABILITIES_NUMBER; - } else if ((currentPage < BATTERYSTATUS_NUMBER) && (_flags & ANTPLUS_HEARTRATE_FLAGS_BATTERYSTATUS_SUPPORTED)) { - return BATTERYSTATUS_NUMBER; + if ((currentPage < HEARTRATE_CUMULATIVEOPERATINGTIME_NUMBER) && + (_flags & ANTPLUS_HEARTRATE_FLAGS_CUMULATIVEOPERATINGTIME_SUPPORTED)) { + 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) && + (_flags & ANTPLUS_HEARTRATE_FLAGS_BATTERYSTATUS_SUPPORTED)) { + return HEARTRATE_BATTERYSTATUS_NUMBER; } else { // Reached end of the loop, start again return getNextBackgroundPage(0); @@ -130,28 +133,28 @@ uint8_t ProfileHeartRateMonitor::getNextBackgroundPage(uint8_t currentPage) { void ProfileHeartRateMonitor::transmitRequestedDataPage() { uint8_t requestedPage = getRequestedPage(); switch (requestedPage) { - case DEFAULT_NUMBER: + case HEARTRATE_DEFAULT_NUMBER: transmitHeartRateDefaultMsg(); break; - case CUMULATIVEOPERATINGTIME_NUMBER: + case HEARTRATE_CUMULATIVEOPERATINGTIME_NUMBER: transmitHeartRateCumulativeOperatingTimeMsg(); break; - case MANUFACTURERINFORMATION_NUMBER: + case HEARTRATE_MANUFACTURERINFORMATION_NUMBER: transmitHeartRateManufacturerInformationMsg(); break; - case PRODUCTINFORMATION_NUMBER: + case HEARTRATE_PRODUCTINFORMATION_NUMBER: transmitHeartRateProductInformationMsg(); break; - case PREVIOUSHEARTBEAT_NUMBER: + case HEARTRATE_PREVIOUSHEARTBEAT_NUMBER: transmitHeartRatePreviousHeartBeatMsg(); break; - case SWIMINTERVALSUMMARY_NUMBER: + case HEARTRATE_SWIMINTERVALSUMMARY_NUMBER: transmitHeartRateSwimIntervalSummaryMsg(); break; - case CAPABILITIES_NUMBER: + case HEARTRATE_CAPABILITIES_NUMBER: transmitHeartRateCapabilitiesMsg(); break; - case BATTERYSTATUS_NUMBER: + case HEARTRATE_BATTERYSTATUS_NUMBER: transmitHeartRateBatteryStatusMsg(); break; } @@ -215,20 +218,20 @@ void ProfileHeartRateMonitor::transmitHeartRateMsg(HeartRateBaseMainDataPageMsg& bool ProfileHeartRateMonitor::isDataPageValid(uint8_t dataPage) { switch (dataPage) { - case DEFAULT_NUMBER: - // TODO double check this is correct that dp 4 is only needed if imlemented + case HEARTRATE_DEFAULT_NUMBER: + // TODO double check this is correct that dp 4 is only needed if implemented return !(_flags & ANTPLUS_HEARTRATE_FLAGS_PREVIOUSHEARTBEAT_SUPPORTED); - case CUMULATIVEOPERATINGTIME_NUMBER: + case HEARTRATE_CUMULATIVEOPERATINGTIME_NUMBER: return _flags & ANTPLUS_HEARTRATE_FLAGS_CUMULATIVEOPERATINGTIME_SUPPORTED; - case MANUFACTURERINFORMATION_NUMBER: - case PRODUCTINFORMATION_NUMBER: + case HEARTRATE_MANUFACTURERINFORMATION_NUMBER: + case HEARTRATE_PRODUCTINFORMATION_NUMBER: return true; - case PREVIOUSHEARTBEAT_NUMBER: + case HEARTRATE_PREVIOUSHEARTBEAT_NUMBER: return _flags & ANTPLUS_HEARTRATE_FLAGS_PREVIOUSHEARTBEAT_SUPPORTED; - case SWIMINTERVALSUMMARY_NUMBER: - case CAPABILITIES_NUMBER: + case HEARTRATE_SWIMINTERVALSUMMARY_NUMBER: + case HEARTRATE_CAPABILITIES_NUMBER: return _flags & ANTPLUS_HEARTRATE_FLAGS_EXTENTED_FEATURES; - case BATTERYSTATUS_NUMBER: + case HEARTRATE_BATTERYSTATUS_NUMBER: return _flags & ANTPLUS_HEARTRATE_FLAGS_BATTERYSTATUS_SUPPORTED; default: return false; diff --git a/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.cpp b/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.cpp index f71a0a9..3ddf6c1 100644 --- a/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.cpp +++ b/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.cpp @@ -62,10 +62,10 @@ bool ProfileLevDisplay::handleDataPage(LevBaseMainDataPage& dp) { case ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_NUMBER: called = handleCapabilities(dp); break; - case MANUFACTURERSINFORMATION_NUMBER: + case COMMON_MANUFACTURERSINFORMATION_NUMBER: called = handleManufacturersInformation(dp); break; - case PRODUCTINFORMATION_NUMBER: + case COMMON_PRODUCTINFORMATION_NUMBER: called = handleProductInformation(dp); break; } diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp index 20748d7..46ecd54 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp @@ -34,9 +34,9 @@ bool ProfileShiftingShifter::isDataPageValid(uint8_t dataPage) { switch (dataPage) { case ANTPLUS_SHIFTING_DATAPAGE_SHIFTSYSTEMSTATUS_NUMBER: - case MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER: - case MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER: - case BATTERYSTATUS_NUMBER: + case COMMON_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER: + case COMMON_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER: + case COMMON_BATTERYSTATUS_NUMBER: return true; } return false; @@ -104,7 +104,7 @@ void ProfileShiftingShifter::onAcknowledgedData(AcknowledgedData& msg) { switch (dataPage) { - case REQUESTDATAPAGE_NUMBER: + case COMMON_REQUESTDATAPAGE_NUMBER: called = handleRequestDataPage(dp); break; } @@ -169,9 +169,9 @@ bool ProfileShiftingShifter::handleRequestDataPage(BaseDataPage Date: Mon, 18 Jan 2021 16:11:58 -0800 Subject: [PATCH 103/241] BicycleSpeed: localize defines step 2 of refactor, move defines close to their used and truncate names --- .../ANTPLUS_BicycleSpeedDefines.h | 2 + .../ANTPLUS_BicycleSpeedPrivateDefines.h | 68 +++---------------- .../ANTPLUS_BicycleSpeedBaseMainDataPage.cpp | 45 ++++++------ .../ANTPLUS_BicycleSpeedBatteryStatus.cpp | 21 +++--- ...US_BicycleSpeedCumulativeOperatingTime.cpp | 8 ++- .../ANTPLUS_BicycleSpeedManufacturerID.cpp | 11 +-- .../ANTPLUS_BicycleSpeedMotionAndSpeed.cpp | 5 +- .../ANTPLUS_BicycleSpeedProductID.cpp | 13 ++-- .../ANTPLUS_ProfileBicycleSpeedDisplay.cpp | 20 +++--- 9 files changed, 80 insertions(+), 113 deletions(-) diff --git a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedDefines.h b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedDefines.h index ce9bdc3..73e5f80 100644 --- a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedDefines.h +++ b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedDefines.h @@ -1,6 +1,8 @@ #ifndef ANTPLUS_BICYCLESPEEDPROFILEDEFINES_h #define ANTPLUS_BICYCLESPEEDPROFILEDEFINES_h +#define ANTPLUS_BICYCLESPEED_DEVICETYPE 123 + #define ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_NEW 1 #define ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_GOOD 2 #define ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_OK 3 diff --git a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedPrivateDefines.h b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedPrivateDefines.h index fc8eae8..71c5193 100644 --- a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedPrivateDefines.h +++ b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedPrivateDefines.h @@ -1,64 +1,18 @@ #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_BIKESPEEDEVENTTIME_LSB_BYTE 4 -#define ANTPLUS_BICYCLESPEED_DATAPAGEBASE_BIKESPEEDEVENTTIME_MSB_BYTE 5 -#define ANTPLUS_BICYCLESPEED_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNT_LSB_BYTE 6 -#define ANTPLUS_BICYCLESPEED_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNT_MSB_BYTE 7 - -#define ANTPLUS_BICYCLESPEED_DATAPAGEBASE_DATAPAGE_MASK 0x7F -#define ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_MASK 0x80 - -#define ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_SHIFT 7 - -/* 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 + +#define BICYCLESPEED_DEFAULT_NUMBER 0 +#define BICYCLESPEED_CUMULATIVEOPERATINGTIME_NUMBER 1 +#define BICYCLESPEED_MANUFACTURERID_NUMBER 2 +#define BICYCLESPEED_PRODUCTID_NUMBER 3 +#define BICYCLESPEED_BATTERYSTATUS_NUMBER 4 +#define BICYCLESPEED_MOTIONANDSPEED_NUMBER 5 #endif // ANTPLUS_BICYCLESPEEDPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.cpp b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.cpp index d2ae743..7c6e2e5 100644 --- a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.cpp +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.cpp @@ -2,35 +2,40 @@ #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() {} +BicycleSpeedCoreMainDataPage::BicycleSpeedCoreMainDataPage() : + CoreDataPage() {} template uint8_t BicycleSpeedCoreMainDataPage::getDataPageNumber() { - return this->get8BitValue( - ANTPLUS_BICYCLESPEED_DATAPAGEBASE_DATAPAGE_BYTE, - ANTPLUS_BICYCLESPEED_DATAPAGEBASE_DATAPAGE_MASK); + return this->get8BitValue(DATAPAGE_BYTE, DATAPAGE_MASK); } template uint8_t BicycleSpeedCoreMainDataPage::getPageChangeToggle() { - return this->get8BitValue(ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_BYTE, - ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_MASK, - ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_SHIFT); + return this->get8BitValue(TOGGLE_BYTE, TOGGLE_MASK, TOGGLE_SHIFT); } template uint16_t BicycleSpeedCoreMainDataPage::getBikeSpeedEventTime() { - return this->get16BitValue( - ANTPLUS_BICYCLESPEED_DATAPAGEBASE_BIKESPEEDEVENTTIME_LSB_BYTE, - ANTPLUS_BICYCLESPEED_DATAPAGEBASE_BIKESPEEDEVENTTIME_MSB_BYTE); + return this->get16BitValue(BIKESPEEDEVENTTIME_LSB_BYTE, + BIKESPEEDEVENTTIME_MSB_BYTE); } template uint16_t BicycleSpeedCoreMainDataPage::getCumulativeSpeedRevolutionCount() { - return this->get16BitValue( - ANTPLUS_BICYCLESPEED_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNT_LSB_BYTE, - ANTPLUS_BICYCLESPEED_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNT_MSB_BYTE); + return this->get16BitValue(CUMULATIVESPEEDREVOLUTIONCOUNT_LSB_BYTE, + CUMULATIVESPEEDREVOLUTIONCOUNT_MSB_BYTE); } BicycleSpeedBaseMainDataPage::BicycleSpeedBaseMainDataPage(AntRxDataResponse& dp) : @@ -45,19 +50,15 @@ BicycleSpeedBaseMainDataPageMsg::BicycleSpeedBaseMainDataPageMsg(uint8_t dataPag } void BicycleSpeedBaseMainDataPageMsg::setPageChangeToggle(uint8_t toggle) { - set8BitValue(toggle ? ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_MASK : 0, - ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_BYTE, - ANTPLUS_BICYCLESPEED_DATAPAGEBASE_TOGGLE_MASK); + set8BitValue(toggle ? TOGGLE_MASK : 0, TOGGLE_BYTE, TOGGLE_MASK); } void BicycleSpeedBaseMainDataPageMsg::setBikeSpeedEventTime(uint16_t time) { - set16BitValue(time, - ANTPLUS_BICYCLESPEED_DATAPAGEBASE_BIKESPEEDEVENTTIME_LSB_BYTE, - ANTPLUS_BICYCLESPEED_DATAPAGEBASE_BIKESPEEDEVENTTIME_MSB_BYTE); + set16BitValue(time, BIKESPEEDEVENTTIME_LSB_BYTE, + BIKESPEEDEVENTTIME_MSB_BYTE); } void BicycleSpeedBaseMainDataPageMsg::setCumulativeSpeedRevolutionCount(uint16_t count) { - set16BitValue(count, - ANTPLUS_BICYCLESPEED_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNT_LSB_BYTE, - ANTPLUS_BICYCLESPEED_DATAPAGEBASE_CUMULATIVESPEEDREVOLUTIONCOUNT_MSB_BYTE); + set16BitValue(count, CUMULATIVESPEEDREVOLUTIONCOUNT_LSB_BYTE, + CUMULATIVESPEEDREVOLUTIONCOUNT_MSB_BYTE); } diff --git a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBatteryStatus.cpp b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBatteryStatus.cpp index be0ac0d..fe29703 100644 --- a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBatteryStatus.cpp +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBatteryStatus.cpp @@ -1,29 +1,32 @@ #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( - ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_FRACTIONALBATTERYVOLTAGE_BYTE); + return this->get8BitValue(FRACTIONALBATTERYVOLTAGE_BYTE); } template uint8_t BicycleSpeedBaseBatteryStatus::getCoarseBatteryVoltage() { - return this->get8BitValue( - ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_BYTE, - ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_COARSEBATTERYVOLTAGE_MASK); + return this->get8BitValue(COARSEBATTERYVOLTAGE_BYTE, + 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); + return this->get8BitValue(BATTERYSTATUS_BYTE, BATTERYSTATUS_MASK, + BATTERYSTATUS_SHIFT); } template class BicycleSpeedBaseBatteryStatus; diff --git a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedCumulativeOperatingTime.cpp b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedCumulativeOperatingTime.cpp index 20492eb..d0a49fa 100644 --- a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedCumulativeOperatingTime.cpp +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedCumulativeOperatingTime.cpp @@ -1,15 +1,17 @@ #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( - ANTPLUS_BICYCLESPEED_DATAPAGE_CUMULATIVEOPERATINGTIME_TIME_LSB_BYTE, - ANTPLUS_BICYCLESPEED_DATAPAGE_CUMULATIVEOPERATINGTIME_TIME_MSB_BYTE); + return this->get24BitValue(CUMULATIVEOPERATINGTIME_TIME_LSB_BYTE, + CUMULATIVEOPERATINGTIME_TIME_MSB_BYTE); } template class BicycleSpeedBaseCumulativeOperatingTime; diff --git a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedManufacturerID.cpp b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedManufacturerID.cpp index 573bcae..003a89d 100644 --- a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedManufacturerID.cpp +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedManufacturerID.cpp @@ -1,21 +1,22 @@ #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( - ANTPLUS_BICYCLESPEED_DATAPAGE_MANUFACTURERINFORMATION_MANUFACTUREREID_BYTE); + return this->get8BitValue(MANUFACTUREREID_BYTE); } template uint16_t BicycleSpeedBaseManufacturerID::getSerialNumber() { - return this->get16BitValue( - ANTPLUS_BICYCLESPEED_DATAPAGE_MANUFACTURERINFORMATION_SERIALNUMBER_LSB_BYTE, - ANTPLUS_BICYCLESPEED_DATAPAGE_MANUFACTURERINFORMATION_SERIALNUMBER_MSB_BYTE); + return this->get16BitValue(SERIALNUMBER_LSB_BYTE, SERIALNUMBER_MSB_BYTE); } template class BicycleSpeedBaseManufacturerID; diff --git a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedMotionAndSpeed.cpp b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedMotionAndSpeed.cpp index eaa6d75..77736f6 100644 --- a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedMotionAndSpeed.cpp +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedMotionAndSpeed.cpp @@ -1,14 +1,15 @@ #include #include +#define FLAGS_BYTE 1 + template 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; diff --git a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedProductID.cpp b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedProductID.cpp index 780d058..c3f92b2 100644 --- a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedProductID.cpp +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedProductID.cpp @@ -1,25 +1,26 @@ #include #include +#define HARDWAREVERSION_BYTE 1 +#define SOFTWAREVERSION_BYTE 2 +#define MODELNUMBER_BYTE 3 + template 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; diff --git a/src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.cpp b/src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.cpp index b5b5675..d4773e0 100644 --- a/src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.cpp +++ b/src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.cpp @@ -3,6 +3,8 @@ #include #include +#define DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE + ProfileBicycleSpeedDisplay::ProfileBicycleSpeedDisplay() : BaseSlaveProfile() { setChannelConfig(); } @@ -28,22 +30,22 @@ bool ProfileBicycleSpeedDisplay::handleDataPage(BicycleSpeedBaseMainDataPage& dp bool called = false; switch (dataPage) { - case ANTPLUS_BICYCLESPEED_DATAPAGE_DEFAULT_NUMBER: + case BICYCLESPEED_DEFAULT_NUMBER: called = handleDefault(dp); break; - case ANTPLUS_BICYCLESPEED_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER: + case BICYCLESPEED_CUMULATIVEOPERATINGTIME_NUMBER: called = handleCumulativeOperatingTime(dp); break; - case ANTPLUS_BICYCLESPEED_DATAPAGE_MANUFACTURERID_NUMBER: + case BICYCLESPEED_MANUFACTURERID_NUMBER: called = handleManufacturerID(dp); break; - case ANTPLUS_BICYCLESPEED_DATAPAGE_PRODUCTID_NUMBER: + case BICYCLESPEED_PRODUCTID_NUMBER: called = handleProductID(dp); break; - case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_NUMBER: + case BICYCLESPEED_BATTERYSTATUS_NUMBER: called = handleBatteryStatus(dp); break; - case ANTPLUS_BICYCLESPEED_DATAPAGE_MOTIONANDSPEED_NUMBER: + case BICYCLESPEED_MOTIONANDSPEED_NUMBER: called = handleMotionAndSpeed(dp); break; } @@ -61,10 +63,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) { From 490fc3811cfbc94baff92d44ede9c98bfa70d570 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 18 Jan 2021 16:19:28 -0800 Subject: [PATCH 104/241] power: fixup channel config names --- .../BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h | 4 ++-- .../Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp | 4 ++-- .../Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h index 26ec07a..4ed7bde 100644 --- a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h @@ -4,9 +4,9 @@ #include /* Channel Config */ -#define CHANNELPERIOD 8182 +#define BICYCLEPOWER_CHANNELPERIOD 8182 // 30 / 2.5 = 12 -#define SEARCHTIMEOUT 12 +#define BICYCLEPOWER_SEARCHTIMEOUT 12 #define BICYCLEPOWER_GENERALCALIBRATION_NUMBER 0x01 #define BICYCLEPOWER_STANDARDPOWERONLY_NUMBER 0x10 diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp index d0b7052..c375793 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp @@ -68,8 +68,8 @@ void ProfileBicyclePowerDisplay::onAcknowledgedData(AcknowledgedData& msg) { void ProfileBicyclePowerDisplay::setChannelConfig() { setChannelType(DISPLAY_CHANNELTYPE); setDeviceType(ANTPLUS_BICYCLEPOWER_DEVICETYPE); - setChannelPeriod(CHANNELPERIOD); - setSearchTimeout(SEARCHTIMEOUT); + setChannelPeriod(BICYCLEPOWER_CHANNELPERIOD); + setSearchTimeout(BICYCLEPOWER_SEARCHTIMEOUT); } bool ProfileBicyclePowerDisplay::handleBatteryStatus(BicyclePowerBaseMainDataPage& dataPage) { diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp index a7c6000..9036f30 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -158,8 +158,8 @@ void ProfileBicyclePowerSensor::transmitRequestedDataPage() { void ProfileBicyclePowerSensor::setChannelConfig() { setChannelType(SENSOR_CHANNELTYPE); setDeviceType(ANTPLUS_BICYCLEPOWER_DEVICETYPE); - setChannelPeriod(CHANNELPERIOD); - setSearchTimeout(SEARCHTIMEOUT); + setChannelPeriod(BICYCLEPOWER_CHANNELPERIOD); + setSearchTimeout(BICYCLEPOWER_SEARCHTIMEOUT); } bool ProfileBicyclePowerSensor::isDataPageValid(uint8_t dataPage) { From 22c2f8b6e5288bcd52589789d938207b9ba8dbaf Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 18 Jan 2021 16:19:49 -0800 Subject: [PATCH 105/241] heartrate: fixup channel config names --- src/Profiles/HeartRate/ANTPLUS_HeartRatePrivateDefines.h | 4 ++-- .../HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp | 4 ++-- .../HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Profiles/HeartRate/ANTPLUS_HeartRatePrivateDefines.h b/src/Profiles/HeartRate/ANTPLUS_HeartRatePrivateDefines.h index 558d1c0..16baa9c 100644 --- a/src/Profiles/HeartRate/ANTPLUS_HeartRatePrivateDefines.h +++ b/src/Profiles/HeartRate/ANTPLUS_HeartRatePrivateDefines.h @@ -2,9 +2,9 @@ #define ANTPLUS_HEARTRATEPROFILEPRIVATEDEFINES_h /* Channel Config */ -#define ANTPLUS_HEARTRATE_CHANNELPERIOD 8070 +#define HEARTRATE_CHANNELPERIOD 8070 // 30 / 2.5 = 12 -#define ANTPLUS_HEARTRATE_SEARCHTIMEOUT 12 +#define HEARTRATE_SEARCHTIMEOUT 12 /* DataPage Numbers */ #define HEARTRATE_DEFAULT_NUMBER 0 diff --git a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp index 4c8aeda..ad53d8b 100644 --- a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp @@ -72,8 +72,8 @@ void ProfileHeartRateDisplay::onAcknowledgedData(AcknowledgedData& msg) { void ProfileHeartRateDisplay::setChannelConfig() { 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/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp index e52e892..a7485fe 100644 --- a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp @@ -251,6 +251,6 @@ bool ProfileHeartRateMonitor::handleRequestDataPage(HeartRateBaseMainDataPage& d void ProfileHeartRateMonitor::setChannelConfig() { setChannelType(MONITOR_CHANNELTYPE); setDeviceType(ANTPLUS_HEARTRATE_DEVICETYPE); - setChannelPeriod(ANTPLUS_HEARTRATE_CHANNELPERIOD); - setSearchTimeout(ANTPLUS_HEARTRATE_SEARCHTIMEOUT); + setChannelPeriod(HEARTRATE_CHANNELPERIOD); + setSearchTimeout(HEARTRATE_SEARCHTIMEOUT); } From 9d6e7b14fc1d8a19a5d0fbc13d3ff3cbde895637 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 18 Jan 2021 16:23:59 -0800 Subject: [PATCH 106/241] BicycleSpeed: consolidate profile implementations silly having a folder for 2 files --- src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedProfile.h | 4 ++-- .../ANTPLUS_ProfileBicycleSpeedDisplay.cpp | 2 +- .../ANTPLUS_ProfileBicycleSpeedDisplay.h | 0 .../{Sensor => Profiles}/ANTPLUS_ProfileBicycleSpeedSensor.h | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) rename src/Profiles/BicycleSpeed/{Display => Profiles}/ANTPLUS_ProfileBicycleSpeedDisplay.cpp (97%) rename src/Profiles/BicycleSpeed/{Display => Profiles}/ANTPLUS_ProfileBicycleSpeedDisplay.h (100%) rename src/Profiles/BicycleSpeed/{Sensor => Profiles}/ANTPLUS_ProfileBicycleSpeedSensor.h (99%) diff --git a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedProfile.h b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedProfile.h index 2f66863..30e85aa 100644 --- a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedProfile.h +++ b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedProfile.h @@ -8,7 +8,7 @@ #include // Profile Classes -#include -#include +#include +#include #endif // ANTPLUS_BICYCLESPEEDPROFILE_h diff --git a/src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.cpp b/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.cpp similarity index 97% rename from src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.cpp rename to src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.cpp index d4773e0..a4beb7c 100644 --- a/src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.cpp +++ b/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.h b/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.h similarity index 100% rename from src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.h rename to src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.h diff --git a/src/Profiles/BicycleSpeed/Sensor/ANTPLUS_ProfileBicycleSpeedSensor.h b/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedSensor.h similarity index 99% rename from src/Profiles/BicycleSpeed/Sensor/ANTPLUS_ProfileBicycleSpeedSensor.h rename to src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedSensor.h index 650582a..bf19aef 100644 --- a/src/Profiles/BicycleSpeed/Sensor/ANTPLUS_ProfileBicycleSpeedSensor.h +++ b/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedSensor.h @@ -5,6 +5,7 @@ #include #include +// TODO class ProfileBicycleSpeedSensor : BaseMasterProfile { public: // void onHeartRateCapabilities(void (*func)(HeartRateCapabilities&, uintptr_t), uintptr_t data = 0) { _onHeartRateCapabilities.set(func, data); } From e550da05c46129a0881fa0fb3f08534d50b4d748 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 18 Jan 2021 17:14:57 -0800 Subject: [PATCH 107/241] BicycleSpeed: add core class implementations whoops, thanks CI --- .../DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.cpp b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.cpp index 7c6e2e5..644cfa3 100644 --- a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.cpp +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.cpp @@ -37,6 +37,8 @@ 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), From 93fec083b927633caf0d83fee2ea91e33ee7f4e7 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 18 Jan 2021 18:52:43 -0800 Subject: [PATCH 108/241] environment: consolidate datapages step 1 of refactor --- .../Environment/ANTPLUS_EnvironmentProfile.h | 2 +- .../ANTPLUS_ProfileEnvironmentDataPages.h | 7 ++++++ .../ANTPLUS_EnvironmentBaseDataPage.cpp | 6 ++--- .../ANTPLUS_EnvironmentBaseDataPage.h | 2 -- ...ANTPLUS_EnvironmentGeneralInformation.cpp} | 10 ++++++--- .../ANTPLUS_EnvironmentGeneralInformation.h | 21 ++++++++++++++++++ ...cpp => ANTPLUS_EnvironmentTemperature.cpp} | 12 ++++++---- .../ANTPLUS_EnvironmentTemperature.h | 22 +++++++++++++++++++ .../ANTPLUS_ProfileEnvironmentDataPages.h | 10 --------- ...NTPLUS_EnvironmentBaseGeneralInformation.h | 18 --------------- .../Base/ANTPLUS_EnvironmentBaseTemperature.h | 18 --------------- .../ANTPLUS_EnvironmentGeneralInformation.cpp | 5 ----- .../ANTPLUS_EnvironmentGeneralInformation.h | 12 ---------- .../RX/ANTPLUS_EnvironmentTemperature.cpp | 6 ----- .../RX/ANTPLUS_EnvironmentTemperature.h | 13 ----------- .../ANTPLUS_ProfileEnvironmentDisplay.h | 2 +- .../ANTPLUS_ProfileEnvironmentMonitor.h | 2 +- 17 files changed, 71 insertions(+), 97 deletions(-) create mode 100644 src/Profiles/Environment/ANTPLUS_ProfileEnvironmentDataPages.h rename src/Profiles/Environment/DataPages/{Base => }/ANTPLUS_EnvironmentBaseDataPage.cpp (51%) rename src/Profiles/Environment/DataPages/{Base => }/ANTPLUS_EnvironmentBaseDataPage.h (94%) rename src/Profiles/Environment/DataPages/{Base/ANTPLUS_EnvironmentBaseGeneralInformation.cpp => ANTPLUS_EnvironmentGeneralInformation.cpp} (85%) create mode 100644 src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentGeneralInformation.h rename src/Profiles/Environment/DataPages/{Base/ANTPLUS_EnvironmentBaseTemperature.cpp => ANTPLUS_EnvironmentTemperature.cpp} (85%) create mode 100644 src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentTemperature.h delete mode 100644 src/Profiles/Environment/DataPages/ANTPLUS_ProfileEnvironmentDataPages.h delete mode 100644 src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseGeneralInformation.h delete mode 100644 src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseTemperature.h delete mode 100644 src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentGeneralInformation.cpp delete mode 100644 src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentGeneralInformation.h delete mode 100644 src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentTemperature.cpp delete mode 100644 src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentTemperature.h diff --git a/src/Profiles/Environment/ANTPLUS_EnvironmentProfile.h b/src/Profiles/Environment/ANTPLUS_EnvironmentProfile.h index 7a5a5a2..ef21197 100644 --- a/src/Profiles/Environment/ANTPLUS_EnvironmentProfile.h +++ b/src/Profiles/Environment/ANTPLUS_EnvironmentProfile.h @@ -5,7 +5,7 @@ #include // Datapages -#include +#include // Profile Classes #include diff --git a/src/Profiles/Environment/ANTPLUS_ProfileEnvironmentDataPages.h b/src/Profiles/Environment/ANTPLUS_ProfileEnvironmentDataPages.h new file mode 100644 index 0000000..faa2ad1 --- /dev/null +++ b/src/Profiles/Environment/ANTPLUS_ProfileEnvironmentDataPages.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/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 94% rename from src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseDataPage.h rename to src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentBaseDataPage.h index 4b3a232..85f41c3 100644 --- a/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseDataPage.h +++ b/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentBaseDataPage.h @@ -3,8 +3,6 @@ #include -#include "ANT.h" - class EnvironmentBaseDataPage : public BaseDataPage { public: explicit EnvironmentBaseDataPage(AntRxDataResponse& dp); diff --git a/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseGeneralInformation.cpp b/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentGeneralInformation.cpp similarity index 85% rename from src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseGeneralInformation.cpp rename to src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentGeneralInformation.cpp index 83b76b9..8a6ce2a 100644 --- a/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseGeneralInformation.cpp +++ b/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentGeneralInformation.cpp @@ -1,9 +1,9 @@ -#include +#include #include template -EnvironmentBaseGeneralInformation::EnvironmentBaseGeneralInformation() : CoreDataPage() { -} +EnvironmentBaseGeneralInformation::EnvironmentBaseGeneralInformation() : + CoreDataPage() {} template uint8_t EnvironmentBaseGeneralInformation::getTransmissionInfoLocalTime() { @@ -37,3 +37,7 @@ uint32_t EnvironmentBaseGeneralInformation::getSupportedPages() { 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/Base/ANTPLUS_EnvironmentBaseTemperature.cpp b/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentTemperature.cpp similarity index 85% rename from src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseTemperature.cpp rename to src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentTemperature.cpp index 5a6ea1c..20376d5 100644 --- a/src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseTemperature.cpp +++ b/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentTemperature.cpp @@ -1,9 +1,9 @@ -#include +#include #include template -EnvironmentBaseTemperature::EnvironmentBaseTemperature() : CoreDataPage() { -} +EnvironmentBaseTemperature::EnvironmentBaseTemperature() : + CoreDataPage() {} template uint8_t EnvironmentBaseTemperature::getEventCount() { @@ -11,7 +11,6 @@ uint8_t EnvironmentBaseTemperature::getEventCount() { 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() { @@ -49,3 +48,8 @@ int16_t EnvironmentBaseTemperature::getCurrentTemp() { 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.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.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 e59f703..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: - explicit 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 23459b8..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: - explicit EnvironmentTemperature(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_ENVIRONMENTTEMPERATURE_h - diff --git a/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.h b/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.h index 139cf30..164062c 100644 --- a/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.h +++ b/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.h @@ -2,7 +2,7 @@ #define ANTPLUS_PROFILEENVIRONMENTDISPLAY_h #include -#include +#include #include #include "ANT.h" diff --git a/src/Profiles/Environment/Monitor/ANTPLUS_ProfileEnvironmentMonitor.h b/src/Profiles/Environment/Monitor/ANTPLUS_ProfileEnvironmentMonitor.h index 2b874fc..a4f7939 100644 --- a/src/Profiles/Environment/Monitor/ANTPLUS_ProfileEnvironmentMonitor.h +++ b/src/Profiles/Environment/Monitor/ANTPLUS_ProfileEnvironmentMonitor.h @@ -2,7 +2,7 @@ #define ANTPLUS_PROFILEENVIRONMENTMONITOR_h #include -#include +#include #include class ProfileEnvironmentMonitor : BaseMasterProfile { From 249fee4b2797e8dee49e658e33b1f2155a62d8b5 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 18 Jan 2021 19:47:01 -0800 Subject: [PATCH 109/241] Environment: localize defines step 2 of refactor --- .../Environment/ANTPLUS_EnvironmentDefines.h | 2 + .../ANTPLUS_EnvironmentPrivateDefines.h | 55 ++----------------- .../ANTPLUS_EnvironmentGeneralInformation.cpp | 31 ++++++----- .../ANTPLUS_EnvironmentTemperature.cpp | 37 +++++++------ .../ANTPLUS_ProfileEnvironmentDisplay.cpp | 12 ++-- 5 files changed, 52 insertions(+), 85 deletions(-) diff --git a/src/Profiles/Environment/ANTPLUS_EnvironmentDefines.h b/src/Profiles/Environment/ANTPLUS_EnvironmentDefines.h index efd7a2f..c27db15 100644 --- a/src/Profiles/Environment/ANTPLUS_EnvironmentDefines.h +++ b/src/Profiles/Environment/ANTPLUS_EnvironmentDefines.h @@ -1,6 +1,8 @@ #ifndef ANTPLUS_ENVIRONMENTPROFILEDEFINES_h #define ANTPLUS_ENVIRONMENTPROFILEDEFINES_h +#define ANTPLUS_ENVIRONMENT_DEVICETYPE 25 + #define ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_SUPPORTEDPAGES_PAGE0SUPPORT 1 #define ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_SUPPORTEDPAGES_PAGE1SUPPORT 2 diff --git a/src/Profiles/Environment/ANTPLUS_EnvironmentPrivateDefines.h b/src/Profiles/Environment/ANTPLUS_EnvironmentPrivateDefines.h index c277479..14fbe4e 100644 --- a/src/Profiles/Environment/ANTPLUS_EnvironmentPrivateDefines.h +++ b/src/Profiles/Environment/ANTPLUS_EnvironmentPrivateDefines.h @@ -1,57 +1,14 @@ #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 +#define ENVIRONMENT_SEARCHTIMEOUT 18 -/* Current Temp */ -#define ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_CURRENTTEMP_LSB_BYTE 6 -#define ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_CURRENTTEMP_MSB_BYTE 7 +#define ENVIRONMENT_GENERALINFORMATION_NUMBER 0 +#define ENVIRONMENT_TEMPERATURE_NUMBER 1 #endif // ANTPLUS_ENVIRONMENTPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentGeneralInformation.cpp b/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentGeneralInformation.cpp index 8a6ce2a..5b48e24 100644 --- a/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentGeneralInformation.cpp +++ b/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentGeneralInformation.cpp @@ -1,38 +1,41 @@ #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( - ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_TRANSMISSIONINFO_BYTE, - ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_TRANSMISSIONINFO_LOCALTIME_MASK, - ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_TRANSMISSIONINFO_LOCALTIME_SHIFT); + return this->get8BitValue(TRANSMISSIONINFO_BYTE, + TRANSMISSIONINFO_LOCALTIME_MASK, 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); + return this->get8BitValue(TRANSMISSIONINFO_BYTE, + TRANSMISSIONINFO_UTCTIME_MASK, TRANSMISSIONINFO_UTCTIME_SHIFT); } template uint8_t EnvironmentBaseGeneralInformation::getTransmissionInfoDefaultTransmissionRate() { - return this->get8BitValue( - ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_TRANSMISSIONINFO_BYTE, - ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_TRANSMISSIONINFO_DEFAULTTRANSMISSIONRATE_MASK); + return this->get8BitValue(TRANSMISSIONINFO_BYTE, + 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); + return this->get32BitValue(SUPPORTEDPAGES_LSB_BYTE, + SUPPORTEDPAGES_MSB_BYTE); } template class EnvironmentBaseGeneralInformation; diff --git a/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentTemperature.cpp b/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentTemperature.cpp index 20376d5..b9aca44 100644 --- a/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentTemperature.cpp +++ b/src/Profiles/Environment/DataPages/ANTPLUS_EnvironmentTemperature.cpp @@ -1,25 +1,33 @@ #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( - ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_EVENTCOUNT_BYTE); + 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( - 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); + 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; @@ -28,12 +36,9 @@ int16_t EnvironmentBaseTemperature::get24HourLow() { /* 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); + 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; @@ -41,9 +46,7 @@ int16_t EnvironmentBaseTemperature::get24HourHigh() { template int16_t EnvironmentBaseTemperature::getCurrentTemp() { - return this->get16BitValue( - ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_CURRENTTEMP_LSB_BYTE, - ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_CURRENTTEMP_MSB_BYTE); + return this->get16BitValue(CURRENTTEMP_LSB_BYTE, CURRENTTEMP_MSB_BYTE); } template class EnvironmentBaseTemperature; diff --git a/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.cpp b/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.cpp index 4279416..e4d4bdf 100644 --- a/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.cpp +++ b/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.cpp @@ -2,6 +2,8 @@ #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 ENVIRONMENT_GENERALINFORMATION_NUMBER: called = handleGeneralInformation(dp); break; - case ANTPLUS_ENVIRONMENT_DATAPAGE_TEMPERATURE_NUMBER: + case ENVIRONMENT_TEMPERATURE_NUMBER: called = handleTemperature(dp); break; case COMMON_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) { From bc5138a4253147cb8d2c861164fb636471a99eed Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 18 Jan 2021 19:51:33 -0800 Subject: [PATCH 110/241] Enviroment: consolidate profiles step 3 of refactor --- src/Profiles/Environment/ANTPLUS_EnvironmentProfile.h | 4 ++-- .../ANTPLUS_ProfileEnvironmentDisplay.cpp | 2 +- .../{Display => Profiles}/ANTPLUS_ProfileEnvironmentDisplay.h | 0 .../{Monitor => Profiles}/ANTPLUS_ProfileEnvironmentMonitor.h | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename src/Profiles/Environment/{Display => Profiles}/ANTPLUS_ProfileEnvironmentDisplay.cpp (97%) rename src/Profiles/Environment/{Display => Profiles}/ANTPLUS_ProfileEnvironmentDisplay.h (100%) rename src/Profiles/Environment/{Monitor => Profiles}/ANTPLUS_ProfileEnvironmentMonitor.h (100%) diff --git a/src/Profiles/Environment/ANTPLUS_EnvironmentProfile.h b/src/Profiles/Environment/ANTPLUS_EnvironmentProfile.h index ef21197..5b331b9 100644 --- a/src/Profiles/Environment/ANTPLUS_EnvironmentProfile.h +++ b/src/Profiles/Environment/ANTPLUS_EnvironmentProfile.h @@ -8,7 +8,7 @@ #include // Profile Classes -#include -#include +#include +#include #endif // ANTPLUS_ENVIRONMENTPROFILE_h diff --git a/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.cpp b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.cpp similarity index 97% rename from src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.cpp rename to src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.cpp index e4d4bdf..429123f 100644 --- a/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.cpp +++ b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.h b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.h similarity index 100% rename from src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.h rename to src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.h diff --git a/src/Profiles/Environment/Monitor/ANTPLUS_ProfileEnvironmentMonitor.h b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentMonitor.h similarity index 100% rename from src/Profiles/Environment/Monitor/ANTPLUS_ProfileEnvironmentMonitor.h rename to src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentMonitor.h From 6a6eae2e5b5f6188f4959f1a0852af3fd8457c25 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 18 Jan 2021 22:46:41 -0800 Subject: [PATCH 111/241] fec: consolidate messages merge message types --- src/Profiles/FEC/ANTPLUS_FECProfile.h | 2 +- .../{DataPages => }/ANTPLUS_ProfileFECDataPages.h | 5 +---- .../{Base => }/ANTPLUS_FECFEMainDataPage.cpp | 6 +++--- .../{Base => }/ANTPLUS_FECFEMainDataPage.h | 0 .../{Base => }/ANTPLUS_FECGeneralMainDataPage.cpp | 2 +- .../{Base => }/ANTPLUS_FECGeneralMainDataPage.h | 0 ...nerDataPage.cpp => ANTPLUS_FECTrainerData.cpp} | 10 +++++++--- ...TrainerDataPage.h => ANTPLUS_FECTrainerData.h} | 15 +++++++++------ .../FEC/DataPages/ANTPLUS_FECTrainerDataPage.cpp | 0 .../FEC/DataPages/RX/ANTPLUS_FECTrainerData.cpp | 5 ----- .../FEC/DataPages/RX/ANTPLUS_FECTrainerData.h | 12 ------------ .../FEC/Display/ANTPLUS_ProfileFECDisplay.h | 2 +- 12 files changed, 23 insertions(+), 36 deletions(-) rename src/Profiles/FEC/{DataPages => }/ANTPLUS_ProfileFECDataPages.h (56%) rename src/Profiles/FEC/DataPages/{Base => }/ANTPLUS_FECFEMainDataPage.cpp (54%) rename src/Profiles/FEC/DataPages/{Base => }/ANTPLUS_FECFEMainDataPage.h (100%) rename src/Profiles/FEC/DataPages/{Base => }/ANTPLUS_FECGeneralMainDataPage.cpp (93%) rename src/Profiles/FEC/DataPages/{Base => }/ANTPLUS_FECGeneralMainDataPage.h (100%) rename src/Profiles/FEC/DataPages/{Base/ANTPLUS_FECTrainerDataPage.cpp => ANTPLUS_FECTrainerData.cpp} (84%) rename src/Profiles/FEC/DataPages/{Base/ANTPLUS_FECTrainerDataPage.h => ANTPLUS_FECTrainerData.h} (53%) create mode 100644 src/Profiles/FEC/DataPages/ANTPLUS_FECTrainerDataPage.cpp delete mode 100644 src/Profiles/FEC/DataPages/RX/ANTPLUS_FECTrainerData.cpp delete mode 100644 src/Profiles/FEC/DataPages/RX/ANTPLUS_FECTrainerData.h diff --git a/src/Profiles/FEC/ANTPLUS_FECProfile.h b/src/Profiles/FEC/ANTPLUS_FECProfile.h index 58ac1e1..800587d 100644 --- a/src/Profiles/FEC/ANTPLUS_FECProfile.h +++ b/src/Profiles/FEC/ANTPLUS_FECProfile.h @@ -5,7 +5,7 @@ #include // Datapages -#include +#include // Profile Classes #include diff --git a/src/Profiles/FEC/DataPages/ANTPLUS_ProfileFECDataPages.h b/src/Profiles/FEC/ANTPLUS_ProfileFECDataPages.h similarity index 56% rename from src/Profiles/FEC/DataPages/ANTPLUS_ProfileFECDataPages.h rename to src/Profiles/FEC/ANTPLUS_ProfileFECDataPages.h index 002598c..dde2148 100644 --- a/src/Profiles/FEC/DataPages/ANTPLUS_ProfileFECDataPages.h +++ b/src/Profiles/FEC/ANTPLUS_ProfileFECDataPages.h @@ -1,9 +1,6 @@ #ifndef ANTPLUS_PROFILEFECDATAPAGES_h #define ANTPLUS_PROFILEFECDATAPAGES_h -/* RX */ -#include - -/* TX */ +#include #endif // ANTPLUS_PROFILEFECDATAPAGES_h diff --git a/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECFEMainDataPage.cpp b/src/Profiles/FEC/DataPages/ANTPLUS_FECFEMainDataPage.cpp similarity index 54% rename from src/Profiles/FEC/DataPages/Base/ANTPLUS_FECFEMainDataPage.cpp rename to src/Profiles/FEC/DataPages/ANTPLUS_FECFEMainDataPage.cpp index 893424a..c5e96fe 100644 --- a/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECFEMainDataPage.cpp +++ b/src/Profiles/FEC/DataPages/ANTPLUS_FECFEMainDataPage.cpp @@ -1,9 +1,9 @@ -#include +#include #include template -FECFEMainDataPage::FECFEMainDataPage() : CoreDataPage() { -} +FECFEMainDataPage::FECFEMainDataPage() : + CoreDataPage() {} template class FECFEMainDataPage; template class FECFEMainDataPage; diff --git a/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECFEMainDataPage.h b/src/Profiles/FEC/DataPages/ANTPLUS_FECFEMainDataPage.h similarity index 100% rename from src/Profiles/FEC/DataPages/Base/ANTPLUS_FECFEMainDataPage.h rename to src/Profiles/FEC/DataPages/ANTPLUS_FECFEMainDataPage.h diff --git a/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECGeneralMainDataPage.cpp b/src/Profiles/FEC/DataPages/ANTPLUS_FECGeneralMainDataPage.cpp similarity index 93% rename from src/Profiles/FEC/DataPages/Base/ANTPLUS_FECGeneralMainDataPage.cpp rename to src/Profiles/FEC/DataPages/ANTPLUS_FECGeneralMainDataPage.cpp index f3fb46f..a468409 100644 --- a/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECGeneralMainDataPage.cpp +++ b/src/Profiles/FEC/DataPages/ANTPLUS_FECGeneralMainDataPage.cpp @@ -1,4 +1,4 @@ -#include +#include #include template diff --git a/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECGeneralMainDataPage.h b/src/Profiles/FEC/DataPages/ANTPLUS_FECGeneralMainDataPage.h similarity index 100% rename from src/Profiles/FEC/DataPages/Base/ANTPLUS_FECGeneralMainDataPage.h rename to src/Profiles/FEC/DataPages/ANTPLUS_FECGeneralMainDataPage.h diff --git a/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECTrainerDataPage.cpp b/src/Profiles/FEC/DataPages/ANTPLUS_FECTrainerData.cpp similarity index 84% rename from src/Profiles/FEC/DataPages/Base/ANTPLUS_FECTrainerDataPage.cpp rename to src/Profiles/FEC/DataPages/ANTPLUS_FECTrainerData.cpp index 7df6597..484137b 100644 --- a/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECTrainerDataPage.cpp +++ b/src/Profiles/FEC/DataPages/ANTPLUS_FECTrainerData.cpp @@ -1,9 +1,9 @@ -#include +#include #include template -FECTrainerDataPage::FECTrainerDataPage() : CoreDataPage() { -} +FECTrainerDataPage::FECTrainerDataPage() : + CoreDataPage() {} template uint8_t FECTrainerDataPage::getDataPageNumber() { @@ -57,3 +57,7 @@ uint8_t FECTrainerDataPage::getTrainerStatusBits() { template class FECTrainerDataPage; template class FECTrainerDataPage; + +FECTrainerData::FECTrainerData(AntRxDataResponse& dp) : + BaseDataPage(dp), + FECTrainerDataPage() {} diff --git a/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECTrainerDataPage.h b/src/Profiles/FEC/DataPages/ANTPLUS_FECTrainerData.h similarity index 53% rename from src/Profiles/FEC/DataPages/Base/ANTPLUS_FECTrainerDataPage.h rename to src/Profiles/FEC/DataPages/ANTPLUS_FECTrainerData.h index 67d1dfb..62332d6 100644 --- a/src/Profiles/FEC/DataPages/Base/ANTPLUS_FECTrainerDataPage.h +++ b/src/Profiles/FEC/DataPages/ANTPLUS_FECTrainerData.h @@ -1,9 +1,7 @@ -#ifndef ANTPLUS_FECTRAINERDATAPAGE_h -#define ANTPLUS_FECTRAINERDATAPAGE_h +#ifndef ANTPLUS_FECTRAINERDATA_h +#define ANTPLUS_FECTRAINERDATA_h -#include - -#include "ANT.h" +#include template class FECTrainerDataPage : virtual public CoreDataPage { @@ -19,4 +17,9 @@ class FECTrainerDataPage : virtual public CoreDataPage { uint8_t getFEStateBits(); }; -#endif // ANTPLUS_FECTRAINERDATAPAGE_h +class FECTrainerData : public BaseDataPage, public FECTrainerDataPage { +public: + explicit FECTrainerData(AntRxDataResponse& dp); +}; + +#endif // ANTPLUS_FECTRAINERDATA_h diff --git a/src/Profiles/FEC/DataPages/ANTPLUS_FECTrainerDataPage.cpp b/src/Profiles/FEC/DataPages/ANTPLUS_FECTrainerDataPage.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/Profiles/FEC/DataPages/RX/ANTPLUS_FECTrainerData.cpp b/src/Profiles/FEC/DataPages/RX/ANTPLUS_FECTrainerData.cpp deleted file mode 100644 index ce645ab..0000000 --- a/src/Profiles/FEC/DataPages/RX/ANTPLUS_FECTrainerData.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -FECTrainerData::FECTrainerData(AntRxDataResponse& dp) : BaseDataPage(dp), FECTrainerDataPage() { - -} diff --git a/src/Profiles/FEC/DataPages/RX/ANTPLUS_FECTrainerData.h b/src/Profiles/FEC/DataPages/RX/ANTPLUS_FECTrainerData.h deleted file mode 100644 index 1dd42d3..0000000 --- a/src/Profiles/FEC/DataPages/RX/ANTPLUS_FECTrainerData.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_FECTRAINERDATA_h -#define ANTPLUS_FECTRAINERDATA_h - -#include -#include - -class FECTrainerData : public BaseDataPage, public FECTrainerDataPage { -public: - explicit FECTrainerData(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_FECTRAINERDATA_h diff --git a/src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.h b/src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.h index a2fccb9..4230f97 100644 --- a/src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.h +++ b/src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.h @@ -2,7 +2,7 @@ #define ANTPLUS_PROFILEFECDISPLAY_h #include -#include +#include #include #include "ANT.h" From 17542ce479865c3d339ec9a2516ce41a8c392e29 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 18 Jan 2021 22:53:14 -0800 Subject: [PATCH 112/241] power: fixup print in example --- examples/BicyclePowerDisplay/BicyclePowerDisplay.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino index d9cb8de..a5578ad 100644 --- a/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino +++ b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino @@ -134,7 +134,7 @@ void bicyclePowerBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data) { } void powerOnlyDataPageHandler(BicyclePowerStandardPowerOnly& msg, uintptr_t data) { - Serial.print("Pedal Balance: "); + Serial.print("Pedal Power: "); Serial.println(msg.getPedalPower()); Serial.print("Instantaneous Cadence: "); Serial.println(msg.getInstantaneousCadence()); From 5440624b0f4003ba410a2c067ddb3072eeb59e8a Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 19 Jan 2021 08:20:30 -0800 Subject: [PATCH 113/241] fec: expand acronym and cleanup Delete an empty file and some unneeded header includes. Expand the acronym since its not very common (took me forever to figure out wha the "C" was for.) --- src/Profiles/ANTPLUS_Profiles.h | 2 +- src/Profiles/FEC/ANTPLUS_FECProfile.h | 14 -------------- .../FEC/DataPages/ANTPLUS_FECFEMainDataPage.cpp | 9 --------- .../FEC/DataPages/ANTPLUS_FECTrainerDataPage.cpp | 0 .../ANTPLUS_FitnessEquipmentControlsDataPages.h} | 2 +- .../ANTPLUS_FitnessEquipmentControlsDefines.h} | 0 ...TPLUS_FitnessEquipmentControlsPrivateDefines.h} | 2 ++ .../ANTPLUS_FitnessEquipmentControlsProfile.h | 14 ++++++++++++++ ...PLUS_FitnessEquipmentControlsFEMainDataPage.cpp | 10 ++++++++++ ...TPLUS_FitnessEquipmentControlsFEMainDataPage.h} | 0 ...itnessEquipmentControlsGeneralMainDataPage.cpp} | 4 ++-- ..._FitnessEquipmentControlsGeneralMainDataPage.h} | 0 ...NTPLUS_FitnessEquipmentControlsTrainerData.cpp} | 4 ++-- .../ANTPLUS_FitnessEquipmentControlsTrainerData.h} | 0 ...LUS_FitnessEquipmentControlsProfileDisplay.cpp} | 5 ++--- ...TPLUS_FitnessEquipmentControlsProfileDisplay.h} | 4 +--- 16 files changed, 35 insertions(+), 35 deletions(-) delete mode 100644 src/Profiles/FEC/ANTPLUS_FECProfile.h delete mode 100644 src/Profiles/FEC/DataPages/ANTPLUS_FECFEMainDataPage.cpp delete mode 100644 src/Profiles/FEC/DataPages/ANTPLUS_FECTrainerDataPage.cpp rename src/Profiles/{FEC/ANTPLUS_ProfileFECDataPages.h => FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsDataPages.h} (52%) rename src/Profiles/{FEC/ANTPLUS_FECDefines.h => FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsDefines.h} (100%) rename src/Profiles/{FEC/ANTPLUS_FECPrivateDefines.h => FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsPrivateDefines.h} (93%) create mode 100644 src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsProfile.h create mode 100644 src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsFEMainDataPage.cpp rename src/Profiles/{FEC/DataPages/ANTPLUS_FECFEMainDataPage.h => FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsFEMainDataPage.h} (100%) rename src/Profiles/{FEC/DataPages/ANTPLUS_FECGeneralMainDataPage.cpp => FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsGeneralMainDataPage.cpp} (86%) rename src/Profiles/{FEC/DataPages/ANTPLUS_FECGeneralMainDataPage.h => FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsGeneralMainDataPage.h} (100%) rename src/Profiles/{FEC/DataPages/ANTPLUS_FECTrainerData.cpp => FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsTrainerData.cpp} (88%) rename src/Profiles/{FEC/DataPages/ANTPLUS_FECTrainerData.h => FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsTrainerData.h} (100%) rename src/Profiles/{FEC/Display/ANTPLUS_ProfileFECDisplay.cpp => FitnessEquipmentControls/Display/ANTPLUS_FitnessEquipmentControlsProfileDisplay.cpp} (86%) rename src/Profiles/{FEC/Display/ANTPLUS_ProfileFECDisplay.h => FitnessEquipmentControls/Display/ANTPLUS_FitnessEquipmentControlsProfileDisplay.h} (88%) diff --git a/src/Profiles/ANTPLUS_Profiles.h b/src/Profiles/ANTPLUS_Profiles.h index 2541977..63a5700 100644 --- a/src/Profiles/ANTPLUS_Profiles.h +++ b/src/Profiles/ANTPLUS_Profiles.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/Profiles/FEC/ANTPLUS_FECProfile.h b/src/Profiles/FEC/ANTPLUS_FECProfile.h deleted file mode 100644 index 800587d..0000000 --- a/src/Profiles/FEC/ANTPLUS_FECProfile.h +++ /dev/null @@ -1,14 +0,0 @@ -#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_FECFEMainDataPage.cpp b/src/Profiles/FEC/DataPages/ANTPLUS_FECFEMainDataPage.cpp deleted file mode 100644 index c5e96fe..0000000 --- a/src/Profiles/FEC/DataPages/ANTPLUS_FECFEMainDataPage.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -template -FECFEMainDataPage::FECFEMainDataPage() : - CoreDataPage() {} - -template class FECFEMainDataPage; -template class FECFEMainDataPage; diff --git a/src/Profiles/FEC/DataPages/ANTPLUS_FECTrainerDataPage.cpp b/src/Profiles/FEC/DataPages/ANTPLUS_FECTrainerDataPage.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/Profiles/FEC/ANTPLUS_ProfileFECDataPages.h b/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsDataPages.h similarity index 52% rename from src/Profiles/FEC/ANTPLUS_ProfileFECDataPages.h rename to src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsDataPages.h index dde2148..82659b2 100644 --- a/src/Profiles/FEC/ANTPLUS_ProfileFECDataPages.h +++ b/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsDataPages.h @@ -1,6 +1,6 @@ #ifndef ANTPLUS_PROFILEFECDATAPAGES_h #define ANTPLUS_PROFILEFECDATAPAGES_h -#include +#include #endif // ANTPLUS_PROFILEFECDATAPAGES_h diff --git a/src/Profiles/FEC/ANTPLUS_FECDefines.h b/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsDefines.h similarity index 100% rename from src/Profiles/FEC/ANTPLUS_FECDefines.h rename to src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsDefines.h diff --git a/src/Profiles/FEC/ANTPLUS_FECPrivateDefines.h b/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsPrivateDefines.h similarity index 93% rename from src/Profiles/FEC/ANTPLUS_FECPrivateDefines.h rename to src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsPrivateDefines.h index f70cc10..ace2109 100644 --- a/src/Profiles/FEC/ANTPLUS_FECPrivateDefines.h +++ b/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsPrivateDefines.h @@ -1,6 +1,8 @@ #ifndef ANTPLUS_FECPROFILEPRIVATEDEFINES_h #define ANTPLUS_FECPROFILEPRIVATEDEFINES_h +#include + /* Channel Config */ #define ANTPLUS_FEC_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE #define ANTPLUS_FEC_MONITOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT diff --git a/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsProfile.h b/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsProfile.h new file mode 100644 index 0000000..879cb3f --- /dev/null +++ b/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsProfile.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/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsFEMainDataPage.cpp b/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsFEMainDataPage.cpp new file mode 100644 index 0000000..def2871 --- /dev/null +++ b/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsFEMainDataPage.cpp @@ -0,0 +1,10 @@ +#include +#include + +// TODO update name +template +FECFEMainDataPage::FECFEMainDataPage() : + CoreDataPage() {} + +template class FECFEMainDataPage; +template class FECFEMainDataPage; diff --git a/src/Profiles/FEC/DataPages/ANTPLUS_FECFEMainDataPage.h b/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsFEMainDataPage.h similarity index 100% rename from src/Profiles/FEC/DataPages/ANTPLUS_FECFEMainDataPage.h rename to src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsFEMainDataPage.h diff --git a/src/Profiles/FEC/DataPages/ANTPLUS_FECGeneralMainDataPage.cpp b/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsGeneralMainDataPage.cpp similarity index 86% rename from src/Profiles/FEC/DataPages/ANTPLUS_FECGeneralMainDataPage.cpp rename to src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsGeneralMainDataPage.cpp index a468409..c22d5fc 100644 --- a/src/Profiles/FEC/DataPages/ANTPLUS_FECGeneralMainDataPage.cpp +++ b/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsGeneralMainDataPage.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include template FECGeneralMainDataPage::FECGeneralMainDataPage() : CoreDataPage() { diff --git a/src/Profiles/FEC/DataPages/ANTPLUS_FECGeneralMainDataPage.h b/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsGeneralMainDataPage.h similarity index 100% rename from src/Profiles/FEC/DataPages/ANTPLUS_FECGeneralMainDataPage.h rename to src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsGeneralMainDataPage.h diff --git a/src/Profiles/FEC/DataPages/ANTPLUS_FECTrainerData.cpp b/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsTrainerData.cpp similarity index 88% rename from src/Profiles/FEC/DataPages/ANTPLUS_FECTrainerData.cpp rename to src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsTrainerData.cpp index 484137b..a44fc9d 100644 --- a/src/Profiles/FEC/DataPages/ANTPLUS_FECTrainerData.cpp +++ b/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsTrainerData.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include template FECTrainerDataPage::FECTrainerDataPage() : diff --git a/src/Profiles/FEC/DataPages/ANTPLUS_FECTrainerData.h b/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsTrainerData.h similarity index 100% rename from src/Profiles/FEC/DataPages/ANTPLUS_FECTrainerData.h rename to src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsTrainerData.h diff --git a/src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.cpp b/src/Profiles/FitnessEquipmentControls/Display/ANTPLUS_FitnessEquipmentControlsProfileDisplay.cpp similarity index 86% rename from src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.cpp rename to src/Profiles/FitnessEquipmentControls/Display/ANTPLUS_FitnessEquipmentControlsProfileDisplay.cpp index f2ad990..fac3c8d 100644 --- a/src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.cpp +++ b/src/Profiles/FitnessEquipmentControls/Display/ANTPLUS_FitnessEquipmentControlsProfileDisplay.cpp @@ -1,6 +1,5 @@ -#include -#include -#include +#include +#include ProfileFECDisplay::ProfileFECDisplay() : BaseSlaveProfile() { setChannelConfig(); diff --git a/src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.h b/src/Profiles/FitnessEquipmentControls/Display/ANTPLUS_FitnessEquipmentControlsProfileDisplay.h similarity index 88% rename from src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.h rename to src/Profiles/FitnessEquipmentControls/Display/ANTPLUS_FitnessEquipmentControlsProfileDisplay.h index 4230f97..2a38e61 100644 --- a/src/Profiles/FEC/Display/ANTPLUS_ProfileFECDisplay.h +++ b/src/Profiles/FitnessEquipmentControls/Display/ANTPLUS_FitnessEquipmentControlsProfileDisplay.h @@ -2,11 +2,9 @@ #define ANTPLUS_PROFILEFECDISPLAY_h #include -#include +#include #include -#include "ANT.h" - class ProfileFECDisplay : public BaseSlaveProfile { public: ProfileFECDisplay(); From 2a93894fdeb0ea55d2a9edfadc24af370ef3f2ab Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Wed, 20 Jan 2021 00:07:43 -0800 Subject: [PATCH 114/241] fec: localize defines step 2 of refactor --- ...S_FitnessEquipmentControlsPrivateDefines.h | 28 ------------ ...FitnessEquipmentControlsFEMainDataPage.cpp | 3 ++ ...ssEquipmentControlsGeneralMainDataPage.cpp | 45 +++++++++++-------- ...US_FitnessEquipmentControlsTrainerData.cpp | 39 ++++++++-------- 4 files changed, 50 insertions(+), 65 deletions(-) diff --git a/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsPrivateDefines.h b/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsPrivateDefines.h index ace2109..43a0858 100644 --- a/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsPrivateDefines.h +++ b/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsPrivateDefines.h @@ -10,34 +10,6 @@ // 30 / 2.5 = 12 #define ANTPLUS_FEC_SEARCHTIMEOUT 12 -/* General Main DataPage */ -#define ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_DATAPAGE_BYTE 0 -#define ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_EQUIPMENT_TYPE_BIT_BYTE 1 -#define ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_ELAPSED_TIME_BYTE 2 -#define ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_DISTANCE_TRAVELED_BYTE 3 -#define ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_SPEED_LSB_BYTE 4 -#define ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_SPEED_MSB_BYTE 5 -#define ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_HEARTRATE_BYTE 6 -#define ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_CAPBILITY_FESTATE_BIT_BYTE 7 - -/* FE Main DataPage */ -#define ANTPLUS_FEC_DATAPAGE_FE_MAIN_DATAPAGE_BYTE 0 -#define ANTPLUS_FEC_DATAPAGE_FE_MAIN_CADENCE_BYTE 4 -#define ANTPLUS_FEC_DATAPAGE_FE_MAIN_NEGTIVE_VERTICAL_DISTANCE_BYTE 5 - -/* Trainer Data DataPage */ -#define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_DATAPAGE_BYTE 0 -#define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_UPDATE_EVENT_COUNT_BYTE 1 -#define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_INSTANTANEOUS_CADENCE_BYTE 2 -#define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_ACCUMULATED_POWER_LSB_BYTE 3 -#define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_ACCUMULATED_POWER_MSB_BYTE 4 -#define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_INSTANTANEOUS_POWER_LSB_BYTE 5 -#define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_INSTANTANEOUS_POWER_MSB_BYTE 6 -#define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_TRAINER_STATUS_BYTE 6 -#define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_FLAGS_FESTATE_BIT_BYTE 7 - -/* Default DataPage */ -#define ANTPLUS_FEC_DATAPAGE_DEFAULT_NUMBER 0 #define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_NUMBER 25 #endif // ANTPLUS_FECPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsFEMainDataPage.cpp b/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsFEMainDataPage.cpp index def2871..6067b97 100644 --- a/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsFEMainDataPage.cpp +++ b/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsFEMainDataPage.cpp @@ -1,6 +1,9 @@ #include #include +#define CADENCE_BYTE 4 +#define NEGTIVE_VERTICAL_DISTANCE_BYTE 5 + // TODO update name template FECFEMainDataPage::FECFEMainDataPage() : diff --git a/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsGeneralMainDataPage.cpp b/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsGeneralMainDataPage.cpp index c22d5fc..4945f12 100644 --- a/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsGeneralMainDataPage.cpp +++ b/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsGeneralMainDataPage.cpp @@ -1,57 +1,64 @@ #include #include +#include + +// TODO this is a mixture of datapages +#define EQUIPMENTTYPEBITS_BYTE 1 +#define ELAPSEDTIME_BYTE 2 +#define DISTANCETRAVELED_BYTE 3 +#define SPEED_LSB_BYTE 4 +#define SPEED_MSB_BYTE 5 +#define HEARTRATE_BYTE 6 +#define CAPABILITIESBITFIELD_BYTE 7 +#define CAPABILITIESBITFIELD_MASK 0x0F +#define FESTATEBITFIELD_BYTE 7 +#define FESTATEBITFIELD_MASK 0xF0 +#define FESTATEBITFIELD_SHIFT 4 template -FECGeneralMainDataPage::FECGeneralMainDataPage() : CoreDataPage() { -} +FECGeneralMainDataPage::FECGeneralMainDataPage() : + CoreDataPage() {} template uint8_t FECGeneralMainDataPage::getDataPageNumber() { - return this->get8BitValue( - ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_DATAPAGE_BYTE); + return this->get8BitValue(ANTPLUS_DEFAULT_DATAPAGE_BYTE); } template uint8_t FECGeneralMainDataPage::getEquipmentTypeBits() { - return this->get8BitValue( - ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_EQUIPMENT_TYPE_BIT_BYTE); + return this->get8BitValue(EQUIPMENTTYPEBITS_BYTE); } template uint8_t FECGeneralMainDataPage::getElapsedTime() { - return this->get8BitValue( - ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_ELAPSED_TIME_BYTE); + return this->get8BitValue(ELAPSEDTIME_BYTE); } template uint8_t FECGeneralMainDataPage::getDistanceTraveled() { - return this->get8BitValue( - ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_DISTANCE_TRAVELED_BYTE); + return this->get8BitValue(DISTANCETRAVELED_BYTE); } template uint8_t FECGeneralMainDataPage::getHeartRate() { - return this->get8BitValue( - ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_HEARTRATE_BYTE); + return this->get8BitValue(HEARTRATE_BYTE); } template uint8_t FECGeneralMainDataPage::getCapabilitiesBits() { - return this->get8BitValue( - ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_CAPBILITY_FESTATE_BIT_BYTE) & 0x0F; + return this->get8BitValue(CAPABILITIESBITFIELD_BYTE, + CAPABILITIESBITFIELD_MASK); } template uint8_t FECGeneralMainDataPage::getFEStateBits() { - return (this->get8BitValue( - ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_CAPBILITY_FESTATE_BIT_BYTE) & 0xF0) >> 4; + return this->get8BitValue(FESTATEBITFIELD_BYTE, FESTATEBITFIELD_MASK, + FESTATEBITFIELD_SHIFT); } template uint16_t FECGeneralMainDataPage::getSpeed() { - return this->get16BitValue( - ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_SPEED_LSB_BYTE, - ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_SPEED_MSB_BYTE); + return this->get16BitValue(SPEED_LSB_BYTE, SPEED_MSB_BYTE); } template class FECGeneralMainDataPage; diff --git a/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsTrainerData.cpp b/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsTrainerData.cpp index a44fc9d..f0b250e 100644 --- a/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsTrainerData.cpp +++ b/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsTrainerData.cpp @@ -1,5 +1,16 @@ #include #include +#include + +// TODO correct names +#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 TRAINERSTATUS_BYTE 6 +#define FLAGSFESTATEBIT_BYTE 7 template FECTrainerDataPage::FECTrainerDataPage() : @@ -7,52 +18,44 @@ FECTrainerDataPage::FECTrainerDataPage() : template uint8_t FECTrainerDataPage::getDataPageNumber() { - return this->get8BitValue( - ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_DATAPAGE_BYTE); + return this->get8BitValue(ANTPLUS_DEFAULT_DATAPAGE_BYTE); } template uint8_t FECTrainerDataPage::getUpdateEventCount() { - return this->get8BitValue( - ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_UPDATE_EVENT_COUNT_BYTE); + return this->get8BitValue(UPDATEEVENTCOUNT_BYTE); } template uint8_t FECTrainerDataPage::getInstantaneousCadence() { - return this->get8BitValue( - ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_INSTANTANEOUS_CADENCE_BYTE); + return this->get8BitValue(INSTANTANEOUSCADENCE_BYTE); } template uint8_t FECTrainerDataPage::getFlagsBits() { - return this->get8BitValue( - ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_FLAGS_FESTATE_BIT_BYTE) & 0x0F; + return this->get8BitValue(FLAGSFESTATEBIT_BYTE) & 0x0F; } template uint8_t FECTrainerDataPage::getFEStateBits() { - return (this->get8BitValue( - ANTPLUS_FEC_DATAPAGE_GENERAL_MAIN_CAPBILITY_FESTATE_BIT_BYTE) & 0xF0) >> 4; + return (this->get8BitValue(FLAGSFESTATEBIT_BYTE) & 0xF0) >> 4; } template uint16_t FECTrainerDataPage::getAccumulatedPower() { - return this->get16BitValue( - ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_ACCUMULATED_POWER_LSB_BYTE, - ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_ACCUMULATED_POWER_MSB_BYTE); + return this->get16BitValue(ACCUMULATEDPOWER_LSB_BYTE, + ACCUMULATEDPOWER_MSB_BYTE); } template uint16_t FECTrainerDataPage::getInstantaneousPower() { - return this->get16BitValue( - ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_INSTANTANEOUS_POWER_LSB_BYTE, - ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_INSTANTANEOUS_POWER_MSB_BYTE) & 0x0FFF; + return this->get16BitValue(INSTANTANEOUSPOWER_LSB_BYTE, + INSTANTANEOUSPOWER_MSB_BYTE) & 0x0FFF; } template uint8_t FECTrainerDataPage::getTrainerStatusBits() { - return (this->get8BitValue( - ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_TRAINER_STATUS_BYTE) & 0xF0) >> 4; + return (this->get8BitValue(TRAINERSTATUS_BYTE) & 0xF0) >> 4; } template class FECTrainerDataPage; From 4cf8c79c3de3ead0dbe6c82e854c6e643382becb Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Wed, 20 Jan 2021 21:17:51 -0800 Subject: [PATCH 115/241] FEC: anonymize profile directory step 3 of refactor --- .../ANTPLUS_FitnessEquipmentControlsProfile.h | 2 +- .../ANTPLUS_FitnessEquipmentControlsProfileDisplay.cpp | 2 +- .../ANTPLUS_FitnessEquipmentControlsProfileDisplay.h | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename src/Profiles/FitnessEquipmentControls/{Display => Profiles}/ANTPLUS_FitnessEquipmentControlsProfileDisplay.cpp (91%) rename src/Profiles/FitnessEquipmentControls/{Display => Profiles}/ANTPLUS_FitnessEquipmentControlsProfileDisplay.h (100%) diff --git a/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsProfile.h b/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsProfile.h index 879cb3f..57e4845 100644 --- a/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsProfile.h +++ b/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsProfile.h @@ -8,7 +8,7 @@ #include // Profile Classes -#include +#include // #include #endif // ANTPLUS_FECPROFILE_h diff --git a/src/Profiles/FitnessEquipmentControls/Display/ANTPLUS_FitnessEquipmentControlsProfileDisplay.cpp b/src/Profiles/FitnessEquipmentControls/Profiles/ANTPLUS_FitnessEquipmentControlsProfileDisplay.cpp similarity index 91% rename from src/Profiles/FitnessEquipmentControls/Display/ANTPLUS_FitnessEquipmentControlsProfileDisplay.cpp rename to src/Profiles/FitnessEquipmentControls/Profiles/ANTPLUS_FitnessEquipmentControlsProfileDisplay.cpp index fac3c8d..dd5ead6 100644 --- a/src/Profiles/FitnessEquipmentControls/Display/ANTPLUS_FitnessEquipmentControlsProfileDisplay.cpp +++ b/src/Profiles/FitnessEquipmentControls/Profiles/ANTPLUS_FitnessEquipmentControlsProfileDisplay.cpp @@ -1,4 +1,4 @@ -#include +#include #include ProfileFECDisplay::ProfileFECDisplay() : BaseSlaveProfile() { diff --git a/src/Profiles/FitnessEquipmentControls/Display/ANTPLUS_FitnessEquipmentControlsProfileDisplay.h b/src/Profiles/FitnessEquipmentControls/Profiles/ANTPLUS_FitnessEquipmentControlsProfileDisplay.h similarity index 100% rename from src/Profiles/FitnessEquipmentControls/Display/ANTPLUS_FitnessEquipmentControlsProfileDisplay.h rename to src/Profiles/FitnessEquipmentControls/Profiles/ANTPLUS_FitnessEquipmentControlsProfileDisplay.h From 9da936b6cff0c037f553bfb10a499d72370c4479 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Wed, 20 Jan 2021 21:50:02 -0800 Subject: [PATCH 116/241] LEV: consolidate datapages Not much to do here since LEV has not migrated to core datapages yet. --- src/Profiles/Lev/ANTPLUS_LevProfile.h | 2 +- src/Profiles/Lev/ANTPLUS_ProfileLevDataPages.h | 12 ++++++++++++ .../ANTPLUS_LevAltSpeedDistanceInformation.cpp | 6 +++--- .../ANTPLUS_LevAltSpeedDistanceInformation.h | 2 +- .../Lev/DataPages/ANTPLUS_LevBaseMainDataPage.cpp | 11 +++++++++++ .../{Base => }/ANTPLUS_LevBaseMainDataPage.h | 10 ++++++++-- .../ANTPLUS_LevBaseSpeedDistanceInformation.cpp | 6 +++--- .../ANTPLUS_LevBaseSpeedDistanceInformation.h | 2 +- .../ANTPLUS_LevBaseSpeedSystemInformation.cpp | 6 +++--- .../ANTPLUS_LevBaseSpeedSystemInformation.h | 2 +- .../{RX => }/ANTPLUS_LevBatteryInformation.cpp | 6 +++--- .../{RX => }/ANTPLUS_LevBatteryInformation.h | 2 +- .../{RX => }/ANTPLUS_LevCapabilities.cpp | 6 +++--- .../DataPages/{RX => }/ANTPLUS_LevCapabilities.h | 2 +- ...playDataMsg.cpp => ANTPLUS_LevDisplayData.cpp} | 2 +- ...vDisplayDataMsg.h => ANTPLUS_LevDisplayData.h} | 2 +- .../ANTPLUS_LevSpeedDistanceInformation.cpp | 6 +++--- .../ANTPLUS_LevSpeedDistanceInformation.h | 2 +- .../ANTPLUS_LevSpeedSystemInformation1.cpp | 6 +++--- .../{RX => }/ANTPLUS_LevSpeedSystemInformation1.h | 2 +- .../ANTPLUS_LevSpeedSystemInformation2.cpp | 6 +++--- .../{RX => }/ANTPLUS_LevSpeedSystemInformation2.h | 2 +- .../Lev/DataPages/ANTPLUS_ProfileLevDataPages.h | 15 --------------- .../Base/ANTPLUS_LevBaseMainDataPage.cpp | 5 ----- .../Base/ANTPLUS_LevBaseMainDataPageMsg.cpp | 8 -------- .../Base/ANTPLUS_LevBaseMainDataPageMsg.h | 15 --------------- .../Lev/Display/ANTPLUS_ProfileLevDisplay.h | 4 +--- 27 files changed, 67 insertions(+), 83 deletions(-) create mode 100644 src/Profiles/Lev/ANTPLUS_ProfileLevDataPages.h rename src/Profiles/Lev/DataPages/{RX => }/ANTPLUS_LevAltSpeedDistanceInformation.cpp (80%) rename src/Profiles/Lev/DataPages/{RX => }/ANTPLUS_LevAltSpeedDistanceInformation.h (81%) create mode 100644 src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.cpp rename src/Profiles/Lev/DataPages/{Base => }/ANTPLUS_LevBaseMainDataPage.h (55%) rename src/Profiles/Lev/DataPages/{Base => }/ANTPLUS_LevBaseSpeedDistanceInformation.cpp (88%) rename src/Profiles/Lev/DataPages/{Base => }/ANTPLUS_LevBaseSpeedDistanceInformation.h (84%) rename src/Profiles/Lev/DataPages/{Base => }/ANTPLUS_LevBaseSpeedSystemInformation.cpp (94%) rename src/Profiles/Lev/DataPages/{Base => }/ANTPLUS_LevBaseSpeedSystemInformation.h (89%) rename src/Profiles/Lev/DataPages/{RX => }/ANTPLUS_LevBatteryInformation.cpp (92%) rename src/Profiles/Lev/DataPages/{RX => }/ANTPLUS_LevBatteryInformation.h (85%) rename src/Profiles/Lev/DataPages/{RX => }/ANTPLUS_LevCapabilities.cpp (86%) rename src/Profiles/Lev/DataPages/{RX => }/ANTPLUS_LevCapabilities.h (83%) rename src/Profiles/Lev/DataPages/{TX/ANTPLUS_LevDisplayDataMsg.cpp => ANTPLUS_LevDisplayData.cpp} (98%) rename src/Profiles/Lev/DataPages/{TX/ANTPLUS_LevDisplayDataMsg.h => ANTPLUS_LevDisplayData.h} (92%) rename src/Profiles/Lev/DataPages/{RX => }/ANTPLUS_LevSpeedDistanceInformation.cpp (80%) rename src/Profiles/Lev/DataPages/{RX => }/ANTPLUS_LevSpeedDistanceInformation.h (80%) rename src/Profiles/Lev/DataPages/{RX => }/ANTPLUS_LevSpeedSystemInformation1.cpp (92%) rename src/Profiles/Lev/DataPages/{RX => }/ANTPLUS_LevSpeedSystemInformation1.h (85%) rename src/Profiles/Lev/DataPages/{RX => }/ANTPLUS_LevSpeedSystemInformation2.cpp (85%) rename src/Profiles/Lev/DataPages/{RX => }/ANTPLUS_LevSpeedSystemInformation2.h (83%) delete mode 100644 src/Profiles/Lev/DataPages/ANTPLUS_ProfileLevDataPages.h delete mode 100644 src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPage.cpp delete mode 100644 src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPageMsg.cpp delete mode 100644 src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPageMsg.h diff --git a/src/Profiles/Lev/ANTPLUS_LevProfile.h b/src/Profiles/Lev/ANTPLUS_LevProfile.h index 7da71fc..4477fdd 100644 --- a/src/Profiles/Lev/ANTPLUS_LevProfile.h +++ b/src/Profiles/Lev/ANTPLUS_LevProfile.h @@ -5,7 +5,7 @@ #include // Datapages -#include +#include // Profile Classes #include diff --git a/src/Profiles/Lev/ANTPLUS_ProfileLevDataPages.h b/src/Profiles/Lev/ANTPLUS_ProfileLevDataPages.h new file mode 100644 index 0000000..055fe99 --- /dev/null +++ b/src/Profiles/Lev/ANTPLUS_ProfileLevDataPages.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/DataPages/RX/ANTPLUS_LevAltSpeedDistanceInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.cpp similarity index 80% rename from src/Profiles/Lev/DataPages/RX/ANTPLUS_LevAltSpeedDistanceInformation.cpp rename to src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.cpp index 962dac0..5284055 100644 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevAltSpeedDistanceInformation.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.cpp @@ -1,9 +1,9 @@ -#include +#include #include /* Alt Speed and Distance */ -LevAltSpeedDistanceInformation::LevAltSpeedDistanceInformation(AntRxDataResponse& dp) : LevBaseSpeedDistanceInformation(dp) { -} +LevAltSpeedDistanceInformation::LevAltSpeedDistanceInformation(AntRxDataResponse& dp) : + LevBaseSpeedDistanceInformation(dp) {} uint16_t LevAltSpeedDistanceInformation::getFuelConsumption() // in Wh/km { diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevAltSpeedDistanceInformation.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.h similarity index 81% rename from src/Profiles/Lev/DataPages/RX/ANTPLUS_LevAltSpeedDistanceInformation.h rename to src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.h index e01f1df..050542c 100644 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevAltSpeedDistanceInformation.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.h @@ -1,7 +1,7 @@ #ifndef ANTPLUS_LEVALTSPEEDDISTANCEINFORMATION_h #define ANTPLUS_LEVALTSPEEDDISTANCEINFORMATION_h -#include +#include class LevAltSpeedDistanceInformation : public LevBaseSpeedDistanceInformation { public: diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.cpp new file mode 100644 index 0000000..d16466e --- /dev/null +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.cpp @@ -0,0 +1,11 @@ +#include +#include + +LevBaseMainDataPage::LevBaseMainDataPage(AntRxDataResponse& dp) : + BaseDataPage(dp) {} + +LevBaseMainDataPageMsg::LevBaseMainDataPageMsg(uint8_t dataPageNumber) : + BaseDataPageMsg() { + setDataBuffer(_buffer); + _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = dataPageNumber; +} diff --git a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPage.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.h similarity index 55% rename from src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPage.h rename to src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.h index e76d7ed..ef1b401 100644 --- a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseMainDataPage.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.h @@ -2,12 +2,18 @@ #define ANTPLUS_LEVBASEMAINDATAPAGE_h #include - -#include "ANT.h" +#include class LevBaseMainDataPage : public BaseDataPage { public: explicit LevBaseMainDataPage(AntRxDataResponse& dp); }; +class LevBaseMainDataPageMsg : public BaseDataPageMsg { +public: + explicit LevBaseMainDataPageMsg(uint8_t dataPageNumber); +protected: + uint8_t _buffer[MESSAGE_SIZE]; +}; + #endif // ANTPLUS_LEVBASEMAINDATAPAGE_h diff --git a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedDistanceInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.cpp similarity index 88% rename from src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedDistanceInformation.cpp rename to src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.cpp index fc1372d..1fa6790 100644 --- a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedDistanceInformation.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.cpp @@ -1,9 +1,9 @@ -#include +#include #include /* Speed and Distance */ -LevBaseSpeedDistanceInformation::LevBaseSpeedDistanceInformation(AntRxDataResponse& dp) : LevBaseMainDataPage(dp) { -} +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); diff --git a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedDistanceInformation.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.h similarity index 84% rename from src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedDistanceInformation.h rename to src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.h index 1529a43..5877ed0 100644 --- a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedDistanceInformation.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.h @@ -1,7 +1,7 @@ #ifndef ANTPLUS_LEVBASESPEEDDISTANCEINFORMATION_h #define ANTPLUS_LEVBASESPEEDDISTANCEINFORMATION_h -#include +#include class LevBaseSpeedDistanceInformation : public LevBaseMainDataPage { public: diff --git a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedSystemInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedSystemInformation.cpp similarity index 94% rename from src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedSystemInformation.cpp rename to src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedSystemInformation.cpp index 1007328..172493f 100644 --- a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedSystemInformation.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedSystemInformation.cpp @@ -1,8 +1,8 @@ -#include +#include #include -LevBaseSpeedSystemInformation::LevBaseSpeedSystemInformation(AntRxDataResponse& dp) : LevBaseMainDataPage(dp) { -} +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; diff --git a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedSystemInformation.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedSystemInformation.h similarity index 89% rename from src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedSystemInformation.h rename to src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedSystemInformation.h index 73bda52..56c911f 100644 --- a/src/Profiles/Lev/DataPages/Base/ANTPLUS_LevBaseSpeedSystemInformation.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedSystemInformation.h @@ -1,7 +1,7 @@ #ifndef ANTPLUS_LEVBASESPEEDSYSTEMINFORMATION_h #define ANTPLUS_LEVBASESPEEDSYSTEMINFORMATION_h -#include +#include class LevBaseSpeedSystemInformation : public LevBaseMainDataPage { public: diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevBatteryInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.cpp similarity index 92% rename from src/Profiles/Lev/DataPages/RX/ANTPLUS_LevBatteryInformation.cpp rename to src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.cpp index 4814d8b..f6b6fb6 100644 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevBatteryInformation.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.cpp @@ -1,8 +1,8 @@ -#include +#include #include -LevBatteryInformation::LevBatteryInformation(AntRxDataResponse& dp) : LevBaseMainDataPage(dp) { -} +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); diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevBatteryInformation.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.h similarity index 85% rename from src/Profiles/Lev/DataPages/RX/ANTPLUS_LevBatteryInformation.h rename to src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.h index 86f75de..09a9a5e 100644 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevBatteryInformation.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.h @@ -1,7 +1,7 @@ #ifndef ANTPLUS_LEVBATTERYINFORMATION_h #define ANTPLUS_LEVBATTERYINFORMATION_h -#include +#include class LevBatteryInformation : public LevBaseMainDataPage { public: diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevCapabilities.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.cpp similarity index 86% rename from src/Profiles/Lev/DataPages/RX/ANTPLUS_LevCapabilities.cpp rename to src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.cpp index b759e93..a4f3d30 100644 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevCapabilities.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.cpp @@ -1,8 +1,8 @@ -#include +#include #include -LevCapabilities::LevCapabilities(AntRxDataResponse& dp) : LevBaseMainDataPage(dp) { -} +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; diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevCapabilities.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.h similarity index 83% rename from src/Profiles/Lev/DataPages/RX/ANTPLUS_LevCapabilities.h rename to src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.h index 19adecd..c7bbef5 100644 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevCapabilities.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.h @@ -1,7 +1,7 @@ #ifndef ANTPLUS_LEVCAPABILITIES_h #define ANTPLUS_LEVCAPABILITIES_h -#include +#include class LevCapabilities : public LevBaseMainDataPage { public: diff --git a/src/Profiles/Lev/DataPages/TX/ANTPLUS_LevDisplayDataMsg.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.cpp similarity index 98% rename from src/Profiles/Lev/DataPages/TX/ANTPLUS_LevDisplayDataMsg.cpp rename to src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.cpp index b5f8efd..b996def 100644 --- a/src/Profiles/Lev/DataPages/TX/ANTPLUS_LevDisplayDataMsg.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.cpp @@ -1,4 +1,4 @@ -#include +#include #include LevDisplayDataMsg::LevDisplayDataMsg() : LevBaseMainDataPageMsg(ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_NUMBER) { diff --git a/src/Profiles/Lev/DataPages/TX/ANTPLUS_LevDisplayDataMsg.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.h similarity index 92% rename from src/Profiles/Lev/DataPages/TX/ANTPLUS_LevDisplayDataMsg.h rename to src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.h index 67c165b..e667867 100644 --- a/src/Profiles/Lev/DataPages/TX/ANTPLUS_LevDisplayDataMsg.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.h @@ -1,7 +1,7 @@ #ifndef ANTPLUS_LEVDISPLAYDATAMSG_h #define ANTPLUS_LEVDISPLAYDATAMSG_h -#include +#include class LevDisplayDataMsg : public LevBaseMainDataPageMsg { public: diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedDistanceInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.cpp similarity index 80% rename from src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedDistanceInformation.cpp rename to src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.cpp index 9926254..d4d3760 100644 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedDistanceInformation.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.cpp @@ -1,9 +1,9 @@ -#include +#include #include /* Speed and Distance */ -LevSpeedDistanceInformation::LevSpeedDistanceInformation(AntRxDataResponse& dp) : LevBaseSpeedDistanceInformation(dp) { -} +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/ANTPLUS_LevSpeedDistanceInformation.h similarity index 80% rename from src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedDistanceInformation.h rename to src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.h index e98498b..d67315c 100644 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedDistanceInformation.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.h @@ -1,7 +1,7 @@ #ifndef ANTPLUS_LEVSPEEDDISTANCEINFORMATION_h #define ANTPLUS_LEVSPEEDDISTANCEINFORMATION_h -#include +#include class LevSpeedDistanceInformation : public LevBaseSpeedDistanceInformation { public: diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation1.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.cpp similarity index 92% rename from src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation1.cpp rename to src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.cpp index 1171382..fcd41a5 100644 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation1.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.cpp @@ -1,8 +1,8 @@ -#include +#include #include -LevSpeedSystemInformation1::LevSpeedSystemInformation1(AntRxDataResponse& dp) : LevBaseSpeedSystemInformation(dp) { -} +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; diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation1.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.h similarity index 85% rename from src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation1.h rename to src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.h index e12ddaa..147ee33 100644 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation1.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.h @@ -1,7 +1,7 @@ #ifndef ANTPLUS_LEVSPEEDSYSTEMINFORMATION1_h #define ANTPLUS_LEVSPEEDSYSTEMINFORMATION1_h -#include +#include class LevSpeedSystemInformation1 : public LevBaseSpeedSystemInformation { public: diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation2.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.cpp similarity index 85% rename from src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation2.cpp rename to src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.cpp index b985fac..b2b2f49 100644 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation2.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.cpp @@ -1,8 +1,8 @@ -#include +#include #include -LevSpeedSystemInformation2::LevSpeedSystemInformation2(AntRxDataResponse& dp) : LevBaseSpeedSystemInformation(dp) { -} +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; diff --git a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation2.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.h similarity index 83% rename from src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation2.h rename to src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.h index 9c15c6a..cd3a262 100644 --- a/src/Profiles/Lev/DataPages/RX/ANTPLUS_LevSpeedSystemInformation2.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.h @@ -1,7 +1,7 @@ #ifndef ANTPLUS_LEVSPEEDSYSTEMINFORMATION2_h #define ANTPLUS_LEVSPEEDSYSTEMINFORMATION2_h -#include +#include class LevSpeedSystemInformation2 : public LevBaseSpeedSystemInformation { public: 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_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 35590e8..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: - explicit LevBaseMainDataPageMsg(uint8_t dataPageNumber); -protected: - uint8_t _buffer[MESSAGE_SIZE]; -}; - -#endif // ANTPLUS_LEVBASEMAINDATAPAGEMSG_h diff --git a/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.h b/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.h index 2b5b74b..3d99264 100644 --- a/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.h +++ b/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.h @@ -2,11 +2,9 @@ #define ANTPLUS_PROFILELEVDISPLAY_h #include -#include +#include #include -#include "ANT.h" - class ProfileLevDisplay : public BaseSlaveProfile { public: ProfileLevDisplay(); From 4e708bc4717836af9124ac2a72ec94bc5c8a8c71 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 21 Jan 2021 00:11:31 -0800 Subject: [PATCH 117/241] fec: undo name expansion, its too long but still change to camel case --- src/Profiles/ANTPLUS_Profiles.h | 2 +- .../ANTPLUS_FecDataPages.h} | 2 +- .../ANTPLUS_FecDefines.h} | 0 .../ANTPLUS_FecPrivateDefines.h} | 2 +- src/Profiles/Fec/ANTPLUS_FecProfile.h | 14 +++++++++ .../DataPages/ANTPLUS_FecFEMainDataPage.cpp} | 4 +-- .../DataPages/ANTPLUS_FecFEMainDataPage.h} | 0 .../ANTPLUS_FecGeneralMainDataPage.cpp} | 4 +-- .../ANTPLUS_FecGeneralMainDataPage.h} | 0 .../ANTPLUS_FecSpecificTrainerData.cpp} | 30 +++++++++---------- .../ANTPLUS_FecSpecificTrainerData.h} | 8 ++--- .../Profiles/ANTPLUS_FecProfileDisplay.cpp} | 24 +++++++-------- .../Profiles/ANTPLUS_FecProfileDisplay.h} | 14 ++++----- .../ANTPLUS_FitnessEquipmentControlsProfile.h | 14 --------- 14 files changed, 59 insertions(+), 59 deletions(-) rename src/Profiles/{FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsDataPages.h => Fec/ANTPLUS_FecDataPages.h} (52%) rename src/Profiles/{FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsDefines.h => Fec/ANTPLUS_FecDefines.h} (100%) rename src/Profiles/{FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsPrivateDefines.h => Fec/ANTPLUS_FecPrivateDefines.h} (81%) create mode 100644 src/Profiles/Fec/ANTPLUS_FecProfile.h rename src/Profiles/{FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsFEMainDataPage.cpp => Fec/DataPages/ANTPLUS_FecFEMainDataPage.cpp} (56%) rename src/Profiles/{FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsFEMainDataPage.h => Fec/DataPages/ANTPLUS_FecFEMainDataPage.h} (100%) rename src/Profiles/{FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsGeneralMainDataPage.cpp => Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp} (86%) rename src/Profiles/{FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsGeneralMainDataPage.h => Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.h} (100%) rename src/Profiles/{FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsTrainerData.cpp => Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp} (54%) rename src/Profiles/{FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsTrainerData.h => Fec/DataPages/ANTPLUS_FecSpecificTrainerData.h} (60%) rename src/Profiles/{FitnessEquipmentControls/Profiles/ANTPLUS_FitnessEquipmentControlsProfileDisplay.cpp => Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp} (55%) rename src/Profiles/{FitnessEquipmentControls/Profiles/ANTPLUS_FitnessEquipmentControlsProfileDisplay.h => Fec/Profiles/ANTPLUS_FecProfileDisplay.h} (50%) delete mode 100644 src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsProfile.h diff --git a/src/Profiles/ANTPLUS_Profiles.h b/src/Profiles/ANTPLUS_Profiles.h index 63a5700..2d08126 100644 --- a/src/Profiles/ANTPLUS_Profiles.h +++ b/src/Profiles/ANTPLUS_Profiles.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsDataPages.h b/src/Profiles/Fec/ANTPLUS_FecDataPages.h similarity index 52% rename from src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsDataPages.h rename to src/Profiles/Fec/ANTPLUS_FecDataPages.h index 82659b2..3b10475 100644 --- a/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsDataPages.h +++ b/src/Profiles/Fec/ANTPLUS_FecDataPages.h @@ -1,6 +1,6 @@ #ifndef ANTPLUS_PROFILEFECDATAPAGES_h #define ANTPLUS_PROFILEFECDATAPAGES_h -#include +#include #endif // ANTPLUS_PROFILEFECDATAPAGES_h diff --git a/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsDefines.h b/src/Profiles/Fec/ANTPLUS_FecDefines.h similarity index 100% rename from src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsDefines.h rename to src/Profiles/Fec/ANTPLUS_FecDefines.h diff --git a/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsPrivateDefines.h b/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h similarity index 81% rename from src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsPrivateDefines.h rename to src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h index 43a0858..1dbe7c7 100644 --- a/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsPrivateDefines.h +++ b/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h @@ -1,7 +1,7 @@ #ifndef ANTPLUS_FECPROFILEPRIVATEDEFINES_h #define ANTPLUS_FECPROFILEPRIVATEDEFINES_h -#include +#include /* Channel Config */ #define ANTPLUS_FEC_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE diff --git a/src/Profiles/Fec/ANTPLUS_FecProfile.h b/src/Profiles/Fec/ANTPLUS_FecProfile.h new file mode 100644 index 0000000..3dab049 --- /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/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsFEMainDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecFEMainDataPage.cpp similarity index 56% rename from src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsFEMainDataPage.cpp rename to src/Profiles/Fec/DataPages/ANTPLUS_FecFEMainDataPage.cpp index 6067b97..64dd7ec 100644 --- a/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsFEMainDataPage.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecFEMainDataPage.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #define CADENCE_BYTE 4 #define NEGTIVE_VERTICAL_DISTANCE_BYTE 5 diff --git a/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsFEMainDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecFEMainDataPage.h similarity index 100% rename from src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsFEMainDataPage.h rename to src/Profiles/Fec/DataPages/ANTPLUS_FecFEMainDataPage.h diff --git a/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsGeneralMainDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp similarity index 86% rename from src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsGeneralMainDataPage.cpp rename to src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp index 4945f12..9bead91 100644 --- a/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsGeneralMainDataPage.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include // TODO this is a mixture of datapages diff --git a/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsGeneralMainDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.h similarity index 100% rename from src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsGeneralMainDataPage.h rename to src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.h diff --git a/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsTrainerData.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp similarity index 54% rename from src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsTrainerData.cpp rename to src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp index f0b250e..aa12307 100644 --- a/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsTrainerData.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include // TODO correct names @@ -13,54 +13,54 @@ #define FLAGSFESTATEBIT_BYTE 7 template -FECTrainerDataPage::FECTrainerDataPage() : +FecBaseSpecificTrainerData::FecBaseSpecificTrainerData() : CoreDataPage() {} template -uint8_t FECTrainerDataPage::getDataPageNumber() { +uint8_t FecBaseSpecificTrainerData::getDataPageNumber() { return this->get8BitValue(ANTPLUS_DEFAULT_DATAPAGE_BYTE); } template -uint8_t FECTrainerDataPage::getUpdateEventCount() { +uint8_t FecBaseSpecificTrainerData::getUpdateEventCount() { return this->get8BitValue(UPDATEEVENTCOUNT_BYTE); } template -uint8_t FECTrainerDataPage::getInstantaneousCadence() { +uint8_t FecBaseSpecificTrainerData::getInstantaneousCadence() { return this->get8BitValue(INSTANTANEOUSCADENCE_BYTE); } template -uint8_t FECTrainerDataPage::getFlagsBits() { +uint8_t FecBaseSpecificTrainerData::getFlagsBits() { return this->get8BitValue(FLAGSFESTATEBIT_BYTE) & 0x0F; } template -uint8_t FECTrainerDataPage::getFEStateBits() { +uint8_t FecBaseSpecificTrainerData::getFEStateBits() { return (this->get8BitValue(FLAGSFESTATEBIT_BYTE) & 0xF0) >> 4; } template -uint16_t FECTrainerDataPage::getAccumulatedPower() { +uint16_t FecBaseSpecificTrainerData::getAccumulatedPower() { return this->get16BitValue(ACCUMULATEDPOWER_LSB_BYTE, ACCUMULATEDPOWER_MSB_BYTE); } template -uint16_t FECTrainerDataPage::getInstantaneousPower() { +uint16_t FecBaseSpecificTrainerData::getInstantaneousPower() { return this->get16BitValue(INSTANTANEOUSPOWER_LSB_BYTE, INSTANTANEOUSPOWER_MSB_BYTE) & 0x0FFF; } template -uint8_t FECTrainerDataPage::getTrainerStatusBits() { +uint8_t FecBaseSpecificTrainerData::getTrainerStatusBits() { return (this->get8BitValue(TRAINERSTATUS_BYTE) & 0xF0) >> 4; } -template class FECTrainerDataPage; -template class FECTrainerDataPage; +template class FecBaseSpecificTrainerData; +template class FecBaseSpecificTrainerData; -FECTrainerData::FECTrainerData(AntRxDataResponse& dp) : +FecSpecificTrainerData::FecSpecificTrainerData(AntRxDataResponse& dp) : BaseDataPage(dp), - FECTrainerDataPage() {} + FecBaseSpecificTrainerData() {} diff --git a/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsTrainerData.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.h similarity index 60% rename from src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsTrainerData.h rename to src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.h index 62332d6..a7e863e 100644 --- a/src/Profiles/FitnessEquipmentControls/DataPages/ANTPLUS_FitnessEquipmentControlsTrainerData.h +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.h @@ -4,9 +4,9 @@ #include template -class FECTrainerDataPage : virtual public CoreDataPage { +class FecBaseSpecificTrainerData : virtual public CoreDataPage { public: - FECTrainerDataPage(); + FecBaseSpecificTrainerData(); uint8_t getDataPageNumber(); uint8_t getUpdateEventCount(); uint8_t getInstantaneousCadence(); @@ -17,9 +17,9 @@ class FECTrainerDataPage : virtual public CoreDataPage { uint8_t getFEStateBits(); }; -class FECTrainerData : public BaseDataPage, public FECTrainerDataPage { +class FecSpecificTrainerData : public BaseDataPage, public FecBaseSpecificTrainerData { public: - explicit FECTrainerData(AntRxDataResponse& dp); + explicit FecSpecificTrainerData(AntRxDataResponse& dp); }; #endif // ANTPLUS_FECTRAINERDATA_h diff --git a/src/Profiles/FitnessEquipmentControls/Profiles/ANTPLUS_FitnessEquipmentControlsProfileDisplay.cpp b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp similarity index 55% rename from src/Profiles/FitnessEquipmentControls/Profiles/ANTPLUS_FitnessEquipmentControlsProfileDisplay.cpp rename to src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp index dd5ead6..16c0fd2 100644 --- a/src/Profiles/FitnessEquipmentControls/Profiles/ANTPLUS_FitnessEquipmentControlsProfileDisplay.cpp +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp @@ -1,19 +1,19 @@ -#include -#include +#include +#include -ProfileFECDisplay::ProfileFECDisplay() : BaseSlaveProfile() { +ProfileFecDisplay::ProfileFecDisplay() : BaseSlaveProfile() { setChannelConfig(); } -ProfileFECDisplay::ProfileFECDisplay(uint16_t deviceNumber) : BaseSlaveProfile(deviceNumber) { +ProfileFecDisplay::ProfileFecDisplay(uint16_t deviceNumber) : BaseSlaveProfile(deviceNumber) { setChannelConfig(); } -ProfileFECDisplay::ProfileFECDisplay(uint16_t deviceNumber, uint8_t transmissionType) : BaseSlaveProfile(deviceNumber, transmissionType) { +ProfileFecDisplay::ProfileFecDisplay(uint16_t deviceNumber, uint8_t transmissionType) : BaseSlaveProfile(deviceNumber, transmissionType) { setChannelConfig(); } -void ProfileFECDisplay::onBroadcastData(BroadcastData& msg) { +void ProfileFecDisplay::onBroadcastData(BroadcastData& msg) { BaseDataPage dp = BaseDataPage(msg); BaseSlaveProfile::onBroadcastData(msg); if (!handleDataPage(dp)) { @@ -21,7 +21,7 @@ void ProfileFECDisplay::onBroadcastData(BroadcastData& msg) { } } -bool ProfileFECDisplay::handleDataPage(BaseDataPage& dp) { +bool ProfileFecDisplay::handleDataPage(BaseDataPage& dp) { uint8_t dataPage = dp.getDataPageNumber(); bool called = false; @@ -34,7 +34,7 @@ bool ProfileFECDisplay::handleDataPage(BaseDataPage& dp) { return called; } -void ProfileFECDisplay::onAcknowledgedData(AcknowledgedData& msg) { +void ProfileFecDisplay::onAcknowledgedData(AcknowledgedData& msg) { BaseDataPage dp = BaseDataPage(msg); BaseSlaveProfile::onAcknowledgedData(msg); if (!handleDataPage(dp)) { @@ -43,14 +43,14 @@ void ProfileFECDisplay::onAcknowledgedData(AcknowledgedData& msg) { } -void ProfileFECDisplay::setChannelConfig() { +void ProfileFecDisplay::setChannelConfig() { setChannelType(ANTPLUS_FEC_DISPLAY_CHANNELTYPE); setDeviceType(ANTPLUS_FEC_DEVICETYPE); setChannelPeriod(ANTPLUS_FEC_CHANNELPERIOD); setSearchTimeout(ANTPLUS_FEC_SEARCHTIMEOUT); } -bool ProfileFECDisplay::handleTrainerData(BaseDataPage& dataPage) { - FECTrainerData dp = FECTrainerData(dataPage); - return _onFECTrainerData.call(dp); +bool ProfileFecDisplay::handleTrainerData(BaseDataPage& dataPage) { + FecSpecificTrainerData dp(dataPage); + return _onFecSpecificTrainerData.call(dp); } diff --git a/src/Profiles/FitnessEquipmentControls/Profiles/ANTPLUS_FitnessEquipmentControlsProfileDisplay.h b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h similarity index 50% rename from src/Profiles/FitnessEquipmentControls/Profiles/ANTPLUS_FitnessEquipmentControlsProfileDisplay.h rename to src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h index 2a38e61..3920131 100644 --- a/src/Profiles/FitnessEquipmentControls/Profiles/ANTPLUS_FitnessEquipmentControlsProfileDisplay.h +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h @@ -2,15 +2,15 @@ #define ANTPLUS_PROFILEFECDISPLAY_h #include -#include +#include #include -class ProfileFECDisplay : public BaseSlaveProfile { +class ProfileFecDisplay : public BaseSlaveProfile { public: - ProfileFECDisplay(); - ProfileFECDisplay(uint16_t deviceNumber); - ProfileFECDisplay(uint16_t deviceNumber, uint8_t transmissionType); - void onFECTrainerData(void (*func)(FECTrainerData&, uintptr_t), uintptr_t data = 0) { _onFECTrainerData.set(func, data); } + ProfileFecDisplay(); + ProfileFecDisplay(uint16_t deviceNumber); + ProfileFecDisplay(uint16_t deviceNumber, uint8_t transmissionType); + void onFecTrainerData(void (*func)(FecSpecificTrainerData&, uintptr_t), uintptr_t data = 0) { _onFecSpecificTrainerData.set(func, data); } private: void setChannelConfig(); @@ -20,7 +20,7 @@ class ProfileFECDisplay : public BaseSlaveProfile { bool handleDataPage(BaseDataPage& dp); bool handleTrainerData(BaseDataPage& dataPage); - AntCallback _onFECTrainerData; + AntCallback _onFecSpecificTrainerData; }; #endif // ANTPLUS_PROFILEFECDISPLAY_h diff --git a/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsProfile.h b/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsProfile.h deleted file mode 100644 index 57e4845..0000000 --- a/src/Profiles/FitnessEquipmentControls/ANTPLUS_FitnessEquipmentControlsProfile.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef ANTPLUS_FECPROFILE_h -#define ANTPLUS_FECPROFILE_h - -// General Definitions -#include - -// Datapages -#include - -// Profile Classes -#include -// #include - -#endif // ANTPLUS_FECPROFILE_h From c0f4ee523e7d071f0495f2513e9972be2217ef3b Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 24 Jan 2021 16:19:34 -0800 Subject: [PATCH 118/241] profiles: fix datapage header name prefix also remove some unneeded ANT headers. --- ...icyclePowerDataPages.h => ANTPLUS_BicyclePowerDataPages.h} | 0 src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h | 2 +- .../Profiles/ANTPLUS_ProfileBicyclePowerDisplay.h | 4 +--- .../BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h | 2 +- ...icycleSpeedDataPages.h => ANTPLUS_BicycleSpeedDataPages.h} | 0 src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedProfile.h | 2 +- .../Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.h | 4 +--- .../BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedSensor.h | 2 +- ...eEnvironmentDataPages.h => ANTPLUS_EnvironmentDataPages.h} | 0 src/Profiles/Environment/ANTPLUS_EnvironmentProfile.h | 2 +- .../Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.h | 4 +--- .../Environment/Profiles/ANTPLUS_ProfileEnvironmentMonitor.h | 2 +- ...ofileHeartRateDataPages.h => ANTPLUS_HeartRateDataPages.h} | 0 src/Profiles/HeartRate/ANTPLUS_HeartRateProfile.h | 2 +- .../HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.h | 2 +- .../HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.h | 2 +- .../{ANTPLUS_ProfileLevDataPages.h => ANTPLUS_LevDataPages.h} | 0 src/Profiles/Lev/ANTPLUS_LevProfile.h | 2 +- src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.h | 2 +- 19 files changed, 14 insertions(+), 20 deletions(-) rename src/Profiles/BicyclePower/{ANTPLUS_ProfileBicyclePowerDataPages.h => ANTPLUS_BicyclePowerDataPages.h} (100%) rename src/Profiles/BicycleSpeed/{ANTPLUS_ProfileBicycleSpeedDataPages.h => ANTPLUS_BicycleSpeedDataPages.h} (100%) rename src/Profiles/Environment/{ANTPLUS_ProfileEnvironmentDataPages.h => ANTPLUS_EnvironmentDataPages.h} (100%) rename src/Profiles/HeartRate/{ANTPLUS_ProfileHeartRateDataPages.h => ANTPLUS_HeartRateDataPages.h} (100%) rename src/Profiles/Lev/{ANTPLUS_ProfileLevDataPages.h => ANTPLUS_LevDataPages.h} (100%) diff --git a/src/Profiles/BicyclePower/ANTPLUS_ProfileBicyclePowerDataPages.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDataPages.h similarity index 100% rename from src/Profiles/BicyclePower/ANTPLUS_ProfileBicyclePowerDataPages.h rename to src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDataPages.h diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h index 27c8ed7..1b2e5c8 100644 --- a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerProfile.h @@ -5,7 +5,7 @@ #include // Datapages -#include +#include // Profile Classes #include diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.h b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.h index 157515a..2cbb06a 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.h +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.h @@ -2,11 +2,9 @@ #define ANTPLUS_PROFILEBICYCLEPOWERDISPLAY_h #include -#include +#include #include -#include "ANT.h" - class ProfileBicyclePowerDisplay : public BaseSlaveProfile { public: ProfileBicyclePowerDisplay(); diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h index 53ffbfc..cb45217 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h @@ -2,7 +2,7 @@ #define ANTPLUS_PROFILEBICYCLEPOWERSENSOR_h #include -#include +#include #include class ProfileBicyclePowerSensor : public BaseMasterProfile { diff --git a/src/Profiles/BicycleSpeed/ANTPLUS_ProfileBicycleSpeedDataPages.h b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedDataPages.h similarity index 100% rename from src/Profiles/BicycleSpeed/ANTPLUS_ProfileBicycleSpeedDataPages.h rename to src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedDataPages.h diff --git a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedProfile.h b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedProfile.h index 30e85aa..54ffffa 100644 --- a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedProfile.h +++ b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedProfile.h @@ -5,7 +5,7 @@ #include // Datapages -#include +#include // Profile Classes #include diff --git a/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.h b/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.h index 15de07a..fdebac2 100644 --- a/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.h +++ b/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.h @@ -2,11 +2,9 @@ #define ANTPLUS_PROFILEBICYCLESPEEDDISPLAY_h #include -#include +#include #include -#include "ANT.h" - class ProfileBicycleSpeedDisplay : public BaseSlaveProfile { public: ProfileBicycleSpeedDisplay(); diff --git a/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedSensor.h b/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedSensor.h index bf19aef..6a56ff0 100644 --- a/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedSensor.h +++ b/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedSensor.h @@ -2,7 +2,7 @@ #define ANTPLUS_PROFILEBICYCLESPEEDSENSOR_h #include -#include +#include #include // TODO diff --git a/src/Profiles/Environment/ANTPLUS_ProfileEnvironmentDataPages.h b/src/Profiles/Environment/ANTPLUS_EnvironmentDataPages.h similarity index 100% rename from src/Profiles/Environment/ANTPLUS_ProfileEnvironmentDataPages.h rename to src/Profiles/Environment/ANTPLUS_EnvironmentDataPages.h diff --git a/src/Profiles/Environment/ANTPLUS_EnvironmentProfile.h b/src/Profiles/Environment/ANTPLUS_EnvironmentProfile.h index 5b331b9..466e5ff 100644 --- a/src/Profiles/Environment/ANTPLUS_EnvironmentProfile.h +++ b/src/Profiles/Environment/ANTPLUS_EnvironmentProfile.h @@ -5,7 +5,7 @@ #include // Datapages -#include +#include // Profile Classes #include diff --git a/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.h b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.h index 164062c..178c7dd 100644 --- a/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.h +++ b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.h @@ -2,11 +2,9 @@ #define ANTPLUS_PROFILEENVIRONMENTDISPLAY_h #include -#include +#include #include -#include "ANT.h" - class ProfileEnvironmentDisplay : public BaseSlaveProfile { public: ProfileEnvironmentDisplay(); diff --git a/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentMonitor.h b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentMonitor.h index a4f7939..93044d3 100644 --- a/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentMonitor.h +++ b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentMonitor.h @@ -2,7 +2,7 @@ #define ANTPLUS_PROFILEENVIRONMENTMONITOR_h #include -#include +#include #include class ProfileEnvironmentMonitor : BaseMasterProfile { diff --git a/src/Profiles/HeartRate/ANTPLUS_ProfileHeartRateDataPages.h b/src/Profiles/HeartRate/ANTPLUS_HeartRateDataPages.h similarity index 100% rename from src/Profiles/HeartRate/ANTPLUS_ProfileHeartRateDataPages.h rename to src/Profiles/HeartRate/ANTPLUS_HeartRateDataPages.h diff --git a/src/Profiles/HeartRate/ANTPLUS_HeartRateProfile.h b/src/Profiles/HeartRate/ANTPLUS_HeartRateProfile.h index 4612807..6fb1c92 100644 --- a/src/Profiles/HeartRate/ANTPLUS_HeartRateProfile.h +++ b/src/Profiles/HeartRate/ANTPLUS_HeartRateProfile.h @@ -5,7 +5,7 @@ #include // Datapages -#include +#include // Profile Classes #include diff --git a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.h b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.h index f4c4c8b..a057b70 100644 --- a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.h +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.h @@ -2,7 +2,7 @@ #define ANTPLUS_PROFILEHEARTRATEDISPLAY_h #include -#include +#include #include class ProfileHeartRateDisplay : public BaseSlaveProfile { diff --git a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.h b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.h index d4ab0cc..333c477 100644 --- a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.h +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.h @@ -2,7 +2,7 @@ #define ANTPLUS_PROFILEHEARTRATEMONITOR_h #include -#include +#include #include #include diff --git a/src/Profiles/Lev/ANTPLUS_ProfileLevDataPages.h b/src/Profiles/Lev/ANTPLUS_LevDataPages.h similarity index 100% rename from src/Profiles/Lev/ANTPLUS_ProfileLevDataPages.h rename to src/Profiles/Lev/ANTPLUS_LevDataPages.h diff --git a/src/Profiles/Lev/ANTPLUS_LevProfile.h b/src/Profiles/Lev/ANTPLUS_LevProfile.h index 4477fdd..87b2443 100644 --- a/src/Profiles/Lev/ANTPLUS_LevProfile.h +++ b/src/Profiles/Lev/ANTPLUS_LevProfile.h @@ -5,7 +5,7 @@ #include // Datapages -#include +#include // Profile Classes #include diff --git a/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.h b/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.h index 3d99264..b4e7d6a 100644 --- a/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.h +++ b/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.h @@ -2,7 +2,7 @@ #define ANTPLUS_PROFILELEVDISPLAY_h #include -#include +#include #include class ProfileLevDisplay : public BaseSlaveProfile { From 0e68cfb27883b28a8207d119bf9a543a9c4f3984 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 25 Jan 2021 00:05:40 -0800 Subject: [PATCH 119/241] lev: localize defines also upgrade to core datapage functions --- src/Profiles/Lev/ANTPLUS_LevPrivateDefines.h | 133 ++---------------- ...ANTPLUS_LevAltSpeedDistanceInformation.cpp | 7 +- ...NTPLUS_LevBaseSpeedDistanceInformation.cpp | 11 +- .../ANTPLUS_LevBaseSpeedSystemInformation.cpp | 40 ++++-- .../ANTPLUS_LevBatteryInformation.cpp | 24 +++- .../Lev/DataPages/ANTPLUS_LevCapabilities.cpp | 18 ++- .../Lev/DataPages/ANTPLUS_LevDisplayData.cpp | 102 +++++++------- .../ANTPLUS_LevSpeedDistanceInformation.cpp | 7 +- .../ANTPLUS_LevSpeedSystemInformation1.cpp | 27 +++- .../ANTPLUS_LevSpeedSystemInformation2.cpp | 12 +- .../Lev/Display/ANTPLUS_ProfileLevDisplay.cpp | 20 +-- 11 files changed, 193 insertions(+), 208 deletions(-) diff --git a/src/Profiles/Lev/ANTPLUS_LevPrivateDefines.h b/src/Profiles/Lev/ANTPLUS_LevPrivateDefines.h index 5b20072..d809254 100644 --- a/src/Profiles/Lev/ANTPLUS_LevPrivateDefines.h +++ b/src/Profiles/Lev/ANTPLUS_LevPrivateDefines.h @@ -2,129 +2,16 @@ #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 + +#define SPEEDSYSTEMINFORMATION1_NUMBER 1 +#define SPEEDDISTANCEINFORMATION_NUMBER 2 +#define ALTSPEEDDISTANCEINFORMATION_NUMBER 34 +#define SPEEDSYSTEMINFORMATION2_NUMBER 3 +#define BATTERYINFORMATION_NUMBER 4 +#define LEVCAPABILITIES_NUMBER 5 +#define DISPLAYDATA_NUMBER 16 #endif // ANTPLUS_BICYCLESPEEDPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.cpp index 5284055..f50d887 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.cpp @@ -1,12 +1,17 @@ #include #include +#define FUELCONSUMPTION_LSB_BYTE 4 +#define FUELCONSUMPTION_MSB_BYTE 5 +#define FUELCONSUMPTION_MASK 0x0FFF + /* 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); + return this->get16BitValue(FUELCONSUMPTION_LSB_BYTE, + FUELCONSUMPTION_MSB_BYTE, FUELCONSUMPTION_MASK); } diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.cpp index 1fa6790..200400a 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.cpp @@ -1,15 +1,22 @@ #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 */ 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); + return this->get32BitValue(ODOMETER_LSB_BYTE, ODOMETER_MSB_BYTE); } 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); + return this->get16BitValue(LEVSPEED_LSB_BYTE, LEVSPEED_MSB_BYTE, + LEVSPEED_MASK); } diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedSystemInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedSystemInformation.cpp index 172493f..db6b839 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedSystemInformation.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedSystemInformation.cpp @@ -1,37 +1,61 @@ #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 + 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; + return this->get8BitValue(TRAVELMODESTATE_BYTE, + 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; + return this->get8BitValue(TRAVELMODESTATE_BYTE, + TRAVELMODESTATE_CURRENTASSISTLEVEL_MASK, + TRAVELMODESTATE_CURRENTASSISTLEVEL_SHIFT); } uint8_t LevBaseSpeedSystemInformation::getSystemState() { - return getData(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_SYSTEMSTATE_BYTE); + return this->get8BitValue(SYSTEMSTATE_BYTE); } uint8_t LevBaseSpeedSystemInformation::getCurrentFrontGear() { - return getData(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_GEARSTATE_BYTE) & ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION_GEARSTATE_CURRENTFRONTGEAR_MASK; + return this->get8BitValue(GEARSTATE_BYTE, 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; + return this->get8BitValue(GEARSTATE_BYTE, GEARSTATE_CURRENTREARGEAR_MASK, + 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; + return this->get8BitValue(GEARSTATE_BYTE, GEARSTATE_MANUALAUTO_MASK, + 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; + return this->get8BitValue(GEARSTATE_BYTE, GEARSTATE_GEAREXIST_MASK, + 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); + return this->get16BitValue(LEVSPEED_LSB_BYTE, LEVSPEED_MSB_BYTE, + LEVSPEED_MASK); } diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.cpp index f6b6fb6..43f18a0 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.cpp @@ -1,21 +1,37 @@ #include #include +#define CHARGINGCYCLECOUNT_LSB_BYTE 2 +#define CHARGINGCYCLECOUNT_MSB_BYTE 3 +#define CHARGINGCYCLECOUNT_MASK 0x0FFF +#define FUELCONSUMPTION_LSB_BYTE 4 +#define FUELCONSUMPTION_MSB_BYTE 3 +#define FUELCONSUMPTION_MASK 0xF0 +#define FUELCONSUMPTION_SHIFT 4 +#define BATTERYVOLTAGE_BYTE 5 +#define DISTANCEONCURRENTCHARGE_LSB_BYTE 6 +#define DISTANCEONCURRENTCHARGE_MSB_BYTE 7 + 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); + return this->get16BitValue(CHARGINGCYCLECOUNT_LSB_BYTE, + CHARGINGCYCLECOUNT_MSB_BYTE, CHARGINGCYCLECOUNT_MASK); } +// TODO check this in testing 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); + return this->get16BitValue(FUELCONSUMPTION_LSB_BYTE, + FUELCONSUMPTION_MSB_BYTE, FUELCONSUMPTION_MASK, + FUELCONSUMPTION_SHIFT); } uint8_t LevBatteryInformation::getBatteryVoltage() { - return getData(ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_BATTERYVOLTAGE_BYTE); + return this->get8BitValue(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); + return this->get16BitValue(DISTANCEONCURRENTCHARGE_LSB_BYTE, + DISTANCEONCURRENTCHARGE_MSB_BYTE); } diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.cpp index a4f3d30..01712f2 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.cpp @@ -1,17 +1,29 @@ #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 0xF + 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; + return this->get8BitValue(TRAVELMODESSUPPORTED_BYTE, + TRAVELMODESSUPPORTED_NUMBERASSISTMODES_MASK, + TRAVELMODESSUPPORTED_NUMBERASSISTMODES_SHIFT); } uint8_t LevCapabilities::getNumberOfRegenerativeModesSupported() { - return getData(ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_TRAVELMODESSUPPORTED_BYTE) & ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_TRAVELMODESSUPPORTED_NUMBERREGENERATIVEMODES_MASK; + return this->get8BitValue(TRAVELMODESSUPPORTED_BYTE, + 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); + return this->get16BitValue(WHEELCIRCUMFERENCE_LSB_BYTE, + WHEELCIRCUMFERENCE_MSB_BYTE, WHEELCIRCUMFERENCE_MASK); } diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.cpp index b996def..26f3211 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.cpp @@ -1,96 +1,100 @@ #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; +#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 CURRENTLIGHTMODE_BYTE 4 +#define CURRENTLIGHTMODE_MASK 0xF +#define MANUFACTURERID_LSB_BYTE 6 +#define MANUFACTURERID_MSB_BYTE 7 + +LevDisplayDataMsg::LevDisplayDataMsg() : LevBaseMainDataPageMsg(DISPLAYDATA_NUMBER) { + set8BitValue(RESERVED1_VALUE, RESERVED1_BYTE); + set8BitValue(RESERVED2_VALUE, RESERVED2_BYTE); } 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); + return this->get16BitValue(WHEELCIRCUMFERENCE_LSB_BYTE, + WHEELCIRCUMFERENCE_MSB_BYTE, 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); + return this->get8BitValue(CURRENTASSISTLEVEL_BYTE, CURRENTASSISTLEVEL_MASK, + CURRENTASSISTLEVEL_SHIFT); } uint8_t LevDisplayDataMsg::getCurrentRegenerativeLevel() { - return get8BitValue(ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTREGENERATIVELEVEL_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTREGENERATIVELEVEL_MASK); + return this->get8BitValue(CURRENTREGENERATIVELEVEL_BYTE, + 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); + return (uint8_t)this->get16BitValue(CURRENTREARGEAR_LSB_BYTE, + CURRENTREARGEAR_MSB_BYTE, CURRENTREARGEAR_MASK, + 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); + return this->get8BitValue(CURRENTFRONTGEAR_BYTE, CURRENTFRONTGEAR_MASK, + CURRENTFRONTGEAR_SHIFT); } +// TODO break apart bitfield uint8_t LevDisplayDataMsg::getCurrentLightMode() { - return get8BitValue(ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTLIGHTMODE_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTLIGHTMODE_MASK); + return this->get8BitValue(CURRENTLIGHTMODE_BYTE, CURRENTLIGHTMODE_MASK); } uint16_t LevDisplayDataMsg::getManufacturerID() { - return get16BitValue(ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_MANUFACTURERID_LSB_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_MANUFACTURERID_MSB_BYTE); + return this->get16BitValue(MANUFACTURERID_LSB_BYTE, 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); + set16BitValue(circumference, WHEELCIRCUMFERENCE_LSB_BYTE, + WHEELCIRCUMFERENCE_MSB_BYTE, 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); + set8BitValue(level, CURRENTASSISTLEVEL_BYTE, CURRENTASSISTLEVEL_MASK, + CURRENTASSISTLEVEL_SHIFT); } void LevDisplayDataMsg::setCurrentRegenerativeLevel(uint8_t level) { - set8BitValue(level, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTREGENERATIVELEVEL_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTREGENERATIVELEVEL_MASK); + set8BitValue(level, CURRENTREGENERATIVELEVEL_BYTE, + 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); + set16BitValue(gear, CURRENTREARGEAR_LSB_BYTE, CURRENTREARGEAR_MSB_BYTE, + CURRENTREARGEAR_MASK, 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); + set8BitValue(gear, CURRENTFRONTGEAR_BYTE, CURRENTFRONTGEAR_MASK, + CURRENTFRONTGEAR_SHIFT); } void LevDisplayDataMsg::setCurrentLightMode(uint8_t state) { - set8BitValue(state, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTLIGHTMODE_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_CURRENTLIGHTMODE_MASK); + set8BitValue(state, CURRENTLIGHTMODE_BYTE, CURRENTLIGHTMODE_MASK); } void LevDisplayDataMsg::setManufacturerID(uint16_t id) { - set16BitValue(id, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_MANUFACTURERID_LSB_BYTE, - ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_MANUFACTURERID_MSB_BYTE); + set16BitValue(id, MANUFACTURERID_LSB_BYTE, MANUFACTURERID_MSB_BYTE); } diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.cpp index d4d3760..87e8dfd 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.cpp @@ -1,10 +1,15 @@ #include #include +#define REMAININGRANGE_LSB_BYTE 4 +#define REMAININGRANGE_MSB_BYTE 5 +#define REMAININGRANGE_MASK 0x0FFF + /* 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); + return this->get16BitValue(REMAININGRANGE_LSB_BYTE, REMAININGRANGE_MSB_BYTE, + REMAININGRANGE_MASK); } diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.cpp index fcd41a5..662ebc7 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.cpp @@ -1,27 +1,44 @@ #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 + 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; + return this->get8BitValue(TEMPERATURESTATE_BYTE, + 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; + return this->get8BitValue(TEMPERATURESTATE_BYTE, + TEMPERATURESTATE_BATTERYTEMPERATUREALERT_MASK, + 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; + return this->get8BitValue(TEMPERATURESTATE_BYTE, + TEMPERATURESTATE_MOTORTEMPERATURE_MASK, + 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; + return this->get8BitValue(TEMPERATURESTATE_BYTE, + TEMPERATURESTATE_MOTORTEMPERATUREALERT_MASK, + TEMPERATURESTATE_MOTORTEMPERATUREALERT_SHIFT); } uint8_t LevSpeedSystemInformation1::getErrorMessage() { - return getData(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_ERRORMESSAGE_BYTE); + return this->get8BitValue(ERRORMESSAGE_BYTE); } diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.cpp index b2b2f49..82e51b4 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.cpp @@ -1,17 +1,23 @@ #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 + 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; + return this->get8BitValue(BATTERYSOC_BYTE, 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; + return this->get8BitValue(BATTERYSOC_BYTE, BATTERYSOC_BATTERYEMPTY_MASK, BATTERYSOC_BATTERYEMPTY_SHIFT); } uint8_t LevSpeedSystemInformation2::getPercentAssist() { - return getData(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION2_PERCENTASSIST_BYTE); + return this->get8BitValue(PERCENTASSIST_BYTE); } diff --git a/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.cpp b/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.cpp index 3ddf6c1..8490dfa 100644 --- a/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.cpp +++ b/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.cpp @@ -3,6 +3,8 @@ #include #include +#define DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE + ProfileLevDisplay::ProfileLevDisplay() : BaseSlaveProfile() { setChannelConfig(); } @@ -16,10 +18,10 @@ ProfileLevDisplay::ProfileLevDisplay(uint16_t deviceNumber, uint8_t transmission } 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) { @@ -44,22 +46,22 @@ bool ProfileLevDisplay::handleDataPage(LevBaseMainDataPage& dp) { switch (dataPage) { - case ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_NUMBER: + case SPEEDSYSTEMINFORMATION1_NUMBER: called = handleSpeedSystemInformation1(dp); break; - case ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_NUMBER: + case SPEEDDISTANCEINFORMATION_NUMBER: called = handleSpeedDistanceInformation(dp); break; - case ANTPLUS_LEV_DATAPAGE_ALTSPEEDDISTANCEINFORMATION_NUMBER: + case ALTSPEEDDISTANCEINFORMATION_NUMBER: called = handleAltSpeedDistanceInformation(dp); break; - case ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION2_NUMBER: + case SPEEDSYSTEMINFORMATION2_NUMBER: called = handleSpeedSystemInformation2(dp); break; - case ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_NUMBER: + case BATTERYINFORMATION_NUMBER: called = handleBatteryInformation(dp); break; - case ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_NUMBER: + case LEVCAPABILITIES_NUMBER: called = handleCapabilities(dp); break; case COMMON_MANUFACTURERSINFORMATION_NUMBER: From 6e94e099b0259306bb09ba8b8589dc89e04f8be4 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 25 Jan 2021 00:08:12 -0800 Subject: [PATCH 120/241] lev: consolidate profiles --- src/Profiles/Lev/ANTPLUS_LevProfile.h | 2 +- .../Lev/{Display => Profiles}/ANTPLUS_ProfileLevDisplay.cpp | 2 +- .../Lev/{Display => Profiles}/ANTPLUS_ProfileLevDisplay.h | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename src/Profiles/Lev/{Display => Profiles}/ANTPLUS_ProfileLevDisplay.cpp (98%) rename src/Profiles/Lev/{Display => Profiles}/ANTPLUS_ProfileLevDisplay.h (100%) diff --git a/src/Profiles/Lev/ANTPLUS_LevProfile.h b/src/Profiles/Lev/ANTPLUS_LevProfile.h index 87b2443..a94ed73 100644 --- a/src/Profiles/Lev/ANTPLUS_LevProfile.h +++ b/src/Profiles/Lev/ANTPLUS_LevProfile.h @@ -8,6 +8,6 @@ #include // Profile Classes -#include +#include #endif // ANTPLUS_LEVPROFILE_h diff --git a/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.cpp b/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.cpp similarity index 98% rename from src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.cpp rename to src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.cpp index 8490dfa..d8dad74 100644 --- a/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.cpp +++ b/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.h b/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.h similarity index 100% rename from src/Profiles/Lev/Display/ANTPLUS_ProfileLevDisplay.h rename to src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.h From 35d7caab5b5739c6d3d3eb9c1ddbd5d43ce300ca Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 25 Jan 2021 00:42:30 -0800 Subject: [PATCH 121/241] moxy: consoilidate datapges step 1 of refactor --- .../ANTPLUS_MuscleOxygenProfile.h | 6 +- .../ANTPLUS_ProfileMuscleOxygenDataPages.h | 7 ++ ... ANTPLUS_MuscleOxygenBaseMainDataPage.cpp} | 3 +- ...=> ANTPLUS_MuscleOxygenBaseMainDataPage.h} | 3 +- .../{RX => }/ANTPLUS_MuscleOxygenCommands.cpp | 0 .../{RX => }/ANTPLUS_MuscleOxygenCommands.h | 0 .../ANTPLUS_MuscleOxygenMuscleOxygenData.cpp | 69 +++++++++++++++++++ .../ANTPLUS_MuscleOxygenMuscleOxygenData.h | 29 ++++++++ .../ANTPLUS_ProfileMuscleOxygenDataPages.h | 10 --- .../Base/ANTPLUS_MuscleOxygenBaseCommands.cpp | 0 .../Base/ANTPLUS_MuscleOxygenBaseCommands.h | 0 .../ANTPLUS_MuscleOxygenBaseMainDataPage.cpp | 0 .../ANTPLUS_MuscleOxygenBaseMainDataPage.h | 0 ...TPLUS_MuscleOxygenBaseMuscleOxygenData.cpp | 36 ---------- ...ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h | 18 ----- ...NTPLUS_MuscleOxygenMuscleOxygenDataMsg.cpp | 34 --------- .../ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.h | 19 ----- .../ANTPLUS_ProfileMuscleOxygenMonitor.h | 2 +- 18 files changed, 112 insertions(+), 124 deletions(-) create mode 100644 src/Profiles/MuscleOxygen/ANTPLUS_ProfileMuscleOxygenDataPages.h rename src/Profiles/MuscleOxygen/DataPages/{Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.cpp => ANTPLUS_MuscleOxygenBaseMainDataPage.cpp} (73%) rename src/Profiles/MuscleOxygen/DataPages/{Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h => ANTPLUS_MuscleOxygenBaseMainDataPage.h} (90%) rename src/Profiles/MuscleOxygen/DataPages/{RX => }/ANTPLUS_MuscleOxygenCommands.cpp (100%) rename src/Profiles/MuscleOxygen/DataPages/{RX => }/ANTPLUS_MuscleOxygenCommands.h (100%) create mode 100644 src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.cpp create mode 100644 src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.h delete mode 100644 src/Profiles/MuscleOxygen/DataPages/ANTPLUS_ProfileMuscleOxygenDataPages.h delete mode 100644 src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseCommands.cpp delete mode 100644 src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseCommands.h delete mode 100644 src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPage.cpp delete mode 100644 src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPage.h delete mode 100644 src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h delete mode 100644 src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.cpp delete mode 100644 src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.h diff --git a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenProfile.h b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenProfile.h index d4da4cf..3a2603f 100644 --- a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenProfile.h +++ b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenProfile.h @@ -2,12 +2,12 @@ #define ANTPLUS_MUSCLEOXYGENPROFILE_h // General Definitions -#include +// TODO // Datapages -#include +#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/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.cpp b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.cpp similarity index 73% rename from src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.cpp rename to src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.cpp index 7327850..82e70a3 100644 --- a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.cpp +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.cpp @@ -1,6 +1,7 @@ -#include +#include #include +// TODO setup core MuscleOxygenBaseMainDataPageMsg::MuscleOxygenBaseMainDataPageMsg(uint8_t dataPageNumber) : BaseDataPageMsg() { memset(_buffer, 0, MESSAGE_SIZE); setDataBuffer(_buffer); diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.h similarity index 90% rename from src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h rename to src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.h index 58b2169..05624d7 100644 --- a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.h @@ -1,10 +1,9 @@ #ifndef ANTPLUS_MUSCLEOXYGENBASEMAINDATAPAGEMSG_h #define ANTPLUS_MUSCLEOXYGENBASEMAINDATAPAGEMSG_h +#include #include -#include "ANT.h" - class MuscleOxygenBaseMainDataPageMsg : public BaseDataPageMsg { public: explicit MuscleOxygenBaseMainDataPageMsg(uint8_t dataPageNumber); diff --git a/src/Profiles/MuscleOxygen/DataPages/RX/ANTPLUS_MuscleOxygenCommands.cpp b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenCommands.cpp similarity index 100% rename from src/Profiles/MuscleOxygen/DataPages/RX/ANTPLUS_MuscleOxygenCommands.cpp rename to src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenCommands.cpp diff --git a/src/Profiles/MuscleOxygen/DataPages/RX/ANTPLUS_MuscleOxygenCommands.h b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenCommands.h similarity index 100% rename from src/Profiles/MuscleOxygen/DataPages/RX/ANTPLUS_MuscleOxygenCommands.h rename to src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenCommands.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..f366931 --- /dev/null +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.cpp @@ -0,0 +1,69 @@ +#include +#include + +// TODO Magic numbers +template +MuscleOxygenBaseMuscleOxygenData::MuscleOxygenBaseMuscleOxygenData() : CoreDataPage() {} + +template +uint8_t MuscleOxygenBaseMuscleOxygenData::getEventCount() { + return this->get8BitValue(1); +} + +template +uint8_t MuscleOxygenBaseMuscleOxygenData::getNotifications() { + return this->get8BitValue(2); +} + +template +uint8_t MuscleOxygenBaseMuscleOxygenData::getCapabilities() { + return this->get8BitValue(3); +} + +template +uint16_t MuscleOxygenBaseMuscleOxygenData::getTotalHemoglobinConcentration() { + return this->get16BitValue(4, 5, 0x0FFF); +} + +template +uint16_t MuscleOxygenBaseMuscleOxygenData::getPreviousSaturatedHemoglobinPercentage() { + return this->get16BitValue(5, 6, 0x3FF0, 4); +} + +template +uint16_t MuscleOxygenBaseMuscleOxygenData::getCurrentSaturatedHemoglobinPercentage() { + return this->get16BitValue(6, 7, 0xFFC0, 6); +} + +// TODO magic numbers +MuscleOxygenMuscleOxygenDataMsg::MuscleOxygenMuscleOxygenDataMsg() : + MuscleOxygenBaseMainDataPageMsg(0), + MuscleOxygenBaseMuscleOxygenData() { + setTotalHemoglobinConcentration(0xFFF); + setPreviousSaturatedHemoglobinPercentage(0x3FF); + setCurrentSaturatedHemoglobinPercentage(0x3FF); +} + +void MuscleOxygenMuscleOxygenDataMsg::setEventCount(uint8_t n) { + set8BitValue(n, 1); +} + +void MuscleOxygenMuscleOxygenDataMsg::setNotifications(uint8_t notifications) { + set8BitValue(notifications, 2); +} + +void MuscleOxygenMuscleOxygenDataMsg::setCapabilities(uint8_t capabilities) { + set8BitValue(capabilities, 3); +} + +void MuscleOxygenMuscleOxygenDataMsg::setTotalHemoglobinConcentration(uint16_t concentration) { + set16BitValue(concentration, 4, 5, 0x0FFF); +} + +void MuscleOxygenMuscleOxygenDataMsg::setPreviousSaturatedHemoglobinPercentage(uint16_t percent) { + set16BitValue(percent, 5, 6, 0x3FF0, 4); +} + +void MuscleOxygenMuscleOxygenDataMsg::setCurrentSaturatedHemoglobinPercentage(uint16_t percent) { + set16BitValue(percent, 6, 7, 0xFFC0, 6); +} diff --git a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.h b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.h new file mode 100644 index 0000000..47654a4 --- /dev/null +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.h @@ -0,0 +1,29 @@ +#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 getCapabilities(); + 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 setCapabilities(uint8_t capabilities); + 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/DataPages/ANTPLUS_ProfileMuscleOxygenDataPages.h b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_ProfileMuscleOxygenDataPages.h deleted file mode 100644 index 0b3d125..0000000 --- a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_ProfileMuscleOxygenDataPages.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef ANTPLUS_PROFILEMUSCLEOXYGENDATAPAGES_h -#define ANTPLUS_PROFILEMUSCLEOXYGENDATAPAGES_h - -/* RX */ -#include - -/* TX */ -#include - -#endif // ANTPLUS_PROFILEMUSCLEOXYGENDATAPAGES_h diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseCommands.cpp b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseCommands.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseCommands.h b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseCommands.h deleted file mode 100644 index e69de29..0000000 diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPage.cpp b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPage.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPage.h b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPage.h deleted file mode 100644 index e69de29..0000000 diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.cpp b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.cpp index 1921d1d..e69de29 100644 --- a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.cpp +++ b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.cpp @@ -1,36 +0,0 @@ -#include - -// TODO Magic numbers -template -MuscleOxygenBaseMuscleOxygenData::MuscleOxygenBaseMuscleOxygenData() { -} - -template -uint8_t MuscleOxygenBaseMuscleOxygenData::getEventCount() { - return this->get8BitValue(1); -} - -template -uint8_t MuscleOxygenBaseMuscleOxygenData::getNotifications() { - return this->get8BitValue(2); -} - -template -uint8_t MuscleOxygenBaseMuscleOxygenData::getCapabilities() { - return this->get8BitValue(3); -} - -template -uint16_t MuscleOxygenBaseMuscleOxygenData::getTotalHemoglobinConcentration() { - return this->get16BitValue(4, 5, 0x0FFF); -} - -template -uint16_t MuscleOxygenBaseMuscleOxygenData::getPreviousSaturatedHemoglobinPercentage() { - return this->get16BitValue(5, 6, 0x3FF0, 4); -} - -template -uint16_t MuscleOxygenBaseMuscleOxygenData::getCurrentSaturatedHemoglobinPercentage() { - return this->get16BitValue(6, 7, 0xFFC0, 6); -} diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h deleted file mode 100644 index 5c2e890..0000000 --- a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef ANTPLUS_MUSCLEOXYGENBASEMUSCLEOXYGENDATA_h -#define ANTPLUS_MUSCLEOXYGENBASEMUSCLEOXYGENDATA_h - -#include - -template -class MuscleOxygenBaseMuscleOxygenData : public virtual CoreDataPage { -public: - MuscleOxygenBaseMuscleOxygenData(); - uint8_t getEventCount(); - uint8_t getNotifications(); - uint8_t getCapabilities(); - uint16_t getTotalHemoglobinConcentration(); - uint16_t getPreviousSaturatedHemoglobinPercentage(); - uint16_t getCurrentSaturatedHemoglobinPercentage(); -}; - -#endif // ANTPLUS_MUSCLEOXYGENBASEMUSCLEOXYGENDATA_h diff --git a/src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.cpp b/src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.cpp deleted file mode 100644 index 8a3e041..0000000 --- a/src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include - - -// TODO magic numbers -MuscleOxygenMuscleOxygenDataMsg::MuscleOxygenMuscleOxygenDataMsg() : MuscleOxygenBaseMainDataPageMsg(0) { - setTotalHemoglobinConcentration(0xFFF); - setPreviousSaturatedHemoglobinPercentage(0x3FF); - setCurrentSaturatedHemoglobinPercentage(0x3FF); -} - -void MuscleOxygenMuscleOxygenDataMsg::setEventCount(uint8_t n) { - set8BitValue(n, 1); -} - -void MuscleOxygenMuscleOxygenDataMsg::setNotifications(uint8_t notifications) { - set8BitValue(notifications, 2); -} - -void MuscleOxygenMuscleOxygenDataMsg::setCapabilities(uint8_t capabilities) { - set8BitValue(capabilities, 3); -} - -void MuscleOxygenMuscleOxygenDataMsg::setTotalHemoglobinConcentration(uint16_t concentration) { - set16BitValue(concentration, 4, 5, 0x0FFF); -} - -void MuscleOxygenMuscleOxygenDataMsg::setPreviousSaturatedHemoglobinPercentage(uint16_t percent) { - set16BitValue(percent, 5, 6, 0x3FF0, 4); -} - -void MuscleOxygenMuscleOxygenDataMsg::setCurrentSaturatedHemoglobinPercentage(uint16_t percent) { - set16BitValue(percent, 6, 7, 0xFFC0, 6); -} diff --git a/src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.h b/src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.h deleted file mode 100644 index 7ce3261..0000000 --- a/src/Profiles/MuscleOxygen/DataPages/TX/ANTPLUS_MuscleOxygenMuscleOxygenDataMsg.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef ANTPLUS_MUSCLEOXYGENMUSCLEOXYGENDATAMSG_h -#define ANTPLUS_MUSCLEOXYGENMUSCLEOXYGENDATAMSG_h - -#include - -#include "ANT.h" - -class MuscleOxygenMuscleOxygenDataMsg : public MuscleOxygenBaseMainDataPageMsg { -public: - MuscleOxygenMuscleOxygenDataMsg(); - void setEventCount(uint8_t n); - void setNotifications(uint8_t notficications); - void setCapabilities(uint8_t capabilities); - void setTotalHemoglobinConcentration(uint16_t concentration); - void setPreviousSaturatedHemoglobinPercentage(uint16_t percent); - void setCurrentSaturatedHemoglobinPercentage(uint16_t percent); -}; - -#endif // ANTPLUS_MUSCLEOXYGENMUSCLEOXYGENDATAMSG_h diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h index 1d022b3..454a40d 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h @@ -2,7 +2,7 @@ #define ANTPLUS_PROFILEMUSCLEOXYGENMONITOR_h #include -#include +#include #include #include From 3571504f618cc86b587678588f6b56d16fd4fb69 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 1 Feb 2021 00:01:42 -0800 Subject: [PATCH 122/241] circleci: upgrade python for circleci --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0c69030..afdbf84 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,7 @@ jobs: docker: # specify the version you desire here # use `-browsers` prefix for selenium tests, e.g. `3.6.1-browsers` - - image: circleci/python:2.7 + - image: circleci/python:3.8 # Specify service dependencies here if necessary # CircleCI maintains a library of pre-built images From dbf6a98666251e3da805321d4d1e59b32fc2e1e8 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 6 Feb 2021 20:38:33 -0800 Subject: [PATCH 123/241] muslceoxygen: clean up todo, fix datapge number bug and defines --- .../ANTPLUS_MuscleOxygenDefines.h | 11 +++ .../ANTPLUS_MuscleOxygenPrivateDefines.h | 9 +-- .../ANTPLUS_MuscleOxygenProfile.h | 2 +- .../ANTPLUS_MuscleOxygenMuscleOxygenData.cpp | 68 ++++++++++++++----- 4 files changed, 67 insertions(+), 23 deletions(-) create mode 100644 src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h diff --git a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h new file mode 100644 index 0000000..7d290d0 --- /dev/null +++ b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h @@ -0,0 +1,11 @@ +#ifndef ANTPLUS_MUSCLEOXYGENDEFINES_h +#define ANTPLUS_MUSCLEOXYGENDEFINES_h + +#define ANTPLUS_MUSCLEOXYGEN_DEVICETYPE 31 + +#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 + +#endif // ANTPLUS_MUSCLEOXYGENDEFINES_h diff --git a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h index 4d5ad96..9718ba7 100644 --- a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h +++ b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h @@ -1,9 +1,10 @@ -#ifndef ANTPLUS_MUSCLEOXYGENPROFILEPRIVATEDEFINES_h -#define ANTPLUS_MUSCLEOXYGENPROFILEPRIVATEDEFINES_h +#ifndef ANTPLUS_MUSCLEOXYGENPRIVATEDEFINES_h +#define ANTPLUS_MUSCLEOXYGENPRIVATEDEFINES_h + +#include /* Channel Config */ #define ANTPLUS_MUSCLEOXYGEN_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE -#define ANTPLUS_MUSCLEOXYGEN_DEVICETYPE 31 #define ANTPLUS_MUSCLEOXYGEN_CHANNELPERIOD 8192 // Master channel #define ANTPLUS_MUSCLEOXYGEN_MONITOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT @@ -18,4 +19,4 @@ // Base page */ #define ANTPLUS_MUSCLEOXYGEN_DATAPAGEBASE_DATAPAGE_BYTE 0x00 -#endif // ANTPLUS_MUSCLEOXYGENPROFILEPRIVATEDEFINES_h +#endif // ANTPLUS_MUSCLEOXYGENPRIVATEDEFINES_h diff --git a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenProfile.h b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenProfile.h index 3a2603f..09b2988 100644 --- a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenProfile.h +++ b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenProfile.h @@ -2,7 +2,7 @@ #define ANTPLUS_MUSCLEOXYGENPROFILE_h // General Definitions -// TODO +#include // Datapages #include diff --git a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.cpp b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.cpp index f366931..5bfcaed 100644 --- a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.cpp +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.cpp @@ -1,69 +1,101 @@ #include #include -// TODO Magic numbers +#define EVENTCOUNT_BYTE 1 +#define NOTIFICATIONS_BYTE 2 +#define CAPABILITIES_BYTE 3 +#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(1); + return this->get8BitValue(EVENTCOUNT_BYTE); } template uint8_t MuscleOxygenBaseMuscleOxygenData::getNotifications() { - return this->get8BitValue(2); + return this->get8BitValue(NOTIFICATIONS_BYTE); } template uint8_t MuscleOxygenBaseMuscleOxygenData::getCapabilities() { - return this->get8BitValue(3); + return this->get8BitValue(CAPABILITIES_BYTE); } template uint16_t MuscleOxygenBaseMuscleOxygenData::getTotalHemoglobinConcentration() { - return this->get16BitValue(4, 5, 0x0FFF); + return this->get16BitValue(TOTALHEMOGLOBINCONCENTRATION_LSB_BYTE, + TOTALHEMOGLOBINCONCENTRATION_MSB_BYTE, + TOTALHEMOGLOBINCONCENTRATION_MASK); } template uint16_t MuscleOxygenBaseMuscleOxygenData::getPreviousSaturatedHemoglobinPercentage() { - return this->get16BitValue(5, 6, 0x3FF0, 4); + return this->get16BitValue(PREVIOUSSATURATEDHEMOGLOBINPERCENTAGE_LSB_BYTE, + PREVIOUSSATURATEDHEMOGLOBINPERCENTAGE_MSB_BYTE, + PREVIOUSSATURATEDHEMOGLOBINPERCENTAGE_MASK, + PREVIOUSSATURATEDHEMOGLOBINPERCENTAGE_MASK); } template uint16_t MuscleOxygenBaseMuscleOxygenData::getCurrentSaturatedHemoglobinPercentage() { - return this->get16BitValue(6, 7, 0xFFC0, 6); + return this->get16BitValue(CURRENTSATURATEDHEMOGLOBINPERCENTAGE_LSB_BYTE, + CURRENTSATURATEDHEMOGLOBINPERCENTAGE_MSB_BYTE, + CURRENTSATURATEDHEMOGLOBINPERCENTAGE_MASK, + CURRENTSATURATEDHEMOGLOBINPERCENTAGE_SHIFT); } -// TODO magic numbers MuscleOxygenMuscleOxygenDataMsg::MuscleOxygenMuscleOxygenDataMsg() : - MuscleOxygenBaseMainDataPageMsg(0), + MuscleOxygenBaseMainDataPageMsg(ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_NUMBER), MuscleOxygenBaseMuscleOxygenData() { - setTotalHemoglobinConcentration(0xFFF); - setPreviousSaturatedHemoglobinPercentage(0x3FF); - setCurrentSaturatedHemoglobinPercentage(0x3FF); + 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, 1); + set8BitValue(n, EVENTCOUNT_BYTE); } void MuscleOxygenMuscleOxygenDataMsg::setNotifications(uint8_t notifications) { - set8BitValue(notifications, 2); + set8BitValue(notifications, NOTIFICATIONS_BYTE); } void MuscleOxygenMuscleOxygenDataMsg::setCapabilities(uint8_t capabilities) { - set8BitValue(capabilities, 3); + set8BitValue(capabilities, CAPABILITIES_BYTE); } void MuscleOxygenMuscleOxygenDataMsg::setTotalHemoglobinConcentration(uint16_t concentration) { - set16BitValue(concentration, 4, 5, 0x0FFF); + set16BitValue(concentration, TOTALHEMOGLOBINCONCENTRATION_LSB_BYTE, + TOTALHEMOGLOBINCONCENTRATION_MSB_BYTE, + TOTALHEMOGLOBINCONCENTRATION_MASK); } void MuscleOxygenMuscleOxygenDataMsg::setPreviousSaturatedHemoglobinPercentage(uint16_t percent) { - set16BitValue(percent, 5, 6, 0x3FF0, 4); + set16BitValue(percent, PREVIOUSSATURATEDHEMOGLOBINPERCENTAGE_LSB_BYTE, + PREVIOUSSATURATEDHEMOGLOBINPERCENTAGE_MSB_BYTE, + PREVIOUSSATURATEDHEMOGLOBINPERCENTAGE_MASK, + PREVIOUSSATURATEDHEMOGLOBINPERCENTAGE_SHIFT); } void MuscleOxygenMuscleOxygenDataMsg::setCurrentSaturatedHemoglobinPercentage(uint16_t percent) { - set16BitValue(percent, 6, 7, 0xFFC0, 6); + set16BitValue(percent, CURRENTSATURATEDHEMOGLOBINPERCENTAGE_LSB_BYTE, + CURRENTSATURATEDHEMOGLOBINPERCENTAGE_MSB_BYTE, + CURRENTSATURATEDHEMOGLOBINPERCENTAGE_MASK, + CURRENTSATURATEDHEMOGLOBINPERCENTAGE_SHIFT); } From d04ac449258481c6764c55704a660d7353ee89c5 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 7 Feb 2021 12:43:48 -0800 Subject: [PATCH 124/241] MuscleOxygen: fixup existing defines --- src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h | 1 + .../MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h | 8 +++----- .../DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.cpp | 2 +- .../Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp | 9 +++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h index 7d290d0..8a09ee0 100644 --- a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h +++ b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h @@ -1,6 +1,7 @@ #ifndef ANTPLUS_MUSCLEOXYGENDEFINES_h #define ANTPLUS_MUSCLEOXYGENDEFINES_h +#define ANTPLUS_MUSCLEOXYGEN_MONITOR_TRANSMISSIONTYPE 0x5 #define ANTPLUS_MUSCLEOXYGEN_DEVICETYPE 31 #define ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_TOTALHEMOGLOBINCONCENTRATION_AMBIENTLIGHTOOHIGH 0xFFE diff --git a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h index 9718ba7..400a7b7 100644 --- a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h +++ b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h @@ -5,16 +5,14 @@ /* Channel Config */ #define ANTPLUS_MUSCLEOXYGEN_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE -#define ANTPLUS_MUSCLEOXYGEN_CHANNELPERIOD 8192 // Master channel -#define ANTPLUS_MUSCLEOXYGEN_MONITOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT -#define ANTPLUS_MUSCLEOXYGEN_MONITOR_TRANSMISSIONTYPE 5 +#define MUSCLEOXYGEN_CHANNELPERIOD 8192 // 30 / 2.5 = 12 -#define ANTPLUS_MUSCLEOXYGEN_SEARCHTIMEOUT 12 +#define MUSCLEOXYGEN_SEARCHTIMEOUT 12 /* Pages */ -#define ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_NUMBER 1 +#define MUSCLEOXYGEN_MUSCLEOXYGENDATA_NUMBER 1 // Base page */ #define ANTPLUS_MUSCLEOXYGEN_DATAPAGEBASE_DATAPAGE_BYTE 0x00 diff --git a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.cpp b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.cpp index 5bfcaed..742433d 100644 --- a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.cpp +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.cpp @@ -58,7 +58,7 @@ uint16_t MuscleOxygenBaseMuscleOxygenData::getCurrentSaturatedHemoglobinPerce } MuscleOxygenMuscleOxygenDataMsg::MuscleOxygenMuscleOxygenDataMsg() : - MuscleOxygenBaseMainDataPageMsg(ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_NUMBER), + MuscleOxygenBaseMainDataPageMsg(MUSCLEOXYGEN_MUSCLEOXYGENDATA_NUMBER), MuscleOxygenBaseMuscleOxygenData() { setTotalHemoglobinConcentration( ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_TOTALHEMOGLOBINCONCENTRATION_INVALID); diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp index bac2a6e..8b8a10b 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp @@ -1,6 +1,7 @@ #include #include +#define MONITOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT ProfileMuscleOxygenMonitor::ProfileMuscleOxygenMonitor( uint16_t deviceNumber, uint8_t transmissionType) : BaseMasterProfile(deviceNumber, transmissionType), @@ -11,15 +12,15 @@ ProfileMuscleOxygenMonitor::ProfileMuscleOxygenMonitor( uint16_t deviceNumber, u } void ProfileMuscleOxygenMonitor::setChannelConfig() { - setChannelType(ANTPLUS_MUSCLEOXYGEN_MONITOR_CHANNELTYPE); + setChannelType(MONITOR_CHANNELTYPE); setDeviceType(ANTPLUS_MUSCLEOXYGEN_DEVICETYPE); - setChannelPeriod(ANTPLUS_MUSCLEOXYGEN_CHANNELPERIOD); - setSearchTimeout(ANTPLUS_MUSCLEOXYGEN_SEARCHTIMEOUT); + setChannelPeriod(MUSCLEOXYGEN_CHANNELPERIOD); + setSearchTimeout(MUSCLEOXYGEN_SEARCHTIMEOUT); } bool ProfileMuscleOxygenMonitor::isDataPageValid(uint8_t dataPage) { switch (dataPage) { - case ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_NUMBER: + case MUSCLEOXYGEN_MUSCLEOXYGENDATA_NUMBER: return true; // TODO other datapages } From b69b077839f9250d2f520c9cc2e0b2e3c94d34f3 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 7 Feb 2021 15:49:21 -0800 Subject: [PATCH 125/241] profiles: enforce transmission type for master profiles also use ant-arduino defines Fixes #21 --- src/ANTPLUS_PrivateDefines.h | 5 ++++- .../ANTPLUS_ProfileBicyclePowerSensor.cpp | 16 ++++++---------- .../Profiles/ANTPLUS_ProfileBicyclePowerSensor.h | 3 +-- .../Profiles/ANTPLUS_ProfileEnvironmentMonitor.h | 4 +--- .../Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp | 15 +++++---------- .../Profiles/ANTPLUS_ProfileHeartRateMonitor.h | 3 +-- .../MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h | 1 - .../ANTPLUS_ProfileMuscleOxygenMonitor.cpp | 7 ++++++- .../Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h | 2 +- src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h | 2 ++ .../Shifting/ANTPLUS_ShiftingPrivateDefines.h | 9 ++------- .../Shifter/ANTPLUS_ProfileShiftingShifter.cpp | 14 ++++++++++---- .../Shifter/ANTPLUS_ProfileShiftingShifter.h | 2 +- 13 files changed, 40 insertions(+), 43 deletions(-) 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/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp index 9036f30..0835bf5 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -2,23 +2,19 @@ #include #include #include +#include #define SENSOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT - -ProfileBicyclePowerSensor::ProfileBicyclePowerSensor( - uint16_t deviceNumber, - uint8_t transmissionType) : - BaseMasterProfile(deviceNumber, transmissionType), - //_nextBackgroundPage(ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER), - _flags(0) { - setChannelConfig(); -} +#define SENSOR_TRANSMISSIONTYPE (TRANSMISSION_TYPE_INDEPENDENT | TRANSMISSION_TYPE_GLOBALDATAPGESUSED) ProfileBicyclePowerSensor::ProfileBicyclePowerSensor( uint16_t deviceNumber, uint8_t transmissionType, uint32_t flags) : - BaseMasterProfile(deviceNumber, transmissionType), + BaseMasterProfile(deviceNumber, + ANTPLUS_TRANSMISSION_SET_LSN( + transmissionType, SENSOR_TRANSMISSIONTYPE)), + // TODO //_nextBackgroundPage(ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER), _flags(flags) { setChannelConfig(); diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h index cb45217..61133de 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h @@ -7,8 +7,7 @@ class ProfileBicyclePowerSensor : public BaseMasterProfile { public: - ProfileBicyclePowerSensor(uint16_t deviceNumber, uint8_t transmissionType); - ProfileBicyclePowerSensor(uint16_t deviceNumber, uint8_t transmissionType, uint32_t flags); + ProfileBicyclePowerSensor(uint16_t deviceNumber, uint8_t transmissionType = 0, uint32_t flags = 0); /** * Register callback to populate default data messages (Datapage 0) */ diff --git a/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentMonitor.h b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentMonitor.h index 93044d3..8a64eb4 100644 --- a/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentMonitor.h +++ b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentMonitor.h @@ -8,9 +8,7 @@ class ProfileEnvironmentMonitor : BaseMasterProfile { public: // TODO - ProfileEnvironmentMonitor(); - ProfileEnvironmentMonitor(uint16_t deviceNumber); - ProfileEnvironmentMonitor(uint16_t deviceNumber, uint8_t transmissionType); + ProfileEnvironmentMonitor(uint16_t deviceNumber, uint8_t transmissionType = 0); }; #endif // ANTPLUS_PROFILEENVIRONMENTMONITOR_h diff --git a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp index a7485fe..caab651 100644 --- a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp @@ -2,23 +2,18 @@ #include #include #include +#include #define MONITOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT - -ProfileHeartRateMonitor::ProfileHeartRateMonitor( - uint16_t deviceNumber, - uint8_t transmissionType) : - BaseMasterProfile(deviceNumber, transmissionType), - _nextBackgroundPage(HEARTRATE_MANUFACTURERINFORMATION_NUMBER), - _flags(0) { - setChannelConfig(); -} +#define MONITOR_TRANSMISSIONTYPE TRANSMISSION_TYPE_INDEPENDENT ProfileHeartRateMonitor::ProfileHeartRateMonitor( uint16_t deviceNumber, uint8_t transmissionType, uint32_t flags) : - BaseMasterProfile(deviceNumber, transmissionType), + BaseMasterProfile(deviceNumber, + ANTPLUS_TRANSMISSION_SET_LSN( + transmissionType, MONITOR_TRANSMISSIONTYPE)), _nextBackgroundPage(HEARTRATE_MANUFACTURERINFORMATION_NUMBER), _flags(flags) { setChannelConfig(); diff --git a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.h b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.h index 333c477..44ab906 100644 --- a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.h +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.h @@ -8,8 +8,7 @@ class ProfileHeartRateMonitor : public BaseMasterProfile { public: - ProfileHeartRateMonitor(uint16_t deviceNumber, uint8_t transmissionType); - ProfileHeartRateMonitor(uint16_t deviceNumber, uint8_t transmissionType, uint32_t flags); + ProfileHeartRateMonitor(uint16_t deviceNumber, uint8_t transmissionType = 0, uint32_t flags = 0); /** * Register callback to populate default data messages (Datapage 0) */ diff --git a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h index 8a09ee0..7d290d0 100644 --- a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h +++ b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h @@ -1,7 +1,6 @@ #ifndef ANTPLUS_MUSCLEOXYGENDEFINES_h #define ANTPLUS_MUSCLEOXYGENDEFINES_h -#define ANTPLUS_MUSCLEOXYGEN_MONITOR_TRANSMISSIONTYPE 0x5 #define ANTPLUS_MUSCLEOXYGEN_DEVICETYPE 31 #define ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_TOTALHEMOGLOBINCONCENTRATION_AMBIENTLIGHTOOHIGH 0xFFE diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp index 8b8a10b..4472f5d 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp @@ -1,10 +1,14 @@ #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) : - BaseMasterProfile(deviceNumber, transmissionType), + BaseMasterProfile(deviceNumber, + ANTPLUS_TRANSMISSION_SET_LSN( + transmissionType, MONITOR_TRANSMISSIONTYPE)), _patternStep(0), _backgroundStep(0) { @@ -61,4 +65,5 @@ void ProfileMuscleOxygenMonitor::transmitMuscleOxygenMuscleOxygenDataMsg() { } void ProfileMuscleOxygenMonitor::transmitBatteryStatusMsg() { + // TODO } diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h index 454a40d..8005a83 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h @@ -8,7 +8,7 @@ class ProfileMuscleOxygenMonitor : public BaseMasterProfile { public: - explicit ProfileMuscleOxygenMonitor(uint16_t deviceNumber, uint8_t transmissionType = ANTPLUS_MUSCLEOXYGEN_MONITOR_TRANSMISSIONTYPE); + explicit ProfileMuscleOxygenMonitor(uint16_t deviceNumber, uint8_t transmissionType = 0); /** * Register callback to populate Muscle Oxygen data messages (Datapage 0) diff --git a/src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h b/src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h index 35aaf1f..f45fa12 100644 --- a/src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h +++ b/src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h @@ -1,6 +1,8 @@ #ifndef ANTPLUS_SHIFTINGPROFILEDEFINES_h #define ANTPLUS_SHIFTINGPROFILEDEFINES_h +#define ANTPLUS_SHIFTING_DEVICETYPE 34 + #define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_SYSTEM 0 #define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_FRONTDERAILLEUR 1 #define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_REARDERAILLEUR 2 diff --git a/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h b/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h index f24a371..6d6caa0 100644 --- a/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h +++ b/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h @@ -3,14 +3,9 @@ /* Channel Config */ #define ANTPLUS_SHIFTING_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE -#define ANTPLUS_SHIFTING_DEVICETYPE 34 -#define ANTPLUS_SHIFTING_CHANNELPERIOD 8192 -// Master channel (shifter) -#define ANTPLUS_SHIFTING_SHIFTER_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT -#define ANTPLUS_SHIFTING_SHIFTER_TRANSMISSIONTYPE 5 - +#define SHIFTING_CHANNELPERIOD 8192 // 30 / 2.5 = 12 -#define ANTPLUS_SHIFTING_SEARCHTIMEOUT 12 +#define SHIFTING_SEARCHTIMEOUT 12 // Transmission pattern math #define ANTPLUS_SHIFTING_BACKGROUNDPAGE_INTERLEAVEINTERVAL 260 diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp index 46ecd54..bd865a4 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp @@ -1,9 +1,15 @@ #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, transmissionType), + BaseMasterProfile(deviceNumber, + ANTPLUS_TRANSMISSION_SET_LSN( + transmissionType, SHIFTER_TRANSMISSIONTYPE)), _componentFlags(componentFlags) { setChannelConfig(); @@ -24,10 +30,10 @@ ProfileShiftingShifter::ProfileShiftingShifter(uint16_t deviceNumber, uint8_t tr } void ProfileShiftingShifter::setChannelConfig() { - setChannelType(ANTPLUS_SHIFTING_SHIFTER_CHANNELTYPE); + setChannelType(SHIFTER_CHANNELTYPE); setDeviceType(ANTPLUS_SHIFTING_DEVICETYPE); - setChannelPeriod(ANTPLUS_SHIFTING_CHANNELPERIOD); - setSearchTimeout(ANTPLUS_SHIFTING_SEARCHTIMEOUT); + setChannelPeriod(SHIFTING_CHANNELPERIOD); + setSearchTimeout(SHIFTING_SEARCHTIMEOUT); } bool ProfileShiftingShifter::isDataPageValid(uint8_t dataPage) diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h index bd67553..53cfd02 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h +++ b/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h @@ -8,7 +8,7 @@ class ProfileShiftingShifter : public BaseMasterProfile { public: - explicit ProfileShiftingShifter(uint16_t deviceNumber, uint8_t transmissionType = ANTPLUS_SHIFTING_SHIFTER_TRANSMISSIONTYPE, uint16_t componentsSupported = 0x1); + explicit ProfileShiftingShifter(uint16_t deviceNumber, uint8_t transmissionType = 0, uint16_t componentsSupported = 0x1); /** * Register callback to populate default data messages (Datapage 1) From c026b3dc97a74dc82c22245aba53c22c9a58831d Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 7 Feb 2021 16:18:41 -0800 Subject: [PATCH 126/241] heartrate: updpate set to core format --- .../HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.cpp index 6a70b02..55c2bfa 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.cpp @@ -51,8 +51,7 @@ HeartRateBaseMainDataPageMsg::HeartRateBaseMainDataPageMsg(uint8_t dataPageNumbe BaseDataPageMsg(), HeartRateCoreMainDataPage() { setDataBuffer(_buffer); - // TODO fixup to set data api - _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = dataPageNumber; + set8BitValue(dataPageNumber, ANTPLUS_DEFAULT_DATAPAGE_BYTE); } void HeartRateBaseMainDataPageMsg::setPageChangeToggle(uint8_t toggle) { From d2bf2d1e5aa6ace249903d8a4d6052a9c5167735 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 7 Feb 2021 16:25:59 -0800 Subject: [PATCH 127/241] heartrate: fixup reserved set --- .../HeartRate/DataPages/ANTPLUS_HeartRateDefault.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.cpp index d72f7c2..d937db1 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.cpp @@ -1,13 +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(HEARTRATE_DEFAULT_NUMBER) { - // TODO magic numbers - _buffer[1] = 0xFF; - _buffer[2] = 0xFF; - _buffer[3] = 0xFF; + set24BitValue(RESERVED_VALUE, RESERVED_LSB_BYTE, RESERVED_MSB_BYTE); } From 4d7d538fbce35d6518bdbb4a501b544bfd15bf47 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 7 Feb 2021 17:32:53 -0800 Subject: [PATCH 128/241] shifting: multiple fixes fixup public flags to be dependent move profiles to common directory fix magic numbers move shifting defines where they belong --- .../Shifting/ANTPLUS_ShiftingDefines.h | 26 +++++++++---------- .../Shifting/ANTPLUS_ShiftingPrivateDefines.h | 1 - .../Shifting/ANTPLUS_ShiftingProfile.h | 2 +- .../ANTPLUS_ProfileShiftingDisplay.cpp | 1 + .../ANTPLUS_ProfileShiftingShifter.cpp | 4 +-- .../ANTPLUS_ProfileShiftingShifter.h | 7 ++--- 6 files changed, 21 insertions(+), 20 deletions(-) create mode 100644 src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingDisplay.cpp rename src/Profiles/Shifting/{Shifter => Profiles}/ANTPLUS_ProfileShiftingShifter.cpp (97%) rename src/Profiles/Shifting/{Shifter => Profiles}/ANTPLUS_ProfileShiftingShifter.h (92%) diff --git a/src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h b/src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h index f45fa12..765ad43 100644 --- a/src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h +++ b/src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h @@ -17,19 +17,19 @@ #define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_EXTENSIONSHIFTER2 11 #define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_UNKNOWNIDENTIFIED 15 -#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_SYSTEM_FLAG (1 << 0) -#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_FRONTDERAILLEUR_FLAG (1 << 1) -#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_REARDERAILLEUR_FLAG (1 << 2) -#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_LEFTSHIFTER_FLAG (1 << 3) -#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_RIGHTSHIFTER_FLAG (1 << 4) -#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_SHIFTER_FLAG (1 << 5) -#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_LEFTEXTENSIONSHIFTER_FLAG (1 << 6) -#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_RIGHTEXTENSIONSHIFTER_FLAG (1 << 7) -#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_EXTENSIONSHIFTER1_FLAG (1 << 8) -#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_LEFTEXTENSIONSHIFTER2_FLAG (1 << 9) -#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_RIGHTEXTENSIONSHIFTER2_FLAG (1 << 10) -#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_EXTENSIONSHIFTER2_FLAG (1 << 11) -#define ANTPLUS_SHIFTING_COMPONENTIDENTIFIER_UNKNOWNIDENTIFIED_FLAG (1 << 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 diff --git a/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h b/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h index 6d6caa0..7c7d6cf 100644 --- a/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h +++ b/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h @@ -2,7 +2,6 @@ #define ANTPLUS_SHIFTINGPROFILEPRIVATEDEFINES_h /* Channel Config */ -#define ANTPLUS_SHIFTING_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE #define SHIFTING_CHANNELPERIOD 8192 // 30 / 2.5 = 12 #define SHIFTING_SEARCHTIMEOUT 12 diff --git a/src/Profiles/Shifting/ANTPLUS_ShiftingProfile.h b/src/Profiles/Shifting/ANTPLUS_ShiftingProfile.h index 37b724e..a9a67f4 100644 --- a/src/Profiles/Shifting/ANTPLUS_ShiftingProfile.h +++ b/src/Profiles/Shifting/ANTPLUS_ShiftingProfile.h @@ -8,6 +8,6 @@ #include // Profile Classes -#include +#include #endif // ANTPLUS_SHIFTINGPROFILE_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/Shifter/ANTPLUS_ProfileShiftingShifter.cpp b/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.cpp similarity index 97% rename from src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp rename to src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.cpp index bd865a4..ee52176 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.cpp +++ b/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.cpp @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #define SHIFTER_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT diff --git a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h b/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.h similarity index 92% rename from src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h rename to src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.h index 53cfd02..d8f3ddd 100644 --- a/src/Profiles/Shifting/Shifter/ANTPLUS_ProfileShiftingShifter.h +++ b/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.h @@ -3,13 +3,14 @@ #include #include -#include +#include #include class ProfileShiftingShifter : public BaseMasterProfile { public: - explicit ProfileShiftingShifter(uint16_t deviceNumber, uint8_t transmissionType = 0, uint16_t componentsSupported = 0x1); - + 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) */ From e44b0f199394b4687a4cab2dff077e27a3dee25b Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 7 Feb 2021 17:44:38 -0800 Subject: [PATCH 129/241] shifting: fixup magic nums and api calls --- .../DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp index c9c90b0..a9db135 100644 --- a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp +++ b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp @@ -2,11 +2,13 @@ #include #include +#define RESERVED_BYTE 2 +#define RESERVED_VALUE 0xFF + ShiftingBaseMainDataPageMsg::ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber) : BaseDataPageMsg() { memset(_buffer, 0, MESSAGE_SIZE); setDataBuffer(_buffer); set8BitValue(dataPageNumber, ANTPLUS_SHIFTING_DATAPAGEBASE_DATAPAGE_BYTE); - // TODO magic numbers - _buffer[2] = 0xFF; + set8BitValue(RESERVED_VALUE, RESERVED_BYTE); } From 5889d81dc134d9637eba5600f73cf89be2cd1ca5 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 7 Feb 2021 18:14:27 -0800 Subject: [PATCH 130/241] shifting: remove magic numbers and fix formatting --- .../ANTPLUS_ShiftingBaseMainDataPageMsg.cpp | 3 +- .../ANTPLUS_ShiftingShiftSystemStatusMsg.cpp | 60 +++++++++++++++---- 2 files changed, 49 insertions(+), 14 deletions(-) diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp index a9db135..8accc18 100644 --- a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp +++ b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp @@ -5,7 +5,8 @@ #define RESERVED_BYTE 2 #define RESERVED_VALUE 0xFF -ShiftingBaseMainDataPageMsg::ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber) : BaseDataPageMsg() +ShiftingBaseMainDataPageMsg::ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber) : + BaseDataPageMsg() { memset(_buffer, 0, MESSAGE_SIZE); setDataBuffer(_buffer); diff --git a/src/Profiles/Shifting/DataPages/TX/ANTPLUS_ShiftingShiftSystemStatusMsg.cpp b/src/Profiles/Shifting/DataPages/TX/ANTPLUS_ShiftingShiftSystemStatusMsg.cpp index c2b22aa..5464cc4 100644 --- a/src/Profiles/Shifting/DataPages/TX/ANTPLUS_ShiftingShiftSystemStatusMsg.cpp +++ b/src/Profiles/Shifting/DataPages/TX/ANTPLUS_ShiftingShiftSystemStatusMsg.cpp @@ -1,49 +1,83 @@ #include #include -ShiftingShiftSystemStatusMsg::ShiftingShiftSystemStatusMsg() : ShiftingBaseMainDataPageMsg(ANTPLUS_SHIFTING_DATAPAGE_SHIFTSYSTEMSTATUS_NUMBER), ShiftingBaseShiftSystemStatus() { -} +#define EVENTCOUNT_BYTE 1 +#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 6 +#define SHIFTFAILURECOUNT_REAR_MASK 0x0F +#define SHIFTFAILURECOUNT_FRONT_MASK 0xF0 +#define SHIFTFAILURECOUNT_FRONT_SHIFT 4 + +ShiftingShiftSystemStatusMsg::ShiftingShiftSystemStatusMsg() : + ShiftingBaseMainDataPageMsg(ANTPLUS_SHIFTING_DATAPAGE_SHIFTSYSTEMSTATUS_NUMBER), + ShiftingBaseShiftSystemStatus() {} void ShiftingShiftSystemStatusMsg::setEventCount(uint8_t n) { - set8BitValue(n, 1); + set8BitValue(n, EVENTCOUNT_BYTE); } void ShiftingShiftSystemStatusMsg::setCurrentGearRear(uint8_t cgr) { - set8BitValue(cgr, 3, 0x1F); + set8BitValue(cgr, CURRENTGEAR_BYTE, CURRENTGEAR_REAR_MASK); } void ShiftingShiftSystemStatusMsg::setCurrentGearFront(uint8_t cgf) { - set8BitValue(cgf, 3, 0xE0, 5); + set8BitValue(cgf, CURRENTGEAR_BYTE, CURRENTGEAR_FRONT_MASK, + CURRENTGEAR_FRONT_SHIFT); } void ShiftingShiftSystemStatusMsg::setTotalNumbersGearRear(uint8_t tgr) { - set8BitValue(tgr, 4, 0x1F); + set8BitValue(tgr, TOTALNUMBEROFGEARS_BYTE, TOTALNUMBEROFGEARS_REAR_MASK); } void ShiftingShiftSystemStatusMsg::setTotalNumbersGearFront(uint8_t tgf) { - set8BitValue(tgf, 4, 0xE0, 5); + set8BitValue(tgf, TOTALNUMBEROFGEARS_BYTE, TOTALNUMBEROFGEARS_FRONT_MASK, + TOTALNUMBEROFGEARS_FRONT_SHIFT); } void ShiftingShiftSystemStatusMsg::setInvalidInboardShiftCountRear(uint8_t isr) { - set8BitValue(isr, 5, 0x0F); + set8BitValue(isr, INVALIDINBOARDSHIFTCOUNT_REAR_BYTE, + INVALIDINBOARDSHIFTCOUNT_REAR_MASK); } void ShiftingShiftSystemStatusMsg::setInvalidOutboardShiftCountRear(uint8_t osr) { - set8BitValue(osr, 0xF0, 4); + set8BitValue(osr, INVALIDOUTBOARDSHIFTCOUNT_REAR_BYTE, + INVALIDOUTBOARDSHIFTCOUNT_REAR_MASK, + INVALIDOUTBOARDSHIFTCOUNT_REAR_SHIFT); } void ShiftingShiftSystemStatusMsg::setInvalidInboardShiftCountFront(uint8_t isf) { - set8BitValue(isf, 6, 0x0F); + set8BitValue(isf, INVALIDINBOARDSHIFTCOUNT_FRONT_BYTE, + INVALIDINBOARDSHIFTCOUNT_FRONT_MASK); } void ShiftingShiftSystemStatusMsg::setInvalidOutboardShiftCountFront(uint8_t osf) { - set8BitValue(osf, 6, 0xF0, 4); + set8BitValue(osf, INVALIDOUTBOARDSHIFTCOUNT_FRONT_BYTE, + INVALIDOUTBOARDSHIFTCOUNT_FRONT_MASK, + INVALIDOUTBOARDSHIFTCOUNT_FRONT_SHIFT); } void ShiftingShiftSystemStatusMsg::setShiftFailureCountRear(uint8_t sfr) { - set8BitValue(sfr, 7, 0x0F); + set8BitValue(sfr, SHIFTFAILURECOUNT_BYTE, SHIFTFAILURECOUNT_REAR_MASK); } void ShiftingShiftSystemStatusMsg::setShiftFailureCountFront(uint8_t sff) { - set8BitValue(sff, 7, 0xF0, 4); + set8BitValue(sff, SHIFTFAILURECOUNT_BYTE, SHIFTFAILURECOUNT_FRONT_MASK, + SHIFTFAILURECOUNT_FRONT_SHIFT); } From 38f140a30e1bbee0c93111eb50af6f68f040cc8e Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 7 Feb 2021 21:11:49 -0800 Subject: [PATCH 131/241] bicyclepower: add crank torque frequency support --- .../ANTPLUS_BicyclePowerDataPages.h | 1 + ...TPLUS_BicyclePowerCrankTorqueFrequency.cpp | 30 ++++++++++++++++++- ...ANTPLUS_BicyclePowerCrankTorqueFrequency.h | 22 ++++++++++++++ .../ANTPLUS_BicyclePowerStandardPowerOnly.h | 2 -- .../ANTPLUS_ProfileBicyclePowerDisplay.cpp | 16 +++++----- .../ANTPLUS_ProfileBicyclePowerDisplay.h | 7 +++-- 6 files changed, 64 insertions(+), 14 deletions(-) diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDataPages.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDataPages.h index 36fe808..2af9bce 100644 --- a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDataPages.h +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDataPages.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #endif // ANTPLUS_PROFILEBICYCLEPOWERDATAPAGES_h diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.cpp index 1c9e36d..62663fb 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.cpp @@ -1,3 +1,6 @@ +#include +#include + #define SLOPE_MSB_BYTE 2 #define SLOPE_LSB_BYTE 3 #define TIMESTAMP_MSB_BYTE 4 @@ -5,4 +8,29 @@ #define TORQUETICKSTAMP_MSB_BYTE 6 #define TORQUETICKSTAMP_LSB_BYTE 7 -// TODO +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() {} diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.h index e69de29..fe4685a 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.h +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.h @@ -0,0 +1,22 @@ +#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); +}; + +#endif // ANTPLUS_BICYCLEPOWERCRANKTORQUEFREQUENCY_h diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.h index 7e1cd67..0dd6cb6 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.h +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.h @@ -24,8 +24,6 @@ class BicyclePowerStandardPowerOnlyMsg : public BicyclePowerBaseMainDataPageMsg, void setUpdateEventCount(uint8_t eventCount); void setCumulativePowerCount(uint16_t accPower); void setInstataneousPowerCount(uint16_t power); -protected: - uint8_t _buffer[MESSAGE_SIZE]; }; #endif // ANTPLUS_BICYCLEPOWERSTANDARDPOWERONLY_h diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp index c375793..e6d61d6 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp @@ -5,14 +5,6 @@ #define DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE -ProfileBicyclePowerDisplay::ProfileBicyclePowerDisplay() : BaseSlaveProfile() { - setChannelConfig(); -} - -ProfileBicyclePowerDisplay::ProfileBicyclePowerDisplay(uint16_t deviceNumber) : BaseSlaveProfile(deviceNumber) { - setChannelConfig(); -} - ProfileBicyclePowerDisplay::ProfileBicyclePowerDisplay(uint16_t deviceNumber, uint8_t transmissionType) : BaseSlaveProfile(deviceNumber, transmissionType) { setChannelConfig(); } @@ -51,6 +43,9 @@ bool ProfileBicyclePowerDisplay::handleDataPage(BicyclePowerBaseMainDataPage& dp case BICYCLEPOWER_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: called = handleTorqueEffectivenessAndPedalSmoothness(dp); break; + case BICYCLEPOWER_CRANKTORQUEFREQUENCY_NUMBER: + called = handleCrankTorqueFrequency(dp); + break; } return called; @@ -97,6 +92,11 @@ bool ProfileBicyclePowerDisplay::handleStandardCrankTorque(BicyclePowerBaseMainD 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); diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.h b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.h index 2cbb06a..8131bb0 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.h +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.h @@ -7,15 +7,14 @@ class ProfileBicyclePowerDisplay : public BaseSlaveProfile { public: - ProfileBicyclePowerDisplay(); - ProfileBicyclePowerDisplay(uint16_t deviceNumber); - ProfileBicyclePowerDisplay(uint16_t deviceNumber, uint8_t transmissionType); + 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: @@ -30,6 +29,7 @@ class ProfileBicyclePowerDisplay : public BaseSlaveProfile { 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; @@ -37,6 +37,7 @@ class ProfileBicyclePowerDisplay : public BaseSlaveProfile { AntCallback _onProductInformation; AntCallback _onBicyclePowerStandardPowerOnly; AntCallback _onBicyclePowerStandardCrankTorque; + AntCallback _onBicyclePowerCrankTorqueFrequency; AntCallback _onBicyclePowerStandardWheelTorque; AntCallback _onBicyclePowerTorqueEffectivenessAndPedalSmoothness; }; From 4b1af6c57143800690ef64d4f5c13f35f6476c6d Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 7 Feb 2021 21:22:47 -0800 Subject: [PATCH 132/241] router: use open rx channel defines --- src/MainClasses/ANTPLUS_AntPlusRouter.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/MainClasses/ANTPLUS_AntPlusRouter.cpp b/src/MainClasses/ANTPLUS_AntPlusRouter.cpp index 6123b67..2245fac 100644 --- a/src/MainClasses/ANTPLUS_AntPlusRouter.cpp +++ b/src/MainClasses/ANTPLUS_AntPlusRouter.cpp @@ -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; From 3cf36fd445d7524fc838454c877d3cc92d7e8394 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 7 Feb 2021 21:36:32 -0800 Subject: [PATCH 133/241] common: fix magic nums and api set --- .../ANTPLUS_ManufacturersInformation.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/CommonDataPages/ANTPLUS_ManufacturersInformation.cpp b/src/CommonDataPages/ANTPLUS_ManufacturersInformation.cpp index 75f3430..3ca54ed 100644 --- a/src/CommonDataPages/ANTPLUS_ManufacturersInformation.cpp +++ b/src/CommonDataPages/ANTPLUS_ManufacturersInformation.cpp @@ -7,6 +7,9 @@ #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() : @@ -25,7 +28,7 @@ uint16_t BaseManufacturersInformation::getManufacturerID() { template uint16_t BaseManufacturersInformation::getModelNumber() { - return this->get16BitValue( MODELNUMBER_LSB_BYTE, MODELNUMBER_MSB_BYTE); + return this->get16BitValue(MODELNUMBER_LSB_BYTE, MODELNUMBER_MSB_BYTE); } template class BaseManufacturersInformation; @@ -35,14 +38,13 @@ ManufacturersInformation::ManufacturersInformation(AntRxDataResponse& dp) : BaseDataPage(dp), BaseManufacturersInformation() {} -// TODO Magic numbers ManufacturersInformationMsg::ManufacturersInformationMsg() : BaseDataPageMsg(), BaseManufacturersInformation() { setDataBuffer(_buffer); - _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = COMMON_MANUFACTURERSINFORMATION_NUMBER; - _buffer[1] = 0xFF; - _buffer[2] = 0xFF; + set8BitValue(COMMON_MANUFACTURERSINFORMATION_NUMBER, + ANTPLUS_DEFAULT_DATAPAGE_BYTE); + set16BitValue(RESERVED_VALUE, RESERVED_LSB_BYTE, RESERVED_MSB_BYTE); } void ManufacturersInformationMsg::setHWRevision(uint8_t revision) { From 4ee619ebb9300629be22f04fb5410e4b71faaf87 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 7 Feb 2021 23:59:06 -0800 Subject: [PATCH 134/241] bicyclepower: add TX types and fill out sensor push profile closer to completion --- .../ANTPLUS_BicyclePowerPrivateDefines.h | 2 -- ...TPLUS_BicyclePowerCrankTorqueFrequency.cpp | 17 ++++++++++ ...ANTPLUS_BicyclePowerCrankTorqueFrequency.h | 10 ++++++ ...NTPLUS_BicyclePowerStandardCrankTorque.cpp | 19 +++++++++++ .../ANTPLUS_BicyclePowerStandardCrankTorque.h | 15 ++++++++- ...NTPLUS_BicyclePowerStandardWheelTorque.cpp | 24 ++++++++++++-- .../ANTPLUS_BicyclePowerStandardWheelTorque.h | 15 ++++++++- ...rTorqueEffectivenessAndPedalSmoothness.cpp | 20 ++++++++++++ ...werTorqueEffectivenessAndPedalSmoothness.h | 18 +++++++++-- .../ANTPLUS_ProfileBicyclePowerSensor.cpp | 32 +++++++++++++++---- .../ANTPLUS_ProfileBicyclePowerSensor.h | 8 +++++ 11 files changed, 166 insertions(+), 14 deletions(-) diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h index 4ed7bde..12edd45 100644 --- a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h @@ -15,6 +15,4 @@ #define BICYCLEPOWER_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER 0x13 #define BICYCLEPOWER_CRANKTORQUEFREQUENCY_NUMBER 0x20 -/* Fixed Bytes */ - #endif // ANTPLUS_BICYCLEPOWERPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.cpp index 62663fb..66c58ed 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.cpp @@ -34,3 +34,20 @@ template class BicyclePowerBaseCrankTorqueFrequency; BicyclePowerCrankTorqueFrequency::BicyclePowerCrankTorqueFrequency(AntRxDataResponse& dp) : BicyclePowerBaseMainDataPage(dp), BicyclePowerBaseCrankTorqueFrequency() {} + +BicyclePowerCrankTorqueFrequencyMsg::BicyclePowerCrankTorqueFrequencyMsg() : + BicyclePowerBaseMainDataPageMsg(BICYCLEPOWER_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 index fe4685a..e16c309 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.h +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.h @@ -19,4 +19,14 @@ class BicyclePowerCrankTorqueFrequency : 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 index ee1a4b9..f470408 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.cpp @@ -39,3 +39,22 @@ template class BicyclePowerBaseStandardCrankTorque; BicyclePowerStandardCrankTorque::BicyclePowerStandardCrankTorque(AntRxDataResponse& dp) : BicyclePowerBaseMainDataPage(dp), BicyclePowerBaseStandardCrankTorque() {} + +BicyclePowerStandardCrankTorqueMsg::BicyclePowerStandardCrankTorqueMsg() : + BicyclePowerBaseMainDataPageMsg(BICYCLEPOWER_STANDARDCRANKTORQUE_NUMBER), + BicyclePowerBaseStandardCrankTorque() {} + +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 index f93cc23..949bd76 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.h +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.h @@ -13,9 +13,22 @@ class BicyclePowerBaseStandardCrankTorque : virtual public CoreDataPage { uint16_t getAccumulatedTorque(); }; -class BicyclePowerStandardCrankTorque : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseStandardCrankTorque { +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); //TODO is vaid check, May not be available, 0xFF indicates invalid + void setCrankPeriod(uint16_t period); + void setAccumulatedTorque(uint16_t torque); +}; + #endif // ANTPLUS_BICYCLEPOWERSTANDARDCRANKTORQUE_h diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.cpp index 923c75d..9ac7a61 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.cpp @@ -24,8 +24,7 @@ uint8_t BicyclePowerBaseStandardWheelTorque::getInstantaneousCadence() { template uint16_t BicyclePowerBaseStandardWheelTorque::getWheelPeriod() { - return this->get16BitValue( - WHEELPERIOD_LSB_BYTE, WHEELPERIOD_MSB_BYTE); + return this->get16BitValue(WHEELPERIOD_LSB_BYTE, WHEELPERIOD_MSB_BYTE); } template @@ -40,3 +39,24 @@ template class BicyclePowerBaseStandardWheelTorque; BicyclePowerStandardWheelTorque::BicyclePowerStandardWheelTorque(AntRxDataResponse& dp) : BicyclePowerBaseMainDataPage(dp), BicyclePowerBaseStandardWheelTorque() {} + +BicyclePowerStandardWheelTorqueMsg::BicyclePowerStandardWheelTorqueMsg() : + BicyclePowerBaseMainDataPageMsg(BICYCLEPOWER_STANDARDWHEELTORQUE_NUMBER), + BicyclePowerBaseStandardWheelTorque() {} + +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 index 84c9dac..2c688ca 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.h +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.h @@ -13,9 +13,22 @@ class BicyclePowerBaseStandardWheelTorque : virtual public CoreDataPage { uint16_t getAccumulatedTorque(); }; -class BicyclePowerStandardWheelTorque : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseStandardWheelTorque { +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); // TODO(is valid check) May not be available, 0xFF indicates invalid + 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 index d70ea18..5c7609e 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.cpp @@ -36,3 +36,23 @@ template class BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness template -class BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness : virtual public CoreDataPage { +class BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness : + virtual public CoreDataPage { public: BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness(); uint8_t getLeftTorqueEffectiveness(); @@ -13,9 +14,22 @@ class BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness : virtual public Cor uint8_t getRightPedalSmoothness(); }; -class BicyclePowerTorqueEffectivenessAndPedalSmoothness : public BicyclePowerBaseMainDataPage, public BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness { +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_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp index 0835bf5..7d63d0c 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -111,26 +111,33 @@ void ProfileBicyclePowerSensor::transmitBackgroundDataPage() { } void ProfileBicyclePowerSensor::transmitBicyclePowerStandardPowerOnlyMsg() { - // TODO BicyclePowerStandardPowerOnlyMsg msg; _createBicyclePowerStandardPowerOnlyMsg.call(msg); transmitMsg(msg); } void ProfileBicyclePowerSensor::transmitBicyclePowerStandardWheelTorqueMsg() { - // TODO + BicyclePowerStandardWheelTorqueMsg msg; + _createBicyclePowerStandardWheelTorqueMsg.call(msg); + transmitMsg(msg); } void ProfileBicyclePowerSensor::transmitBicyclePowerStandardCrankTorqueMsg() { - // TODO + BicyclePowerStandardCrankTorqueMsg msg; + _createBicyclePowerStandardCrankTorqueMsg.call(msg); + transmitMsg(msg); } void ProfileBicyclePowerSensor::transmitBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg() { - // TODO + BicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg msg; + _createBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg.call(msg); + transmitMsg(msg); } void ProfileBicyclePowerSensor::transmitBicyclePowerCrankTorqueFrequencyMsg() { - // TODO + BicyclePowerCrankTorqueFrequencyMsg msg; + _createBicyclePowerCrankTorqueFrequencyMsg.call(msg); + transmitMsg(msg); } void ProfileBicyclePowerSensor::transmistBicyclePowerGeneralCalibrationResponse() { @@ -145,8 +152,21 @@ uint8_t ProfileBicyclePowerSensor::getNextBackgroundPage(uint8_t currentPage) { void ProfileBicyclePowerSensor::transmitRequestedDataPage() { uint8_t requestedPage = getRequestedPage(); switch (requestedPage) { + // TODO rest of datapages case BICYCLEPOWER_STANDARDPOWERONLY_NUMBER: - // TODO + transmitBicyclePowerStandardPowerOnlyMsg(); + break; + case BICYCLEPOWER_STANDARDWHEELTORQUE_NUMBER: + transmitBicyclePowerStandardWheelTorqueMsg(); + break; + case BICYCLEPOWER_STANDARDCRANKTORQUE_NUMBER: + transmitBicyclePowerStandardCrankTorqueMsg(); + break; + case BICYCLEPOWER_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: + transmitBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg(); + break; + case BICYCLEPOWER_CRANKTORQUEFREQUENCY_NUMBER: + transmitBicyclePowerCrankTorqueFrequencyMsg(); break; } } diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h index 61133de..b31f37c 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h @@ -12,6 +12,10 @@ class ProfileBicyclePowerSensor : public BaseMasterProfile { * 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); } protected: void transmitNextDataPage(); @@ -36,6 +40,10 @@ class ProfileBicyclePowerSensor : public BaseMasterProfile { uint8_t getNextBackgroundPage(uint8_t currentPage); AntCallback _onRequestDataPage; AntCallback _createBicyclePowerStandardPowerOnlyMsg; + AntCallback _createBicyclePowerStandardWheelTorqueMsg; + AntCallback _createBicyclePowerStandardCrankTorqueMsg; + AntCallback _createBicyclePowerCrankTorqueFrequencyMsg; + AntCallback _createBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg; uint8_t _nextBackgroundPage; uint8_t _patternStep = 0; uint32_t _flags = 0; From 1ebe65bc432338fc0716efc08da4a65e8d8247b6 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 8 Feb 2021 00:49:53 -0800 Subject: [PATCH 135/241] common: add explicit constructor and optimize pio check fixes and remove redundant code --- src/BaseClasses/ANTPLUS_BaseSlaveProfile.cpp | 13 ++----------- src/BaseClasses/ANTPLUS_BaseSlaveProfile.h | 4 +--- src/CommonDataPages/ANTPLUS_BatteryStatus.h | 2 +- 3 files changed, 4 insertions(+), 15 deletions(-) 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/CommonDataPages/ANTPLUS_BatteryStatus.h b/src/CommonDataPages/ANTPLUS_BatteryStatus.h index c218102..675afdc 100644 --- a/src/CommonDataPages/ANTPLUS_BatteryStatus.h +++ b/src/CommonDataPages/ANTPLUS_BatteryStatus.h @@ -21,7 +21,7 @@ class BaseBatteryStatus : virtual public CoreDataPage { class BatteryStatus : public BaseDataPage, public BaseBatteryStatus { public: - BatteryStatus(AntRxDataResponse& dp); + explicit BatteryStatus(AntRxDataResponse& dp); }; class BatteryStatusMsg : public BaseDataPageMsg, public BaseBatteryStatus { From db5be391cb0dca3293f032fa66e56127bab20b8c Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 8 Feb 2021 00:50:32 -0800 Subject: [PATCH 136/241] bicyclepower: add initializer for callbacks silences cppcheck --- .../ANTPLUS_ProfileBicyclePowerDisplay.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.h b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.h index 8131bb0..be4bc17 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.h +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.h @@ -32,14 +32,14 @@ class ProfileBicyclePowerDisplay : public BaseSlaveProfile { bool handleCrankTorqueFrequency(BicyclePowerBaseMainDataPage& dataPage); bool handleStandardWheelTorque(BicyclePowerBaseMainDataPage& dataPage); bool handleTorqueEffectivenessAndPedalSmoothness(BicyclePowerBaseMainDataPage& dataPage); - AntCallback _onBatteryStatus; - AntCallback _onManufacturersInformation; - AntCallback _onProductInformation; - AntCallback _onBicyclePowerStandardPowerOnly; - AntCallback _onBicyclePowerStandardCrankTorque; - AntCallback _onBicyclePowerCrankTorqueFrequency; - AntCallback _onBicyclePowerStandardWheelTorque; - AntCallback _onBicyclePowerTorqueEffectivenessAndPedalSmoothness; + 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 From 9dbd8cc051edc1819328f945269e43bd350f1866 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 8 Feb 2021 00:53:31 -0800 Subject: [PATCH 137/241] bicyclespeed: add callback initializer fixes cppcheck --- .../Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.h b/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.h index fdebac2..3dbc004 100644 --- a/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.h +++ b/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.h @@ -29,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 From 48a3edae8dd3c7094d5980ee157955a2efff6e3c Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 8 Feb 2021 00:54:55 -0800 Subject: [PATCH 138/241] environment: add callback initializers silence cppcheck --- .../Profiles/ANTPLUS_ProfileEnvironmentDisplay.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.h b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.h index 178c7dd..c255f6c 100644 --- a/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.h +++ b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.h @@ -26,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 From 60eed48447bd76aeb93f6384a21c711297cbc129 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 8 Feb 2021 00:58:02 -0800 Subject: [PATCH 139/241] bicyclepower: add callback initializers silences cppcheck --- .../Profiles/ANTPLUS_ProfileBicyclePowerSensor.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h index b31f37c..4b16584 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h @@ -38,12 +38,12 @@ class ProfileBicyclePowerSensor : public BaseMasterProfile { bool handleRequestDataPage(BicyclePowerStandardPowerOnly& dataPage); bool handleGeneralCalibration(BicyclePowerStandardPowerOnly& dataPage); uint8_t getNextBackgroundPage(uint8_t currentPage); - AntCallback _onRequestDataPage; - AntCallback _createBicyclePowerStandardPowerOnlyMsg; - AntCallback _createBicyclePowerStandardWheelTorqueMsg; - AntCallback _createBicyclePowerStandardCrankTorqueMsg; - AntCallback _createBicyclePowerCrankTorqueFrequencyMsg; - AntCallback _createBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg; + AntCallback _onRequestDataPage = { .func = NULL }; + AntCallback _createBicyclePowerStandardPowerOnlyMsg = { .func = NULL }; + AntCallback _createBicyclePowerStandardWheelTorqueMsg = { .func = NULL }; + AntCallback _createBicyclePowerStandardCrankTorqueMsg = { .func = NULL }; + AntCallback _createBicyclePowerCrankTorqueFrequencyMsg = { .func = NULL }; + AntCallback _createBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg = { .func = NULL }; uint8_t _nextBackgroundPage; uint8_t _patternStep = 0; uint32_t _flags = 0; From b0263fdb606c075e3944bf082e555dacb0e40240 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 8 Feb 2021 00:59:38 -0800 Subject: [PATCH 140/241] bicyclepower: add override to silence cppcheck --- .../Profiles/ANTPLUS_ProfileBicyclePowerSensor.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h index 4b16584..226b499 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h @@ -18,10 +18,10 @@ class ProfileBicyclePowerSensor : public BaseMasterProfile { void createBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg(void (*func)(BicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg&, uintptr_t), uintptr_t data = 0) { _createBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg.set(func, data); } protected: - void transmitNextDataPage(); - void onAcknowledgedData(AcknowledgedData& msg); - void onBroadcastData(BroadcastData& msg); - bool isDataPageValid(uint8_t dataPage); + void transmitNextDataPage() override; + void onAcknowledgedData(AcknowledgedData& msg) override; + void onBroadcastData(BroadcastData& msg) override; + bool isDataPageValid(uint8_t dataPage) override; private: void setChannelConfig(); void transmitPrimaryDataPage(); From 4d7b61fb9ec4e9d9e03bb744cf54ac79de6f12bc Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 8 Feb 2021 01:01:26 -0800 Subject: [PATCH 141/241] HeartRate: initialize callbacks silence cppcheck --- .../ANTPLUS_ProfileHeartRateMonitor.h | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.h b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.h index 44ab906..90d65ee 100644 --- a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.h +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.h @@ -79,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; From 0e03c8e44f212e4bacaded77107d28224dcbc49e Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 8 Feb 2021 23:13:53 -0800 Subject: [PATCH 142/241] fec: optimize constructors for display --- src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp | 8 -------- src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h | 4 +--- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp index 16c0fd2..50fc368 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp @@ -1,14 +1,6 @@ #include #include -ProfileFecDisplay::ProfileFecDisplay() : BaseSlaveProfile() { - setChannelConfig(); -} - -ProfileFecDisplay::ProfileFecDisplay(uint16_t deviceNumber) : BaseSlaveProfile(deviceNumber) { - setChannelConfig(); -} - ProfileFecDisplay::ProfileFecDisplay(uint16_t deviceNumber, uint8_t transmissionType) : BaseSlaveProfile(deviceNumber, transmissionType) { setChannelConfig(); } diff --git a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h index 3920131..7e16983 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h @@ -7,9 +7,7 @@ class ProfileFecDisplay : public BaseSlaveProfile { public: - ProfileFecDisplay(); - ProfileFecDisplay(uint16_t deviceNumber); - ProfileFecDisplay(uint16_t deviceNumber, uint8_t transmissionType); + ProfileFecDisplay(uint16_t deviceNumber = 0, uint8_t transmissionType = 0); void onFecTrainerData(void (*func)(FecSpecificTrainerData&, uintptr_t), uintptr_t data = 0) { _onFecSpecificTrainerData.set(func, data); } private: From 812a0fe0aa13d01dd20491543a8c023ee28ee013 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 8 Feb 2021 23:15:15 -0800 Subject: [PATCH 143/241] fec: initialize all members silence cppcheck --- src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h index 7e16983..6d7c471 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h @@ -18,7 +18,7 @@ class ProfileFecDisplay : public BaseSlaveProfile { bool handleDataPage(BaseDataPage& dp); bool handleTrainerData(BaseDataPage& dataPage); - AntCallback _onFecSpecificTrainerData; + AntCallback _onFecSpecificTrainerData = { .func = NULL }; }; #endif // ANTPLUS_PROFILEFECDISPLAY_h From b77261a0bc10c719cceae2fa158f35022dd642c9 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 8 Feb 2021 23:16:22 -0800 Subject: [PATCH 144/241] heartrate: display: initialize all members silence cppcheck --- .../Profiles/ANTPLUS_ProfileHeartRateDisplay.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.h b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.h index a057b70..b926b00 100644 --- a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.h +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.h @@ -34,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 From d1f8c46b433003ad51c83f51972bf4e30d670fc8 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 8 Feb 2021 23:17:55 -0800 Subject: [PATCH 145/241] lev: display: optimize constructors --- src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.cpp | 8 -------- src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.h | 4 +--- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.cpp b/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.cpp index d8dad74..4c16287 100644 --- a/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.cpp +++ b/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.cpp @@ -5,14 +5,6 @@ #define DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE -ProfileLevDisplay::ProfileLevDisplay() : BaseSlaveProfile() { - setChannelConfig(); -} - -ProfileLevDisplay::ProfileLevDisplay(uint16_t deviceNumber) : BaseSlaveProfile(deviceNumber) { - setChannelConfig(); -} - ProfileLevDisplay::ProfileLevDisplay(uint16_t deviceNumber, uint8_t transmissionType) : BaseSlaveProfile(deviceNumber, transmissionType) { setChannelConfig(); } diff --git a/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.h b/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.h index b4e7d6a..f46a110 100644 --- a/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.h +++ b/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.h @@ -7,9 +7,7 @@ class ProfileLevDisplay : public BaseSlaveProfile { public: - ProfileLevDisplay(); - explicit ProfileLevDisplay(uint16_t deviceNumber); - explicit 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); } From 8c443577cdacbad40745d63636ed7627bf531ee0 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 8 Feb 2021 23:19:08 -0800 Subject: [PATCH 146/241] lev: display: initialize all members silence cppcheck --- .../Lev/Profiles/ANTPLUS_ProfileLevDisplay.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.h b/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.h index f46a110..0b04e95 100644 --- a/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.h +++ b/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.h @@ -33,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 From 5f1eef8828f0681876143f41bf9ea859519e8ed8 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 8 Feb 2021 23:19:55 -0800 Subject: [PATCH 147/241] bicyclepower: sensor: mark constructor as explicit silence cppcheck --- .../BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h index 226b499..4ddfd7e 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h @@ -7,7 +7,7 @@ class ProfileBicyclePowerSensor : public BaseMasterProfile { public: - ProfileBicyclePowerSensor(uint16_t deviceNumber, uint8_t transmissionType = 0, uint32_t flags = 0); + explicit ProfileBicyclePowerSensor(uint16_t deviceNumber, uint8_t transmissionType = 0, uint32_t flags = 0); /** * Register callback to populate default data messages (Datapage 0) */ From 1685a8b7d2750943ca3c0f1e3acdc9b073832a25 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 8 Feb 2021 23:21:23 -0800 Subject: [PATCH 148/241] shifting: shifter: initialize all members silence cppcheck --- .../Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.h b/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.h index d8f3ddd..44bfe59 100644 --- a/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.h +++ b/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.h @@ -60,11 +60,11 @@ class ProfileShiftingShifter : public BaseMasterProfile { uint8_t _interleaveStep; uint8_t _componentCount = 0; - AntCallback _createShiftingShiftSystemStatusMsg; - AntCallback _createMultiComponentSystemManufacturersInformationMsg; - AntCallback _createMultiComponentSystemProductInformationMsg; - AntCallback _createBatteryStatusMsg; - AntCallback _onRequestDataPage; + AntCallback _createShiftingShiftSystemStatusMsg = { .func = NULL }; + AntCallback _createMultiComponentSystemManufacturersInformationMsg = { .func = NULL }; + AntCallback _createMultiComponentSystemProductInformationMsg = { .func = NULL }; + AntCallback _createBatteryStatusMsg = { .func = NULL }; + AntCallback _onRequestDataPage = { .func = NULL }; }; #endif // ANTPLUS_PROFILESHIFTINGSHIFTER_h From 0694b1fb8ed5e4b911b60f394aff566d8fa4d992 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 8 Feb 2021 23:22:25 -0800 Subject: [PATCH 149/241] MuscleOxygen: Monitor: initialize all members silence cppcheck --- .../Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h index 8005a83..8faaee5 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h @@ -37,10 +37,10 @@ class ProfileMuscleOxygenMonitor : public BaseMasterProfile { uint8_t _patternStep; uint8_t _backgroundStep; - AntCallback _createMuscleOxygenMuscleOxygenDataMsg; - AntCallback _createManufacturersInformationMsg; - AntCallback _createProductInformationMsg; - AntCallback _createBatteryStatusMsg; + AntCallback _createMuscleOxygenMuscleOxygenDataMsg = { .func = NULL }; + AntCallback _createManufacturersInformationMsg = { .func = NULL }; + AntCallback _createProductInformationMsg = { .func = NULL }; + AntCallback _createBatteryStatusMsg = { .func = NULL }; }; #endif // ANTPLUS_PROFILEMUSCLEOXYGENMONITOR_h From 8b70da4f7e4880afd47e1e2a62383161df407405 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 8 Feb 2021 23:28:14 -0800 Subject: [PATCH 150/241] core: remove some whitespace --- src/BaseClasses/ANTPLUS_CoreDataPage.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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() { From 489bf465f2e2df2e23a18db6ff9a918b35c8d3dc Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 8 Feb 2021 23:31:42 -0800 Subject: [PATCH 151/241] Fec: add overrides silence cppcheck --- src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h index 6d7c471..08cff44 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h @@ -12,8 +12,8 @@ class ProfileFecDisplay : public BaseSlaveProfile { private: void setChannelConfig(); - void onBroadcastData(BroadcastData& msg); - void onAcknowledgedData(AcknowledgedData& msg); + void onBroadcastData(BroadcastData& msg) override; + void onAcknowledgedData(AcknowledgedData& msg) override; bool handleDataPage(BaseDataPage& dp); From 127518c65a80074e2dd037a44c783986132b03ac Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 8 Feb 2021 23:35:54 -0800 Subject: [PATCH 152/241] cppcheck: add some more explicit keywords make cppcheck happy --- .../HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.h | 2 +- .../Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.h | 2 +- .../Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.h | 2 +- .../DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.h b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.h index 90d65ee..d372575 100644 --- a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.h +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.h @@ -8,7 +8,7 @@ class ProfileHeartRateMonitor : public BaseMasterProfile { public: - ProfileHeartRateMonitor(uint16_t deviceNumber, uint8_t transmissionType = 0, uint32_t flags = 0); + explicit ProfileHeartRateMonitor(uint16_t deviceNumber, uint8_t transmissionType = 0, uint32_t flags = 0); /** * Register callback to populate default data messages (Datapage 0) */ diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.h index 5877ed0..b848f05 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.h @@ -5,7 +5,7 @@ class LevBaseSpeedDistanceInformation : public LevBaseMainDataPage { public: - LevBaseSpeedDistanceInformation(AntRxDataResponse& dp); + explicit LevBaseSpeedDistanceInformation(AntRxDataResponse& dp); uint32_t getOdometer(); // in km uint16_t getLevSpeed(); // in 1/10 km/h }; diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.h index d67315c..05e881e 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.h @@ -5,7 +5,7 @@ class LevSpeedDistanceInformation : public LevBaseSpeedDistanceInformation { public: - LevSpeedDistanceInformation(AntRxDataResponse& dp); + explicit LevSpeedDistanceInformation(AntRxDataResponse& dp); uint16_t getRemainingRange(); // in km }; diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h index 1d31e0f..a9acdb3 100644 --- a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h +++ b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h @@ -8,7 +8,7 @@ class ShiftingBaseMainDataPageMsg : public BaseDataPageMsg, public ShiftingCoreMainDataPage { public: - ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber); + explicit ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber); protected: uint8_t _buffer[MESSAGE_SIZE]; }; From c72dc17758887c90954aae07ad41c2567297bf45 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 8 Feb 2021 23:48:43 -0800 Subject: [PATCH 153/241] shifting: remove core class there are no common fields to the whole profile, it has one datapage --- .../Shifting/ANTPLUS_ShiftingPrivateDefines.h | 3 --- .../Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp | 2 +- .../Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h | 3 +-- .../Base/ANTPLUS_ShiftingCoreMainDataPage.cpp | 14 -------------- .../Base/ANTPLUS_ShiftingCoreMainDataPage.h | 15 --------------- .../Profiles/ANTPLUS_ProfileShiftingShifter.h | 8 ++++---- 6 files changed, 6 insertions(+), 39 deletions(-) delete mode 100644 src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingCoreMainDataPage.cpp delete mode 100644 src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingCoreMainDataPage.h diff --git a/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h b/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h index 7c7d6cf..67afbb7 100644 --- a/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h +++ b/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h @@ -13,7 +13,4 @@ /* Pages */ #define ANTPLUS_SHIFTING_DATAPAGE_SHIFTSYSTEMSTATUS_NUMBER 1 -// Base page */ -#define ANTPLUS_SHIFTING_DATAPAGEBASE_DATAPAGE_BYTE 0x00 - #endif // ANTPLUS_SHIFTINGPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp index 8accc18..365ebef 100644 --- a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp +++ b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp @@ -10,6 +10,6 @@ ShiftingBaseMainDataPageMsg::ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber) { memset(_buffer, 0, MESSAGE_SIZE); setDataBuffer(_buffer); - set8BitValue(dataPageNumber, ANTPLUS_SHIFTING_DATAPAGEBASE_DATAPAGE_BYTE); + set8BitValue(dataPageNumber, ANTPLUS_DEFAULT_DATAPAGE_BYTE); set8BitValue(RESERVED_VALUE, RESERVED_BYTE); } diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h index a9acdb3..2a6b2d8 100644 --- a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h +++ b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h @@ -2,11 +2,10 @@ #define ANTPLUS_SHIFTINGBASEMAINDATAPAGEMSG_h #include -#include #include "ANT.h" -class ShiftingBaseMainDataPageMsg : public BaseDataPageMsg, public ShiftingCoreMainDataPage { +class ShiftingBaseMainDataPageMsg : public BaseDataPageMsg { public: explicit ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber); protected: diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingCoreMainDataPage.cpp b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingCoreMainDataPage.cpp deleted file mode 100644 index 41a3bf6..0000000 --- a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingCoreMainDataPage.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include - -template -ShiftingCoreMainDataPage::ShiftingCoreMainDataPage() : CoreDataPage() { -} - -template -uint8_t ShiftingCoreMainDataPage::getDataPageNumber() { - return this->get8BitValue(ANTPLUS_SHIFTING_DATAPAGEBASE_DATAPAGE_BYTE); -} - -template class ShiftingCoreMainDataPage; -template class ShiftingCoreMainDataPage; diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingCoreMainDataPage.h b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingCoreMainDataPage.h deleted file mode 100644 index 54b4d27..0000000 --- a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingCoreMainDataPage.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef ANTPLUS_SHIFTINGCOREMAINDATAPAGEMSG_h -#define ANTPLUS_SHIFTINGCOREMAINDATAPAGEMSG_h - -#include - -#include "ANT.h" - -template -class ShiftingCoreMainDataPage : virtual public CoreDataPage { -public: - ShiftingCoreMainDataPage(); - uint8_t getDataPageNumber(); -}; - -#endif // ANTPLUS_SHIFTINGCOREMAINDATAPAGEMSG_h diff --git a/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.h b/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.h index 44bfe59..4daf6d5 100644 --- a/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.h +++ b/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.h @@ -34,10 +34,10 @@ class ProfileShiftingShifter : public BaseMasterProfile { void onRequestDataPage(void (*func)(RequestDataPage&, uintptr_t), uintptr_t data = 0) { _onRequestDataPage.set(func, data); } protected: - virtual void transmitNextDataPage(); - virtual bool isDataPageValid(uint8_t dataPage); - void onAcknowledgedData(AcknowledgedData& msg); - void onBroadcastData(BroadcastData& msg); + virtual void transmitNextDataPage() override; + virtual bool isDataPageValid(uint8_t dataPage) override; + void onAcknowledgedData(AcknowledgedData& msg) override; + void onBroadcastData(BroadcastData& msg) override; private: void transmitShiftingMainPageMsg(); From 06be04b0f181de90fb4e4e02526e739118e84541 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 8 Feb 2021 23:58:56 -0800 Subject: [PATCH 154/241] fec: remove unneccessary func this is defined in parent classes --- .../Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp | 5 ----- src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.h | 1 - 2 files changed, 6 deletions(-) diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp index aa12307..68183f3 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp @@ -16,11 +16,6 @@ template FecBaseSpecificTrainerData::FecBaseSpecificTrainerData() : CoreDataPage() {} -template -uint8_t FecBaseSpecificTrainerData::getDataPageNumber() { - return this->get8BitValue(ANTPLUS_DEFAULT_DATAPAGE_BYTE); -} - template uint8_t FecBaseSpecificTrainerData::getUpdateEventCount() { return this->get8BitValue(UPDATEEVENTCOUNT_BYTE); diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.h index a7e863e..675b279 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.h +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.h @@ -7,7 +7,6 @@ template class FecBaseSpecificTrainerData : virtual public CoreDataPage { public: FecBaseSpecificTrainerData(); - uint8_t getDataPageNumber(); uint8_t getUpdateEventCount(); uint8_t getInstantaneousCadence(); uint16_t getAccumulatedPower(); From d9eb4cc418cebaf995a186900defebd3166e1f8c Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 9 Feb 2021 00:02:34 -0800 Subject: [PATCH 155/241] muscleoxygen: monitor: add override flags make cppcheck happy --- .../MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h index 8faaee5..f701b06 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h @@ -24,8 +24,8 @@ class ProfileMuscleOxygenMonitor : public BaseMasterProfile { void createProductInformationMsg(void(*func)(ProductInformationMsg&, uintptr_t), uintptr_t data = 0) { _createProductInformationMsg.set(func, data); } protected: - void transmitNextDataPage(); - bool isDataPageValid(uint8_t dataPage); + void transmitNextDataPage() override; + bool isDataPageValid(uint8_t dataPage) override; private: void setChannelConfig(); From cae00835ed75d121ad2f982b8648895689ffa77d Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 9 Feb 2021 00:03:29 -0800 Subject: [PATCH 156/241] environment: monitor: add explicit flags to construct silence cppcheck --- .../Environment/Profiles/ANTPLUS_ProfileEnvironmentMonitor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentMonitor.h b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentMonitor.h index 8a64eb4..eb60f67 100644 --- a/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentMonitor.h +++ b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentMonitor.h @@ -8,7 +8,7 @@ class ProfileEnvironmentMonitor : BaseMasterProfile { public: // TODO - ProfileEnvironmentMonitor(uint16_t deviceNumber, uint8_t transmissionType = 0); + explicit ProfileEnvironmentMonitor(uint16_t deviceNumber, uint8_t transmissionType = 0); }; #endif // ANTPLUS_PROFILEENVIRONMENTMONITOR_h From 9cdfa334eb873457b0e819ec5bd1be48d23f5b00 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 9 Feb 2021 00:37:31 -0800 Subject: [PATCH 157/241] profiles: add comments name level out logic easier to read if its flatter --- .../ANTPLUS_ProfileHeartRateMonitor.cpp | 29 ++++++++++--------- .../ANTPLUS_ProfileMuscleOxygenMonitor.cpp | 1 + 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp index caab651..5f9845f 100644 --- a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp @@ -7,6 +7,7 @@ #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, @@ -60,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; } } } @@ -76,12 +78,13 @@ void ProfileHeartRateMonitor::transmitNextDataPage() { void ProfileHeartRateMonitor::transmitPrimaryDataPage() { if (_sportsMode == ANTPLUS_COMMON_DATAPAGE_MODESETTINGS_SPORTSMODE_SWIMMING) { transmitHeartRateSwimIntervalSummaryMsg(); + return; + } + + if (_flags & ANTPLUS_HEARTRATE_FLAGS_PREVIOUSHEARTBEAT_SUPPORTED) { + transmitHeartRatePreviousHeartBeatMsg(); } else { - if (_flags & ANTPLUS_HEARTRATE_FLAGS_PREVIOUSHEARTBEAT_SUPPORTED) { - transmitHeartRatePreviousHeartBeatMsg(); - } else { - transmitHeartRateDefaultMsg(); - } + transmitHeartRateDefaultMsg(); } } diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp index 4472f5d..ba35f98 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp @@ -31,6 +31,7 @@ bool ProfileMuscleOxygenMonitor::isDataPageValid(uint8_t dataPage) { return false; } +// TODO add check for batterystatus callback void ProfileMuscleOxygenMonitor::transmitNextDataPage() { if (_patternStep++ < 64) { transmitMuscleOxygenMuscleOxygenDataMsg(); From 734e1a6d616acbc2cbf5cabe0c91fa46795587eb Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 9 Feb 2021 00:40:17 -0800 Subject: [PATCH 158/241] MuscleOxygen: delete empty file artifact of refactor --- .../DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.cpp diff --git a/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.cpp b/src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMuscleOxygenData.cpp deleted file mode 100644 index e69de29..0000000 From a5d2169f47a6d69b85cf5cf7acb6f8cd5cdff688 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 9 Feb 2021 20:42:00 -0800 Subject: [PATCH 159/241] MuscleOxygen: add commands datapage also base RX datapage --- .../ANTPLUS_MuscleOxygenPrivateDefines.h | 1 + .../ANTPLUS_MuscleOxygenBaseMainDataPage.cpp | 4 +- .../ANTPLUS_MuscleOxygenBaseMainDataPage.h | 5 ++ .../ANTPLUS_MuscleOxygenCommands.cpp | 50 +++++++++++++++++++ .../DataPages/ANTPLUS_MuscleOxygenCommands.h | 32 ++++++++++++ 5 files changed, 91 insertions(+), 1 deletion(-) diff --git a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h index 400a7b7..1162861 100644 --- a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h +++ b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h @@ -13,6 +13,7 @@ /* Pages */ #define MUSCLEOXYGEN_MUSCLEOXYGENDATA_NUMBER 1 +#define MUSCLEOXYGEN_COMMANDS_NUMBER 16 // Base page */ #define ANTPLUS_MUSCLEOXYGEN_DATAPAGEBASE_DATAPAGE_BYTE 0x00 diff --git a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.cpp b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.cpp index 82e70a3..aed0225 100644 --- a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.cpp +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.cpp @@ -1,7 +1,9 @@ #include #include -// TODO setup core +MuscleOxygenBaseMainDataPage::MuscleOxygenBaseMainDataPage(AntRxDataResponse& dp) : + BaseDataPage(dp) {} + MuscleOxygenBaseMainDataPageMsg::MuscleOxygenBaseMainDataPageMsg(uint8_t dataPageNumber) : BaseDataPageMsg() { memset(_buffer, 0, MESSAGE_SIZE); setDataBuffer(_buffer); diff --git a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.h b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.h index 05624d7..208c888 100644 --- a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.h +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.h @@ -4,6 +4,11 @@ #include #include +class MuscleOxygenBaseMainDataPage : public BaseDataPage { +public: + explicit MuscleOxygenBaseMainDataPage(AntRxDataResponse& dp); +}; + class MuscleOxygenBaseMainDataPageMsg : public BaseDataPageMsg { public: explicit MuscleOxygenBaseMainDataPageMsg(uint8_t dataPageNumber); diff --git a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenCommands.cpp b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenCommands.cpp index e69de29..c6a28a9 100644 --- a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenCommands.cpp +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenCommands.cpp @@ -0,0 +1,50 @@ +#include +#include + +#define COMMANDID_BYTE 1 +#define LOCALTIMEOFFSET_BYTE 3 +#define CURRENTTIMETIMESTAMP_LSB_BYTE 4 +#define CURRENTTIMETIMESTAMP_MSB_BYTE 7 + +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(MUSCLEOXYGEN_COMMANDS_NUMBER), + MuscleOxygenBaseCommands() {} + +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 index e69de29..183c2e2 100644 --- a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenCommands.h +++ 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 From 5e5c02c044fb61a9acd7d965e75b84aac11c258b Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 9 Feb 2021 20:43:46 -0800 Subject: [PATCH 160/241] lev: update set call --- src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.cpp index d16466e..b311e8b 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.cpp @@ -7,5 +7,5 @@ LevBaseMainDataPage::LevBaseMainDataPage(AntRxDataResponse& dp) : LevBaseMainDataPageMsg::LevBaseMainDataPageMsg(uint8_t dataPageNumber) : BaseDataPageMsg() { setDataBuffer(_buffer); - _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = dataPageNumber; + set8BitValue(dataPageNumber, ANTPLUS_DEFAULT_DATAPAGE_BYTE); } From 2ae4378a2c6cbf091f142949b57b38c1ee1f223c Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 15 Feb 2021 17:26:21 -0800 Subject: [PATCH 161/241] MuscleOxygen: set reserver byte for command msg --- .../DataPages/ANTPLUS_MuscleOxygenCommands.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenCommands.cpp b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenCommands.cpp index c6a28a9..7e68609 100644 --- a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenCommands.cpp +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenCommands.cpp @@ -2,10 +2,13 @@ #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() {} @@ -34,7 +37,9 @@ MuscleOxygenCommands::MuscleOxygenCommands(AntRxDataResponse& dp) : MuscleOxygenCommandsMsg::MuscleOxygenCommandsMsg() : MuscleOxygenBaseMainDataPageMsg(MUSCLEOXYGEN_COMMANDS_NUMBER), - MuscleOxygenBaseCommands() {} + MuscleOxygenBaseCommands() { + set8BitValue(RESERVED_VALUE, RESERVED_BYTE); +} void MuscleOxygenCommandsMsg::setCommandId(uint8_t id) { set8BitValue(id, COMMANDID_BYTE); From 6fad78c216ec2918dc104c6b67d9d6eec86507b3 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 26 Apr 2021 00:36:56 -0700 Subject: [PATCH 162/241] MuscleOxygen: add batterystatus support profile optionally supports it --- .../ANTPLUS_MuscleOxygenDefines.h | 2 ++ .../ANTPLUS_ProfileMuscleOxygenMonitor.cpp | 24 +++++++++++-------- .../ANTPLUS_ProfileMuscleOxygenMonitor.h | 8 ++++--- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h index 7d290d0..959f4bb 100644 --- a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h +++ b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h @@ -3,6 +3,8 @@ #define ANTPLUS_MUSCLEOXYGEN_DEVICETYPE 31 +#define ANTPLUS_MUSCLEOXYGEN_FLAGS_BATTERYSTATUS_SUPPORTED (1 << 0) + #define ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_TOTALHEMOGLOBINCONCENTRATION_AMBIENTLIGHTOOHIGH 0xFFE #define ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_TOTALHEMOGLOBINCONCENTRATION_INVALID 0xFFF #define ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_PREVIOUSSATURATEDHEMOGLOBINPERCENTAGE_INVALID 0xFFF diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp index ba35f98..786e3fb 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp @@ -5,14 +5,14 @@ #define MONITOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT #define MONITOR_TRANSMISSIONTYPE (TRANSMISSION_TYPE_INDEPENDENT | TRANSMISSION_TYPE_GLOBALDATAPGESUSED) -ProfileMuscleOxygenMonitor::ProfileMuscleOxygenMonitor( uint16_t deviceNumber, uint8_t transmissionType) : +ProfileMuscleOxygenMonitor::ProfileMuscleOxygenMonitor( uint16_t deviceNumber, uint8_t transmissionType, uint32_t flags) : BaseMasterProfile(deviceNumber, ANTPLUS_TRANSMISSION_SET_LSN( - transmissionType, MONITOR_TRANSMISSIONTYPE)), - _patternStep(0), - _backgroundStep(0) + transmissionType, MONITOR_TRANSMISSIONTYPE)) { setChannelConfig(); + // change the background cycle loop size + _backgroundStepSize = 2 + (flags & ANTPLUS_MUSCLEOXYGEN_FLAGS_BATTERYSTATUS_SUPPORTED ? 1 : 0); } void ProfileMuscleOxygenMonitor::setChannelConfig() { @@ -26,22 +26,24 @@ bool ProfileMuscleOxygenMonitor::isDataPageValid(uint8_t dataPage) { switch (dataPage) { case MUSCLEOXYGEN_MUSCLEOXYGENDATA_NUMBER: return true; - // TODO other datapages + case COMMON_BATTERYSTATUS_NUMBER: + return _flags & ANTPLUS_MUSCLEOXYGEN_FLAGS_BATTERYSTATUS_SUPPORTED; } return false; } -// TODO add check for batterystatus callback void ProfileMuscleOxygenMonitor::transmitNextDataPage() { if (_patternStep++ < 64) { transmitMuscleOxygenMuscleOxygenDataMsg(); } else { - if (_backgroundStep++ % 2 == 0) { + if ((_backgroundStep++ % _backgroundStepSize) == 0) { transmitManufacturerInformationMsg(); - } - else { + _backgroundStep = 0; + } else if ((_backgroundStep % _backgroundStepSize) == 1) { transmitProductInformationMsg(); + } else if (_flags & ANTPLUS_MUSCLEOXYGEN_FLAGS_BATTERYSTATUS_SUPPORTED) { + transmitBatteryStatusMsg(); } _patternStep = 0; } @@ -66,5 +68,7 @@ void ProfileMuscleOxygenMonitor::transmitMuscleOxygenMuscleOxygenDataMsg() { } void ProfileMuscleOxygenMonitor::transmitBatteryStatusMsg() { - // TODO + 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 index f701b06..87ec99c 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h @@ -8,7 +8,7 @@ class ProfileMuscleOxygenMonitor : public BaseMasterProfile { public: - explicit ProfileMuscleOxygenMonitor(uint16_t deviceNumber, uint8_t transmissionType = 0); + explicit ProfileMuscleOxygenMonitor(uint16_t deviceNumber, uint8_t transmissionType = 0, uint32_t flags = 0); /** * Register callback to populate Muscle Oxygen data messages (Datapage 0) @@ -34,8 +34,10 @@ class ProfileMuscleOxygenMonitor : public BaseMasterProfile { void transmitProductInformationMsg(); void transmitBatteryStatusMsg(); - uint8_t _patternStep; - uint8_t _backgroundStep; + uint8_t _patternStep = 0; + uint8_t _backgroundStep = 0; + uint8_t _backgroundStepSize = 0; + uint32_t _flags; AntCallback _createMuscleOxygenMuscleOxygenDataMsg = { .func = NULL }; AntCallback _createManufacturersInformationMsg = { .func = NULL }; From fbf1633decb75807d1b0940c79c5405cd33cf714 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 26 Apr 2021 23:02:59 -0700 Subject: [PATCH 163/241] ci: fix unit tests something broke in platformio --- .github/workflows/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f492cd1..971f614 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -86,6 +86,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 From b23977a2e2efa0a1c8b475229381d5a5a331b832 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 26 Apr 2021 23:15:18 -0700 Subject: [PATCH 164/241] moxy: add support for requesting required common pages product and manufacturer info are required, so they should be requestable --- .../MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp index 786e3fb..38e4b20 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp @@ -25,6 +25,8 @@ void ProfileMuscleOxygenMonitor::setChannelConfig() { bool ProfileMuscleOxygenMonitor::isDataPageValid(uint8_t dataPage) { switch (dataPage) { case MUSCLEOXYGEN_MUSCLEOXYGENDATA_NUMBER: + case COMMON_PRODUCTINFORMATION_NUMBER: + case COMMON_MANUFACTURERSINFORMATION_NUMBER: return true; case COMMON_BATTERYSTATUS_NUMBER: return _flags & ANTPLUS_MUSCLEOXYGEN_FLAGS_BATTERYSTATUS_SUPPORTED; From d44e809d99f855970e96fdf55087bad98f41b785 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 2 May 2021 17:02:07 -0700 Subject: [PATCH 165/241] BicyclePower: Refactor transmission patterns So upon further reading of the profile doc it appears this profile is much more complex as it houses 4 different underlying types of power sensors each with their own transmission pattern. Therefore lets break this out for each sensor so we don't end up with spaghetti code. --- .../ANTPLUS_BicyclePowerPrivateDefines.h | 6 ++ .../ANTPLUS_ProfileBicyclePowerSensor.cpp | 76 +++++++++---------- .../ANTPLUS_ProfileBicyclePowerSensor.h | 7 +- 3 files changed, 46 insertions(+), 43 deletions(-) diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h index 12edd45..4dee1f7 100644 --- a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h @@ -8,6 +8,12 @@ // 30 / 2.5 = 12 #define BICYCLEPOWER_SEARCHTIMEOUT 12 +/* Sensor Types */ +#define BICYCLEPOWER_SENSORTYPE_POWERONLY 0 +#define BICYCLEPOWER_SENSORTYPE_TORQUEWHEEL 1 +#define BICYCLEPOWER_SENSORTYPE_TORQUECRANK 2 +#define BICYCLEPOWER_SENSORTYPE_CTF 3 + #define BICYCLEPOWER_GENERALCALIBRATION_NUMBER 0x01 #define BICYCLEPOWER_STANDARDPOWERONLY_NUMBER 0x10 #define BICYCLEPOWER_STANDARDWHEELTORQUE_NUMBER 0x11 diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp index 7d63d0c..d5fc190 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -14,9 +14,9 @@ ProfileBicyclePowerSensor::ProfileBicyclePowerSensor( BaseMasterProfile(deviceNumber, ANTPLUS_TRANSMISSION_SET_LSN( transmissionType, SENSOR_TRANSMISSIONTYPE)), - // TODO - //_nextBackgroundPage(ANTPLUS_HEARTRATE_DATAPAGE_MANUFACTURERINFORMATION_NUMBER), - _flags(flags) { + _flags(flags), + _sensorType(BICYCLEPOWER_SENSORTYPE_POWERONLY) { + // TODO add and parse flags to figure out sensor type setChannelConfig(); } @@ -59,55 +59,49 @@ void ProfileBicyclePowerSensor::onAcknowledgedData(AcknowledgedData& msg) { void ProfileBicyclePowerSensor::transmitNextDataPage() { if (isRequestedPagePending()) { transmitRequestedDataPage(); - } else { - if (_patternStep++ < 64) { - transmitPrimaryDataPage(); - } else { - transmitBackgroundDataPage(); - if (_patternStep > 67) { - _nextBackgroundPage = getNextBackgroundPage(_nextBackgroundPage); - _patternStep = 0; - } - } + return; + } + + switch (_sensorType) { + case BICYCLEPOWER_SENSORTYPE_POWERONLY: + transmitPowerOnlySensorPage(); + break; + case BICYCLEPOWER_SENSORTYPE_TORQUEWHEEL: + transmitTorqueWheelSensorPage(); + break; + case BICYCLEPOWER_SENSORTYPE_TORQUECRANK: + transmitTorqueCrankSensorPage(); + break; + case BICYCLEPOWER_SENSORTYPE_CTF: + transmitCTFSensorPage(); + break; } - transmitPrimaryDataPage(); } -bool ProfileBicyclePowerSensor::handleRequestDataPage(BicyclePowerStandardPowerOnly& dataPage) { - RequestDataPage dp(dataPage); - return _onRequestDataPage.call(dp); +void ProfileBicyclePowerSensor::transmitPowerOnlySensorPage() { + // TODO } -bool ProfileBicyclePowerSensor::handleGeneralCalibration(BicyclePowerStandardPowerOnly& dataPage) { +void ProfileBicyclePowerSensor::transmitTorqueWheelSensorPage() { // TODO - return false; } -void ProfileBicyclePowerSensor::transmitPrimaryDataPage() { +void ProfileBicyclePowerSensor::transmitTorqueCrankSensorPage() { // TODO } -void ProfileBicyclePowerSensor::transmitBackgroundDataPage() { - switch (_nextBackgroundPage) { - case BICYCLEPOWER_STANDARDPOWERONLY_NUMBER: - transmitBicyclePowerStandardPowerOnlyMsg(); - break; - case BICYCLEPOWER_STANDARDWHEELTORQUE_NUMBER: - transmitBicyclePowerStandardWheelTorqueMsg(); - break; - case BICYCLEPOWER_STANDARDCRANKTORQUE_NUMBER: - transmitBicyclePowerStandardCrankTorqueMsg(); - break; - case BICYCLEPOWER_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: - transmitBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg(); - break; - case BICYCLEPOWER_CRANKTORQUEFREQUENCY_NUMBER: - transmitBicyclePowerCrankTorqueFrequencyMsg(); - break; - case BICYCLEPOWER_GENERALCALIBRATION_NUMBER: // TODO (check is this part of the background transmission, seems sus) - transmistBicyclePowerGeneralCalibrationResponse(); - break; - } +void ProfileBicyclePowerSensor::transmitCTFSensorPage() { + // TODO +} + +bool ProfileBicyclePowerSensor::handleRequestDataPage(BicyclePowerStandardPowerOnly& dataPage) { + RequestDataPage dp(dataPage); + return _onRequestDataPage.call(dp); +} + +bool ProfileBicyclePowerSensor::handleGeneralCalibration(BicyclePowerStandardPowerOnly& dataPage) { + // TODO + return false; } void ProfileBicyclePowerSensor::transmitBicyclePowerStandardPowerOnlyMsg() { diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h index 4ddfd7e..6b3605c 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h @@ -24,9 +24,11 @@ class ProfileBicyclePowerSensor : public BaseMasterProfile { bool isDataPageValid(uint8_t dataPage) override; private: void setChannelConfig(); - void transmitPrimaryDataPage(); - void transmitBackgroundDataPage(); void transmitRequestedDataPage(); + void transmitPowerOnlySensorPage(); + void transmitTorqueWheelSensorPage(); + void transmitTorqueCrankSensorPage(); + void transmitCTFSensorPage(); void transmitBicyclePowerDefaultMsg(); void transmitBicycleStandardPowerOnlyMsg(BicyclePowerStandardPowerOnlyMsg& msg); void transmitBicyclePowerStandardPowerOnlyMsg(); @@ -47,6 +49,7 @@ class ProfileBicyclePowerSensor : public BaseMasterProfile { uint8_t _nextBackgroundPage; uint8_t _patternStep = 0; uint32_t _flags = 0; + uint8_t _sensorType; }; #endif // ANTPLUS_PROFILEBICYCLEPOWERSENSOR_h From 301ff2136525c33bb31ca8d4697a79bd686a08cd Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 2 May 2021 20:39:19 -0700 Subject: [PATCH 166/241] MuscleOxygen: fix cppcheck warning --- .../MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp index 38e4b20..c6667e5 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp @@ -12,7 +12,7 @@ ProfileMuscleOxygenMonitor::ProfileMuscleOxygenMonitor( uint16_t deviceNumber, u { setChannelConfig(); // change the background cycle loop size - _backgroundStepSize = 2 + (flags & ANTPLUS_MUSCLEOXYGEN_FLAGS_BATTERYSTATUS_SUPPORTED ? 1 : 0); + _backgroundStepSize = 2 + ((flags & ANTPLUS_MUSCLEOXYGEN_FLAGS_BATTERYSTATUS_SUPPORTED) ? 1 : 0); } void ProfileMuscleOxygenMonitor::setChannelConfig() { From ea0aa7eafb31971fb82441841a474d82400841a0 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Wed, 26 May 2021 22:58:48 -0700 Subject: [PATCH 167/241] BicyclePower: Refactor transimission patterns Make common background data function, make common transmisison path --- .../ANTPLUS_ProfileBicyclePowerSensor.cpp | 104 ++++++++++++++---- .../ANTPLUS_ProfileBicyclePowerSensor.h | 17 +-- 2 files changed, 91 insertions(+), 30 deletions(-) diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp index d5fc190..9e56f8c 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -57,43 +57,65 @@ void ProfileBicyclePowerSensor::onAcknowledgedData(AcknowledgedData& msg) { } void ProfileBicyclePowerSensor::transmitNextDataPage() { + uint8_t page = 0; if (isRequestedPagePending()) { - transmitRequestedDataPage(); + transmitDataPage(getRequestedPage()); return; } + _patternStep++; + if (_patternStep == 120) { + _patternStep = 0; + } + switch (_sensorType) { case BICYCLEPOWER_SENSORTYPE_POWERONLY: - transmitPowerOnlySensorPage(); + page = getNextPowerOnlySensorPage(); break; case BICYCLEPOWER_SENSORTYPE_TORQUEWHEEL: - transmitTorqueWheelSensorPage(); - break; case BICYCLEPOWER_SENSORTYPE_TORQUECRANK: - transmitTorqueCrankSensorPage(); + page = getNextTorqueSensorPage(); break; case BICYCLEPOWER_SENSORTYPE_CTF: - transmitCTFSensorPage(); + page = BICYCLEPOWER_CRANKTORQUEFREQUENCY_NUMBER; break; } -} -void ProfileBicyclePowerSensor::transmitPowerOnlySensorPage() { - // TODO + transmitDataPage(page); } -void ProfileBicyclePowerSensor::transmitTorqueWheelSensorPage() { - // TODO -} +uint8_t ProfileBicyclePowerSensor::getNextPowerOnlySensorPage() { + uint8_t backgroundPage; -void ProfileBicyclePowerSensor::transmitTorqueCrankSensorPage() { - // TODO + backgroundPage = getBackgroundPage(); + if (backgroundPage) { + return backgroundPage; + } + return BICYCLEPOWER_STANDARDPOWERONLY_NUMBER; } -void ProfileBicyclePowerSensor::transmitCTFSensorPage() { - // TODO +uint8_t ProfileBicyclePowerSensor::getNextTorqueSensorPage() { + uint8_t backgroundPage; + uint8_t mod_five = _patternStep % 5; + + if (mod_five == 0) { + /* Interleave every 5th message */ + return BICYCLEPOWER_STANDARDPOWERONLY_NUMBER; + } else if ((mod_five == 1) && _createBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg.func) { + /* Interleave every 5th message if implemented */ + return BICYCLEPOWER_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER; + } + + backgroundPage = getBackgroundPage(); + if (backgroundPage) { + return backgroundPage; + } + + return _sensorType == BICYCLEPOWER_SENSORTYPE_TORQUECRANK ? + BICYCLEPOWER_STANDARDCRANKTORQUE_NUMBER : BICYCLEPOWER_STANDARDWHEELTORQUE_NUMBER; } + bool ProfileBicyclePowerSensor::handleRequestDataPage(BicyclePowerStandardPowerOnly& dataPage) { RequestDataPage dp(dataPage); return _onRequestDataPage.call(dp); @@ -134,18 +156,53 @@ void ProfileBicyclePowerSensor::transmitBicyclePowerCrankTorqueFrequencyMsg() { transmitMsg(msg); } -void ProfileBicyclePowerSensor::transmistBicyclePowerGeneralCalibrationResponse() { - // TODO +void ProfileBicyclePowerSensor::transmitBatteryStatusMsg() { + BatteryStatusMsg msg; + _createBatteryStatusMsg.call(msg); + transmitMsg(msg); } -uint8_t ProfileBicyclePowerSensor::getNextBackgroundPage(uint8_t currentPage) { +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 COMMON_MANUFACTURERSINFORMATION_NUMBER; + } + + if (_patternStep == 119) { + return COMMON_PRODUCTINFORMATION_NUMBER; + } + + if ((_patternStep == 33 || _patternStep == 93) && _createBatteryStatusMsg.func) { + return COMMON_BATTERYSTATUS_NUMBER; + } + + /* we don't have anything to transmit */ return 0; } -void ProfileBicyclePowerSensor::transmitRequestedDataPage() { - uint8_t requestedPage = getRequestedPage(); - switch (requestedPage) { +void ProfileBicyclePowerSensor::transmitDataPage(uint8_t page) { + switch (page) { // TODO rest of datapages case BICYCLEPOWER_STANDARDPOWERONLY_NUMBER: transmitBicyclePowerStandardPowerOnlyMsg(); @@ -162,6 +219,9 @@ void ProfileBicyclePowerSensor::transmitRequestedDataPage() { case BICYCLEPOWER_CRANKTORQUEFREQUENCY_NUMBER: transmitBicyclePowerCrankTorqueFrequencyMsg(); break; + case COMMON_BATTERYSTATUS_NUMBER: + transmitBatteryStatusMsg(); + break; } } diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h index 6b3605c..443b7f5 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h @@ -16,6 +16,7 @@ class ProfileBicyclePowerSensor : public BaseMasterProfile { 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); } protected: void transmitNextDataPage() override; @@ -24,11 +25,11 @@ class ProfileBicyclePowerSensor : public BaseMasterProfile { bool isDataPageValid(uint8_t dataPage) override; private: void setChannelConfig(); - void transmitRequestedDataPage(); - void transmitPowerOnlySensorPage(); - void transmitTorqueWheelSensorPage(); - void transmitTorqueCrankSensorPage(); - void transmitCTFSensorPage(); + 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(); @@ -36,17 +37,17 @@ class ProfileBicyclePowerSensor : public BaseMasterProfile { void transmitBicyclePowerStandardCrankTorqueMsg(); void transmitBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg(); void transmitBicyclePowerCrankTorqueFrequencyMsg(); - void transmistBicyclePowerGeneralCalibrationResponse(); + void transmitBicyclePowerGeneralCalibrationResponse(); + void transmitBatteryStatusMsg(); bool handleRequestDataPage(BicyclePowerStandardPowerOnly& dataPage); bool handleGeneralCalibration(BicyclePowerStandardPowerOnly& dataPage); - uint8_t getNextBackgroundPage(uint8_t currentPage); AntCallback _onRequestDataPage = { .func = NULL }; AntCallback _createBicyclePowerStandardPowerOnlyMsg = { .func = NULL }; AntCallback _createBicyclePowerStandardWheelTorqueMsg = { .func = NULL }; AntCallback _createBicyclePowerStandardCrankTorqueMsg = { .func = NULL }; AntCallback _createBicyclePowerCrankTorqueFrequencyMsg = { .func = NULL }; AntCallback _createBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg = { .func = NULL }; - uint8_t _nextBackgroundPage; + AntCallback _createBatteryStatusMsg = { .func = NULL }; uint8_t _patternStep = 0; uint32_t _flags = 0; uint8_t _sensorType; From a0a28e56abd2dabedd5af3e2e9a9146aab1fa4ea Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 15 Jul 2021 10:42:10 -0700 Subject: [PATCH 168/241] BicyclePower: Add TE & PS Main Data Page support for power only Power only sensors my support TE & PS page, therefore add check in datapage rotation --- .../Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp index 9e56f8c..32649bf 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -86,6 +86,12 @@ void ProfileBicyclePowerSensor::transmitNextDataPage() { 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 BICYCLEPOWER_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER; + } backgroundPage = getBackgroundPage(); if (backgroundPage) { From 1ae5b7770d10d665fb73f6668c245bf6ad68d386 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 15 Jul 2021 10:47:59 -0700 Subject: [PATCH 169/241] BicyclePower: Add isDataPageValid implementation Implement checks for request data page --- .../ANTPLUS_ProfileBicyclePowerSensor.cpp | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp index 32649bf..8ece494 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -239,6 +239,25 @@ void ProfileBicyclePowerSensor::setChannelConfig() { } bool ProfileBicyclePowerSensor::isDataPageValid(uint8_t dataPage) { - // TODO - return true; + // TODO calibration data pages + switch (dataPage) { + case BICYCLEPOWER_STANDARDPOWERONLY_NUMBER: + return _sensorType != BICYCLEPOWER_SENSORTYPE_CTF; + case BICYCLEPOWER_STANDARDWHEELTORQUE_NUMBER: + return _sensorType == BICYCLEPOWER_SENSORTYPE_TORQUEWHEEL; + case BICYCLEPOWER_STANDARDCRANKTORQUE_NUMBER: + return _sensorType == BICYCLEPOWER_SENSORTYPE_TORQUECRANK; + case BICYCLEPOWER_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: + return _sensorType != BICYCLEPOWER_SENSORTYPE_CTF && + (bool)_createBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg.func; + case BICYCLEPOWER_CRANKTORQUEFREQUENCY_NUMBER: + return _sensorType == BICYCLEPOWER_SENSORTYPE_CTF; + case COMMON_BATTERYSTATUS_NUMBER: + return (bool)_createBatteryStatusMsg.func; + case COMMON_PRODUCTINFORMATION_NUMBER: + case COMMON_MANUFACTURERSINFORMATION_NUMBER: + return true; + default: + return false; + } } From ad97ddd8b76e65b1ce305ed523cf8e78f3bd8fe4 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 15 Jul 2021 15:56:07 -0700 Subject: [PATCH 170/241] BicyclePower: Add Product and Mannufacturers Information Hooks Missing required common datapage hooks --- .../ANTPLUS_ProfileBicyclePowerSensor.cpp | 20 ++++++++++++++++++- .../ANTPLUS_ProfileBicyclePowerSensor.h | 6 ++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp index 8ece494..4eaf871 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -168,6 +168,18 @@ void ProfileBicyclePowerSensor::transmitBatteryStatusMsg() { 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 } @@ -209,7 +221,7 @@ uint8_t ProfileBicyclePowerSensor::getBackgroundPage() { void ProfileBicyclePowerSensor::transmitDataPage(uint8_t page) { switch (page) { - // TODO rest of datapages + // TODO calibration datapages case BICYCLEPOWER_STANDARDPOWERONLY_NUMBER: transmitBicyclePowerStandardPowerOnlyMsg(); break; @@ -225,6 +237,12 @@ void ProfileBicyclePowerSensor::transmitDataPage(uint8_t page) { case BICYCLEPOWER_CRANKTORQUEFREQUENCY_NUMBER: transmitBicyclePowerCrankTorqueFrequencyMsg(); break; + case COMMON_PRODUCTINFORMATION_NUMBER: + transmitProductInfomrationMsg(); + break; + case COMMON_MANUFACTURERSINFORMATION_NUMBER: + transmitManufacturesInformationMsg(); + break; case COMMON_BATTERYSTATUS_NUMBER: transmitBatteryStatusMsg(); break; diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h index 443b7f5..d722e98 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h @@ -17,6 +17,8 @@ class ProfileBicyclePowerSensor : public BaseMasterProfile { 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; @@ -39,6 +41,8 @@ class ProfileBicyclePowerSensor : public BaseMasterProfile { void transmitBicyclePowerCrankTorqueFrequencyMsg(); void transmitBicyclePowerGeneralCalibrationResponse(); void transmitBatteryStatusMsg(); + void transmitProductInfomrationMsg(); + void transmitManufacturesInformationMsg(); bool handleRequestDataPage(BicyclePowerStandardPowerOnly& dataPage); bool handleGeneralCalibration(BicyclePowerStandardPowerOnly& dataPage); AntCallback _onRequestDataPage = { .func = NULL }; @@ -48,6 +52,8 @@ class ProfileBicyclePowerSensor : public BaseMasterProfile { 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; uint8_t _sensorType; From 9b5080fa6e2d7deb3569418a474dad8d09e208b4 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 17 Jul 2021 22:49:07 -0600 Subject: [PATCH 171/241] HeartRate: Remove unneeded flags Optional datapage support can be detected by checking if a callback was installed, no need for additional bitfields --- .../HeartRate/ANTPLUS_HeartRateDefines.h | 5 +---- .../ANTPLUS_ProfileHeartRateMonitor.cpp | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/Profiles/HeartRate/ANTPLUS_HeartRateDefines.h b/src/Profiles/HeartRate/ANTPLUS_HeartRateDefines.h index 5f716ce..65db00a 100644 --- a/src/Profiles/HeartRate/ANTPLUS_HeartRateDefines.h +++ b/src/Profiles/HeartRate/ANTPLUS_HeartRateDefines.h @@ -3,10 +3,7 @@ #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) #define ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURES_EXTENDEDRUNNING 0x01 #define ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURES_EXTENDEDCYCLING 0x02 diff --git a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp index 5f9845f..429564e 100644 --- a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp @@ -81,7 +81,7 @@ void ProfileHeartRateMonitor::transmitPrimaryDataPage() { return; } - if (_flags & ANTPLUS_HEARTRATE_FLAGS_PREVIOUSHEARTBEAT_SUPPORTED) { + if (_createHeartRatePreviousHeartBeatMsg.func) { transmitHeartRatePreviousHeartBeatMsg(); } else { transmitHeartRateDefaultMsg(); @@ -110,7 +110,7 @@ void ProfileHeartRateMonitor::transmitBackgroundDataPage() { uint8_t ProfileHeartRateMonitor::getNextBackgroundPage(uint8_t currentPage) { if ((currentPage < HEARTRATE_CUMULATIVEOPERATINGTIME_NUMBER) && - (_flags & ANTPLUS_HEARTRATE_FLAGS_CUMULATIVEOPERATINGTIME_SUPPORTED)) { + (_createHeartRateCumulativeOperatingTimeMsg.func)) { return HEARTRATE_CUMULATIVEOPERATINGTIME_NUMBER; } else if (currentPage < HEARTRATE_MANUFACTURERINFORMATION_NUMBER) { return HEARTRATE_MANUFACTURERINFORMATION_NUMBER; @@ -120,7 +120,7 @@ uint8_t ProfileHeartRateMonitor::getNextBackgroundPage(uint8_t currentPage) { (_flags & ANTPLUS_HEARTRATE_FLAGS_EXTENTED_FEATURES)) { return HEARTRATE_CAPABILITIES_NUMBER; } else if ((currentPage < HEARTRATE_BATTERYSTATUS_NUMBER) && - (_flags & ANTPLUS_HEARTRATE_FLAGS_BATTERYSTATUS_SUPPORTED)) { + (_createHeartRateBatteryStatusMsg.func)) { return HEARTRATE_BATTERYSTATUS_NUMBER; } else { // Reached end of the loop, start again @@ -217,20 +217,21 @@ void ProfileHeartRateMonitor::transmitHeartRateMsg(HeartRateBaseMainDataPageMsg& bool ProfileHeartRateMonitor::isDataPageValid(uint8_t dataPage) { switch (dataPage) { case HEARTRATE_DEFAULT_NUMBER: - // TODO double check this is correct that dp 4 is only needed if implemented - return !(_flags & ANTPLUS_HEARTRATE_FLAGS_PREVIOUSHEARTBEAT_SUPPORTED); + return (bool)(_createHeartRateDefaultMsg.func); case HEARTRATE_CUMULATIVEOPERATINGTIME_NUMBER: - return _flags & ANTPLUS_HEARTRATE_FLAGS_CUMULATIVEOPERATINGTIME_SUPPORTED; + return (bool)(_createHeartRateCumulativeOperatingTimeMsg.func); case HEARTRATE_MANUFACTURERINFORMATION_NUMBER: case HEARTRATE_PRODUCTINFORMATION_NUMBER: return true; case HEARTRATE_PREVIOUSHEARTBEAT_NUMBER: - return _flags & ANTPLUS_HEARTRATE_FLAGS_PREVIOUSHEARTBEAT_SUPPORTED; - case HEARTRATE_SWIMINTERVALSUMMARY_NUMBER: + return (bool)(_createHeartRatePreviousHeartBeatMsg.func); case HEARTRATE_CAPABILITIES_NUMBER: return _flags & ANTPLUS_HEARTRATE_FLAGS_EXTENTED_FEATURES; + case HEARTRATE_SWIMINTERVALSUMMARY_NUMBER: + return _flags & ANTPLUS_HEARTRATE_FLAGS_EXTENTED_FEATURES && + (bool)(_createHeartRateSwimIntervalSummaryMsg.func); case HEARTRATE_BATTERYSTATUS_NUMBER: - return _flags & ANTPLUS_HEARTRATE_FLAGS_BATTERYSTATUS_SUPPORTED; + return (bool)(_createHeartRateBatteryStatusMsg.func); default: return false; } From 1f3dea8cfa5c83a493241d079a71623a26cc1195 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 17 Jul 2021 23:00:51 -0600 Subject: [PATCH 172/241] BicyclePower: expose multiple sensor type flags There are 4 types of power sensors, now that the internal infra is implemented (untested) we can go ahead and expose the API to change the sensor type --- .../ANTPLUS_BicyclePowerDefines.h | 6 ++++ .../ANTPLUS_BicyclePowerPrivateDefines.h | 6 ---- .../ANTPLUS_ProfileBicyclePowerSensor.cpp | 30 ++++++++++--------- .../ANTPLUS_ProfileBicyclePowerSensor.h | 1 - 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h index 8fe74ed..724c46b 100644 --- a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h @@ -3,4 +3,10 @@ #define ANTPLUS_BICYCLEPOWER_DEVICETYPE 11 +/* Sensor Types */ +#define BICYCLEPOWER_FLAGS_SENSORTYPE_POWERONLY 0 +#define BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUEWHEEL 1 +#define BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUECRANK 2 +#define BICYCLEPOWER_FLAGS_SENSORTYPE_CTF 3 + #endif // ANTPLUS_BICYCLEPOWERPROFILEDEFINES_h diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h index 4dee1f7..12edd45 100644 --- a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h @@ -8,12 +8,6 @@ // 30 / 2.5 = 12 #define BICYCLEPOWER_SEARCHTIMEOUT 12 -/* Sensor Types */ -#define BICYCLEPOWER_SENSORTYPE_POWERONLY 0 -#define BICYCLEPOWER_SENSORTYPE_TORQUEWHEEL 1 -#define BICYCLEPOWER_SENSORTYPE_TORQUECRANK 2 -#define BICYCLEPOWER_SENSORTYPE_CTF 3 - #define BICYCLEPOWER_GENERALCALIBRATION_NUMBER 0x01 #define BICYCLEPOWER_STANDARDPOWERONLY_NUMBER 0x10 #define BICYCLEPOWER_STANDARDWHEELTORQUE_NUMBER 0x11 diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp index 4eaf871..a830141 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -7,6 +7,8 @@ #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, @@ -14,9 +16,7 @@ ProfileBicyclePowerSensor::ProfileBicyclePowerSensor( BaseMasterProfile(deviceNumber, ANTPLUS_TRANSMISSION_SET_LSN( transmissionType, SENSOR_TRANSMISSIONTYPE)), - _flags(flags), - _sensorType(BICYCLEPOWER_SENSORTYPE_POWERONLY) { - // TODO add and parse flags to figure out sensor type + _flags(flags) { setChannelConfig(); } @@ -58,6 +58,8 @@ void ProfileBicyclePowerSensor::onAcknowledgedData(AcknowledgedData& msg) { void ProfileBicyclePowerSensor::transmitNextDataPage() { uint8_t page = 0; + uint8_t sensorType = FLAGS_SENSORTYPE(_flags); + if (isRequestedPagePending()) { transmitDataPage(getRequestedPage()); return; @@ -68,15 +70,15 @@ void ProfileBicyclePowerSensor::transmitNextDataPage() { _patternStep = 0; } - switch (_sensorType) { - case BICYCLEPOWER_SENSORTYPE_POWERONLY: + switch (sensorType) { + case BICYCLEPOWER_FLAGS_SENSORTYPE_POWERONLY: page = getNextPowerOnlySensorPage(); break; - case BICYCLEPOWER_SENSORTYPE_TORQUEWHEEL: - case BICYCLEPOWER_SENSORTYPE_TORQUECRANK: + case BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUEWHEEL: + case BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUECRANK: page = getNextTorqueSensorPage(); break; - case BICYCLEPOWER_SENSORTYPE_CTF: + case BICYCLEPOWER_FLAGS_SENSORTYPE_CTF: page = BICYCLEPOWER_CRANKTORQUEFREQUENCY_NUMBER; break; } @@ -117,7 +119,7 @@ uint8_t ProfileBicyclePowerSensor::getNextTorqueSensorPage() { return backgroundPage; } - return _sensorType == BICYCLEPOWER_SENSORTYPE_TORQUECRANK ? + return FLAGS_SENSORTYPE(_flags) == BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUECRANK ? BICYCLEPOWER_STANDARDCRANKTORQUE_NUMBER : BICYCLEPOWER_STANDARDWHEELTORQUE_NUMBER; } @@ -260,16 +262,16 @@ bool ProfileBicyclePowerSensor::isDataPageValid(uint8_t dataPage) { // TODO calibration data pages switch (dataPage) { case BICYCLEPOWER_STANDARDPOWERONLY_NUMBER: - return _sensorType != BICYCLEPOWER_SENSORTYPE_CTF; + return FLAGS_SENSORTYPE(_flags) != BICYCLEPOWER_FLAGS_SENSORTYPE_CTF; case BICYCLEPOWER_STANDARDWHEELTORQUE_NUMBER: - return _sensorType == BICYCLEPOWER_SENSORTYPE_TORQUEWHEEL; + return FLAGS_SENSORTYPE(_flags) == BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUEWHEEL; case BICYCLEPOWER_STANDARDCRANKTORQUE_NUMBER: - return _sensorType == BICYCLEPOWER_SENSORTYPE_TORQUECRANK; + return FLAGS_SENSORTYPE(_flags) == BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUECRANK; case BICYCLEPOWER_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: - return _sensorType != BICYCLEPOWER_SENSORTYPE_CTF && + return FLAGS_SENSORTYPE(_flags) != BICYCLEPOWER_FLAGS_SENSORTYPE_CTF && (bool)_createBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg.func; case BICYCLEPOWER_CRANKTORQUEFREQUENCY_NUMBER: - return _sensorType == BICYCLEPOWER_SENSORTYPE_CTF; + return FLAGS_SENSORTYPE(_flags) == BICYCLEPOWER_FLAGS_SENSORTYPE_CTF; case COMMON_BATTERYSTATUS_NUMBER: return (bool)_createBatteryStatusMsg.func; case COMMON_PRODUCTINFORMATION_NUMBER: diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h index d722e98..0c5d013 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.h @@ -56,7 +56,6 @@ class ProfileBicyclePowerSensor : public BaseMasterProfile { AntCallback _createManufacturersInformationMsg = { .func = NULL }; uint8_t _patternStep = 0; uint32_t _flags = 0; - uint8_t _sensorType; }; #endif // ANTPLUS_PROFILEBICYCLEPOWERSENSOR_h From cfbc21456826cf9f82e791222a5e5f871a3cccf9 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 8 Aug 2021 09:59:36 -0600 Subject: [PATCH 173/241] examples: DeviceSearch: Add more device types Now that more device types have been exposed, lets add them to the search example for proper usage demonstration --- examples/DeviceSearch/DeviceSearch.ino | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/examples/DeviceSearch/DeviceSearch.ino b/examples/DeviceSearch/DeviceSearch.ino index c216db3..80d2ca7 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_DEVICETYPE: + Serial.println("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; From bb0b3546095f19cb2751a1106fae558ff108f14c Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 8 Aug 2021 11:46:53 -0600 Subject: [PATCH 174/241] BicyclePower: PowerOnly: Fix typo instat would be a weird thing --- .../DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp | 2 +- .../DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp index 00fa922..855a529 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp @@ -60,7 +60,7 @@ void BicyclePowerStandardPowerOnlyMsg::setCumulativePowerCount(uint16_t accPower _buffer[ACCUMULATEDPOWER_LSB_BYTE] = accPower & ANTPLUS_DEFAULT_BYTE_MASK; } -void BicyclePowerStandardPowerOnlyMsg::setInstataneousPowerCount(uint16_t power) { +void BicyclePowerStandardPowerOnlyMsg::setInstantaneousPowerCount(uint16_t power) { _buffer[INSTANTANEOUSPOWER_MSB_BYTE] = power >> 8; _buffer[INSTANTANEOUSPOWER_LSB_BYTE] = power & ANTPLUS_DEFAULT_BYTE_MASK; } diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.h index 0dd6cb6..8cf843a 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.h +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.h @@ -23,7 +23,7 @@ class BicyclePowerStandardPowerOnlyMsg : public BicyclePowerBaseMainDataPageMsg, BicyclePowerStandardPowerOnlyMsg(void); void setUpdateEventCount(uint8_t eventCount); void setCumulativePowerCount(uint16_t accPower); - void setInstataneousPowerCount(uint16_t power); + void setInstantaneousPowerCount(uint16_t power); }; #endif // ANTPLUS_BICYCLEPOWERSTANDARDPOWERONLY_h From 505b88b43016036c6fb77b4cb301d90b4cfe8f9b Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 8 Aug 2021 11:48:05 -0600 Subject: [PATCH 175/241] BicyclePower: PowerOnly: Migrate to new byte API Move another msg over --- .../ANTPLUS_BicyclePowerStandardPowerOnly.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp index 855a529..0a08afd 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp @@ -46,21 +46,19 @@ BicyclePowerStandardPowerOnly::BicyclePowerStandardPowerOnly(AntRxDataResponse& BicyclePowerStandardPowerOnlyMsg::BicyclePowerStandardPowerOnlyMsg() : BicyclePowerBaseMainDataPageMsg(BICYCLEPOWER_STANDARDPOWERONLY_NUMBER), BicyclePowerBaseStandardPowerOnly() { - // TODO magic nums also using buffer directly - _buffer[PEDALPOWER_BYTE] = 0xFF; - _buffer[INSTANTANEOUSCADENCE_BYTE] = 0xFF; + // TODO magic nums + this->set8BitValue(0xFF, PEDALPOWER_BYTE); + this->set8BitValue(0xFF, INSTANTANEOUSCADENCE_BYTE); } void BicyclePowerStandardPowerOnlyMsg::setUpdateEventCount(uint8_t eventCount) { - _buffer[UPDATEEVENTCOUNT_BYTE] = eventCount; + this->set8BitValue(eventCount, UPDATEEVENTCOUNT_BYTE); } void BicyclePowerStandardPowerOnlyMsg::setCumulativePowerCount(uint16_t accPower) { - _buffer[ACCUMULATEDPOWER_MSB_BYTE] = accPower >> 8; - _buffer[ACCUMULATEDPOWER_LSB_BYTE] = accPower & ANTPLUS_DEFAULT_BYTE_MASK; + this->set16BitValue(accPower, ACCUMULATEDPOWER_LSB_BYTE, ACCUMULATEDPOWER_MSB_BYTE); } void BicyclePowerStandardPowerOnlyMsg::setInstantaneousPowerCount(uint16_t power) { - _buffer[INSTANTANEOUSPOWER_MSB_BYTE] = power >> 8; - _buffer[INSTANTANEOUSPOWER_LSB_BYTE] = power & ANTPLUS_DEFAULT_BYTE_MASK; + this->set16BitValue(power, INSTANTANEOUSPOWER_LSB_BYTE, INSTANTANEOUSPOWER_MSB_BYTE); } From ed54382e68a689afd7d734a5dc4df8680a0b7211 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 8 Aug 2021 11:49:43 -0600 Subject: [PATCH 176/241] BicyclePower: CrankTorque: fix comment typo vaid is not quite valid --- .../DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.h index 949bd76..3c5a8bc 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.h +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.h @@ -8,7 +8,7 @@ class BicyclePowerBaseStandardCrankTorque : virtual public CoreDataPage { public: BicyclePowerBaseStandardCrankTorque(); uint8_t getCrankTicks(); - uint8_t getInstantaneousCadence(); //TODO is vaid check, May not be available, 0xFF indicates invalid + uint8_t getInstantaneousCadence(); //TODO is valid check, May not be available, 0xFF indicates invalid uint16_t getCrankPeriod(); uint16_t getAccumulatedTorque(); }; @@ -26,7 +26,7 @@ class BicyclePowerStandardCrankTorqueMsg : public: BicyclePowerStandardCrankTorqueMsg(); void setCrankTicks(uint8_t ticks); - void setInstantaneousCadence(uint8_t cadence); //TODO is vaid check, May not be available, 0xFF indicates invalid + void setInstantaneousCadence(uint8_t cadence); //TODO is valid check, May not be available, 0xFF indicates invalid void setCrankPeriod(uint16_t period); void setAccumulatedTorque(uint16_t torque); }; From b3411910cad17d9feb636c1d0b6989deb54ad13b Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 8 Aug 2021 11:54:23 -0600 Subject: [PATCH 177/241] Examples: BicyclePowerSensor: Add example Add example of how to use power sensor and build with CI --- .github/workflows/main.yml | 1 + .../BicyclePowerSensor/BicyclePowerSensor.ino | 134 ++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 examples/BicyclePowerSensor/BicyclePowerSensor.ino diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 971f614..93f652a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,6 +15,7 @@ jobs: matrix: example: [ examples/BicyclePowerDisplay/BicyclePowerDisplay.ino, + examples/BicyclePowerSensor/BicyclePowerSensor.ino, examples/BicycleSpeedDisplay/BicycleSpeedDisplay.ino, examples/DeviceSearch/DeviceSearch.ino, examples/DynamicProfiles/DynamicProfiles.ino, diff --git a/examples/BicyclePowerSensor/BicyclePowerSensor.ino b/examples/BicyclePowerSensor/BicyclePowerSensor.ino new file mode 100644 index 0000000..989764f --- /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, 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(15000); + + 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.setCumulativePowerCount(eventCount * 3); + msg.setInstantaneousPowerCount(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"); +// } From 4c784e3f19cfb0a7257868d3e8ca7438380a0092 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 8 Aug 2021 14:37:09 -0600 Subject: [PATCH 178/241] HeartRate: DataPages: Fixup data access API use new byte set API --- .../DataPages/ANTPLUS_HeartRateProductInformation.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateProductInformation.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateProductInformation.cpp index 8ca939b..1df0d3c 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateProductInformation.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateProductInformation.cpp @@ -35,15 +35,14 @@ HeartRateProductInformationMsg::HeartRateProductInformationMsg() : HeartRateBaseMainDataPageMsg(HEARTRATE_PRODUCTINFORMATION_NUMBER), HeartRateBaseProductInformation() {} -// TODO set to product information API void HeartRateProductInformationMsg::setHardwareVersion(uint8_t hwVersion) { - _buffer[HARDWAREVERSION_BYTE] = hwVersion; + this->set8BitValue(hwVersion, HARDWAREVERSION_BYTE); } void HeartRateProductInformationMsg::setSoftwareVersion(uint8_t swVersion) { - _buffer[SOFTWAREVERSION_BYTE] = swVersion; + this->set8BitValue(swVersion, SOFTWAREVERSION_BYTE); } void HeartRateProductInformationMsg::setModelNumber(uint8_t modelNumber) { - _buffer[MODELNUMBER_BYTE] = modelNumber; + this->set8BitValue(modelNumber, MODELNUMBER_BYTE); } From f656fe781f691b9289a3c3533957543d76a4bf24 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 8 Aug 2021 14:41:38 -0600 Subject: [PATCH 179/241] CommonDataPages: Fixup direct buffer access move to new API --- src/CommonDataPages/ANTPLUS_ProductInformation.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/CommonDataPages/ANTPLUS_ProductInformation.cpp b/src/CommonDataPages/ANTPLUS_ProductInformation.cpp index a0db10d..5706f02 100644 --- a/src/CommonDataPages/ANTPLUS_ProductInformation.cpp +++ b/src/CommonDataPages/ANTPLUS_ProductInformation.cpp @@ -35,10 +35,11 @@ ProductInformation::ProductInformation(AntRxDataResponse& dp) : ProductInformationMsg::ProductInformationMsg() : BaseDataPageMsg(), BaseProductInformation() { - // TODO set default values + // TODO magic numbers setDataBuffer(_buffer); - _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = COMMON_PRODUCTINFORMATION_NUMBER; - _buffer[1] = 0xFF; + set8BitValue(COMMON_PRODUCTINFORMATION_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); + set8BitValue(0xFF, 1); + set8BitValue(0xFF, SWREVISIONSUPPLEMENTAL_BYTE); } void ProductInformationMsg::setSWRevisionSupplemental(uint8_t revision) { From 17092df2c875257d55d23f4e0b6a31d6c32d137c Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 8 Aug 2021 14:48:55 -0600 Subject: [PATCH 180/241] DataPages: remove memset and default values Better to define the initial data than programmatically set it ourselves --- src/CommonDataPages/ANTPLUS_BatteryStatus.h | 2 +- src/CommonDataPages/ANTPLUS_ManufacturersInformation.h | 2 +- .../ANTPLUS_MultiComponentSystemManufacturersInformation.h | 2 +- .../ANTPLUS_MultiComponentSystemProductInformation.h | 2 +- src/CommonDataPages/ANTPLUS_ProductInformation.h | 2 +- src/CommonDataPages/ANTPLUS_RequestDataPage.h | 2 +- .../DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.h | 2 +- .../DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.h | 2 +- .../HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.h | 2 +- src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.h | 2 +- .../DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.cpp | 1 - .../DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.h | 2 +- .../DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp | 1 - .../DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h | 2 +- 14 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/CommonDataPages/ANTPLUS_BatteryStatus.h b/src/CommonDataPages/ANTPLUS_BatteryStatus.h index 675afdc..3d5c142 100644 --- a/src/CommonDataPages/ANTPLUS_BatteryStatus.h +++ b/src/CommonDataPages/ANTPLUS_BatteryStatus.h @@ -35,7 +35,7 @@ class BatteryStatusMsg : public BaseDataPageMsg, public BaseBa void setBatteryStatus(uint8_t status); void setCumulativeOperatingTimeResolution(uint8_t resolution); private: - uint8_t _buffer[MESSAGE_SIZE]; + uint8_t _buffer[MESSAGE_SIZE] = {0}; }; #endif // ANTPLUS_BATTERYSTATUS_h diff --git a/src/CommonDataPages/ANTPLUS_ManufacturersInformation.h b/src/CommonDataPages/ANTPLUS_ManufacturersInformation.h index 5fbbe32..93c3811 100644 --- a/src/CommonDataPages/ANTPLUS_ManufacturersInformation.h +++ b/src/CommonDataPages/ANTPLUS_ManufacturersInformation.h @@ -27,7 +27,7 @@ class ManufacturersInformationMsg : public BaseDataPageMsg, Ba void setManufacturerId(uint16_t id); void setModelNumber(uint16_t modelNumber); private: - uint8_t _buffer[MESSAGE_SIZE]; + uint8_t _buffer[MESSAGE_SIZE] = {0}; }; #endif // ANTPLUS_MANUFACTURERSINFORMATION_h diff --git a/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.h b/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.h index 6c34685..0bba1cc 100644 --- a/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.h +++ b/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.h @@ -31,7 +31,7 @@ class MultiComponentSystemManufacturersInformationMsg : public BaseDataPageMsg, public B void setSWRevisionMain(uint8_t revision); void setSerialNumber(uint32_t serialNumber); private: - uint8_t _buffer[MESSAGE_SIZE]; + uint8_t _buffer[MESSAGE_SIZE] = {0}; }; #endif // ANTPLUS_PRODUCTINFORMATION_h diff --git a/src/CommonDataPages/ANTPLUS_RequestDataPage.h b/src/CommonDataPages/ANTPLUS_RequestDataPage.h index 14358b8..bdae33d 100644 --- a/src/CommonDataPages/ANTPLUS_RequestDataPage.h +++ b/src/CommonDataPages/ANTPLUS_RequestDataPage.h @@ -36,7 +36,7 @@ class RequestDataPageMsg : public BaseDataPageMsg, public B void setRequestedPageNumber(uint8_t pageNumber); void setCommandType(uint8_t commandType); private: - uint8_t _buffer[MESSAGE_SIZE]; + uint8_t _buffer[MESSAGE_SIZE] = {0}; }; #endif // ANTPLUS_REQUESTDATAPAGE_h diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.h index 269c2a5..848554c 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.h +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.h @@ -15,7 +15,7 @@ class BicyclePowerBaseMainDataPageMsg : public BaseDataPageMsg public: explicit BicyclePowerBaseMainDataPageMsg(uint8_t dataPageNumber); protected: - uint8_t _buffer[MESSAGE_SIZE]; + uint8_t _buffer[MESSAGE_SIZE] = {0}; }; #endif // ANTPLUS_BICYCLEPOWERPOWERONLYDATAPAGE_h diff --git a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.h b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.h index 47b9262..68717a2 100644 --- a/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.h +++ b/src/Profiles/BicycleSpeed/DataPages/ANTPLUS_BicycleSpeedBaseMainDataPage.h @@ -26,7 +26,7 @@ class BicycleSpeedBaseMainDataPageMsg : public BaseDataPageMsg void setBikeSpeedEventTime(uint16_t time); void setCumulativeSpeedRevolutionCount(uint16_t count); protected: - uint8_t _buffer[MESSAGE_SIZE]; + uint8_t _buffer[MESSAGE_SIZE] = {0}; }; #endif // ANTPLUS_BICYCLESPEEDBASEMAINDATAPAGE_h diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.h b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.h index 7f5dca2..0f3880c 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.h +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBaseMainDataPage.h @@ -28,7 +28,7 @@ class HeartRateBaseMainDataPageMsg : public BaseDataPageMsg, p void setHeartBeatCount(uint8_t count); void setComputedHeartRate(uint8_t heartRate); protected: - uint8_t _buffer[MESSAGE_SIZE]; + uint8_t _buffer[MESSAGE_SIZE] = {0}; }; #endif // ANTPLUS_HEARTRATEBASEMAINDATAPAGE_h diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.h index ef1b401..3ed7212 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.h @@ -13,7 +13,7 @@ class LevBaseMainDataPageMsg : public BaseDataPageMsg { public: explicit LevBaseMainDataPageMsg(uint8_t dataPageNumber); protected: - uint8_t _buffer[MESSAGE_SIZE]; + uint8_t _buffer[MESSAGE_SIZE] = {0}; }; #endif // ANTPLUS_LEVBASEMAINDATAPAGE_h diff --git a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.cpp b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.cpp index aed0225..dc470da 100644 --- a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.cpp +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.cpp @@ -5,7 +5,6 @@ MuscleOxygenBaseMainDataPage::MuscleOxygenBaseMainDataPage(AntRxDataResponse& dp BaseDataPage(dp) {} MuscleOxygenBaseMainDataPageMsg::MuscleOxygenBaseMainDataPageMsg(uint8_t dataPageNumber) : BaseDataPageMsg() { - memset(_buffer, 0, MESSAGE_SIZE); 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 index 208c888..e6bd474 100644 --- a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.h +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenBaseMainDataPage.h @@ -13,7 +13,7 @@ class MuscleOxygenBaseMainDataPageMsg : public BaseDataPageMsg public: explicit MuscleOxygenBaseMainDataPageMsg(uint8_t dataPageNumber); protected: - uint8_t _buffer[MESSAGE_SIZE]; + uint8_t _buffer[MESSAGE_SIZE] = {0}; }; #endif // ANTPLUS_MUSCLEOXYGENBASEMAINDATAPAGEMSG_h diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp index 365ebef..0f445d8 100644 --- a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp +++ b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp @@ -8,7 +8,6 @@ ShiftingBaseMainDataPageMsg::ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber) : BaseDataPageMsg() { - memset(_buffer, 0, MESSAGE_SIZE); setDataBuffer(_buffer); set8BitValue(dataPageNumber, ANTPLUS_DEFAULT_DATAPAGE_BYTE); set8BitValue(RESERVED_VALUE, RESERVED_BYTE); diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h index 2a6b2d8..c177413 100644 --- a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h +++ b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h @@ -9,7 +9,7 @@ class ShiftingBaseMainDataPageMsg : public BaseDataPageMsg { public: explicit ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber); protected: - uint8_t _buffer[MESSAGE_SIZE]; + uint8_t _buffer[MESSAGE_SIZE] = {0}; }; #endif // ANTPLUS_SHIFTINGBASEMAINDATAPAGEMSG_h From c2037ed3c7f9c8b311a95c8cabe9cf54035b51ee Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 8 Aug 2021 15:04:22 -0600 Subject: [PATCH 181/241] CommonDataPages: Add ModeSettingsMsg HeartRate Displays could not transmit the ModeSettings message till now as it was undefined --- src/CommonDataPages/ANTPLUS_ModeSettings.cpp | 19 ++++++++++++++++++- src/CommonDataPages/ANTPLUS_ModeSettings.h | 5 ++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/CommonDataPages/ANTPLUS_ModeSettings.cpp b/src/CommonDataPages/ANTPLUS_ModeSettings.cpp index 610a544..f358548 100644 --- a/src/CommonDataPages/ANTPLUS_ModeSettings.cpp +++ b/src/CommonDataPages/ANTPLUS_ModeSettings.cpp @@ -1,7 +1,9 @@ #include #include +#include #define SPORTSMODE_BYTE 7 +#define RESERVED_BYTE 0xFF template BaseModeSettings::BaseModeSettings() : CoreDataPage() {} @@ -18,4 +20,19 @@ ModeSettings::ModeSettings(AntRxDataResponse& dp) : BaseDataPage(dp), BaseModeSettings() {} -// TODO ModeSettingsMsg +ModeSettingsMsg::ModeSettingsMsg() : + BaseDataPageMsg(), + BaseModeSettings() { + setDataBuffer(_buffer); + set8BitValue(COMMON_MODESETTINGS_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); + set8BitValue(RESERVED_BYTE, 1); + set8BitValue(RESERVED_BYTE, 2); + set8BitValue(RESERVED_BYTE, 3); + set8BitValue(RESERVED_BYTE, 4); + set8BitValue(RESERVED_BYTE, 5); + set8BitValue(RESERVED_BYTE, 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 index 438c129..904e917 100644 --- a/src/CommonDataPages/ANTPLUS_ModeSettings.h +++ b/src/CommonDataPages/ANTPLUS_ModeSettings.h @@ -19,7 +19,10 @@ class ModeSettings : public BaseDataPage, public BaseModeSettings }; class ModeSettingsMsg : public BaseDataPageMsg, public BaseModeSettings { -// TODO + ModeSettingsMsg(); + void setSportMode(uint8_t sportsMode); +private: + uint8_t _buffer[MESSAGE_SIZE] = {0}; }; #endif // ANTPLUS_MODESETTINGS_h From 4172109e413f853616d344631f7a5a42656efe34 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 8 Aug 2021 15:26:25 -0600 Subject: [PATCH 182/241] Examples: HeartRateDisplay: utilize all definitions Show fields that can have invalid values --- .../HeartRateDisplay/HeartRateDisplay.ino | 26 ++++++++++++++++--- .../HeartRate/ANTPLUS_HeartRateDefines.h | 1 - 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/examples/HeartRateDisplay/HeartRateDisplay.ino b/examples/HeartRateDisplay/HeartRateDisplay.ino index 465553b..5f96109 100644 --- a/examples/HeartRateDisplay/HeartRateDisplay.ino +++ b/examples/HeartRateDisplay/HeartRateDisplay.ino @@ -106,7 +106,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 +126,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/src/Profiles/HeartRate/ANTPLUS_HeartRateDefines.h b/src/Profiles/HeartRate/ANTPLUS_HeartRateDefines.h index 65db00a..8c88afc 100644 --- a/src/Profiles/HeartRate/ANTPLUS_HeartRateDefines.h +++ b/src/Profiles/HeartRate/ANTPLUS_HeartRateDefines.h @@ -11,7 +11,6 @@ #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 From 92723f27d5a614720b492a67c3ebdef62ff70384 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 8 Aug 2021 15:59:43 -0600 Subject: [PATCH 183/241] BicyclePower: Fix defines and remove magic numbers Fixup defines to match other profiles and remove magic numbers --- .../BicyclePowerDisplay.ino | 12 +++++++++-- .../BicyclePowerSensor/BicyclePowerSensor.ino | 2 +- .../ANTPLUS_BicyclePowerDefines.h | 12 +++++++---- .../ANTPLUS_BicyclePowerStandardPowerOnly.cpp | 6 +++--- .../ANTPLUS_ProfileBicyclePowerSensor.cpp | 20 +++++++++---------- 5 files changed, 32 insertions(+), 20 deletions(-) diff --git a/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino index a5578ad..3e0b629 100644 --- a/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino +++ b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino @@ -135,9 +135,17 @@ void bicyclePowerBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data) { void powerOnlyDataPageHandler(BicyclePowerStandardPowerOnly& msg, uintptr_t data) { Serial.print("Pedal Power: "); - Serial.println(msg.getPedalPower()); + if (msg.getPedalPower() == ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_PEDALPOWER_NOTUSED) { + Serial.println("Not Used"); + } else { + Serial.println(msg.getPedalPower()); + } Serial.print("Instantaneous Cadence: "); - Serial.println(msg.getInstantaneousCadence()); + 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: "); diff --git a/examples/BicyclePowerSensor/BicyclePowerSensor.ino b/examples/BicyclePowerSensor/BicyclePowerSensor.ino index 989764f..70d4334 100644 --- a/examples/BicyclePowerSensor/BicyclePowerSensor.ino +++ b/examples/BicyclePowerSensor/BicyclePowerSensor.ino @@ -30,7 +30,7 @@ const int RESET_PIN = 2; ArduinoSerialAntWithCallbacks ant; AntPlusRouter router; -ProfileBicyclePowerSensor bikePower(123, 0, BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUECRANK); +ProfileBicyclePowerSensor bikePower(123, 0, ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUECRANK); void batteryStatusDataPageHandler(BatteryStatusMsg& msg, uintptr_t data); void manufacturerIDDataPageHandler(ManufacturersInformationMsg& msg, uintptr_t data); diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h index 724c46b..d213af0 100644 --- a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h @@ -4,9 +4,13 @@ #define ANTPLUS_BICYCLEPOWER_DEVICETYPE 11 /* Sensor Types */ -#define BICYCLEPOWER_FLAGS_SENSORTYPE_POWERONLY 0 -#define BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUEWHEEL 1 -#define BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUECRANK 2 -#define BICYCLEPOWER_FLAGS_SENSORTYPE_CTF 3 +#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_STANDARDPOWERONLY_PEDALPOWER_NOTUSED 0xFF +#define ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_INSTANTANEOUSCADENCE_INVALID 0xFF #endif // ANTPLUS_BICYCLEPOWERPROFILEDEFINES_h diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp index 0a08afd..372fae1 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #define UPDATEEVENTCOUNT_BYTE 1 @@ -46,9 +47,8 @@ BicyclePowerStandardPowerOnly::BicyclePowerStandardPowerOnly(AntRxDataResponse& BicyclePowerStandardPowerOnlyMsg::BicyclePowerStandardPowerOnlyMsg() : BicyclePowerBaseMainDataPageMsg(BICYCLEPOWER_STANDARDPOWERONLY_NUMBER), BicyclePowerBaseStandardPowerOnly() { - // TODO magic nums - this->set8BitValue(0xFF, PEDALPOWER_BYTE); - this->set8BitValue(0xFF, INSTANTANEOUSCADENCE_BYTE); + this->set8BitValue(ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_PEDALPOWER_NOTUSED, PEDALPOWER_BYTE); + this->set8BitValue(ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_INSTANTANEOUSCADENCE_INVALID, INSTANTANEOUSCADENCE_BYTE); } void BicyclePowerStandardPowerOnlyMsg::setUpdateEventCount(uint8_t eventCount) { diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp index a830141..41487a1 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -71,14 +71,14 @@ void ProfileBicyclePowerSensor::transmitNextDataPage() { } switch (sensorType) { - case BICYCLEPOWER_FLAGS_SENSORTYPE_POWERONLY: + case ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_POWERONLY: page = getNextPowerOnlySensorPage(); break; - case BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUEWHEEL: - case BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUECRANK: + case ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUEWHEEL: + case ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUECRANK: page = getNextTorqueSensorPage(); break; - case BICYCLEPOWER_FLAGS_SENSORTYPE_CTF: + case ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_CTF: page = BICYCLEPOWER_CRANKTORQUEFREQUENCY_NUMBER; break; } @@ -119,7 +119,7 @@ uint8_t ProfileBicyclePowerSensor::getNextTorqueSensorPage() { return backgroundPage; } - return FLAGS_SENSORTYPE(_flags) == BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUECRANK ? + return FLAGS_SENSORTYPE(_flags) == ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUECRANK ? BICYCLEPOWER_STANDARDCRANKTORQUE_NUMBER : BICYCLEPOWER_STANDARDWHEELTORQUE_NUMBER; } @@ -262,16 +262,16 @@ bool ProfileBicyclePowerSensor::isDataPageValid(uint8_t dataPage) { // TODO calibration data pages switch (dataPage) { case BICYCLEPOWER_STANDARDPOWERONLY_NUMBER: - return FLAGS_SENSORTYPE(_flags) != BICYCLEPOWER_FLAGS_SENSORTYPE_CTF; + return FLAGS_SENSORTYPE(_flags) != ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_CTF; case BICYCLEPOWER_STANDARDWHEELTORQUE_NUMBER: - return FLAGS_SENSORTYPE(_flags) == BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUEWHEEL; + return FLAGS_SENSORTYPE(_flags) == ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUEWHEEL; case BICYCLEPOWER_STANDARDCRANKTORQUE_NUMBER: - return FLAGS_SENSORTYPE(_flags) == BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUECRANK; + return FLAGS_SENSORTYPE(_flags) == ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUECRANK; case BICYCLEPOWER_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: - return FLAGS_SENSORTYPE(_flags) != BICYCLEPOWER_FLAGS_SENSORTYPE_CTF && + return FLAGS_SENSORTYPE(_flags) != ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_CTF && (bool)_createBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg.func; case BICYCLEPOWER_CRANKTORQUEFREQUENCY_NUMBER: - return FLAGS_SENSORTYPE(_flags) == BICYCLEPOWER_FLAGS_SENSORTYPE_CTF; + return FLAGS_SENSORTYPE(_flags) == ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_CTF; case COMMON_BATTERYSTATUS_NUMBER: return (bool)_createBatteryStatusMsg.func; case COMMON_PRODUCTINFORMATION_NUMBER: From f167f837b76a90573341399f5a01579d2a2c62ff Mon Sep 17 00:00:00 2001 From: charles-antoine fournel Date: Thu, 13 Jan 2022 08:52:46 +0100 Subject: [PATCH 184/241] add new datapages --- src/.vscode/c_cpp_properties.json | 17 +++ src/Profiles/Fec/ANTPLUS_FecDataPages.h | 9 ++ src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h | 10 ++ .../DataPages/ANTPLUS_FecBaseMainDataPage.cpp | 72 ++++++++++++ .../DataPages/ANTPLUS_FecBaseMainDataPage.h | 34 ++++++ .../ANTPLUS_FecBasicResistanceDataPage.cpp | 28 +++++ .../ANTPLUS_FecBasicResistanceDataPage.h | 26 +++++ ...LUS_FecCapabilitiesInformationDataPage.cpp | 40 +++++++ ...TPLUS_FecCapabilitiesInformationDataPage.h | 27 +++++ .../ANTPLUS_FecGeneralMainDataPage.cpp | 41 ++++--- .../ANTPLUS_FecGeneralMainDataPage.h | 29 +++-- .../ANTPLUS_FecGeneralSettingsDataPage.cpp | 60 ++++++++++ .../ANTPLUS_FecGeneralSettingsDataPage.h | 29 +++++ .../ANTPLUS_FecManufacturerInformation.cpp | 54 +++++++++ .../ANTPLUS_FecManufacturerInformation.h | 28 +++++ .../ANTPLUS_FecProductInformation.cpp | 31 +++++ .../DataPages/ANTPLUS_FecProductInformation.h | 24 ++++ .../ANTPLUS_FecTargetPowerDataPage.cpp | 29 +++++ .../ANTPLUS_FecTargetPowerDataPage.h | 26 +++++ .../ANTPLUS_FecTrackResistanceDataPage.cpp | 31 +++++ .../ANTPLUS_FecTrackResistanceDataPage.h | 26 +++++ .../ANTPLUS_FecUserInformationDataPage.cpp | 42 +++++++ .../ANTPLUS_FecUserInformationDataPage.h | 27 +++++ .../Profiles/ANTPLUS_FecProfileDisplay.cpp | 106 ++++++++++++++++++ .../Fec/Profiles/ANTPLUS_FecProfileDisplay.h | 34 +++++- 25 files changed, 854 insertions(+), 26 deletions(-) create mode 100644 src/.vscode/c_cpp_properties.json create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecBaseMainDataPage.cpp create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecBaseMainDataPage.h create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.cpp create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.h create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecCapabilitiesInformationDataPage.cpp create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecCapabilitiesInformationDataPage.h create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.cpp create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.h create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecManufacturerInformation.cpp create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecManufacturerInformation.h create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecProductInformation.cpp create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecProductInformation.h create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.cpp create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.h create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.cpp create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.h create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecUserInformationDataPage.cpp create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecUserInformationDataPage.h diff --git a/src/.vscode/c_cpp_properties.json b/src/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..4c12546 --- /dev/null +++ b/src/.vscode/c_cpp_properties.json @@ -0,0 +1,17 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**", + "/home/charles/Arduino/libraries/ANT-Arduino/src/**" + ], + "defines": [], + "compilerPath": "/usr/bin/gcc", + "cStandard": "gnu17", + "cppStandard": "gnu++14", + "intelliSenseMode": "linux-gcc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/src/Profiles/Fec/ANTPLUS_FecDataPages.h b/src/Profiles/Fec/ANTPLUS_FecDataPages.h index 3b10475..d785670 100644 --- a/src/Profiles/Fec/ANTPLUS_FecDataPages.h +++ b/src/Profiles/Fec/ANTPLUS_FecDataPages.h @@ -2,5 +2,14 @@ #define ANTPLUS_PROFILEFECDATAPAGES_h #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif // ANTPLUS_PROFILEFECDATAPAGES_h diff --git a/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h b/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h index 1dbe7c7..be9b00b 100644 --- a/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h +++ b/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h @@ -10,6 +10,16 @@ // 30 / 2.5 = 12 #define ANTPLUS_FEC_SEARCHTIMEOUT 12 +/* DataPages number */ +#define ANTPLUS_FEC_MANUFACTURERINFORMATION_NUMBER 80 +#define ANTPLUS_FEC_PRODUCT_INFORMATION_NUMBER 81 #define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_NUMBER 25 +#define ANTPLUS_FEC_GENERAL_INFORMATION_NUMBER 16 +#define ANTPLUS_FEC_GENERAL_SETTINGS_NUMBER 17 +#define ANTPLUS_FEC_BASIC_RESISTANCE_NUMBER 48 +#define ANTPLUS_FEC_TARGET_POWER_NUMBER 49 +#define ANTPLUS_FEC_TRACK_RESISTANCE_NUMBER 51 +#define ANTPLUS_FEC_CAPABILITIES_INFORMATION_NUMBER 54 +#define ANTPLUS_FEC_USER_INFORMATION_NUMBER 55 #endif // ANTPLUS_FECPROFILEPRIVATEDEFINES_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..26e2c3c --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecBaseMainDataPage.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 +FecCoreMainDataPage::FecCoreMainDataPage() : CoreDataPage() {} + +template +uint8_t FecCoreMainDataPage::getDataPageNumber() { + return this->get8BitValue(DATAPAGE_BYTE, DATAPAGE_MASK); +} + +template +uint8_t FecCoreMainDataPage::getPageChangeToggle() { + return this->get8BitValue(TOGGLE_BYTE, TOGGLE_MASK, TOGGLE_SHIFT); +} + +template +uint16_t FecCoreMainDataPage::getHeartBeatEventTime() { + return this->get16BitValue(HEARTBEATEVENTTIME_LSB_BYTE, HEARTBEATEVENTTIME_MSB_BYTE); +} + +template +uint8_t FecCoreMainDataPage::getHeartBeatCount() { + return this->get8BitValue(HEARTBEATCOUNT_BYTE); +} + +template +uint8_t FecCoreMainDataPage::getComputedHeartRate() { + return this->get8BitValue(COMPUTEDHEARTRATE_BYTE); +} + +template class FecCoreMainDataPage; +template class FecCoreMainDataPage; + +FecBaseMainDataPage::FecBaseMainDataPage(AntRxDataResponse& dp) : + BaseDataPage(dp), + FecCoreMainDataPage() {} + +FecBaseMainDataPageMsg::FecBaseMainDataPageMsg(uint8_t dataPageNumber) : + BaseDataPageMsg(), + FecCoreMainDataPage() { + setDataBuffer(_buffer); + set8BitValue(dataPageNumber, ANTPLUS_DEFAULT_DATAPAGE_BYTE); +} + +void FecBaseMainDataPageMsg::setPageChangeToggle(uint8_t toggle) { + set8BitValue(toggle ? 1 : 0, TOGGLE_BYTE, TOGGLE_MASK, TOGGLE_SHIFT); +} + +void FecBaseMainDataPageMsg::setHeartBeatEventTime(uint16_t time) { + set16BitValue(time, HEARTBEATEVENTTIME_LSB_BYTE, + HEARTBEATEVENTTIME_MSB_BYTE); +} + +void FecBaseMainDataPageMsg::setHeartBeatCount(uint8_t count) { + set8BitValue(count, HEARTBEATCOUNT_BYTE); +} + +void FecBaseMainDataPageMsg::setComputedHeartRate(uint8_t heartRate) { + set8BitValue(heartRate, COMPUTEDHEARTRATE_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..69c0dd7 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecBaseMainDataPage.h @@ -0,0 +1,34 @@ +#ifndef ANTPLUS_FECBASEMAINDATAPAGE_h +#define ANTPLUS_FECBASEMAINDATAPAGE_h + +#include +#include + +template +class FecCoreMainDataPage : virtual public CoreDataPage { +public: + FecCoreMainDataPage(); + uint8_t getDataPageNumber() override; + uint8_t getPageChangeToggle(); + uint16_t getHeartBeatEventTime(); + uint8_t getHeartBeatCount(); + uint8_t getComputedHeartRate(); +}; + +class FecBaseMainDataPage : public BaseDataPage, public FecCoreMainDataPage { +public: + explicit FecBaseMainDataPage(AntRxDataResponse& dp); +}; + +class FecBaseMainDataPageMsg : public BaseDataPageMsg, public FecCoreMainDataPage { +public: + explicit FecBaseMainDataPageMsg(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_FECBASEMAINDATAPAGE_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.cpp new file mode 100644 index 0000000..7babfdf --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.cpp @@ -0,0 +1,28 @@ +#include +#include + +#define POWER_BYTE 7 + +template +FecBaseBasicResistanceDataPage::FecBaseBasicResistanceDataPage() : + CoreDataPage() {} + +template +uint8_t FecBaseBasicResistanceDataPage::getPower() { + return this->get8BitValue(POWER_BYTE); +} + +template class FecBaseBasicResistanceDataPage; +template class FecBaseBasicResistanceDataPage; + +FecBasicResistanceDataPage::FecBasicResistanceDataPage(AntRxDataResponse& dp) : + FecBaseMainDataPage(dp), + FecBaseBasicResistanceDataPage() {} + +FecBasicResistanceDataMsg::FecBasicResistanceDataMsg() : + FecBaseMainDataPageMsg(ANTPLUS_FEC_BASIC_RESISTANCE_NUMBER), + FecBaseBasicResistanceDataPage() {} + +void FecBasicResistanceDataMsg::setPower(uint8_t Power) { + set8BitValue(Power, POWER_BYTE); +} diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.h new file mode 100644 index 0000000..ca2bd86 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.h @@ -0,0 +1,26 @@ +#ifndef ANTPLUS_FECBASICRESISTANCEDATAPAGE_h +#define ANTPLUS_FECBASICRESISTANCEDATAPAGE_h + +#include + +template +class FecBaseBasicResistanceDataPage : virtual public CoreDataPage { +public: + FecBaseBasicResistanceDataPage(); + uint8_t getPower(); +}; + +class FecBasicResistanceDataPage : public FecBaseMainDataPage, public FecBaseBasicResistanceDataPage { +public: + explicit FecBasicResistanceDataPage(AntRxDataResponse& dp); +}; + +class FecBasicResistanceDataMsg : public FecBaseMainDataPageMsg, public FecBaseBasicResistanceDataPage { +public: + FecBasicResistanceDataMsg(); + void setPower(uint8_t Power); +}; + + +#endif // ANTPLUS_FECBASICRESISTANCEDATAPAGE_h + diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecCapabilitiesInformationDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecCapabilitiesInformationDataPage.cpp new file mode 100644 index 0000000..764baa2 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecCapabilitiesInformationDataPage.cpp @@ -0,0 +1,40 @@ +#include +#include + +#define MAX_RESISTANCE_LSB_BYTE 5 +#define MAX_RESISTANCE_MSB_BYTE 6 +#define FEC_CAPABILITIES_BYTE 7 + +template +FecBaseCapabilitiesInformationDatapage::FecBaseCapabilitiesInformationDatapage() : + CoreDataPage() {} + +template +uint16_t FecBaseCapabilitiesInformationDatapage::getMaximumResistance() { + return this->get16BitValue(MAX_RESISTANCE_LSB_BYTE, MAX_RESISTANCE_MSB_BYTE); +} + +template +uint8_t FecBaseCapabilitiesInformationDatapage::getCapabilities() { + return this->get8BitValue(FEC_CAPABILITIES_BYTE); +} + +template class FecBaseCapabilitiesInformationDatapage; +template class FecBaseCapabilitiesInformationDatapage; + +FecCapabilitiesInformationDatapage::FecCapabilitiesInformationDatapage(AntRxDataResponse& dp) : + FecBaseMainDataPage(dp), + FecBaseCapabilitiesInformationDatapage() {} + +FecCapabilitiesInformationMsg::FecCapabilitiesInformationMsg() : + FecBaseMainDataPageMsg(ANTPLUS_FEC_USER_INFORMATION_NUMBER), + FecBaseCapabilitiesInformationDatapage() {} + +void FecCapabilitiesInformationMsg::setMaximumResistance(uint16_t MaximumResistance) { + set16BitValue(MaximumResistance, MAX_RESISTANCE_LSB_BYTE, MAX_RESISTANCE_MSB_BYTE); +} + +void FecCapabilitiesInformationMsg::setCapabitilies(uint8_t Capabilities) { + set8BitValue(Capabilities, FEC_CAPABILITIES_BYTE); +} + diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecCapabilitiesInformationDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecCapabilitiesInformationDataPage.h new file mode 100644 index 0000000..253f3c3 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecCapabilitiesInformationDataPage.h @@ -0,0 +1,27 @@ +#ifndef ANTPLUS_FECCAPABILITIESINFORMATIONDATAPAGE_h +#define ANTPLUS_FECCAPABILITIESINFORMATIONDATAPAGE_h + +#include + +template +class FecBaseCapabilitiesInformationDatapage : virtual public CoreDataPage { +public: + FecBaseCapabilitiesInformationDatapage(); + uint16_t getMaximumResistance(); + uint8_t getCapabilities(); +}; + +class FecCapabilitiesInformationDatapage : public FecBaseMainDataPage, public FecBaseCapabilitiesInformationDatapage { +public: + explicit FecCapabilitiesInformationDatapage(AntRxDataResponse& dp); +}; + +class FecCapabilitiesInformationMsg : public FecBaseMainDataPageMsg, public FecBaseCapabilitiesInformationDatapage { +public: + FecCapabilitiesInformationMsg(); + void setMaximumResistance(uint16_t UserWeight); + void setCapabitilies(uint8_t BikeWeight); +}; + +#endif // ANTPLUS_FECCAPABILITIESINFORMATIONDATAPAGE_h + diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp index 9bead91..98dc316 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp @@ -16,50 +16,61 @@ #define FESTATEBITFIELD_SHIFT 4 template -FECGeneralMainDataPage::FECGeneralMainDataPage() : +FecBaseGeneralMainDataPage::FecBaseGeneralMainDataPage() : CoreDataPage() {} template -uint8_t FECGeneralMainDataPage::getDataPageNumber() { - return this->get8BitValue(ANTPLUS_DEFAULT_DATAPAGE_BYTE); -} - -template -uint8_t FECGeneralMainDataPage::getEquipmentTypeBits() { +uint8_t FecBaseGeneralMainDataPage::getEquipmentTypeBits() { return this->get8BitValue(EQUIPMENTTYPEBITS_BYTE); } template -uint8_t FECGeneralMainDataPage::getElapsedTime() { +uint8_t FecBaseGeneralMainDataPage::getElapsedTime() { return this->get8BitValue(ELAPSEDTIME_BYTE); } template -uint8_t FECGeneralMainDataPage::getDistanceTraveled() { +uint8_t FecBaseGeneralMainDataPage::getDistanceTraveled() { return this->get8BitValue(DISTANCETRAVELED_BYTE); } template -uint8_t FECGeneralMainDataPage::getHeartRate() { +uint8_t FecBaseGeneralMainDataPage::getHeartRate() { return this->get8BitValue(HEARTRATE_BYTE); } template -uint8_t FECGeneralMainDataPage::getCapabilitiesBits() { +uint8_t FecBaseGeneralMainDataPage::getCapabilitiesBits() { return this->get8BitValue(CAPABILITIESBITFIELD_BYTE, CAPABILITIESBITFIELD_MASK); } template -uint8_t FECGeneralMainDataPage::getFEStateBits() { +uint8_t FecBaseGeneralMainDataPage::getFEStateBits() { return this->get8BitValue(FESTATEBITFIELD_BYTE, FESTATEBITFIELD_MASK, FESTATEBITFIELD_SHIFT); } template -uint16_t FECGeneralMainDataPage::getSpeed() { +/* + +in meter / s + +*/ +uint16_t FecBaseGeneralMainDataPage::getSpeed(bool km) { + if ( km == true ){ + return 3.6 * (this->get16BitValue(SPEED_LSB_BYTE, SPEED_MSB_BYTE)) /1000; + } return this->get16BitValue(SPEED_LSB_BYTE, SPEED_MSB_BYTE); } -template class FECGeneralMainDataPage; -template class FECGeneralMainDataPage; +template class FecBaseGeneralMainDataPage; +template class FecBaseGeneralMainDataPage; + +FecGeneralMainDataPage::FecGeneralMainDataPage(AntRxDataResponse& dp) : + FecBaseMainDataPage(dp), + FecBaseGeneralMainDataPage() {} + +FecGeneralMainDataMsg::FecGeneralMainDataMsg() : + FecBaseMainDataPageMsg(ANTPLUS_FEC_GENERAL_INFORMATION_NUMBER), + FecBaseGeneralMainDataPage() {} \ No newline at end of file diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.h index 1060f49..479c127 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.h +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.h @@ -1,22 +1,31 @@ -#ifndef ANTPLUS_FECCOREMAINDATAPAGE_h -#define ANTPLUS_FECCOREMAINDATAPAGE_h +#ifndef ANTPLUS_FECGENERALMAINDATAPAGE_h +#define ANTPLUS_FECGENERALMAINDATAPAGE_h -#include - -#include "ANT.h" +#include template -class FECGeneralMainDataPage : virtual public CoreDataPage { +class FecBaseGeneralMainDataPage : virtual public CoreDataPage { public: - FECGeneralMainDataPage(); - uint8_t getDataPageNumber(); + FecBaseGeneralMainDataPage(); uint8_t getEquipmentTypeBits(); uint8_t getElapsedTime(); uint8_t getDistanceTraveled(); - uint16_t getSpeed(); + uint16_t getSpeed(bool km); uint8_t getHeartRate(); uint8_t getCapabilitiesBits(); uint8_t getFEStateBits(); }; -#endif // ANTPLUS_FECCOREMAINDATAPAGE_h +class FecGeneralMainDataPage : public FecBaseMainDataPage, public FecBaseGeneralMainDataPage { +public: + explicit FecGeneralMainDataPage(AntRxDataResponse& dp); +}; + +class FecGeneralMainDataMsg : public FecBaseMainDataPageMsg, public FecBaseGeneralMainDataPage { +public: + FecGeneralMainDataMsg(); + // void setSoftwareRevision(uint16_t SoftwareRevision); +}; + + +#endif // ANTPLUS_FECGENERALMAINDATAPAGE_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.cpp new file mode 100644 index 0000000..fe4d096 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.cpp @@ -0,0 +1,60 @@ +#include +#include +#include + +// TODO this is a mixture of datapages +#define CYCLE_LENGTH_BYTE 3 +#define INCLINE_LSB_BYTE 4 +#define INCLINE_MSB_BYTE 5 +#define RESISTANTCE_LEVEL_BYTE 6 +#define CAPABILITIESBITFIELD_BYTE 7 +#define CAPABILITIESBITFIELD_MASK 0x0F +#define FESTATEBITFIELD_BYTE 7 +#define FESTATEBITFIELD_MASK 0xF0 +#define FESTATEBITFIELD_SHIFT 4 + +template +FecBaseGeneralSettingsDataPage::FecBaseGeneralSettingsDataPage() : + CoreDataPage() {} + +template +uint8_t FecBaseGeneralSettingsDataPage::getCycleLength() { + return this->get8BitValue(CYCLE_LENGTH_BYTE); +} + +template +uint8_t FecBaseGeneralSettingsDataPage::getInclineValue() { + return this->get16BitValue(INCLINE_MSB_BYTE, INCLINE_LSB_BYTE); +} + +template +uint8_t FecBaseGeneralSettingsDataPage::getResistanceLevel() { + return this->get8BitValue(RESISTANTCE_LEVEL_BYTE); +} + +template +uint8_t FecBaseGeneralSettingsDataPage::getCapabilitiesBits() { + return this->get8BitValue(CAPABILITIESBITFIELD_BYTE, + CAPABILITIESBITFIELD_MASK); +} + +template +uint8_t FecBaseGeneralSettingsDataPage::getFEStateBits() { + return this->get8BitValue(FESTATEBITFIELD_BYTE, FESTATEBITFIELD_MASK, + FESTATEBITFIELD_SHIFT); +} + +template class FecBaseGeneralSettingsDataPage; +template class FecBaseGeneralSettingsDataPage; + +FecGeneralSettingsDataPage::FecGeneralSettingsDataPage(AntRxDataResponse& dp) : + FecBaseMainDataPage(dp), + FecBaseGeneralSettingsDataPage() {} + +FecGeneralSettingsDataMsg::FecGeneralSettingsDataMsg() : + FecBaseMainDataPageMsg(ANTPLUS_FEC_GENERAL_SETTINGS_NUMBER), + FecBaseGeneralSettingsDataPage() {} + +void FecGeneralSettingsDataMsg::setResistanceLevel(uint8_t ResistanceLevel) { + set8BitValue(ResistanceLevel, RESISTANTCE_LEVEL_BYTE); +} diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.h new file mode 100644 index 0000000..7620393 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.h @@ -0,0 +1,29 @@ +#ifndef ANTPLUS_FECGENERALSEETTINGSDATAPAGE_h +#define ANTPLUS_FECGENERALSEETTINGSDATAPAGE_h + +#include + +template +class FecBaseGeneralSettingsDataPage : virtual public CoreDataPage { +public: + FecBaseGeneralSettingsDataPage(); + uint8_t getCycleLength(); + uint8_t getInclineValue(); + uint8_t getResistanceLevel(); + uint8_t getCapabilitiesBits(); + uint8_t getFEStateBits(); +}; + +class FecGeneralSettingsDataPage : public FecBaseMainDataPage, public FecBaseGeneralSettingsDataPage { +public: + explicit FecGeneralSettingsDataPage(AntRxDataResponse& dp); +}; + +class FecGeneralSettingsDataMsg : public FecBaseMainDataPageMsg, public FecBaseGeneralSettingsDataPage { +public: + FecGeneralSettingsDataMsg(); + void setResistanceLevel(uint8_t ResistanceLevel); +}; + + +#endif // ANTPLUS_FECGENERALSETTINGSDATAPAGE_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecManufacturerInformation.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecManufacturerInformation.cpp new file mode 100644 index 0000000..9211eb5 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecManufacturerInformation.cpp @@ -0,0 +1,54 @@ +#include +#include + +//#define DP_NUMBER_BYTE 1 +#define RESERVED_BYTE 1 +#define RESERVER_BYTE2 2 +#define HW_REVISION_BYTE 3 +#define MANUFACTUREREIDLSB_BYTE 4 +#define MANUFACTUREREIDMSB_BYTE 5 +#define MODELNUMBER_LSB_BYTE 6 +#define MODELNUMBER_MSB_BYTE 7 + +template +FecBaseManufacturerInformation::FecBaseManufacturerInformation() : + CoreDataPage() {} + +template +uint16_t FecBaseManufacturerInformation::getManufacturerId() { + return this->get16BitValue(MANUFACTUREREIDLSB_BYTE, MANUFACTUREREIDMSB_BYTE); +} + +template +uint16_t FecBaseManufacturerInformation::getModelNumber() { + return this->get16BitValue(MODELNUMBER_LSB_BYTE, MODELNUMBER_MSB_BYTE); +} + +template +uint8_t FecBaseManufacturerInformation::getHardwareRevision() { + return this->get8BitValue(HW_REVISION_BYTE); +} + +template class FecBaseManufacturerInformation; +template class FecBaseManufacturerInformation; + +FecManufacturerInformation::FecManufacturerInformation(AntRxDataResponse& dp) : + FecBaseMainDataPage(dp), + FecBaseManufacturerInformation() {} + +FecManufacturerInformationMsg::FecManufacturerInformationMsg() : + FecBaseMainDataPageMsg(ANTPLUS_FEC_MANUFACTURERINFORMATION_NUMBER), + FecBaseManufacturerInformation() {} + +void FecManufacturerInformationMsg::setManufacturerId(uint16_t id) { + set16BitValue(id, MANUFACTUREREIDLSB_BYTE, MANUFACTUREREIDMSB_BYTE); +} + +void FecManufacturerInformationMsg::setModelNumber(uint16_t ModelNumber) { + set16BitValue(ModelNumber, MODELNUMBER_LSB_BYTE, MODELNUMBER_MSB_BYTE); +} + +void FecManufacturerInformationMsg::setHardwareRevision(uint8_t HardwareRevision) { + set8BitValue(HardwareRevision, HW_REVISION_BYTE); +} + diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecManufacturerInformation.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecManufacturerInformation.h new file mode 100644 index 0000000..255a025 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecManufacturerInformation.h @@ -0,0 +1,28 @@ +#ifndef ANTPLUS_FECMANUFACTURERINFORMATION_h +#define ANTPLUS_FECMANUFACTURERINFORMATION_h + +#include + +template +class FecBaseManufacturerInformation : virtual public CoreDataPage { +public: + FecBaseManufacturerInformation(); + uint16_t getManufacturerId(); + uint8_t getHardwareRevision(); + uint16_t getModelNumber(); +}; + +class FecManufacturerInformation : public FecBaseMainDataPage, public FecBaseManufacturerInformation { +public: + explicit FecManufacturerInformation(AntRxDataResponse& dp); +}; + +class FecManufacturerInformationMsg : public FecBaseMainDataPageMsg, public FecBaseManufacturerInformation { +public: + FecManufacturerInformationMsg(); + void setManufacturerId(uint16_t id); + void setModelNumber(uint16_t ModelNumber); + void setHardwareRevision(uint8_t HardwareRevision); +}; + +#endif // ANTPLUS_FECMANUFACTURERINFORMATION_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecProductInformation.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecProductInformation.cpp new file mode 100644 index 0000000..8d75d1a --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecProductInformation.cpp @@ -0,0 +1,31 @@ +#include +#include + +#define RESERVED_BYTE 1 +#define SW_SUPLEMENTAL_REVISION_BYTE 2 +#define SW_MAIN_REVISION_BYTE 3 + +template +FecBaseProductInformation::FecBaseProductInformation() : + CoreDataPage() {} + +template +uint16_t FecBaseProductInformation::getSoftwareRevision() { + return this->get16BitValue(SW_MAIN_REVISION_BYTE, SW_SUPLEMENTAL_REVISION_BYTE); +} + +template class FecBaseProductInformation; +template class FecBaseProductInformation; + +FecProductInformation::FecProductInformation(AntRxDataResponse& dp) : + FecBaseMainDataPage(dp), + FecBaseProductInformation() {} + +FecProductInformationMsg::FecProductInformationMsg() : + FecBaseMainDataPageMsg(ANTPLUS_FEC_PRODUCT_INFORMATION_NUMBER), + FecBaseProductInformation() {} + +void FecProductInformationMsg::setSoftwareRevision(uint16_t SoftwareRevision) { + set16BitValue(SoftwareRevision, SW_MAIN_REVISION_BYTE, SW_SUPLEMENTAL_REVISION_BYTE); +} + diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecProductInformation.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecProductInformation.h new file mode 100644 index 0000000..cc1dd78 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecProductInformation.h @@ -0,0 +1,24 @@ +#ifndef ANTPLUS_FECPRODUCTINFORMATION_h +#define ANTPLUS_FECPRODUCTINFORMATION_h + +#include + +template +class FecBaseProductInformation : virtual public CoreDataPage { +public: + FecBaseProductInformation(); + uint16_t getSoftwareRevision(); +}; + +class FecProductInformation : public FecBaseMainDataPage, public FecBaseProductInformation { +public: + explicit FecProductInformation(AntRxDataResponse& dp); +}; + +class FecProductInformationMsg : public FecBaseMainDataPageMsg, public FecBaseProductInformation { +public: + FecProductInformationMsg(); + void setSoftwareRevision(uint16_t SoftwareRevision); +}; + +#endif // ANTPLUS_FECPRODUCTINFORMATION_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.cpp new file mode 100644 index 0000000..15c1eec --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.cpp @@ -0,0 +1,29 @@ +#include +#include + +#define TARGET_POWER_LSB_BYTE 6 +#define TARGET_POWER_MSB_BYTE 7 + +template +FecBaseTargetPowerDataPage::FecBaseTargetPowerDataPage() : + CoreDataPage() {} + +template +uint16_t FecBaseTargetPowerDataPage::getTargetPower() { + return this->get16BitValue(TARGET_POWER_LSB_BYTE, TARGET_POWER_MSB_BYTE); +} + +template class FecBaseTargetPowerDataPage; +template class FecBaseTargetPowerDataPage; + +FecTargetPowerDataPage::FecTargetPowerDataPage(AntRxDataResponse& dp) : + FecBaseMainDataPage(dp), + FecBaseTargetPowerDataPage() {} + +FecTargetPowerDataMsg::FecTargetPowerDataMsg() : + FecBaseMainDataPageMsg(ANTPLUS_FEC_TARGET_POWER_NUMBER), + FecBaseTargetPowerDataPage() {} + +void FecTargetPowerDataMsg::setTargetPower(uint16_t TargetPower) { + set16BitValue(TargetPower, TARGET_POWER_LSB_BYTE, TARGET_POWER_MSB_BYTE); +} diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.h new file mode 100644 index 0000000..90cb800 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.h @@ -0,0 +1,26 @@ +#ifndef ANTPLUS_FECTARGETPOWERDATAPAGE_h +#define ANTPLUS_FECTARGETPOWERDATAPAGE_h + +#include + +template +class FecBaseTargetPowerDataPage : virtual public CoreDataPage { +public: + FecBaseTargetPowerDataPage(); + uint16_t getTargetPower(); +}; + +class FecTargetPowerDataPage : public FecBaseMainDataPage, public FecBaseTargetPowerDataPage { +public: + explicit FecTargetPowerDataPage(AntRxDataResponse& dp); +}; + +class FecTargetPowerDataMsg : public FecBaseMainDataPageMsg, public FecBaseTargetPowerDataPage { +public: + FecTargetPowerDataMsg(); + void setTargetPower(uint16_t TargetPower); +}; + + +#endif // ANTPLUS_FECTARGETPOWERDATAPAGE_h + diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.cpp new file mode 100644 index 0000000..92df87d --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.cpp @@ -0,0 +1,31 @@ +#include +#include +#include + +// TODO this is a mixture of datapages +#define GRADE_LSB_BYTE 5 +#define GRADE_MSB_BYTE 6 + +template +FecBaseTrackResistanceDataPage::FecBaseTrackResistanceDataPage() : + CoreDataPage() {} + +template +uint16_t FecBaseTrackResistanceDataPage::getGrade() { + return this->get16BitValue(GRADE_LSB_BYTE, GRADE_MSB_BYTE); +} + +template class FecBaseTrackResistanceDataPage; +template class FecBaseTrackResistanceDataPage; + +FecTrackResistanceDataPage::FecTrackResistanceDataPage(AntRxDataResponse& dp) : + FecBaseMainDataPage(dp), + FecBaseTrackResistanceDataPage() {} + +FecTrackResistanceDataMsg::FecTrackResistanceDataMsg() : + FecBaseMainDataPageMsg(ANTPLUS_FEC_TRACK_RESISTANCE_NUMBER), + FecBaseTrackResistanceDataPage() {} + +void FecTrackResistanceDataMsg::setTargetGrade(uint16_t TargetGrade) { + set16BitValue(TargetGrade, GRADE_LSB_BYTE, GRADE_MSB_BYTE); +} diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.h new file mode 100644 index 0000000..d0771c5 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.h @@ -0,0 +1,26 @@ +#ifndef ANTPLUS_FECTRACKRESISTANCEDATAPAGE_h +#define ANTPLUS_FECTRACKRESISTANCEDATAPAGE_h + +#include + +template +class FecBaseTrackResistanceDataPage : virtual public CoreDataPage { +public: + FecBaseTrackResistanceDataPage(); + uint16_t getGrade(); +}; + +class FecTrackResistanceDataPage : public FecBaseMainDataPage, public FecBaseTrackResistanceDataPage { +public: + explicit FecTrackResistanceDataPage(AntRxDataResponse& dp); +}; + +class FecTrackResistanceDataMsg : public FecBaseMainDataPageMsg, public FecBaseTrackResistanceDataPage { +public: + FecTrackResistanceDataMsg(); + void setTargetGrade(uint16_t TargetGrade); +}; + + +#endif // ANTPLUS_FECTRACKRESISTANCEDATAPAGE_h + diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecUserInformationDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecUserInformationDataPage.cpp new file mode 100644 index 0000000..cceb2e9 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecUserInformationDataPage.cpp @@ -0,0 +1,42 @@ +#include +#include + +#define USER_WEIGHT_LSB_BYTE 1 +#define USER_WEIGHT_MSB_BYTE 2 +#define BICYCLE_WHEEL_BYTE 4 +#define BICYCLE_WEIGHT_LSB_BYTE 4 +#define BICYCLE_WEIGHT_MSB_BYTE 5 + +template +FecBaseUserInformationDatapage::FecBaseUserInformationDatapage() : + CoreDataPage() {} + +template +uint16_t FecBaseUserInformationDatapage::getUserWeight() { + return this->get16BitValue(USER_WEIGHT_LSB_BYTE, USER_WEIGHT_MSB_BYTE); +} + +template +uint16_t FecBaseUserInformationDatapage::getBikeWeight() { + return this->get16BitValue(BICYCLE_WEIGHT_LSB_BYTE, BICYCLE_WEIGHT_MSB_BYTE); +} + +template class FecBaseUserInformationDatapage; +template class FecBaseUserInformationDatapage; + +FecUserInformationDatapage::FecUserInformationDatapage(AntRxDataResponse& dp) : + FecBaseMainDataPage(dp), + FecBaseUserInformationDatapage() {} + +FecUserInformationMsg::FecUserInformationMsg() : + FecBaseMainDataPageMsg(ANTPLUS_FEC_USER_INFORMATION_NUMBER), + FecBaseUserInformationDatapage() {} + +void FecUserInformationMsg::setUserWeight(uint16_t UserWeight) { + set16BitValue(UserWeight, USER_WEIGHT_LSB_BYTE, USER_WEIGHT_MSB_BYTE); +} + +void FecUserInformationMsg::setBikeWeight(uint16_t BikeWeight) { + set16BitValue(BikeWeight, BICYCLE_WEIGHT_LSB_BYTE, BICYCLE_WEIGHT_MSB_BYTE); +} + diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecUserInformationDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecUserInformationDataPage.h new file mode 100644 index 0000000..8af6856 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecUserInformationDataPage.h @@ -0,0 +1,27 @@ +#ifndef ANTPLUS_FECUSERINFORMATIONDATAPAGE_h +#define ANTPLUS_FECUSERINFORMATIONDATAPAGE_h + +#include + +template +class FecBaseUserInformationDatapage : virtual public CoreDataPage { +public: + FecBaseUserInformationDatapage(); + uint16_t getUserWeight(); + uint16_t getBikeWeight(); +}; + +class FecUserInformationDatapage : public FecBaseMainDataPage, public FecBaseUserInformationDatapage { +public: + explicit FecUserInformationDatapage(AntRxDataResponse& dp); +}; + +class FecUserInformationMsg : public FecBaseMainDataPageMsg, public FecBaseUserInformationDatapage { +public: + FecUserInformationMsg(); + void setUserWeight(uint16_t UserWeight); + void setBikeWeight(uint16_t BikeWeight); +}; + +#endif // ANTPLUS_FECUSERINFORMATIONDATAPAGE_h + diff --git a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp index 50fc368..2734477 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp @@ -21,6 +21,35 @@ bool ProfileFecDisplay::handleDataPage(BaseDataPage& dp) { case ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_NUMBER: called = handleTrainerData(dp); break; + + case ANTPLUS_FEC_MANUFACTURERINFORMATION_NUMBER: + called = handleManufacturerInformation(dp); + break; + + case ANTPLUS_FEC_PRODUCT_INFORMATION_NUMBER: + called = handleProductInformation(dp); + break; + + case ANTPLUS_FEC_GENERAL_INFORMATION_NUMBER: + called = handleGeneralDataPage(dp); + break; + + case ANTPLUS_FEC_GENERAL_SETTINGS_NUMBER: + called = handleGeneralSettingsDataPage(dp); + break; + + case ANTPLUS_FEC_TARGET_POWER_NUMBER: + called = handleTargetPowerDataPage(dp); + break; + + case ANTPLUS_FEC_CAPABILITIES_INFORMATION_NUMBER: + called = handleCapabilitiesInformationDataPage(dp); + break; + + case ANTPLUS_FEC_BASIC_RESISTANCE_NUMBER: + called = handleBasicResistanceDataPage(dp); + break; + } return called; @@ -42,7 +71,84 @@ void ProfileFecDisplay::setChannelConfig() { setSearchTimeout(ANTPLUS_FEC_SEARCHTIMEOUT); } +bool ProfileFecDisplay::handleManufacturerInformation(BaseDataPage& dataPage) { + FecManufacturerInformation dp(dataPage); + return _onFecManufacturerInformation.call(dp); +} + +bool ProfileFecDisplay::handleProductInformation(BaseDataPage& dataPage) { + FecProductInformation dp(dataPage); + return _onFecProductInformation.call(dp); +} + +bool ProfileFecDisplay::handleGeneralDataPage(BaseDataPage& dataPage) { + FecGeneralMainDataPage dp(dataPage); + return _onFecGeneralDataPage.call(dp); +} + +bool ProfileFecDisplay::handleGeneralSettingsDataPage(BaseDataPage& dataPage) { + FecGeneralSettingsDataPage dp(dataPage); + return _onFecGeneralSettingsDataPage.call(dp); +} +bool ProfileFecDisplay::handleTargetPowerDataPage(BaseDataPage& dataPage) { + FecTargetPowerDataPage dp(dataPage); + return _onFecTargetPowerDataPage.call(dp); +} + +bool ProfileFecDisplay::handleBasicResistanceDataPage(BaseDataPage& dataPage) { + FecBasicResistanceDataPage dp(dataPage); + return _onFecBasicResistanceDataPage.call(dp); +} + +bool ProfileFecDisplay::handleCapabilitiesInformationDataPage(BaseDataPage& dataPage) { + FecCapabilitiesInformationDatapage dp(dataPage); + return _onFecCapabilitiesInformationDataPage.call(dp); +} + +bool ProfileFecDisplay::transmitFecTargetPowerMsg(uint16_t TargetPower) { + FecTargetPowerDataMsg msg; + msg.setTargetPower(TargetPower); + send(msg); + return false; +} + +bool ProfileFecDisplay::transmitFecTrackResistanceMsg(uint16_t TargetGrade) { + FecTrackResistanceDataMsg msg; + msg.setTargetGrade(TargetGrade); + send(msg); + return false; +} + +bool ProfileFecDisplay::transmitFecBasicResistanceMsg(uint8_t Power) { + FecBasicResistanceDataMsg msg; + msg.setPower(Power); + send(msg); + return false; +} + +bool ProfileFecDisplay::transmitFecUserInformationMsg(uint16_t UserWeight, uint16_t BikeWeight) { + FecUserInformationMsg msg; + msg.setUserWeight(UserWeight); + msg.setBikeWeight(BikeWeight); + send(msg); + return true; +} + +bool ProfileFecDisplay::transmitFecCapabitiliesRequestMsg() +{ + FecCapabilitiesInformationMsg msg; + msg.setCapabitilies(0); + msg.setMaximumResistance(800); + send(msg); + return true; +} + bool ProfileFecDisplay::handleTrainerData(BaseDataPage& dataPage) { FecSpecificTrainerData dp(dataPage); return _onFecSpecificTrainerData.call(dp); } + +bool ProfileFecDisplay::handleUserInformationDataPage(BaseDataPage& dataPage) { + FecUserInformationDatapage dp(dataPage); + return _onFecUserInformationDataPage.call(dp); +} diff --git a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h index 08cff44..ab634d8 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h @@ -9,6 +9,20 @@ 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 onFecManufacturerInformation(void (*func)(FecManufacturerInformation&, uintptr_t), uintptr_t data = 0) { _onFecManufacturerInformation.set(func, data); } + void onFecProductInformation(void (*func)(FecProductInformation&, uintptr_t), uintptr_t data = 0) { _onFecProductInformation.set(func, data); } + void onFecGeneralDataPage(void (*func)(FecGeneralMainDataPage&, uintptr_t), uintptr_t data = 0) { _onFecGeneralDataPage.set(func, data); } + void onFecGeneralSettingsDataPage(void (*func)(FecGeneralSettingsDataPage&, uintptr_t), uintptr_t data = 0) { _onFecGeneralSettingsDataPage.set(func, data); } + void onFecTargetPowerDataPage(void (*func)(FecTargetPowerDataPage&, uintptr_t), uintptr_t data = 0) { _onFecTargetPowerDataPage.set(func, data); } + void onFecTrackResistanceDataPage(void (*func)(FecTrackResistanceDataPage&, uintptr_t), uintptr_t data = 0) { _onFecTrackResistanceDataPage.set(func, data); } + void onFecBasicResistanceDataPage(void (*func)(FecBasicResistanceDataPage&, uintptr_t), uintptr_t data = 0) { _onFecBasicResistanceDataPage.set(func, data); } + void onFecUserInformationDataPage(void (*func)(FecUserInformationDatapage&, uintptr_t), uintptr_t data = 0) { _onFecUserInformationDataPage.set(func, data); } + void onFecCapabilitiesInformationDataPage(void (*func)(FecCapabilitiesInformationDatapage&, uintptr_t), uintptr_t data = 0) { _onFecCapabilitiesInformationDataPage.set(func, data); } + bool transmitFecTargetPowerMsg(uint16_t TargetPower); + bool transmitFecTrackResistanceMsg(uint16_t TrackResistance); + bool transmitFecBasicResistanceMsg(uint8_t Power); + bool transmitFecUserInformationMsg(uint16_t UserWeight, uint16_t BikeWeight); + bool transmitFecCapabitiliesRequestMsg(); private: void setChannelConfig(); @@ -16,9 +30,27 @@ class ProfileFecDisplay : public BaseSlaveProfile { void onAcknowledgedData(AcknowledgedData& msg) override; bool handleDataPage(BaseDataPage& dp); - + bool handleManufacturerInformation(BaseDataPage& dataPage); + bool handleProductInformation(BaseDataPage& dataPage); + bool handleGeneralDataPage(BaseDataPage& dataPage); + bool handleGeneralSettingsDataPage(BaseDataPage& dataPage); bool handleTrainerData(BaseDataPage& dataPage); + bool handleTargetPowerDataPage(BaseDataPage& dataPage); + bool handleTrackResistanceDataPage(BaseDataPage& dataPage); + bool handleBasicResistanceDataPage(BaseDataPage& dataPage); + bool handleUserInformationDataPage(BaseDataPage& dataPage); + bool handleCapabilitiesInformationDataPage(BaseDataPage& dataPage); + AntCallback _onFecSpecificTrainerData = { .func = NULL }; + AntCallback _onFecManufacturerInformation = { .func = NULL }; + AntCallback _onFecProductInformation = { .func = NULL }; + AntCallback _onFecGeneralDataPage = { .func = NULL }; + AntCallback _onFecGeneralSettingsDataPage = { .func = NULL }; + AntCallback _onFecTargetPowerDataPage = { .func = NULL }; + AntCallback _onFecTrackResistanceDataPage = { .func = NULL }; + AntCallback _onFecBasicResistanceDataPage = { .func = NULL }; + AntCallback _onFecUserInformationDataPage = { .func = NULL }; + AntCallback _onFecCapabilitiesInformationDataPage = { .func = NULL }; }; #endif // ANTPLUS_PROFILEFECDISPLAY_h From 3d695b9094d51848754c377baae93b85bdc506a6 Mon Sep 17 00:00:00 2001 From: charles-antoine fournel Date: Thu, 13 Jan 2022 08:55:42 +0100 Subject: [PATCH 185/241] add example for native driver --- .../FecBikeTrainerDisplay/fe-c_native.ino | 209 ++++++++++++++++++ 1 file changed, 209 insertions(+) create mode 100644 examples/FecBikeTrainerDisplay/fe-c_native.ino diff --git a/examples/FecBikeTrainerDisplay/fe-c_native.ino b/examples/FecBikeTrainerDisplay/fe-c_native.ino new file mode 100644 index 0000000..c08f769 --- /dev/null +++ b/examples/FecBikeTrainerDisplay/fe-c_native.ino @@ -0,0 +1,209 @@ +/*********************************** + * AntPlus Native Drive Fe-c Display + * + * Finds a nearby Indoor bike trainer + * And display content sent by it + * + * Author Charles-Antoine FOURNEL + ************************************/ +#include +#include "ANT.h" +#include "ANTPLUS.h" +#include "bluefruit.h" +#define BAUD_RATE 115200 +#define CHANNEL_0 0 +#define TOTAL_CHANNELS 1 +#define ENCRYPTED_CHANNELS 0 + +const uint8_t NETWORK_KEY[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}; // get this from thisisant.com + +ArduinoNativeAntWithCallbacks ant; +AntPlusRouter router = AntPlusRouter(); +ProfileFecDisplay ht = ProfileFecDisplay(); + +void fecBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data); +void batteryStatusDataPageHandler(HeartRateBatteryStatus& msg, uintptr_t data); +void capabilitiesDataPageHandler(HeartRateCapabilities& msg, uintptr_t data); +void cumulativeOperatingTimeDataPageHandler(HeartRateCumulativeOperatingTime& msg, uintptr_t data); +void defaultDataPageHandler(HeartRateDefault& msg, uintptr_t data); +void manufacturerInformationDataPageHandler(FecManufacturerInformation& msg, uintptr_t data); +void productInformationDataPageHandler(FecProductInformation& msg, uintptr_t data); +void GeneralDataPageHandler(FecGeneralMainDataPage& msg, uintptr_t data); +void GeneralSettingsDataPageHandler(FecGeneralSettingsDataPage& msg, uintptr_t data); +void SpecificTrainerDataPageHandler(FecSpecificTrainerData& msg, uintptr_t data); +void CapabitiliesDataPageHandler(FecCapabilitiesInformationDatapage& msg, uintptr_t data); + +void TargetPowerDataPagehandler(FecTargetPowerDataPage& msg, uintptr_t data); +void TrackREsistanceDataPageHandler(FecTrackResistanceDataPage& msg, uintptr_t data); + +long previousMillis = 0; +long interval = 4000; +int TargetPower = 50; +void fecRateFeatures(uint8_t bitfield); +void printStatus(uint8_t status); + +void setup() { + delay(2000); + Bluefruit.begin() ; + Serial1.begin(BAUD_RATE); + ant.begin(TOTAL_CHANNELS, ENCRYPTED_CHANNELS); + delay(5000); + + router.setDriver(&ant); // never touch ant again + router.setAntPlusNetworkKey(NETWORK_KEY); + router.setProfile(CHANNEL_0, &ht); + // Delay after initial setup to wait for user to connect on serial + + Serial.begin(BAUD_RATE); + Serial.println("Running"); + ht.onDataPage(fecBaseDataPageHandler); + //ht.onFecManufacturerInformation(manufacturerInformationDataPageHandler); + //ht.onFecProductInformation(ProductInformationDataPageHandler); + ht.onFecGeneralDataPage(GeneralDataPageHandler); + //ht.onFecGeneralSettingsDataPage(GeneralSettingsDataPageHandler); + ht.onFecTargetPowerDataPage(TargetPowerDataPagehandler); + ht.onFecTrackResistanceDataPage(TrackResistanceDataPageHandler); + ht.onFecTrainerData(SpecificTrainerDataPageHandler); + ht.onFecCapabilitiesInformationDataPage(CapabitiliesDataPageHandler); + + ht.begin(); + // wait for pair to complete + uint8_t status = ht.waitForPair(); + // print channel status + Serial.println("==========================="); + printStatus(status); + Serial.print("Device Number: "); + Serial.println(ht.getDeviceNumber()); + Serial.print("Transmisison Type: "); + Serial.println(ht.getTransmissionType()); + Serial.print("settings user information"); + ht.transmitFecUserInformationMsg(9000, 3000); + // get fec capabilities + ht.transmitFecCapabitiliesRequestMsg(); + Serial.print("Ask for capacity"); // this datapage not always sent by indoor bike trainer + +} + +void loop() { + router.loop(); + ant.readPacket(); + 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) + { + // save the last time you blinked the LED + previousMillis = currentMillis; + //Serial.println("Envoi de la puissance vise"); + if ( TargetPower == 100 ) + { + TargetPower = 50; + }else{ + TargetPower = 100; + } + ht.transmitFecTargetPowerMsg(TargetPower); + Serial.println(TargetPower); + } +} + + +void manufacturerInformationDataPageHandler(FecManufacturerInformation& 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.getHardwareRevision()); +} + +void ProductInformationDataPageHandler(FecProductInformation& msg, uintptr_t data) { + Serial.print("Software Revision: "); + Serial.println(msg.getSoftwareRevision()); +} + +void GeneralDataPageHandler(FecGeneralMainDataPage& msg, uintptr_t data) { + Serial.print("Equipment type: "); + Serial.println(msg.getEquipmentTypeBits()); + Serial.print("Current speed:" ); + Serial.println(msg.getSpeed(true)); + Serial.print("FE State:"); + Serial.println(msg.getFEStateBits()); + Serial.print("FEC CAPABILITIES:"); + Serial.println(msg.getCapabilitiesBits()); +} + +void GeneralSettingsDataPageHandler(FecGeneralSettingsDataPage& msg, uintptr_t data) { + Serial.print("Cycle length: "); + Serial.println(msg.getCycleLength()); + Serial.print("Incline value:" ); + Serial.println(msg.getInclineValue()); + Serial.print("Resistance level:"); + Serial.println(msg.getResistanceLevel()); +} + + +void fecBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data) { + FecBaseMainDataPage dp = FecBaseMainDataPage(msg); + Serial.println("==========================="); + Serial.print("DataPage: "); + Serial.println(dp.getDataPageNumber()); +} + +void TargetPowerDataPagehandler(FecTargetPowerDataPage& msg, uintptr_t data){ + Serial.print("Target POWER: "); + Serial.println(msg.getTargetPower()); +} + +void TrackResistanceDataPageHandler(FecTrackResistanceDataPage& msg, uintptr_t data){ + Serial.print("Track Resistance: "); + Serial.println(msg.getGrade()); +} + +void SpecificTrainerDataPageHandler(FecSpecificTrainerData& msg, uintptr_t data){ + Serial.print("Trainer status: "); + Serial.println(msg.getTrainerStatusBits()); + if ( msg.getTrainerStatusBits() == 4 ) + { + ht.transmitFecUserInformationMsg(9000, 3000); + Serial.println("Envoi des informations utilisateurs :"); + } + Serial.print("Trainer flag bit: "); + Serial.println(msg.getFlagsBits()); +} + +void CapabitiliesDataPageHandler(FecCapabilitiesInformationDatapage& msg, uintptr_t data) +{ + Serial.print("Max resistance: "); + Serial.println(msg.getMaximumResistance()); + Serial.print("Fec Capabilities: "); + Serial.println(msg.getCapabilities()); +} + + +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; + } +} From d2086faa99abc24480f35df671bd4b3200b31514 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 23 Jan 2022 12:21:41 -0800 Subject: [PATCH 186/241] remove vscode config system specific changes --- src/.vscode/c_cpp_properties.json | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 src/.vscode/c_cpp_properties.json diff --git a/src/.vscode/c_cpp_properties.json b/src/.vscode/c_cpp_properties.json deleted file mode 100644 index 4c12546..0000000 --- a/src/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "configurations": [ - { - "name": "Linux", - "includePath": [ - "${workspaceFolder}/**", - "/home/charles/Arduino/libraries/ANT-Arduino/src/**" - ], - "defines": [], - "compilerPath": "/usr/bin/gcc", - "cStandard": "gnu17", - "cppStandard": "gnu++14", - "intelliSenseMode": "linux-gcc-x64" - } - ], - "version": 4 -} \ No newline at end of file From 03391649c648f60cb160b457ae55a2a3c29fa515 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 23 Jan 2022 12:27:16 -0800 Subject: [PATCH 187/241] examples: Fec: BikeTrainer update * rename to match folder so arduino is happy * switch base driver so CI is happy * remove trailing whitespace --- ...c_native.ino => FecBikeTrainerDisplay.ino} | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) rename examples/FecBikeTrainerDisplay/{fe-c_native.ino => FecBikeTrainerDisplay.ino} (95%) diff --git a/examples/FecBikeTrainerDisplay/fe-c_native.ino b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino similarity index 95% rename from examples/FecBikeTrainerDisplay/fe-c_native.ino rename to examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino index c08f769..e565b0e 100644 --- a/examples/FecBikeTrainerDisplay/fe-c_native.ino +++ b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino @@ -17,7 +17,7 @@ const uint8_t NETWORK_KEY[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}; // get this from thisisant.com -ArduinoNativeAntWithCallbacks ant; +ArduinoSerialAntWithCallbacks ant; AntPlusRouter router = AntPlusRouter(); ProfileFecDisplay ht = ProfileFecDisplay(); @@ -36,8 +36,8 @@ void CapabitiliesDataPageHandler(FecCapabilitiesInformationDatapage& msg, uintpt void TargetPowerDataPagehandler(FecTargetPowerDataPage& msg, uintptr_t data); void TrackREsistanceDataPageHandler(FecTrackResistanceDataPage& msg, uintptr_t data); -long previousMillis = 0; -long interval = 4000; +long previousMillis = 0; +long interval = 4000; int TargetPower = 50; void fecRateFeatures(uint8_t bitfield); void printStatus(uint8_t status); @@ -94,16 +94,16 @@ void loop() { } unsigned long currentMillis = millis(); - /** - * - * Just a quick test to switch target power + /** + * + * Just a quick test to switch target power * every **interval** - * + * */ - if(currentMillis - previousMillis > interval) + if(currentMillis - previousMillis > interval) { - // save the last time you blinked the LED - previousMillis = currentMillis; + // save the last time you blinked the LED + previousMillis = currentMillis; //Serial.println("Envoi de la puissance vise"); if ( TargetPower == 100 ) { @@ -186,7 +186,7 @@ void CapabitiliesDataPageHandler(FecCapabilitiesInformationDatapage& msg, uintpt Serial.print("Max resistance: "); Serial.println(msg.getMaximumResistance()); Serial.print("Fec Capabilities: "); - Serial.println(msg.getCapabilities()); + Serial.println(msg.getCapabilities()); } From 19c0ae7d820a753adafdf5420fd060205fa5e018 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 24 Jan 2022 18:30:53 -0800 Subject: [PATCH 188/241] examples: fec: update for CI * update driver to CI compatible driver * update name of profile object * remove debug code --- .../FecBikeTrainerDisplay.ino | 43 +++++++++---------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino index e565b0e..aa4d628 100644 --- a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino +++ b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino @@ -19,7 +19,7 @@ const uint8_t NETWORK_KEY[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}; ArduinoSerialAntWithCallbacks ant; AntPlusRouter router = AntPlusRouter(); -ProfileFecDisplay ht = ProfileFecDisplay(); +ProfileFecDisplay fec = ProfileFecDisplay(); void fecBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data); void batteryStatusDataPageHandler(HeartRateBatteryStatus& msg, uintptr_t data); @@ -44,9 +44,8 @@ void printStatus(uint8_t status); void setup() { delay(2000); - Bluefruit.begin() ; Serial1.begin(BAUD_RATE); - ant.begin(TOTAL_CHANNELS, ENCRYPTED_CHANNELS); + ant.begin(9600); delay(5000); router.setDriver(&ant); // never touch ant again @@ -56,30 +55,30 @@ void setup() { Serial.begin(BAUD_RATE); Serial.println("Running"); - ht.onDataPage(fecBaseDataPageHandler); - //ht.onFecManufacturerInformation(manufacturerInformationDataPageHandler); - //ht.onFecProductInformation(ProductInformationDataPageHandler); - ht.onFecGeneralDataPage(GeneralDataPageHandler); - //ht.onFecGeneralSettingsDataPage(GeneralSettingsDataPageHandler); - ht.onFecTargetPowerDataPage(TargetPowerDataPagehandler); - ht.onFecTrackResistanceDataPage(TrackResistanceDataPageHandler); - ht.onFecTrainerData(SpecificTrainerDataPageHandler); - ht.onFecCapabilitiesInformationDataPage(CapabitiliesDataPageHandler); - - ht.begin(); + fec.onDataPage(fecBaseDataPageHandler); + //fec.onFecManufacturerInformation(manufacturerInformationDataPageHandler); + //fec.onFecProductInformation(ProductInformationDataPageHandler); + fec.onFecGeneralDataPage(GeneralDataPageHandler); + //fec.onFecGeneralSettingsDataPage(GeneralSettingsDataPageHandler); + fec.onFecTargetPowerDataPage(TargetPowerDataPagehandler); + fec.onFecTrackResistanceDataPage(TrackResistanceDataPageHandler); + fec.onFecTrainerData(SpecificTrainerDataPageHandler); + fec.onFecCapabilitiesInformationDataPage(CapabitiliesDataPageHandler); + + fec.begin(); // wait for pair to complete - uint8_t status = ht.waitForPair(); + uint8_t status = fec.waitForPair(); // print channel status Serial.println("==========================="); printStatus(status); Serial.print("Device Number: "); - Serial.println(ht.getDeviceNumber()); + Serial.println(fec.getDeviceNumber()); Serial.print("Transmisison Type: "); - Serial.println(ht.getTransmissionType()); + Serial.println(fec.getTransmissionType()); Serial.print("settings user information"); - ht.transmitFecUserInformationMsg(9000, 3000); + fec.transmitFecUserInformationMsg(9000, 3000); // get fec capabilities - ht.transmitFecCapabitiliesRequestMsg(); + fec.transmitFecCapabitiliesRequestMsg(); Serial.print("Ask for capacity"); // this datapage not always sent by indoor bike trainer } @@ -102,16 +101,14 @@ void loop() { */ if(currentMillis - previousMillis > interval) { - // save the last time you blinked the LED previousMillis = currentMillis; - //Serial.println("Envoi de la puissance vise"); - if ( TargetPower == 100 ) + if (TargetPower == 100) { TargetPower = 50; }else{ TargetPower = 100; } - ht.transmitFecTargetPowerMsg(TargetPower); + fec.transmitFecTargetPowerMsg(TargetPower); Serial.println(TargetPower); } } From da7cf5abcaa2123c4d6aa13c4a11461ca7d15e9f Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 24 Jan 2022 18:33:28 -0800 Subject: [PATCH 189/241] Fec: Convert to unix line endings Sorry but im a unix guy :) --- src/Profiles/Fec/ANTPLUS_FecDataPages.h | 30 +- src/Profiles/Fec/ANTPLUS_FecDefines.h | 48 +-- src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h | 50 +-- src/Profiles/Fec/ANTPLUS_FecProfile.h | 28 +- .../ANTPLUS_FecBasicResistanceDataPage.cpp | 56 ++-- .../ANTPLUS_FecBasicResistanceDataPage.h | 52 +-- .../DataPages/ANTPLUS_FecFEMainDataPage.cpp | 26 +- .../Fec/DataPages/ANTPLUS_FecFEMainDataPage.h | 28 +- .../ANTPLUS_FecGeneralMainDataPage.cpp | 150 ++++----- .../ANTPLUS_FecGeneralMainDataPage.h | 62 ++-- .../ANTPLUS_FecGeneralSettingsDataPage.cpp | 120 +++---- .../ANTPLUS_FecGeneralSettingsDataPage.h | 58 ++-- .../ANTPLUS_FecSpecificTrainerData.cpp | 122 +++---- .../ANTPLUS_FecSpecificTrainerData.h | 48 +-- .../ANTPLUS_FecTargetPowerDataPage.cpp | 58 ++-- .../ANTPLUS_FecTargetPowerDataPage.h | 52 +-- .../ANTPLUS_FecTrackResistanceDataPage.cpp | 62 ++-- .../ANTPLUS_FecTrackResistanceDataPage.h | 52 +-- .../Profiles/ANTPLUS_FecProfileDisplay.cpp | 308 +++++++++--------- .../Fec/Profiles/ANTPLUS_FecProfileDisplay.h | 112 +++---- 20 files changed, 761 insertions(+), 761 deletions(-) diff --git a/src/Profiles/Fec/ANTPLUS_FecDataPages.h b/src/Profiles/Fec/ANTPLUS_FecDataPages.h index d785670..108b5c0 100644 --- a/src/Profiles/Fec/ANTPLUS_FecDataPages.h +++ b/src/Profiles/Fec/ANTPLUS_FecDataPages.h @@ -1,15 +1,15 @@ -#ifndef ANTPLUS_PROFILEFECDATAPAGES_h -#define ANTPLUS_PROFILEFECDATAPAGES_h - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif // ANTPLUS_PROFILEFECDATAPAGES_h +#ifndef ANTPLUS_PROFILEFECDATAPAGES_h +#define ANTPLUS_PROFILEFECDATAPAGES_h + +#include +#include +#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 index ec80d18..52be091 100644 --- a/src/Profiles/Fec/ANTPLUS_FecDefines.h +++ b/src/Profiles/Fec/ANTPLUS_FecDefines.h @@ -1,24 +1,24 @@ -#ifndef ANTPLUS_FECPROFILEDEFINES_h -#define ANTPLUS_FECPROFILEDEFINES_h - -#define ANTPLUS_FEC_DEVICETYPE 17 - -#define ANTPLUS_FEC_FLAGS_CUMULATIVEOPERATINGTIME_SUPPORTED (1 << 0) -#define ANTPLUS_FEC_FLAGS_PREVIOUSHEARTBEAT_SUPPORTED (1 << 1) -#define ANTPLUS_FEC_FLAGS_EXTENTED_FEATURES (1 << 2) -#define ANTPLUS_FEC_FLAGS_BATTERYSTATUS_SUPPORTED (1 << 3) - -#define ANTPLUS_FEC_DATAPAGE_CAPABILITIES_FEATURES_EXTENDEDRUNNING 0x01 -#define ANTPLUS_FEC_DATAPAGE_CAPABILITIES_FEATURES_EXTENDEDCYCLING 0x02 -#define ANTPLUS_FEC_DATAPAGE_CAPABILITIES_FEATURES_EXTENDEDSWIMMING 0x04 -#define ANTPLUS_FEC_DATAPAGE_CAPABILITIES_FEATURES_MANUFACTURER1 0x40 -#define ANTPLUS_FEC_DATAPAGE_CAPABILITIES_FEATURES_MANUFACTURER2 0x80 - -// TODO all below defines need to be added to example -#define ANTPLUS_FEC_DATAPAGE_PREVIOUSHEARTBEAT_MANUFACTURERSPECIFIC_INVALID 0xFF - -#define ANTPLUS_FEC_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALAVERAGEFEC_INVALID 0 -#define ANTPLUS_FEC_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALMAXIMUMFEC_INVALID 0 -#define ANTPLUS_FEC_DATAPAGE_SWIMINTERVALSUMMARY_SESSIONAVERAGEFEC_INVALID 0 - -#endif // ANTPLUS_FECPROFILEDEFINES_h +#ifndef ANTPLUS_FECPROFILEDEFINES_h +#define ANTPLUS_FECPROFILEDEFINES_h + +#define ANTPLUS_FEC_DEVICETYPE 17 + +#define ANTPLUS_FEC_FLAGS_CUMULATIVEOPERATINGTIME_SUPPORTED (1 << 0) +#define ANTPLUS_FEC_FLAGS_PREVIOUSHEARTBEAT_SUPPORTED (1 << 1) +#define ANTPLUS_FEC_FLAGS_EXTENTED_FEATURES (1 << 2) +#define ANTPLUS_FEC_FLAGS_BATTERYSTATUS_SUPPORTED (1 << 3) + +#define ANTPLUS_FEC_DATAPAGE_CAPABILITIES_FEATURES_EXTENDEDRUNNING 0x01 +#define ANTPLUS_FEC_DATAPAGE_CAPABILITIES_FEATURES_EXTENDEDCYCLING 0x02 +#define ANTPLUS_FEC_DATAPAGE_CAPABILITIES_FEATURES_EXTENDEDSWIMMING 0x04 +#define ANTPLUS_FEC_DATAPAGE_CAPABILITIES_FEATURES_MANUFACTURER1 0x40 +#define ANTPLUS_FEC_DATAPAGE_CAPABILITIES_FEATURES_MANUFACTURER2 0x80 + +// TODO all below defines need to be added to example +#define ANTPLUS_FEC_DATAPAGE_PREVIOUSHEARTBEAT_MANUFACTURERSPECIFIC_INVALID 0xFF + +#define ANTPLUS_FEC_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALAVERAGEFEC_INVALID 0 +#define ANTPLUS_FEC_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALMAXIMUMFEC_INVALID 0 +#define ANTPLUS_FEC_DATAPAGE_SWIMINTERVALSUMMARY_SESSIONAVERAGEFEC_INVALID 0 + +#endif // ANTPLUS_FECPROFILEDEFINES_h diff --git a/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h b/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h index be9b00b..f3036c6 100644 --- a/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h +++ b/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h @@ -1,25 +1,25 @@ -#ifndef ANTPLUS_FECPROFILEPRIVATEDEFINES_h -#define ANTPLUS_FECPROFILEPRIVATEDEFINES_h - -#include - -/* Channel Config */ -#define ANTPLUS_FEC_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE -#define ANTPLUS_FEC_MONITOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT -#define ANTPLUS_FEC_CHANNELPERIOD 8192 -// 30 / 2.5 = 12 -#define ANTPLUS_FEC_SEARCHTIMEOUT 12 - -/* DataPages number */ -#define ANTPLUS_FEC_MANUFACTURERINFORMATION_NUMBER 80 -#define ANTPLUS_FEC_PRODUCT_INFORMATION_NUMBER 81 -#define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_NUMBER 25 -#define ANTPLUS_FEC_GENERAL_INFORMATION_NUMBER 16 -#define ANTPLUS_FEC_GENERAL_SETTINGS_NUMBER 17 -#define ANTPLUS_FEC_BASIC_RESISTANCE_NUMBER 48 -#define ANTPLUS_FEC_TARGET_POWER_NUMBER 49 -#define ANTPLUS_FEC_TRACK_RESISTANCE_NUMBER 51 -#define ANTPLUS_FEC_CAPABILITIES_INFORMATION_NUMBER 54 -#define ANTPLUS_FEC_USER_INFORMATION_NUMBER 55 - -#endif // ANTPLUS_FECPROFILEPRIVATEDEFINES_h +#ifndef ANTPLUS_FECPROFILEPRIVATEDEFINES_h +#define ANTPLUS_FECPROFILEPRIVATEDEFINES_h + +#include + +/* Channel Config */ +#define ANTPLUS_FEC_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE +#define ANTPLUS_FEC_MONITOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT +#define ANTPLUS_FEC_CHANNELPERIOD 8192 +// 30 / 2.5 = 12 +#define ANTPLUS_FEC_SEARCHTIMEOUT 12 + +/* DataPages number */ +#define ANTPLUS_FEC_MANUFACTURERINFORMATION_NUMBER 80 +#define ANTPLUS_FEC_PRODUCT_INFORMATION_NUMBER 81 +#define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_NUMBER 25 +#define ANTPLUS_FEC_GENERAL_INFORMATION_NUMBER 16 +#define ANTPLUS_FEC_GENERAL_SETTINGS_NUMBER 17 +#define ANTPLUS_FEC_BASIC_RESISTANCE_NUMBER 48 +#define ANTPLUS_FEC_TARGET_POWER_NUMBER 49 +#define ANTPLUS_FEC_TRACK_RESISTANCE_NUMBER 51 +#define ANTPLUS_FEC_CAPABILITIES_INFORMATION_NUMBER 54 +#define ANTPLUS_FEC_USER_INFORMATION_NUMBER 55 + +#endif // ANTPLUS_FECPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/Fec/ANTPLUS_FecProfile.h b/src/Profiles/Fec/ANTPLUS_FecProfile.h index 3dab049..fc9a540 100644 --- a/src/Profiles/Fec/ANTPLUS_FecProfile.h +++ b/src/Profiles/Fec/ANTPLUS_FecProfile.h @@ -1,14 +1,14 @@ -#ifndef ANTPLUS_FECPROFILE_h -#define ANTPLUS_FECPROFILE_h - -// General Definitions -#include - -// Datapages -#include - -// Profile Classes -#include -// #include - -#endif // ANTPLUS_FECPROFILE_h +#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_FecBasicResistanceDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.cpp index 7babfdf..ff70680 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.cpp @@ -1,28 +1,28 @@ -#include -#include - -#define POWER_BYTE 7 - -template -FecBaseBasicResistanceDataPage::FecBaseBasicResistanceDataPage() : - CoreDataPage() {} - -template -uint8_t FecBaseBasicResistanceDataPage::getPower() { - return this->get8BitValue(POWER_BYTE); -} - -template class FecBaseBasicResistanceDataPage; -template class FecBaseBasicResistanceDataPage; - -FecBasicResistanceDataPage::FecBasicResistanceDataPage(AntRxDataResponse& dp) : - FecBaseMainDataPage(dp), - FecBaseBasicResistanceDataPage() {} - -FecBasicResistanceDataMsg::FecBasicResistanceDataMsg() : - FecBaseMainDataPageMsg(ANTPLUS_FEC_BASIC_RESISTANCE_NUMBER), - FecBaseBasicResistanceDataPage() {} - -void FecBasicResistanceDataMsg::setPower(uint8_t Power) { - set8BitValue(Power, POWER_BYTE); -} +#include +#include + +#define POWER_BYTE 7 + +template +FecBaseBasicResistanceDataPage::FecBaseBasicResistanceDataPage() : + CoreDataPage() {} + +template +uint8_t FecBaseBasicResistanceDataPage::getPower() { + return this->get8BitValue(POWER_BYTE); +} + +template class FecBaseBasicResistanceDataPage; +template class FecBaseBasicResistanceDataPage; + +FecBasicResistanceDataPage::FecBasicResistanceDataPage(AntRxDataResponse& dp) : + FecBaseMainDataPage(dp), + FecBaseBasicResistanceDataPage() {} + +FecBasicResistanceDataMsg::FecBasicResistanceDataMsg() : + FecBaseMainDataPageMsg(ANTPLUS_FEC_BASIC_RESISTANCE_NUMBER), + FecBaseBasicResistanceDataPage() {} + +void FecBasicResistanceDataMsg::setPower(uint8_t Power) { + set8BitValue(Power, POWER_BYTE); +} diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.h index ca2bd86..2b6c16c 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.h +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.h @@ -1,26 +1,26 @@ -#ifndef ANTPLUS_FECBASICRESISTANCEDATAPAGE_h -#define ANTPLUS_FECBASICRESISTANCEDATAPAGE_h - -#include - -template -class FecBaseBasicResistanceDataPage : virtual public CoreDataPage { -public: - FecBaseBasicResistanceDataPage(); - uint8_t getPower(); -}; - -class FecBasicResistanceDataPage : public FecBaseMainDataPage, public FecBaseBasicResistanceDataPage { -public: - explicit FecBasicResistanceDataPage(AntRxDataResponse& dp); -}; - -class FecBasicResistanceDataMsg : public FecBaseMainDataPageMsg, public FecBaseBasicResistanceDataPage { -public: - FecBasicResistanceDataMsg(); - void setPower(uint8_t Power); -}; - - -#endif // ANTPLUS_FECBASICRESISTANCEDATAPAGE_h - +#ifndef ANTPLUS_FECBASICRESISTANCEDATAPAGE_h +#define ANTPLUS_FECBASICRESISTANCEDATAPAGE_h + +#include + +template +class FecBaseBasicResistanceDataPage : virtual public CoreDataPage { +public: + FecBaseBasicResistanceDataPage(); + uint8_t getPower(); +}; + +class FecBasicResistanceDataPage : public FecBaseMainDataPage, public FecBaseBasicResistanceDataPage { +public: + explicit FecBasicResistanceDataPage(AntRxDataResponse& dp); +}; + +class FecBasicResistanceDataMsg : public FecBaseMainDataPageMsg, public FecBaseBasicResistanceDataPage { +public: + FecBasicResistanceDataMsg(); + void setPower(uint8_t Power); +}; + + +#endif // ANTPLUS_FECBASICRESISTANCEDATAPAGE_h + diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecFEMainDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecFEMainDataPage.cpp index 64dd7ec..bede4c3 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecFEMainDataPage.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecFEMainDataPage.cpp @@ -1,13 +1,13 @@ -#include -#include - -#define CADENCE_BYTE 4 -#define NEGTIVE_VERTICAL_DISTANCE_BYTE 5 - -// TODO update name -template -FECFEMainDataPage::FECFEMainDataPage() : - CoreDataPage() {} - -template class FECFEMainDataPage; -template class FECFEMainDataPage; +#include +#include + +#define CADENCE_BYTE 4 +#define NEGTIVE_VERTICAL_DISTANCE_BYTE 5 + +// TODO update name +template +FECFEMainDataPage::FECFEMainDataPage() : + CoreDataPage() {} + +template class FECFEMainDataPage; +template class FECFEMainDataPage; diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecFEMainDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecFEMainDataPage.h index 967e456..3fbd1cc 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecFEMainDataPage.h +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecFEMainDataPage.h @@ -1,14 +1,14 @@ -#ifndef ANTPLUS_FECFEEMAINDATAPAGE_h -#define ANTPLUS_FECFEEMAINDATAPAGE_h - -#include - -#include "ANT.h" - -template -class FECFEMainDataPage : virtual public CoreDataPage { -public: - FECFEMainDataPage(); -}; - -#endif // ANTPLUS_FECFEEMAINDATAPAGE_h +#ifndef ANTPLUS_FECFEEMAINDATAPAGE_h +#define ANTPLUS_FECFEEMAINDATAPAGE_h + +#include + +#include "ANT.h" + +template +class FECFEMainDataPage : virtual public CoreDataPage { +public: + FECFEMainDataPage(); +}; + +#endif // ANTPLUS_FECFEEMAINDATAPAGE_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp index 98dc316..c803a35 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp @@ -1,76 +1,76 @@ -#include -#include -#include - -// TODO this is a mixture of datapages -#define EQUIPMENTTYPEBITS_BYTE 1 -#define ELAPSEDTIME_BYTE 2 -#define DISTANCETRAVELED_BYTE 3 -#define SPEED_LSB_BYTE 4 -#define SPEED_MSB_BYTE 5 -#define HEARTRATE_BYTE 6 -#define CAPABILITIESBITFIELD_BYTE 7 -#define CAPABILITIESBITFIELD_MASK 0x0F -#define FESTATEBITFIELD_BYTE 7 -#define FESTATEBITFIELD_MASK 0xF0 -#define FESTATEBITFIELD_SHIFT 4 - -template -FecBaseGeneralMainDataPage::FecBaseGeneralMainDataPage() : - CoreDataPage() {} - -template -uint8_t FecBaseGeneralMainDataPage::getEquipmentTypeBits() { - return this->get8BitValue(EQUIPMENTTYPEBITS_BYTE); -} - -template -uint8_t FecBaseGeneralMainDataPage::getElapsedTime() { - return this->get8BitValue(ELAPSEDTIME_BYTE); -} - -template -uint8_t FecBaseGeneralMainDataPage::getDistanceTraveled() { - return this->get8BitValue(DISTANCETRAVELED_BYTE); -} - -template -uint8_t FecBaseGeneralMainDataPage::getHeartRate() { - return this->get8BitValue(HEARTRATE_BYTE); -} - -template -uint8_t FecBaseGeneralMainDataPage::getCapabilitiesBits() { - return this->get8BitValue(CAPABILITIESBITFIELD_BYTE, - CAPABILITIESBITFIELD_MASK); -} - -template -uint8_t FecBaseGeneralMainDataPage::getFEStateBits() { - return this->get8BitValue(FESTATEBITFIELD_BYTE, FESTATEBITFIELD_MASK, - FESTATEBITFIELD_SHIFT); -} - -template -/* - -in meter / s - -*/ -uint16_t FecBaseGeneralMainDataPage::getSpeed(bool km) { - if ( km == true ){ - return 3.6 * (this->get16BitValue(SPEED_LSB_BYTE, SPEED_MSB_BYTE)) /1000; - } - return this->get16BitValue(SPEED_LSB_BYTE, SPEED_MSB_BYTE); -} - -template class FecBaseGeneralMainDataPage; -template class FecBaseGeneralMainDataPage; - -FecGeneralMainDataPage::FecGeneralMainDataPage(AntRxDataResponse& dp) : - FecBaseMainDataPage(dp), - FecBaseGeneralMainDataPage() {} - -FecGeneralMainDataMsg::FecGeneralMainDataMsg() : - FecBaseMainDataPageMsg(ANTPLUS_FEC_GENERAL_INFORMATION_NUMBER), +#include +#include +#include + +// TODO this is a mixture of datapages +#define EQUIPMENTTYPEBITS_BYTE 1 +#define ELAPSEDTIME_BYTE 2 +#define DISTANCETRAVELED_BYTE 3 +#define SPEED_LSB_BYTE 4 +#define SPEED_MSB_BYTE 5 +#define HEARTRATE_BYTE 6 +#define CAPABILITIESBITFIELD_BYTE 7 +#define CAPABILITIESBITFIELD_MASK 0x0F +#define FESTATEBITFIELD_BYTE 7 +#define FESTATEBITFIELD_MASK 0xF0 +#define FESTATEBITFIELD_SHIFT 4 + +template +FecBaseGeneralMainDataPage::FecBaseGeneralMainDataPage() : + CoreDataPage() {} + +template +uint8_t FecBaseGeneralMainDataPage::getEquipmentTypeBits() { + return this->get8BitValue(EQUIPMENTTYPEBITS_BYTE); +} + +template +uint8_t FecBaseGeneralMainDataPage::getElapsedTime() { + return this->get8BitValue(ELAPSEDTIME_BYTE); +} + +template +uint8_t FecBaseGeneralMainDataPage::getDistanceTraveled() { + return this->get8BitValue(DISTANCETRAVELED_BYTE); +} + +template +uint8_t FecBaseGeneralMainDataPage::getHeartRate() { + return this->get8BitValue(HEARTRATE_BYTE); +} + +template +uint8_t FecBaseGeneralMainDataPage::getCapabilitiesBits() { + return this->get8BitValue(CAPABILITIESBITFIELD_BYTE, + CAPABILITIESBITFIELD_MASK); +} + +template +uint8_t FecBaseGeneralMainDataPage::getFEStateBits() { + return this->get8BitValue(FESTATEBITFIELD_BYTE, FESTATEBITFIELD_MASK, + FESTATEBITFIELD_SHIFT); +} + +template +/* + +in meter / s + +*/ +uint16_t FecBaseGeneralMainDataPage::getSpeed(bool km) { + if ( km == true ){ + return 3.6 * (this->get16BitValue(SPEED_LSB_BYTE, SPEED_MSB_BYTE)) /1000; + } + return this->get16BitValue(SPEED_LSB_BYTE, SPEED_MSB_BYTE); +} + +template class FecBaseGeneralMainDataPage; +template class FecBaseGeneralMainDataPage; + +FecGeneralMainDataPage::FecGeneralMainDataPage(AntRxDataResponse& dp) : + FecBaseMainDataPage(dp), + FecBaseGeneralMainDataPage() {} + +FecGeneralMainDataMsg::FecGeneralMainDataMsg() : + FecBaseMainDataPageMsg(ANTPLUS_FEC_GENERAL_INFORMATION_NUMBER), FecBaseGeneralMainDataPage() {} \ No newline at end of file diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.h index 479c127..d5ef304 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.h +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.h @@ -1,31 +1,31 @@ -#ifndef ANTPLUS_FECGENERALMAINDATAPAGE_h -#define ANTPLUS_FECGENERALMAINDATAPAGE_h - -#include - -template -class FecBaseGeneralMainDataPage : virtual public CoreDataPage { -public: - FecBaseGeneralMainDataPage(); - uint8_t getEquipmentTypeBits(); - uint8_t getElapsedTime(); - uint8_t getDistanceTraveled(); - uint16_t getSpeed(bool km); - uint8_t getHeartRate(); - uint8_t getCapabilitiesBits(); - uint8_t getFEStateBits(); -}; - -class FecGeneralMainDataPage : public FecBaseMainDataPage, public FecBaseGeneralMainDataPage { -public: - explicit FecGeneralMainDataPage(AntRxDataResponse& dp); -}; - -class FecGeneralMainDataMsg : public FecBaseMainDataPageMsg, public FecBaseGeneralMainDataPage { -public: - FecGeneralMainDataMsg(); - // void setSoftwareRevision(uint16_t SoftwareRevision); -}; - - -#endif // ANTPLUS_FECGENERALMAINDATAPAGE_h +#ifndef ANTPLUS_FECGENERALMAINDATAPAGE_h +#define ANTPLUS_FECGENERALMAINDATAPAGE_h + +#include + +template +class FecBaseGeneralMainDataPage : virtual public CoreDataPage { +public: + FecBaseGeneralMainDataPage(); + uint8_t getEquipmentTypeBits(); + uint8_t getElapsedTime(); + uint8_t getDistanceTraveled(); + uint16_t getSpeed(bool km); + uint8_t getHeartRate(); + uint8_t getCapabilitiesBits(); + uint8_t getFEStateBits(); +}; + +class FecGeneralMainDataPage : public FecBaseMainDataPage, public FecBaseGeneralMainDataPage { +public: + explicit FecGeneralMainDataPage(AntRxDataResponse& dp); +}; + +class FecGeneralMainDataMsg : public FecBaseMainDataPageMsg, public FecBaseGeneralMainDataPage { +public: + FecGeneralMainDataMsg(); + // void setSoftwareRevision(uint16_t SoftwareRevision); +}; + + +#endif // ANTPLUS_FECGENERALMAINDATAPAGE_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.cpp index fe4d096..17081f5 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.cpp @@ -1,60 +1,60 @@ -#include -#include -#include - -// TODO this is a mixture of datapages -#define CYCLE_LENGTH_BYTE 3 -#define INCLINE_LSB_BYTE 4 -#define INCLINE_MSB_BYTE 5 -#define RESISTANTCE_LEVEL_BYTE 6 -#define CAPABILITIESBITFIELD_BYTE 7 -#define CAPABILITIESBITFIELD_MASK 0x0F -#define FESTATEBITFIELD_BYTE 7 -#define FESTATEBITFIELD_MASK 0xF0 -#define FESTATEBITFIELD_SHIFT 4 - -template -FecBaseGeneralSettingsDataPage::FecBaseGeneralSettingsDataPage() : - CoreDataPage() {} - -template -uint8_t FecBaseGeneralSettingsDataPage::getCycleLength() { - return this->get8BitValue(CYCLE_LENGTH_BYTE); -} - -template -uint8_t FecBaseGeneralSettingsDataPage::getInclineValue() { - return this->get16BitValue(INCLINE_MSB_BYTE, INCLINE_LSB_BYTE); -} - -template -uint8_t FecBaseGeneralSettingsDataPage::getResistanceLevel() { - return this->get8BitValue(RESISTANTCE_LEVEL_BYTE); -} - -template -uint8_t FecBaseGeneralSettingsDataPage::getCapabilitiesBits() { - return this->get8BitValue(CAPABILITIESBITFIELD_BYTE, - CAPABILITIESBITFIELD_MASK); -} - -template -uint8_t FecBaseGeneralSettingsDataPage::getFEStateBits() { - return this->get8BitValue(FESTATEBITFIELD_BYTE, FESTATEBITFIELD_MASK, - FESTATEBITFIELD_SHIFT); -} - -template class FecBaseGeneralSettingsDataPage; -template class FecBaseGeneralSettingsDataPage; - -FecGeneralSettingsDataPage::FecGeneralSettingsDataPage(AntRxDataResponse& dp) : - FecBaseMainDataPage(dp), - FecBaseGeneralSettingsDataPage() {} - -FecGeneralSettingsDataMsg::FecGeneralSettingsDataMsg() : - FecBaseMainDataPageMsg(ANTPLUS_FEC_GENERAL_SETTINGS_NUMBER), - FecBaseGeneralSettingsDataPage() {} - -void FecGeneralSettingsDataMsg::setResistanceLevel(uint8_t ResistanceLevel) { - set8BitValue(ResistanceLevel, RESISTANTCE_LEVEL_BYTE); -} +#include +#include +#include + +// TODO this is a mixture of datapages +#define CYCLE_LENGTH_BYTE 3 +#define INCLINE_LSB_BYTE 4 +#define INCLINE_MSB_BYTE 5 +#define RESISTANTCE_LEVEL_BYTE 6 +#define CAPABILITIESBITFIELD_BYTE 7 +#define CAPABILITIESBITFIELD_MASK 0x0F +#define FESTATEBITFIELD_BYTE 7 +#define FESTATEBITFIELD_MASK 0xF0 +#define FESTATEBITFIELD_SHIFT 4 + +template +FecBaseGeneralSettingsDataPage::FecBaseGeneralSettingsDataPage() : + CoreDataPage() {} + +template +uint8_t FecBaseGeneralSettingsDataPage::getCycleLength() { + return this->get8BitValue(CYCLE_LENGTH_BYTE); +} + +template +uint8_t FecBaseGeneralSettingsDataPage::getInclineValue() { + return this->get16BitValue(INCLINE_MSB_BYTE, INCLINE_LSB_BYTE); +} + +template +uint8_t FecBaseGeneralSettingsDataPage::getResistanceLevel() { + return this->get8BitValue(RESISTANTCE_LEVEL_BYTE); +} + +template +uint8_t FecBaseGeneralSettingsDataPage::getCapabilitiesBits() { + return this->get8BitValue(CAPABILITIESBITFIELD_BYTE, + CAPABILITIESBITFIELD_MASK); +} + +template +uint8_t FecBaseGeneralSettingsDataPage::getFEStateBits() { + return this->get8BitValue(FESTATEBITFIELD_BYTE, FESTATEBITFIELD_MASK, + FESTATEBITFIELD_SHIFT); +} + +template class FecBaseGeneralSettingsDataPage; +template class FecBaseGeneralSettingsDataPage; + +FecGeneralSettingsDataPage::FecGeneralSettingsDataPage(AntRxDataResponse& dp) : + FecBaseMainDataPage(dp), + FecBaseGeneralSettingsDataPage() {} + +FecGeneralSettingsDataMsg::FecGeneralSettingsDataMsg() : + FecBaseMainDataPageMsg(ANTPLUS_FEC_GENERAL_SETTINGS_NUMBER), + FecBaseGeneralSettingsDataPage() {} + +void FecGeneralSettingsDataMsg::setResistanceLevel(uint8_t ResistanceLevel) { + set8BitValue(ResistanceLevel, RESISTANTCE_LEVEL_BYTE); +} diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.h index 7620393..7644a55 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.h +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.h @@ -1,29 +1,29 @@ -#ifndef ANTPLUS_FECGENERALSEETTINGSDATAPAGE_h -#define ANTPLUS_FECGENERALSEETTINGSDATAPAGE_h - -#include - -template -class FecBaseGeneralSettingsDataPage : virtual public CoreDataPage { -public: - FecBaseGeneralSettingsDataPage(); - uint8_t getCycleLength(); - uint8_t getInclineValue(); - uint8_t getResistanceLevel(); - uint8_t getCapabilitiesBits(); - uint8_t getFEStateBits(); -}; - -class FecGeneralSettingsDataPage : public FecBaseMainDataPage, public FecBaseGeneralSettingsDataPage { -public: - explicit FecGeneralSettingsDataPage(AntRxDataResponse& dp); -}; - -class FecGeneralSettingsDataMsg : public FecBaseMainDataPageMsg, public FecBaseGeneralSettingsDataPage { -public: - FecGeneralSettingsDataMsg(); - void setResistanceLevel(uint8_t ResistanceLevel); -}; - - -#endif // ANTPLUS_FECGENERALSETTINGSDATAPAGE_h +#ifndef ANTPLUS_FECGENERALSEETTINGSDATAPAGE_h +#define ANTPLUS_FECGENERALSEETTINGSDATAPAGE_h + +#include + +template +class FecBaseGeneralSettingsDataPage : virtual public CoreDataPage { +public: + FecBaseGeneralSettingsDataPage(); + uint8_t getCycleLength(); + uint8_t getInclineValue(); + uint8_t getResistanceLevel(); + uint8_t getCapabilitiesBits(); + uint8_t getFEStateBits(); +}; + +class FecGeneralSettingsDataPage : public FecBaseMainDataPage, public FecBaseGeneralSettingsDataPage { +public: + explicit FecGeneralSettingsDataPage(AntRxDataResponse& dp); +}; + +class FecGeneralSettingsDataMsg : public FecBaseMainDataPageMsg, public FecBaseGeneralSettingsDataPage { +public: + FecGeneralSettingsDataMsg(); + void setResistanceLevel(uint8_t ResistanceLevel); +}; + + +#endif // ANTPLUS_FECGENERALSETTINGSDATAPAGE_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp index 68183f3..55e8f7f 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp @@ -1,61 +1,61 @@ -#include -#include -#include - -// TODO correct names -#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 TRAINERSTATUS_BYTE 6 -#define FLAGSFESTATEBIT_BYTE 7 - -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 -uint8_t FecBaseSpecificTrainerData::getFlagsBits() { - return this->get8BitValue(FLAGSFESTATEBIT_BYTE) & 0x0F; -} - -template -uint8_t FecBaseSpecificTrainerData::getFEStateBits() { - return (this->get8BitValue(FLAGSFESTATEBIT_BYTE) & 0xF0) >> 4; -} - -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) & 0x0FFF; -} - -template -uint8_t FecBaseSpecificTrainerData::getTrainerStatusBits() { - return (this->get8BitValue(TRAINERSTATUS_BYTE) & 0xF0) >> 4; -} - -template class FecBaseSpecificTrainerData; -template class FecBaseSpecificTrainerData; - -FecSpecificTrainerData::FecSpecificTrainerData(AntRxDataResponse& dp) : - BaseDataPage(dp), - FecBaseSpecificTrainerData() {} +#include +#include +#include + +// TODO correct names +#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 TRAINERSTATUS_BYTE 6 +#define FLAGSFESTATEBIT_BYTE 7 + +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 +uint8_t FecBaseSpecificTrainerData::getFlagsBits() { + return this->get8BitValue(FLAGSFESTATEBIT_BYTE) & 0x0F; +} + +template +uint8_t FecBaseSpecificTrainerData::getFEStateBits() { + return (this->get8BitValue(FLAGSFESTATEBIT_BYTE) & 0xF0) >> 4; +} + +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) & 0x0FFF; +} + +template +uint8_t FecBaseSpecificTrainerData::getTrainerStatusBits() { + return (this->get8BitValue(TRAINERSTATUS_BYTE) & 0xF0) >> 4; +} + +template class FecBaseSpecificTrainerData; +template class FecBaseSpecificTrainerData; + +FecSpecificTrainerData::FecSpecificTrainerData(AntRxDataResponse& dp) : + BaseDataPage(dp), + FecBaseSpecificTrainerData() {} diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.h index 675b279..70da738 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.h +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.h @@ -1,24 +1,24 @@ -#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 getTrainerStatusBits(); - uint8_t getFlagsBits(); - uint8_t getFEStateBits(); -}; - -class FecSpecificTrainerData : public BaseDataPage, public FecBaseSpecificTrainerData { -public: - explicit FecSpecificTrainerData(AntRxDataResponse& dp); -}; - -#endif // ANTPLUS_FECTRAINERDATA_h +#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 getTrainerStatusBits(); + uint8_t getFlagsBits(); + uint8_t getFEStateBits(); +}; + +class FecSpecificTrainerData : public BaseDataPage, public FecBaseSpecificTrainerData { +public: + explicit FecSpecificTrainerData(AntRxDataResponse& dp); +}; + +#endif // ANTPLUS_FECTRAINERDATA_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.cpp index 15c1eec..d1fa586 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.cpp @@ -1,29 +1,29 @@ -#include -#include - -#define TARGET_POWER_LSB_BYTE 6 -#define TARGET_POWER_MSB_BYTE 7 - -template -FecBaseTargetPowerDataPage::FecBaseTargetPowerDataPage() : - CoreDataPage() {} - -template -uint16_t FecBaseTargetPowerDataPage::getTargetPower() { - return this->get16BitValue(TARGET_POWER_LSB_BYTE, TARGET_POWER_MSB_BYTE); -} - -template class FecBaseTargetPowerDataPage; -template class FecBaseTargetPowerDataPage; - -FecTargetPowerDataPage::FecTargetPowerDataPage(AntRxDataResponse& dp) : - FecBaseMainDataPage(dp), - FecBaseTargetPowerDataPage() {} - -FecTargetPowerDataMsg::FecTargetPowerDataMsg() : - FecBaseMainDataPageMsg(ANTPLUS_FEC_TARGET_POWER_NUMBER), - FecBaseTargetPowerDataPage() {} - -void FecTargetPowerDataMsg::setTargetPower(uint16_t TargetPower) { - set16BitValue(TargetPower, TARGET_POWER_LSB_BYTE, TARGET_POWER_MSB_BYTE); -} +#include +#include + +#define TARGET_POWER_LSB_BYTE 6 +#define TARGET_POWER_MSB_BYTE 7 + +template +FecBaseTargetPowerDataPage::FecBaseTargetPowerDataPage() : + CoreDataPage() {} + +template +uint16_t FecBaseTargetPowerDataPage::getTargetPower() { + return this->get16BitValue(TARGET_POWER_LSB_BYTE, TARGET_POWER_MSB_BYTE); +} + +template class FecBaseTargetPowerDataPage; +template class FecBaseTargetPowerDataPage; + +FecTargetPowerDataPage::FecTargetPowerDataPage(AntRxDataResponse& dp) : + FecBaseMainDataPage(dp), + FecBaseTargetPowerDataPage() {} + +FecTargetPowerDataMsg::FecTargetPowerDataMsg() : + FecBaseMainDataPageMsg(ANTPLUS_FEC_TARGET_POWER_NUMBER), + FecBaseTargetPowerDataPage() {} + +void FecTargetPowerDataMsg::setTargetPower(uint16_t TargetPower) { + set16BitValue(TargetPower, TARGET_POWER_LSB_BYTE, TARGET_POWER_MSB_BYTE); +} diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.h index 90cb800..2d0e61f 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.h +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.h @@ -1,26 +1,26 @@ -#ifndef ANTPLUS_FECTARGETPOWERDATAPAGE_h -#define ANTPLUS_FECTARGETPOWERDATAPAGE_h - -#include - -template -class FecBaseTargetPowerDataPage : virtual public CoreDataPage { -public: - FecBaseTargetPowerDataPage(); - uint16_t getTargetPower(); -}; - -class FecTargetPowerDataPage : public FecBaseMainDataPage, public FecBaseTargetPowerDataPage { -public: - explicit FecTargetPowerDataPage(AntRxDataResponse& dp); -}; - -class FecTargetPowerDataMsg : public FecBaseMainDataPageMsg, public FecBaseTargetPowerDataPage { -public: - FecTargetPowerDataMsg(); - void setTargetPower(uint16_t TargetPower); -}; - - -#endif // ANTPLUS_FECTARGETPOWERDATAPAGE_h - +#ifndef ANTPLUS_FECTARGETPOWERDATAPAGE_h +#define ANTPLUS_FECTARGETPOWERDATAPAGE_h + +#include + +template +class FecBaseTargetPowerDataPage : virtual public CoreDataPage { +public: + FecBaseTargetPowerDataPage(); + uint16_t getTargetPower(); +}; + +class FecTargetPowerDataPage : public FecBaseMainDataPage, public FecBaseTargetPowerDataPage { +public: + explicit FecTargetPowerDataPage(AntRxDataResponse& dp); +}; + +class FecTargetPowerDataMsg : public FecBaseMainDataPageMsg, public FecBaseTargetPowerDataPage { +public: + FecTargetPowerDataMsg(); + void setTargetPower(uint16_t TargetPower); +}; + + +#endif // ANTPLUS_FECTARGETPOWERDATAPAGE_h + diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.cpp index 92df87d..ec3c232 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.cpp @@ -1,31 +1,31 @@ -#include -#include -#include - -// TODO this is a mixture of datapages -#define GRADE_LSB_BYTE 5 -#define GRADE_MSB_BYTE 6 - -template -FecBaseTrackResistanceDataPage::FecBaseTrackResistanceDataPage() : - CoreDataPage() {} - -template -uint16_t FecBaseTrackResistanceDataPage::getGrade() { - return this->get16BitValue(GRADE_LSB_BYTE, GRADE_MSB_BYTE); -} - -template class FecBaseTrackResistanceDataPage; -template class FecBaseTrackResistanceDataPage; - -FecTrackResistanceDataPage::FecTrackResistanceDataPage(AntRxDataResponse& dp) : - FecBaseMainDataPage(dp), - FecBaseTrackResistanceDataPage() {} - -FecTrackResistanceDataMsg::FecTrackResistanceDataMsg() : - FecBaseMainDataPageMsg(ANTPLUS_FEC_TRACK_RESISTANCE_NUMBER), - FecBaseTrackResistanceDataPage() {} - -void FecTrackResistanceDataMsg::setTargetGrade(uint16_t TargetGrade) { - set16BitValue(TargetGrade, GRADE_LSB_BYTE, GRADE_MSB_BYTE); -} +#include +#include +#include + +// TODO this is a mixture of datapages +#define GRADE_LSB_BYTE 5 +#define GRADE_MSB_BYTE 6 + +template +FecBaseTrackResistanceDataPage::FecBaseTrackResistanceDataPage() : + CoreDataPage() {} + +template +uint16_t FecBaseTrackResistanceDataPage::getGrade() { + return this->get16BitValue(GRADE_LSB_BYTE, GRADE_MSB_BYTE); +} + +template class FecBaseTrackResistanceDataPage; +template class FecBaseTrackResistanceDataPage; + +FecTrackResistanceDataPage::FecTrackResistanceDataPage(AntRxDataResponse& dp) : + FecBaseMainDataPage(dp), + FecBaseTrackResistanceDataPage() {} + +FecTrackResistanceDataMsg::FecTrackResistanceDataMsg() : + FecBaseMainDataPageMsg(ANTPLUS_FEC_TRACK_RESISTANCE_NUMBER), + FecBaseTrackResistanceDataPage() {} + +void FecTrackResistanceDataMsg::setTargetGrade(uint16_t TargetGrade) { + set16BitValue(TargetGrade, GRADE_LSB_BYTE, GRADE_MSB_BYTE); +} diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.h index d0771c5..8fb6fb6 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.h +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.h @@ -1,26 +1,26 @@ -#ifndef ANTPLUS_FECTRACKRESISTANCEDATAPAGE_h -#define ANTPLUS_FECTRACKRESISTANCEDATAPAGE_h - -#include - -template -class FecBaseTrackResistanceDataPage : virtual public CoreDataPage { -public: - FecBaseTrackResistanceDataPage(); - uint16_t getGrade(); -}; - -class FecTrackResistanceDataPage : public FecBaseMainDataPage, public FecBaseTrackResistanceDataPage { -public: - explicit FecTrackResistanceDataPage(AntRxDataResponse& dp); -}; - -class FecTrackResistanceDataMsg : public FecBaseMainDataPageMsg, public FecBaseTrackResistanceDataPage { -public: - FecTrackResistanceDataMsg(); - void setTargetGrade(uint16_t TargetGrade); -}; - - -#endif // ANTPLUS_FECTRACKRESISTANCEDATAPAGE_h - +#ifndef ANTPLUS_FECTRACKRESISTANCEDATAPAGE_h +#define ANTPLUS_FECTRACKRESISTANCEDATAPAGE_h + +#include + +template +class FecBaseTrackResistanceDataPage : virtual public CoreDataPage { +public: + FecBaseTrackResistanceDataPage(); + uint16_t getGrade(); +}; + +class FecTrackResistanceDataPage : public FecBaseMainDataPage, public FecBaseTrackResistanceDataPage { +public: + explicit FecTrackResistanceDataPage(AntRxDataResponse& dp); +}; + +class FecTrackResistanceDataMsg : public FecBaseMainDataPageMsg, public FecBaseTrackResistanceDataPage { +public: + FecTrackResistanceDataMsg(); + void setTargetGrade(uint16_t TargetGrade); +}; + + +#endif // ANTPLUS_FECTRACKRESISTANCEDATAPAGE_h + diff --git a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp index 2734477..776484f 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp @@ -1,154 +1,154 @@ -#include -#include - -ProfileFecDisplay::ProfileFecDisplay(uint16_t deviceNumber, uint8_t transmissionType) : BaseSlaveProfile(deviceNumber, transmissionType) { - setChannelConfig(); -} - -void ProfileFecDisplay::onBroadcastData(BroadcastData& msg) { - BaseDataPage dp = BaseDataPage(msg); - BaseSlaveProfile::onBroadcastData(msg); - if (!handleDataPage(dp)) { - callOnOtherDataPage(msg); - } -} - -bool ProfileFecDisplay::handleDataPage(BaseDataPage& dp) { - uint8_t dataPage = dp.getDataPageNumber(); - bool called = false; - - switch (dataPage) { - case ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_NUMBER: - called = handleTrainerData(dp); - break; - - case ANTPLUS_FEC_MANUFACTURERINFORMATION_NUMBER: - called = handleManufacturerInformation(dp); - break; - - case ANTPLUS_FEC_PRODUCT_INFORMATION_NUMBER: - called = handleProductInformation(dp); - break; - - case ANTPLUS_FEC_GENERAL_INFORMATION_NUMBER: - called = handleGeneralDataPage(dp); - break; - - case ANTPLUS_FEC_GENERAL_SETTINGS_NUMBER: - called = handleGeneralSettingsDataPage(dp); - break; - - case ANTPLUS_FEC_TARGET_POWER_NUMBER: - called = handleTargetPowerDataPage(dp); - break; - - case ANTPLUS_FEC_CAPABILITIES_INFORMATION_NUMBER: - called = handleCapabilitiesInformationDataPage(dp); - break; - - case ANTPLUS_FEC_BASIC_RESISTANCE_NUMBER: - called = handleBasicResistanceDataPage(dp); - break; - - } - - return called; -} - -void ProfileFecDisplay::onAcknowledgedData(AcknowledgedData& msg) { - BaseDataPage dp = BaseDataPage(msg); - BaseSlaveProfile::onAcknowledgedData(msg); - if (!handleDataPage(dp)) { - callOnOtherDataPage(msg); - } -} - - -void ProfileFecDisplay::setChannelConfig() { - setChannelType(ANTPLUS_FEC_DISPLAY_CHANNELTYPE); - setDeviceType(ANTPLUS_FEC_DEVICETYPE); - setChannelPeriod(ANTPLUS_FEC_CHANNELPERIOD); - setSearchTimeout(ANTPLUS_FEC_SEARCHTIMEOUT); -} - -bool ProfileFecDisplay::handleManufacturerInformation(BaseDataPage& dataPage) { - FecManufacturerInformation dp(dataPage); - return _onFecManufacturerInformation.call(dp); -} - -bool ProfileFecDisplay::handleProductInformation(BaseDataPage& dataPage) { - FecProductInformation dp(dataPage); - return _onFecProductInformation.call(dp); -} - -bool ProfileFecDisplay::handleGeneralDataPage(BaseDataPage& dataPage) { - FecGeneralMainDataPage dp(dataPage); - return _onFecGeneralDataPage.call(dp); -} - -bool ProfileFecDisplay::handleGeneralSettingsDataPage(BaseDataPage& dataPage) { - FecGeneralSettingsDataPage dp(dataPage); - return _onFecGeneralSettingsDataPage.call(dp); -} -bool ProfileFecDisplay::handleTargetPowerDataPage(BaseDataPage& dataPage) { - FecTargetPowerDataPage dp(dataPage); - return _onFecTargetPowerDataPage.call(dp); -} - -bool ProfileFecDisplay::handleBasicResistanceDataPage(BaseDataPage& dataPage) { - FecBasicResistanceDataPage dp(dataPage); - return _onFecBasicResistanceDataPage.call(dp); -} - -bool ProfileFecDisplay::handleCapabilitiesInformationDataPage(BaseDataPage& dataPage) { - FecCapabilitiesInformationDatapage dp(dataPage); - return _onFecCapabilitiesInformationDataPage.call(dp); -} - -bool ProfileFecDisplay::transmitFecTargetPowerMsg(uint16_t TargetPower) { - FecTargetPowerDataMsg msg; - msg.setTargetPower(TargetPower); - send(msg); - return false; -} - -bool ProfileFecDisplay::transmitFecTrackResistanceMsg(uint16_t TargetGrade) { - FecTrackResistanceDataMsg msg; - msg.setTargetGrade(TargetGrade); - send(msg); - return false; -} - -bool ProfileFecDisplay::transmitFecBasicResistanceMsg(uint8_t Power) { - FecBasicResistanceDataMsg msg; - msg.setPower(Power); - send(msg); - return false; -} - -bool ProfileFecDisplay::transmitFecUserInformationMsg(uint16_t UserWeight, uint16_t BikeWeight) { - FecUserInformationMsg msg; - msg.setUserWeight(UserWeight); - msg.setBikeWeight(BikeWeight); - send(msg); - return true; -} - -bool ProfileFecDisplay::transmitFecCapabitiliesRequestMsg() -{ - FecCapabilitiesInformationMsg msg; - msg.setCapabitilies(0); - msg.setMaximumResistance(800); - send(msg); - return true; -} - -bool ProfileFecDisplay::handleTrainerData(BaseDataPage& dataPage) { - FecSpecificTrainerData dp(dataPage); - return _onFecSpecificTrainerData.call(dp); -} - -bool ProfileFecDisplay::handleUserInformationDataPage(BaseDataPage& dataPage) { - FecUserInformationDatapage dp(dataPage); - return _onFecUserInformationDataPage.call(dp); -} +#include +#include + +ProfileFecDisplay::ProfileFecDisplay(uint16_t deviceNumber, uint8_t transmissionType) : BaseSlaveProfile(deviceNumber, transmissionType) { + setChannelConfig(); +} + +void ProfileFecDisplay::onBroadcastData(BroadcastData& msg) { + BaseDataPage dp = BaseDataPage(msg); + BaseSlaveProfile::onBroadcastData(msg); + if (!handleDataPage(dp)) { + callOnOtherDataPage(msg); + } +} + +bool ProfileFecDisplay::handleDataPage(BaseDataPage& dp) { + uint8_t dataPage = dp.getDataPageNumber(); + bool called = false; + + switch (dataPage) { + case ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_NUMBER: + called = handleTrainerData(dp); + break; + + case ANTPLUS_FEC_MANUFACTURERINFORMATION_NUMBER: + called = handleManufacturerInformation(dp); + break; + + case ANTPLUS_FEC_PRODUCT_INFORMATION_NUMBER: + called = handleProductInformation(dp); + break; + + case ANTPLUS_FEC_GENERAL_INFORMATION_NUMBER: + called = handleGeneralDataPage(dp); + break; + + case ANTPLUS_FEC_GENERAL_SETTINGS_NUMBER: + called = handleGeneralSettingsDataPage(dp); + break; + + case ANTPLUS_FEC_TARGET_POWER_NUMBER: + called = handleTargetPowerDataPage(dp); + break; + + case ANTPLUS_FEC_CAPABILITIES_INFORMATION_NUMBER: + called = handleCapabilitiesInformationDataPage(dp); + break; + + case ANTPLUS_FEC_BASIC_RESISTANCE_NUMBER: + called = handleBasicResistanceDataPage(dp); + break; + + } + + return called; +} + +void ProfileFecDisplay::onAcknowledgedData(AcknowledgedData& msg) { + BaseDataPage dp = BaseDataPage(msg); + BaseSlaveProfile::onAcknowledgedData(msg); + if (!handleDataPage(dp)) { + callOnOtherDataPage(msg); + } +} + + +void ProfileFecDisplay::setChannelConfig() { + setChannelType(ANTPLUS_FEC_DISPLAY_CHANNELTYPE); + setDeviceType(ANTPLUS_FEC_DEVICETYPE); + setChannelPeriod(ANTPLUS_FEC_CHANNELPERIOD); + setSearchTimeout(ANTPLUS_FEC_SEARCHTIMEOUT); +} + +bool ProfileFecDisplay::handleManufacturerInformation(BaseDataPage& dataPage) { + FecManufacturerInformation dp(dataPage); + return _onFecManufacturerInformation.call(dp); +} + +bool ProfileFecDisplay::handleProductInformation(BaseDataPage& dataPage) { + FecProductInformation dp(dataPage); + return _onFecProductInformation.call(dp); +} + +bool ProfileFecDisplay::handleGeneralDataPage(BaseDataPage& dataPage) { + FecGeneralMainDataPage dp(dataPage); + return _onFecGeneralDataPage.call(dp); +} + +bool ProfileFecDisplay::handleGeneralSettingsDataPage(BaseDataPage& dataPage) { + FecGeneralSettingsDataPage dp(dataPage); + return _onFecGeneralSettingsDataPage.call(dp); +} +bool ProfileFecDisplay::handleTargetPowerDataPage(BaseDataPage& dataPage) { + FecTargetPowerDataPage dp(dataPage); + return _onFecTargetPowerDataPage.call(dp); +} + +bool ProfileFecDisplay::handleBasicResistanceDataPage(BaseDataPage& dataPage) { + FecBasicResistanceDataPage dp(dataPage); + return _onFecBasicResistanceDataPage.call(dp); +} + +bool ProfileFecDisplay::handleCapabilitiesInformationDataPage(BaseDataPage& dataPage) { + FecCapabilitiesInformationDatapage dp(dataPage); + return _onFecCapabilitiesInformationDataPage.call(dp); +} + +bool ProfileFecDisplay::transmitFecTargetPowerMsg(uint16_t TargetPower) { + FecTargetPowerDataMsg msg; + msg.setTargetPower(TargetPower); + send(msg); + return false; +} + +bool ProfileFecDisplay::transmitFecTrackResistanceMsg(uint16_t TargetGrade) { + FecTrackResistanceDataMsg msg; + msg.setTargetGrade(TargetGrade); + send(msg); + return false; +} + +bool ProfileFecDisplay::transmitFecBasicResistanceMsg(uint8_t Power) { + FecBasicResistanceDataMsg msg; + msg.setPower(Power); + send(msg); + return false; +} + +bool ProfileFecDisplay::transmitFecUserInformationMsg(uint16_t UserWeight, uint16_t BikeWeight) { + FecUserInformationMsg msg; + msg.setUserWeight(UserWeight); + msg.setBikeWeight(BikeWeight); + send(msg); + return true; +} + +bool ProfileFecDisplay::transmitFecCapabitiliesRequestMsg() +{ + FecCapabilitiesInformationMsg msg; + msg.setCapabitilies(0); + msg.setMaximumResistance(800); + send(msg); + return true; +} + +bool ProfileFecDisplay::handleTrainerData(BaseDataPage& dataPage) { + FecSpecificTrainerData dp(dataPage); + return _onFecSpecificTrainerData.call(dp); +} + +bool ProfileFecDisplay::handleUserInformationDataPage(BaseDataPage& dataPage) { + FecUserInformationDatapage dp(dataPage); + return _onFecUserInformationDataPage.call(dp); +} diff --git a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h index ab634d8..25dfbbe 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h @@ -1,56 +1,56 @@ -#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 onFecManufacturerInformation(void (*func)(FecManufacturerInformation&, uintptr_t), uintptr_t data = 0) { _onFecManufacturerInformation.set(func, data); } - void onFecProductInformation(void (*func)(FecProductInformation&, uintptr_t), uintptr_t data = 0) { _onFecProductInformation.set(func, data); } - void onFecGeneralDataPage(void (*func)(FecGeneralMainDataPage&, uintptr_t), uintptr_t data = 0) { _onFecGeneralDataPage.set(func, data); } - void onFecGeneralSettingsDataPage(void (*func)(FecGeneralSettingsDataPage&, uintptr_t), uintptr_t data = 0) { _onFecGeneralSettingsDataPage.set(func, data); } - void onFecTargetPowerDataPage(void (*func)(FecTargetPowerDataPage&, uintptr_t), uintptr_t data = 0) { _onFecTargetPowerDataPage.set(func, data); } - void onFecTrackResistanceDataPage(void (*func)(FecTrackResistanceDataPage&, uintptr_t), uintptr_t data = 0) { _onFecTrackResistanceDataPage.set(func, data); } - void onFecBasicResistanceDataPage(void (*func)(FecBasicResistanceDataPage&, uintptr_t), uintptr_t data = 0) { _onFecBasicResistanceDataPage.set(func, data); } - void onFecUserInformationDataPage(void (*func)(FecUserInformationDatapage&, uintptr_t), uintptr_t data = 0) { _onFecUserInformationDataPage.set(func, data); } - void onFecCapabilitiesInformationDataPage(void (*func)(FecCapabilitiesInformationDatapage&, uintptr_t), uintptr_t data = 0) { _onFecCapabilitiesInformationDataPage.set(func, data); } - bool transmitFecTargetPowerMsg(uint16_t TargetPower); - bool transmitFecTrackResistanceMsg(uint16_t TrackResistance); - bool transmitFecBasicResistanceMsg(uint8_t Power); - bool transmitFecUserInformationMsg(uint16_t UserWeight, uint16_t BikeWeight); - bool transmitFecCapabitiliesRequestMsg(); - -private: - void setChannelConfig(); - void onBroadcastData(BroadcastData& msg) override; - void onAcknowledgedData(AcknowledgedData& msg) override; - - bool handleDataPage(BaseDataPage& dp); - bool handleManufacturerInformation(BaseDataPage& dataPage); - bool handleProductInformation(BaseDataPage& dataPage); - bool handleGeneralDataPage(BaseDataPage& dataPage); - bool handleGeneralSettingsDataPage(BaseDataPage& dataPage); - bool handleTrainerData(BaseDataPage& dataPage); - bool handleTargetPowerDataPage(BaseDataPage& dataPage); - bool handleTrackResistanceDataPage(BaseDataPage& dataPage); - bool handleBasicResistanceDataPage(BaseDataPage& dataPage); - bool handleUserInformationDataPage(BaseDataPage& dataPage); - bool handleCapabilitiesInformationDataPage(BaseDataPage& dataPage); - - AntCallback _onFecSpecificTrainerData = { .func = NULL }; - AntCallback _onFecManufacturerInformation = { .func = NULL }; - AntCallback _onFecProductInformation = { .func = NULL }; - AntCallback _onFecGeneralDataPage = { .func = NULL }; - AntCallback _onFecGeneralSettingsDataPage = { .func = NULL }; - AntCallback _onFecTargetPowerDataPage = { .func = NULL }; - AntCallback _onFecTrackResistanceDataPage = { .func = NULL }; - AntCallback _onFecBasicResistanceDataPage = { .func = NULL }; - AntCallback _onFecUserInformationDataPage = { .func = NULL }; - AntCallback _onFecCapabilitiesInformationDataPage = { .func = NULL }; -}; - -#endif // ANTPLUS_PROFILEFECDISPLAY_h +#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 onFecManufacturerInformation(void (*func)(FecManufacturerInformation&, uintptr_t), uintptr_t data = 0) { _onFecManufacturerInformation.set(func, data); } + void onFecProductInformation(void (*func)(FecProductInformation&, uintptr_t), uintptr_t data = 0) { _onFecProductInformation.set(func, data); } + void onFecGeneralDataPage(void (*func)(FecGeneralMainDataPage&, uintptr_t), uintptr_t data = 0) { _onFecGeneralDataPage.set(func, data); } + void onFecGeneralSettingsDataPage(void (*func)(FecGeneralSettingsDataPage&, uintptr_t), uintptr_t data = 0) { _onFecGeneralSettingsDataPage.set(func, data); } + void onFecTargetPowerDataPage(void (*func)(FecTargetPowerDataPage&, uintptr_t), uintptr_t data = 0) { _onFecTargetPowerDataPage.set(func, data); } + void onFecTrackResistanceDataPage(void (*func)(FecTrackResistanceDataPage&, uintptr_t), uintptr_t data = 0) { _onFecTrackResistanceDataPage.set(func, data); } + void onFecBasicResistanceDataPage(void (*func)(FecBasicResistanceDataPage&, uintptr_t), uintptr_t data = 0) { _onFecBasicResistanceDataPage.set(func, data); } + void onFecUserInformationDataPage(void (*func)(FecUserInformationDatapage&, uintptr_t), uintptr_t data = 0) { _onFecUserInformationDataPage.set(func, data); } + void onFecCapabilitiesInformationDataPage(void (*func)(FecCapabilitiesInformationDatapage&, uintptr_t), uintptr_t data = 0) { _onFecCapabilitiesInformationDataPage.set(func, data); } + bool transmitFecTargetPowerMsg(uint16_t TargetPower); + bool transmitFecTrackResistanceMsg(uint16_t TrackResistance); + bool transmitFecBasicResistanceMsg(uint8_t Power); + bool transmitFecUserInformationMsg(uint16_t UserWeight, uint16_t BikeWeight); + bool transmitFecCapabitiliesRequestMsg(); + +private: + void setChannelConfig(); + void onBroadcastData(BroadcastData& msg) override; + void onAcknowledgedData(AcknowledgedData& msg) override; + + bool handleDataPage(BaseDataPage& dp); + bool handleManufacturerInformation(BaseDataPage& dataPage); + bool handleProductInformation(BaseDataPage& dataPage); + bool handleGeneralDataPage(BaseDataPage& dataPage); + bool handleGeneralSettingsDataPage(BaseDataPage& dataPage); + bool handleTrainerData(BaseDataPage& dataPage); + bool handleTargetPowerDataPage(BaseDataPage& dataPage); + bool handleTrackResistanceDataPage(BaseDataPage& dataPage); + bool handleBasicResistanceDataPage(BaseDataPage& dataPage); + bool handleUserInformationDataPage(BaseDataPage& dataPage); + bool handleCapabilitiesInformationDataPage(BaseDataPage& dataPage); + + AntCallback _onFecSpecificTrainerData = { .func = NULL }; + AntCallback _onFecManufacturerInformation = { .func = NULL }; + AntCallback _onFecProductInformation = { .func = NULL }; + AntCallback _onFecGeneralDataPage = { .func = NULL }; + AntCallback _onFecGeneralSettingsDataPage = { .func = NULL }; + AntCallback _onFecTargetPowerDataPage = { .func = NULL }; + AntCallback _onFecTrackResistanceDataPage = { .func = NULL }; + AntCallback _onFecBasicResistanceDataPage = { .func = NULL }; + AntCallback _onFecUserInformationDataPage = { .func = NULL }; + AntCallback _onFecCapabilitiesInformationDataPage = { .func = NULL }; +}; + +#endif // ANTPLUS_PROFILEFECDISPLAY_h From 77ebab2e5bacf17a42876b498c8cb958440146dc Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 24 Jan 2022 18:35:44 -0800 Subject: [PATCH 190/241] examples: FecDisplay: add to github workflow --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 93f652a..a79fd0d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,6 +20,7 @@ jobs: 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, From a63b8819ec91fde1076f0d3edf85ab0893319d4d Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 24 Jan 2022 18:39:45 -0800 Subject: [PATCH 191/241] examples: fec: update headers and defines to satisfy CI --- examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino index aa4d628..56d9340 100644 --- a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino +++ b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino @@ -9,11 +9,8 @@ #include #include "ANT.h" #include "ANTPLUS.h" -#include "bluefruit.h" -#define BAUD_RATE 115200 +#define BAUD_RATE 9600 #define CHANNEL_0 0 -#define TOTAL_CHANNELS 1 -#define ENCRYPTED_CHANNELS 0 const uint8_t NETWORK_KEY[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}; // get this from thisisant.com From 4153d371a4e4527369788b3985c2e61579c1edb9 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 24 Jan 2022 18:44:19 -0800 Subject: [PATCH 192/241] examples: fec: fix more errors reported by CI --- .../FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino index 56d9340..b1a69e3 100644 --- a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino +++ b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino @@ -15,8 +15,8 @@ const uint8_t NETWORK_KEY[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}; // get this from thisisant.com ArduinoSerialAntWithCallbacks ant; -AntPlusRouter router = AntPlusRouter(); -ProfileFecDisplay fec = ProfileFecDisplay(); +AntPlusRouter router; +ProfileFecDisplay fec; void fecBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data); void batteryStatusDataPageHandler(HeartRateBatteryStatus& msg, uintptr_t data); @@ -42,12 +42,12 @@ void printStatus(uint8_t status); void setup() { delay(2000); Serial1.begin(BAUD_RATE); - ant.begin(9600); + ant.begin(Serial1); delay(5000); router.setDriver(&ant); // never touch ant again router.setAntPlusNetworkKey(NETWORK_KEY); - router.setProfile(CHANNEL_0, &ht); + router.setProfile(CHANNEL_0, &fec); // Delay after initial setup to wait for user to connect on serial Serial.begin(BAUD_RATE); @@ -168,7 +168,7 @@ void SpecificTrainerDataPageHandler(FecSpecificTrainerData& msg, uintptr_t data) Serial.println(msg.getTrainerStatusBits()); if ( msg.getTrainerStatusBits() == 4 ) { - ht.transmitFecUserInformationMsg(9000, 3000); + fec.transmitFecUserInformationMsg(9000, 3000); Serial.println("Envoi des informations utilisateurs :"); } Serial.print("Trainer flag bit: "); From 18b4ed029a73fb2c377a5c5f5d3f345ef4236381 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 24 Jan 2022 18:47:30 -0800 Subject: [PATCH 193/241] examples: fec: fix types CI complaining about signed/unsigned comparison --- examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino index b1a69e3..279ddd0 100644 --- a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino +++ b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino @@ -33,8 +33,8 @@ void CapabitiliesDataPageHandler(FecCapabilitiesInformationDatapage& msg, uintpt void TargetPowerDataPagehandler(FecTargetPowerDataPage& msg, uintptr_t data); void TrackREsistanceDataPageHandler(FecTrackResistanceDataPage& msg, uintptr_t data); -long previousMillis = 0; -long interval = 4000; +unsigned long previousMillis = 0; +const unsigned long interval = 4000; int TargetPower = 50; void fecRateFeatures(uint8_t bitfield); void printStatus(uint8_t status); From eba47ba1cf2b26ad7513463570449560c0165682 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 24 Jan 2022 19:00:06 -0800 Subject: [PATCH 194/241] fec: remove some trailing whitespace --- src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp index 776484f..837a7bb 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp @@ -37,7 +37,7 @@ bool ProfileFecDisplay::handleDataPage(BaseDataPage& dp) { case ANTPLUS_FEC_GENERAL_SETTINGS_NUMBER: called = handleGeneralSettingsDataPage(dp); break; - + case ANTPLUS_FEC_TARGET_POWER_NUMBER: called = handleTargetPowerDataPage(dp); break; From 08a6db496bc1af256ac90b0a936de29e20e1bb37 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 24 Jan 2022 19:04:31 -0800 Subject: [PATCH 195/241] fec: remove common datapage definitions Reuse the common datapages to reduce code --- .../FecBikeTrainerDisplay.ino | 29 +++++----- src/Profiles/Fec/ANTPLUS_FecDataPages.h | 2 - src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h | 2 - .../ANTPLUS_FecManufacturerInformation.cpp | 54 ------------------- .../ANTPLUS_FecManufacturerInformation.h | 28 ---------- .../ANTPLUS_FecProductInformation.cpp | 31 ----------- .../DataPages/ANTPLUS_FecProductInformation.h | 24 --------- .../Profiles/ANTPLUS_FecProfileDisplay.cpp | 13 ++--- .../Fec/Profiles/ANTPLUS_FecProfileDisplay.h | 8 +-- 9 files changed, 26 insertions(+), 165 deletions(-) delete mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecManufacturerInformation.cpp delete mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecManufacturerInformation.h delete mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecProductInformation.cpp delete mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecProductInformation.h diff --git a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino index 279ddd0..c6db102 100644 --- a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino +++ b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino @@ -5,6 +5,7 @@ * And display content sent by it * * Author Charles-Antoine FOURNEL + * Updated by Curtis Malainey ************************************/ #include #include "ANT.h" @@ -19,12 +20,8 @@ AntPlusRouter router; ProfileFecDisplay fec; void fecBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data); -void batteryStatusDataPageHandler(HeartRateBatteryStatus& msg, uintptr_t data); -void capabilitiesDataPageHandler(HeartRateCapabilities& msg, uintptr_t data); -void cumulativeOperatingTimeDataPageHandler(HeartRateCumulativeOperatingTime& msg, uintptr_t data); -void defaultDataPageHandler(HeartRateDefault& msg, uintptr_t data); -void manufacturerInformationDataPageHandler(FecManufacturerInformation& msg, uintptr_t data); -void productInformationDataPageHandler(FecProductInformation& msg, uintptr_t data); +void manufacturerInformationDataPageHandler(ManufacturersInformation& msg, uintptr_t data); +void productInformationDataPageHandler(ProductInformation& msg, uintptr_t data); void GeneralDataPageHandler(FecGeneralMainDataPage& msg, uintptr_t data); void GeneralSettingsDataPageHandler(FecGeneralSettingsDataPage& msg, uintptr_t data); void SpecificTrainerDataPageHandler(FecSpecificTrainerData& msg, uintptr_t data); @@ -53,8 +50,8 @@ void setup() { Serial.begin(BAUD_RATE); Serial.println("Running"); fec.onDataPage(fecBaseDataPageHandler); - //fec.onFecManufacturerInformation(manufacturerInformationDataPageHandler); - //fec.onFecProductInformation(ProductInformationDataPageHandler); + fec.onManufacturersInformation(manufacturerInformationDataPageHandler); + fec.onProductInformation(productInformationDataPageHandler); fec.onFecGeneralDataPage(GeneralDataPageHandler); //fec.onFecGeneralSettingsDataPage(GeneralSettingsDataPageHandler); fec.onFecTargetPowerDataPage(TargetPowerDataPagehandler); @@ -111,18 +108,22 @@ void loop() { } -void manufacturerInformationDataPageHandler(FecManufacturerInformation& msg, uintptr_t data) { +void manufacturerInformationDataPageHandler(ManufacturersInformation& msg, uintptr_t data) { Serial.print("Manufacturer ID: "); - Serial.println(msg.getManufacturerId()); + Serial.println(msg.getManufacturerID()); Serial.print("Model Number: "); Serial.println(msg.getModelNumber()); Serial.print("hardware Revision: "); - Serial.println(msg.getHardwareRevision()); + Serial.println(msg.getHWRevision()); } -void ProductInformationDataPageHandler(FecProductInformation& msg, uintptr_t data) { - Serial.print("Software Revision: "); - Serial.println(msg.getSoftwareRevision()); +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(FecGeneralMainDataPage& msg, uintptr_t data) { diff --git a/src/Profiles/Fec/ANTPLUS_FecDataPages.h b/src/Profiles/Fec/ANTPLUS_FecDataPages.h index 108b5c0..e618d2d 100644 --- a/src/Profiles/Fec/ANTPLUS_FecDataPages.h +++ b/src/Profiles/Fec/ANTPLUS_FecDataPages.h @@ -2,8 +2,6 @@ #define ANTPLUS_PROFILEFECDATAPAGES_h #include -#include -#include #include #include #include diff --git a/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h b/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h index f3036c6..a728e3f 100644 --- a/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h +++ b/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h @@ -11,8 +11,6 @@ #define ANTPLUS_FEC_SEARCHTIMEOUT 12 /* DataPages number */ -#define ANTPLUS_FEC_MANUFACTURERINFORMATION_NUMBER 80 -#define ANTPLUS_FEC_PRODUCT_INFORMATION_NUMBER 81 #define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_NUMBER 25 #define ANTPLUS_FEC_GENERAL_INFORMATION_NUMBER 16 #define ANTPLUS_FEC_GENERAL_SETTINGS_NUMBER 17 diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecManufacturerInformation.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecManufacturerInformation.cpp deleted file mode 100644 index 9211eb5..0000000 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecManufacturerInformation.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include - -//#define DP_NUMBER_BYTE 1 -#define RESERVED_BYTE 1 -#define RESERVER_BYTE2 2 -#define HW_REVISION_BYTE 3 -#define MANUFACTUREREIDLSB_BYTE 4 -#define MANUFACTUREREIDMSB_BYTE 5 -#define MODELNUMBER_LSB_BYTE 6 -#define MODELNUMBER_MSB_BYTE 7 - -template -FecBaseManufacturerInformation::FecBaseManufacturerInformation() : - CoreDataPage() {} - -template -uint16_t FecBaseManufacturerInformation::getManufacturerId() { - return this->get16BitValue(MANUFACTUREREIDLSB_BYTE, MANUFACTUREREIDMSB_BYTE); -} - -template -uint16_t FecBaseManufacturerInformation::getModelNumber() { - return this->get16BitValue(MODELNUMBER_LSB_BYTE, MODELNUMBER_MSB_BYTE); -} - -template -uint8_t FecBaseManufacturerInformation::getHardwareRevision() { - return this->get8BitValue(HW_REVISION_BYTE); -} - -template class FecBaseManufacturerInformation; -template class FecBaseManufacturerInformation; - -FecManufacturerInformation::FecManufacturerInformation(AntRxDataResponse& dp) : - FecBaseMainDataPage(dp), - FecBaseManufacturerInformation() {} - -FecManufacturerInformationMsg::FecManufacturerInformationMsg() : - FecBaseMainDataPageMsg(ANTPLUS_FEC_MANUFACTURERINFORMATION_NUMBER), - FecBaseManufacturerInformation() {} - -void FecManufacturerInformationMsg::setManufacturerId(uint16_t id) { - set16BitValue(id, MANUFACTUREREIDLSB_BYTE, MANUFACTUREREIDMSB_BYTE); -} - -void FecManufacturerInformationMsg::setModelNumber(uint16_t ModelNumber) { - set16BitValue(ModelNumber, MODELNUMBER_LSB_BYTE, MODELNUMBER_MSB_BYTE); -} - -void FecManufacturerInformationMsg::setHardwareRevision(uint8_t HardwareRevision) { - set8BitValue(HardwareRevision, HW_REVISION_BYTE); -} - diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecManufacturerInformation.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecManufacturerInformation.h deleted file mode 100644 index 255a025..0000000 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecManufacturerInformation.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef ANTPLUS_FECMANUFACTURERINFORMATION_h -#define ANTPLUS_FECMANUFACTURERINFORMATION_h - -#include - -template -class FecBaseManufacturerInformation : virtual public CoreDataPage { -public: - FecBaseManufacturerInformation(); - uint16_t getManufacturerId(); - uint8_t getHardwareRevision(); - uint16_t getModelNumber(); -}; - -class FecManufacturerInformation : public FecBaseMainDataPage, public FecBaseManufacturerInformation { -public: - explicit FecManufacturerInformation(AntRxDataResponse& dp); -}; - -class FecManufacturerInformationMsg : public FecBaseMainDataPageMsg, public FecBaseManufacturerInformation { -public: - FecManufacturerInformationMsg(); - void setManufacturerId(uint16_t id); - void setModelNumber(uint16_t ModelNumber); - void setHardwareRevision(uint8_t HardwareRevision); -}; - -#endif // ANTPLUS_FECMANUFACTURERINFORMATION_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecProductInformation.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecProductInformation.cpp deleted file mode 100644 index 8d75d1a..0000000 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecProductInformation.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include - -#define RESERVED_BYTE 1 -#define SW_SUPLEMENTAL_REVISION_BYTE 2 -#define SW_MAIN_REVISION_BYTE 3 - -template -FecBaseProductInformation::FecBaseProductInformation() : - CoreDataPage() {} - -template -uint16_t FecBaseProductInformation::getSoftwareRevision() { - return this->get16BitValue(SW_MAIN_REVISION_BYTE, SW_SUPLEMENTAL_REVISION_BYTE); -} - -template class FecBaseProductInformation; -template class FecBaseProductInformation; - -FecProductInformation::FecProductInformation(AntRxDataResponse& dp) : - FecBaseMainDataPage(dp), - FecBaseProductInformation() {} - -FecProductInformationMsg::FecProductInformationMsg() : - FecBaseMainDataPageMsg(ANTPLUS_FEC_PRODUCT_INFORMATION_NUMBER), - FecBaseProductInformation() {} - -void FecProductInformationMsg::setSoftwareRevision(uint16_t SoftwareRevision) { - set16BitValue(SoftwareRevision, SW_MAIN_REVISION_BYTE, SW_SUPLEMENTAL_REVISION_BYTE); -} - diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecProductInformation.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecProductInformation.h deleted file mode 100644 index cc1dd78..0000000 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecProductInformation.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef ANTPLUS_FECPRODUCTINFORMATION_h -#define ANTPLUS_FECPRODUCTINFORMATION_h - -#include - -template -class FecBaseProductInformation : virtual public CoreDataPage { -public: - FecBaseProductInformation(); - uint16_t getSoftwareRevision(); -}; - -class FecProductInformation : public FecBaseMainDataPage, public FecBaseProductInformation { -public: - explicit FecProductInformation(AntRxDataResponse& dp); -}; - -class FecProductInformationMsg : public FecBaseMainDataPageMsg, public FecBaseProductInformation { -public: - FecProductInformationMsg(); - void setSoftwareRevision(uint16_t SoftwareRevision); -}; - -#endif // ANTPLUS_FECPRODUCTINFORMATION_h diff --git a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp index 837a7bb..6583193 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp @@ -1,5 +1,6 @@ #include #include +#include ProfileFecDisplay::ProfileFecDisplay(uint16_t deviceNumber, uint8_t transmissionType) : BaseSlaveProfile(deviceNumber, transmissionType) { setChannelConfig(); @@ -22,11 +23,11 @@ bool ProfileFecDisplay::handleDataPage(BaseDataPage& dp) { called = handleTrainerData(dp); break; - case ANTPLUS_FEC_MANUFACTURERINFORMATION_NUMBER: + case COMMON_MANUFACTURERSINFORMATION_NUMBER: called = handleManufacturerInformation(dp); break; - case ANTPLUS_FEC_PRODUCT_INFORMATION_NUMBER: + case COMMON_PRODUCTINFORMATION_NUMBER: called = handleProductInformation(dp); break; @@ -72,13 +73,13 @@ void ProfileFecDisplay::setChannelConfig() { } bool ProfileFecDisplay::handleManufacturerInformation(BaseDataPage& dataPage) { - FecManufacturerInformation dp(dataPage); - return _onFecManufacturerInformation.call(dp); + ManufacturersInformation dp(dataPage); + return _onManufacturersInformation.call(dp); } bool ProfileFecDisplay::handleProductInformation(BaseDataPage& dataPage) { - FecProductInformation dp(dataPage); - return _onFecProductInformation.call(dp); + ProductInformation dp(dataPage); + return _onProductInformation.call(dp); } bool ProfileFecDisplay::handleGeneralDataPage(BaseDataPage& dataPage) { diff --git a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h index 25dfbbe..99a638b 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h @@ -9,8 +9,8 @@ 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 onFecManufacturerInformation(void (*func)(FecManufacturerInformation&, uintptr_t), uintptr_t data = 0) { _onFecManufacturerInformation.set(func, data); } - void onFecProductInformation(void (*func)(FecProductInformation&, uintptr_t), uintptr_t data = 0) { _onFecProductInformation.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 onFecGeneralDataPage(void (*func)(FecGeneralMainDataPage&, uintptr_t), uintptr_t data = 0) { _onFecGeneralDataPage.set(func, data); } void onFecGeneralSettingsDataPage(void (*func)(FecGeneralSettingsDataPage&, uintptr_t), uintptr_t data = 0) { _onFecGeneralSettingsDataPage.set(func, data); } void onFecTargetPowerDataPage(void (*func)(FecTargetPowerDataPage&, uintptr_t), uintptr_t data = 0) { _onFecTargetPowerDataPage.set(func, data); } @@ -42,8 +42,8 @@ class ProfileFecDisplay : public BaseSlaveProfile { bool handleCapabilitiesInformationDataPage(BaseDataPage& dataPage); AntCallback _onFecSpecificTrainerData = { .func = NULL }; - AntCallback _onFecManufacturerInformation = { .func = NULL }; - AntCallback _onFecProductInformation = { .func = NULL }; + AntCallback _onManufacturersInformation = { .func = NULL }; + AntCallback _onProductInformation = { .func = NULL }; AntCallback _onFecGeneralDataPage = { .func = NULL }; AntCallback _onFecGeneralSettingsDataPage = { .func = NULL }; AntCallback _onFecTargetPowerDataPage = { .func = NULL }; From a84bcf679fc57d1e988135b7958a2e7cb02a650f Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 24 Jan 2022 19:20:23 -0800 Subject: [PATCH 196/241] muscleoxygen: remove unneeded define when we add display we can add it back --- src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h index 1162861..736e396 100644 --- a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h +++ b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h @@ -3,8 +3,6 @@ #include -/* Channel Config */ -#define ANTPLUS_MUSCLEOXYGEN_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE // Master channel #define MUSCLEOXYGEN_CHANNELPERIOD 8192 From 9a7bfe4889783a4e92ec9ce7cb0aad72f8e07ea5 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 24 Jan 2022 21:17:29 -0800 Subject: [PATCH 197/241] fec: refactor step 1 * remove prefixes from private defines * rename private defines to match docs * move channel type to the cpp file and remove prefix * rename UserInformationDatapage to UserConfiguration to match docs * remove UserInformationDatapage handler from display as it only transmitted by the display --- .../FecBikeTrainerDisplay.ino | 4 +- src/Profiles/Fec/ANTPLUS_FecDataPages.h | 2 +- src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h | 17 ++++---- .../ANTPLUS_FecBasicResistanceDataPage.cpp | 2 +- ...LUS_FecCapabilitiesInformationDataPage.cpp | 2 +- .../ANTPLUS_FecGeneralMainDataPage.cpp | 6 +-- .../ANTPLUS_FecGeneralSettingsDataPage.cpp | 2 +- .../ANTPLUS_FecTargetPowerDataPage.cpp | 2 +- .../ANTPLUS_FecTrackResistanceDataPage.cpp | 2 +- .../ANTPLUS_FecUserConfiguration.cpp | 41 ++++++++++++++++++ .../DataPages/ANTPLUS_FecUserConfiguration.h | 29 +++++++++++++ .../ANTPLUS_FecUserInformationDataPage.cpp | 42 ------------------- .../ANTPLUS_FecUserInformationDataPage.h | 27 ------------ .../Profiles/ANTPLUS_FecProfileDisplay.cpp | 26 +++++------- .../Fec/Profiles/ANTPLUS_FecProfileDisplay.h | 5 +-- .../ANTPLUS_ProfileHeartRateDisplay.cpp | 1 - 16 files changed, 101 insertions(+), 109 deletions(-) create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecUserConfiguration.cpp create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecUserConfiguration.h delete mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecUserInformationDataPage.cpp delete mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecUserInformationDataPage.h diff --git a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino index c6db102..182cf98 100644 --- a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino +++ b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino @@ -70,7 +70,7 @@ void setup() { Serial.print("Transmisison Type: "); Serial.println(fec.getTransmissionType()); Serial.print("settings user information"); - fec.transmitFecUserInformationMsg(9000, 3000); + fec.transmitFecUserConfigurationMsg(9000, 3000); // get fec capabilities fec.transmitFecCapabitiliesRequestMsg(); Serial.print("Ask for capacity"); // this datapage not always sent by indoor bike trainer @@ -169,7 +169,7 @@ void SpecificTrainerDataPageHandler(FecSpecificTrainerData& msg, uintptr_t data) Serial.println(msg.getTrainerStatusBits()); if ( msg.getTrainerStatusBits() == 4 ) { - fec.transmitFecUserInformationMsg(9000, 3000); + fec.transmitFecUserConfigurationMsg(9000, 3000); Serial.println("Envoi des informations utilisateurs :"); } Serial.print("Trainer flag bit: "); diff --git a/src/Profiles/Fec/ANTPLUS_FecDataPages.h b/src/Profiles/Fec/ANTPLUS_FecDataPages.h index e618d2d..bdc9122 100644 --- a/src/Profiles/Fec/ANTPLUS_FecDataPages.h +++ b/src/Profiles/Fec/ANTPLUS_FecDataPages.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h b/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h index a728e3f..1e3cab0 100644 --- a/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h +++ b/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h @@ -4,20 +4,19 @@ #include /* Channel Config */ -#define ANTPLUS_FEC_DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE #define ANTPLUS_FEC_MONITOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT #define ANTPLUS_FEC_CHANNELPERIOD 8192 // 30 / 2.5 = 12 #define ANTPLUS_FEC_SEARCHTIMEOUT 12 /* DataPages number */ -#define ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_NUMBER 25 -#define ANTPLUS_FEC_GENERAL_INFORMATION_NUMBER 16 -#define ANTPLUS_FEC_GENERAL_SETTINGS_NUMBER 17 -#define ANTPLUS_FEC_BASIC_RESISTANCE_NUMBER 48 -#define ANTPLUS_FEC_TARGET_POWER_NUMBER 49 -#define ANTPLUS_FEC_TRACK_RESISTANCE_NUMBER 51 -#define ANTPLUS_FEC_CAPABILITIES_INFORMATION_NUMBER 54 -#define ANTPLUS_FEC_USER_INFORMATION_NUMBER 55 +#define GENERAL_FE_DATA_NUMBER 16 +#define GENERAL_SETTINGS_PAGE_NUMBER 17 +#define SPECIFIC_TRAINER_DATA_NUMBER 25 +#define BASIC_RESISTANCE_NUMBER 48 +#define TARGET_POWER_NUMBER 49 +#define TRACK_RESISTANCE_NUMBER 51 +#define FE_CAPABILITIES_NUMBER 54 +#define USER_CONFIGURATION_NUMBER 55 #endif // ANTPLUS_FECPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.cpp index ff70680..98cee27 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.cpp @@ -20,7 +20,7 @@ FecBasicResistanceDataPage::FecBasicResistanceDataPage(AntRxDataResponse& dp) : FecBaseBasicResistanceDataPage() {} FecBasicResistanceDataMsg::FecBasicResistanceDataMsg() : - FecBaseMainDataPageMsg(ANTPLUS_FEC_BASIC_RESISTANCE_NUMBER), + FecBaseMainDataPageMsg(BASIC_RESISTANCE_NUMBER), FecBaseBasicResistanceDataPage() {} void FecBasicResistanceDataMsg::setPower(uint8_t Power) { diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecCapabilitiesInformationDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecCapabilitiesInformationDataPage.cpp index 764baa2..d063b27 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecCapabilitiesInformationDataPage.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecCapabilitiesInformationDataPage.cpp @@ -27,7 +27,7 @@ FecCapabilitiesInformationDatapage::FecCapabilitiesInformationDatapage(AntRxData FecBaseCapabilitiesInformationDatapage() {} FecCapabilitiesInformationMsg::FecCapabilitiesInformationMsg() : - FecBaseMainDataPageMsg(ANTPLUS_FEC_USER_INFORMATION_NUMBER), + FecBaseMainDataPageMsg(FE_CAPABILITIES_NUMBER), FecBaseCapabilitiesInformationDatapage() {} void FecCapabilitiesInformationMsg::setMaximumResistance(uint16_t MaximumResistance) { diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp index c803a35..9a1493d 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp @@ -54,7 +54,7 @@ uint8_t FecBaseGeneralMainDataPage::getFEStateBits() { template /* -in meter / s +in meter / s */ uint16_t FecBaseGeneralMainDataPage::getSpeed(bool km) { @@ -72,5 +72,5 @@ FecGeneralMainDataPage::FecGeneralMainDataPage(AntRxDataResponse& dp) : FecBaseGeneralMainDataPage() {} FecGeneralMainDataMsg::FecGeneralMainDataMsg() : - FecBaseMainDataPageMsg(ANTPLUS_FEC_GENERAL_INFORMATION_NUMBER), - FecBaseGeneralMainDataPage() {} \ No newline at end of file + FecBaseMainDataPageMsg(GENERAL_FE_DATA_NUMBER), + FecBaseGeneralMainDataPage() {} diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.cpp index 17081f5..abd5d2f 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.cpp @@ -52,7 +52,7 @@ FecGeneralSettingsDataPage::FecGeneralSettingsDataPage(AntRxDataResponse& dp) : FecBaseGeneralSettingsDataPage() {} FecGeneralSettingsDataMsg::FecGeneralSettingsDataMsg() : - FecBaseMainDataPageMsg(ANTPLUS_FEC_GENERAL_SETTINGS_NUMBER), + FecBaseMainDataPageMsg(GENERAL_SETTINGS_PAGE_NUMBER), FecBaseGeneralSettingsDataPage() {} void FecGeneralSettingsDataMsg::setResistanceLevel(uint8_t ResistanceLevel) { diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.cpp index d1fa586..fb46189 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.cpp @@ -21,7 +21,7 @@ FecTargetPowerDataPage::FecTargetPowerDataPage(AntRxDataResponse& dp) : FecBaseTargetPowerDataPage() {} FecTargetPowerDataMsg::FecTargetPowerDataMsg() : - FecBaseMainDataPageMsg(ANTPLUS_FEC_TARGET_POWER_NUMBER), + FecBaseMainDataPageMsg(TARGET_POWER_NUMBER), FecBaseTargetPowerDataPage() {} void FecTargetPowerDataMsg::setTargetPower(uint16_t TargetPower) { diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.cpp index ec3c232..9e87ac7 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.cpp @@ -23,7 +23,7 @@ FecTrackResistanceDataPage::FecTrackResistanceDataPage(AntRxDataResponse& dp) : FecBaseTrackResistanceDataPage() {} FecTrackResistanceDataMsg::FecTrackResistanceDataMsg() : - FecBaseMainDataPageMsg(ANTPLUS_FEC_TRACK_RESISTANCE_NUMBER), + FecBaseMainDataPageMsg(TRACK_RESISTANCE_NUMBER), FecBaseTrackResistanceDataPage() {} void FecTrackResistanceDataMsg::setTargetGrade(uint16_t TargetGrade) { diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecUserConfiguration.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecUserConfiguration.cpp new file mode 100644 index 0000000..f5d5255 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecUserConfiguration.cpp @@ -0,0 +1,41 @@ +#include +#include + +#define USER_WEIGHT_LSB_BYTE 1 +#define USER_WEIGHT_MSB_BYTE 2 +#define BICYCLE_WEIGHT_LSB_BYTE 4 +#define BICYCLE_WEIGHT_MSB_BYTE 5 + +template +FecBaseUserConfiguration::FecBaseUserConfiguration() : + CoreDataPage() {} + +template +uint16_t FecBaseUserConfiguration::getUserWeight() { + return this->get16BitValue(USER_WEIGHT_LSB_BYTE, USER_WEIGHT_MSB_BYTE); +} + +template +uint16_t FecBaseUserConfiguration::getBikeWeight() { + return this->get16BitValue(BICYCLE_WEIGHT_LSB_BYTE, BICYCLE_WEIGHT_MSB_BYTE); +} + +template class FecBaseUserConfiguration; +template class FecBaseUserConfiguration; + +FecUserConfiguration::FecUserConfiguration(AntRxDataResponse& dp) : + FecBaseMainDataPage(dp), + FecBaseUserConfiguration() {} + +FecUserConfigurationMsg::FecUserConfigurationMsg() : + FecBaseMainDataPageMsg(USER_CONFIGURATION_NUMBER), + FecBaseUserConfiguration() {} + +void FecUserConfigurationMsg::setUserWeight(uint16_t UserWeight) { + set16BitValue(UserWeight, USER_WEIGHT_LSB_BYTE, USER_WEIGHT_MSB_BYTE); +} + +void FecUserConfigurationMsg::setBikeWeight(uint16_t BikeWeight) { + set16BitValue(BikeWeight, BICYCLE_WEIGHT_LSB_BYTE, BICYCLE_WEIGHT_MSB_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..be7ffae --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecUserConfiguration.h @@ -0,0 +1,29 @@ +#ifndef ANTPLUS_FECUSERCONFIGURATION_h +#define ANTPLUS_FECUSERCONFIGURATION_h + +#include + +// TODO missing fields + +template +class FecBaseUserConfiguration : virtual public CoreDataPage { +public: + FecBaseUserConfiguration(); + uint16_t getUserWeight(); + uint16_t getBikeWeight(); +}; + +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 setBikeWeight(uint16_t BikeWeight); +}; + +#endif // ANTPLUS_FECUSERCONFIGURATION_h + diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecUserInformationDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecUserInformationDataPage.cpp deleted file mode 100644 index cceb2e9..0000000 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecUserInformationDataPage.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include - -#define USER_WEIGHT_LSB_BYTE 1 -#define USER_WEIGHT_MSB_BYTE 2 -#define BICYCLE_WHEEL_BYTE 4 -#define BICYCLE_WEIGHT_LSB_BYTE 4 -#define BICYCLE_WEIGHT_MSB_BYTE 5 - -template -FecBaseUserInformationDatapage::FecBaseUserInformationDatapage() : - CoreDataPage() {} - -template -uint16_t FecBaseUserInformationDatapage::getUserWeight() { - return this->get16BitValue(USER_WEIGHT_LSB_BYTE, USER_WEIGHT_MSB_BYTE); -} - -template -uint16_t FecBaseUserInformationDatapage::getBikeWeight() { - return this->get16BitValue(BICYCLE_WEIGHT_LSB_BYTE, BICYCLE_WEIGHT_MSB_BYTE); -} - -template class FecBaseUserInformationDatapage; -template class FecBaseUserInformationDatapage; - -FecUserInformationDatapage::FecUserInformationDatapage(AntRxDataResponse& dp) : - FecBaseMainDataPage(dp), - FecBaseUserInformationDatapage() {} - -FecUserInformationMsg::FecUserInformationMsg() : - FecBaseMainDataPageMsg(ANTPLUS_FEC_USER_INFORMATION_NUMBER), - FecBaseUserInformationDatapage() {} - -void FecUserInformationMsg::setUserWeight(uint16_t UserWeight) { - set16BitValue(UserWeight, USER_WEIGHT_LSB_BYTE, USER_WEIGHT_MSB_BYTE); -} - -void FecUserInformationMsg::setBikeWeight(uint16_t BikeWeight) { - set16BitValue(BikeWeight, BICYCLE_WEIGHT_LSB_BYTE, BICYCLE_WEIGHT_MSB_BYTE); -} - diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecUserInformationDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecUserInformationDataPage.h deleted file mode 100644 index 8af6856..0000000 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecUserInformationDataPage.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef ANTPLUS_FECUSERINFORMATIONDATAPAGE_h -#define ANTPLUS_FECUSERINFORMATIONDATAPAGE_h - -#include - -template -class FecBaseUserInformationDatapage : virtual public CoreDataPage { -public: - FecBaseUserInformationDatapage(); - uint16_t getUserWeight(); - uint16_t getBikeWeight(); -}; - -class FecUserInformationDatapage : public FecBaseMainDataPage, public FecBaseUserInformationDatapage { -public: - explicit FecUserInformationDatapage(AntRxDataResponse& dp); -}; - -class FecUserInformationMsg : public FecBaseMainDataPageMsg, public FecBaseUserInformationDatapage { -public: - FecUserInformationMsg(); - void setUserWeight(uint16_t UserWeight); - void setBikeWeight(uint16_t BikeWeight); -}; - -#endif // ANTPLUS_FECUSERINFORMATIONDATAPAGE_h - diff --git a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp index 6583193..766e7a1 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp @@ -2,6 +2,8 @@ #include #include +#define DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE + ProfileFecDisplay::ProfileFecDisplay(uint16_t deviceNumber, uint8_t transmissionType) : BaseSlaveProfile(deviceNumber, transmissionType) { setChannelConfig(); } @@ -19,7 +21,7 @@ bool ProfileFecDisplay::handleDataPage(BaseDataPage& dp) { bool called = false; switch (dataPage) { - case ANTPLUS_FEC_DATAPAGE_TRAINER_DATA_NUMBER: + case SPECIFIC_TRAINER_DATA_NUMBER: called = handleTrainerData(dp); break; @@ -31,23 +33,23 @@ bool ProfileFecDisplay::handleDataPage(BaseDataPage& dp) { called = handleProductInformation(dp); break; - case ANTPLUS_FEC_GENERAL_INFORMATION_NUMBER: + case GENERAL_FE_DATA_NUMBER: called = handleGeneralDataPage(dp); break; - case ANTPLUS_FEC_GENERAL_SETTINGS_NUMBER: + case GENERAL_SETTINGS_PAGE_NUMBER: called = handleGeneralSettingsDataPage(dp); break; - case ANTPLUS_FEC_TARGET_POWER_NUMBER: + case TARGET_POWER_NUMBER: called = handleTargetPowerDataPage(dp); break; - case ANTPLUS_FEC_CAPABILITIES_INFORMATION_NUMBER: + case FE_CAPABILITIES_NUMBER: called = handleCapabilitiesInformationDataPage(dp); break; - case ANTPLUS_FEC_BASIC_RESISTANCE_NUMBER: + case BASIC_RESISTANCE_NUMBER: called = handleBasicResistanceDataPage(dp); break; @@ -64,9 +66,8 @@ void ProfileFecDisplay::onAcknowledgedData(AcknowledgedData& msg) { } } - void ProfileFecDisplay::setChannelConfig() { - setChannelType(ANTPLUS_FEC_DISPLAY_CHANNELTYPE); + setChannelType(DISPLAY_CHANNELTYPE); setDeviceType(ANTPLUS_FEC_DEVICETYPE); setChannelPeriod(ANTPLUS_FEC_CHANNELPERIOD); setSearchTimeout(ANTPLUS_FEC_SEARCHTIMEOUT); @@ -127,8 +128,8 @@ bool ProfileFecDisplay::transmitFecBasicResistanceMsg(uint8_t Power) { return false; } -bool ProfileFecDisplay::transmitFecUserInformationMsg(uint16_t UserWeight, uint16_t BikeWeight) { - FecUserInformationMsg msg; +bool ProfileFecDisplay::transmitFecUserConfigurationMsg(uint16_t UserWeight, uint16_t BikeWeight) { + FecUserConfigurationMsg msg; msg.setUserWeight(UserWeight); msg.setBikeWeight(BikeWeight); send(msg); @@ -148,8 +149,3 @@ bool ProfileFecDisplay::handleTrainerData(BaseDataPage& dataPage) FecSpecificTrainerData dp(dataPage); return _onFecSpecificTrainerData.call(dp); } - -bool ProfileFecDisplay::handleUserInformationDataPage(BaseDataPage& dataPage) { - FecUserInformationDatapage dp(dataPage); - return _onFecUserInformationDataPage.call(dp); -} diff --git a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h index 99a638b..238cbac 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h @@ -16,12 +16,11 @@ class ProfileFecDisplay : public BaseSlaveProfile { void onFecTargetPowerDataPage(void (*func)(FecTargetPowerDataPage&, uintptr_t), uintptr_t data = 0) { _onFecTargetPowerDataPage.set(func, data); } void onFecTrackResistanceDataPage(void (*func)(FecTrackResistanceDataPage&, uintptr_t), uintptr_t data = 0) { _onFecTrackResistanceDataPage.set(func, data); } void onFecBasicResistanceDataPage(void (*func)(FecBasicResistanceDataPage&, uintptr_t), uintptr_t data = 0) { _onFecBasicResistanceDataPage.set(func, data); } - void onFecUserInformationDataPage(void (*func)(FecUserInformationDatapage&, uintptr_t), uintptr_t data = 0) { _onFecUserInformationDataPage.set(func, data); } void onFecCapabilitiesInformationDataPage(void (*func)(FecCapabilitiesInformationDatapage&, uintptr_t), uintptr_t data = 0) { _onFecCapabilitiesInformationDataPage.set(func, data); } bool transmitFecTargetPowerMsg(uint16_t TargetPower); bool transmitFecTrackResistanceMsg(uint16_t TrackResistance); bool transmitFecBasicResistanceMsg(uint8_t Power); - bool transmitFecUserInformationMsg(uint16_t UserWeight, uint16_t BikeWeight); + bool transmitFecUserConfigurationMsg(uint16_t UserWeight, uint16_t BikeWeight); bool transmitFecCapabitiliesRequestMsg(); private: @@ -38,7 +37,6 @@ class ProfileFecDisplay : public BaseSlaveProfile { bool handleTargetPowerDataPage(BaseDataPage& dataPage); bool handleTrackResistanceDataPage(BaseDataPage& dataPage); bool handleBasicResistanceDataPage(BaseDataPage& dataPage); - bool handleUserInformationDataPage(BaseDataPage& dataPage); bool handleCapabilitiesInformationDataPage(BaseDataPage& dataPage); AntCallback _onFecSpecificTrainerData = { .func = NULL }; @@ -49,7 +47,6 @@ class ProfileFecDisplay : public BaseSlaveProfile { AntCallback _onFecTargetPowerDataPage = { .func = NULL }; AntCallback _onFecTrackResistanceDataPage = { .func = NULL }; AntCallback _onFecBasicResistanceDataPage = { .func = NULL }; - AntCallback _onFecUserInformationDataPage = { .func = NULL }; AntCallback _onFecCapabilitiesInformationDataPage = { .func = NULL }; }; diff --git a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp index ad53d8b..f382f7e 100644 --- a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include #define DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE From 7d992f545c2bec14e845df05cca381a97f3270ee Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 24 Jan 2022 21:24:22 -0800 Subject: [PATCH 198/241] examples: Fec: don't touch the driver calling readpacket will cause the router to miss messages --- examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino index 182cf98..05363ae 100644 --- a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino +++ b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino @@ -78,9 +78,7 @@ void setup() { } void loop() { - router.loop(); - ant.readPacket(); - if (ant.getResponse().isError()) + if (!router.loop() && ant.getResponse().isError()) { Serial.print("ANT MSG ERROR: "); Serial.println(ant.getResponse().getErrorCode()); From 4f2c254c67fe7354a4b44670eb792e40e7684308 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 24 Jan 2022 21:32:19 -0800 Subject: [PATCH 199/241] fec: remove unit conversions lib is not meant to be a place for unit conversions given the infinite number of units available. All types can be extended to support this as needed --- .../FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino | 2 +- .../Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp | 11 ++--------- .../Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.h | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino index 05363ae..e94e2bb 100644 --- a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino +++ b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino @@ -128,7 +128,7 @@ void GeneralDataPageHandler(FecGeneralMainDataPage& msg, uintptr_t data) { Serial.print("Equipment type: "); Serial.println(msg.getEquipmentTypeBits()); Serial.print("Current speed:" ); - Serial.println(msg.getSpeed(true)); + Serial.println(msg.getSpeed()); Serial.print("FE State:"); Serial.println(msg.getFEStateBits()); Serial.print("FEC CAPABILITIES:"); diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp index 9a1493d..dee3a57 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp @@ -52,15 +52,7 @@ uint8_t FecBaseGeneralMainDataPage::getFEStateBits() { } template -/* - -in meter / s - -*/ -uint16_t FecBaseGeneralMainDataPage::getSpeed(bool km) { - if ( km == true ){ - return 3.6 * (this->get16BitValue(SPEED_LSB_BYTE, SPEED_MSB_BYTE)) /1000; - } +uint16_t FecBaseGeneralMainDataPage::getSpeed() { return this->get16BitValue(SPEED_LSB_BYTE, SPEED_MSB_BYTE); } @@ -74,3 +66,4 @@ FecGeneralMainDataPage::FecGeneralMainDataPage(AntRxDataResponse& dp) : FecGeneralMainDataMsg::FecGeneralMainDataMsg() : FecBaseMainDataPageMsg(GENERAL_FE_DATA_NUMBER), FecBaseGeneralMainDataPage() {} +// TODO diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.h index d5ef304..56ffe60 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.h +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.h @@ -10,7 +10,7 @@ class FecBaseGeneralMainDataPage : virtual public CoreDataPage { uint8_t getEquipmentTypeBits(); uint8_t getElapsedTime(); uint8_t getDistanceTraveled(); - uint16_t getSpeed(bool km); + uint16_t getSpeed(); uint8_t getHeartRate(); uint8_t getCapabilitiesBits(); uint8_t getFEStateBits(); From 9ea9b9bbe9876e7d9615a3783bb2e1ca56514760 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 24 Jan 2022 21:53:57 -0800 Subject: [PATCH 200/241] fec: refactor step 2 * remove suffix off BasicResistance * remove handler as this is a display TX only page * fix field name * Add TODO for reserved field sets that are missing --- src/Profiles/Fec/ANTPLUS_FecDataPages.h | 6 ++-- .../DataPages/ANTPLUS_FecBasicResistance.cpp | 29 +++++++++++++++++++ .../DataPages/ANTPLUS_FecBasicResistance.h | 25 ++++++++++++++++ .../ANTPLUS_FecBasicResistanceDataPage.cpp | 28 ------------------ .../ANTPLUS_FecBasicResistanceDataPage.h | 26 ----------------- .../Profiles/ANTPLUS_FecProfileDisplay.cpp | 16 ++-------- .../Fec/Profiles/ANTPLUS_FecProfileDisplay.h | 5 +--- 7 files changed, 61 insertions(+), 74 deletions(-) create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistance.cpp create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistance.h delete mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.cpp delete mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.h diff --git a/src/Profiles/Fec/ANTPLUS_FecDataPages.h b/src/Profiles/Fec/ANTPLUS_FecDataPages.h index bdc9122..468bce0 100644 --- a/src/Profiles/Fec/ANTPLUS_FecDataPages.h +++ b/src/Profiles/Fec/ANTPLUS_FecDataPages.h @@ -1,13 +1,13 @@ #ifndef ANTPLUS_PROFILEFECDATAPAGES_h #define ANTPLUS_PROFILEFECDATAPAGES_h -#include #include #include +#include +#include #include #include -#include #include -#include +#include #endif // ANTPLUS_PROFILEFECDATAPAGES_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..e9acf2b --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistance.cpp @@ -0,0 +1,29 @@ +#include +#include + +#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(BASIC_RESISTANCE_NUMBER), + FecBaseBasicResistance() {} + // TODO reserved fields + +void FecBasicResistanceMsg::setTotalResistance(uint8_t total_resistance) { + set8BitValue(total_resistance, 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..4a3a8df --- /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 total_resistance); +}; + + +#endif // ANTPLUS_FECBASICRESISTANCE_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.cpp deleted file mode 100644 index 98cee27..0000000 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include - -#define POWER_BYTE 7 - -template -FecBaseBasicResistanceDataPage::FecBaseBasicResistanceDataPage() : - CoreDataPage() {} - -template -uint8_t FecBaseBasicResistanceDataPage::getPower() { - return this->get8BitValue(POWER_BYTE); -} - -template class FecBaseBasicResistanceDataPage; -template class FecBaseBasicResistanceDataPage; - -FecBasicResistanceDataPage::FecBasicResistanceDataPage(AntRxDataResponse& dp) : - FecBaseMainDataPage(dp), - FecBaseBasicResistanceDataPage() {} - -FecBasicResistanceDataMsg::FecBasicResistanceDataMsg() : - FecBaseMainDataPageMsg(BASIC_RESISTANCE_NUMBER), - FecBaseBasicResistanceDataPage() {} - -void FecBasicResistanceDataMsg::setPower(uint8_t Power) { - set8BitValue(Power, POWER_BYTE); -} diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.h deleted file mode 100644 index 2b6c16c..0000000 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistanceDataPage.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef ANTPLUS_FECBASICRESISTANCEDATAPAGE_h -#define ANTPLUS_FECBASICRESISTANCEDATAPAGE_h - -#include - -template -class FecBaseBasicResistanceDataPage : virtual public CoreDataPage { -public: - FecBaseBasicResistanceDataPage(); - uint8_t getPower(); -}; - -class FecBasicResistanceDataPage : public FecBaseMainDataPage, public FecBaseBasicResistanceDataPage { -public: - explicit FecBasicResistanceDataPage(AntRxDataResponse& dp); -}; - -class FecBasicResistanceDataMsg : public FecBaseMainDataPageMsg, public FecBaseBasicResistanceDataPage { -public: - FecBasicResistanceDataMsg(); - void setPower(uint8_t Power); -}; - - -#endif // ANTPLUS_FECBASICRESISTANCEDATAPAGE_h - diff --git a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp index 766e7a1..cde5d3a 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp @@ -48,11 +48,6 @@ bool ProfileFecDisplay::handleDataPage(BaseDataPage& dp) { case FE_CAPABILITIES_NUMBER: called = handleCapabilitiesInformationDataPage(dp); break; - - case BASIC_RESISTANCE_NUMBER: - called = handleBasicResistanceDataPage(dp); - break; - } return called; @@ -97,11 +92,6 @@ bool ProfileFecDisplay::handleTargetPowerDataPage(BaseDataPage& d return _onFecTargetPowerDataPage.call(dp); } -bool ProfileFecDisplay::handleBasicResistanceDataPage(BaseDataPage& dataPage) { - FecBasicResistanceDataPage dp(dataPage); - return _onFecBasicResistanceDataPage.call(dp); -} - bool ProfileFecDisplay::handleCapabilitiesInformationDataPage(BaseDataPage& dataPage) { FecCapabilitiesInformationDatapage dp(dataPage); return _onFecCapabilitiesInformationDataPage.call(dp); @@ -121,9 +111,9 @@ bool ProfileFecDisplay::transmitFecTrackResistanceMsg(uint16_t TargetGrade) { return false; } -bool ProfileFecDisplay::transmitFecBasicResistanceMsg(uint8_t Power) { - FecBasicResistanceDataMsg msg; - msg.setPower(Power); +bool ProfileFecDisplay::transmitFecBasicResistanceMsg(uint8_t total_resistance) { + FecBasicResistanceMsg msg; + msg.setTotalResistance(total_resistance); send(msg); return false; } diff --git a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h index 238cbac..ae5c86e 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h @@ -15,11 +15,10 @@ class ProfileFecDisplay : public BaseSlaveProfile { void onFecGeneralSettingsDataPage(void (*func)(FecGeneralSettingsDataPage&, uintptr_t), uintptr_t data = 0) { _onFecGeneralSettingsDataPage.set(func, data); } void onFecTargetPowerDataPage(void (*func)(FecTargetPowerDataPage&, uintptr_t), uintptr_t data = 0) { _onFecTargetPowerDataPage.set(func, data); } void onFecTrackResistanceDataPage(void (*func)(FecTrackResistanceDataPage&, uintptr_t), uintptr_t data = 0) { _onFecTrackResistanceDataPage.set(func, data); } - void onFecBasicResistanceDataPage(void (*func)(FecBasicResistanceDataPage&, uintptr_t), uintptr_t data = 0) { _onFecBasicResistanceDataPage.set(func, data); } void onFecCapabilitiesInformationDataPage(void (*func)(FecCapabilitiesInformationDatapage&, uintptr_t), uintptr_t data = 0) { _onFecCapabilitiesInformationDataPage.set(func, data); } bool transmitFecTargetPowerMsg(uint16_t TargetPower); bool transmitFecTrackResistanceMsg(uint16_t TrackResistance); - bool transmitFecBasicResistanceMsg(uint8_t Power); + bool transmitFecBasicResistanceMsg(uint8_t total_resistance); bool transmitFecUserConfigurationMsg(uint16_t UserWeight, uint16_t BikeWeight); bool transmitFecCapabitiliesRequestMsg(); @@ -36,7 +35,6 @@ class ProfileFecDisplay : public BaseSlaveProfile { bool handleTrainerData(BaseDataPage& dataPage); bool handleTargetPowerDataPage(BaseDataPage& dataPage); bool handleTrackResistanceDataPage(BaseDataPage& dataPage); - bool handleBasicResistanceDataPage(BaseDataPage& dataPage); bool handleCapabilitiesInformationDataPage(BaseDataPage& dataPage); AntCallback _onFecSpecificTrainerData = { .func = NULL }; @@ -46,7 +44,6 @@ class ProfileFecDisplay : public BaseSlaveProfile { AntCallback _onFecGeneralSettingsDataPage = { .func = NULL }; AntCallback _onFecTargetPowerDataPage = { .func = NULL }; AntCallback _onFecTrackResistanceDataPage = { .func = NULL }; - AntCallback _onFecBasicResistanceDataPage = { .func = NULL }; AntCallback _onFecCapabilitiesInformationDataPage = { .func = NULL }; }; From cf86532312aca9816f47e9b700b0b1dd0bc6d44e Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 24 Jan 2022 22:02:54 -0800 Subject: [PATCH 201/241] fec: remove left over HR code in the base datapage --- .../DataPages/ANTPLUS_FecBaseMainDataPage.cpp | 64 +------------------ .../DataPages/ANTPLUS_FecBaseMainDataPage.h | 19 +----- 2 files changed, 4 insertions(+), 79 deletions(-) diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecBaseMainDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecBaseMainDataPage.cpp index 26e2c3c..d125920 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecBaseMainDataPage.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecBaseMainDataPage.cpp @@ -1,72 +1,12 @@ #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 -FecCoreMainDataPage::FecCoreMainDataPage() : CoreDataPage() {} - -template -uint8_t FecCoreMainDataPage::getDataPageNumber() { - return this->get8BitValue(DATAPAGE_BYTE, DATAPAGE_MASK); -} - -template -uint8_t FecCoreMainDataPage::getPageChangeToggle() { - return this->get8BitValue(TOGGLE_BYTE, TOGGLE_MASK, TOGGLE_SHIFT); -} - -template -uint16_t FecCoreMainDataPage::getHeartBeatEventTime() { - return this->get16BitValue(HEARTBEATEVENTTIME_LSB_BYTE, HEARTBEATEVENTTIME_MSB_BYTE); -} - -template -uint8_t FecCoreMainDataPage::getHeartBeatCount() { - return this->get8BitValue(HEARTBEATCOUNT_BYTE); -} - -template -uint8_t FecCoreMainDataPage::getComputedHeartRate() { - return this->get8BitValue(COMPUTEDHEARTRATE_BYTE); -} - -template class FecCoreMainDataPage; -template class FecCoreMainDataPage; - FecBaseMainDataPage::FecBaseMainDataPage(AntRxDataResponse& dp) : - BaseDataPage(dp), - FecCoreMainDataPage() {} + BaseDataPage(dp) {} FecBaseMainDataPageMsg::FecBaseMainDataPageMsg(uint8_t dataPageNumber) : - BaseDataPageMsg(), - FecCoreMainDataPage() { + BaseDataPageMsg() { setDataBuffer(_buffer); set8BitValue(dataPageNumber, ANTPLUS_DEFAULT_DATAPAGE_BYTE); } -void FecBaseMainDataPageMsg::setPageChangeToggle(uint8_t toggle) { - set8BitValue(toggle ? 1 : 0, TOGGLE_BYTE, TOGGLE_MASK, TOGGLE_SHIFT); -} - -void FecBaseMainDataPageMsg::setHeartBeatEventTime(uint16_t time) { - set16BitValue(time, HEARTBEATEVENTTIME_LSB_BYTE, - HEARTBEATEVENTTIME_MSB_BYTE); -} - -void FecBaseMainDataPageMsg::setHeartBeatCount(uint8_t count) { - set8BitValue(count, HEARTBEATCOUNT_BYTE); -} - -void FecBaseMainDataPageMsg::setComputedHeartRate(uint8_t heartRate) { - set8BitValue(heartRate, COMPUTEDHEARTRATE_BYTE); -} diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecBaseMainDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecBaseMainDataPage.h index 69c0dd7..e505b7d 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecBaseMainDataPage.h +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecBaseMainDataPage.h @@ -4,29 +4,14 @@ #include #include -template -class FecCoreMainDataPage : virtual public CoreDataPage { -public: - FecCoreMainDataPage(); - uint8_t getDataPageNumber() override; - uint8_t getPageChangeToggle(); - uint16_t getHeartBeatEventTime(); - uint8_t getHeartBeatCount(); - uint8_t getComputedHeartRate(); -}; - -class FecBaseMainDataPage : public BaseDataPage, public FecCoreMainDataPage { +class FecBaseMainDataPage : public BaseDataPage { public: explicit FecBaseMainDataPage(AntRxDataResponse& dp); }; -class FecBaseMainDataPageMsg : public BaseDataPageMsg, public FecCoreMainDataPage { +class FecBaseMainDataPageMsg : public BaseDataPageMsg { public: explicit FecBaseMainDataPageMsg(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}; }; From ead03c7ba0a51012e2f95673ad3beb102f486a94 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 24 Jan 2022 22:07:15 -0800 Subject: [PATCH 202/241] examples: fec: fix loop check made an error and thought loop returned a value, it does not --- examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino index e94e2bb..5729022 100644 --- a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino +++ b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino @@ -78,7 +78,8 @@ void setup() { } void loop() { - if (!router.loop() && ant.getResponse().isError()) + router.loop(); + if (ant.getResponse().isError()) { Serial.print("ANT MSG ERROR: "); Serial.println(ant.getResponse().getErrorCode()); From fd9c64fb5bcc2db4f9006b89bb56c7763e63f362 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 24 Jan 2022 22:22:41 -0800 Subject: [PATCH 203/241] fec: fix variable name formatting error --- src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistance.cpp | 4 ++-- src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistance.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistance.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistance.cpp index e9acf2b..a2ef273 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistance.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistance.cpp @@ -24,6 +24,6 @@ FecBasicResistanceMsg::FecBasicResistanceMsg() : FecBaseBasicResistance() {} // TODO reserved fields -void FecBasicResistanceMsg::setTotalResistance(uint8_t total_resistance) { - set8BitValue(total_resistance, TOTAL_RESISTANCE_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 index 4a3a8df..7bb4e69 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistance.h +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistance.h @@ -18,7 +18,7 @@ class FecBasicResistance : public FecBaseMainDataPage, public FecBaseBasicResist class FecBasicResistanceMsg : public FecBaseMainDataPageMsg, public FecBaseBasicResistance { public: FecBasicResistanceMsg(); - void setTotalResistance(uint8_t total_resistance); + void setTotalResistance(uint8_t totalResistance); }; From 4a305074a8c32b676252f14fa831e812b4cd3ac7 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 24 Jan 2022 22:54:52 -0800 Subject: [PATCH 204/241] fec: refactor part 3 * rename FecCapabilitiesInformationDataPage to FecFeCapabilities * remove transmit request as it is invalid and should be using the request datapage (TODO) * add defines for bitfield and add to example * rename device type as there is more than one in this profile --- examples/DeviceSearch/DeviceSearch.ino | 4 +- .../FecBikeTrainerDisplay.ino | 22 ++++++---- src/Profiles/Fec/ANTPLUS_FecDataPages.h | 2 +- src/Profiles/Fec/ANTPLUS_FecDefines.h | 23 +++-------- ...LUS_FecCapabilitiesInformationDataPage.cpp | 40 ------------------ ...TPLUS_FecCapabilitiesInformationDataPage.h | 27 ------------ .../DataPages/ANTPLUS_FecFeCapabilities.cpp | 41 +++++++++++++++++++ .../Fec/DataPages/ANTPLUS_FecFeCapabilities.h | 27 ++++++++++++ .../Profiles/ANTPLUS_FecProfileDisplay.cpp | 19 +++------ .../Fec/Profiles/ANTPLUS_FecProfileDisplay.h | 10 +++-- 10 files changed, 100 insertions(+), 115 deletions(-) delete mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecCapabilitiesInformationDataPage.cpp delete mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecCapabilitiesInformationDataPage.h create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.cpp create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.h diff --git a/examples/DeviceSearch/DeviceSearch.ino b/examples/DeviceSearch/DeviceSearch.ino index 80d2ca7..276bef0 100644 --- a/examples/DeviceSearch/DeviceSearch.ino +++ b/examples/DeviceSearch/DeviceSearch.ino @@ -71,8 +71,8 @@ void searchCallback(uint16_t deviceNumber, uint8_t deviceType, uint8_t transmiss case ANTPLUS_ENVIRONMENT_DEVICETYPE: Serial.println("Environment"); break; - case ANTPLUS_FEC_DEVICETYPE: - Serial.println("Fitness Equiment"); + case ANTPLUS_FEC_REALTIMECHANNEL_DEVICETYPE: + Serial.println("Realtime Fitness Equiment"); break; case ANTPLUS_HEARTRATE_DEVICETYPE: Serial.println("Heart Rate"); diff --git a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino index 5729022..ec465b0 100644 --- a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino +++ b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino @@ -25,7 +25,7 @@ void productInformationDataPageHandler(ProductInformation& msg, uintptr_t data); void GeneralDataPageHandler(FecGeneralMainDataPage& msg, uintptr_t data); void GeneralSettingsDataPageHandler(FecGeneralSettingsDataPage& msg, uintptr_t data); void SpecificTrainerDataPageHandler(FecSpecificTrainerData& msg, uintptr_t data); -void CapabitiliesDataPageHandler(FecCapabilitiesInformationDatapage& msg, uintptr_t data); +void FeCapabitiliesDataPageHandler(FecFeCapabilities& msg, uintptr_t data); void TargetPowerDataPagehandler(FecTargetPowerDataPage& msg, uintptr_t data); void TrackREsistanceDataPageHandler(FecTrackResistanceDataPage& msg, uintptr_t data); @@ -57,7 +57,7 @@ void setup() { fec.onFecTargetPowerDataPage(TargetPowerDataPagehandler); fec.onFecTrackResistanceDataPage(TrackResistanceDataPageHandler); fec.onFecTrainerData(SpecificTrainerDataPageHandler); - fec.onFecCapabilitiesInformationDataPage(CapabitiliesDataPageHandler); + fec.onFecFeCapabilities(FeCapabitiliesDataPageHandler); fec.begin(); // wait for pair to complete @@ -72,7 +72,7 @@ void setup() { Serial.print("settings user information"); fec.transmitFecUserConfigurationMsg(9000, 3000); // get fec capabilities - fec.transmitFecCapabitiliesRequestMsg(); + // TODO transmit request datapage asking for capabilities Serial.print("Ask for capacity"); // this datapage not always sent by indoor bike trainer } @@ -132,8 +132,8 @@ void GeneralDataPageHandler(FecGeneralMainDataPage& msg, uintptr_t data) { Serial.println(msg.getSpeed()); Serial.print("FE State:"); Serial.println(msg.getFEStateBits()); - Serial.print("FEC CAPABILITIES:"); - Serial.println(msg.getCapabilitiesBits()); + Serial.println("Fec Capabilities:"); + // TODO } void GeneralSettingsDataPageHandler(FecGeneralSettingsDataPage& msg, uintptr_t data) { @@ -175,15 +175,19 @@ void SpecificTrainerDataPageHandler(FecSpecificTrainerData& msg, uintptr_t data) Serial.println(msg.getFlagsBits()); } -void CapabitiliesDataPageHandler(FecCapabilitiesInformationDatapage& msg, uintptr_t data) -{ +void FeCapabitiliesDataPageHandler(FecFeCapabilities& msg, uintptr_t data) { + uint8_t bits = msg.getCapabilitiesBitField(); Serial.print("Max resistance: "); Serial.println(msg.getMaximumResistance()); Serial.print("Fec Capabilities: "); - Serial.println(msg.getCapabilities()); + Serial.print(" Supports Basic Resistance Mode: "); + Serial.println(bits & ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_CAPABILITIESBITFIELD_SUPPORTSBASICRESISTANCEMODE ? "Y" : "N"); + Serial.print(" Supports Target Power Mode: "); + Serial.println(bits & ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_CAPABILITIESBITFIELD_SUPPORTSTARGETPOWERMODE ? "Y" : "N"); + Serial.print(" Supports Sumulation Mode: "); + Serial.println(bits & ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_CAPABILITIESBITFIELD_SUPPORTSSIMULATIONMODE ? "Y" : "N"); } - void printStatus(uint8_t status) { Serial.print("Channel Status: "); switch (status) { diff --git a/src/Profiles/Fec/ANTPLUS_FecDataPages.h b/src/Profiles/Fec/ANTPLUS_FecDataPages.h index 468bce0..93b4453 100644 --- a/src/Profiles/Fec/ANTPLUS_FecDataPages.h +++ b/src/Profiles/Fec/ANTPLUS_FecDataPages.h @@ -7,7 +7,7 @@ #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 index 52be091..ae0e72d 100644 --- a/src/Profiles/Fec/ANTPLUS_FecDefines.h +++ b/src/Profiles/Fec/ANTPLUS_FecDefines.h @@ -1,24 +1,11 @@ #ifndef ANTPLUS_FECPROFILEDEFINES_h #define ANTPLUS_FECPROFILEDEFINES_h -#define ANTPLUS_FEC_DEVICETYPE 17 +#define ANTPLUS_FEC_REALTIMECHANNEL_DEVICETYPE 17 +// TODO there are multiple device types for this profile -#define ANTPLUS_FEC_FLAGS_CUMULATIVEOPERATINGTIME_SUPPORTED (1 << 0) -#define ANTPLUS_FEC_FLAGS_PREVIOUSHEARTBEAT_SUPPORTED (1 << 1) -#define ANTPLUS_FEC_FLAGS_EXTENTED_FEATURES (1 << 2) -#define ANTPLUS_FEC_FLAGS_BATTERYSTATUS_SUPPORTED (1 << 3) - -#define ANTPLUS_FEC_DATAPAGE_CAPABILITIES_FEATURES_EXTENDEDRUNNING 0x01 -#define ANTPLUS_FEC_DATAPAGE_CAPABILITIES_FEATURES_EXTENDEDCYCLING 0x02 -#define ANTPLUS_FEC_DATAPAGE_CAPABILITIES_FEATURES_EXTENDEDSWIMMING 0x04 -#define ANTPLUS_FEC_DATAPAGE_CAPABILITIES_FEATURES_MANUFACTURER1 0x40 -#define ANTPLUS_FEC_DATAPAGE_CAPABILITIES_FEATURES_MANUFACTURER2 0x80 - -// TODO all below defines need to be added to example -#define ANTPLUS_FEC_DATAPAGE_PREVIOUSHEARTBEAT_MANUFACTURERSPECIFIC_INVALID 0xFF - -#define ANTPLUS_FEC_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALAVERAGEFEC_INVALID 0 -#define ANTPLUS_FEC_DATAPAGE_SWIMINTERVALSUMMARY_INTERVALMAXIMUMFEC_INVALID 0 -#define ANTPLUS_FEC_DATAPAGE_SWIMINTERVALSUMMARY_SESSIONAVERAGEFEC_INVALID 0 +#define ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_CAPABILITIESBITFIELD_SUPPORTSBASICRESISTANCEMODE (1 << 0) +#define ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_CAPABILITIESBITFIELD_SUPPORTSTARGETPOWERMODE (1 << 1) +#define ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_CAPABILITIESBITFIELD_SUPPORTSSIMULATIONMODE (1 << 2) #endif // ANTPLUS_FECPROFILEDEFINES_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecCapabilitiesInformationDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecCapabilitiesInformationDataPage.cpp deleted file mode 100644 index d063b27..0000000 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecCapabilitiesInformationDataPage.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include - -#define MAX_RESISTANCE_LSB_BYTE 5 -#define MAX_RESISTANCE_MSB_BYTE 6 -#define FEC_CAPABILITIES_BYTE 7 - -template -FecBaseCapabilitiesInformationDatapage::FecBaseCapabilitiesInformationDatapage() : - CoreDataPage() {} - -template -uint16_t FecBaseCapabilitiesInformationDatapage::getMaximumResistance() { - return this->get16BitValue(MAX_RESISTANCE_LSB_BYTE, MAX_RESISTANCE_MSB_BYTE); -} - -template -uint8_t FecBaseCapabilitiesInformationDatapage::getCapabilities() { - return this->get8BitValue(FEC_CAPABILITIES_BYTE); -} - -template class FecBaseCapabilitiesInformationDatapage; -template class FecBaseCapabilitiesInformationDatapage; - -FecCapabilitiesInformationDatapage::FecCapabilitiesInformationDatapage(AntRxDataResponse& dp) : - FecBaseMainDataPage(dp), - FecBaseCapabilitiesInformationDatapage() {} - -FecCapabilitiesInformationMsg::FecCapabilitiesInformationMsg() : - FecBaseMainDataPageMsg(FE_CAPABILITIES_NUMBER), - FecBaseCapabilitiesInformationDatapage() {} - -void FecCapabilitiesInformationMsg::setMaximumResistance(uint16_t MaximumResistance) { - set16BitValue(MaximumResistance, MAX_RESISTANCE_LSB_BYTE, MAX_RESISTANCE_MSB_BYTE); -} - -void FecCapabilitiesInformationMsg::setCapabitilies(uint8_t Capabilities) { - set8BitValue(Capabilities, FEC_CAPABILITIES_BYTE); -} - diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecCapabilitiesInformationDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecCapabilitiesInformationDataPage.h deleted file mode 100644 index 253f3c3..0000000 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecCapabilitiesInformationDataPage.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef ANTPLUS_FECCAPABILITIESINFORMATIONDATAPAGE_h -#define ANTPLUS_FECCAPABILITIESINFORMATIONDATAPAGE_h - -#include - -template -class FecBaseCapabilitiesInformationDatapage : virtual public CoreDataPage { -public: - FecBaseCapabilitiesInformationDatapage(); - uint16_t getMaximumResistance(); - uint8_t getCapabilities(); -}; - -class FecCapabilitiesInformationDatapage : public FecBaseMainDataPage, public FecBaseCapabilitiesInformationDatapage { -public: - explicit FecCapabilitiesInformationDatapage(AntRxDataResponse& dp); -}; - -class FecCapabilitiesInformationMsg : public FecBaseMainDataPageMsg, public FecBaseCapabilitiesInformationDatapage { -public: - FecCapabilitiesInformationMsg(); - void setMaximumResistance(uint16_t UserWeight); - void setCapabitilies(uint8_t BikeWeight); -}; - -#endif // ANTPLUS_FECCAPABILITIESINFORMATIONDATAPAGE_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..b286684 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.cpp @@ -0,0 +1,41 @@ +#include +#include + +#define MAXIMUM_RESISTANCE_LSB_BYTE 5 +#define MAXIMUM_RESISTANCE_MSB_BYTE 6 +#define CAPABILITIES_BIT_FIELD_BYTE 7 + +template +FecBaseFeCapabilities::FecBaseFeCapabilities() : + CoreDataPage() {} + +template +uint16_t FecBaseFeCapabilities::getMaximumResistance() { + return this->get16BitValue(MAXIMUM_RESISTANCE_LSB_BYTE, MAXIMUM_RESISTANCE_MSB_BYTE); +} + +template +uint8_t FecBaseFeCapabilities::getCapabilitiesBitField() { + return this->get8BitValue(CAPABILITIES_BIT_FIELD_BYTE); +} + +template class FecBaseFeCapabilities; +template class FecBaseFeCapabilities; + +FecFeCapabilities::FecFeCapabilities(AntRxDataResponse& dp) : + FecBaseMainDataPage(dp), + FecBaseFeCapabilities() {} + +FecFeCapabilitiesMsg::FecFeCapabilitiesMsg() : + FecBaseMainDataPageMsg(FE_CAPABILITIES_NUMBER), + FecBaseFeCapabilities() {} + // TODO reserved fields + +void FecFeCapabilitiesMsg::setMaximumResistance(uint16_t maximumResistance) { + set16BitValue(maximumResistance, MAXIMUM_RESISTANCE_LSB_BYTE, MAXIMUM_RESISTANCE_MSB_BYTE); +} + +void FecFeCapabilitiesMsg::setCapabitiliesBitField(uint8_t capabilities) { + set8BitValue(capabilities, CAPABILITIES_BIT_FIELD_BYTE); +} + diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.h new file mode 100644 index 0000000..ed73bc5 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.h @@ -0,0 +1,27 @@ +#ifndef ANTPLUS_FECFECAPABILITIES_h +#define ANTPLUS_FECFECAPABILITIES_h + +#include + +template +class FecBaseFeCapabilities : virtual public CoreDataPage { +public: + FecBaseFeCapabilities(); + uint16_t getMaximumResistance(); + uint8_t getCapabilitiesBitField(); +}; + +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 setCapabitiliesBitField(uint8_t BikeWeight); +}; + +#endif // ANTPLUS_FECFECAPABILITIES_h + diff --git a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp index cde5d3a..44c284f 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp @@ -46,7 +46,7 @@ bool ProfileFecDisplay::handleDataPage(BaseDataPage& dp) { break; case FE_CAPABILITIES_NUMBER: - called = handleCapabilitiesInformationDataPage(dp); + called = handleFeCapabilities(dp); break; } @@ -63,7 +63,7 @@ void ProfileFecDisplay::onAcknowledgedData(AcknowledgedData& msg) { void ProfileFecDisplay::setChannelConfig() { setChannelType(DISPLAY_CHANNELTYPE); - setDeviceType(ANTPLUS_FEC_DEVICETYPE); + setDeviceType(ANTPLUS_FEC_REALTIMECHANNEL_DEVICETYPE); setChannelPeriod(ANTPLUS_FEC_CHANNELPERIOD); setSearchTimeout(ANTPLUS_FEC_SEARCHTIMEOUT); } @@ -92,9 +92,9 @@ bool ProfileFecDisplay::handleTargetPowerDataPage(BaseDataPage& d return _onFecTargetPowerDataPage.call(dp); } -bool ProfileFecDisplay::handleCapabilitiesInformationDataPage(BaseDataPage& dataPage) { - FecCapabilitiesInformationDatapage dp(dataPage); - return _onFecCapabilitiesInformationDataPage.call(dp); +bool ProfileFecDisplay::handleFeCapabilities(BaseDataPage& dataPage) { + FecFeCapabilities dp(dataPage); + return _onFecFeCapabilities.call(dp); } bool ProfileFecDisplay::transmitFecTargetPowerMsg(uint16_t TargetPower) { @@ -126,15 +126,6 @@ bool ProfileFecDisplay::transmitFecUserConfigurationMsg(uint16_t UserWeight, uin return true; } -bool ProfileFecDisplay::transmitFecCapabitiliesRequestMsg() -{ - FecCapabilitiesInformationMsg msg; - msg.setCapabitilies(0); - msg.setMaximumResistance(800); - send(msg); - return true; -} - bool ProfileFecDisplay::handleTrainerData(BaseDataPage& 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 index ae5c86e..76cc2d0 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h @@ -15,12 +15,13 @@ class ProfileFecDisplay : public BaseSlaveProfile { void onFecGeneralSettingsDataPage(void (*func)(FecGeneralSettingsDataPage&, uintptr_t), uintptr_t data = 0) { _onFecGeneralSettingsDataPage.set(func, data); } void onFecTargetPowerDataPage(void (*func)(FecTargetPowerDataPage&, uintptr_t), uintptr_t data = 0) { _onFecTargetPowerDataPage.set(func, data); } void onFecTrackResistanceDataPage(void (*func)(FecTrackResistanceDataPage&, uintptr_t), uintptr_t data = 0) { _onFecTrackResistanceDataPage.set(func, data); } - void onFecCapabilitiesInformationDataPage(void (*func)(FecCapabilitiesInformationDatapage&, uintptr_t), uintptr_t data = 0) { _onFecCapabilitiesInformationDataPage.set(func, data); } + void onFecFeCapabilities(void (*func)(FecFeCapabilities&, uintptr_t), uintptr_t data = 0) { _onFecFeCapabilities.set(func, data); } bool transmitFecTargetPowerMsg(uint16_t TargetPower); bool transmitFecTrackResistanceMsg(uint16_t TrackResistance); bool transmitFecBasicResistanceMsg(uint8_t total_resistance); bool transmitFecUserConfigurationMsg(uint16_t UserWeight, uint16_t BikeWeight); - bool transmitFecCapabitiliesRequestMsg(); + // TODO delete these + // TODO also move data page numbers to public, otherwise requests don't work private: void setChannelConfig(); @@ -35,7 +36,8 @@ class ProfileFecDisplay : public BaseSlaveProfile { bool handleTrainerData(BaseDataPage& dataPage); bool handleTargetPowerDataPage(BaseDataPage& dataPage); bool handleTrackResistanceDataPage(BaseDataPage& dataPage); - bool handleCapabilitiesInformationDataPage(BaseDataPage& dataPage); + bool handleFeCapabilities(BaseDataPage& dataPage); + // TODO update to base main dp AntCallback _onFecSpecificTrainerData = { .func = NULL }; AntCallback _onManufacturersInformation = { .func = NULL }; @@ -44,7 +46,7 @@ class ProfileFecDisplay : public BaseSlaveProfile { AntCallback _onFecGeneralSettingsDataPage = { .func = NULL }; AntCallback _onFecTargetPowerDataPage = { .func = NULL }; AntCallback _onFecTrackResistanceDataPage = { .func = NULL }; - AntCallback _onFecCapabilitiesInformationDataPage = { .func = NULL }; + AntCallback _onFecFeCapabilities = { .func = NULL }; }; #endif // ANTPLUS_PROFILEFECDISPLAY_h From 7a44be8ecc7cd8fe368397e367f70ea3e050e025 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Fri, 28 Jan 2022 12:35:37 -0800 Subject: [PATCH 205/241] fec: datapges: set reserved values for capabilities --- .../Fec/DataPages/ANTPLUS_FecFeCapabilities.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.cpp index b286684..1765d1d 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.cpp @@ -4,6 +4,10 @@ #define MAXIMUM_RESISTANCE_LSB_BYTE 5 #define MAXIMUM_RESISTANCE_MSB_BYTE 6 #define CAPABILITIES_BIT_FIELD_BYTE 7 +#define MAXIMUM_RESISTANCE_INVALID 0xFFFF +#define RESERVED_LSB 1 +#define RESERVED_MSB 4 +#define RESERVED_VALUE 0xFFFFFFFF template FecBaseFeCapabilities::FecBaseFeCapabilities() : @@ -28,8 +32,10 @@ FecFeCapabilities::FecFeCapabilities(AntRxDataResponse& dp) : FecFeCapabilitiesMsg::FecFeCapabilitiesMsg() : FecBaseMainDataPageMsg(FE_CAPABILITIES_NUMBER), - FecBaseFeCapabilities() {} - // TODO reserved fields + FecBaseFeCapabilities() { + this->set32BitValue(RESERVED_VALUE, RESERVED_LSB, RESERVED_MSB); + setMaximumResistance(MAXIMUM_RESISTANCE_INVALID); +} void FecFeCapabilitiesMsg::setMaximumResistance(uint16_t maximumResistance) { set16BitValue(maximumResistance, MAXIMUM_RESISTANCE_LSB_BYTE, MAXIMUM_RESISTANCE_MSB_BYTE); From a3b79856cd2263620506c99e6c408f9f151ded70 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Fri, 28 Jan 2022 12:47:52 -0800 Subject: [PATCH 206/241] fec: datapages: refine equipment type bitfield add defines and mask byte per doc requirements --- .../FecBikeTrainerDisplay.ino | 31 ++++++++++++++++++- src/Profiles/Fec/ANTPLUS_FecDefines.h | 9 ++++++ .../ANTPLUS_FecGeneralMainDataPage.cpp | 3 +- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino index ec465b0..b506679 100644 --- a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino +++ b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino @@ -126,8 +126,37 @@ void productInformationDataPageHandler(ProductInformation& msg, uintptr_t data) } void GeneralDataPageHandler(FecGeneralMainDataPage& msg, uintptr_t data) { + uint8_t equipment_type = msg.getEquipmentTypeBits(); Serial.print("Equipment type: "); - Serial.println(msg.getEquipmentTypeBits()); + switch (equipment_type) { + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_GENERAL: + Serial.println("General"); + break; + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_TREADMILL: + Serial.println("Treadmill"); + break; + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_ELLIPTICAL: + Serial.println("Elliptical"); + break; + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_STATIONARYBIKE: + Serial.println("Stationary Bike"); + break; + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_ROWER: + Serial.println("Rower"); + break; + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_CLIMBER: + Serial.println("Climber"); + break; + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_NORDICSKIER: + Serial.println("Nordic Skier"); + break; + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_TRAINER: + Serial.println("Trainer"); + break; + default: + Serial.println("Unknown"); + break; + } Serial.print("Current speed:" ); Serial.println(msg.getSpeed()); Serial.print("FE State:"); diff --git a/src/Profiles/Fec/ANTPLUS_FecDefines.h b/src/Profiles/Fec/ANTPLUS_FecDefines.h index ae0e72d..d60078a 100644 --- a/src/Profiles/Fec/ANTPLUS_FecDefines.h +++ b/src/Profiles/Fec/ANTPLUS_FecDefines.h @@ -4,6 +4,15 @@ #define ANTPLUS_FEC_REALTIMECHANNEL_DEVICETYPE 17 // TODO there are multiple device types for this profile +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_GENERAL 16 +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_TREADMILL 19 +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_ELLIPTICAL 20 +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_STATIONARYBIKE 21 +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_ROWER 22 +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_CLIMBER 23 +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_NORDICSKIER 24 +#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_TRAINER 25 + #define ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_CAPABILITIESBITFIELD_SUPPORTSBASICRESISTANCEMODE (1 << 0) #define ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_CAPABILITIESBITFIELD_SUPPORTSTARGETPOWERMODE (1 << 1) #define ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_CAPABILITIESBITFIELD_SUPPORTSSIMULATIONMODE (1 << 2) diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp index dee3a57..c2a1646 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp @@ -4,6 +4,7 @@ // TODO this is a mixture of datapages #define EQUIPMENTTYPEBITS_BYTE 1 +#define EQUIPMENTTYPEBITS_MASK 0x0F #define ELAPSEDTIME_BYTE 2 #define DISTANCETRAVELED_BYTE 3 #define SPEED_LSB_BYTE 4 @@ -21,7 +22,7 @@ FecBaseGeneralMainDataPage::FecBaseGeneralMainDataPage() : template uint8_t FecBaseGeneralMainDataPage::getEquipmentTypeBits() { - return this->get8BitValue(EQUIPMENTTYPEBITS_BYTE); + return this->get8BitValue(EQUIPMENTTYPEBITS_BYTE, EQUIPMENTTYPEBITS_MASK); } template From 575d77b757ed0b48b6d410b01b313ffdade6f590 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Fri, 28 Jan 2022 18:53:18 -0800 Subject: [PATCH 207/241] fec: refactor part 4 * Rename general main datapage to general fe data * Add a bunch of public defines for the fields --- .../FecBikeTrainerDisplay.ino | 81 ++++++++--- src/Profiles/Fec/ANTPLUS_FecDataPages.h | 2 +- src/Profiles/Fec/ANTPLUS_FecDefines.h | 35 +++-- src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h | 8 ++ .../DataPages/ANTPLUS_FecGeneralFeData.cpp | 135 ++++++++++++++++++ .../Fec/DataPages/ANTPLUS_FecGeneralFeData.h | 43 ++++++ .../ANTPLUS_FecGeneralMainDataPage.cpp | 70 --------- .../ANTPLUS_FecGeneralMainDataPage.h | 31 ---- .../Profiles/ANTPLUS_FecProfileDisplay.cpp | 4 +- .../Fec/Profiles/ANTPLUS_FecProfileDisplay.h | 4 +- 10 files changed, 280 insertions(+), 133 deletions(-) create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.cpp create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.h delete mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp delete mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.h diff --git a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino index b506679..c19bbff 100644 --- a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino +++ b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino @@ -22,7 +22,7 @@ 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(FecGeneralMainDataPage& msg, uintptr_t data); +void GeneralDataPageHandler(FecGeneralFeData& msg, uintptr_t data); void GeneralSettingsDataPageHandler(FecGeneralSettingsDataPage& msg, uintptr_t data); void SpecificTrainerDataPageHandler(FecSpecificTrainerData& msg, uintptr_t data); void FeCapabitiliesDataPageHandler(FecFeCapabilities& msg, uintptr_t data); @@ -52,7 +52,7 @@ void setup() { fec.onDataPage(fecBaseDataPageHandler); fec.onManufacturersInformation(manufacturerInformationDataPageHandler); fec.onProductInformation(productInformationDataPageHandler); - fec.onFecGeneralDataPage(GeneralDataPageHandler); + fec.onFecGeneralFeData(GeneralDataPageHandler); //fec.onFecGeneralSettingsDataPage(GeneralSettingsDataPageHandler); fec.onFecTargetPowerDataPage(TargetPowerDataPagehandler); fec.onFecTrackResistanceDataPage(TrackResistanceDataPageHandler); @@ -125,44 +125,59 @@ void productInformationDataPageHandler(ProductInformation& msg, uintptr_t data) Serial.println(msg.getSerialNumber()); } -void GeneralDataPageHandler(FecGeneralMainDataPage& msg, uintptr_t data) { - uint8_t equipment_type = msg.getEquipmentTypeBits(); +void GeneralDataPageHandler(FecGeneralFeData& msg, uintptr_t data) { + uint8_t fe_type = msg.getFeType(); Serial.print("Equipment type: "); - switch (equipment_type) { - case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_GENERAL: + switch (fe_type) { + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_GENERAL: Serial.println("General"); break; - case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_TREADMILL: + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_TREADMILL: Serial.println("Treadmill"); break; - case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_ELLIPTICAL: + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_ELLIPTICAL: Serial.println("Elliptical"); break; - case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_STATIONARYBIKE: + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_STATIONARYBIKE: Serial.println("Stationary Bike"); break; - case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_ROWER: + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_ROWER: Serial.println("Rower"); break; - case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_CLIMBER: + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_CLIMBER: Serial.println("Climber"); break; - case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_NORDICSKIER: + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_NORDICSKIER: Serial.println("Nordic Skier"); break; - case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_TRAINER: + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_TRAINER: Serial.println("Trainer"); break; default: Serial.println("Unknown"); break; } - Serial.print("Current speed:" ); - Serial.println(msg.getSpeed()); - Serial.print("FE State:"); - Serial.println(msg.getFEStateBits()); - Serial.println("Fec Capabilities:"); - // TODO + 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); + } + + printFeState(msg.getFeState()); + printLapToggleBit(msg.getLapToggleBit()); } void GeneralSettingsDataPageHandler(FecGeneralSettingsDataPage& msg, uintptr_t data) { @@ -174,6 +189,34 @@ void GeneralSettingsDataPageHandler(FecGeneralSettingsDataPage& msg, uintptr_t d Serial.println(msg.getResistanceLevel()); } +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 fecBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data) { FecBaseMainDataPage dp = FecBaseMainDataPage(msg); diff --git a/src/Profiles/Fec/ANTPLUS_FecDataPages.h b/src/Profiles/Fec/ANTPLUS_FecDataPages.h index 93b4453..f5f7c9f 100644 --- a/src/Profiles/Fec/ANTPLUS_FecDataPages.h +++ b/src/Profiles/Fec/ANTPLUS_FecDataPages.h @@ -1,7 +1,7 @@ #ifndef ANTPLUS_PROFILEFECDATAPAGES_h #define ANTPLUS_PROFILEFECDATAPAGES_h -#include +#include #include #include #include diff --git a/src/Profiles/Fec/ANTPLUS_FecDefines.h b/src/Profiles/Fec/ANTPLUS_FecDefines.h index d60078a..fc74f4b 100644 --- a/src/Profiles/Fec/ANTPLUS_FecDefines.h +++ b/src/Profiles/Fec/ANTPLUS_FecDefines.h @@ -4,14 +4,33 @@ #define ANTPLUS_FEC_REALTIMECHANNEL_DEVICETYPE 17 // TODO there are multiple device types for this profile -#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_GENERAL 16 -#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_TREADMILL 19 -#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_ELLIPTICAL 20 -#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_STATIONARYBIKE 21 -#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_ROWER 22 -#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_CLIMBER 23 -#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_NORDICSKIER 24 -#define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_EQUIPMENTTYPEBITFIELD_TRAINER 25 +#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 + +#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 #define ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_CAPABILITIESBITFIELD_SUPPORTSBASICRESISTANCEMODE (1 << 0) #define ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_CAPABILITIESBITFIELD_SUPPORTSTARGETPOWERMODE (1 << 1) diff --git a/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h b/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h index 1e3cab0..158f143 100644 --- a/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h +++ b/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h @@ -19,4 +19,12 @@ #define FE_CAPABILITIES_NUMBER 54 #define USER_CONFIGURATION_NUMBER 55 +// 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/DataPages/ANTPLUS_FecGeneralFeData.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.cpp new file mode 100644 index 0000000..32bebcc --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.cpp @@ -0,0 +1,135 @@ +#include +#include +#include + +#define FETYPE_BYTE 1 +#define FETYPE_MASK 0x0F +#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(GENERAL_FE_DATA_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..77d8282 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.h @@ -0,0 +1,43 @@ +#ifndef ANTPLUS_FECGENERALMAINDATAPAGE_h +#define ANTPLUS_FECGENERALMAINDATAPAGE_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_FECGENERALMAINDATAPAGE_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp deleted file mode 100644 index c2a1646..0000000 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include -#include -#include - -// TODO this is a mixture of datapages -#define EQUIPMENTTYPEBITS_BYTE 1 -#define EQUIPMENTTYPEBITS_MASK 0x0F -#define ELAPSEDTIME_BYTE 2 -#define DISTANCETRAVELED_BYTE 3 -#define SPEED_LSB_BYTE 4 -#define SPEED_MSB_BYTE 5 -#define HEARTRATE_BYTE 6 -#define CAPABILITIESBITFIELD_BYTE 7 -#define CAPABILITIESBITFIELD_MASK 0x0F -#define FESTATEBITFIELD_BYTE 7 -#define FESTATEBITFIELD_MASK 0xF0 -#define FESTATEBITFIELD_SHIFT 4 - -template -FecBaseGeneralMainDataPage::FecBaseGeneralMainDataPage() : - CoreDataPage() {} - -template -uint8_t FecBaseGeneralMainDataPage::getEquipmentTypeBits() { - return this->get8BitValue(EQUIPMENTTYPEBITS_BYTE, EQUIPMENTTYPEBITS_MASK); -} - -template -uint8_t FecBaseGeneralMainDataPage::getElapsedTime() { - return this->get8BitValue(ELAPSEDTIME_BYTE); -} - -template -uint8_t FecBaseGeneralMainDataPage::getDistanceTraveled() { - return this->get8BitValue(DISTANCETRAVELED_BYTE); -} - -template -uint8_t FecBaseGeneralMainDataPage::getHeartRate() { - return this->get8BitValue(HEARTRATE_BYTE); -} - -template -uint8_t FecBaseGeneralMainDataPage::getCapabilitiesBits() { - return this->get8BitValue(CAPABILITIESBITFIELD_BYTE, - CAPABILITIESBITFIELD_MASK); -} - -template -uint8_t FecBaseGeneralMainDataPage::getFEStateBits() { - return this->get8BitValue(FESTATEBITFIELD_BYTE, FESTATEBITFIELD_MASK, - FESTATEBITFIELD_SHIFT); -} - -template -uint16_t FecBaseGeneralMainDataPage::getSpeed() { - return this->get16BitValue(SPEED_LSB_BYTE, SPEED_MSB_BYTE); -} - -template class FecBaseGeneralMainDataPage; -template class FecBaseGeneralMainDataPage; - -FecGeneralMainDataPage::FecGeneralMainDataPage(AntRxDataResponse& dp) : - FecBaseMainDataPage(dp), - FecBaseGeneralMainDataPage() {} - -FecGeneralMainDataMsg::FecGeneralMainDataMsg() : - FecBaseMainDataPageMsg(GENERAL_FE_DATA_NUMBER), - FecBaseGeneralMainDataPage() {} -// TODO diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.h deleted file mode 100644 index 56ffe60..0000000 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralMainDataPage.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef ANTPLUS_FECGENERALMAINDATAPAGE_h -#define ANTPLUS_FECGENERALMAINDATAPAGE_h - -#include - -template -class FecBaseGeneralMainDataPage : virtual public CoreDataPage { -public: - FecBaseGeneralMainDataPage(); - uint8_t getEquipmentTypeBits(); - uint8_t getElapsedTime(); - uint8_t getDistanceTraveled(); - uint16_t getSpeed(); - uint8_t getHeartRate(); - uint8_t getCapabilitiesBits(); - uint8_t getFEStateBits(); -}; - -class FecGeneralMainDataPage : public FecBaseMainDataPage, public FecBaseGeneralMainDataPage { -public: - explicit FecGeneralMainDataPage(AntRxDataResponse& dp); -}; - -class FecGeneralMainDataMsg : public FecBaseMainDataPageMsg, public FecBaseGeneralMainDataPage { -public: - FecGeneralMainDataMsg(); - // void setSoftwareRevision(uint16_t SoftwareRevision); -}; - - -#endif // ANTPLUS_FECGENERALMAINDATAPAGE_h diff --git a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp index 44c284f..45e6353 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp @@ -79,8 +79,8 @@ bool ProfileFecDisplay::handleProductInformation(BaseDataPage& da } bool ProfileFecDisplay::handleGeneralDataPage(BaseDataPage& dataPage) { - FecGeneralMainDataPage dp(dataPage); - return _onFecGeneralDataPage.call(dp); + FecGeneralFeData dp(dataPage); + return _onFecGeneralFeData.call(dp); } bool ProfileFecDisplay::handleGeneralSettingsDataPage(BaseDataPage& dataPage) { diff --git a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h index 76cc2d0..576b568 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h @@ -11,7 +11,7 @@ class ProfileFecDisplay : public BaseSlaveProfile { 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 onFecGeneralDataPage(void (*func)(FecGeneralMainDataPage&, uintptr_t), uintptr_t data = 0) { _onFecGeneralDataPage.set(func, data); } + void onFecGeneralFeData(void (*func)(FecGeneralFeData&, uintptr_t), uintptr_t data = 0) { _onFecGeneralFeData.set(func, data); } void onFecGeneralSettingsDataPage(void (*func)(FecGeneralSettingsDataPage&, uintptr_t), uintptr_t data = 0) { _onFecGeneralSettingsDataPage.set(func, data); } void onFecTargetPowerDataPage(void (*func)(FecTargetPowerDataPage&, uintptr_t), uintptr_t data = 0) { _onFecTargetPowerDataPage.set(func, data); } void onFecTrackResistanceDataPage(void (*func)(FecTrackResistanceDataPage&, uintptr_t), uintptr_t data = 0) { _onFecTrackResistanceDataPage.set(func, data); } @@ -42,7 +42,7 @@ class ProfileFecDisplay : public BaseSlaveProfile { AntCallback _onFecSpecificTrainerData = { .func = NULL }; AntCallback _onManufacturersInformation = { .func = NULL }; AntCallback _onProductInformation = { .func = NULL }; - AntCallback _onFecGeneralDataPage = { .func = NULL }; + AntCallback _onFecGeneralFeData = { .func = NULL }; AntCallback _onFecGeneralSettingsDataPage = { .func = NULL }; AntCallback _onFecTargetPowerDataPage = { .func = NULL }; AntCallback _onFecTrackResistanceDataPage = { .func = NULL }; From f44aa7cb615d643423f3f0aa44b6089db6292d3a Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Fri, 28 Jan 2022 19:27:28 -0800 Subject: [PATCH 208/241] fec: datapages: breakout capabilites bit field --- .../FecBikeTrainerDisplay.ino | 7 ++- src/Profiles/Fec/ANTPLUS_FecDefines.h | 4 +- .../DataPages/ANTPLUS_FecFeCapabilities.cpp | 47 ++++++++++++++++--- .../Fec/DataPages/ANTPLUS_FecFeCapabilities.h | 8 +++- 4 files changed, 50 insertions(+), 16 deletions(-) diff --git a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino index c19bbff..b82f69b 100644 --- a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino +++ b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino @@ -248,16 +248,15 @@ void SpecificTrainerDataPageHandler(FecSpecificTrainerData& msg, uintptr_t data) } void FeCapabitiliesDataPageHandler(FecFeCapabilities& msg, uintptr_t data) { - uint8_t bits = msg.getCapabilitiesBitField(); Serial.print("Max resistance: "); Serial.println(msg.getMaximumResistance()); Serial.print("Fec Capabilities: "); Serial.print(" Supports Basic Resistance Mode: "); - Serial.println(bits & ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_CAPABILITIESBITFIELD_SUPPORTSBASICRESISTANCEMODE ? "Y" : "N"); + Serial.println(msg.getBasicResistanceModeSupport() ? "Y" : "N"); Serial.print(" Supports Target Power Mode: "); - Serial.println(bits & ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_CAPABILITIESBITFIELD_SUPPORTSTARGETPOWERMODE ? "Y" : "N"); + Serial.println(msg.getTargetPowerModeSupport() ? "Y" : "N"); Serial.print(" Supports Sumulation Mode: "); - Serial.println(bits & ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_CAPABILITIESBITFIELD_SUPPORTSSIMULATIONMODE ? "Y" : "N"); + Serial.println(msg.getSimulationModeSupport() ? "Y" : "N"); } void printStatus(uint8_t status) { diff --git a/src/Profiles/Fec/ANTPLUS_FecDefines.h b/src/Profiles/Fec/ANTPLUS_FecDefines.h index fc74f4b..cfb8861 100644 --- a/src/Profiles/Fec/ANTPLUS_FecDefines.h +++ b/src/Profiles/Fec/ANTPLUS_FecDefines.h @@ -32,8 +32,6 @@ #define ANTPLUS_FEC_DATAPAGE_FESTATE_INUSE 3 #define ANTPLUS_FEC_DATAPAGE_FESTATE_FINISHED 4 -#define ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_CAPABILITIESBITFIELD_SUPPORTSBASICRESISTANCEMODE (1 << 0) -#define ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_CAPABILITIESBITFIELD_SUPPORTSTARGETPOWERMODE (1 << 1) -#define ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_CAPABILITIESBITFIELD_SUPPORTSSIMULATIONMODE (1 << 2) +#define ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_MAXIMUM_RESISTANCE_INVALID 0xFFFF #endif // ANTPLUS_FECPROFILEDEFINES_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.cpp index 1765d1d..f5062d3 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.cpp @@ -3,8 +3,14 @@ #define MAXIMUM_RESISTANCE_LSB_BYTE 5 #define MAXIMUM_RESISTANCE_MSB_BYTE 6 -#define CAPABILITIES_BIT_FIELD_BYTE 7 -#define MAXIMUM_RESISTANCE_INVALID 0xFFFF +#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 1 #define RESERVED_MSB 4 #define RESERVED_VALUE 0xFFFFFFFF @@ -19,8 +25,22 @@ uint16_t FecBaseFeCapabilities::getMaximumResistance() { } template -uint8_t FecBaseFeCapabilities::getCapabilitiesBitField() { - return this->get8BitValue(CAPABILITIES_BIT_FIELD_BYTE); +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; @@ -34,14 +54,27 @@ FecFeCapabilitiesMsg::FecFeCapabilitiesMsg() : FecBaseMainDataPageMsg(FE_CAPABILITIES_NUMBER), FecBaseFeCapabilities() { this->set32BitValue(RESERVED_VALUE, RESERVED_LSB, RESERVED_MSB); - setMaximumResistance(MAXIMUM_RESISTANCE_INVALID); + 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::setCapabitiliesBitField(uint8_t capabilities) { - set8BitValue(capabilities, CAPABILITIES_BIT_FIELD_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 index ed73bc5..169dcc2 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.h +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.h @@ -8,7 +8,9 @@ class FecBaseFeCapabilities : virtual public CoreDataPage { public: FecBaseFeCapabilities(); uint16_t getMaximumResistance(); - uint8_t getCapabilitiesBitField(); + uint8_t getBasicResistanceModeSupport(); + uint8_t getTargetPowerModeSupport(); + uint8_t getSimulationModeSupport(); }; class FecFeCapabilities : public FecBaseMainDataPage, public FecBaseFeCapabilities { @@ -20,7 +22,9 @@ class FecFeCapabilitiesMsg : public FecBaseMainDataPageMsg, public FecBaseFeCapa public: FecFeCapabilitiesMsg(); void setMaximumResistance(uint16_t UserWeight); - void setCapabitiliesBitField(uint8_t BikeWeight); + void setBasicResistanceModeSupport(uint8_t support); + void setTargetPowerModeSupport(uint8_t support); + void setSimulationModeSupport(uint8_t support); }; #endif // ANTPLUS_FECFECAPABILITIES_h From d3e2f55e3de53b4d346a6e70f69fa5ff9df53990 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Fri, 28 Jan 2022 19:35:37 -0800 Subject: [PATCH 209/241] fec: remove incomplete datapage --- .../Fec/DataPages/ANTPLUS_FecFEMainDataPage.cpp | 13 ------------- .../Fec/DataPages/ANTPLUS_FecFEMainDataPage.h | 14 -------------- 2 files changed, 27 deletions(-) delete mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecFEMainDataPage.cpp delete mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecFEMainDataPage.h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecFEMainDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecFEMainDataPage.cpp deleted file mode 100644 index bede4c3..0000000 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecFEMainDataPage.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include - -#define CADENCE_BYTE 4 -#define NEGTIVE_VERTICAL_DISTANCE_BYTE 5 - -// TODO update name -template -FECFEMainDataPage::FECFEMainDataPage() : - CoreDataPage() {} - -template class FECFEMainDataPage; -template class FECFEMainDataPage; diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecFEMainDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecFEMainDataPage.h deleted file mode 100644 index 3fbd1cc..0000000 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecFEMainDataPage.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef ANTPLUS_FECFEEMAINDATAPAGE_h -#define ANTPLUS_FECFEEMAINDATAPAGE_h - -#include - -#include "ANT.h" - -template -class FECFEMainDataPage : virtual public CoreDataPage { -public: - FECFEMainDataPage(); -}; - -#endif // ANTPLUS_FECFEEMAINDATAPAGE_h From 43ee94c00190f7f64b29db129786f2bab3187a05 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Fri, 28 Jan 2022 20:30:23 -0800 Subject: [PATCH 210/241] fec: refactor general settings update more fields, update example and add defines --- .../FecBikeTrainerDisplay.ino | 34 ++++++--- src/Profiles/Fec/ANTPLUS_FecDataPages.h | 2 +- src/Profiles/Fec/ANTPLUS_FecDefines.h | 18 +++-- .../ANTPLUS_FecGeneralSettingsDataPage.cpp | 60 --------------- .../ANTPLUS_FecGeneralSettingsDataPage.h | 29 -------- .../ANTPLUS_FecGeneralSettingsPage.cpp | 73 +++++++++++++++++++ .../ANTPLUS_FecGeneralSettingsPage.h | 35 +++++++++ .../Profiles/ANTPLUS_FecProfileDisplay.cpp | 12 +-- .../Fec/Profiles/ANTPLUS_FecProfileDisplay.h | 8 +- 9 files changed, 156 insertions(+), 115 deletions(-) delete mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.cpp delete mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.h create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsPage.cpp create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsPage.h diff --git a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino index b82f69b..c603077 100644 --- a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino +++ b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino @@ -23,7 +23,7 @@ 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(FecGeneralSettingsDataPage& 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); @@ -106,7 +106,6 @@ void loop() { } } - void manufacturerInformationDataPageHandler(ManufacturersInformation& msg, uintptr_t data) { Serial.print("Manufacturer ID: "); Serial.println(msg.getManufacturerID()); @@ -180,13 +179,30 @@ void GeneralDataPageHandler(FecGeneralFeData& msg, uintptr_t data) { printLapToggleBit(msg.getLapToggleBit()); } -void GeneralSettingsDataPageHandler(FecGeneralSettingsDataPage& msg, uintptr_t data) { +void GeneralSettingsDataPageHandler(FecGeneralSettingsPage& msg, uintptr_t data) { + uint8_t cycle_length = msg.getCycleLength(); Serial.print("Cycle length: "); - Serial.println(msg.getCycleLength()); - Serial.print("Incline value:" ); - Serial.println(msg.getInclineValue()); - Serial.print("Resistance level:"); - Serial.println(msg.getResistanceLevel()); + 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 printFeState(uint8_t fe_state) { @@ -226,7 +242,7 @@ void fecBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data) { } void TargetPowerDataPagehandler(FecTargetPowerDataPage& msg, uintptr_t data){ - Serial.print("Target POWER: "); + Serial.print("Target Power: "); Serial.println(msg.getTargetPower()); } diff --git a/src/Profiles/Fec/ANTPLUS_FecDataPages.h b/src/Profiles/Fec/ANTPLUS_FecDataPages.h index f5f7c9f..4315d10 100644 --- a/src/Profiles/Fec/ANTPLUS_FecDataPages.h +++ b/src/Profiles/Fec/ANTPLUS_FecDataPages.h @@ -2,7 +2,7 @@ #define ANTPLUS_PROFILEFECDATAPAGES_h #include -#include +#include #include #include #include diff --git a/src/Profiles/Fec/ANTPLUS_FecDefines.h b/src/Profiles/Fec/ANTPLUS_FecDefines.h index cfb8861..e2ebdda 100644 --- a/src/Profiles/Fec/ANTPLUS_FecDefines.h +++ b/src/Profiles/Fec/ANTPLUS_FecDefines.h @@ -4,6 +4,12 @@ #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 + #define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_GENERAL 16 #define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_TREADMILL 19 #define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_FETYPE_ELLIPTICAL 20 @@ -26,12 +32,12 @@ #define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_VIRTUALSPEEDFLAG_VIRTUALSPEED 1 -#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 - #define ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_MAXIMUM_RESISTANCE_INVALID 0xFFFF +#define ANTPLUS_FEC_DATAPAGE_GENERALSETTINGSPAGE_CYCLELENGTH_INVALID 0xFF + +#define ANTPLUS_FEC_DATAPAGE_GENERALSETTINGSPAGE_INCLINE_INVALID 0x7FFF + +#define ANTPLUS_FEC_DATAPAGE_GENERALSETTINGSPAGE_RESISTANCELEVEL_INVALID 0xFF + #endif // ANTPLUS_FECPROFILEDEFINES_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.cpp deleted file mode 100644 index abd5d2f..0000000 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include -#include - -// TODO this is a mixture of datapages -#define CYCLE_LENGTH_BYTE 3 -#define INCLINE_LSB_BYTE 4 -#define INCLINE_MSB_BYTE 5 -#define RESISTANTCE_LEVEL_BYTE 6 -#define CAPABILITIESBITFIELD_BYTE 7 -#define CAPABILITIESBITFIELD_MASK 0x0F -#define FESTATEBITFIELD_BYTE 7 -#define FESTATEBITFIELD_MASK 0xF0 -#define FESTATEBITFIELD_SHIFT 4 - -template -FecBaseGeneralSettingsDataPage::FecBaseGeneralSettingsDataPage() : - CoreDataPage() {} - -template -uint8_t FecBaseGeneralSettingsDataPage::getCycleLength() { - return this->get8BitValue(CYCLE_LENGTH_BYTE); -} - -template -uint8_t FecBaseGeneralSettingsDataPage::getInclineValue() { - return this->get16BitValue(INCLINE_MSB_BYTE, INCLINE_LSB_BYTE); -} - -template -uint8_t FecBaseGeneralSettingsDataPage::getResistanceLevel() { - return this->get8BitValue(RESISTANTCE_LEVEL_BYTE); -} - -template -uint8_t FecBaseGeneralSettingsDataPage::getCapabilitiesBits() { - return this->get8BitValue(CAPABILITIESBITFIELD_BYTE, - CAPABILITIESBITFIELD_MASK); -} - -template -uint8_t FecBaseGeneralSettingsDataPage::getFEStateBits() { - return this->get8BitValue(FESTATEBITFIELD_BYTE, FESTATEBITFIELD_MASK, - FESTATEBITFIELD_SHIFT); -} - -template class FecBaseGeneralSettingsDataPage; -template class FecBaseGeneralSettingsDataPage; - -FecGeneralSettingsDataPage::FecGeneralSettingsDataPage(AntRxDataResponse& dp) : - FecBaseMainDataPage(dp), - FecBaseGeneralSettingsDataPage() {} - -FecGeneralSettingsDataMsg::FecGeneralSettingsDataMsg() : - FecBaseMainDataPageMsg(GENERAL_SETTINGS_PAGE_NUMBER), - FecBaseGeneralSettingsDataPage() {} - -void FecGeneralSettingsDataMsg::setResistanceLevel(uint8_t ResistanceLevel) { - set8BitValue(ResistanceLevel, RESISTANTCE_LEVEL_BYTE); -} diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.h deleted file mode 100644 index 7644a55..0000000 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsDataPage.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef ANTPLUS_FECGENERALSEETTINGSDATAPAGE_h -#define ANTPLUS_FECGENERALSEETTINGSDATAPAGE_h - -#include - -template -class FecBaseGeneralSettingsDataPage : virtual public CoreDataPage { -public: - FecBaseGeneralSettingsDataPage(); - uint8_t getCycleLength(); - uint8_t getInclineValue(); - uint8_t getResistanceLevel(); - uint8_t getCapabilitiesBits(); - uint8_t getFEStateBits(); -}; - -class FecGeneralSettingsDataPage : public FecBaseMainDataPage, public FecBaseGeneralSettingsDataPage { -public: - explicit FecGeneralSettingsDataPage(AntRxDataResponse& dp); -}; - -class FecGeneralSettingsDataMsg : public FecBaseMainDataPageMsg, public FecBaseGeneralSettingsDataPage { -public: - FecGeneralSettingsDataMsg(); - void setResistanceLevel(uint8_t ResistanceLevel); -}; - - -#endif // ANTPLUS_FECGENERALSETTINGSDATAPAGE_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..200e8e3 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsPage.cpp @@ -0,0 +1,73 @@ +#include +#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_MSB_BYTE, INCLINE_LSB_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(GENERAL_SETTINGS_PAGE_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..1aaeb55 --- /dev/null +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsPage.h @@ -0,0 +1,35 @@ +#ifndef ANTPLUS_FECGENERALSEETTINGSDATAPAGE_h +#define ANTPLUS_FECGENERALSEETTINGSDATAPAGE_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_FECGENERALSETTINGSDATAPAGE_h diff --git a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp index 45e6353..4b43d21 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp @@ -34,11 +34,11 @@ bool ProfileFecDisplay::handleDataPage(BaseDataPage& dp) { break; case GENERAL_FE_DATA_NUMBER: - called = handleGeneralDataPage(dp); + called = handleGeneralFeData(dp); break; case GENERAL_SETTINGS_PAGE_NUMBER: - called = handleGeneralSettingsDataPage(dp); + called = handleGeneralSettingsPage(dp); break; case TARGET_POWER_NUMBER: @@ -78,14 +78,14 @@ bool ProfileFecDisplay::handleProductInformation(BaseDataPage& da return _onProductInformation.call(dp); } -bool ProfileFecDisplay::handleGeneralDataPage(BaseDataPage& dataPage) { +bool ProfileFecDisplay::handleGeneralFeData(BaseDataPage& dataPage) { FecGeneralFeData dp(dataPage); return _onFecGeneralFeData.call(dp); } -bool ProfileFecDisplay::handleGeneralSettingsDataPage(BaseDataPage& dataPage) { - FecGeneralSettingsDataPage dp(dataPage); - return _onFecGeneralSettingsDataPage.call(dp); +bool ProfileFecDisplay::handleGeneralSettingsPage(BaseDataPage& dataPage) { + FecGeneralSettingsPage dp(dataPage); + return _onFecGeneralSettingsPage.call(dp); } bool ProfileFecDisplay::handleTargetPowerDataPage(BaseDataPage& dataPage) { FecTargetPowerDataPage dp(dataPage); diff --git a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h index 576b568..d26d91a 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h @@ -12,7 +12,7 @@ class ProfileFecDisplay : public BaseSlaveProfile { 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 onFecGeneralSettingsDataPage(void (*func)(FecGeneralSettingsDataPage&, uintptr_t), uintptr_t data = 0) { _onFecGeneralSettingsDataPage.set(func, data); } + void onFecGeneralSettingsPage(void (*func)(FecGeneralSettingsPage&, uintptr_t), uintptr_t data = 0) { _onFecGeneralSettingsPage.set(func, data); } void onFecTargetPowerDataPage(void (*func)(FecTargetPowerDataPage&, uintptr_t), uintptr_t data = 0) { _onFecTargetPowerDataPage.set(func, data); } void onFecTrackResistanceDataPage(void (*func)(FecTrackResistanceDataPage&, uintptr_t), uintptr_t data = 0) { _onFecTrackResistanceDataPage.set(func, data); } void onFecFeCapabilities(void (*func)(FecFeCapabilities&, uintptr_t), uintptr_t data = 0) { _onFecFeCapabilities.set(func, data); } @@ -31,8 +31,8 @@ class ProfileFecDisplay : public BaseSlaveProfile { bool handleDataPage(BaseDataPage& dp); bool handleManufacturerInformation(BaseDataPage& dataPage); bool handleProductInformation(BaseDataPage& dataPage); - bool handleGeneralDataPage(BaseDataPage& dataPage); - bool handleGeneralSettingsDataPage(BaseDataPage& dataPage); + bool handleGeneralFeData(BaseDataPage& dataPage); + bool handleGeneralSettingsPage(BaseDataPage& dataPage); bool handleTrainerData(BaseDataPage& dataPage); bool handleTargetPowerDataPage(BaseDataPage& dataPage); bool handleTrackResistanceDataPage(BaseDataPage& dataPage); @@ -43,7 +43,7 @@ class ProfileFecDisplay : public BaseSlaveProfile { AntCallback _onManufacturersInformation = { .func = NULL }; AntCallback _onProductInformation = { .func = NULL }; AntCallback _onFecGeneralFeData = { .func = NULL }; - AntCallback _onFecGeneralSettingsDataPage = { .func = NULL }; + AntCallback _onFecGeneralSettingsPage = { .func = NULL }; AntCallback _onFecTargetPowerDataPage = { .func = NULL }; AntCallback _onFecTrackResistanceDataPage = { .func = NULL }; AntCallback _onFecFeCapabilities = { .func = NULL }; From efec0ffa5b7b1a7bec92ce126d7381431455287f Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Fri, 28 Jan 2022 21:32:32 -0800 Subject: [PATCH 211/241] fec: expand specific trainer data --- .../FecBikeTrainerDisplay.ino | 64 +++++++++++++++++-- src/Profiles/Fec/ANTPLUS_FecDefines.h | 12 ++++ .../ANTPLUS_FecSpecificTrainerData.cpp | 61 +++++++++++++----- .../ANTPLUS_FecSpecificTrainerData.h | 11 +++- 4 files changed, 123 insertions(+), 25 deletions(-) diff --git a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino index c603077..426f5f9 100644 --- a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino +++ b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino @@ -252,15 +252,65 @@ void TrackResistanceDataPageHandler(FecTrackResistanceDataPage& msg, uintptr_t d } void SpecificTrainerDataPageHandler(FecSpecificTrainerData& msg, uintptr_t data){ - Serial.print("Trainer status: "); - Serial.println(msg.getTrainerStatusBits()); - if ( msg.getTrainerStatusBits() == 4 ) + 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.println("Accumulated Power: "); + Serial.print(msg.getAccumulatedPower()); + Serial.println("Instantaneous Power: "); + Serial.print(power); + } + Serial.print("Bicycle Power Calibration: "); + if (msg.getBicyclePowerCalibration()) { - fec.transmitFecUserConfigurationMsg(9000, 3000); - Serial.println("Envoi des informations utilisateurs :"); + Serial.println("Required"); + } else { + Serial.println("Complete/Not Required"); } - Serial.print("Trainer flag bit: "); - Serial.println(msg.getFlagsBits()); + 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"); + fec.transmitFecUserConfigurationMsg(9000, 3000); + } 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) { diff --git a/src/Profiles/Fec/ANTPLUS_FecDefines.h b/src/Profiles/Fec/ANTPLUS_FecDefines.h index e2ebdda..1de9e4a 100644 --- a/src/Profiles/Fec/ANTPLUS_FecDefines.h +++ b/src/Profiles/Fec/ANTPLUS_FecDefines.h @@ -32,12 +32,24 @@ #define ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_VIRTUALSPEEDFLAG_VIRTUALSPEED 1 + #define ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_MAXIMUM_RESISTANCE_INVALID 0xFFFF + #define ANTPLUS_FEC_DATAPAGE_GENERALSETTINGSPAGE_CYCLELENGTH_INVALID 0xFF #define ANTPLUS_FEC_DATAPAGE_GENERALSETTINGSPAGE_INCLINE_INVALID 0x7FFF #define ANTPLUS_FEC_DATAPAGE_GENERALSETTINGSPAGE_RESISTANCELEVEL_INVALID 0xFF + +#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 + #endif // ANTPLUS_FECPROFILEDEFINES_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp index 55e8f7f..c498c07 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp @@ -2,15 +2,24 @@ #include #include -// TODO correct names #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 TRAINERSTATUS_BYTE 6 -#define FLAGSFESTATEBIT_BYTE 7 +#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() : @@ -27,30 +36,52 @@ uint8_t FecBaseSpecificTrainerData::getInstantaneousCadence() { } template -uint8_t FecBaseSpecificTrainerData::getFlagsBits() { - return this->get8BitValue(FLAGSFESTATEBIT_BYTE) & 0x0F; +uint16_t FecBaseSpecificTrainerData::getAccumulatedPower() { + return this->get16BitValue(ACCUMULATEDPOWER_LSB_BYTE, + ACCUMULATEDPOWER_MSB_BYTE); } template -uint8_t FecBaseSpecificTrainerData::getFEStateBits() { - return (this->get8BitValue(FLAGSFESTATEBIT_BYTE) & 0xF0) >> 4; +uint16_t FecBaseSpecificTrainerData::getInstantaneousPower() { + return this->get16BitValue(INSTANTANEOUSPOWER_LSB_BYTE, + INSTANTANEOUSPOWER_MSB_BYTE, + INSTANTANEOUSPOWER_MSB_MASK); } template -uint16_t FecBaseSpecificTrainerData::getAccumulatedPower() { - return this->get16BitValue(ACCUMULATEDPOWER_LSB_BYTE, - ACCUMULATEDPOWER_MSB_BYTE); +uint8_t FecBaseSpecificTrainerData::getBicyclePowerCalibration() { + return this->get8BitValue(BICYCLEPOWERCALIBRATION_BYTE, + BICYCLEPOWERCALIBRATION_MASK, + BICYCLEPOWERCALIBRATION_SHIFT); } template -uint16_t FecBaseSpecificTrainerData::getInstantaneousPower() { - return this->get16BitValue(INSTANTANEOUSPOWER_LSB_BYTE, - INSTANTANEOUSPOWER_MSB_BYTE) & 0x0FFF; +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::getTrainerStatusBits() { - return (this->get8BitValue(TRAINERSTATUS_BYTE) & 0xF0) >> 4; +uint8_t FecBaseSpecificTrainerData::getLapToggleBit() { + return this->get8BitValue(LAPTOGGLEBIT_BYTE, LAPTOGGLEBIT_MASK, LAPTOGGLEBIT_SHIFT); } template class FecBaseSpecificTrainerData; diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.h index 70da738..4f48cf3 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.h +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.h @@ -11,9 +11,12 @@ class FecBaseSpecificTrainerData : virtual public CoreDataPage { uint8_t getInstantaneousCadence(); uint16_t getAccumulatedPower(); uint16_t getInstantaneousPower(); - uint8_t getTrainerStatusBits(); - uint8_t getFlagsBits(); - uint8_t getFEStateBits(); + uint8_t getBicyclePowerCalibration(); + uint8_t getResistanceCalibration(); + uint8_t getUserConfiguration(); + uint8_t getTargetPowerLimits(); + uint8_t getFeState(); + uint8_t getLapToggleBit(); }; class FecSpecificTrainerData : public BaseDataPage, public FecBaseSpecificTrainerData { @@ -21,4 +24,6 @@ class FecSpecificTrainerData : public BaseDataPage, public FecBas explicit FecSpecificTrainerData(AntRxDataResponse& dp); }; +// TODO TX type + #endif // ANTPLUS_FECTRAINERDATA_h From 7b08677444c98a874338fa8bd808b8d1f7735aad Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 29 Jan 2022 12:12:41 -0800 Subject: [PATCH 212/241] router: constify removeProfile parameter cppcheck mentioned it --- src/MainClasses/ANTPLUS_AntPlusRouter.cpp | 2 +- src/MainClasses/ANTPLUS_AntPlusRouter.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MainClasses/ANTPLUS_AntPlusRouter.cpp b/src/MainClasses/ANTPLUS_AntPlusRouter.cpp index 2245fac..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); diff --git a/src/MainClasses/ANTPLUS_AntPlusRouter.h b/src/MainClasses/ANTPLUS_AntPlusRouter.h index c77469a..3021da5 100644 --- a/src/MainClasses/ANTPLUS_AntPlusRouter.h +++ b/src/MainClasses/ANTPLUS_AntPlusRouter.h @@ -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 From fde4230409dd10d0e6e4b19034bf78a4abb00074 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 29 Jan 2022 16:13:07 -0800 Subject: [PATCH 213/241] fec: final refactor part * removed transmits * updated multiple pages * added missing fields * moved page numbers to public * fixed example --- .../FecBikeTrainerDisplay.ino | 37 ++++------ src/Profiles/Fec/ANTPLUS_FecDataPages.h | 4 +- src/Profiles/Fec/ANTPLUS_FecDefines.h | 41 ++++++++++ src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h | 10 --- .../DataPages/ANTPLUS_FecBasicResistance.cpp | 14 +++- .../DataPages/ANTPLUS_FecFeCapabilities.cpp | 8 +- .../DataPages/ANTPLUS_FecGeneralFeData.cpp | 3 +- .../Fec/DataPages/ANTPLUS_FecGeneralFeData.h | 6 +- .../ANTPLUS_FecGeneralSettingsPage.cpp | 3 +- .../ANTPLUS_FecGeneralSettingsPage.h | 7 +- .../ANTPLUS_FecSpecificTrainerData.cpp | 1 - .../Fec/DataPages/ANTPLUS_FecTargetPower.cpp | 37 ++++++++++ .../Fec/DataPages/ANTPLUS_FecTargetPower.h | 26 +++++++ .../ANTPLUS_FecTargetPowerDataPage.cpp | 29 -------- .../ANTPLUS_FecTargetPowerDataPage.h | 26 ------- .../DataPages/ANTPLUS_FecTrackResistance.cpp | 46 ++++++++++++ .../DataPages/ANTPLUS_FecTrackResistance.h | 28 +++++++ .../ANTPLUS_FecTrackResistanceDataPage.cpp | 31 -------- .../ANTPLUS_FecTrackResistanceDataPage.h | 26 ------- .../ANTPLUS_FecUserConfiguration.cpp | 74 +++++++++++++++---- .../DataPages/ANTPLUS_FecUserConfiguration.h | 14 ++-- .../Profiles/ANTPLUS_FecProfileDisplay.cpp | 63 ++++------------ .../Fec/Profiles/ANTPLUS_FecProfileDisplay.h | 27 ++----- 23 files changed, 309 insertions(+), 252 deletions(-) create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPower.cpp create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPower.h delete mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.cpp delete mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.h create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistance.cpp create mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistance.h delete mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.cpp delete mode 100644 src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.h diff --git a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino index 426f5f9..a64f507 100644 --- a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino +++ b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino @@ -27,9 +27,6 @@ void GeneralSettingsDataPageHandler(FecGeneralSettingsPage& msg, uintptr_t data) void SpecificTrainerDataPageHandler(FecSpecificTrainerData& msg, uintptr_t data); void FeCapabitiliesDataPageHandler(FecFeCapabilities& msg, uintptr_t data); -void TargetPowerDataPagehandler(FecTargetPowerDataPage& msg, uintptr_t data); -void TrackREsistanceDataPageHandler(FecTrackResistanceDataPage& msg, uintptr_t data); - unsigned long previousMillis = 0; const unsigned long interval = 4000; int TargetPower = 50; @@ -54,8 +51,6 @@ void setup() { fec.onProductInformation(productInformationDataPageHandler); fec.onFecGeneralFeData(GeneralDataPageHandler); //fec.onFecGeneralSettingsDataPage(GeneralSettingsDataPageHandler); - fec.onFecTargetPowerDataPage(TargetPowerDataPagehandler); - fec.onFecTrackResistanceDataPage(TrackResistanceDataPageHandler); fec.onFecTrainerData(SpecificTrainerDataPageHandler); fec.onFecFeCapabilities(FeCapabitiliesDataPageHandler); @@ -70,11 +65,16 @@ void setup() { Serial.print("Transmisison Type: "); Serial.println(fec.getTransmissionType()); Serial.print("settings user information"); - fec.transmitFecUserConfigurationMsg(9000, 3000); + FecUserConfigurationMsg uc; + uc.setUserWeight(9000); + uc.setBicycleWeight(3000); + fec.send(uc); // get fec capabilities - // TODO transmit request datapage asking for capabilities - Serial.print("Ask for capacity"); // this datapage not always sent by indoor bike trainer - + 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() { @@ -101,7 +101,9 @@ void loop() { }else{ TargetPower = 100; } - fec.transmitFecTargetPowerMsg(TargetPower); + FecTargetPowerMsg tp; + tp.setTargetPower(TargetPower); + fec.send(tp); Serial.println(TargetPower); } } @@ -241,16 +243,6 @@ void fecBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data) { Serial.println(dp.getDataPageNumber()); } -void TargetPowerDataPagehandler(FecTargetPowerDataPage& msg, uintptr_t data){ - Serial.print("Target Power: "); - Serial.println(msg.getTargetPower()); -} - -void TrackResistanceDataPageHandler(FecTrackResistanceDataPage& msg, uintptr_t data){ - Serial.print("Track Resistance: "); - Serial.println(msg.getGrade()); -} - void SpecificTrainerDataPageHandler(FecSpecificTrainerData& msg, uintptr_t data){ Serial.print("Update Event Count: "); Serial.println(msg.getUpdateEventCount()); @@ -289,7 +281,10 @@ void SpecificTrainerDataPageHandler(FecSpecificTrainerData& msg, uintptr_t data) if (msg.getUserConfiguration()) { Serial.println("Required"); - fec.transmitFecUserConfigurationMsg(9000, 3000); + FecUserConfigurationMsg uc; + uc.setUserWeight(9000); + uc.setBicycleWeight(3000); + fec.send(uc); } else { Serial.println("Complete/Not Required"); } diff --git a/src/Profiles/Fec/ANTPLUS_FecDataPages.h b/src/Profiles/Fec/ANTPLUS_FecDataPages.h index 4315d10..29abb1c 100644 --- a/src/Profiles/Fec/ANTPLUS_FecDataPages.h +++ b/src/Profiles/Fec/ANTPLUS_FecDataPages.h @@ -5,8 +5,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/src/Profiles/Fec/ANTPLUS_FecDefines.h b/src/Profiles/Fec/ANTPLUS_FecDefines.h index 1de9e4a..b541d91 100644 --- a/src/Profiles/Fec/ANTPLUS_FecDefines.h +++ b/src/Profiles/Fec/ANTPLUS_FecDefines.h @@ -10,6 +10,10 @@ #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 @@ -32,10 +36,15 @@ #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 @@ -43,6 +52,9 @@ #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 @@ -52,4 +64,33 @@ #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 index 158f143..420f0ee 100644 --- a/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h +++ b/src/Profiles/Fec/ANTPLUS_FecPrivateDefines.h @@ -9,16 +9,6 @@ // 30 / 2.5 = 12 #define ANTPLUS_FEC_SEARCHTIMEOUT 12 -/* DataPages number */ -#define GENERAL_FE_DATA_NUMBER 16 -#define GENERAL_SETTINGS_PAGE_NUMBER 17 -#define SPECIFIC_TRAINER_DATA_NUMBER 25 -#define BASIC_RESISTANCE_NUMBER 48 -#define TARGET_POWER_NUMBER 49 -#define TRACK_RESISTANCE_NUMBER 51 -#define FE_CAPABILITIES_NUMBER 54 -#define USER_CONFIGURATION_NUMBER 55 - // Field common to some base messages #define FESTATE_BYTE 7 #define FESTATE_MASK 0x70 diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistance.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistance.cpp index a2ef273..6faa4b9 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistance.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecBasicResistance.cpp @@ -1,6 +1,12 @@ #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 @@ -20,9 +26,11 @@ FecBasicResistance::FecBasicResistance(AntRxDataResponse& dp) : FecBaseBasicResistance() {} FecBasicResistanceMsg::FecBasicResistanceMsg() : - FecBaseMainDataPageMsg(BASIC_RESISTANCE_NUMBER), - FecBaseBasicResistance() {} - // TODO reserved fields + 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_FecFeCapabilities.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.cpp index f5062d3..65d1a46 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecFeCapabilities.cpp @@ -11,8 +11,8 @@ #define SIMULATIONMODESUPPORT_BYTE 7 #define SIMULATIONMODESUPPORT_MASK 0x4 #define SIMULATIONMODESUPPORT_SHIFT 2 -#define RESERVED_LSB 1 -#define RESERVED_MSB 4 +#define RESERVED_LSB_BYTE 1 +#define RESERVED_MSB_BYTE 4 #define RESERVED_VALUE 0xFFFFFFFF template @@ -51,9 +51,9 @@ FecFeCapabilities::FecFeCapabilities(AntRxDataResponse& dp) : FecBaseFeCapabilities() {} FecFeCapabilitiesMsg::FecFeCapabilitiesMsg() : - FecBaseMainDataPageMsg(FE_CAPABILITIES_NUMBER), + FecBaseMainDataPageMsg(ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_NUMBER), FecBaseFeCapabilities() { - this->set32BitValue(RESERVED_VALUE, RESERVED_LSB, RESERVED_MSB); + this->set32BitValue(RESERVED_VALUE, RESERVED_LSB_BYTE, RESERVED_MSB_BYTE); setMaximumResistance(ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_MAXIMUM_RESISTANCE_INVALID); } diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.cpp index 32bebcc..4f0e690 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.cpp @@ -1,6 +1,5 @@ #include #include -#include #define FETYPE_BYTE 1 #define FETYPE_MASK 0x0F @@ -83,7 +82,7 @@ FecGeneralFeData::FecGeneralFeData(AntRxDataResponse& dp) : FecBaseGeneralFeData() {} FecGeneralFeDataMsg::FecGeneralFeDataMsg() : - FecBaseMainDataPageMsg(GENERAL_FE_DATA_NUMBER), + FecBaseMainDataPageMsg(ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_NUMBER), FecBaseGeneralFeData() { setSpeed(ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_SPEED_INVALID); setHeartRate(ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_HEARTRATE_INVALID); diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.h index 77d8282..a700668 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.h +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.h @@ -1,5 +1,5 @@ -#ifndef ANTPLUS_FECGENERALMAINDATAPAGE_h -#define ANTPLUS_FECGENERALMAINDATAPAGE_h +#ifndef ANTPLUS_FECGENERALFEDATA_h +#define ANTPLUS_FECGENERALFEDATA_h #include @@ -40,4 +40,4 @@ class FecGeneralFeDataMsg : public FecBaseMainDataPageMsg, public FecBaseGeneral }; -#endif // ANTPLUS_FECGENERALMAINDATAPAGE_h +#endif // ANTPLUS_FECGENERALFEDATA_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsPage.cpp index 200e8e3..ab73b00 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsPage.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsPage.cpp @@ -1,6 +1,5 @@ #include #include -#include #define CYCLE_LENGTH_BYTE 3 #define INCLINE_LSB_BYTE 4 @@ -44,7 +43,7 @@ FecGeneralSettingsPage::FecGeneralSettingsPage(AntRxDataResponse& dp) : FecBaseGeneralSettingsPage() {} FecGeneralSettingsPageMsg::FecGeneralSettingsPageMsg() : - FecBaseMainDataPageMsg(GENERAL_SETTINGS_PAGE_NUMBER), + FecBaseMainDataPageMsg(ANTPLUS_FEC_DATAPAGE_GENERALSETTINGSPAGE_NUMBER), FecBaseGeneralSettingsPage() { setCycleLength(ANTPLUS_FEC_DATAPAGE_GENERALSETTINGSPAGE_CYCLELENGTH_INVALID); setIncline(ANTPLUS_FEC_DATAPAGE_GENERALSETTINGSPAGE_INCLINE_INVALID); diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsPage.h index 1aaeb55..71ff4da 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsPage.h +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsPage.h @@ -1,5 +1,5 @@ -#ifndef ANTPLUS_FECGENERALSEETTINGSDATAPAGE_h -#define ANTPLUS_FECGENERALSEETTINGSDATAPAGE_h +#ifndef ANTPLUS_FECGENERALSEETTINGSPAGE_h +#define ANTPLUS_FECGENERALSEETTINGSPAGE_h #include @@ -31,5 +31,4 @@ class FecGeneralSettingsPageMsg : public FecBaseMainDataPageMsg, public FecBaseG void setLapToggleBit(uint8_t toggle); }; - -#endif // ANTPLUS_FECGENERALSETTINGSDATAPAGE_h +#endif // ANTPLUS_FECGENERALSETTINGSPAGE_h diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp index c498c07..a7d8772 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp @@ -1,6 +1,5 @@ #include #include -#include #define UPDATEEVENTCOUNT_BYTE 1 #define INSTANTANEOUSCADENCE_BYTE 2 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_FecTargetPowerDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.cpp deleted file mode 100644 index fb46189..0000000 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -#define TARGET_POWER_LSB_BYTE 6 -#define TARGET_POWER_MSB_BYTE 7 - -template -FecBaseTargetPowerDataPage::FecBaseTargetPowerDataPage() : - CoreDataPage() {} - -template -uint16_t FecBaseTargetPowerDataPage::getTargetPower() { - return this->get16BitValue(TARGET_POWER_LSB_BYTE, TARGET_POWER_MSB_BYTE); -} - -template class FecBaseTargetPowerDataPage; -template class FecBaseTargetPowerDataPage; - -FecTargetPowerDataPage::FecTargetPowerDataPage(AntRxDataResponse& dp) : - FecBaseMainDataPage(dp), - FecBaseTargetPowerDataPage() {} - -FecTargetPowerDataMsg::FecTargetPowerDataMsg() : - FecBaseMainDataPageMsg(TARGET_POWER_NUMBER), - FecBaseTargetPowerDataPage() {} - -void FecTargetPowerDataMsg::setTargetPower(uint16_t TargetPower) { - set16BitValue(TargetPower, TARGET_POWER_LSB_BYTE, TARGET_POWER_MSB_BYTE); -} diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.h deleted file mode 100644 index 2d0e61f..0000000 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecTargetPowerDataPage.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef ANTPLUS_FECTARGETPOWERDATAPAGE_h -#define ANTPLUS_FECTARGETPOWERDATAPAGE_h - -#include - -template -class FecBaseTargetPowerDataPage : virtual public CoreDataPage { -public: - FecBaseTargetPowerDataPage(); - uint16_t getTargetPower(); -}; - -class FecTargetPowerDataPage : public FecBaseMainDataPage, public FecBaseTargetPowerDataPage { -public: - explicit FecTargetPowerDataPage(AntRxDataResponse& dp); -}; - -class FecTargetPowerDataMsg : public FecBaseMainDataPageMsg, public FecBaseTargetPowerDataPage { -public: - FecTargetPowerDataMsg(); - void setTargetPower(uint16_t TargetPower); -}; - - -#endif // ANTPLUS_FECTARGETPOWERDATAPAGE_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_FecTrackResistanceDataPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.cpp deleted file mode 100644 index 9e87ac7..0000000 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include -#include - -// TODO this is a mixture of datapages -#define GRADE_LSB_BYTE 5 -#define GRADE_MSB_BYTE 6 - -template -FecBaseTrackResistanceDataPage::FecBaseTrackResistanceDataPage() : - CoreDataPage() {} - -template -uint16_t FecBaseTrackResistanceDataPage::getGrade() { - return this->get16BitValue(GRADE_LSB_BYTE, GRADE_MSB_BYTE); -} - -template class FecBaseTrackResistanceDataPage; -template class FecBaseTrackResistanceDataPage; - -FecTrackResistanceDataPage::FecTrackResistanceDataPage(AntRxDataResponse& dp) : - FecBaseMainDataPage(dp), - FecBaseTrackResistanceDataPage() {} - -FecTrackResistanceDataMsg::FecTrackResistanceDataMsg() : - FecBaseMainDataPageMsg(TRACK_RESISTANCE_NUMBER), - FecBaseTrackResistanceDataPage() {} - -void FecTrackResistanceDataMsg::setTargetGrade(uint16_t TargetGrade) { - set16BitValue(TargetGrade, GRADE_LSB_BYTE, GRADE_MSB_BYTE); -} diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.h b/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.h deleted file mode 100644 index 8fb6fb6..0000000 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecTrackResistanceDataPage.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef ANTPLUS_FECTRACKRESISTANCEDATAPAGE_h -#define ANTPLUS_FECTRACKRESISTANCEDATAPAGE_h - -#include - -template -class FecBaseTrackResistanceDataPage : virtual public CoreDataPage { -public: - FecBaseTrackResistanceDataPage(); - uint16_t getGrade(); -}; - -class FecTrackResistanceDataPage : public FecBaseMainDataPage, public FecBaseTrackResistanceDataPage { -public: - explicit FecTrackResistanceDataPage(AntRxDataResponse& dp); -}; - -class FecTrackResistanceDataMsg : public FecBaseMainDataPageMsg, public FecBaseTrackResistanceDataPage { -public: - FecTrackResistanceDataMsg(); - void setTargetGrade(uint16_t TargetGrade); -}; - - -#endif // ANTPLUS_FECTRACKRESISTANCEDATAPAGE_h - diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecUserConfiguration.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecUserConfiguration.cpp index f5d5255..da4bbab 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecUserConfiguration.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecUserConfiguration.cpp @@ -1,10 +1,18 @@ #include #include -#define USER_WEIGHT_LSB_BYTE 1 -#define USER_WEIGHT_MSB_BYTE 2 -#define BICYCLE_WEIGHT_LSB_BYTE 4 -#define BICYCLE_WEIGHT_MSB_BYTE 5 +#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() : @@ -12,12 +20,30 @@ FecBaseUserConfiguration::FecBaseUserConfiguration() : template uint16_t FecBaseUserConfiguration::getUserWeight() { - return this->get16BitValue(USER_WEIGHT_LSB_BYTE, USER_WEIGHT_MSB_BYTE); + return this->get16BitValue(USERWEIGHT_LSB_BYTE, USERWEIGHT_MSB_BYTE); } template -uint16_t FecBaseUserConfiguration::getBikeWeight() { - return this->get16BitValue(BICYCLE_WEIGHT_LSB_BYTE, BICYCLE_WEIGHT_MSB_BYTE); +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; @@ -28,14 +54,36 @@ FecUserConfiguration::FecUserConfiguration(AntRxDataResponse& dp) : FecBaseUserConfiguration() {} FecUserConfigurationMsg::FecUserConfigurationMsg() : - FecBaseMainDataPageMsg(USER_CONFIGURATION_NUMBER), - FecBaseUserConfiguration() {} + 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, USER_WEIGHT_LSB_BYTE, USER_WEIGHT_MSB_BYTE); +void FecUserConfigurationMsg::setUserWeight(uint16_t userWeight) { + set16BitValue(userWeight, USERWEIGHT_LSB_BYTE, USERWEIGHT_MSB_BYTE); } -void FecUserConfigurationMsg::setBikeWeight(uint16_t BikeWeight) { - set16BitValue(BikeWeight, BICYCLE_WEIGHT_LSB_BYTE, BICYCLE_WEIGHT_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 index be7ffae..0b06493 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecUserConfiguration.h +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecUserConfiguration.h @@ -3,14 +3,15 @@ #include -// TODO missing fields - template class FecBaseUserConfiguration : virtual public CoreDataPage { public: FecBaseUserConfiguration(); uint16_t getUserWeight(); - uint16_t getBikeWeight(); + uint8_t getBicycleWheelDiameterOffset(); + uint16_t getBicycleWeight(); + uint8_t getBicycleWheelDiameter(); + uint8_t getGearRatio(); }; class FecUserConfiguration : public FecBaseMainDataPage, public FecBaseUserConfiguration { @@ -21,8 +22,11 @@ class FecUserConfiguration : public FecBaseMainDataPage, public FecBaseUserConfi class FecUserConfigurationMsg : public FecBaseMainDataPageMsg, public FecBaseUserConfiguration { public: FecUserConfigurationMsg(); - void setUserWeight(uint16_t UserWeight); - void setBikeWeight(uint16_t BikeWeight); + 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 index 4b43d21..b2dae55 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp @@ -9,19 +9,19 @@ ProfileFecDisplay::ProfileFecDisplay(uint16_t deviceNumber, uint8_t transmission } void ProfileFecDisplay::onBroadcastData(BroadcastData& msg) { - BaseDataPage dp = BaseDataPage(msg); + FecBaseMainDataPage dp(msg); BaseSlaveProfile::onBroadcastData(msg); if (!handleDataPage(dp)) { callOnOtherDataPage(msg); } } -bool ProfileFecDisplay::handleDataPage(BaseDataPage& dp) { +bool ProfileFecDisplay::handleDataPage(FecBaseMainDataPage& dp) { uint8_t dataPage = dp.getDataPageNumber(); bool called = false; switch (dataPage) { - case SPECIFIC_TRAINER_DATA_NUMBER: + case ANTPLUS_FEC_DATAPAGE_SPECIFICTRAINERDATA_NUMBER: called = handleTrainerData(dp); break; @@ -33,19 +33,15 @@ bool ProfileFecDisplay::handleDataPage(BaseDataPage& dp) { called = handleProductInformation(dp); break; - case GENERAL_FE_DATA_NUMBER: + case ANTPLUS_FEC_DATAPAGE_GENERALFEDATA_NUMBER: called = handleGeneralFeData(dp); break; - case GENERAL_SETTINGS_PAGE_NUMBER: + case ANTPLUS_FEC_DATAPAGE_GENERALSETTINGSPAGE_NUMBER: called = handleGeneralSettingsPage(dp); break; - case TARGET_POWER_NUMBER: - called = handleTargetPowerDataPage(dp); - break; - - case FE_CAPABILITIES_NUMBER: + case ANTPLUS_FEC_DATAPAGE_FECAPABILITIES_NUMBER: called = handleFeCapabilities(dp); break; } @@ -54,7 +50,7 @@ bool ProfileFecDisplay::handleDataPage(BaseDataPage& dp) { } void ProfileFecDisplay::onAcknowledgedData(AcknowledgedData& msg) { - BaseDataPage dp = BaseDataPage(msg); + FecBaseMainDataPage dp = FecBaseMainDataPage(msg); BaseSlaveProfile::onAcknowledgedData(msg); if (!handleDataPage(dp)) { callOnOtherDataPage(msg); @@ -68,65 +64,32 @@ void ProfileFecDisplay::setChannelConfig() { setSearchTimeout(ANTPLUS_FEC_SEARCHTIMEOUT); } -bool ProfileFecDisplay::handleManufacturerInformation(BaseDataPage& dataPage) { +bool ProfileFecDisplay::handleManufacturerInformation(FecBaseMainDataPage& dataPage) { ManufacturersInformation dp(dataPage); return _onManufacturersInformation.call(dp); } -bool ProfileFecDisplay::handleProductInformation(BaseDataPage& dataPage) { +bool ProfileFecDisplay::handleProductInformation(FecBaseMainDataPage& dataPage) { ProductInformation dp(dataPage); return _onProductInformation.call(dp); } -bool ProfileFecDisplay::handleGeneralFeData(BaseDataPage& dataPage) { +bool ProfileFecDisplay::handleGeneralFeData(FecBaseMainDataPage& dataPage) { FecGeneralFeData dp(dataPage); return _onFecGeneralFeData.call(dp); } -bool ProfileFecDisplay::handleGeneralSettingsPage(BaseDataPage& dataPage) { +bool ProfileFecDisplay::handleGeneralSettingsPage(FecBaseMainDataPage& dataPage) { FecGeneralSettingsPage dp(dataPage); return _onFecGeneralSettingsPage.call(dp); } -bool ProfileFecDisplay::handleTargetPowerDataPage(BaseDataPage& dataPage) { - FecTargetPowerDataPage dp(dataPage); - return _onFecTargetPowerDataPage.call(dp); -} -bool ProfileFecDisplay::handleFeCapabilities(BaseDataPage& dataPage) { +bool ProfileFecDisplay::handleFeCapabilities(FecBaseMainDataPage& dataPage) { FecFeCapabilities dp(dataPage); return _onFecFeCapabilities.call(dp); } -bool ProfileFecDisplay::transmitFecTargetPowerMsg(uint16_t TargetPower) { - FecTargetPowerDataMsg msg; - msg.setTargetPower(TargetPower); - send(msg); - return false; -} - -bool ProfileFecDisplay::transmitFecTrackResistanceMsg(uint16_t TargetGrade) { - FecTrackResistanceDataMsg msg; - msg.setTargetGrade(TargetGrade); - send(msg); - return false; -} - -bool ProfileFecDisplay::transmitFecBasicResistanceMsg(uint8_t total_resistance) { - FecBasicResistanceMsg msg; - msg.setTotalResistance(total_resistance); - send(msg); - return false; -} - -bool ProfileFecDisplay::transmitFecUserConfigurationMsg(uint16_t UserWeight, uint16_t BikeWeight) { - FecUserConfigurationMsg msg; - msg.setUserWeight(UserWeight); - msg.setBikeWeight(BikeWeight); - send(msg); - return true; -} - -bool ProfileFecDisplay::handleTrainerData(BaseDataPage& dataPage) { +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 index d26d91a..267421a 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.h @@ -13,39 +13,26 @@ class ProfileFecDisplay : public BaseSlaveProfile { 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 onFecTargetPowerDataPage(void (*func)(FecTargetPowerDataPage&, uintptr_t), uintptr_t data = 0) { _onFecTargetPowerDataPage.set(func, data); } - void onFecTrackResistanceDataPage(void (*func)(FecTrackResistanceDataPage&, uintptr_t), uintptr_t data = 0) { _onFecTrackResistanceDataPage.set(func, data); } void onFecFeCapabilities(void (*func)(FecFeCapabilities&, uintptr_t), uintptr_t data = 0) { _onFecFeCapabilities.set(func, data); } - bool transmitFecTargetPowerMsg(uint16_t TargetPower); - bool transmitFecTrackResistanceMsg(uint16_t TrackResistance); - bool transmitFecBasicResistanceMsg(uint8_t total_resistance); - bool transmitFecUserConfigurationMsg(uint16_t UserWeight, uint16_t BikeWeight); - // TODO delete these - // TODO also move data page numbers to public, otherwise requests don't work private: void setChannelConfig(); void onBroadcastData(BroadcastData& msg) override; void onAcknowledgedData(AcknowledgedData& msg) override; - bool handleDataPage(BaseDataPage& dp); - bool handleManufacturerInformation(BaseDataPage& dataPage); - bool handleProductInformation(BaseDataPage& dataPage); - bool handleGeneralFeData(BaseDataPage& dataPage); - bool handleGeneralSettingsPage(BaseDataPage& dataPage); - bool handleTrainerData(BaseDataPage& dataPage); - bool handleTargetPowerDataPage(BaseDataPage& dataPage); - bool handleTrackResistanceDataPage(BaseDataPage& dataPage); - bool handleFeCapabilities(BaseDataPage& dataPage); - // TODO update to base main dp + 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 _onFecTargetPowerDataPage = { .func = NULL }; - AntCallback _onFecTrackResistanceDataPage = { .func = NULL }; AntCallback _onFecFeCapabilities = { .func = NULL }; }; From a11eb36131de1ef8bdb4cff9cc68a4bfcf1e2624 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 29 Jan 2022 16:25:30 -0800 Subject: [PATCH 214/241] commont datapages: fix request page field mismatch --- src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp | 4 ++-- src/CommonDataPages/ANTPLUS_RequestDataPage.cpp | 4 ++-- src/CommonDataPages/ANTPLUS_RequestDataPage.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp b/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp index b87da1d..8ee8045 100644 --- a/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp +++ b/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp @@ -31,9 +31,9 @@ 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 } diff --git a/src/CommonDataPages/ANTPLUS_RequestDataPage.cpp b/src/CommonDataPages/ANTPLUS_RequestDataPage.cpp index 84f9fc7..7658dcb 100644 --- a/src/CommonDataPages/ANTPLUS_RequestDataPage.cpp +++ b/src/CommonDataPages/ANTPLUS_RequestDataPage.cpp @@ -36,14 +36,14 @@ uint8_t BaseRequestDataPage::getDescriptorByte2() { } template -uint8_t BaseRequestDataPage::getRequestedPageCount() { +uint8_t BaseRequestDataPage::getRequestedTransmissionResponseCount() { return this->get8BitValue( REQUESTEDTRANSMISSIONRESPONSE_BYTE, REQUESTEDTRANSMISSIONRESPONSE_COUNT_MASK); } template -uint8_t BaseRequestDataPage::getUseAcknowledgedMsgs() { +uint8_t BaseRequestDataPage::getRequestedTransmissionUseAcknowledged() { return this->get8BitValue( REQUESTEDTRANSMISSIONRESPONSE_BYTE, REQUESTEDTRANSMISSIONRESPONSE_USEACKNOWLEDGED_MASK, diff --git a/src/CommonDataPages/ANTPLUS_RequestDataPage.h b/src/CommonDataPages/ANTPLUS_RequestDataPage.h index bdae33d..d42a970 100644 --- a/src/CommonDataPages/ANTPLUS_RequestDataPage.h +++ b/src/CommonDataPages/ANTPLUS_RequestDataPage.h @@ -13,8 +13,8 @@ class BaseRequestDataPage : virtual public CoreDataPage { uint16_t getSlaveSerialNumber(); uint8_t getDescriptorByte1(); uint8_t getDescriptorByte2(); - uint8_t getRequestedPageCount(); - uint8_t getUseAcknowledgedMsgs(); + uint8_t getRequestedTransmissionResponseCount(); + uint8_t getRequestedTransmissionUseAcknowledged(); uint8_t transmitTillAcknowledged(); uint8_t getRequestedPageNumber(); uint8_t getCommandType(); From 3ed7458b49186c8e405be6108a42757a4b107ae6 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 30 Jan 2022 13:24:41 -0800 Subject: [PATCH 215/241] examples: fec: fix function order c/cpp being cpp --- .../FecBikeTrainerDisplay.ino | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino index a64f507..8650539 100644 --- a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino +++ b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino @@ -108,6 +108,35 @@ void loop() { } } +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()); @@ -207,35 +236,6 @@ void GeneralSettingsDataPageHandler(FecGeneralSettingsPage& msg, uintptr_t data) printLapToggleBit(msg.getLapToggleBit()); } -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 fecBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data) { FecBaseMainDataPage dp = FecBaseMainDataPage(msg); Serial.println("==========================="); From 18d662ca24c1ba638e997e4905aa7c52575c894c Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 30 Jan 2022 13:38:16 -0800 Subject: [PATCH 216/241] fec: fix equipment type bitfield off by one bit --- src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.cpp index 4f0e690..78f88f4 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralFeData.cpp @@ -2,7 +2,7 @@ #include #define FETYPE_BYTE 1 -#define FETYPE_MASK 0x0F +#define FETYPE_MASK 0x1F #define ELAPSEDTIME_BYTE 2 #define DISTANCETRAVELED_BYTE 3 #define SPEED_LSB_BYTE 4 From ae89b84819c90972d81853f779bcdca0e240c619 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 30 Jan 2022 14:12:09 -0800 Subject: [PATCH 217/241] examples: fec: add missing prints also fix some formatting errors and remove debug prints --- .../FecBikeTrainerDisplay.ino | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino index 8650539..132c361 100644 --- a/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino +++ b/examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino @@ -50,7 +50,7 @@ void setup() { fec.onManufacturersInformation(manufacturerInformationDataPageHandler); fec.onProductInformation(productInformationDataPageHandler); fec.onFecGeneralFeData(GeneralDataPageHandler); - //fec.onFecGeneralSettingsDataPage(GeneralSettingsDataPageHandler); + fec.onFecGeneralSettingsPage(GeneralSettingsDataPageHandler); fec.onFecTrainerData(SpecificTrainerDataPageHandler); fec.onFecFeCapabilities(FeCapabitiliesDataPageHandler); @@ -104,12 +104,11 @@ void loop() { FecTargetPowerMsg tp; tp.setTargetPower(TargetPower); fec.send(tp); - Serial.println(TargetPower); } } void printFeState(uint8_t fe_state) { - Serial.print("FE State:"); + Serial.print("FE State: "); switch (fe_state) { case ANTPLUS_FEC_DATAPAGE_FESTATE_RESERVED: Serial.println("Reserved"); @@ -205,7 +204,26 @@ void GeneralDataPageHandler(FecGeneralFeData& msg, uintptr_t data) { } 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()); } @@ -258,10 +276,10 @@ void SpecificTrainerDataPageHandler(FecSpecificTrainerData& msg, uintptr_t data) Serial.println("Accumulated Power: Invalid"); Serial.println("Instantaneous Power: Invalid"); } else { - Serial.println("Accumulated Power: "); - Serial.print(msg.getAccumulatedPower()); - Serial.println("Instantaneous Power: "); - Serial.print(power); + Serial.print("Accumulated Power: "); + Serial.println(msg.getAccumulatedPower()); + Serial.print("Instantaneous Power: "); + Serial.println(power); } Serial.print("Bicycle Power Calibration: "); if (msg.getBicyclePowerCalibration()) @@ -311,7 +329,7 @@ void SpecificTrainerDataPageHandler(FecSpecificTrainerData& msg, uintptr_t data) void FeCapabitiliesDataPageHandler(FecFeCapabilities& msg, uintptr_t data) { Serial.print("Max resistance: "); Serial.println(msg.getMaximumResistance()); - Serial.print("Fec Capabilities: "); + Serial.println("Fec Capabilities: "); Serial.print(" Supports Basic Resistance Mode: "); Serial.println(msg.getBasicResistanceModeSupport() ? "Y" : "N"); Serial.print(" Supports Target Power Mode: "); From 67c9b51a247adec4e754fd5bfaa3b5ee9dc775c3 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 30 Jan 2022 14:12:37 -0800 Subject: [PATCH 218/241] fec: fix incline lookup byte order is reversed --- src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsPage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsPage.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsPage.cpp index ab73b00..5d21b12 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsPage.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecGeneralSettingsPage.cpp @@ -17,7 +17,7 @@ uint8_t FecBaseGeneralSettingsPage::getCycleLength() { template uint16_t FecBaseGeneralSettingsPage::getIncline() { - return this->get16BitValue(INCLINE_MSB_BYTE, INCLINE_LSB_BYTE); + return this->get16BitValue(INCLINE_LSB_BYTE, INCLINE_MSB_BYTE); } template From a848de7b7d2f8e291bb6221bbda69b6bd8e904d9 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Mon, 31 Jan 2022 09:15:40 -0800 Subject: [PATCH 219/241] BicyclePower: fix standard power only page Fixup missing fields in both messages --- .../ANTPLUS_BicyclePowerStandardPowerOnly.cpp | 39 ++++++++++++++++--- .../ANTPLUS_BicyclePowerStandardPowerOnly.h | 9 ++++- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp index 372fae1..9fd59e4 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp @@ -5,6 +5,10 @@ #define UPDATEEVENTCOUNT_BYTE 1 #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 @@ -15,9 +19,21 @@ template BicyclePowerBaseStandardPowerOnly::BicyclePowerBaseStandardPowerOnly() : CoreDataPage() {} +template +uint8_t BicyclePowerBaseStandardPowerOnly::getUpdateEventCount() { + return this->get8BitValue(UPDATEEVENTCOUNT_BYTE); +} + template uint8_t BicyclePowerBaseStandardPowerOnly::getPedalPower() { - return this->get8BitValue(PEDALPOWER_BYTE); + return this->get8BitValue(PEDALPOWER_BYTE, PEDALPOWER_MASK); +} + +template +uint8_t BicyclePowerBaseStandardPowerOnly::getPedalDifferentiation() { + return this->get8BitValue(PEDALDIFFERENTIATION_BYTE, + PEDALDIFFERENTIATION_MASK, + PEDALDIFFERENTIATION_SHIFT); } template @@ -52,13 +68,24 @@ BicyclePowerStandardPowerOnlyMsg::BicyclePowerStandardPowerOnlyMsg() : } void BicyclePowerStandardPowerOnlyMsg::setUpdateEventCount(uint8_t eventCount) { - this->set8BitValue(eventCount, UPDATEEVENTCOUNT_BYTE); + set8BitValue(eventCount, UPDATEEVENTCOUNT_BYTE); +} + +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::setCumulativePowerCount(uint16_t accPower) { - this->set16BitValue(accPower, ACCUMULATEDPOWER_LSB_BYTE, ACCUMULATEDPOWER_MSB_BYTE); +void BicyclePowerStandardPowerOnlyMsg::setAccumulatedPower(uint16_t accPower) { + set16BitValue(accPower, ACCUMULATEDPOWER_LSB_BYTE, ACCUMULATEDPOWER_MSB_BYTE); } -void BicyclePowerStandardPowerOnlyMsg::setInstantaneousPowerCount(uint16_t power) { - this->set16BitValue(power, INSTANTANEOUSPOWER_LSB_BYTE, INSTANTANEOUSPOWER_MSB_BYTE); +void BicyclePowerStandardPowerOnlyMsg::setInstantaneousPowerCount(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 index 8cf843a..eaa8a3e 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.h +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.h @@ -7,7 +7,9 @@ template class BicyclePowerBaseStandardPowerOnly : virtual public CoreDataPage { public: BicyclePowerBaseStandardPowerOnly(); + uint8_t getUpdateEventCount(); uint8_t getPedalPower(); + uint8_t getPedalDifferentiation(); uint8_t getInstantaneousCadence(); uint16_t getAccumulatedPower(); uint16_t getInstantaneousPower(); @@ -22,8 +24,11 @@ class BicyclePowerStandardPowerOnlyMsg : public BicyclePowerBaseMainDataPageMsg, public: BicyclePowerStandardPowerOnlyMsg(void); void setUpdateEventCount(uint8_t eventCount); - void setCumulativePowerCount(uint16_t accPower); - void setInstantaneousPowerCount(uint16_t power); + void setPedalPower(uint8_t pedalPower); + void setPedalDifferentiation(uint8_t differentiation); + void setInstantaneousCadence(uint8_t cadence); + void setAccumulatedPower(uint16_t accPower); + void setInstantaneousPowerCount(uint16_t instantaneousPower); }; #endif // ANTPLUS_BICYCLEPOWERSTANDARDPOWERONLY_h From 6e8bbccf09cd748dfe05ffdb81a045be100398af Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 1 Feb 2022 20:36:25 -0800 Subject: [PATCH 220/241] BicyclePower: update datapages and example fixup some duplicate fields and naming, also add invalid value checks to example while also setting fields to invalid on initialization --- .../BicyclePowerDisplay.ino | 45 +++++++++++++++---- .../BicyclePowerSensor/BicyclePowerSensor.ino | 4 +- .../ANTPLUS_BicyclePowerDefines.h | 34 +++++++++++++- .../ANTPLUS_BicyclePowerPrivateDefines.h | 7 --- .../ANTPLUS_BicyclePowerBaseMainDataPage.cpp | 8 +++- .../ANTPLUS_BicyclePowerBaseMainDataPage.h | 1 + ...TPLUS_BicyclePowerCrankTorqueFrequency.cpp | 2 +- ...NTPLUS_BicyclePowerStandardCrankTorque.cpp | 6 ++- .../ANTPLUS_BicyclePowerStandardPowerOnly.cpp | 23 ++++------ .../ANTPLUS_BicyclePowerStandardPowerOnly.h | 4 +- ...NTPLUS_BicyclePowerStandardWheelTorque.cpp | 6 ++- .../ANTPLUS_BicyclePowerStandardWheelTorque.h | 4 +- ...rTorqueEffectivenessAndPedalSmoothness.cpp | 9 +++- .../ANTPLUS_ProfileBicyclePowerDisplay.cpp | 10 ++--- .../ANTPLUS_ProfileBicyclePowerSensor.cpp | 35 ++++++++------- 15 files changed, 129 insertions(+), 69 deletions(-) diff --git a/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino index 3e0b629..2135c77 100644 --- a/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino +++ b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino @@ -99,6 +99,14 @@ void loop() { router.loop(); } +void printOrInvalid(uint8_t value, uint8_t invalidValue) { + if (value == invalidValue) { + Serial.println("Invalid"); + } else { + Serial.println(value); + } +} + void batteryStatusDataPageHandler(BatteryStatus& msg, uintptr_t data) { Serial.print("Fractional Battery Voltage: "); Serial.println(msg.getFractionalBatteryVoltage()); @@ -135,10 +143,17 @@ void bicyclePowerBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data) { void powerOnlyDataPageHandler(BicyclePowerStandardPowerOnly& msg, uintptr_t data) { Serial.print("Pedal Power: "); - if (msg.getPedalPower() == ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_PEDALPOWER_NOTUSED) { + 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) { @@ -156,7 +171,8 @@ void crankTorqueDataPageHandler(BicyclePowerStandardCrankTorque& msg, uintptr_t Serial.print("Crank Ticks: "); Serial.println(msg.getCrankTicks()); Serial.print("Instantaneous Cadence: "); - Serial.println(msg.getInstantaneousCadence()); + printOrInvalid(msg.getInstantaneousCadence(), + ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDCRANKTORQUE_INSTANTANEOUSCADENCE_INVALID); Serial.print("Crank Period: "); Serial.println(msg.getCrankPeriod()); Serial.print("Accumulated Torque: "); @@ -167,7 +183,8 @@ void wheelTorqueDataPageHandler(BicyclePowerStandardWheelTorque& msg, uintptr_t Serial.print("Wheel Ticks: "); Serial.println(msg.getWheelTicks()); Serial.print("Instantaneous Cadence: "); - Serial.println(msg.getInstantaneousCadence()); + printOrInvalid(msg.getInstantaneousCadence(), + ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDWHEELTORQUE_INSTANTANEOUSCADENCE_INVALID); Serial.print("Wheel Period: "); Serial.println(msg.getWheelPeriod()); Serial.print("Accumulated Torque: "); @@ -176,13 +193,23 @@ void wheelTorqueDataPageHandler(BicyclePowerStandardWheelTorque& msg, uintptr_t void pedalSmoothnessDataPageHandler(BicyclePowerTorqueEffectivenessAndPedalSmoothness& msg, uintptr_t data) { Serial.print("Left Torque Effectiveness: "); - Serial.println(msg.getLeftTorqueEffectiveness()); + printOrInvalid(msg.getLeftTorqueEffectiveness(), + ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_TORQUEEFFECTIVENESS_INVALID); Serial.print("Right Torque Effectiveness: "); - Serial.println(msg.getRightTorqueEffectiveness()); - Serial.print("Left Pedal Smoothness: "); - Serial.println(msg.getLeftPedalSmoothness()); - Serial.print("Right Pedal Smoothness: "); - Serial.println(msg.getRightPedalSmoothness()); + 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) { diff --git a/examples/BicyclePowerSensor/BicyclePowerSensor.ino b/examples/BicyclePowerSensor/BicyclePowerSensor.ino index 70d4334..b19e10d 100644 --- a/examples/BicyclePowerSensor/BicyclePowerSensor.ino +++ b/examples/BicyclePowerSensor/BicyclePowerSensor.ino @@ -114,8 +114,8 @@ void powerOnlyDataPageHandler(BicyclePowerStandardPowerOnlyMsg& msg, uintptr_t d printDpMsg(16, "Power Only"); msg.setUpdateEventCount(eventCount++); - msg.setCumulativePowerCount(eventCount * 3); - msg.setInstantaneousPowerCount(eventCount * 2); + msg.setAccumulatedPower(eventCount * 3); + msg.setInstantaneousPower(eventCount * 2); } void crankTorqueDataPageHandler(BicyclePowerStandardCrankTorqueMsg& msg, uintptr_t data) { diff --git a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h index d213af0..10426bd 100644 --- a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerDefines.h @@ -10,7 +10,39 @@ #define ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_CTF 3 /* DataPage Defines */ -#define ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_PEDALPOWER_NOTUSED 0xFF +#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 index 12edd45..eb82f8b 100644 --- a/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h +++ b/src/Profiles/BicyclePower/ANTPLUS_BicyclePowerPrivateDefines.h @@ -8,11 +8,4 @@ // 30 / 2.5 = 12 #define BICYCLEPOWER_SEARCHTIMEOUT 12 -#define BICYCLEPOWER_GENERALCALIBRATION_NUMBER 0x01 -#define BICYCLEPOWER_STANDARDPOWERONLY_NUMBER 0x10 -#define BICYCLEPOWER_STANDARDWHEELTORQUE_NUMBER 0x11 -#define BICYCLEPOWER_STANDARDCRANKTORQUE_NUMBER 0x12 -#define BICYCLEPOWER_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER 0x13 -#define BICYCLEPOWER_CRANKTORQUEFREQUENCY_NUMBER 0x20 - #endif // ANTPLUS_BICYCLEPOWERPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.cpp index 1477d28..a06dcb6 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.cpp @@ -9,11 +9,11 @@ BicyclePowerBaseMainDataPage::BicyclePowerBaseMainDataPage(AntRxDataResponse& dp BaseDataPage(dp) {} uint8_t BicyclePowerBaseMainDataPage::getDataPageNumber() { - return getData(ANTPLUS_DEFAULT_DATAPAGE_BYTE); + return this->get8BitValue(ANTPLUS_DEFAULT_DATAPAGE_BYTE); } uint8_t BicyclePowerBaseMainDataPage::getUpdateEventCount() { - return getData(UPDATEEVENTCOUNT_BYTE); + return this->get8BitValue(UPDATEEVENTCOUNT_BYTE); } BicyclePowerBaseMainDataPageMsg::BicyclePowerBaseMainDataPageMsg(uint8_t dataPageNumber) : @@ -21,3 +21,7 @@ BicyclePowerBaseMainDataPageMsg::BicyclePowerBaseMainDataPageMsg(uint8_t dataPag 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 index 848554c..a608dbc 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.h +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerBaseMainDataPage.h @@ -14,6 +14,7 @@ class BicyclePowerBaseMainDataPage : public BaseDataPage { class BicyclePowerBaseMainDataPageMsg : public BaseDataPageMsg { public: explicit BicyclePowerBaseMainDataPageMsg(uint8_t dataPageNumber); + void setUpdateEventCount(uint8_t eventCount); protected: uint8_t _buffer[MESSAGE_SIZE] = {0}; }; diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.cpp index 66c58ed..d5921ce 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerCrankTorqueFrequency.cpp @@ -36,7 +36,7 @@ BicyclePowerCrankTorqueFrequency::BicyclePowerCrankTorqueFrequency(AntRxDataResp BicyclePowerBaseCrankTorqueFrequency() {} BicyclePowerCrankTorqueFrequencyMsg::BicyclePowerCrankTorqueFrequencyMsg() : - BicyclePowerBaseMainDataPageMsg(BICYCLEPOWER_CRANKTORQUEFREQUENCY_NUMBER), + BicyclePowerBaseMainDataPageMsg(ANTPLUS_BICYCLEPOWER_DATAPAGES_CRANKTORQUEFREQUENCY_NUMBER), BicyclePowerBaseCrankTorqueFrequency() {} void BicyclePowerCrankTorqueFrequencyMsg::setSlope(uint16_t slope) { diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.cpp index f470408..c46ab86 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.cpp @@ -41,8 +41,10 @@ BicyclePowerStandardCrankTorque::BicyclePowerStandardCrankTorque(AntRxDataRespon BicyclePowerBaseStandardCrankTorque() {} BicyclePowerStandardCrankTorqueMsg::BicyclePowerStandardCrankTorqueMsg() : - BicyclePowerBaseMainDataPageMsg(BICYCLEPOWER_STANDARDCRANKTORQUE_NUMBER), - BicyclePowerBaseStandardCrankTorque() {} + BicyclePowerBaseMainDataPageMsg(ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDCRANKTORQUE_NUMBER), + BicyclePowerBaseStandardCrankTorque() { + setInstantaneousCadence(ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDCRANKTORQUE_INSTANTANEOUSCADENCE_INVALID); +} void BicyclePowerStandardCrankTorqueMsg::setCrankTicks(uint8_t ticks) { set8BitValue(ticks, CRANKTICKS_BYTE); diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp index 9fd59e4..f458b84 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.cpp @@ -3,7 +3,6 @@ #include #include -#define UPDATEEVENTCOUNT_BYTE 1 #define PEDALPOWER_BYTE 2 #define PEDALPOWER_MASK 0x7F #define PEDALDIFFERENTIATION_BYTE 2 @@ -19,11 +18,6 @@ template BicyclePowerBaseStandardPowerOnly::BicyclePowerBaseStandardPowerOnly() : CoreDataPage() {} -template -uint8_t BicyclePowerBaseStandardPowerOnly::getUpdateEventCount() { - return this->get8BitValue(UPDATEEVENTCOUNT_BYTE); -} - template uint8_t BicyclePowerBaseStandardPowerOnly::getPedalPower() { return this->get8BitValue(PEDALPOWER_BYTE, PEDALPOWER_MASK); @@ -61,14 +55,11 @@ BicyclePowerStandardPowerOnly::BicyclePowerStandardPowerOnly(AntRxDataResponse& BicyclePowerBaseStandardPowerOnly() {} BicyclePowerStandardPowerOnlyMsg::BicyclePowerStandardPowerOnlyMsg() : - BicyclePowerBaseMainDataPageMsg(BICYCLEPOWER_STANDARDPOWERONLY_NUMBER), + BicyclePowerBaseMainDataPageMsg(ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_NUMBER), BicyclePowerBaseStandardPowerOnly() { - this->set8BitValue(ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_PEDALPOWER_NOTUSED, PEDALPOWER_BYTE); - this->set8BitValue(ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_INSTANTANEOUSCADENCE_INVALID, INSTANTANEOUSCADENCE_BYTE); -} - -void BicyclePowerStandardPowerOnlyMsg::setUpdateEventCount(uint8_t eventCount) { - set8BitValue(eventCount, UPDATEEVENTCOUNT_BYTE); + 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) { @@ -82,10 +73,14 @@ void BicyclePowerStandardPowerOnlyMsg::setPedalDifferentiation(uint8_t different 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::setInstantaneousPowerCount(uint16_t instantaneousPower) { +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 index eaa8a3e..a401189 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.h +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardPowerOnly.h @@ -7,7 +7,6 @@ template class BicyclePowerBaseStandardPowerOnly : virtual public CoreDataPage { public: BicyclePowerBaseStandardPowerOnly(); - uint8_t getUpdateEventCount(); uint8_t getPedalPower(); uint8_t getPedalDifferentiation(); uint8_t getInstantaneousCadence(); @@ -23,12 +22,11 @@ class BicyclePowerStandardPowerOnly : public BicyclePowerBaseMainDataPage, publi class BicyclePowerStandardPowerOnlyMsg : public BicyclePowerBaseMainDataPageMsg, public BicyclePowerBaseStandardPowerOnly { public: BicyclePowerStandardPowerOnlyMsg(void); - void setUpdateEventCount(uint8_t eventCount); void setPedalPower(uint8_t pedalPower); void setPedalDifferentiation(uint8_t differentiation); void setInstantaneousCadence(uint8_t cadence); void setAccumulatedPower(uint16_t accPower); - void setInstantaneousPowerCount(uint16_t instantaneousPower); + 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 index 9ac7a61..54b0698 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.cpp @@ -41,8 +41,10 @@ BicyclePowerStandardWheelTorque::BicyclePowerStandardWheelTorque(AntRxDataRespon BicyclePowerBaseStandardWheelTorque() {} BicyclePowerStandardWheelTorqueMsg::BicyclePowerStandardWheelTorqueMsg() : - BicyclePowerBaseMainDataPageMsg(BICYCLEPOWER_STANDARDWHEELTORQUE_NUMBER), - BicyclePowerBaseStandardWheelTorque() {} + BicyclePowerBaseMainDataPageMsg(ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDWHEELTORQUE_NUMBER), + BicyclePowerBaseStandardWheelTorque() { + setInstantaneousCadence(ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDWHEELTORQUE_INSTANTANEOUSCADENCE_INVALID); +} void BicyclePowerStandardWheelTorqueMsg::setWheelTicks(uint8_t ticks) { set8BitValue(ticks, WHEELTICKS_BYTE); diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.h index 2c688ca..ab80491 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.h +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardWheelTorque.h @@ -8,7 +8,7 @@ class BicyclePowerBaseStandardWheelTorque : virtual public CoreDataPage { public: BicyclePowerBaseStandardWheelTorque(); uint8_t getWheelTicks(); - uint8_t getInstantaneousCadence(); // TODO(is valid check) May not be available, 0xFF indicates invalid + uint8_t getInstantaneousCadence(); uint16_t getWheelPeriod(); uint16_t getAccumulatedTorque(); }; @@ -26,7 +26,7 @@ class BicyclePowerStandardWheelTorqueMsg : public: BicyclePowerStandardWheelTorqueMsg(); void setWheelTicks(uint8_t ticks); - void setInstantaneousCadence(uint8_t cadence); // TODO(is valid check) May not be available, 0xFF indicates invalid + void setInstantaneousCadence(uint8_t cadence); void setWheelPeriod(uint16_t period); void setAccumulatedTorque(uint16_t torque); }; diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.cpp b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.cpp index 5c7609e..e656c6f 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.cpp +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerTorqueEffectivenessAndPedalSmoothness.cpp @@ -38,8 +38,13 @@ BicyclePowerTorqueEffectivenessAndPedalSmoothness::BicyclePowerTorqueEffectivene BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness() {} BicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg::BicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg() : - BicyclePowerBaseMainDataPageMsg(BICYCLEPOWER_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER), - BicyclePowerBaseTorqueEffectivenessAndPedalSmoothness() {} + 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); diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp index e6d61d6..74663b4 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp @@ -31,19 +31,19 @@ bool ProfileBicyclePowerDisplay::handleDataPage(BicyclePowerBaseMainDataPage& dp case COMMON_BATTERYSTATUS_NUMBER: called = handleBatteryStatus(dp); break; - case BICYCLEPOWER_STANDARDPOWERONLY_NUMBER: + case ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_NUMBER: called = handleStandardPowerOnly(dp); break; - case BICYCLEPOWER_STANDARDCRANKTORQUE_NUMBER: + case ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDCRANKTORQUE_NUMBER: called = handleStandardCrankTorque(dp); break; - case BICYCLEPOWER_STANDARDWHEELTORQUE_NUMBER: + case ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDWHEELTORQUE_NUMBER: called = handleStandardWheelTorque(dp); break; - case BICYCLEPOWER_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: + case ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: called = handleTorqueEffectivenessAndPedalSmoothness(dp); break; - case BICYCLEPOWER_CRANKTORQUEFREQUENCY_NUMBER: + case ANTPLUS_BICYCLEPOWER_DATAPAGES_CRANKTORQUEFREQUENCY_NUMBER: called = handleCrankTorqueFrequency(dp); break; } diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp index 41487a1..ecd0b2a 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -47,7 +47,7 @@ void ProfileBicyclePowerSensor::onAcknowledgedData(AcknowledgedData& msg) { case COMMON_REQUESTDATAPAGE_NUMBER: called = handleRequestDataPage(dp); break; - case BICYCLEPOWER_GENERALCALIBRATION_NUMBER: + case ANTPLUS_BICYCLEPOWER_DATAPAGES_GENERALCALIBRATION_NUMBER: called = handleGeneralCalibration(dp); break; } @@ -79,7 +79,7 @@ void ProfileBicyclePowerSensor::transmitNextDataPage() { page = getNextTorqueSensorPage(); break; case ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_CTF: - page = BICYCLEPOWER_CRANKTORQUEFREQUENCY_NUMBER; + page = ANTPLUS_BICYCLEPOWER_DATAPAGES_CRANKTORQUEFREQUENCY_NUMBER; break; } @@ -92,14 +92,14 @@ uint8_t ProfileBicyclePowerSensor::getNextPowerOnlySensorPage() { if ((mod_five == 0) && _createBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg.func) { /* Interleave every 5th message if implemented */ - return BICYCLEPOWER_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER; + return ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER; } backgroundPage = getBackgroundPage(); if (backgroundPage) { return backgroundPage; } - return BICYCLEPOWER_STANDARDPOWERONLY_NUMBER; + return ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_NUMBER; } uint8_t ProfileBicyclePowerSensor::getNextTorqueSensorPage() { @@ -108,10 +108,10 @@ uint8_t ProfileBicyclePowerSensor::getNextTorqueSensorPage() { if (mod_five == 0) { /* Interleave every 5th message */ - return BICYCLEPOWER_STANDARDPOWERONLY_NUMBER; + return ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_NUMBER; } else if ((mod_five == 1) && _createBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg.func) { /* Interleave every 5th message if implemented */ - return BICYCLEPOWER_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER; + return ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER; } backgroundPage = getBackgroundPage(); @@ -120,7 +120,8 @@ uint8_t ProfileBicyclePowerSensor::getNextTorqueSensorPage() { } return FLAGS_SENSORTYPE(_flags) == ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUECRANK ? - BICYCLEPOWER_STANDARDCRANKTORQUE_NUMBER : BICYCLEPOWER_STANDARDWHEELTORQUE_NUMBER; + ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDCRANKTORQUE_NUMBER : + ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDWHEELTORQUE_NUMBER; } @@ -224,19 +225,19 @@ uint8_t ProfileBicyclePowerSensor::getBackgroundPage() { void ProfileBicyclePowerSensor::transmitDataPage(uint8_t page) { switch (page) { // TODO calibration datapages - case BICYCLEPOWER_STANDARDPOWERONLY_NUMBER: + case ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_NUMBER: transmitBicyclePowerStandardPowerOnlyMsg(); break; - case BICYCLEPOWER_STANDARDWHEELTORQUE_NUMBER: + case ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDWHEELTORQUE_NUMBER: transmitBicyclePowerStandardWheelTorqueMsg(); break; - case BICYCLEPOWER_STANDARDCRANKTORQUE_NUMBER: + case ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDCRANKTORQUE_NUMBER: transmitBicyclePowerStandardCrankTorqueMsg(); break; - case BICYCLEPOWER_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: + case ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: transmitBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg(); break; - case BICYCLEPOWER_CRANKTORQUEFREQUENCY_NUMBER: + case ANTPLUS_BICYCLEPOWER_DATAPAGES_CRANKTORQUEFREQUENCY_NUMBER: transmitBicyclePowerCrankTorqueFrequencyMsg(); break; case COMMON_PRODUCTINFORMATION_NUMBER: @@ -261,16 +262,16 @@ void ProfileBicyclePowerSensor::setChannelConfig() { bool ProfileBicyclePowerSensor::isDataPageValid(uint8_t dataPage) { // TODO calibration data pages switch (dataPage) { - case BICYCLEPOWER_STANDARDPOWERONLY_NUMBER: + case ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_NUMBER: return FLAGS_SENSORTYPE(_flags) != ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_CTF; - case BICYCLEPOWER_STANDARDWHEELTORQUE_NUMBER: + case ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDWHEELTORQUE_NUMBER: return FLAGS_SENSORTYPE(_flags) == ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUEWHEEL; - case BICYCLEPOWER_STANDARDCRANKTORQUE_NUMBER: + case ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDCRANKTORQUE_NUMBER: return FLAGS_SENSORTYPE(_flags) == ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_TORQUECRANK; - case BICYCLEPOWER_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: + case ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_NUMBER: return FLAGS_SENSORTYPE(_flags) != ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_CTF && (bool)_createBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg.func; - case BICYCLEPOWER_CRANKTORQUEFREQUENCY_NUMBER: + case ANTPLUS_BICYCLEPOWER_DATAPAGES_CRANKTORQUEFREQUENCY_NUMBER: return FLAGS_SENSORTYPE(_flags) == ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_CTF; case COMMON_BATTERYSTATUS_NUMBER: return (bool)_createBatteryStatusMsg.func; From b6438d16ea853b2ef9359c078134684a882f857e Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 1 Feb 2022 23:42:43 -0800 Subject: [PATCH 221/241] Shifting: Move profile to new datapges format Refactor everything to less files and use local defines --- .../ANTPLUS_ProfileShiftingDataPages.h | 6 +- .../Shifting/ANTPLUS_ShiftingDefines.h | 3 + .../Shifting/ANTPLUS_ShiftingPrivateDefines.h | 3 - .../Shifting/ANTPLUS_ShiftingProfile.h | 2 +- ...p => ANTPLUS_ShiftingBaseMainDataPage.cpp} | 7 +- .../ANTPLUS_ShiftingBaseMainDataPage.h | 19 ++++ ... => ANTPLUS_ShiftingShiftSystemStatus.cpp} | 89 ++++++++++++++++++- .../ANTPLUS_ShiftingShiftSystemStatus.h | 44 +++++++++ .../ANTPLUS_ShiftingBaseMainDataPageMsg.h | 15 ---- .../ANTPLUS_ShiftingBaseShiftSystemStatus.cpp | 63 ------------- .../ANTPLUS_ShiftingBaseShiftSystemStatus.h | 25 ------ .../TX/ANTPLUS_ShiftingShiftSystemStatusMsg.h | 25 ------ .../Profiles/ANTPLUS_ProfileShiftingShifter.h | 2 +- 13 files changed, 157 insertions(+), 146 deletions(-) rename src/Profiles/Shifting/{DataPages => }/ANTPLUS_ProfileShiftingDataPages.h (55%) rename src/Profiles/Shifting/DataPages/{Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp => ANTPLUS_ShiftingBaseMainDataPage.cpp} (62%) create mode 100644 src/Profiles/Shifting/DataPages/ANTPLUS_ShiftingBaseMainDataPage.h rename src/Profiles/Shifting/DataPages/{TX/ANTPLUS_ShiftingShiftSystemStatusMsg.cpp => ANTPLUS_ShiftingShiftSystemStatus.cpp} (50%) create mode 100644 src/Profiles/Shifting/DataPages/ANTPLUS_ShiftingShiftSystemStatus.h delete mode 100644 src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h delete mode 100644 src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseShiftSystemStatus.cpp delete mode 100644 src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseShiftSystemStatus.h delete mode 100644 src/Profiles/Shifting/DataPages/TX/ANTPLUS_ShiftingShiftSystemStatusMsg.h diff --git a/src/Profiles/Shifting/DataPages/ANTPLUS_ProfileShiftingDataPages.h b/src/Profiles/Shifting/ANTPLUS_ProfileShiftingDataPages.h similarity index 55% rename from src/Profiles/Shifting/DataPages/ANTPLUS_ProfileShiftingDataPages.h rename to src/Profiles/Shifting/ANTPLUS_ProfileShiftingDataPages.h index 07bc2ab..c555bb2 100644 --- a/src/Profiles/Shifting/DataPages/ANTPLUS_ProfileShiftingDataPages.h +++ b/src/Profiles/Shifting/ANTPLUS_ProfileShiftingDataPages.h @@ -1,10 +1,6 @@ #ifndef ANTPLUS_PROFILESHIFTINGDATAPAGES_h #define ANTPLUS_PROFILESHIFTINGDATAPAGES_h -/* RX */ -// ... - -/* TX */ -#include +#include #endif // ANTPLUS_PROFILESHIFTINGDATAPAGES_h diff --git a/src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h b/src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h index 765ad43..aab6f43 100644 --- a/src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h +++ b/src/Profiles/Shifting/ANTPLUS_ShiftingDefines.h @@ -3,6 +3,9 @@ #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 diff --git a/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h b/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h index 67afbb7..d4be8db 100644 --- a/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h +++ b/src/Profiles/Shifting/ANTPLUS_ShiftingPrivateDefines.h @@ -10,7 +10,4 @@ #define ANTPLUS_SHIFTING_BACKGROUNDPAGE_INTERLEAVEINTERVAL 260 #define ANTPLUS_SHIFTING_NUMBERBACKGROUNDPAGES_PERCOMPONENT 3 -/* Pages */ -#define ANTPLUS_SHIFTING_DATAPAGE_SHIFTSYSTEMSTATUS_NUMBER 1 - #endif // ANTPLUS_SHIFTINGPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/Shifting/ANTPLUS_ShiftingProfile.h b/src/Profiles/Shifting/ANTPLUS_ShiftingProfile.h index a9a67f4..f1ef9db 100644 --- a/src/Profiles/Shifting/ANTPLUS_ShiftingProfile.h +++ b/src/Profiles/Shifting/ANTPLUS_ShiftingProfile.h @@ -5,7 +5,7 @@ #include // Datapages -#include +#include // Profile Classes #include diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp b/src/Profiles/Shifting/DataPages/ANTPLUS_ShiftingBaseMainDataPage.cpp similarity index 62% rename from src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp rename to src/Profiles/Shifting/DataPages/ANTPLUS_ShiftingBaseMainDataPage.cpp index 0f445d8..25168a2 100644 --- a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.cpp +++ b/src/Profiles/Shifting/DataPages/ANTPLUS_ShiftingBaseMainDataPage.cpp @@ -1,14 +1,13 @@ -#include +#include #include #include -#define RESERVED_BYTE 2 -#define RESERVED_VALUE 0xFF +ShiftingBaseMainDataPage::ShiftingBaseMainDataPage(AntRxDataResponse& dp) : + BaseDataPage(dp) {} ShiftingBaseMainDataPageMsg::ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber) : BaseDataPageMsg() { setDataBuffer(_buffer); set8BitValue(dataPageNumber, ANTPLUS_DEFAULT_DATAPAGE_BYTE); - set8BitValue(RESERVED_VALUE, RESERVED_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/TX/ANTPLUS_ShiftingShiftSystemStatusMsg.cpp b/src/Profiles/Shifting/DataPages/ANTPLUS_ShiftingShiftSystemStatus.cpp similarity index 50% rename from src/Profiles/Shifting/DataPages/TX/ANTPLUS_ShiftingShiftSystemStatusMsg.cpp rename to src/Profiles/Shifting/DataPages/ANTPLUS_ShiftingShiftSystemStatus.cpp index 5464cc4..0ca1808 100644 --- a/src/Profiles/Shifting/DataPages/TX/ANTPLUS_ShiftingShiftSystemStatusMsg.cpp +++ b/src/Profiles/Shifting/DataPages/ANTPLUS_ShiftingShiftSystemStatus.cpp @@ -1,7 +1,9 @@ -#include -#include +#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 @@ -20,14 +22,93 @@ #define INVALIDOUTBOARDSHIFTCOUNT_FRONT_BYTE 6 #define INVALIDOUTBOARDSHIFTCOUNT_FRONT_MASK 0xF0 #define INVALIDOUTBOARDSHIFTCOUNT_FRONT_SHIFT 4 -#define SHIFTFAILURECOUNT_BYTE 6 +#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() {} + ShiftingBaseShiftSystemStatus() { + set8BitValue(RESERVED_VALUE, RESERVED_BYTE); +} void ShiftingShiftSystemStatusMsg::setEventCount(uint8_t n) { set8BitValue(n, EVENTCOUNT_BYTE); 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/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h deleted file mode 100644 index c177413..0000000 --- a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseMainDataPageMsg.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef ANTPLUS_SHIFTINGBASEMAINDATAPAGEMSG_h -#define ANTPLUS_SHIFTINGBASEMAINDATAPAGEMSG_h - -#include - -#include "ANT.h" - -class ShiftingBaseMainDataPageMsg : public BaseDataPageMsg { -public: - explicit ShiftingBaseMainDataPageMsg(uint8_t dataPageNumber); -protected: - uint8_t _buffer[MESSAGE_SIZE] = {0}; -}; - -#endif // ANTPLUS_SHIFTINGBASEMAINDATAPAGEMSG_h diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseShiftSystemStatus.cpp b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseShiftSystemStatus.cpp deleted file mode 100644 index 38c529a..0000000 --- a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseShiftSystemStatus.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include -#include - -template -ShiftingBaseShiftSystemStatus::ShiftingBaseShiftSystemStatus() : CoreDataPage() { -} - -template -uint8_t ShiftingBaseShiftSystemStatus::getEventCount() { - return this->get8BitValue(1); -} - -template -uint8_t ShiftingBaseShiftSystemStatus::getCurrentGearRear() { - return this->get8BitValue(3, 0x1F); -} - -template -uint8_t ShiftingBaseShiftSystemStatus::getCurrentGearFront() { - return this->get8BitValue(3, 0xE0, 5); -} - -template -uint8_t ShiftingBaseShiftSystemStatus::getTotalNumbersGearRear() { - return this->get8BitValue(4, 0x1F); -} - -template -uint8_t ShiftingBaseShiftSystemStatus::getTotalNumbersGearFront() { - return this->get8BitValue(4, 0xE0, 5); -} - -template -uint8_t ShiftingBaseShiftSystemStatus::getInvalidInboardShiftCountRear() { - return this->get8BitValue(5, 0x0F); -} - -template -uint8_t ShiftingBaseShiftSystemStatus::getInvalidOutboardShiftCountRear() { - return this->get8BitValue(5, 0xF0, 4); -} - -template -uint8_t ShiftingBaseShiftSystemStatus::getInvalidInboardShiftCountFront() { - return this->get8BitValue(6, 0x0F); -} - -template -uint8_t ShiftingBaseShiftSystemStatus::getInvalidOutboardShiftCountFront() { - return this->get8BitValue(6, 0xF0, 4); -} - -template -uint8_t ShiftingBaseShiftSystemStatus::getShiftFailureCountRear() { - return this->get8BitValue(7, 0x0F); -} - -template -uint8_t ShiftingBaseShiftSystemStatus::getShiftFailureCountFront() { - return this->get8BitValue(7, 0xF0, 4); -} - -template class ShiftingBaseShiftSystemStatus; diff --git a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseShiftSystemStatus.h b/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseShiftSystemStatus.h deleted file mode 100644 index 8acd3db..0000000 --- a/src/Profiles/Shifting/DataPages/Base/ANTPLUS_ShiftingBaseShiftSystemStatus.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef ANTPLUS_SHIFTINGBASESHIFTSYSTEMSTATUS_h -#define ANTPLUS_SHIFTINGBASESHIFTSYSTEMSTATUS_h - -#include - -#include "ANT.h" - -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(); -}; - -#endif // ANTPLUS_SHIFTINGBASESHIFTSYSTEMSTATUS_h diff --git a/src/Profiles/Shifting/DataPages/TX/ANTPLUS_ShiftingShiftSystemStatusMsg.h b/src/Profiles/Shifting/DataPages/TX/ANTPLUS_ShiftingShiftSystemStatusMsg.h deleted file mode 100644 index d6cd7ab..0000000 --- a/src/Profiles/Shifting/DataPages/TX/ANTPLUS_ShiftingShiftSystemStatusMsg.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef ANTPLUS_SHIFTINGSHIFTSYSTEMSTATUSMSG_h -#define ANTPLUS_SHIFTINGSHIFTSYSTEMSTATUSMSG_h - -#include -#include - -#include "ANT.h" - -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_SHIFTINGSHIFTSYSTEMSTATUSMSG_h diff --git a/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.h b/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.h index 4daf6d5..0af25f3 100644 --- a/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.h +++ b/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.h @@ -2,7 +2,7 @@ #define ANTPLUS_PROFILESHIFTINGSHIFTER_h #include -#include +#include #include #include From be34742537b9c02439048064243b6eeab0799213 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Wed, 2 Feb 2022 00:25:44 -0800 Subject: [PATCH 222/241] Common: Make datapage numbers public This is needed for request datapages --- src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp | 4 +-- src/CommonDataPages/ANTPLUS_BatteryStatus.cpp | 4 +-- .../ANTPLUS_CommonDataPageDefines.h | 25 +++++++++++++++++++ .../ANTPLUS_CommonDataPagePrivateDefines.h | 12 --------- .../ANTPLUS_ManufacturersInformation.cpp | 4 +-- src/CommonDataPages/ANTPLUS_ModeSettings.cpp | 4 +-- ...omponentSystemManufacturersInformation.cpp | 4 +-- ...MultiComponentSystemProductInformation.cpp | 4 +-- .../ANTPLUS_ProductInformation.cpp | 11 ++++---- .../ANTPLUS_RequestDataPage.cpp | 3 +-- .../ANTPLUS_ProfileBicyclePowerDisplay.cpp | 8 +++--- .../ANTPLUS_ProfileBicyclePowerSensor.cpp | 22 ++++++++-------- .../ANTPLUS_ProfileBicycleSpeedDisplay.cpp | 2 -- .../ANTPLUS_ProfileEnvironmentDisplay.cpp | 6 ++--- .../Profiles/ANTPLUS_FecProfileDisplay.cpp | 6 ++--- .../ANTPLUS_ProfileHeartRateDisplay.cpp | 1 - .../ANTPLUS_ProfileHeartRateMonitor.cpp | 6 ++--- .../Profiles/ANTPLUS_ProfileLevDisplay.cpp | 6 ++--- .../ANTPLUS_ProfileMuscleOxygenMonitor.cpp | 9 ++++--- .../ANTPLUS_ProfileShiftingShifter.cpp | 16 ++++++------ 20 files changed, 84 insertions(+), 73 deletions(-) delete mode 100644 src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h diff --git a/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp b/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp index 8ee8045..6232b8a 100644 --- a/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp +++ b/src/BaseClasses/ANTPLUS_BaseMasterProfile.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include BaseMasterProfile::BaseMasterProfile(uint16_t deviceNumber, uint8_t transmissionType) : BaseProfile(deviceNumber, transmissionType) { @@ -20,7 +20,7 @@ void BaseMasterProfile::onAcknowledgedData(AcknowledgedData& msg) { BaseProfile::onAcknowledgedData(msg); BaseDataPage dp(msg); - if (dp.getDataPageNumber() == COMMON_REQUESTDATAPAGE_NUMBER) { + if (dp.getDataPageNumber() == ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER) { handleRequestDataPage(msg); } } diff --git a/src/CommonDataPages/ANTPLUS_BatteryStatus.cpp b/src/CommonDataPages/ANTPLUS_BatteryStatus.cpp index 9f66c7b..d7e1837 100644 --- a/src/CommonDataPages/ANTPLUS_BatteryStatus.cpp +++ b/src/CommonDataPages/ANTPLUS_BatteryStatus.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #define RESERVED_BYTE 1 @@ -77,7 +77,7 @@ BatteryStatusMsg::BatteryStatusMsg() : BaseDataPageMsg(), BaseBatteryStatus() { setDataBuffer(_buffer); - set8BitValue(COMMON_BATTERYSTATUS_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); + set8BitValue(ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); set8BitValue(RESERVED_VALUE, RESERVED_BYTE); } diff --git a/src/CommonDataPages/ANTPLUS_CommonDataPageDefines.h b/src/CommonDataPages/ANTPLUS_CommonDataPageDefines.h index 164d065..146cf59 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,12 +18,35 @@ #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 diff --git a/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h b/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h deleted file mode 100644 index 79315d4..0000000 --- a/src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ANTPLUS_COMMONDATAPAGEPRIVATEDEFINES_h -#define ANTPLUS_COMMONDATAPAGEPRIVATEDEFINES_h - -#define COMMON_REQUESTDATAPAGE_NUMBER 70 -#define COMMON_MODESETTINGS_NUMBER 76 -#define COMMON_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER 78 -#define COMMON_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER 79 -#define COMMON_MANUFACTURERSINFORMATION_NUMBER 80 -#define COMMON_PRODUCTINFORMATION_NUMBER 81 -#define COMMON_BATTERYSTATUS_NUMBER 82 - -#endif // ANTPLUS_COMMONDATAPAGEPRIVATEDEFINES_h diff --git a/src/CommonDataPages/ANTPLUS_ManufacturersInformation.cpp b/src/CommonDataPages/ANTPLUS_ManufacturersInformation.cpp index 3ca54ed..349d502 100644 --- a/src/CommonDataPages/ANTPLUS_ManufacturersInformation.cpp +++ b/src/CommonDataPages/ANTPLUS_ManufacturersInformation.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #define HWREVISION_BYTE 3 @@ -42,7 +42,7 @@ ManufacturersInformationMsg::ManufacturersInformationMsg() : BaseDataPageMsg(), BaseManufacturersInformation() { setDataBuffer(_buffer); - set8BitValue(COMMON_MANUFACTURERSINFORMATION_NUMBER, + set8BitValue(ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); set16BitValue(RESERVED_VALUE, RESERVED_LSB_BYTE, RESERVED_MSB_BYTE); } diff --git a/src/CommonDataPages/ANTPLUS_ModeSettings.cpp b/src/CommonDataPages/ANTPLUS_ModeSettings.cpp index f358548..1bd461a 100644 --- a/src/CommonDataPages/ANTPLUS_ModeSettings.cpp +++ b/src/CommonDataPages/ANTPLUS_ModeSettings.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #define SPORTSMODE_BYTE 7 @@ -24,7 +24,7 @@ ModeSettingsMsg::ModeSettingsMsg() : BaseDataPageMsg(), BaseModeSettings() { setDataBuffer(_buffer); - set8BitValue(COMMON_MODESETTINGS_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); + set8BitValue(ANTPLUS_COMMON_DATAPAGE_MODESETTINGS_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); set8BitValue(RESERVED_BYTE, 1); set8BitValue(RESERVED_BYTE, 2); set8BitValue(RESERVED_BYTE, 3); diff --git a/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp b/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp index 02988dc..7d99573 100644 --- a/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp +++ b/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #define COMPONENTIDENTIFIER_BYTE 2 @@ -56,7 +56,7 @@ MultiComponentSystemManufacturersInformationMsg::MultiComponentSystemManufacture BaseMultiComponentSystemManufacturersInformation() { setDataBuffer(_buffer); set8BitValue( - COMMON_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER, + ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); } diff --git a/src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.cpp b/src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.cpp index 86b97a0..0080158 100644 --- a/src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.cpp +++ b/src/CommonDataPages/ANTPLUS_MultiComponentSystemProductInformation.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #define COMPONENTIDENTIFIER_BYTE 1 @@ -54,7 +54,7 @@ MultiComponentSystemProductInformationMsg::MultiComponentSystemProductInformatio BaseDataPageMsg(), BaseMultiComponentSystemProductInformation() { setDataBuffer(_buffer); - set8BitValue(COMMON_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER, + set8BitValue(ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); } diff --git a/src/CommonDataPages/ANTPLUS_ProductInformation.cpp b/src/CommonDataPages/ANTPLUS_ProductInformation.cpp index 5706f02..cfeab92 100644 --- a/src/CommonDataPages/ANTPLUS_ProductInformation.cpp +++ b/src/CommonDataPages/ANTPLUS_ProductInformation.cpp @@ -1,7 +1,9 @@ #include -#include +#include #include +#define RESERVED_BYTE 1 +#define RESERVED_VALUE 0xFF #define SWREVISIONSUPPLEMENTAL_BYTE 2 #define SWREVISIONMAIN_BYTE 3 #define SERIALNUMBER_LSB_BYTE 4 @@ -35,11 +37,10 @@ ProductInformation::ProductInformation(AntRxDataResponse& dp) : ProductInformationMsg::ProductInformationMsg() : BaseDataPageMsg(), BaseProductInformation() { - // TODO magic numbers setDataBuffer(_buffer); - set8BitValue(COMMON_PRODUCTINFORMATION_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); - set8BitValue(0xFF, 1); - set8BitValue(0xFF, SWREVISIONSUPPLEMENTAL_BYTE); + 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) { diff --git a/src/CommonDataPages/ANTPLUS_RequestDataPage.cpp b/src/CommonDataPages/ANTPLUS_RequestDataPage.cpp index 7658dcb..85ee8d7 100644 --- a/src/CommonDataPages/ANTPLUS_RequestDataPage.cpp +++ b/src/CommonDataPages/ANTPLUS_RequestDataPage.cpp @@ -1,5 +1,4 @@ #include -#include #include #include @@ -79,7 +78,7 @@ RequestDataPageMsg::RequestDataPageMsg() : setDataBuffer(_buffer); setDescriptorByte1(ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE1_INVALID); setDescriptorByte2(ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_DESCRIPTORBYTE2_INVALID); - set8BitValue(COMMON_REQUESTDATAPAGE_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); + set8BitValue(ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); } void RequestDataPageMsg::setSlaveSerialNumber(uint16_t serialNumber) { diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp index 74663b4..a9eed11 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerDisplay.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #define DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE @@ -22,13 +22,13 @@ bool ProfileBicyclePowerDisplay::handleDataPage(BicyclePowerBaseMainDataPage& dp bool called = false; switch (dataPage) { - case COMMON_MANUFACTURERSINFORMATION_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER: called = handleManufacturersInformation(dp); break; - case COMMON_PRODUCTINFORMATION_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER: called = handleProductInformation(dp); break; - case COMMON_BATTERYSTATUS_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER: called = handleBatteryStatus(dp); break; case ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_NUMBER: diff --git a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp index ecd0b2a..fe28935 100644 --- a/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp +++ b/src/Profiles/BicyclePower/Profiles/ANTPLUS_ProfileBicyclePowerSensor.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #define SENSOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT @@ -44,7 +44,7 @@ void ProfileBicyclePowerSensor::onAcknowledgedData(AcknowledgedData& msg) { BaseMasterProfile::onAcknowledgedData(msg); switch (dataPage) { - case COMMON_REQUESTDATAPAGE_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER: called = handleRequestDataPage(dp); break; case ANTPLUS_BICYCLEPOWER_DATAPAGES_GENERALCALIBRATION_NUMBER: @@ -207,15 +207,15 @@ uint8_t ProfileBicyclePowerSensor::getBackgroundPage() { * */ if (_patternStep == 118) { - return COMMON_MANUFACTURERSINFORMATION_NUMBER; + return ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER; } if (_patternStep == 119) { - return COMMON_PRODUCTINFORMATION_NUMBER; + return ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER; } if ((_patternStep == 33 || _patternStep == 93) && _createBatteryStatusMsg.func) { - return COMMON_BATTERYSTATUS_NUMBER; + return ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER; } /* we don't have anything to transmit */ @@ -240,13 +240,13 @@ void ProfileBicyclePowerSensor::transmitDataPage(uint8_t page) { case ANTPLUS_BICYCLEPOWER_DATAPAGES_CRANKTORQUEFREQUENCY_NUMBER: transmitBicyclePowerCrankTorqueFrequencyMsg(); break; - case COMMON_PRODUCTINFORMATION_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER: transmitProductInfomrationMsg(); break; - case COMMON_MANUFACTURERSINFORMATION_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER: transmitManufacturesInformationMsg(); break; - case COMMON_BATTERYSTATUS_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER: transmitBatteryStatusMsg(); break; } @@ -273,10 +273,10 @@ bool ProfileBicyclePowerSensor::isDataPageValid(uint8_t dataPage) { (bool)_createBicyclePowerTorqueEffectivenessAndPedalSmoothnessMsg.func; case ANTPLUS_BICYCLEPOWER_DATAPAGES_CRANKTORQUEFREQUENCY_NUMBER: return FLAGS_SENSORTYPE(_flags) == ANTPLUS_BICYCLEPOWER_FLAGS_SENSORTYPE_CTF; - case COMMON_BATTERYSTATUS_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER: return (bool)_createBatteryStatusMsg.func; - case COMMON_PRODUCTINFORMATION_NUMBER: - case COMMON_MANUFACTURERSINFORMATION_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER: return true; default: return false; diff --git a/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.cpp b/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.cpp index a4beb7c..e3c8cbc 100644 --- a/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.cpp +++ b/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.cpp @@ -1,7 +1,5 @@ #include #include -#include -#include #define DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE diff --git a/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.cpp b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.cpp index 429123f..1c4428a 100644 --- a/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.cpp +++ b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #define DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE @@ -35,11 +35,11 @@ bool ProfileEnvironmentDisplay::handleDataPage(EnvironmentBaseDataPage& dp) { case ENVIRONMENT_TEMPERATURE_NUMBER: called = handleTemperature(dp); break; - case COMMON_MANUFACTURERSINFORMATION_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER: // Called Manufacturers Identification in Environment Profile PDF called = handleManufacturersInformation(dp); break; - case COMMON_PRODUCTINFORMATION_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER: called = handleProductInformation(dp); break; } diff --git a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp index b2dae55..14212ef 100644 --- a/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp +++ b/src/Profiles/Fec/Profiles/ANTPLUS_FecProfileDisplay.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #define DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE @@ -25,11 +25,11 @@ bool ProfileFecDisplay::handleDataPage(FecBaseMainDataPage& dp) { called = handleTrainerData(dp); break; - case COMMON_MANUFACTURERSINFORMATION_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER: called = handleManufacturerInformation(dp); break; - case COMMON_PRODUCTINFORMATION_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER: called = handleProductInformation(dp); break; diff --git a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp index f382f7e..607c47c 100644 --- a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateDisplay.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #define DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE diff --git a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp index 429564e..a921516 100644 --- a/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp +++ b/src/Profiles/HeartRate/Profiles/ANTPLUS_ProfileHeartRateMonitor.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #define MONITOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT @@ -45,10 +45,10 @@ void ProfileHeartRateMonitor::onAcknowledgedData(AcknowledgedData& msg) { switch (dataPage) { - case COMMON_REQUESTDATAPAGE_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER: called = handleRequestDataPage(dp); break; - case COMMON_MODESETTINGS_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_MODESETTINGS_NUMBER: called = handleModeSettings(dp); break; } diff --git a/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.cpp b/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.cpp index 4c16287..7b74b4e 100644 --- a/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.cpp +++ b/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #define DISPLAY_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE @@ -56,10 +56,10 @@ bool ProfileLevDisplay::handleDataPage(LevBaseMainDataPage& dp) { case LEVCAPABILITIES_NUMBER: called = handleCapabilities(dp); break; - case COMMON_MANUFACTURERSINFORMATION_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER: called = handleManufacturersInformation(dp); break; - case COMMON_PRODUCTINFORMATION_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER: called = handleProductInformation(dp); break; } diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp index c6667e5..6292e08 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #define MONITOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT @@ -25,10 +25,11 @@ void ProfileMuscleOxygenMonitor::setChannelConfig() { bool ProfileMuscleOxygenMonitor::isDataPageValid(uint8_t dataPage) { switch (dataPage) { case MUSCLEOXYGEN_MUSCLEOXYGENDATA_NUMBER: - case COMMON_PRODUCTINFORMATION_NUMBER: - case COMMON_MANUFACTURERSINFORMATION_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER: return true; - case COMMON_BATTERYSTATUS_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER: + // TODO use callback return _flags & ANTPLUS_MUSCLEOXYGEN_FLAGS_BATTERYSTATUS_SUPPORTED; } return false; diff --git a/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.cpp b/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.cpp index ee52176..510f0d8 100644 --- a/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.cpp +++ b/src/Profiles/Shifting/Profiles/ANTPLUS_ProfileShiftingShifter.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include @@ -40,9 +40,9 @@ bool ProfileShiftingShifter::isDataPageValid(uint8_t dataPage) { switch (dataPage) { case ANTPLUS_SHIFTING_DATAPAGE_SHIFTSYSTEMSTATUS_NUMBER: - case COMMON_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER: - case COMMON_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER: - case COMMON_BATTERYSTATUS_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMPRODUCTINFORMATION_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_NUMBER: return true; } return false; @@ -110,7 +110,7 @@ void ProfileShiftingShifter::onAcknowledgedData(AcknowledgedData& msg) { switch (dataPage) { - case COMMON_REQUESTDATAPAGE_NUMBER: + case ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER: called = handleRequestDataPage(dp); break; } @@ -175,9 +175,9 @@ bool ProfileShiftingShifter::handleRequestDataPage(BaseDataPage Date: Wed, 2 Feb 2022 18:57:47 -0800 Subject: [PATCH 223/241] Fec: Add Tx type for specific trainer data --- .../ANTPLUS_FecSpecificTrainerData.cpp | 54 +++++++++++++++++++ .../ANTPLUS_FecSpecificTrainerData.h | 17 +++++- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp index a7d8772..e42091b 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.cpp @@ -89,3 +89,57 @@ 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 index 4f48cf3..a70f061 100644 --- a/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.h +++ b/src/Profiles/Fec/DataPages/ANTPLUS_FecSpecificTrainerData.h @@ -1,7 +1,7 @@ #ifndef ANTPLUS_FECTRAINERDATA_h #define ANTPLUS_FECTRAINERDATA_h -#include +#include template class FecBaseSpecificTrainerData : virtual public CoreDataPage { @@ -24,6 +24,19 @@ class FecSpecificTrainerData : public BaseDataPage, public FecBas explicit FecSpecificTrainerData(AntRxDataResponse& dp); }; -// TODO TX type +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 From 133fd75ec92c7b42c10835b7ef1384519cd8b12d Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Wed, 2 Feb 2022 18:59:00 -0800 Subject: [PATCH 224/241] Profiles: remove unneeded TODOs --- .../DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.h | 4 ++-- .../DataPages/ANTPLUS_HeartRateSwimIntervalSummary.cpp | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.h b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.h index 3c5a8bc..2e7ec6d 100644 --- a/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.h +++ b/src/Profiles/BicyclePower/DataPages/ANTPLUS_BicyclePowerStandardCrankTorque.h @@ -8,7 +8,7 @@ class BicyclePowerBaseStandardCrankTorque : virtual public CoreDataPage { public: BicyclePowerBaseStandardCrankTorque(); uint8_t getCrankTicks(); - uint8_t getInstantaneousCadence(); //TODO is valid check, May not be available, 0xFF indicates invalid + uint8_t getInstantaneousCadence(); uint16_t getCrankPeriod(); uint16_t getAccumulatedTorque(); }; @@ -26,7 +26,7 @@ class BicyclePowerStandardCrankTorqueMsg : public: BicyclePowerStandardCrankTorqueMsg(); void setCrankTicks(uint8_t ticks); - void setInstantaneousCadence(uint8_t cadence); //TODO is valid check, May not be available, 0xFF indicates invalid + void setInstantaneousCadence(uint8_t cadence); void setCrankPeriod(uint16_t period); void setAccumulatedTorque(uint16_t torque); }; diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateSwimIntervalSummary.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateSwimIntervalSummary.cpp index ce7d958..c3ad8c2 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateSwimIntervalSummary.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateSwimIntervalSummary.cpp @@ -32,7 +32,6 @@ HeartRateSwimIntervalSummary::HeartRateSwimIntervalSummary(AntRxDataResponse& dp HeartRateBaseMainDataPage(dp), HeartRateBaseSwimIntervalSummary() {} -// TODO add isValid methods HeartRateSwimIntervalSummaryMsg::HeartRateSwimIntervalSummaryMsg() : HeartRateBaseMainDataPageMsg(HEARTRATE_SWIMINTERVALSUMMARY_NUMBER), HeartRateBaseSwimIntervalSummary() { From eac2ae0303c05df0c3a008ad6ab6a8edc568c33e Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Wed, 2 Feb 2022 19:47:34 -0800 Subject: [PATCH 225/241] Lev: Split display data into RX and TX types also break apart command bitfield --- .../Lev/DataPages/ANTPLUS_LevDisplayData.cpp | 94 +++++++++++++++---- .../Lev/DataPages/ANTPLUS_LevDisplayData.h | 24 ++++- 2 files changed, 98 insertions(+), 20 deletions(-) diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.cpp index 26f3211..edadf71 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.cpp @@ -20,52 +20,93 @@ #define CURRENTFRONTGEAR_BYTE 4 #define CURRENTFRONTGEAR_MASK 0x30 #define CURRENTFRONTGEAR_SHIFT 4 -#define CURRENTLIGHTMODE_BYTE 4 -#define CURRENTLIGHTMODE_MASK 0xF +#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 -LevDisplayDataMsg::LevDisplayDataMsg() : LevBaseMainDataPageMsg(DISPLAYDATA_NUMBER) { - set8BitValue(RESERVED1_VALUE, RESERVED1_BYTE); - set8BitValue(RESERVED2_VALUE, RESERVED2_BYTE); -} +template +LevBaseDisplayData::LevBaseDisplayData() : CoreDataPage() {} -uint16_t LevDisplayDataMsg::getWheelCircumference() { +template +uint16_t LevBaseDisplayData::getWheelCircumference() { return this->get16BitValue(WHEELCIRCUMFERENCE_LSB_BYTE, WHEELCIRCUMFERENCE_MSB_BYTE, WHEELCIRCUMFERENCE_MASK); } -uint8_t LevDisplayDataMsg::getCurrentAssistLevel() { +template +uint8_t LevBaseDisplayData::getCurrentAssistLevel() { return this->get8BitValue(CURRENTASSISTLEVEL_BYTE, CURRENTASSISTLEVEL_MASK, CURRENTASSISTLEVEL_SHIFT); } -uint8_t LevDisplayDataMsg::getCurrentRegenerativeLevel() { +template +uint8_t LevBaseDisplayData::getCurrentRegenerativeLevel() { return this->get8BitValue(CURRENTREGENERATIVELEVEL_BYTE, CURRENTREGENERATIVELEVEL_MASK); } -uint8_t LevDisplayDataMsg::getCurrentRearGear() { +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); } -uint8_t LevDisplayDataMsg::getCurrentFrontGear() { +template +uint8_t LevBaseDisplayData::getCurrentFrontGear() { return this->get8BitValue(CURRENTFRONTGEAR_BYTE, CURRENTFRONTGEAR_MASK, CURRENTFRONTGEAR_SHIFT); } -// TODO break apart bitfield -uint8_t LevDisplayDataMsg::getCurrentLightMode() { - return this->get8BitValue(CURRENTLIGHTMODE_BYTE, CURRENTLIGHTMODE_MASK); +template +bool LevBaseDisplayData::getDisplayCommandTurnSignalRight() { + return this->get8BitValue(DISPLAYCOMMAND_BYTE, + DISPLAYCOMMANDTURNSIGNALRIGHT_MASK); +} + +template +bool LevBaseDisplayData::getDisplayCommandTurnSignalLeft() { + return this->get8BitValue(DISPLAYCOMMAND_BYTE, + DISPLAYCOMMANDTURNSIGNALLEFT_MASK, + DISPLAYCOMMANDTURNSIGNALLEFT_SHIFT); } -uint16_t LevDisplayDataMsg::getManufacturerID() { +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(DISPLAYDATA_NUMBER) { + 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); @@ -91,8 +132,27 @@ void LevDisplayDataMsg::setCurrentFrontGear(uint8_t gear) { CURRENTFRONTGEAR_SHIFT); } -void LevDisplayDataMsg::setCurrentLightMode(uint8_t state) { - set8BitValue(state, CURRENTLIGHTMODE_BYTE, CURRENTLIGHTMODE_MASK); +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) { diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.h index e667867..07040ad 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.h @@ -3,16 +3,31 @@ #include -class LevDisplayDataMsg : public LevBaseMainDataPageMsg { +template +class LevBaseDisplayData : virtual public CoreDataPage { public: - LevDisplayDataMsg(); + 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 @@ -22,7 +37,10 @@ class LevDisplayDataMsg : public LevBaseMainDataPageMsg { void setCurrentRegenerativeLevel(uint8_t level); void setCurrentRearGear(uint8_t gear); void setCurrentFrontGear(uint8_t gear); - void setCurrentLightMode(uint8_t state); + void setDisplayCommandTurnSignalRight(bool rightSignal); + void setDisplayCommandTurnSignalLeft(bool leftSignal); + void setDisplayCommandLightHighBeam(bool highBeam); + void setDisplayCommandLightOnOff(bool onOff); void setManufacturerID(uint16_t id); }; From e5a26271c7508ad2a92c21769dee86508d7a2238 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Wed, 2 Feb 2022 23:36:36 -0800 Subject: [PATCH 226/241] Lev: fixup datapage structure --- .../DataPages/ANTPLUS_LevBaseMainDataPage.cpp | 12 ++++-- .../DataPages/ANTPLUS_LevBaseMainDataPage.h | 3 +- .../Lev/DataPages/ANTPLUS_LevCapabilities.cpp | 39 ++++++++++++++++--- .../Lev/DataPages/ANTPLUS_LevCapabilities.h | 18 ++++++++- .../Lev/DataPages/ANTPLUS_LevDisplayData.cpp | 6 +-- .../Lev/DataPages/ANTPLUS_LevDisplayData.h | 2 +- 6 files changed, 64 insertions(+), 16 deletions(-) diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.cpp index b311e8b..d4ae47b 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.cpp @@ -4,8 +4,12 @@ LevBaseMainDataPage::LevBaseMainDataPage(AntRxDataResponse& dp) : BaseDataPage(dp) {} -LevBaseMainDataPageMsg::LevBaseMainDataPageMsg(uint8_t dataPageNumber) : - BaseDataPageMsg() { - setDataBuffer(_buffer); - set8BitValue(dataPageNumber, ANTPLUS_DEFAULT_DATAPAGE_BYTE); +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 index 3ed7212..b2c1ecb 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.h @@ -9,7 +9,8 @@ class LevBaseMainDataPage : public BaseDataPage { explicit LevBaseMainDataPage(AntRxDataResponse& dp); }; -class LevBaseMainDataPageMsg : public BaseDataPageMsg { +template +class LevBaseMainDataPageMsg : public BaseDataPageMsg { public: explicit LevBaseMainDataPageMsg(uint8_t dataPageNumber); protected: diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.cpp index 01712f2..1ae8c18 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.cpp @@ -9,21 +9,50 @@ #define WHEELCIRCUMFERENCE_MSB_BYTE 4 #define WHEELCIRCUMFERENCE_MASK 0xF -LevCapabilities::LevCapabilities(AntRxDataResponse& dp) : - LevBaseMainDataPage(dp) {} +template +LevBaseCapabilities::LevBaseCapabilities() : CoreDataPage() {} -uint8_t LevCapabilities::getNumberOfAssistModesSupported() { +template +uint8_t LevBaseCapabilities::getNumberOfAssistModesSupported() { return this->get8BitValue(TRAVELMODESSUPPORTED_BYTE, TRAVELMODESSUPPORTED_NUMBERASSISTMODES_MASK, TRAVELMODESSUPPORTED_NUMBERASSISTMODES_SHIFT); } -uint8_t LevCapabilities::getNumberOfRegenerativeModesSupported() { +template +uint8_t LevBaseCapabilities::getNumberOfRegenerativeModesSupported() { return this->get8BitValue(TRAVELMODESSUPPORTED_BYTE, TRAVELMODESSUPPORTED_NUMBERREGENERATIVEMODES_MASK); } -uint16_t LevCapabilities::getWheelCircumference() { +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(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 index c7bbef5..1a80731 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.h @@ -3,12 +3,26 @@ #include -class LevCapabilities : public LevBaseMainDataPage { +template +class LevBaseCapabilities : virtual public CoreDataPage { public: - explicit LevCapabilities(AntRxDataResponse& dp); + 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 index edadf71..a6c6558 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.cpp @@ -98,10 +98,10 @@ uint16_t LevBaseDisplayData::getManufacturerID() { return this->get16BitValue(MANUFACTURERID_LSB_BYTE, MANUFACTURERID_MSB_BYTE); } -template class LevBaseDisplayData; -template class LevBaseDisplayData; +template class LevBaseDisplayData; +template class LevBaseDisplayData; -LevDisplayDataMsg::LevDisplayDataMsg() : LevBaseMainDataPageMsg(DISPLAYDATA_NUMBER) { +LevDisplayDataMsg::LevDisplayDataMsg() : LevBaseMainDataPageMsg(DISPLAYDATA_NUMBER), LevBaseDisplayData() { set8BitValue(RESERVED1_VALUE, RESERVED1_BYTE); set8BitValue(RESERVED2_VALUE, RESERVED2_BYTE); } diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.h b/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.h index 07040ad..baa63a2 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.h @@ -25,7 +25,7 @@ class LevDisplayData : public LevBaseMainDataPage, public LevBaseDisplayData { +class LevDisplayDataMsg : public LevBaseMainDataPageMsg, public LevBaseDisplayData { public: LevDisplayDataMsg(); void setWheelCircumference(uint16_t circumference); From 303911e0848a2b8a33c67d8a14d9b7fa9e7a1c9c Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 3 Feb 2022 00:01:34 -0800 Subject: [PATCH 227/241] Lev: BatteryInformation: format refector --- .../ANTPLUS_LevBatteryInformation.cpp | 54 ++++++++++++++++--- .../DataPages/ANTPLUS_LevBatteryInformation.h | 18 ++++++- 2 files changed, 63 insertions(+), 9 deletions(-) diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.cpp index 43f18a0..91ccb1b 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.cpp @@ -1,6 +1,8 @@ #include #include +#define RESERVED_BYTE 1 +#define RESERVED_VALUE 0xFF #define CHARGINGCYCLECOUNT_LSB_BYTE 2 #define CHARGINGCYCLECOUNT_MSB_BYTE 3 #define CHARGINGCYCLECOUNT_MASK 0x0FFF @@ -12,26 +14,64 @@ #define DISTANCEONCURRENTCHARGE_LSB_BYTE 6 #define DISTANCEONCURRENTCHARGE_MSB_BYTE 7 -LevBatteryInformation::LevBatteryInformation(AntRxDataResponse& dp) : - LevBaseMainDataPage(dp) {} +template +LevBaseBatteryInformation::LevBaseBatteryInformation() : CoreDataPage() {} -uint16_t LevBatteryInformation::getChargingCycleCount() { +template +uint16_t LevBaseBatteryInformation::getChargingCycleCount() { return this->get16BitValue(CHARGINGCYCLECOUNT_LSB_BYTE, CHARGINGCYCLECOUNT_MSB_BYTE, CHARGINGCYCLECOUNT_MASK); } -// TODO check this in testing -uint16_t LevBatteryInformation::getFuelConsumption() { +template +uint16_t LevBaseBatteryInformation::getFuelConsumption() { return this->get16BitValue(FUELCONSUMPTION_LSB_BYTE, FUELCONSUMPTION_MSB_BYTE, FUELCONSUMPTION_MASK, FUELCONSUMPTION_SHIFT); } -uint8_t LevBatteryInformation::getBatteryVoltage() { +template +uint8_t LevBaseBatteryInformation::getBatteryVoltage() { return this->get8BitValue(BATTERYVOLTAGE_BYTE); } -uint16_t LevBatteryInformation::getDistanceOnCurrentCharge() { +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(BATTERYINFORMATION_NUMBER), + LevBaseBatteryInformation() { + set8BitValue(RESERVED_VALUE, RESERVED_BYTE); +} + +void LevBatteryInformationMsg::setChargingCycleCount(uint16_t cycleCount) { + set16BitValue(cycleCount, CHARGINGCYCLECOUNT_LSB_BYTE, + CHARGINGCYCLECOUNT_MSB_BYTE, + CHARGINGCYCLECOUNT_MASK); +} + +void LevBatteryInformationMsg::setFuelConsumption(uint16_t consumption) { + set16BitValue(consumption, FUELCONSUMPTION_LSB_BYTE, + FUELCONSUMPTION_MSB_BYTE, + FUELCONSUMPTION_MASK, + FUELCONSUMPTION_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 index 09a9a5e..a5abce8 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.h @@ -3,13 +3,27 @@ #include -class LevBatteryInformation : public LevBaseMainDataPage { +template +class LevBaseBatteryInformation : virtual public CoreDataPage { public: - explicit LevBatteryInformation(AntRxDataResponse& dp); + 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 From 4b75c247b8e495ffea72d1fb914c59aa80ce00ca Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Fri, 4 Feb 2022 16:35:44 -0800 Subject: [PATCH 228/241] Lev: SpeedSystemInformation: move to core datapage format also optimize display code --- .../ANTPLUS_LevBaseSpeedSystemInformation.cpp | 79 ++++++++++++++++--- .../ANTPLUS_LevBaseSpeedSystemInformation.h | 23 +++++- .../ANTPLUS_LevSpeedSystemInformation1.cpp | 60 ++++++++++++-- .../ANTPLUS_LevSpeedSystemInformation1.h | 20 ++++- .../ANTPLUS_LevSpeedSystemInformation2.cpp | 42 ++++++++-- .../ANTPLUS_LevSpeedSystemInformation2.h | 18 ++++- .../Profiles/ANTPLUS_ProfileLevDisplay.cpp | 16 ++-- 7 files changed, 220 insertions(+), 38 deletions(-) diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedSystemInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedSystemInformation.cpp index db6b839..e6a6c5a 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedSystemInformation.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedSystemInformation.cpp @@ -18,44 +18,103 @@ #define LEVSPEED_MSB_BYTE 7 #define LEVSPEED_MASK 0x0FFF -LevBaseSpeedSystemInformation::LevBaseSpeedSystemInformation(AntRxDataResponse& dp) : - LevBaseMainDataPage(dp) {} +template +LevCoreSpeedSystemInformation::LevCoreSpeedSystemInformation() : + CoreDataPage() {} -uint8_t LevBaseSpeedSystemInformation::getCurrentRegenerativeLevel() { +template +uint8_t LevCoreSpeedSystemInformation::getCurrentRegenerativeLevel() { return this->get8BitValue(TRAVELMODESTATE_BYTE, TRAVELMODESTATE_CURRENTREGENERATIVELEVEL_MASK); } -uint8_t LevBaseSpeedSystemInformation::getCurrentAssistLevel() { +template +uint8_t LevCoreSpeedSystemInformation::getCurrentAssistLevel() { return this->get8BitValue(TRAVELMODESTATE_BYTE, TRAVELMODESTATE_CURRENTASSISTLEVEL_MASK, TRAVELMODESTATE_CURRENTASSISTLEVEL_SHIFT); } -uint8_t LevBaseSpeedSystemInformation::getSystemState() { +template +uint8_t LevCoreSpeedSystemInformation::getSystemState() { return this->get8BitValue(SYSTEMSTATE_BYTE); } -uint8_t LevBaseSpeedSystemInformation::getCurrentFrontGear() { +template +uint8_t LevCoreSpeedSystemInformation::getCurrentFrontGear() { return this->get8BitValue(GEARSTATE_BYTE, GEARSTATE_CURRENTFRONTGEAR_MASK); } -uint8_t LevBaseSpeedSystemInformation::getCurrentRearGear() { +template +uint8_t LevCoreSpeedSystemInformation::getCurrentRearGear() { return this->get8BitValue(GEARSTATE_BYTE, GEARSTATE_CURRENTREARGEAR_MASK, GEARSTATE_CURRENTREARGEAR_SHIFT); } -uint8_t LevBaseSpeedSystemInformation::getManualAutoState() { +template +uint8_t LevCoreSpeedSystemInformation::getManualAutoState() { return this->get8BitValue(GEARSTATE_BYTE, GEARSTATE_MANUALAUTO_MASK, GEARSTATE_MANUALAUTO_SHIFT); } -uint8_t LevBaseSpeedSystemInformation::getGearExist() { +template +uint8_t LevCoreSpeedSystemInformation::getGearExist() { return this->get8BitValue(GEARSTATE_BYTE, GEARSTATE_GEAREXIST_MASK, GEARSTATE_GEAREXIST_SHIFT); } -uint16_t LevBaseSpeedSystemInformation::getSpeed() { // in 1/10 km/h +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 index 56c911f..4b9e330 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedSystemInformation.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedSystemInformation.h @@ -3,9 +3,10 @@ #include -class LevBaseSpeedSystemInformation : public LevBaseMainDataPage { +template +class LevCoreSpeedSystemInformation : virtual public CoreDataPage { public: - explicit LevBaseSpeedSystemInformation(AntRxDataResponse& dp); + LevCoreSpeedSystemInformation(); uint8_t getCurrentRegenerativeLevel(); uint8_t getCurrentAssistLevel(); uint8_t getSystemState(); @@ -16,4 +17,22 @@ class LevBaseSpeedSystemInformation : public LevBaseMainDataPage { 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_LevSpeedSystemInformation1.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.cpp index 662ebc7..2aaea86 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.cpp @@ -11,34 +11,78 @@ #define TEMPERATURESTATE_MOTORTEMPERATUREALERT_MASK 0x80 #define ERRORMESSAGE_BYTE 5 -LevSpeedSystemInformation1::LevSpeedSystemInformation1(AntRxDataResponse& dp) : - LevBaseSpeedSystemInformation(dp) {} +template +LevBaseSpeedSystemInformation1::LevBaseSpeedSystemInformation1() : + CoreDataPage() {} -uint8_t LevSpeedSystemInformation1::getBatteryTemperatureState() { +template +uint8_t LevBaseSpeedSystemInformation1::getBatteryTemperatureState() { return this->get8BitValue(TEMPERATURESTATE_BYTE, TEMPERATURESTATE_BATTERYTEMPERATURE_MASK); } -uint8_t LevSpeedSystemInformation1::getBatteryTemperatureAlert() { +template +uint8_t LevBaseSpeedSystemInformation1::getBatteryTemperatureAlert() { return this->get8BitValue(TEMPERATURESTATE_BYTE, TEMPERATURESTATE_BATTERYTEMPERATUREALERT_MASK, TEMPERATURESTATE_BATTERYTEMPERATUREALERT_SHIFT); } -uint8_t LevSpeedSystemInformation1::getMotorTemperatureState() { +template +uint8_t LevBaseSpeedSystemInformation1::getMotorTemperatureState() { return this->get8BitValue(TEMPERATURESTATE_BYTE, TEMPERATURESTATE_MOTORTEMPERATURE_MASK, TEMPERATURESTATE_MOTORTEMPERATURE_SHIFT); } -uint8_t LevSpeedSystemInformation1::getMotorTemperatureAlert() { +template +uint8_t LevBaseSpeedSystemInformation1::getMotorTemperatureAlert() { return this->get8BitValue(TEMPERATURESTATE_BYTE, TEMPERATURESTATE_MOTORTEMPERATUREALERT_MASK, TEMPERATURESTATE_MOTORTEMPERATUREALERT_SHIFT); } - -uint8_t LevSpeedSystemInformation1::getErrorMessage() { +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(SPEEDSYSTEMINFORMATION1_NUMBER), + LevBaseSpeedSystemInformation1() {} + +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 index 147ee33..311cba4 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.h @@ -3,9 +3,10 @@ #include -class LevSpeedSystemInformation1 : public LevBaseSpeedSystemInformation { +template +class LevBaseSpeedSystemInformation1 : virtual public CoreDataPage { public: - explicit LevSpeedSystemInformation1(AntRxDataResponse& dp); + LevBaseSpeedSystemInformation1(); uint8_t getBatteryTemperatureState(); uint8_t getBatteryTemperatureAlert(); uint8_t getMotorTemperatureState(); @@ -13,4 +14,19 @@ class LevSpeedSystemInformation1 : public LevBaseSpeedSystemInformation { 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 index 82e51b4..1c0572b 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.cpp @@ -7,17 +7,47 @@ #define BATTERYSOC_BATTERYEMPTY_MASK 0x80 #define PERCENTASSIST_BYTE 5 -LevSpeedSystemInformation2::LevSpeedSystemInformation2(AntRxDataResponse& dp) : - LevBaseSpeedSystemInformation(dp) {} +template +LevBaseSpeedSystemInformation2::LevBaseSpeedSystemInformation2() : + CoreDataPage() {} -uint8_t LevSpeedSystemInformation2::getBatterySOC() { +template +uint8_t LevBaseSpeedSystemInformation2::getBatterySOC() { return this->get8BitValue(BATTERYSOC_BYTE, BATTERYSOC_STATEOFCHARGE_MASK); } -uint8_t LevSpeedSystemInformation2::getBatteryEmptyWarning() { - return this->get8BitValue(BATTERYSOC_BYTE, BATTERYSOC_BATTERYEMPTY_MASK, BATTERYSOC_BATTERYEMPTY_SHIFT); +template +uint8_t LevBaseSpeedSystemInformation2::getBatteryEmptyWarning() { + return this->get8BitValue(BATTERYSOC_BYTE, + BATTERYSOC_BATTERYEMPTY_MASK, + BATTERYSOC_BATTERYEMPTY_SHIFT); } -uint8_t LevSpeedSystemInformation2::getPercentAssist() { +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(SPEEDSYSTEMINFORMATION2_NUMBER), + LevBaseSpeedSystemInformation2() {} + +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 index cd3a262..961d991 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.h @@ -3,12 +3,26 @@ #include -class LevSpeedSystemInformation2 : public LevBaseSpeedSystemInformation { +template +class LevBaseSpeedSystemInformation2 : virtual public CoreDataPage { public: - explicit LevSpeedSystemInformation2(AntRxDataResponse& dp); + 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/Profiles/ANTPLUS_ProfileLevDisplay.cpp b/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.cpp index 7b74b4e..40ad714 100644 --- a/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.cpp +++ b/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.cpp @@ -67,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); } From c95216681d599aedeb0369debd34e0c6a19b990b Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 5 Feb 2022 11:36:52 -0800 Subject: [PATCH 229/241] Lev: SpeedAndDistance: Update to new datapage format --- ...ANTPLUS_LevAltSpeedDistanceInformation.cpp | 24 ++++++++++++-- .../ANTPLUS_LevAltSpeedDistanceInformation.h | 16 ++++++++-- ...NTPLUS_LevBaseSpeedDistanceInformation.cpp | 31 ++++++++++++++++--- .../ANTPLUS_LevBaseSpeedDistanceInformation.h | 17 ++++++++-- .../ANTPLUS_LevSpeedDistanceInformation.cpp | 24 ++++++++++++-- .../ANTPLUS_LevSpeedDistanceInformation.h | 16 ++++++++-- 6 files changed, 111 insertions(+), 17 deletions(-) diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.cpp index f50d887..c268cc1 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.cpp @@ -6,12 +6,30 @@ #define FUELCONSUMPTION_MASK 0x0FFF /* Alt Speed and Distance */ -LevAltSpeedDistanceInformation::LevAltSpeedDistanceInformation(AntRxDataResponse& dp) : - LevBaseSpeedDistanceInformation(dp) {} +template +LevBaseAltSpeedDistanceInformation::LevBaseAltSpeedDistanceInformation() : + CoreDataPage() {} -uint16_t LevAltSpeedDistanceInformation::getFuelConsumption() // in Wh/km +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(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 index 050542c..7d8167d 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.h @@ -3,10 +3,22 @@ #include -class LevAltSpeedDistanceInformation : public LevBaseSpeedDistanceInformation { +template +class LevBaseAltSpeedDistanceInformation : virtual public CoreDataPage { public: - explicit LevAltSpeedDistanceInformation(AntRxDataResponse& dp); + 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_LevBaseSpeedDistanceInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.cpp index 200400a..31b582e 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.cpp @@ -8,15 +8,36 @@ #define LEVSPEED_MASK 0x0FFF /* Speed and Distance */ -LevBaseSpeedDistanceInformation::LevBaseSpeedDistanceInformation(AntRxDataResponse& dp) : - LevBaseMainDataPage(dp) {} +template +LevCoreSpeedDistanceInformation::LevCoreSpeedDistanceInformation() : + CoreDataPage() {} -uint32_t LevBaseSpeedDistanceInformation::getOdometer() { // in km +template +uint32_t LevCoreSpeedDistanceInformation::getOdometer() { // in km return this->get32BitValue(ODOMETER_LSB_BYTE, ODOMETER_MSB_BYTE); } -uint16_t LevBaseSpeedDistanceInformation::getLevSpeed() // in 1/10 km/h -{ +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) { + set32BitValue(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 index b848f05..72c6d7a 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.h @@ -3,11 +3,24 @@ #include -class LevBaseSpeedDistanceInformation : public LevBaseMainDataPage { +template +class LevCoreSpeedDistanceInformation : virtual public CoreDataPage { public: - explicit LevBaseSpeedDistanceInformation(AntRxDataResponse& dp); + 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_LevSpeedDistanceInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.cpp index 87e8dfd..7386d9f 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.cpp @@ -6,10 +6,28 @@ #define REMAININGRANGE_MASK 0x0FFF /* Speed and Distance */ -LevSpeedDistanceInformation::LevSpeedDistanceInformation(AntRxDataResponse& dp) : - LevBaseSpeedDistanceInformation(dp) {} +template +LevInternalSpeedDistanceInformation::LevInternalSpeedDistanceInformation() : + CoreDataPage() {} -uint16_t LevSpeedDistanceInformation::getRemainingRange() { // in km +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(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 index 05e881e..4c8c397 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.h +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.h @@ -3,10 +3,22 @@ #include -class LevSpeedDistanceInformation : public LevBaseSpeedDistanceInformation { +template +class LevInternalSpeedDistanceInformation : virtual public CoreDataPage { public: - explicit LevSpeedDistanceInformation(AntRxDataResponse& dp); + 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 From 76e777d796ba2110ade4994f423f8b05b8c3bf78 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 5 Feb 2022 12:56:41 -0800 Subject: [PATCH 230/241] BicyclePower: Update examples Add more datapages for verification steps --- .../BicyclePowerDisplay.ino | 28 +++++++++++++++++-- .../BicyclePowerSensor/BicyclePowerSensor.ino | 2 +- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino index 2135c77..c81a466 100644 --- a/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino +++ b/examples/BicyclePowerDisplay/BicyclePowerDisplay.ino @@ -43,6 +43,7 @@ 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); @@ -66,7 +67,7 @@ void setup() { antSerial.begin(BAUD_RATE); ant.setSerial(antSerial); - delay(15000); + delay(5000); router.setDriver(&ant); // never touch ant again router.setAntPlusNetworkKey(NETWORK_KEY); @@ -83,6 +84,7 @@ void setup() { bikePower.onBicyclePowerStandardCrankTorque(crankTorqueDataPageHandler); bikePower.onBicyclePowerStandardWheelTorque(wheelTorqueDataPageHandler); bikePower.onBicyclePowerTorqueEffectivenessAndPedalSmoothness(pedalSmoothnessDataPageHandler); + bikePower.onBicyclePowerCrankTorqueFrequency(crankTorqueFrequencyDataPageHandler); bikePower.begin(); // wait for pair to complete uint8_t status = bikePower.waitForPair(); @@ -107,11 +109,30 @@ void printOrInvalid(uint8_t value, uint8_t invalidValue) { } } +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) { @@ -137,7 +158,10 @@ void bicyclePowerBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data) { Serial.println("==========================="); Serial.print("DataPage: "); Serial.println(dp.getDataPageNumber()); - Serial.print("Bike Power Event Count: "); + if (dp.getDataPageNumber() >= ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER) { + return; + } + Serial.print("Update Event Count: "); Serial.println(dp.getUpdateEventCount()); } diff --git a/examples/BicyclePowerSensor/BicyclePowerSensor.ino b/examples/BicyclePowerSensor/BicyclePowerSensor.ino index b19e10d..9f8f103 100644 --- a/examples/BicyclePowerSensor/BicyclePowerSensor.ino +++ b/examples/BicyclePowerSensor/BicyclePowerSensor.ino @@ -59,7 +59,7 @@ void setup() { antSerial.begin(BAUD_RATE); ant.setSerial(antSerial); - delay(15000); + delay(5000); router.setDriver(&ant); // never touch ant again router.setAntPlusNetworkKey(NETWORK_KEY); From b82de3dc5adde1bedd83b4fd5901314e0fc9100f Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 5 Feb 2022 15:04:56 -0800 Subject: [PATCH 231/241] Lev: DataPages: make datapage numbers public this should be a no-op --- src/Profiles/Lev/ANTPLUS_LevDefines.h | 16 ++++++++++++++++ src/Profiles/Lev/ANTPLUS_LevPrivateDefines.h | 8 -------- .../ANTPLUS_LevAltSpeedDistanceInformation.cpp | 4 ++-- .../DataPages/ANTPLUS_LevBatteryInformation.cpp | 4 ++-- .../Lev/DataPages/ANTPLUS_LevCapabilities.cpp | 4 ++-- .../Lev/DataPages/ANTPLUS_LevDisplayData.cpp | 6 ++++-- .../ANTPLUS_LevSpeedDistanceInformation.cpp | 4 ++-- .../ANTPLUS_LevSpeedSystemInformation1.cpp | 4 ++-- .../ANTPLUS_LevSpeedSystemInformation2.cpp | 4 ++-- .../Lev/Profiles/ANTPLUS_ProfileLevDisplay.cpp | 12 ++++++------ 10 files changed, 38 insertions(+), 28 deletions(-) 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 d809254..577f9b9 100644 --- a/src/Profiles/Lev/ANTPLUS_LevPrivateDefines.h +++ b/src/Profiles/Lev/ANTPLUS_LevPrivateDefines.h @@ -6,12 +6,4 @@ // 30 / 2.5 = 12 #define LEV_SEARCHTIMEOUT 12 -#define SPEEDSYSTEMINFORMATION1_NUMBER 1 -#define SPEEDDISTANCEINFORMATION_NUMBER 2 -#define ALTSPEEDDISTANCEINFORMATION_NUMBER 34 -#define SPEEDSYSTEMINFORMATION2_NUMBER 3 -#define BATTERYINFORMATION_NUMBER 4 -#define LEVCAPABILITIES_NUMBER 5 -#define DISPLAYDATA_NUMBER 16 - #endif // ANTPLUS_BICYCLESPEEDPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.cpp index c268cc1..2a17734 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevAltSpeedDistanceInformation.cpp @@ -1,5 +1,5 @@ #include -#include +#include #define FUELCONSUMPTION_LSB_BYTE 4 #define FUELCONSUMPTION_MSB_BYTE 5 @@ -25,7 +25,7 @@ LevAltSpeedDistanceInformation::LevAltSpeedDistanceInformation(AntRxDataResponse LevBaseAltSpeedDistanceInformation() {} LevAltSpeedDistanceInformationMsg::LevAltSpeedDistanceInformationMsg() : - LevBaseSpeedDistanceInformationMsg(ALTSPEEDDISTANCEINFORMATION_NUMBER), + LevBaseSpeedDistanceInformationMsg(ANTPLUS_LEV_DATAPAGE_ALTSPEEDDISTANCEINFORMATION_NUMBER), LevBaseAltSpeedDistanceInformation() {} void LevAltSpeedDistanceInformationMsg::setFuelConsumption(uint16_t consumption) // in Wh/km diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.cpp index 91ccb1b..e32750f 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.cpp @@ -1,5 +1,5 @@ #include -#include +#include #define RESERVED_BYTE 1 #define RESERVED_VALUE 0xFF @@ -49,7 +49,7 @@ LevBatteryInformation::LevBatteryInformation(AntRxDataResponse& dp) : LevBaseBatteryInformation() {} LevBatteryInformationMsg::LevBatteryInformationMsg() : - LevBaseMainDataPageMsg(BATTERYINFORMATION_NUMBER), + LevBaseMainDataPageMsg(ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_NUMBER), LevBaseBatteryInformation() { set8BitValue(RESERVED_VALUE, RESERVED_BYTE); } diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.cpp index 1ae8c18..4b46ceb 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.cpp @@ -1,5 +1,5 @@ #include -#include +#include #define TRAVELMODESSUPPORTED_BYTE 2 #define TRAVELMODESSUPPORTED_NUMBERASSISTMODES_MASK 0x38 @@ -38,7 +38,7 @@ LevCapabilities::LevCapabilities(AntRxDataResponse& dp) : LevBaseMainDataPage(dp), LevBaseCapabilities() {} LevCapabilitiesMsg::LevCapabilitiesMsg() : - LevBaseMainDataPageMsg(LEVCAPABILITIES_NUMBER), + LevBaseMainDataPageMsg(ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_NUMBER), LevBaseCapabilities() {} void LevCapabilitiesMsg::setNumberOfAssistModesSupported(uint8_t modes) { diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.cpp index a6c6558..81208f4 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevDisplayData.cpp @@ -1,5 +1,5 @@ #include -#include +#include #define WHEELCIRCUMFERENCE_LSB_BYTE 1 #define WHEELCIRCUMFERENCE_MSB_BYTE 2 @@ -101,7 +101,9 @@ uint16_t LevBaseDisplayData::getManufacturerID() { template class LevBaseDisplayData; template class LevBaseDisplayData; -LevDisplayDataMsg::LevDisplayDataMsg() : LevBaseMainDataPageMsg(DISPLAYDATA_NUMBER), LevBaseDisplayData() { +LevDisplayDataMsg::LevDisplayDataMsg() : + LevBaseMainDataPageMsg(ANTPLUS_LEV_DATAPAGE_DISPLAYDATA_NUMBER), + LevBaseDisplayData() { set8BitValue(RESERVED1_VALUE, RESERVED1_BYTE); set8BitValue(RESERVED2_VALUE, RESERVED2_BYTE); } diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.cpp index 7386d9f..72b874b 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.cpp @@ -1,5 +1,5 @@ #include -#include +#include #define REMAININGRANGE_LSB_BYTE 4 #define REMAININGRANGE_MSB_BYTE 5 @@ -24,7 +24,7 @@ LevSpeedDistanceInformation::LevSpeedDistanceInformation(AntRxDataResponse& dp) LevInternalSpeedDistanceInformation() {} LevSpeedDistanceInformationMsg::LevSpeedDistanceInformationMsg() : - LevBaseSpeedDistanceInformationMsg(SPEEDDISTANCEINFORMATION_NUMBER), + LevBaseSpeedDistanceInformationMsg(ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_NUMBER), LevInternalSpeedDistanceInformation() {} void LevSpeedDistanceInformationMsg::setRemainingRange(uint16_t remainingRange) { // in km diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.cpp index 2aaea86..a5ff2fe 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.cpp @@ -1,5 +1,5 @@ #include -#include +#include #define TEMPERATURESTATE_BYTE 1 #define TEMPERATURESTATE_BATTERYTEMPERATURE_MASK 0x7 @@ -56,7 +56,7 @@ LevSpeedSystemInformation1::LevSpeedSystemInformation1(AntRxDataResponse& dp) : } LevSpeedSystemInformation1Msg::LevSpeedSystemInformation1Msg() : - LevBaseSpeedSystemInformationMsg(SPEEDSYSTEMINFORMATION1_NUMBER), + LevBaseSpeedSystemInformationMsg(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_NUMBER), LevBaseSpeedSystemInformation1() {} void LevSpeedSystemInformation1Msg::setBatteryTemperatureState(uint8_t state) { diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.cpp index 1c0572b..b4b3542 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.cpp @@ -1,5 +1,5 @@ #include -#include +#include #define BATTERYSOC_BYTE 1 #define BATTERYSOC_STATEOFCHARGE_MASK 0x7F @@ -36,7 +36,7 @@ LevSpeedSystemInformation2::LevSpeedSystemInformation2(AntRxDataResponse& dp) : LevBaseSpeedSystemInformation2() {} LevSpeedSystemInformation2Msg::LevSpeedSystemInformation2Msg() : - LevBaseSpeedSystemInformationMsg(SPEEDSYSTEMINFORMATION2_NUMBER), + LevBaseSpeedSystemInformationMsg(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION2_NUMBER), LevBaseSpeedSystemInformation2() {} void LevSpeedSystemInformation2Msg::setBatterySOC(uint8_t soc) { diff --git a/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.cpp b/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.cpp index 40ad714..db7b757 100644 --- a/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.cpp +++ b/src/Profiles/Lev/Profiles/ANTPLUS_ProfileLevDisplay.cpp @@ -38,22 +38,22 @@ bool ProfileLevDisplay::handleDataPage(LevBaseMainDataPage& dp) { switch (dataPage) { - case SPEEDSYSTEMINFORMATION1_NUMBER: + case ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_NUMBER: called = handleSpeedSystemInformation1(dp); break; - case SPEEDDISTANCEINFORMATION_NUMBER: + case ANTPLUS_LEV_DATAPAGE_SPEEDDISTANCEINFORMATION_NUMBER: called = handleSpeedDistanceInformation(dp); break; - case ALTSPEEDDISTANCEINFORMATION_NUMBER: + case ANTPLUS_LEV_DATAPAGE_ALTSPEEDDISTANCEINFORMATION_NUMBER: called = handleAltSpeedDistanceInformation(dp); break; - case SPEEDSYSTEMINFORMATION2_NUMBER: + case ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION2_NUMBER: called = handleSpeedSystemInformation2(dp); break; - case BATTERYINFORMATION_NUMBER: + case ANTPLUS_LEV_DATAPAGE_BATTERYINFORMATION_NUMBER: called = handleBatteryInformation(dp); break; - case LEVCAPABILITIES_NUMBER: + case ANTPLUS_LEV_DATAPAGE_LEVCAPABILITIES_NUMBER: called = handleCapabilities(dp); break; case ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER: From 93fd186ab825b2ba2631e8770863e8ae2ddb3a4a Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 5 Feb 2022 15:07:32 -0800 Subject: [PATCH 232/241] Environment: Datapage: make datapage number public should be a no-op --- src/Profiles/Environment/ANTPLUS_EnvironmentDefines.h | 5 +++++ src/Profiles/Environment/ANTPLUS_EnvironmentPrivateDefines.h | 3 --- .../Profiles/ANTPLUS_ProfileEnvironmentDisplay.cpp | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Profiles/Environment/ANTPLUS_EnvironmentDefines.h b/src/Profiles/Environment/ANTPLUS_EnvironmentDefines.h index c27db15..c85089c 100644 --- a/src/Profiles/Environment/ANTPLUS_EnvironmentDefines.h +++ b/src/Profiles/Environment/ANTPLUS_EnvironmentDefines.h @@ -3,7 +3,12 @@ #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 14fbe4e..b562204 100644 --- a/src/Profiles/Environment/ANTPLUS_EnvironmentPrivateDefines.h +++ b/src/Profiles/Environment/ANTPLUS_EnvironmentPrivateDefines.h @@ -8,7 +8,4 @@ // 45 / 2.5 = 18 #define ENVIRONMENT_SEARCHTIMEOUT 18 -#define ENVIRONMENT_GENERALINFORMATION_NUMBER 0 -#define ENVIRONMENT_TEMPERATURE_NUMBER 1 - #endif // ANTPLUS_ENVIRONMENTPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.cpp b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.cpp index 1c4428a..6de1902 100644 --- a/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.cpp +++ b/src/Profiles/Environment/Profiles/ANTPLUS_ProfileEnvironmentDisplay.cpp @@ -29,10 +29,10 @@ bool ProfileEnvironmentDisplay::handleDataPage(EnvironmentBaseDataPage& dp) { bool called = false; switch (dataPage) { - case ENVIRONMENT_GENERALINFORMATION_NUMBER: + case ANTPLUS_ENVIRONMENT_DATAPAGE_ENVIRONMENT_GENERALINFORMATION_NUMBER: called = handleGeneralInformation(dp); break; - case ENVIRONMENT_TEMPERATURE_NUMBER: + case ANTPLUS_ENVIRONMENT_DATAPAGE_ENVIRONMENT_TEMPERATURE_NUMBER: called = handleTemperature(dp); break; case ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER: From 0eaef3b9752bb7fbb4a1bfb1754e16e441f8ff26 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 5 Feb 2022 15:14:50 -0800 Subject: [PATCH 233/241] BicycleSpeed: DataPage: move datapage numbers to public this should be a no-op --- .../BicycleSpeed/ANTPLUS_BicycleSpeedDefines.h | 18 ++++++++++++++++++ .../ANTPLUS_BicycleSpeedPrivateDefines.h | 7 ------- .../ANTPLUS_ProfileBicycleSpeedDisplay.cpp | 12 ++++++------ 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedDefines.h b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedDefines.h index 73e5f80..dcd4b99 100644 --- a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedDefines.h +++ b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedDefines.h @@ -3,6 +3,21 @@ #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 @@ -10,6 +25,9 @@ #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 #endif // ANTPLUS_BICYCLESPEEDPROFILEDEFINES_h diff --git a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedPrivateDefines.h b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedPrivateDefines.h index 71c5193..4bd0381 100644 --- a/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedPrivateDefines.h +++ b/src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedPrivateDefines.h @@ -8,11 +8,4 @@ // 30 / 2.5 = 12 #define BICYCLESPEED_SEARCHTIMEOUT 12 -#define BICYCLESPEED_DEFAULT_NUMBER 0 -#define BICYCLESPEED_CUMULATIVEOPERATINGTIME_NUMBER 1 -#define BICYCLESPEED_MANUFACTURERID_NUMBER 2 -#define BICYCLESPEED_PRODUCTID_NUMBER 3 -#define BICYCLESPEED_BATTERYSTATUS_NUMBER 4 -#define BICYCLESPEED_MOTIONANDSPEED_NUMBER 5 - #endif // ANTPLUS_BICYCLESPEEDPROFILEPRIVATEDEFINES_h diff --git a/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.cpp b/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.cpp index e3c8cbc..3483695 100644 --- a/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.cpp +++ b/src/Profiles/BicycleSpeed/Profiles/ANTPLUS_ProfileBicycleSpeedDisplay.cpp @@ -28,22 +28,22 @@ bool ProfileBicycleSpeedDisplay::handleDataPage(BicycleSpeedBaseMainDataPage& dp bool called = false; switch (dataPage) { - case BICYCLESPEED_DEFAULT_NUMBER: + case ANTPLUS_BICYCLESPEED_DATAPAGE_DEFAULT_NUMBER: called = handleDefault(dp); break; - case BICYCLESPEED_CUMULATIVEOPERATINGTIME_NUMBER: + case ANTPLUS_BICYCLESPEED_DATAPAGE_CUMULATIVEOPERATINGTIME_NUMBER: called = handleCumulativeOperatingTime(dp); break; - case BICYCLESPEED_MANUFACTURERID_NUMBER: + case ANTPLUS_BICYCLESPEED_DATAPAGE_MANUFACTURERID_NUMBER: called = handleManufacturerID(dp); break; - case BICYCLESPEED_PRODUCTID_NUMBER: + case ANTPLUS_BICYCLESPEED_DATAPAGE_PRODUCTID_NUMBER: called = handleProductID(dp); break; - case BICYCLESPEED_BATTERYSTATUS_NUMBER: + case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERYSTATUS_NUMBER: called = handleBatteryStatus(dp); break; - case BICYCLESPEED_MOTIONANDSPEED_NUMBER: + case ANTPLUS_BICYCLESPEED_DATAPAGE_MOTIONANDSPEED_NUMBER: called = handleMotionAndSpeed(dp); break; } From 6d6e12eb883057a05403dba6785836ef313dfc24 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 5 Feb 2022 17:54:07 -0800 Subject: [PATCH 234/241] HeartRate: Update defines Move datapage numbers to public and add field definitions --- .../HeartRateDisplay/HeartRateDisplay.ino | 36 +++++++++++++++- .../HeartRate/ANTPLUS_HeartRateDefines.h | 43 +++++++++++++++++-- .../ANTPLUS_HeartRatePrivateDefines.h | 1 + .../ANTPLUS_HeartRateBatteryStatus.cpp | 7 ++- .../ANTPLUS_HeartRateCapabilities.cpp | 4 +- .../DataPages/ANTPLUS_HeartRateDefault.cpp | 4 +- 6 files changed, 83 insertions(+), 12 deletions(-) diff --git a/examples/HeartRateDisplay/HeartRateDisplay.ino b/examples/HeartRateDisplay/HeartRateDisplay.ino index 5f96109..77a61fa 100644 --- a/examples/HeartRateDisplay/HeartRateDisplay.ino +++ b/examples/HeartRateDisplay/HeartRateDisplay.ino @@ -73,12 +73,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) { diff --git a/src/Profiles/HeartRate/ANTPLUS_HeartRateDefines.h b/src/Profiles/HeartRate/ANTPLUS_HeartRateDefines.h index 8c88afc..6803d3a 100644 --- a/src/Profiles/HeartRate/ANTPLUS_HeartRateDefines.h +++ b/src/Profiles/HeartRate/ANTPLUS_HeartRateDefines.h @@ -5,16 +5,51 @@ #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 #define ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURES_EXTENDEDSWIMMING 0x04 #define ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURES_MANUFACTURER1 0x40 #define ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_FEATURES_MANUFACTURER2 0x80 -#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 16baa9c..a3a6961 100644 --- a/src/Profiles/HeartRate/ANTPLUS_HeartRatePrivateDefines.h +++ b/src/Profiles/HeartRate/ANTPLUS_HeartRatePrivateDefines.h @@ -7,6 +7,7 @@ #define HEARTRATE_SEARCHTIMEOUT 12 /* DataPage Numbers */ +#warning "derp" #define HEARTRATE_DEFAULT_NUMBER 0 #define HEARTRATE_CUMULATIVEOPERATINGTIME_NUMBER 1 #define HEARTRATE_MANUFACTURERINFORMATION_NUMBER 2 diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBatteryStatus.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBatteryStatus.cpp index b36f3f3..cf7b334 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBatteryStatus.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateBatteryStatus.cpp @@ -1,5 +1,5 @@ #include -#include +#include #define BATTERYLEVEL_BYTE 1 #define FRACTIONALBATTERYVOLTAGE_BYTE 2 @@ -43,8 +43,11 @@ HeartRateBatteryStatus::HeartRateBatteryStatus(AntRxDataResponse& dp) : HeartRateBaseBatteryStatus() {} HeartRateBatteryStatusMsg::HeartRateBatteryStatusMsg() : - HeartRateBaseMainDataPageMsg(HEARTRATE_BATTERYSTATUS_NUMBER), + 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) { diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCapabilities.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCapabilities.cpp index c81582d..cdfac9d 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCapabilities.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateCapabilities.cpp @@ -1,5 +1,5 @@ #include -#include +#include #define FEATURESSUPPORTED_BYTE 2 #define FEATURESENABLED_BYTE 3 @@ -27,7 +27,7 @@ HeartRateCapabilities::HeartRateCapabilities(AntRxDataResponse& dp) : HeartRateBaseCapabilities() {} HeartRateCapabilitiesMsg::HeartRateCapabilitiesMsg() : - HeartRateBaseMainDataPageMsg(HEARTRATE_CAPABILITIES_NUMBER), + HeartRateBaseMainDataPageMsg(ANTPLUS_HEARTRATE_DATAPAGE_CAPABILITIES_NUMBER), HeartRateBaseCapabilities() {} void HeartRateCapabilitiesMsg::setFeaturesSupported(uint8_t supported) { diff --git a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.cpp b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.cpp index d937db1..c8dcba1 100644 --- a/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.cpp +++ b/src/Profiles/HeartRate/DataPages/ANTPLUS_HeartRateDefault.cpp @@ -1,5 +1,5 @@ #include -#include +#include #define RESERVED_LSB_BYTE 1 #define RESERVED_MSB_BYTE 3 @@ -9,6 +9,6 @@ HeartRateDefault::HeartRateDefault(AntRxDataResponse& dp) : HeartRateBaseMainDataPage(dp) {} HeartRateDefaultMsg::HeartRateDefaultMsg() : - HeartRateBaseMainDataPageMsg(HEARTRATE_DEFAULT_NUMBER) { + HeartRateBaseMainDataPageMsg(ANTPLUS_HEARTRATE_DATAPAGE_DEFAULT_NUMBER) { set24BitValue(RESERVED_VALUE, RESERVED_LSB_BYTE, RESERVED_MSB_BYTE); } From 7f6e5357ad9a2a027578d6b09b564dc10219296b Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 5 Feb 2022 18:03:03 -0800 Subject: [PATCH 235/241] MuscleOxygen: datapages: move numbers to public defines this should be a no-op --- src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h | 6 ++++++ .../MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h | 7 ------- .../DataPages/ANTPLUS_MuscleOxygenCommands.cpp | 4 ++-- .../DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.cpp | 2 +- .../Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp | 2 +- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h index 959f4bb..3a5a38b 100644 --- a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h +++ b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h @@ -5,9 +5,15 @@ #define ANTPLUS_MUSCLEOXYGEN_FLAGS_BATTERYSTATUS_SUPPORTED (1 << 0) + +#define ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_NUMBER 1 + #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 index 736e396..54eb483 100644 --- a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h +++ b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenPrivateDefines.h @@ -9,11 +9,4 @@ // 30 / 2.5 = 12 #define MUSCLEOXYGEN_SEARCHTIMEOUT 12 -/* Pages */ -#define MUSCLEOXYGEN_MUSCLEOXYGENDATA_NUMBER 1 -#define MUSCLEOXYGEN_COMMANDS_NUMBER 16 - -// Base page */ -#define ANTPLUS_MUSCLEOXYGEN_DATAPAGEBASE_DATAPAGE_BYTE 0x00 - #endif // ANTPLUS_MUSCLEOXYGENPRIVATEDEFINES_h diff --git a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenCommands.cpp b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenCommands.cpp index 7e68609..f9440ae 100644 --- a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenCommands.cpp +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenCommands.cpp @@ -1,5 +1,5 @@ #include -#include +#include #define COMMANDID_BYTE 1 #define RESERVED_BYTE 2 @@ -36,7 +36,7 @@ MuscleOxygenCommands::MuscleOxygenCommands(AntRxDataResponse& dp) : MuscleOxygenBaseCommands() {} MuscleOxygenCommandsMsg::MuscleOxygenCommandsMsg() : - MuscleOxygenBaseMainDataPageMsg(MUSCLEOXYGEN_COMMANDS_NUMBER), + MuscleOxygenBaseMainDataPageMsg(ANTPLUS_MUSCLEOXYGEN_DATAPAGE_COMMANDS_NUMBER), MuscleOxygenBaseCommands() { set8BitValue(RESERVED_VALUE, RESERVED_BYTE); } diff --git a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.cpp b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.cpp index 742433d..5bfcaed 100644 --- a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.cpp +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.cpp @@ -58,7 +58,7 @@ uint16_t MuscleOxygenBaseMuscleOxygenData::getCurrentSaturatedHemoglobinPerce } MuscleOxygenMuscleOxygenDataMsg::MuscleOxygenMuscleOxygenDataMsg() : - MuscleOxygenBaseMainDataPageMsg(MUSCLEOXYGEN_MUSCLEOXYGENDATA_NUMBER), + MuscleOxygenBaseMainDataPageMsg(ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_NUMBER), MuscleOxygenBaseMuscleOxygenData() { setTotalHemoglobinConcentration( ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_TOTALHEMOGLOBINCONCENTRATION_INVALID); diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp index 6292e08..1fc2008 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp @@ -24,7 +24,7 @@ void ProfileMuscleOxygenMonitor::setChannelConfig() { bool ProfileMuscleOxygenMonitor::isDataPageValid(uint8_t dataPage) { switch (dataPage) { - case MUSCLEOXYGEN_MUSCLEOXYGENDATA_NUMBER: + case ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA_NUMBER: case ANTPLUS_COMMON_DATAPAGE_PRODUCTINFORMATION_NUMBER: case ANTPLUS_COMMON_DATAPAGE_MANUFACTURERSINFORMATION_NUMBER: return true; From 590c6abd6fdc4aa831296bfd042d11154212518d Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 5 Feb 2022 18:25:02 -0800 Subject: [PATCH 236/241] HeartRateDisplay: fix print --- examples/HeartRateDisplay/HeartRateDisplay.ino | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/HeartRateDisplay/HeartRateDisplay.ino b/examples/HeartRateDisplay/HeartRateDisplay.ino index 77a61fa..89f2dcc 100644 --- a/examples/HeartRateDisplay/HeartRateDisplay.ino +++ b/examples/HeartRateDisplay/HeartRateDisplay.ino @@ -72,7 +72,6 @@ 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 { From f6b4e05f55914473681368b9f5af012953e57776 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 6 Feb 2022 14:35:17 -0800 Subject: [PATCH 237/241] Lev: Fixes found during validation Also fix a bitfield design error, disjoint fields are the worst --- examples/LEVDisplay/LEVDisplay.ino | 1 + ...NTPLUS_LevBaseSpeedDistanceInformation.cpp | 4 ++-- .../ANTPLUS_LevBatteryInformation.cpp | 23 +++++++++++-------- .../Lev/DataPages/ANTPLUS_LevCapabilities.cpp | 2 +- .../ANTPLUS_LevSpeedSystemInformation1.cpp | 7 +++++- .../ANTPLUS_LevSpeedSystemInformation2.cpp | 7 +++++- 6 files changed, 29 insertions(+), 15 deletions(-) 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/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.cpp index 31b582e..63a23b9 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.cpp @@ -14,7 +14,7 @@ LevCoreSpeedDistanceInformation::LevCoreSpeedDistanceInformation() : template uint32_t LevCoreSpeedDistanceInformation::getOdometer() { // in km - return this->get32BitValue(ODOMETER_LSB_BYTE, ODOMETER_MSB_BYTE); + return this->get24BitValue(ODOMETER_LSB_BYTE, ODOMETER_MSB_BYTE); } template @@ -35,7 +35,7 @@ LevBaseSpeedDistanceInformationMsg::LevBaseSpeedDistanceInformationMsg(uint8_t d LevCoreSpeedDistanceInformation() {} void LevBaseSpeedDistanceInformationMsg::setOdometer(uint32_t odometer) { - set32BitValue(odometer, ODOMETER_LSB_BYTE, ODOMETER_MSB_BYTE); + set24BitValue(odometer, ODOMETER_LSB_BYTE, ODOMETER_MSB_BYTE); } void LevBaseSpeedDistanceInformationMsg::setLevSpeed(uint16_t speed) { diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.cpp index e32750f..0dfa56b 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevBatteryInformation.cpp @@ -7,9 +7,9 @@ #define CHARGINGCYCLECOUNT_MSB_BYTE 3 #define CHARGINGCYCLECOUNT_MASK 0x0FFF #define FUELCONSUMPTION_LSB_BYTE 4 -#define FUELCONSUMPTION_MSB_BYTE 3 -#define FUELCONSUMPTION_MASK 0xF0 -#define FUELCONSUMPTION_SHIFT 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 @@ -23,11 +23,13 @@ uint16_t LevBaseBatteryInformation::getChargingCycleCount() { 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->get16BitValue(FUELCONSUMPTION_LSB_BYTE, - FUELCONSUMPTION_MSB_BYTE, FUELCONSUMPTION_MASK, - FUELCONSUMPTION_SHIFT); + return this->get8BitValue(FUELCONSUMPTION_LSB_BYTE) | + (((uint16_t)this->get8BitValue(FUELCONSUMPTION_MSN_BYTE, + FUELCONSUMPTION_MSN_MASK, + FUELCONSUMPTION_MSN_SHIFT)) << BITS_IN_BYTE); } template @@ -60,11 +62,12 @@ void LevBatteryInformationMsg::setChargingCycleCount(uint16_t cycleCount) { CHARGINGCYCLECOUNT_MASK); } +// NOTE this a bit inverted field which results in the non-sense below void LevBatteryInformationMsg::setFuelConsumption(uint16_t consumption) { - set16BitValue(consumption, FUELCONSUMPTION_LSB_BYTE, - FUELCONSUMPTION_MSB_BYTE, - FUELCONSUMPTION_MASK, - FUELCONSUMPTION_SHIFT); + 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) { diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.cpp index 4b46ceb..ea94b6b 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevCapabilities.cpp @@ -7,7 +7,7 @@ #define TRAVELMODESSUPPORTED_NUMBERREGENERATIVEMODES_MASK 0x7 #define WHEELCIRCUMFERENCE_LSB_BYTE 3 #define WHEELCIRCUMFERENCE_MSB_BYTE 4 -#define WHEELCIRCUMFERENCE_MASK 0xF +#define WHEELCIRCUMFERENCE_MASK 0xFFF template LevBaseCapabilities::LevBaseCapabilities() : CoreDataPage() {} diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.cpp index a5ff2fe..f38018a 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation1.cpp @@ -10,6 +10,9 @@ #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() : @@ -57,7 +60,9 @@ LevSpeedSystemInformation1::LevSpeedSystemInformation1(AntRxDataResponse& dp) : LevSpeedSystemInformation1Msg::LevSpeedSystemInformation1Msg() : LevBaseSpeedSystemInformationMsg(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION1_NUMBER), - LevBaseSpeedSystemInformation1() {} + LevBaseSpeedSystemInformation1() { + set8BitValue(RESERVED_BYTE, RESERVED_MASK, RESERVED_SHIFT); +} void LevSpeedSystemInformation1Msg::setBatteryTemperatureState(uint8_t state) { set8BitValue(state, TEMPERATURESTATE_BYTE, diff --git a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.cpp b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.cpp index b4b3542..60a7dff 100644 --- a/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.cpp +++ b/src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedSystemInformation2.cpp @@ -6,6 +6,9 @@ #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() : @@ -37,7 +40,9 @@ LevSpeedSystemInformation2::LevSpeedSystemInformation2(AntRxDataResponse& dp) : LevSpeedSystemInformation2Msg::LevSpeedSystemInformation2Msg() : LevBaseSpeedSystemInformationMsg(ANTPLUS_LEV_DATAPAGE_SPEEDSYSTEMINFORMATION2_NUMBER), - LevBaseSpeedSystemInformation2() {} + LevBaseSpeedSystemInformation2() { + set8BitValue(RESERVED_BYTE, RESERVED_MASK, RESERVED_SHIFT); +} void LevSpeedSystemInformation2Msg::setBatterySOC(uint8_t soc) { set8BitValue(soc, BATTERYSOC_BYTE, BATTERYSOC_STATEOFCHARGE_MASK); From af5892830a72b3935059fa986c3fff9aa66d26a5 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 6 Feb 2022 19:03:52 -0800 Subject: [PATCH 238/241] Shifter: fixups from validation --- examples/ShiftingShifter/ShiftingShifter.ino | 11 ++++++++--- src/CommonDataPages/ANTPLUS_CommonDataPageDefines.h | 4 ++++ ...S_MultiComponentSystemManufacturersInformation.cpp | 3 +++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/examples/ShiftingShifter/ShiftingShifter.ino b/examples/ShiftingShifter/ShiftingShifter.ino index 150e4f6..11dbe53 100644 --- a/examples/ShiftingShifter/ShiftingShifter.ino +++ b/examples/ShiftingShifter/ShiftingShifter.ino @@ -62,10 +62,15 @@ void shiftSystemStatusMsgHandler(ShiftingShiftSystemStatusMsg& msg, uintptr_t da 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) { @@ -93,6 +98,6 @@ void batteryStatusMsgHandler(BatteryStatusMsg& msg, uintptr_t data) { msg.setCumulativeOperatingTime(123); msg.setFractionalBatteryVoltage(12); msg.setCoarseBatteryVoltage(12); - msg.setBatteryStatus(0); // TODO defines? - msg.setCumulativeOperatingTimeResolution(12); + msg.setBatteryStatus(ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_OK); + msg.setCumulativeOperatingTimeResolution(ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_CUMULATIVEOPERATINGTIMERESOLUTION_2S); } diff --git a/src/CommonDataPages/ANTPLUS_CommonDataPageDefines.h b/src/CommonDataPages/ANTPLUS_CommonDataPageDefines.h index 146cf59..f11f17d 100644 --- a/src/CommonDataPages/ANTPLUS_CommonDataPageDefines.h +++ b/src/CommonDataPages/ANTPLUS_CommonDataPageDefines.h @@ -47,6 +47,7 @@ /* 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 @@ -54,4 +55,7 @@ #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_MultiComponentSystemManufacturersInformation.cpp b/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp index 7d99573..18517f8 100644 --- a/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp +++ b/src/CommonDataPages/ANTPLUS_MultiComponentSystemManufacturersInformation.cpp @@ -2,6 +2,8 @@ #include #include +#define RESERVED_BYTE 1 +#define RESERVED_VALUE 0xFF #define COMPONENTIDENTIFIER_BYTE 2 #define COMPONENTIDENTIFIER_NUMBERCOMPONENTS_MASK 0x0F #define COMPONENTIDENTIFIER_IDENTIFIER_MASK 0xF0 @@ -58,6 +60,7 @@ MultiComponentSystemManufacturersInformationMsg::MultiComponentSystemManufacture set8BitValue( ANTPLUS_COMMON_DATAPAGE_MULTICOMPONENTSYSTEMMANUFACTURERSINFORMATION_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); + set8BitValue(RESERVED_VALUE, RESERVED_BYTE); } void MultiComponentSystemManufacturersInformationMsg::setNumberOfComponents(uint8_t count) { From 5e88cf0c34d7b8faf88fcdeda0d8e058405611a6 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 6 Feb 2022 19:07:39 -0800 Subject: [PATCH 239/241] ModeSettings: fix naming --- src/CommonDataPages/ANTPLUS_ModeSettings.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/CommonDataPages/ANTPLUS_ModeSettings.cpp b/src/CommonDataPages/ANTPLUS_ModeSettings.cpp index 1bd461a..412cddd 100644 --- a/src/CommonDataPages/ANTPLUS_ModeSettings.cpp +++ b/src/CommonDataPages/ANTPLUS_ModeSettings.cpp @@ -3,7 +3,7 @@ #include #define SPORTSMODE_BYTE 7 -#define RESERVED_BYTE 0xFF +#define RESERVED_VALUE 0xFF template BaseModeSettings::BaseModeSettings() : CoreDataPage() {} @@ -25,12 +25,12 @@ ModeSettingsMsg::ModeSettingsMsg() : BaseModeSettings() { setDataBuffer(_buffer); set8BitValue(ANTPLUS_COMMON_DATAPAGE_MODESETTINGS_NUMBER, ANTPLUS_DEFAULT_DATAPAGE_BYTE); - set8BitValue(RESERVED_BYTE, 1); - set8BitValue(RESERVED_BYTE, 2); - set8BitValue(RESERVED_BYTE, 3); - set8BitValue(RESERVED_BYTE, 4); - set8BitValue(RESERVED_BYTE, 5); - set8BitValue(RESERVED_BYTE, 6); + 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) { From f47af0f86e2b1aee60e9c07760c9b0ce474442f7 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 6 Feb 2022 19:57:34 -0800 Subject: [PATCH 240/241] MuscleOxygen: Fixes from validation fix transmission pattern and missing battery callback --- .../MuscleOxygenMonitor.ino | 12 ++++++++++ .../ANTPLUS_MuscleOxygenDefines.h | 9 +++++++ .../ANTPLUS_MuscleOxygenMuscleOxygenData.cpp | 24 +++++++++++++++---- .../ANTPLUS_MuscleOxygenMuscleOxygenData.h | 6 +++-- .../ANTPLUS_ProfileMuscleOxygenMonitor.cpp | 6 +++-- .../ANTPLUS_ProfileMuscleOxygenMonitor.h | 10 +++++--- 6 files changed, 56 insertions(+), 11 deletions(-) diff --git a/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino b/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino index 22ed4e8..41659f5 100644 --- a/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino +++ b/examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino @@ -48,28 +48,40 @@ 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/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h index 3a5a38b..95ccfb0 100644 --- a/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h +++ b/src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h @@ -8,6 +8,15 @@ #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 diff --git a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.cpp b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.cpp index 5bfcaed..5f06877 100644 --- a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.cpp +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.cpp @@ -4,6 +4,9 @@ #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 @@ -30,8 +33,15 @@ uint8_t MuscleOxygenBaseMuscleOxygenData::getNotifications() { } template -uint8_t MuscleOxygenBaseMuscleOxygenData::getCapabilities() { - return this->get8BitValue(CAPABILITIES_BYTE); +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 @@ -76,8 +86,14 @@ void MuscleOxygenMuscleOxygenDataMsg::setNotifications(uint8_t notifications) { set8BitValue(notifications, NOTIFICATIONS_BYTE); } -void MuscleOxygenMuscleOxygenDataMsg::setCapabilities(uint8_t capabilities) { - set8BitValue(capabilities, CAPABILITIES_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) { diff --git a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.h b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.h index 47654a4..bcdf394 100644 --- a/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.h +++ b/src/Profiles/MuscleOxygen/DataPages/ANTPLUS_MuscleOxygenMuscleOxygenData.h @@ -9,7 +9,8 @@ class MuscleOxygenBaseMuscleOxygenData : public virtual CoreDataPage { MuscleOxygenBaseMuscleOxygenData(); uint8_t getEventCount(); uint8_t getNotifications(); - uint8_t getCapabilities(); + uint8_t getAntFSSupport(); + uint8_t getMeasurementInterval(); uint16_t getTotalHemoglobinConcentration(); uint16_t getPreviousSaturatedHemoglobinPercentage(); uint16_t getCurrentSaturatedHemoglobinPercentage(); @@ -20,7 +21,8 @@ class MuscleOxygenMuscleOxygenDataMsg : public MuscleOxygenBaseMainDataPageMsg, MuscleOxygenMuscleOxygenDataMsg(); void setEventCount(uint8_t n); void setNotifications(uint8_t notficications); - void setCapabilities(uint8_t capabilities); + 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); diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp index 1fc2008..77a1a92 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.cpp @@ -40,9 +40,11 @@ void ProfileMuscleOxygenMonitor::transmitNextDataPage() { transmitMuscleOxygenMuscleOxygenDataMsg(); } else { - if ((_backgroundStep++ % _backgroundStepSize) == 0) { - transmitManufacturerInformationMsg(); + if (++_backgroundStep == _backgroundStepSize) { _backgroundStep = 0; + } + if ((_backgroundStep % _backgroundStepSize) == 0) { + transmitManufacturerInformationMsg(); } else if ((_backgroundStep % _backgroundStepSize) == 1) { transmitProductInformationMsg(); } else if (_flags & ANTPLUS_MUSCLEOXYGEN_FLAGS_BATTERYSTATUS_SUPPORTED) { diff --git a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h index 87ec99c..5ba8b9d 100644 --- a/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h +++ b/src/Profiles/MuscleOxygen/Monitor/ANTPLUS_ProfileMuscleOxygenMonitor.h @@ -11,17 +11,21 @@ class ProfileMuscleOxygenMonitor : public BaseMasterProfile { explicit ProfileMuscleOxygenMonitor(uint16_t deviceNumber, uint8_t transmissionType = 0, uint32_t flags = 0); /** - * Register callback to populate Muscle Oxygen data messages (Datapage 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 2) + * 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 3) + * 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; From c9d30803e8c11a160f5813ab0e2e1f94aae3a848 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sun, 6 Feb 2022 19:58:46 -0800 Subject: [PATCH 241/241] Release version 1.2.0 --- library.json | 2 +- library.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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