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:
- 9:0ed64b14d46b
- Parent:
- 8:3376f79e7d50
- Child:
- 10:2c5c202c69a5
--- a/BroadcasterService.h Tue Feb 24 15:38:16 2015 +0000 +++ b/BroadcasterService.h Thu Mar 12 12:52:26 2015 +0000 @@ -19,11 +19,11 @@ const static uint16_t BROADCAST_SERVICE_UUID = 0x2A67; const static uint16_t BROADCAST_CHARACTERISTIC_UUID = 0x1817; - BroadcasterService(BLEDevice &_ble, uint8_t _command) : + BroadcasterService(BLEDevice &_ble) : //, uint8_t _command[8] ble(_ble), - command(_command), + command(), //instead of command(_command); - broadcasterCharacteristic(BROADCAST_CHARACTERISTIC_UUID, &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) { @@ -46,15 +46,17 @@ * * @param */ - void sendCommand(uint8_t _newCommand) { - command = _newCommand; - ble.updateCharacteristicValue(broadcasterCharacteristic.getValueAttribute().getHandle(), &command, 1); + void sendCommand(uint8_t _newCommand[8]) { +// command = _newCommand; + + memcpy(command, _newCommand, sizeof(_newCommand)); + ble.updateCharacteristicValue(broadcasterCharacteristic.getValueAttribute().getHandle(), command, 8, false); } private: - BLEDevice &ble; - uint8_t command; - GattCharacteristic broadcasterCharacteristic; + BLEDevice &ble; + uint8_t command[8]; + GattCharacteristic broadcasterCharacteristic; }; #endif \ No newline at end of file