17 #ifndef __BLE_ENVIRONMENTAL_SERVICE_H__ 18 #define __BLE_ENVIRONMENTAL_SERVICE_H__ 22 #if BLE_FEATURE_GATT_SERVER 34 typedef int16_t TemperatureType_t;
35 typedef uint16_t HumidityType_t;
36 typedef uint32_t PressureType_t;
48 static bool serviceAdded =
false;
54 &pressureCharacteristic,
55 &temperatureCharacteristic };
59 ble.gattServer().addService(environmentalService);
69 humidity = (HumidityType_t) (newHumidityVal * 100);
70 ble.gattServer().write(humidityCharacteristic.
getValueHandle(), (uint8_t *) &humidity,
sizeof(HumidityType_t));
79 pressure = (PressureType_t) (newPressureVal * 10);
80 ble.gattServer().write(pressureCharacteristic.
getValueHandle(), (uint8_t *) &pressure,
sizeof(PressureType_t));
89 temperature = (TemperatureType_t) (newTemperatureVal * 100);
90 ble.gattServer().write(temperatureCharacteristic.
getValueHandle(), (uint8_t *) &temperature,
sizeof(TemperatureType_t));
96 TemperatureType_t temperature;
97 HumidityType_t humidity;
98 PressureType_t pressure;
105 #endif // BLE_FEATURE_GATT_SERVER void updateHumidity(HumidityType_t newHumidityVal)
Update humidity characteristic.
Abstract away BLE-capable radio transceivers or SOCs.
BLE Environmental Service.
void updatePressure(PressureType_t newPressureVal)
Update pressure characteristic.
EnvironmentalService(BLE &_ble)
EnvironmentalService constructor.
Representation of a GattServer characteristic.
GattAttribute::Handle_t getValueHandle(void) const
Get the characteristic's value attribute handle in the ATT table.
UUID of the environmental service.
Representation of a GattServer service.
void updateTemperature(float newTemperatureVal)
Update temperature characteristic.
Entry namespace for all BLE API definitions.