Python script for controlling (turn ON/OFF) ue boom speaker and getting its current battery level
Tested on ue boom version 1
gatttool
- https://www.jaredwolff.com/get-started-with-bluetooth-low-energy/
- https://github.com/pcborenstein/bluezDoc/wiki/hcitool-and-gatttool-example
boom = Boom('DEVICE_MAC', 'CLIENT_MAC')
#DEVICE_MAC: speakers MAC address, format: XX:XX:XX:XX:XX:XX
#CLIENT_MAC: MAC address of a device that already has been connected to the speaker, format: XX:XX:XX:XX:XX:XX
boom.on() #turns speaker on
boom.off() #turn speaker off
battery_level = boom.get_battery() #returns speakers battery level
Usage: sudo gatttool [OPTIONS]
Paramater:
SPEAKER_MAC speakers mac address, format: XX:XX:XX:XX:XX:XX
CLIENT_MAC mac address of a client that has already been connected to speaker,
format: XXXXXXXXXXXX
Commands:
on
sudo gatttool -i hci0 -b SPEAKER_MAC --char-write-req -a 0x0003 -n CLIENT_MAC01
off
sudo gatttool -i hci0 -b SPEAKER_MAC --char-write-req -a 0x0003 -n CLIENT_MAC02
battery_level
sudo gatttool -i hci0 -b SPEAKER_MAC --char-read --uuid 0x2a19
- Source of gatttool commands (reddit)