certain services like the batteryService and heartRateService don't need to be singletons.

This commit is contained in:
Rohit Grover 2015-06-13 00:14:52 +01:00
parent 33e1d6f93a
commit 1298a1dda9
2 changed files with 0 additions and 13 deletions

View file

@ -38,16 +38,10 @@ public:
batteryLevel(level),
batteryLevelCharacteristic(GattCharacteristic::UUID_BATTERY_LEVEL_CHAR, &batteryLevel, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) {
static bool serviceAdded = false; /* We should only ever need to add the heart rate service once. */
if (serviceAdded) {
return;
}
GattCharacteristic *charTable[] = {&batteryLevelCharacteristic};
GattService batteryService(GattService::UUID_BATTERY_SERVICE, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
ble.addService(batteryService);
serviceAdded = true;
}
/**

View file

@ -127,17 +127,10 @@ public:
private:
void setupService(void) {
static bool serviceAdded = false; /* We should only ever need to add the heart rate service once. */
if (serviceAdded) {
return;
}
GattCharacteristic *charTable[] = {&hrmRate, &hrmLocation, &controlPoint};
GattService hrmService(GattService::UUID_HEART_RATE_SERVICE, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
ble.addService(hrmService);
serviceAdded = true;
ble.onDataWritten(this, &HeartRateService::onDataWritten);
}