Skip to content

joric/bluetooth-battery-monitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 

Repository files navigation

Bluetooth Battery Monitor

Open source Bluetooth battery monitor for Windows

Enumerating Bluetooth devices and services

I'm not using UWP, only classic C/C++ API (check out misc directory for more C++ examples).

API calls:

  • SetupDiGetClassDevs / SetupDiEnumDeviceInfo for getting a list of all bluetooth devices.
  • SetupDiGetDeviceRegistryProperty / SPDRP_HARDWAREID for filtering by device address.
  • BluetoothGATTGetServices / BluetoothGATTGetCharacteristics for BLE properties.
  • SetupDiGetDeviceProperty / DEVPKEY_DeviceContainer_IsConnected for connection status.

UUIDs:

  • {e0cbf06c-cd8b-4647-bb8a-263b43f0f974} (Bluetooth Device) for SetupDiGetClassDevs.
  • {00001800-0000-1000-8000-00805F9B34FB} (Generic Attribute) for Appearance (0x2A01).
  • {0000180F-0000-1000-8000-00805F9B34FB} (Battery Service) for Battery Level (0x2A19).
  • {0000180A-0000-1000-8000-00805F9B34FB} (Device Information) for Manufacturer (0x2A29).

Problems and workarounds:

  • The program supports only BLE reports for now. Obtaining battery status is easy for BLE, but HID and HFP devices use their own approach (see HID Usage Tables "Battery Strength" and HFPGetBatteryLevel accordingly). HFP devices also expose HID interface, probably it's all doable with HID API or a system-wide dll hook. Will implement later.
  • BLUETOOTH_GATT_FLAG_FORCE_READ_FROM_DEVICE (0x00000004) timeouts on disconnected devices, check their status first.
  • {00001800-0000-1000-8000-00805F9B34FB} (Generic Attribute) is read only, don't use GENERIC_WRITE in CreateFile.

References

About

Open source Bluetooth battery monitor for Windows

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published