Geo beacon for VF.
Dependencies: MMA8452 aconno_bsp adc52832_common
AckService.h@25:8ac3ff431ab1, 2017-09-06 (annotated)
- Committer:
- jurica238814
- Date:
- Wed Sep 06 10:41:09 2017 +0000
- Revision:
- 25:8ac3ff431ab1
- Parent:
- 18:e844d3e6ab88
- Child:
- 27:2c67f07590fd
Before implementing our pwm driver.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jurica238814 | 16:a338d2417fd5 | 1 | |
jurica238814 | 16:a338d2417fd5 | 2 | #define MAC_ADDR_SIZE_B (6) |
jurica238814 | 16:a338d2417fd5 | 3 | |
jurica238814 | 16:a338d2417fd5 | 4 | // Template allows you to use 'constant' values on non-constant places (XD) |
jurica238814 | 16:a338d2417fd5 | 5 | template<uint8_t dataSize> |
jurica238814 | 16:a338d2417fd5 | 6 | |
jurica238814 | 16:a338d2417fd5 | 7 | class ACKService{ |
jurica238814 | 16:a338d2417fd5 | 8 | public: |
jurica238814 | 18:e844d3e6ab88 | 9 | const static uint16_t ACK_SERVICE_UUID = 0xA000; |
jurica238814 | 16:a338d2417fd5 | 10 | const static uint16_t ACK_CHARA_UUID = 0xA001; |
jurica238814 | 16:a338d2417fd5 | 11 | const static uint16_t ACK_MAC_CHAR_UUID = 0xA002; |
jurica238814 | 16:a338d2417fd5 | 12 | |
jurica238814 | 16:a338d2417fd5 | 13 | ACKService(BLEDevice &_ble, uint8_t *_initValues) : ble(_ble), ACK(ACK_CHARA_UUID, _initValues), MAC(ACK_MAC_CHAR_UUID, _initValues, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY){ |
jurica238814 | 16:a338d2417fd5 | 14 | GattCharacteristic *charTable[] = {&ACK, &MAC}; // Add characteristick in table |
jurica238814 | 16:a338d2417fd5 | 15 | GattService AckService(ACK_SERVICE_UUID, charTable, sizeof(charTable)/sizeof(GattCharacteristic *)); |
jurica238814 | 16:a338d2417fd5 | 16 | ble.addService(AckService); // Add service in the BLE |
jurica238814 | 16:a338d2417fd5 | 17 | } |
jurica238814 | 25:8ac3ff431ab1 | 18 | inline void updateMacAddress(uint8_t *MacAddress){ |
jurica238814 | 16:a338d2417fd5 | 19 | ble.gattServer().write(MAC.getValueHandle(), MacAddress, MAC_ADDR_SIZE_B); |
jurica238814 | 16:a338d2417fd5 | 20 | } |
jurica238814 | 25:8ac3ff431ab1 | 21 | |
jurica238814 | 25:8ac3ff431ab1 | 22 | inline GattAttribute::Handle_t getACKCharacteristicHandle(){ |
jurica238814 | 25:8ac3ff431ab1 | 23 | return ACK.getValueHandle(); |
jurica238814 | 25:8ac3ff431ab1 | 24 | } |
jurica238814 | 16:a338d2417fd5 | 25 | private: |
jurica238814 | 16:a338d2417fd5 | 26 | BLEDevice &ble; |
jurica238814 | 16:a338d2417fd5 | 27 | // Create new characteristic |
jurica238814 | 16:a338d2417fd5 | 28 | WriteOnlyArrayGattCharacteristic<uint8_t, dataSize> ACK; |
jurica238814 | 16:a338d2417fd5 | 29 | ReadOnlyArrayGattCharacteristic<uint8_t, MAC_ADDR_SIZE_B> MAC; |
jurica238814 | 16:a338d2417fd5 | 30 | }; |