ModoSmart / Mbed 2 deprecated WindowSensorModule

Dependencies:   BLE_API mbed nRF51822

Fork of SensorModulePIR by ModoSmart

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PresenceDetectionService.h Source File

PresenceDetectionService.h

00001 #ifndef __BLE_PRESENCE_DETECTION_SERVICE_H__
00002 #define __BLE_PRESENCE_DETECTION_SERVICE_H__
00003 
00004 class PresenceDetectionService {
00005 public:
00006     const static uint16_t PRESENCE_DETECTION_SERVICE_UUID = 0xA000;
00007     const static uint16_t PRESENCE_CHARACTERISTIC_UUID = 0xA001;
00008 
00009     PresenceDetectionService(BLEDevice &_ble, uint8_t presence) :
00010         ble(_ble), 
00011         presenceValue(PRESENCE_CHARACTERISTIC_UUID, &presence, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY)
00012     {
00013         GattCharacteristic *charTable[] = {&presenceValue};
00014         GattService         getPresenceService(PRESENCE_DETECTION_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
00015         ble.addService(getPresenceService);
00016     }
00017 
00018     GattAttribute::Handle_t getValueHandle() const {
00019         return presenceValue.getValueHandle();
00020     }
00021     
00022     void updatePresence(uint8_t newPresence) {
00023         ble.gattServer().write(presenceValue.getValueHandle(), &newPresence, 1);
00024     }
00025 
00026 public:
00027     BLEDevice                         &ble;
00028     ReadWriteGattCharacteristic<uint8_t>  presenceValue;
00029 };
00030 
00031 #endif /* #ifndef __BLE_PRESENCE_DETECTION_SERVICE_H__ */