20#warning "These services are deprecated and will be removed. Please see services.md for details about replacement services."
22#ifndef __BLE_ENVIRONMENTAL_SERVICE_H__
23#define __BLE_ENVIRONMENTAL_SERVICE_H__
27#include "ble/GattServer.h"
29#if BLE_FEATURE_GATT_SERVER
41 typedef int16_t TemperatureType_t;
42 typedef uint16_t HumidityType_t;
43 typedef uint32_t PressureType_t;
55 static bool serviceAdded =
false;
61 &pressureCharacteristic,
62 &temperatureCharacteristic };
66 ble.gattServer().addService(environmentalService);
76 humidity = (HumidityType_t) (newHumidityVal * 100);
77 ble.gattServer().write(humidityCharacteristic.
getValueHandle(), (uint8_t *) &humidity,
sizeof(HumidityType_t));
86 pressure = (PressureType_t) (newPressureVal * 10);
87 ble.gattServer().write(pressureCharacteristic.
getValueHandle(), (uint8_t *) &pressure,
sizeof(PressureType_t));
96 temperature = (TemperatureType_t) (newTemperatureVal * 100);
97 ble.gattServer().write(temperatureCharacteristic.
getValueHandle(), (uint8_t *) &temperature,
sizeof(TemperatureType_t));
103 TemperatureType_t temperature{};
104 HumidityType_t humidity{};
105 PressureType_t pressure{};
BLE Environmental Service.
void updateTemperature(float newTemperatureVal)
Update temperature characteristic.
void updatePressure(PressureType_t newPressureVal)
Update pressure characteristic.
void updateHumidity(HumidityType_t newHumidityVal)
Update humidity characteristic.
EnvironmentalService(BLE &_ble)
EnvironmentalService constructor.
Representation of a GattServer characteristic.
GattAttribute::Handle_t getValueHandle() const
Get the characteristic's value attribute handle in the ATT table.
Representation of a GattServer service.
@ UUID_ENVIRONMENTAL_SERVICE
UUID of the environmental service.
Helper class that represents a read only GattCharacteristic.
Abstract away BLE-capable radio transceivers or SOCs.
Entry namespace for all BLE API definitions.