![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Project aiming to do a Bluetooth Low Energy IoT devices, which measure temperature and humidity. Bluetooth achieved with the IDB05A1 shield. Temperature/humidity achieved with a DHT11 sensor. Project working, tested on an STM32 L476 board.
Dependencies: BLE_API X_NUCLEO_IDB0XA1 mbed
DHT11_BLEService.h
- Committer:
- ledonger
- Date:
- 2017-04-07
- Revision:
- 0:d2c18f736df1
- Child:
- 1:023e1eae2048
File content as of revision 0:d2c18f736df1:
#ifndef __BLE_DHT11_SERVICE_H__ #define __BLE_DHT11_SERVICE_H__ class DHT11Service { public: const static uint16_t DHT11_UUID = 0x2A61;//False UUID does not exists const static uint16_t TEMPERATURE_CHARACTERISTIC_UUID = 0x2A6E; const static uint16_t HUMIDITY_CHARACTERISTIC_UUID = 0x2A6F; DHT11Service(BLEDevice &_ble, uint8_t initialTempValue, uint8_t initialHumiValue) : ble(_ble), /*temperatureValue(TEMPERATURE_CHARACTERISTIC_UUID,&initialTempValue),*/ temperatureValue(TEMPERATURE_CHARACTERISTIC_UUID, &initialTempValue, sizeof(uint32_t), sizeof(uint32_t), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY), humidityValue(HUMIDITY_CHARACTERISTIC_UUID, &initialHumiValue, sizeof(uint32_t), sizeof(uint32_t), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) /*humidityValue(HUMIDITY_CHARACTERISTIC_UUID,&initialHumiValue)*/ { GattCharacteristic *charTable[] = {&temperatureValue,&humidityValue}; GattService service(DHT11_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); ble.addService(service); } /*GattAttribute::Handle_t getValueHandle() const { return temperatureValue.getValueHandle(); }*/ void updateTemperatureValue(uint32_t value) { ble.gattServer().write(temperatureValue.getValueHandle(), (uint8_t *)&value, sizeof(uint32_t)); } void updateHumidityValue(uint32_t value) { ble.gattServer().write(humidityValue.getValueHandle(), (uint8_t *)&value, sizeof(uint32_t)); } private: BLEDevice &ble; GattCharacteristic temperatureValue; GattCharacteristic humidityValue; }; #endif