yes Spada / Mbed OS programme
Revision:
14:c5578b5edabe
Child:
17:76787f5a334f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BatteryService.h	Tue Apr 02 09:51:34 2019 +0000
@@ -0,0 +1,42 @@
+#pragma once
+
+#include "ble/BLE.h"
+
+// for logging
+#include "Logger.h"
+
+class BatteryService {
+public:
+  typedef int8_t BatteryLevelType_t;
+  
+  /**
+   * @brief   BatteryService constructor.
+   * @param   ble Reference to BLE device.
+   */
+  BatteryService(BLE& ble, Logger& logger);
+  
+  /**
+   * Called after initialization of the BLE module for adding the service
+   * to the GATT server
+   */
+  void addServiceToGattServer(void);
+   
+  /**
+   * @brief   Update battery level characteristic.
+   * @param   newBatteryLevelVal New battery level measurement.
+   */
+  void updateBatteryLevel(BatteryLevelType_t newBatteryLevelVal);
+
+private:
+  // data members
+  BLE& m_ble;
+  bool m_serviceAdded;
+
+  BatteryLevelType_t m_batteryLevel;
+  
+  // characteristics belonging to the service
+  ReadOnlyGattCharacteristic<BatteryLevelType_t> m_batteryLevelCharacteristic;
+    
+  // logger instance
+  Logger& m_logger;
+};