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
- Committer:
- loicguibert
- Date:
- 2019-05-29
- Revision:
- 22:79c64511d34d
- Parent:
- 18:7002e66af2e5
- Child:
- 23:f45027ac625c
File content as of revision 22:79c64511d34d:
#pragma once
#include "ble/BLE.h"
// for logging
#include "Logger.h"
#include "ReadNotifyGattCharacteristic.h"
class EnvironmentalService {
public:
typedef uint32_t PressureType_t;
typedef int16_t TemperatureType_t;
typedef uint16_t HumidityType_t;
typedef uint8_t PressureTrendType_t;
/**
* @brief BatteryService constructor.
* @param ble Reference to BLE device.
*/
EnvironmentalService(BLE& ble, Logger& logger);
/**
* Called after initialization of the BLE module for adding the service
* to the GATT server
*/
void addServiceToGattServer(void);
/**
* @brief Update pressure level characteristic.
* @param newPressure New pressure level measurement.
*/
void updatePressureLevel(PressureType_t newPressure);
/**
* @brief Update temperature level characteristic.
* @param newTemperature New temperature level measurement.
*/
void updateTemperatureLevel(TemperatureType_t newTemperature);
/**
* @brief Update humidity level characteristic.
* @param newHumidity New humidity level measurement.
*/
void updateHumidityLevel(HumidityType_t newHumidity);
/**
* @brief Update pressure trend characteristic.
* @param newPressureTrend New pressure trend measurement.
*/
void updatePressureTrend(uint32_t newPressureTrend);
private:
// data members
BLE& m_ble;
bool m_serviceAdded;
PressureType_t m_pressure;
TemperatureType_t m_temperature;
HumidityType_t m_humidity;
PressureTrendType_t m_pressureTrend;
// characteristics belonging to the service
ReadNotifyGattCharacteristic<PressureType_t> m_pressureCharacteristic;
ReadNotifyGattCharacteristic<TemperatureType_t> m_temperatureCharacteristic;
ReadNotifyGattCharacteristic<HumidityType_t> m_humidityCharacteristic;
ReadNotifyGattCharacteristic<PressureTrendType_t> m_pressureTrendCharacteristic;
// logger instance
Logger& m_logger;
// Enum for pressure trend
enum pressureTrendStates {
UNKNOWN = 0,
FALLING_CONTINUOUSLY = 1,
RISING_CONTINUOUSLY = 2,
FALLING_STEADY = 3,
RISING_STEADY = 4,
FALLING_LESSER_RISE = 5,
FALLING_GREATER_RISE = 6,
RISING_GREATER_RISE = 7,
RISING_LESSER_RISE = 8,
STEADY = 9
};
};