Created
August 15, 2021 19:54
-
-
Save exinmusic/abfc39f3a7c48afd493e33b6cbe67a63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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