yes Spada / Mbed OS programme
Revision:
15:aac1b3950a9e
Parent:
14:c5578b5edabe
Child:
16:eed9a9ba319c
--- a/EnvironmentalService.cpp	Tue Apr 02 09:51:34 2019 +0000
+++ b/EnvironmentalService.cpp	Tue Apr 16 07:22:47 2019 +0000
@@ -5,7 +5,9 @@
 EnvironmentalService::EnvironmentalService(BLE& ble, Logger& logger)
 : m_ble(ble),
   m_serviceAdded(false),
-  //m_batteryLevelCharacteristic(GattCharacteristic::UUID_BATTERY_LEVEL_CHAR, &m_batteryLevel),
+  m_pressureCharacteristic(GattCharacteristic::UUID_PRESSURE_CHAR, &m_pressure),
+  m_temperatureCharacteristic(GattCharacteristic::UUID_TEMPERATURE_CHAR, &m_temperature),
+  m_humidityCharacteristic(GattCharacteristic::UUID_HUMIDITY_CHAR, &m_humidity),
   m_logger(logger) {
 }
 
@@ -15,18 +17,25 @@
     return;
   }
 
-  //GattCharacteristic *charTable[] = { &m_batteryLevelCharacteristic };
+  GattCharacteristic *charTable[] = {
+                                      &m_pressureCharacteristic,
+                                      &m_temperatureCharacteristic,
+                                      &m_humidityCharacteristic
+                                     };
                                       
-  //GattService environmentalService(GattService::UUID_ENVIRONMENTAL_SERVICE, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
-  //m_ble.gattServer().addService(environmentalService);
+  GattService environmentalService(GattService::UUID_ENVIRONMENTAL_SERVICE, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
+  m_ble.gattServer().addService(environmentalService);
   
   m_serviceAdded = true;
   
   m_logger.log("Environmental service added\r\n");
 }
 
- /*void EnvironmentalService::updateEnvironmentalValues(BatteryLevelType_t newBatteryLevelVal) {
-  m_batteryLevel = newBatteryLevelVal;
-  m_ble.gattServer().write(m_batteryLevelCharacteristic.getValueHandle(), (uint8_t *) &m_batteryLevel, sizeof(BatteryLevelType_t));
+void EnvironmentalService::updateEnvironmentalService(PressureType_t newPressure, TemperatureType_t newTemperature, HumidityType_t newHumidity) {
+  m_pressure = newPressure;
+  m_temperature = newTemperature;
+  m_humidity = newHumidity;  
+  m_ble.gattServer().write(m_pressureCharacteristic.getValueHandle(), (uint8_t *) &m_pressure, sizeof(PressureType_t));
+  m_ble.gattServer().write(m_temperatureCharacteristic.getValueHandle(), (uint8_t *) &m_temperature, sizeof(m_temperature));
+  m_ble.gattServer().write(m_humidityCharacteristic.getValueHandle(), (uint8_t *) &m_humidity, sizeof(m_humidity));
 }
-*/