bas.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (C) 2020 Koen Zandberg <koen@bergzand.net>
  3. *
  4. * This file is subject to the terms and conditions of the GNU Lesser
  5. * General Public License v2.1. See the file LICENSE in the top level
  6. * directory for more details.
  7. */
  8. #ifndef _APP_BLEMAN_BAS_H
  9. #define _APP_BLEMAN_BAS_H
  10. #include <stdint.h>
  11. #include "event.h"
  12. #include "event/timeout.h"
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. /**
  17. * @brief Controller battery measurement interval in milliseconds
  18. */
  19. #ifndef BLEMAN_BATTERY_UPDATE_INTERVAL
  20. #define BLEMAN_BATTERY_UPDATE_INTERVAL 30 * MS_PER_SEC
  21. #endif
  22. typedef struct {
  23. event_timeout_t evt; /**< Event timeout for battery notifications */
  24. event_t ev; /**< Event for battery notifications */
  25. uint8_t last_percentage; /**< Last submitted notification percentage */
  26. uint16_t handle; /**< notification handle */
  27. } bleman_bas_t;
  28. /**
  29. * @brief handler for bleman battery service requests
  30. */
  31. int bleman_bas_handler(uint16_t conn_handle, uint16_t attr_handle,
  32. struct ble_gatt_access_ctxt *ctxt, void *arg);
  33. /**
  34. * @brief Enable or disable bleman battery service notifications
  35. */
  36. void bleman_bas_notify(bleman_bas_t *bas, bool enable);
  37. #ifdef __cplusplus
  38. }
  39. #endif
  40. #endif /* APP_BLEMAN_BAS_H */