2021-09-09 21:11:32 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2024-02-16 07:20:45 +00:00
|
|
|
/*
|
|
|
|
* Battery service. Can be used in most profiles.
|
|
|
|
* If auto_update is true, the service will automatically update the battery
|
|
|
|
* level and charging state from power state updates.
|
|
|
|
*/
|
2021-09-13 11:25:37 +00:00
|
|
|
|
2024-02-16 07:20:45 +00:00
|
|
|
typedef struct BleServiceBattery BleServiceBattery;
|
2021-09-09 21:11:32 +00:00
|
|
|
|
2024-02-16 07:20:45 +00:00
|
|
|
BleServiceBattery* ble_svc_battery_start(bool auto_update);
|
2021-12-08 11:28:01 +00:00
|
|
|
|
2024-02-16 07:20:45 +00:00
|
|
|
void ble_svc_battery_stop(BleServiceBattery* service);
|
2021-09-09 21:11:32 +00:00
|
|
|
|
2024-02-16 07:20:45 +00:00
|
|
|
bool ble_svc_battery_update_level(BleServiceBattery* service, uint8_t battery_level);
|
|
|
|
|
|
|
|
bool ble_svc_battery_update_power_state(BleServiceBattery* service, bool charging);
|
|
|
|
|
|
|
|
/* Global function, callable without a service instance
|
|
|
|
* Will update all service instances created with auto_update==true
|
|
|
|
* Both parameters are optional, pass NULL if no value is available
|
|
|
|
*/
|
|
|
|
void ble_svc_battery_state_update(uint8_t* battery_level, bool* charging);
|
2022-05-24 13:42:02 +00:00
|
|
|
|
2021-09-09 21:11:32 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|