Check battery level of connected bluetooth device on linux

后端 未结 9 2056
盖世英雄少女心
盖世英雄少女心 2021-01-30 02:09

How can I check the battery level of a connected bluetooth device? The device shows the battery level on Android so I\'m assuming the device supports the GATT-based Battery Serv

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-30 02:37

    This is such a great question, ahead of development and tools that are available at the moment.

    The short answer (in October 2018)

    you have to write it yourself! It won't be a one liner in the terminal. I am going to write this for myself in Python, but C has a little more documentation, so if you are skilled with C go for it.

    The long answer, but it's more a recommended starting point:

    1. Tony D: https://youtu.be/5fQR2PHMDWE?t=4644 managed to use bluetoothctl to read attributes and send data to a bluetooth device. Definitely check the video information, you will find great links and references: https://learn.adafruit.com/introduction-to-bluetooth-low-energy/gatt
    2. Szymon Janc: https://youtu.be/VMDyebKT5c4 developer and contributer to the LINUX Bluetooth Stack
    3. Definitely check out how this question is answered on Mobile devices. For Android it's the BAS (Battery Service): https://android.stackexchange.com/questions/106073/displaying-bluetooth-gadgets-battery-status-on-the-phone

提交回复
热议问题