Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
EnvironmentalService.h@17:76787f5a334f, 2019-04-16 (annotated)
- Committer:
- loicguibert
- Date:
- Tue Apr 16 09:13:43 2019 +0000
- Revision:
- 17:76787f5a334f
- Parent:
- 16:eed9a9ba319c
- Child:
- 18:7002e66af2e5
qwf
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| loicguibert | 14:c5578b5edabe | 1 | #pragma once | 
| loicguibert | 14:c5578b5edabe | 2 | |
| loicguibert | 14:c5578b5edabe | 3 | #include "ble/BLE.h" | 
| loicguibert | 14:c5578b5edabe | 4 | // for logging | 
| loicguibert | 14:c5578b5edabe | 5 | #include "Logger.h" | 
| loicguibert | 17:76787f5a334f | 6 | #include "ReadNotifyGattCharacteristic.h" | 
| loicguibert | 14:c5578b5edabe | 7 | |
| loicguibert | 14:c5578b5edabe | 8 | class EnvironmentalService { | 
| loicguibert | 14:c5578b5edabe | 9 | public: | 
| loicguibert | 15:aac1b3950a9e | 10 | |
| loicguibert | 15:aac1b3950a9e | 11 | typedef uint32_t PressureType_t; | 
| loicguibert | 15:aac1b3950a9e | 12 | typedef int16_t TemperatureType_t; | 
| loicguibert | 15:aac1b3950a9e | 13 | typedef uint16_t HumidityType_t; | 
| loicguibert | 16:eed9a9ba319c | 14 | typedef uint8_t PressureTrendType_t; | 
| loicguibert | 14:c5578b5edabe | 15 | |
| loicguibert | 14:c5578b5edabe | 16 | /** | 
| loicguibert | 14:c5578b5edabe | 17 | * @brief BatteryService constructor. | 
| loicguibert | 14:c5578b5edabe | 18 | * @param ble Reference to BLE device. | 
| loicguibert | 14:c5578b5edabe | 19 | */ | 
| loicguibert | 14:c5578b5edabe | 20 | EnvironmentalService(BLE& ble, Logger& logger); | 
| loicguibert | 14:c5578b5edabe | 21 | |
| loicguibert | 14:c5578b5edabe | 22 | /** | 
| loicguibert | 14:c5578b5edabe | 23 | * Called after initialization of the BLE module for adding the service | 
| loicguibert | 14:c5578b5edabe | 24 | * to the GATT server | 
| loicguibert | 14:c5578b5edabe | 25 | */ | 
| loicguibert | 14:c5578b5edabe | 26 | void addServiceToGattServer(void); | 
| loicguibert | 14:c5578b5edabe | 27 | |
| loicguibert | 14:c5578b5edabe | 28 | /** | 
| loicguibert | 14:c5578b5edabe | 29 | * @brief Update battery level characteristic. | 
| loicguibert | 14:c5578b5edabe | 30 | * @param newBatteryLevelVal New battery level measurement. | 
| loicguibert | 14:c5578b5edabe | 31 | */ | 
| loicguibert | 16:eed9a9ba319c | 32 | void updateEnvironmentalService(PressureType_t newPressure, TemperatureType_t newTemperature, HumidityType_t newHumidity, uint32_t newPressureTrend); | 
| loicguibert | 14:c5578b5edabe | 33 | |
| loicguibert | 14:c5578b5edabe | 34 | private: | 
| loicguibert | 14:c5578b5edabe | 35 | // data members | 
| loicguibert | 14:c5578b5edabe | 36 | BLE& m_ble; | 
| loicguibert | 14:c5578b5edabe | 37 | bool m_serviceAdded; | 
| loicguibert | 14:c5578b5edabe | 38 | |
| loicguibert | 16:eed9a9ba319c | 39 | PressureType_t m_pressure; | 
| loicguibert | 16:eed9a9ba319c | 40 | TemperatureType_t m_temperature; | 
| loicguibert | 16:eed9a9ba319c | 41 | HumidityType_t m_humidity; | 
| loicguibert | 16:eed9a9ba319c | 42 | PressureTrendType_t m_pressureTrend; | 
| loicguibert | 14:c5578b5edabe | 43 | |
| loicguibert | 14:c5578b5edabe | 44 | // characteristics belonging to the service | 
| loicguibert | 17:76787f5a334f | 45 | ReadNotifyGattCharacteristic<PressureType_t> m_pressureCharacteristic; | 
| loicguibert | 17:76787f5a334f | 46 | ReadNotifyGattCharacteristic<TemperatureType_t> m_temperatureCharacteristic; | 
| loicguibert | 17:76787f5a334f | 47 | ReadNotifyGattCharacteristic<HumidityType_t> m_humidityCharacteristic; | 
| loicguibert | 17:76787f5a334f | 48 | ReadNotifyGattCharacteristic<PressureTrendType_t> m_pressureTrendCharacteristic; | 
| loicguibert | 14:c5578b5edabe | 49 | |
| loicguibert | 14:c5578b5edabe | 50 | // logger instance | 
| loicguibert | 14:c5578b5edabe | 51 | Logger& m_logger; | 
| loicguibert | 16:eed9a9ba319c | 52 | |
| loicguibert | 16:eed9a9ba319c | 53 | // Enum for pressure trend | 
| loicguibert | 16:eed9a9ba319c | 54 | enum pressureTrendStates { | 
| loicguibert | 16:eed9a9ba319c | 55 | UNKNOWN, | 
| loicguibert | 16:eed9a9ba319c | 56 | FALLING_CONTINUOUSLY, | 
| loicguibert | 16:eed9a9ba319c | 57 | RISING_CONTINUOUSLY, | 
| loicguibert | 16:eed9a9ba319c | 58 | FALLING_STEADY, | 
| loicguibert | 16:eed9a9ba319c | 59 | RISING_STEADY, | 
| loicguibert | 16:eed9a9ba319c | 60 | FALLING_LESSER_RISE, | 
| loicguibert | 16:eed9a9ba319c | 61 | FALLING_GREATER_RISE, | 
| loicguibert | 16:eed9a9ba319c | 62 | RISING_GREATER_RISE, | 
| loicguibert | 16:eed9a9ba319c | 63 | RISING_LESSER_RISE, | 
| loicguibert | 16:eed9a9ba319c | 64 | STEADY | 
| loicguibert | 16:eed9a9ba319c | 65 | }; | 
| loicguibert | 14:c5578b5edabe | 66 | }; |