Locator mobile firmware
Dependencies: BLE_API mbed nRF51822
Fork of BLE_Observer by
posService.h@9:3e967b414bd5, 2017-04-30 (annotated)
- Committer:
- sycorax
- Date:
- Sun Apr 30 12:30:24 2017 +0000
- Revision:
- 9:3e967b414bd5
Added a PosService for Broadcasting the measured distances
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sycorax | 9:3e967b414bd5 | 1 | #include "ble/BLE.h" |
sycorax | 9:3e967b414bd5 | 2 | |
sycorax | 9:3e967b414bd5 | 3 | class PosService { |
sycorax | 9:3e967b414bd5 | 4 | public: |
sycorax | 9:3e967b414bd5 | 5 | typedef uint8_t dist_t[3]; |
sycorax | 9:3e967b414bd5 | 6 | ReadOnlyGattCharacteristic<dist_t> distanceCharacteristic; |
sycorax | 9:3e967b414bd5 | 7 | |
sycorax | 9:3e967b414bd5 | 8 | PosService(BLE& _ble) : |
sycorax | 9:3e967b414bd5 | 9 | ble(_ble), |
sycorax | 9:3e967b414bd5 | 10 | distanceCharacteristic(0x2A59, &pos) |
sycorax | 9:3e967b414bd5 | 11 | { |
sycorax | 9:3e967b414bd5 | 12 | GattCharacteristic *charTable[] = { &distanceCharacteristic }; |
sycorax | 9:3e967b414bd5 | 13 | GattService posService(0x2601, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); |
sycorax | 9:3e967b414bd5 | 14 | ble.gattServer().addService(posService); |
sycorax | 9:3e967b414bd5 | 15 | } |
sycorax | 9:3e967b414bd5 | 16 | |
sycorax | 9:3e967b414bd5 | 17 | void updatePos(dist_t poss) { |
sycorax | 9:3e967b414bd5 | 18 | |
sycorax | 9:3e967b414bd5 | 19 | //ble.gattServer().write(distanceCharacteristic.getValueHandle(), &poss, 1); |
sycorax | 9:3e967b414bd5 | 20 | } |
sycorax | 9:3e967b414bd5 | 21 | private: |
sycorax | 9:3e967b414bd5 | 22 | BLE& ble; |
sycorax | 9:3e967b414bd5 | 23 | |
sycorax | 9:3e967b414bd5 | 24 | dist_t pos; |
sycorax | 9:3e967b414bd5 | 25 | }; |