-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathezwake.py
More file actions
37 lines (29 loc) · 1.02 KB
/
ezwake.py
File metadata and controls
37 lines (29 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#Replace GATT write command(fe ea 20 06 53 0e) with yours
import asyncio
from bleak import BleakClient, BleakScanner
WATCH = "F6:B0:2B:69:11:33"
UUID = "0000fee2-0000-1000-8000-00805f9b34fb"
WAKE = bytes.fromhex("fe ea 20 06 53 0e")
async def keep_awake(client):
while True:
await client.write_gatt_char(UUID, WAKE)
print("Wake (connected)")
await asyncio.sleep(8)
async def main():
while True:
try:
print("Scanning...")
device = await BleakScanner.find_device_by_address(WATCH, timeout=15)
if not device:
print("Watch not found")
await asyncio.sleep(5)
continue
print("Connecting...")
async with BleakClient(device) as client:
print("Connected to watch")
await keep_awake(client)
except Exception as e:
print("Disconnected:", e)
print("Retrying in 5 seconds...\n")
await asyncio.sleep(5)
asyncio.run(main())