Skip to content

Instantly share code, notes, and snippets.

@marcust
Created March 14, 2016 19:40
Show Gist options
  • Star 22 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcust/af93ff47899583f5a52f to your computer and use it in GitHub Desktop.
Save marcust/af93ff47899583f5a52f to your computer and use it in GitHub Desktop.
Power on a UE Boom via LE Blootooth commands using gatttool
#!/bin/sh
set -ue
HANDLE=0x0003
VALUE=4480ebedc17401
MAC=88:C6:26:1E:F5:38
gatttool -b $MAC --char-write-req --handle=$HANDLE --value=$VALUE
@crushr3sist
Copy link

gatttool is deprecated and not in current distros anymore.

The following python script should do the trick to turn it on tho:

#!/usr/bin/env python3

import bleak
import asyncio

# ue boom bluetooth mac address
UE_BOOM_MAC = "10:94:97:01:5A:30"

# any mac that was paired to ue boom works here
MY_MAC = "F0:AB:01:A9:6C:EE"

# service to turn on 
PWR_ON = "c6d6dc0d-07f5-47ef-9b59-630622b01fd3"

async def main():
  ble_msg = bytearray.fromhex(MY_MAC.replace(":",""))
  ble_msg.append(1)
  dev = bleak.BleakClient(UE_BOOM_MAC)
  await dev.connect()
  await dev.write_gatt_char(PWR_ON, ble_msg)

if __name__ == '__main__':
  asyncio.run(main())

This was tested with a Megaboom 3 on Linux 6.0.9, but should work with UE Boom 2 as well, and also on windows and mac since bleak is working there as well.

Turning of (linux only) would work like this:

#!/usr/bin/env python3

import socket

# ue boom bluetooth mac address
UE_BOOM_MAC = "10:94:97:01:5A:30"

# ue boom spp bt channel 
UE_BOOM_PORT = 1

# message to turn the speaker off
UE_BOOM_OFF_MSG = b'\x02\x01\xb6'

def main():
  dev = socket.socket(
    socket.AF_BLUETOOTH, 
    socket.SOCK_STREAM, 
    socket.BTPROTO_RFCOMM
  )
  dev.connect((
    UE_BOOM_MAC,
    UE_BOOM_PORT
  ))
  dev.sendall(b'\x02\x01\xb6')
  dev.close()

if __name__ == '__main__':
  main()

check out my repo for updates: https://github.com/eni23/ueboom

yo how did you get the PWR_ON service, I wish your repo had a bit more information

@eni23
Copy link

eni23 commented Jan 27, 2023

yo how did you get the PWR_ON service, I wish your repo had a bit more information

TBH, i did not invest a lot of time into this, but i got most infos from this thread here, a Reddit post where one decompiled the UE Android app https://www.reddit.com/r/bluetooth/comments/ap6npx/bluetooth_protocol_for_ue_boom_2/ and some playing around with bluetoothctl

@skilo-sh
Copy link

gatttool is deprecated and not in current distros anymore.
The following python script should do the trick to turn it on tho:

#!/usr/bin/env python3

import bleak
import asyncio

# ue boom bluetooth mac address
UE_BOOM_MAC = "10:94:97:01:5A:30"

# any mac that was paired to ue boom works here
MY_MAC = "F0:AB:01:A9:6C:EE"

# service to turn on 
PWR_ON = "c6d6dc0d-07f5-47ef-9b59-630622b01fd3"

async def main():
  ble_msg = bytearray.fromhex(MY_MAC.replace(":",""))
  ble_msg.append(1)
  dev = bleak.BleakClient(UE_BOOM_MAC)
  await dev.connect()
  await dev.write_gatt_char(PWR_ON, ble_msg)

if __name__ == '__main__':
  asyncio.run(main())

This was tested with a Megaboom 3 on Linux 6.0.9, but should work with UE Boom 2 as well, and also on windows and mac since bleak is working there as well.
Turning of (linux only) would work like this:

#!/usr/bin/env python3

import socket

# ue boom bluetooth mac address
UE_BOOM_MAC = "10:94:97:01:5A:30"

# ue boom spp bt channel 
UE_BOOM_PORT = 1

# message to turn the speaker off
UE_BOOM_OFF_MSG = b'\x02\x01\xb6'

def main():
  dev = socket.socket(
    socket.AF_BLUETOOTH, 
    socket.SOCK_STREAM, 
    socket.BTPROTO_RFCOMM
  )
  dev.connect((
    UE_BOOM_MAC,
    UE_BOOM_PORT
  ))
  dev.sendall(b'\x02\x01\xb6')
  dev.close()

if __name__ == '__main__':
  main()

check out my repo for updates: https://github.com/eni23/ueboom

yo how did you get the PWR_ON service, I wish your repo had a bit more information

Hello,
If u want more information I have created a repo with some explanation about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment