Workings and tests to create custom GATT services, for use as part of peripheral communication in cars
Dependencies: BLE_API mbed nRF51822
Diff: BroadcasterService.h
- Revision:
- 8:3376f79e7d50
- Parent:
- 7:5c983cf3c352
- Child:
- 9:0ed64b14d46b
--- a/BroadcasterService.h Tue Feb 24 14:55:44 2015 +0000 +++ b/BroadcasterService.h Tue Feb 24 15:38:16 2015 +0000 @@ -15,21 +15,27 @@ * * @param[in] */ + + const static uint16_t BROADCAST_SERVICE_UUID = 0x2A67; + const static uint16_t BROADCAST_CHARACTERISTIC_UUID = 0x1817; + BroadcasterService(BLEDevice &_ble, uint8_t _command) : ble(_ble), command(_command), - broadcasterCharacteristic(0x2A67, &command, sizeof(command), sizeof(command), + + broadcasterCharacteristic(BROADCAST_CHARACTERISTIC_UUID, &command, sizeof(command), sizeof(command), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | // GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) { + static bool serviceAdded = false; /* We should only ever need to add the service once. */ if (serviceAdded) { return; } GattCharacteristic *charTable[] = {&broadcasterCharacteristic}; - GattService broadcasterService(0x1817, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); + GattService broadcasterService(BroadcasterService::BROADCAST_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); ble.addService(broadcasterService); serviceAdded = true;