Geo beacon for VF.

Dependencies:   MMA8452 aconno_bsp adc52832_common

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers AckService.h Source File

AckService.h

00001 /*
00002  *
00003  * Made by Jurica Resetar @ aconno
00004  * More info @ aconno.de
00005  * All right reserved
00006  *
00007  */
00008 
00009 #define MAC_ADDR_SIZE_B (6)
00010 
00011 // Template allows you to use 'constant' values on non-constant places (XD)
00012 template<uint8_t dataSize>
00013 
00014 class ACKService{
00015     public:
00016         const static uint16_t ACK_SERVICE_UUID = 0xA000;
00017         const static uint16_t ACK_CHARA_UUID = 0xA001;
00018         const static uint16_t ACK_MAC_CHAR_UUID = 0xA002;
00019 
00020         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){
00021                 GattCharacteristic *charTable[] = {&ACK, &MAC};     // Add characteristick in table
00022                 GattService AckService(ACK_SERVICE_UUID, charTable, sizeof(charTable)/sizeof(GattCharacteristic *));   
00023                 ble.addService(AckService); // Add service in the BLE
00024         }
00025         inline void updateMacAddress(uint8_t  *MacAddress){
00026             ble.gattServer().write(MAC.getValueHandle(), MacAddress, MAC_ADDR_SIZE_B);
00027         }
00028         
00029         inline GattAttribute::Handle_t getACKCharacteristicHandle(){
00030             return ACK.getValueHandle();
00031         }
00032     private:
00033         BLEDevice &ble;
00034         // Create new characteristic
00035         WriteOnlyArrayGattCharacteristic<uint8_t, dataSize> ACK;
00036         ReadOnlyArrayGattCharacteristic<uint8_t, MAC_ADDR_SIZE_B> MAC;
00037 };