19 #ifndef __BLE_ENVIRONMENTAL_SERVICE_H__ 20 #define __BLE_ENVIRONMENTAL_SERVICE_H__ 24 #include "ble/GattServer.h" 26 #if BLE_FEATURE_GATT_SERVER 38 typedef int16_t TemperatureType_t;
39 typedef uint16_t HumidityType_t;
40 typedef uint32_t PressureType_t;
52 static bool serviceAdded =
false;
58 &pressureCharacteristic,
59 &temperatureCharacteristic };
63 ble.gattServer().addService(environmentalService);
73 humidity = (HumidityType_t) (newHumidityVal * 100);
74 ble.gattServer().write(humidityCharacteristic.
getValueHandle(), (uint8_t *) &humidity,
sizeof(HumidityType_t));
83 pressure = (PressureType_t) (newPressureVal * 10);
84 ble.gattServer().write(pressureCharacteristic.
getValueHandle(), (uint8_t *) &pressure,
sizeof(PressureType_t));
93 temperature = (TemperatureType_t) (newTemperatureVal * 100);
94 ble.gattServer().write(temperatureCharacteristic.
getValueHandle(), (uint8_t *) &temperature,
sizeof(TemperatureType_t));
100 TemperatureType_t temperature{};
101 HumidityType_t humidity{};
102 PressureType_t pressure{};
109 #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.
UUID of the environmental service.
BLE Environmental Service.
void updatePressure(PressureType_t newPressureVal)
Update pressure characteristic.
EnvironmentalService(BLE &_ble)
EnvironmentalService constructor.
Representation of a GattServer characteristic.
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.