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 TemperatureMeasureService.h Source File

TemperatureMeasureService.h

00001 #ifndef __BLE_TEMPERATURE_MEASURE_SERVICE_H__
00002 #define __BLE_TEMPERATURE_MEASURE_SERVICE_H__
00003 
00004 class TemperatureMeasureService {
00005 public:
00006     const static uint16_t TEMPERATURE_MEASURE_SERVICE_UUID = 0xA002;
00007     const static uint16_t TEMPERATURE_CHARACTERISTIC_UUID = 0xA003;
00008 
00009     TemperatureMeasureService(BLEDevice &_ble, float temperature) :
00010         ble(_ble), 
00011         temperatureValue(TEMPERATURE_CHARACTERISTIC_UUID, &temperature, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY)
00012     {
00013         GattCharacteristic *charTable[] = {&temperatureValue};
00014         GattService         getTemperatureService(TEMPERATURE_MEASURE_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
00015         ble.addService(getTemperatureService);
00016     }
00017 
00018     GattAttribute::Handle_t getValueHandle() const {
00019         return temperatureValue.getValueHandle();
00020     }
00021     
00022     void updateTemperature(uint8_t newTemp) {
00023         ble.gattServer().write(temperatureValue.getValueHandle(), &newTemp, 1);
00024     }
00025 
00026 public:
00027     BLEDevice                         &ble;
00028     ReadWriteGattCharacteristic<float>  temperatureValue;
00029 };
00030 
00031 #endif /* #ifndef __BLE_TEMPERATURE_MEASURE_SERVICE_H__ */