How to show battery level in iOS and Android using BLE?

ramier
Posts: 8
Joined: Sat Dec 18, 2021 9:01 pm

How to show battery level in iOS and Android using BLE?

Postby ramier » Fri Jan 21, 2022 1:15 pm

Hey,
I want to show my battery level in iOS and Android, like headphones tpiycaly do.

My code looks something like this, with nRF I do get the correct results, but nowhere in Android or iOS can I see my battery status.
Has anybody managed to show the battery level in iOS or Android?

  1. uint8_t battery_level = 42;
  2. int gatt_svr_chr_access_battery_level(uint16_t conn_handler, uint16_t attr_handler, struct ble_gatt_access_ctxt *ctxt, void *arg) {
  3.     os_mbuf_append(ctxt->om, &battery_level, sizeof(battery_level));
  4.     return 0;
  5. }
  1. {
  2.         .type = BLE_GATT_SVC_TYPE_PRIMARY,
  3.         .uuid = BLE_UUID16_DECLARE(0x180F),
  4.         .characteristics = (struct ble_gatt_chr_def[]) {
  5.                 {
  6.                         .uuid       = BLE_UUID16_DECLARE(0x2A19),
  7.                         .access_cb  = gatt_svr_chr_access_battery_level,
  8.                         .flags      = BLE_GATT_CHR_F_READ
  9.                 },
  10.                 {
  11.                         0 /* No more characteristics in this service */
  12.                 }
  13.         }
  14. },

Who is online

Users browsing this forum: brushlow18, MSN [Bot] and 242 guests