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{};
112 #endif // BLE_FEATURE_GATT_SERVER void updateHumidity(HumidityType_t newHumidityVal)
Update humidity characteristic.
GattAttribute::Handle_t getValueHandle() const
Get the characteristic's value attribute handle in the ATT table.
BLE Environmental Service.
void updatePressure(PressureType_t newPressureVal)
Update pressure characteristic.
EnvironmentalService(BLE &_ble)
EnvironmentalService constructor.
Representation of a GattServer characteristic.
UUID of the environmental service.
Representation of a GattServer service.
void updateTemperature(float newTemperatureVal)
Update temperature characteristic.
Entry namespace for all BLE API definitions.
Abstract away BLE-capable radio transceivers or SOCs.