Skip to content

Instantly share code, notes, and snippets.

@exinmusic
Created August 15, 2021 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save exinmusic/abfc39f3a7c48afd493e33b6cbe67a63 to your computer and use it in GitHub Desktop.
Save exinmusic/abfc39f3a7c48afd493e33b6cbe67a63 to your computer and use it in GitHub Desktop.
import time
from adafruit_ble import BLERadio
from ble_services import TAMAService
ble = BLERadio()
def replay(tama_connection, f):
for i in f.readlines():
hex_line = i[:-1].decode('utf-8')
ln = bytes.fromhex(hex_line)
tama_connection[TAMAService].write(ln)
print(f"-> {hex_line}")
print(f"-> {ln}")
time.sleep(.6)
tama_connection = None
# See if any existing connections are providing TAMAService.
if ble.connected:
for connection in ble.connections:
if TAMAService in connection:
tama_connection = connection
break
if not tama_connection:
print("Scanning...")
for adv in ble.start_scan():
print(adv.complete_name)
if 'TMGC_meets' == adv.complete_name:
print("found a TAMAService advertisement")
tama_connection = ble.connect(adv)
break
# Stop scanning whether or not we are connected.
ble.stop_scan()
if tama_connection and tama_connection.connected:
f = open("playback/handshake.txt", "rb")
replay(tama_connection, f)
time.sleep(1)
f = open("playback/pwnd.txt", "rb")
replay(tama_connection, f)
print('done')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment