Jurica Resetar / Mbed OS aconnoBLETemplate
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers service.h Source File

service.h

00001 /*
00002  * Made by Jurica @ aconno
00003  * All rights reserved
00004  *
00005  */
00006 
00007 #ifndef SERVICE_H
00008 #define SERVICE_H
00009 
00010 #define TIMESTAMP_SIZE_B    (6)
00011 
00012 static const uint16_t SERVICE_UUID = 0xA3B6;
00013 static const uint16_t NTP_CHARACTERISTIC_UUID = 0x33CC;
00014 
00015 class Service{
00016     public:
00017         Service(BLEDevice &ble) : ble(ble), time(NTP_CHARACTERISTIC_UUID, 0){
00018         // Add characteristics to the table
00019         GattCharacteristic *characteristics[] = {&time};
00020         GattService service(SERVICE_UUID, characteristics,
00021             sizeof(characteristics)/sizeof(*characteristics));
00022         ble.addService(service); // Add service in the BLE
00023         }
00024         inline GattAttribute::Handle_t getTimeCharacteristicHandle()
00025         {
00026             return time.getValueHandle();
00027         }
00028     private:
00029         BLEDevice &ble;
00030         // New characteristics names time
00031         WriteOnlyArrayGattCharacteristic<uint8_t, TIMESTAMP_SIZE_B> time;
00032 };
00033 #endif