![](/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
Diff: DHT11_BLEService.h
- Revision:
- 1:023e1eae2048
- Parent:
- 0:d2c18f736df1
--- a/DHT11_BLEService.h Fri Apr 07 11:36:47 2017 +0000 +++ b/DHT11_BLEService.h Tue Apr 18 14:08:50 2017 +0000 @@ -4,7 +4,7 @@ class DHT11Service { public: - const static uint16_t DHT11_UUID = 0x2A61;//False UUID does not exists + const static uint16_t DHT11_UUID = 0xA100;//False UUID does not exists const static uint16_t TEMPERATURE_CHARACTERISTIC_UUID = 0x2A6E; const static uint16_t HUMIDITY_CHARACTERISTIC_UUID = 0x2A6F; @@ -13,13 +13,13 @@ /*temperatureValue(TEMPERATURE_CHARACTERISTIC_UUID,&initialTempValue),*/ temperatureValue(TEMPERATURE_CHARACTERISTIC_UUID, &initialTempValue, - sizeof(uint32_t), - sizeof(uint32_t), + sizeof(uint8_t), + sizeof(uint8_t), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY), humidityValue(HUMIDITY_CHARACTERISTIC_UUID, &initialHumiValue, - sizeof(uint32_t), - sizeof(uint32_t), + sizeof(uint8_t), + sizeof(uint8_t), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) /*humidityValue(HUMIDITY_CHARACTERISTIC_UUID,&initialHumiValue)*/ { @@ -29,15 +29,15 @@ } - /*GattAttribute::Handle_t getValueHandle() const { + 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 updateTemperatureValue(uint8_t value) { + ble.gattServer().write(temperatureValue.getValueHandle(), (uint8_t *)&value, sizeof(uint8_t)); } - void updateHumidityValue(uint32_t value) { - ble.gattServer().write(humidityValue.getValueHandle(), (uint8_t *)&value, sizeof(uint32_t)); + void updateHumidityValue(uint8_t value) { + ble.gattServer().write(humidityValue.getValueHandle(), (uint8_t *)&value, sizeof(uint8_t)); } private: