Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
BatteryService.h
- Committer:
- loicguibert
- Date:
- 2019-04-16
- Revision:
- 17:76787f5a334f
- Parent:
- 14:c5578b5edabe
File content as of revision 17:76787f5a334f:
#pragma once
#include "ble/BLE.h"
// for logging
#include "Logger.h"
#include "ReadNotifyGattCharacteristic.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
ReadNotifyGattCharacteristic<BatteryLevelType_t> m_batteryLevelCharacteristic;
// logger instance
Logger& m_logger;
};