aconno acnsensa project for iOS devices with iBeacon packets support.
Dependencies: LSM9DS1 Si7006A20 aconno_SEGGER_RTT aconno_bsp adc52832_common
service.h@38:c90e1670ffb3, 2018-08-17 (annotated)
- Committer:
- dbartolovic
- Date:
- Fri Aug 17 10:45:24 2018 +0000
- Branch:
- sensaformatfix
- Revision:
- 38:c90e1670ffb3
- Parent:
- 36:9e40cdef6bd6
Added service advertisement to telemetry data
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| jurica238814 | 16:e86a91db0b72 | 1 | /* |
| jurica238814 | 16:e86a91db0b72 | 2 | * |
| jurica238814 | 16:e86a91db0b72 | 3 | * Made by Jurica Resetar @ aconno |
| jurica238814 | 16:e86a91db0b72 | 4 | * More info @ aconno.de |
| jurica238814 | 16:e86a91db0b72 | 5 | * All right reserved |
| jurica238814 | 16:e86a91db0b72 | 6 | * |
| jurica238814 | 16:e86a91db0b72 | 7 | */ |
| jurica238814 | 16:e86a91db0b72 | 8 | |
| dbartolovic | 36:9e40cdef6bd6 | 9 | #include "service_macros.h" |
| dbartolovic | 36:9e40cdef6bd6 | 10 | |
| jurica238814 | 16:e86a91db0b72 | 11 | #define MAC_ADDR_SIZE_B (6) |
| jurica238814 | 16:e86a91db0b72 | 12 | |
| dbartolovic | 36:9e40cdef6bd6 | 13 | extern const int advDataSize; |
| dbartolovic | 36:9e40cdef6bd6 | 14 | |
| jurica238814 | 16:e86a91db0b72 | 15 | class MACService{ |
| jurica238814 | 16:e86a91db0b72 | 16 | public: |
| jurica238814 | 16:e86a91db0b72 | 17 | const static uint16_t SERVICE_UUID = 0xA000; |
| dbartolovic | 36:9e40cdef6bd6 | 18 | const static uint16_t ADV_DATA_UUID = 0xA001; |
| jurica238814 | 16:e86a91db0b72 | 19 | const static uint16_t MAC_CHAR_UUID = 0xA002; |
| jurica238814 | 16:e86a91db0b72 | 20 | |
| dbartolovic | 36:9e40cdef6bd6 | 21 | MACService(BLEDevice &_ble, uint8_t *mac, uint8_t *initAdvData) : ble(_ble), |
| dbartolovic | 36:9e40cdef6bd6 | 22 | MAC(MAC_CHAR_UUID, mac), |
| dbartolovic | 36:9e40cdef6bd6 | 23 | advData(ADV_DATA_UUID, initAdvData, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) |
| jurica238814 | 16:e86a91db0b72 | 24 | { |
| jurica238814 | 16:e86a91db0b72 | 25 | // Add characteristic in table |
| dbartolovic | 36:9e40cdef6bd6 | 26 | GattCharacteristic *charTable[] = {&MAC, &advData}; |
| jurica238814 | 16:e86a91db0b72 | 27 | GattService MACService(SERVICE_UUID, charTable, |
| jurica238814 | 16:e86a91db0b72 | 28 | sizeof(charTable)/sizeof(GattCharacteristic *)); |
| jurica238814 | 16:e86a91db0b72 | 29 | ble.addService(MACService); // Add service in the BLE |
| jurica238814 | 16:e86a91db0b72 | 30 | } |
| jurica238814 | 16:e86a91db0b72 | 31 | inline void updateMacAddress(uint8_t *MacAddress){ |
| jurica238814 | 16:e86a91db0b72 | 32 | ble.gattServer().write(MAC.getValueHandle(), |
| jurica238814 | 16:e86a91db0b72 | 33 | MacAddress, MAC_ADDR_SIZE_B); |
| jurica238814 | 16:e86a91db0b72 | 34 | } |
| dbartolovic | 36:9e40cdef6bd6 | 35 | |
| dbartolovic | 36:9e40cdef6bd6 | 36 | CHARACTERISTIC_A(ReadOnly, uint8_t, 25, advData, AdvData); |
| dbartolovic | 36:9e40cdef6bd6 | 37 | |
| jurica238814 | 16:e86a91db0b72 | 38 | private: |
| jurica238814 | 16:e86a91db0b72 | 39 | BLEDevice &ble; |
| jurica238814 | 16:e86a91db0b72 | 40 | // Create new characteristic |
| jurica238814 | 16:e86a91db0b72 | 41 | ReadOnlyArrayGattCharacteristic<uint8_t, MAC_ADDR_SIZE_B> MAC; |
| jurica238814 | 16:e86a91db0b72 | 42 | }; |


