Skip to content

Commit

Permalink
MuscleOxygen: Fixes from validation
Browse files Browse the repository at this point in the history
fix transmission pattern and missing battery callback
  • Loading branch information
cujomalainey committed Feb 7, 2022
1 parent 5e88cf0 commit f47af0f
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 11 deletions.
12 changes: 12 additions & 0 deletions examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions src/Profiles/MuscleOxygen/ANTPLUS_MuscleOxygenDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,8 +33,15 @@ uint8_t MuscleOxygenBaseMuscleOxygenData<T>::getNotifications() {
}

template<class T>
uint8_t MuscleOxygenBaseMuscleOxygenData<T>::getCapabilities() {
return this->get8BitValue(CAPABILITIES_BYTE);
uint8_t MuscleOxygenBaseMuscleOxygenData<T>::getAntFSSupport() {
return this->get8BitValue(CAPABILITIES_BYTE, ANTFSSUPPORT_MASK);
}

template<class T>
uint8_t MuscleOxygenBaseMuscleOxygenData<T>::getMeasurementInterval() {
return this->get8BitValue(CAPABILITIES_BYTE,
MEASUREMENTINTERVAL_MASK,
MEASUREMENTINTERVAL_SHIFT);
}

template<class T>
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class MuscleOxygenBaseMuscleOxygenData : public virtual CoreDataPage<T> {
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();
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f47af0f

Please sign in to comment.