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@22:79c64511d34d, 2019-05-29 (annotated)
- Committer:
- loicguibert
- Date:
- Wed May 29 06:36:54 2019 +0000
- Revision:
- 22:79c64511d34d
- Parent:
- 18:7002e66af2e5
- Child:
- 23:f45027ac625c
EnvironmentalService modified: each characteristic splitted
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 | 22:79c64511d34d | 29 | * @brief Update pressure level characteristic. |
| loicguibert | 22:79c64511d34d | 30 | * @param newPressure New pressure level measurement. |
| loicguibert | 22:79c64511d34d | 31 | */ |
| loicguibert | 22:79c64511d34d | 32 | void updatePressureLevel(PressureType_t newPressure); |
| loicguibert | 22:79c64511d34d | 33 | |
| loicguibert | 22:79c64511d34d | 34 | /** |
| loicguibert | 22:79c64511d34d | 35 | * @brief Update temperature level characteristic. |
| loicguibert | 22:79c64511d34d | 36 | * @param newTemperature New temperature level measurement. |
| loicguibert | 22:79c64511d34d | 37 | */ |
| loicguibert | 22:79c64511d34d | 38 | void updateTemperatureLevel(TemperatureType_t newTemperature); |
| loicguibert | 22:79c64511d34d | 39 | |
| loicguibert | 22:79c64511d34d | 40 | /** |
| loicguibert | 22:79c64511d34d | 41 | * @brief Update humidity level characteristic. |
| loicguibert | 22:79c64511d34d | 42 | * @param newHumidity New humidity level measurement. |
| loicguibert | 22:79c64511d34d | 43 | */ |
| loicguibert | 22:79c64511d34d | 44 | void updateHumidityLevel(HumidityType_t newHumidity); |
| loicguibert | 22:79c64511d34d | 45 | |
| loicguibert | 22:79c64511d34d | 46 | /** |
| loicguibert | 22:79c64511d34d | 47 | * @brief Update pressure trend characteristic. |
| loicguibert | 22:79c64511d34d | 48 | * @param newPressureTrend New pressure trend measurement. |
| loicguibert | 22:79c64511d34d | 49 | */ |
| loicguibert | 22:79c64511d34d | 50 | void updatePressureTrend(uint32_t newPressureTrend); |
| loicguibert | 14:c5578b5edabe | 51 | |
| loicguibert | 14:c5578b5edabe | 52 | private: |
| loicguibert | 14:c5578b5edabe | 53 | // data members |
| loicguibert | 14:c5578b5edabe | 54 | BLE& m_ble; |
| loicguibert | 14:c5578b5edabe | 55 | bool m_serviceAdded; |
| loicguibert | 14:c5578b5edabe | 56 | |
| loicguibert | 16:eed9a9ba319c | 57 | PressureType_t m_pressure; |
| loicguibert | 16:eed9a9ba319c | 58 | TemperatureType_t m_temperature; |
| loicguibert | 16:eed9a9ba319c | 59 | HumidityType_t m_humidity; |
| loicguibert | 16:eed9a9ba319c | 60 | PressureTrendType_t m_pressureTrend; |
| loicguibert | 14:c5578b5edabe | 61 | |
| loicguibert | 14:c5578b5edabe | 62 | // characteristics belonging to the service |
| loicguibert | 17:76787f5a334f | 63 | ReadNotifyGattCharacteristic<PressureType_t> m_pressureCharacteristic; |
| loicguibert | 17:76787f5a334f | 64 | ReadNotifyGattCharacteristic<TemperatureType_t> m_temperatureCharacteristic; |
| loicguibert | 17:76787f5a334f | 65 | ReadNotifyGattCharacteristic<HumidityType_t> m_humidityCharacteristic; |
| loicguibert | 17:76787f5a334f | 66 | ReadNotifyGattCharacteristic<PressureTrendType_t> m_pressureTrendCharacteristic; |
| loicguibert | 14:c5578b5edabe | 67 | |
| loicguibert | 14:c5578b5edabe | 68 | // logger instance |
| loicguibert | 14:c5578b5edabe | 69 | Logger& m_logger; |
| loicguibert | 16:eed9a9ba319c | 70 | |
| loicguibert | 16:eed9a9ba319c | 71 | // Enum for pressure trend |
| loicguibert | 16:eed9a9ba319c | 72 | enum pressureTrendStates { |
| loicguibert | 18:7002e66af2e5 | 73 | UNKNOWN = 0, |
| loicguibert | 18:7002e66af2e5 | 74 | FALLING_CONTINUOUSLY = 1, |
| loicguibert | 18:7002e66af2e5 | 75 | RISING_CONTINUOUSLY = 2, |
| loicguibert | 18:7002e66af2e5 | 76 | FALLING_STEADY = 3, |
| loicguibert | 18:7002e66af2e5 | 77 | RISING_STEADY = 4, |
| loicguibert | 18:7002e66af2e5 | 78 | FALLING_LESSER_RISE = 5, |
| loicguibert | 18:7002e66af2e5 | 79 | FALLING_GREATER_RISE = 6, |
| loicguibert | 18:7002e66af2e5 | 80 | RISING_GREATER_RISE = 7, |
| loicguibert | 18:7002e66af2e5 | 81 | RISING_LESSER_RISE = 8, |
| loicguibert | 18:7002e66af2e5 | 82 | STEADY = 9 |
| loicguibert | 16:eed9a9ba319c | 83 | }; |
| loicguibert | 14:c5578b5edabe | 84 | }; |