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@15:aac1b3950a9e, 2019-04-16 (annotated)
- Committer:
- loicguibert
- Date:
- Tue Apr 16 07:22:47 2019 +0000
- Revision:
- 15:aac1b3950a9e
- Parent:
- 14:c5578b5edabe
- Child:
- 16:eed9a9ba319c
TP.04 part. 3 done
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 | 14:c5578b5edabe | 6 | |
| loicguibert | 14:c5578b5edabe | 7 | class EnvironmentalService { |
| loicguibert | 14:c5578b5edabe | 8 | public: |
| loicguibert | 15:aac1b3950a9e | 9 | |
| loicguibert | 15:aac1b3950a9e | 10 | typedef uint32_t PressureType_t; |
| loicguibert | 15:aac1b3950a9e | 11 | typedef int16_t TemperatureType_t; |
| loicguibert | 15:aac1b3950a9e | 12 | typedef uint16_t HumidityType_t; |
| loicguibert | 14:c5578b5edabe | 13 | |
| loicguibert | 14:c5578b5edabe | 14 | /** |
| loicguibert | 14:c5578b5edabe | 15 | * @brief BatteryService constructor. |
| loicguibert | 14:c5578b5edabe | 16 | * @param ble Reference to BLE device. |
| loicguibert | 14:c5578b5edabe | 17 | */ |
| loicguibert | 14:c5578b5edabe | 18 | EnvironmentalService(BLE& ble, Logger& logger); |
| loicguibert | 14:c5578b5edabe | 19 | |
| loicguibert | 14:c5578b5edabe | 20 | /** |
| loicguibert | 14:c5578b5edabe | 21 | * Called after initialization of the BLE module for adding the service |
| loicguibert | 14:c5578b5edabe | 22 | * to the GATT server |
| loicguibert | 14:c5578b5edabe | 23 | */ |
| loicguibert | 14:c5578b5edabe | 24 | void addServiceToGattServer(void); |
| loicguibert | 14:c5578b5edabe | 25 | |
| loicguibert | 14:c5578b5edabe | 26 | /** |
| loicguibert | 14:c5578b5edabe | 27 | * @brief Update battery level characteristic. |
| loicguibert | 14:c5578b5edabe | 28 | * @param newBatteryLevelVal New battery level measurement. |
| loicguibert | 14:c5578b5edabe | 29 | */ |
| loicguibert | 15:aac1b3950a9e | 30 | void updateEnvironmentalService(PressureType_t newPressure, TemperatureType_t newTemperature, HumidityType_t newHumidity); |
| loicguibert | 14:c5578b5edabe | 31 | |
| loicguibert | 14:c5578b5edabe | 32 | private: |
| loicguibert | 14:c5578b5edabe | 33 | // data members |
| loicguibert | 14:c5578b5edabe | 34 | BLE& m_ble; |
| loicguibert | 14:c5578b5edabe | 35 | bool m_serviceAdded; |
| loicguibert | 14:c5578b5edabe | 36 | |
| loicguibert | 15:aac1b3950a9e | 37 | PressureType_t m_pressure; |
| loicguibert | 15:aac1b3950a9e | 38 | TemperatureType_t m_temperature; |
| loicguibert | 15:aac1b3950a9e | 39 | HumidityType_t m_humidity; |
| loicguibert | 14:c5578b5edabe | 40 | |
| loicguibert | 14:c5578b5edabe | 41 | // characteristics belonging to the service |
| loicguibert | 15:aac1b3950a9e | 42 | ReadOnlyGattCharacteristic<PressureType_t> m_pressureCharacteristic; |
| loicguibert | 15:aac1b3950a9e | 43 | ReadOnlyGattCharacteristic<TemperatureType_t> m_temperatureCharacteristic; |
| loicguibert | 15:aac1b3950a9e | 44 | ReadOnlyGattCharacteristic<HumidityType_t> m_humidityCharacteristic; |
| loicguibert | 14:c5578b5edabe | 45 | |
| loicguibert | 14:c5578b5edabe | 46 | // logger instance |
| loicguibert | 14:c5578b5edabe | 47 | Logger& m_logger; |
| loicguibert | 14:c5578b5edabe | 48 | }; |