Adaptation of SMPIR for the Window Sensor Module of the Agile-IoT project.
Dependencies: BLE_API mbed nRF51822
Fork of SensorModulePIR by
HumidityMeasureService.h@22:88b6e11eb8d5, 2018-06-06 (annotated)
- Committer:
- MisterGiet
- Date:
- Wed Jun 06 14:53:43 2018 +0000
- Revision:
- 22:88b6e11eb8d5
- Parent:
- 3:53db6c57bb61
Modification for Window Sensor Module for the Agile IoT final review.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MisterGiet | 3:53db6c57bb61 | 1 | #ifndef __BLE_HUMIDITY_MEASURE_SERVICE_H__ |
MisterGiet | 3:53db6c57bb61 | 2 | #define __BLE_HUMIDITY_MEASURE_SERVICE_H__ |
MisterGiet | 3:53db6c57bb61 | 3 | |
MisterGiet | 3:53db6c57bb61 | 4 | class HumidityMeasureService { |
MisterGiet | 3:53db6c57bb61 | 5 | public: |
MisterGiet | 3:53db6c57bb61 | 6 | const static uint16_t HUMIDITY_MEASURE_SERVICE_UUID = 0xA004; |
MisterGiet | 3:53db6c57bb61 | 7 | const static uint16_t HUMIDITY_CHARACTERISTIC_UUID = 0xA005; |
MisterGiet | 3:53db6c57bb61 | 8 | |
MisterGiet | 3:53db6c57bb61 | 9 | HumidityMeasureService(BLEDevice &_ble, float humidity) : |
MisterGiet | 3:53db6c57bb61 | 10 | ble(_ble), |
MisterGiet | 3:53db6c57bb61 | 11 | humidityValue(HUMIDITY_CHARACTERISTIC_UUID, &humidity, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ) |
MisterGiet | 3:53db6c57bb61 | 12 | { |
MisterGiet | 3:53db6c57bb61 | 13 | GattCharacteristic *charTable[] = {&humidityValue}; |
MisterGiet | 3:53db6c57bb61 | 14 | GattService getHumidityService(HUMIDITY_MEASURE_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); |
MisterGiet | 3:53db6c57bb61 | 15 | ble.addService(getHumidityService); |
MisterGiet | 3:53db6c57bb61 | 16 | } |
MisterGiet | 3:53db6c57bb61 | 17 | |
MisterGiet | 3:53db6c57bb61 | 18 | GattAttribute::Handle_t getValueHandle() const { |
MisterGiet | 3:53db6c57bb61 | 19 | return humidityValue.getValueHandle(); |
MisterGiet | 3:53db6c57bb61 | 20 | } |
MisterGiet | 3:53db6c57bb61 | 21 | |
MisterGiet | 3:53db6c57bb61 | 22 | void updateHumidity(uint8_t newHum) { |
MisterGiet | 3:53db6c57bb61 | 23 | ble.gattServer().write(humidityValue.getValueHandle(), &newHum, 1); |
MisterGiet | 3:53db6c57bb61 | 24 | } |
MisterGiet | 3:53db6c57bb61 | 25 | |
MisterGiet | 3:53db6c57bb61 | 26 | public: |
MisterGiet | 3:53db6c57bb61 | 27 | BLEDevice &ble; |
MisterGiet | 3:53db6c57bb61 | 28 | ReadWriteGattCharacteristic<float> humidityValue; |
MisterGiet | 3:53db6c57bb61 | 29 | }; |
MisterGiet | 3:53db6c57bb61 | 30 | |
MisterGiet | 3:53db6c57bb61 | 31 | #endif /* #ifndef __BLE_HUMIDITY_MEASURE_SERVICE_H__ */ |