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
@aryanaggg
Copy link

Hey, I was just wondering how does this work. There isnt anything online related to this.

@JoshuaBeighton
Copy link

JoshuaBeighton commented Apr 22, 2021

Hello,
I tried running your script with my UE Megaboom, but I get the following error.
Characteristic Write Request failed: Attribute requires authorization before read/write
Any ideas?
Thanks

Hi,

I faced the same issue when using this command on my raspberry (Node-RED).
I found out (but I would like confirmation from others), that the MAC address of the sending device (with 01 ou 02 at the end) has to be a MAC address of a previously paired device.

From what I learned, the Mac address does not have be of the sending device but of one of the device that the BOOM was already paired on.

In my cas im using my phone's Mac to ping the BOOM using my raspberry.

Hope this helps.

Adam

I got the same error even after connecting my laptop to the boom and playing music through it. I did try changing the security level of gatttool but despite using gatttool -h, I couldn't figure out the syntax (I only got ubuntu this week)

@eni23
Copy link

eni23 commented Nov 22, 2022

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

@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