aconno acnsensa project for iOS devices with iBeacon packets support.

Dependencies:   LSM9DS1 Si7006A20 aconno_SEGGER_RTT aconno_bsp adc52832_common

service.h

Committer:
jurica238814
Date:
2018-08-01
Branch:
iBeacon
Revision:
16:e86a91db0b72
Child:
36:9e40cdef6bd6

File content as of revision 16:e86a91db0b72:

/*
 *
 * Made by Jurica Resetar @ aconno
 * More info @ aconno.de
 * All right reserved
 *
 */

#define MAC_ADDR_SIZE_B (6)

class MACService{
    public:
        const static uint16_t SERVICE_UUID = 0xA000;
        const static uint16_t MAC_CHAR_UUID = 0xA002;

        MACService(BLEDevice &_ble, uint8_t *mac) : ble(_ble),
                MAC(MAC_CHAR_UUID, mac)
                {
                // Add characteristic in table
                GattCharacteristic *charTable[] = {&MAC};
                GattService MACService(SERVICE_UUID, charTable,
                    sizeof(charTable)/sizeof(GattCharacteristic *));
                ble.addService(MACService); // Add service in the BLE
        }
        inline void updateMacAddress(uint8_t  *MacAddress){
            ble.gattServer().write(MAC.getValueHandle(),
            MacAddress, MAC_ADDR_SIZE_B);
        }
    private:
        BLEDevice &ble;
        // Create new characteristic
        ReadOnlyArrayGattCharacteristic<uint8_t, MAC_ADDR_SIZE_B> MAC;
};