Adaptation of SMPIR for the Window Sensor Module of the Agile-IoT project.

Dependencies:   BLE_API mbed nRF51822

Fork of SensorModulePIR by ModoSmart

TemperatureMeasureService.h

Committer:
MisterGiet
Date:
2018-06-06
Revision:
22:88b6e11eb8d5
Parent:
0:eb280529b0ef
Child:
2:cb698f3be3f1

File content as of revision 22:88b6e11eb8d5:

#ifndef __BLE_TEMPERATURE_MEASURE_SERVICE_H__
#define __BLE_TEMPERATURE_MEASURE_SERVICE_H__

class TemperatureMeasureService {
public:
    const static uint16_t TEMPERATURE_MEASURE_SERVICE_UUID = 0xA002;
    const static uint16_t TEMPERATURE_CHARACTERISTIC_UUID = 0xA003;

    TemperatureMeasureService(BLEDevice &_ble, float temperature) :
        ble(_ble), 
        temperatureValue(TEMPERATURE_CHARACTERISTIC_UUID, &temperature, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY)
    {
        GattCharacteristic *charTable[] = {&temperatureValue};
        GattService         getTemperatureService(TEMPERATURE_MEASURE_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
        ble.addService(getTemperatureService);
    }

    GattAttribute::Handle_t getValueHandle() const {
        return temperatureValue.getValueHandle();
    }
    
    void updateTemperature(uint8_t newTemp) {
        ble.gattServer().write(temperatureValue.getValueHandle(), &newTemp, 1);
    }

public:
    BLEDevice                         &ble;
    ReadWriteGattCharacteristic<float>  temperatureValue;
};

#endif /* #ifndef __BLE_TEMPERATURE_MEASURE_SERVICE_H__ */