blob: 065cbb68148b874cd01c9e21c5cd44275a084eb3 (
plain)
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
|
import asyncio
import sys
try:
from bleak import BleakScanner, BleakClient
except ModuleNotFoundError:
print("Error importing bleak, are you sure you installed it?")
print("Try running the following command: \"pip3 install bleak\"")
print("If that fails, try this: \"pip3 install bleak --break-system-packages\"")
sys.exit(1)
import time, calendar
async def sync(device_name: str):
print(f"Scanning for {device_name}...")
device = await BleakScanner.find_device_by_name(device_name, timeout=10)
if not device:
print("Watch not found!")
return
print(f"Found at {device.address}")
try:
async with BleakClient(device) as client:
packet = bytes([0x51, 0x01])
await client.write_gatt_char("6E40FC20-B5A3-F393-E0A9-E50E24DCCA9E", packet)
print("Vibrating, waiting 5 seconds then stopping vibration")
await asyncio.sleep(5)
packet = bytes([0x51, 0x00])
await client.write_gatt_char("6E40FC20-B5A3-F393-E0A9-E50E24DCCA9E", packet)
print("Stopped vibrating")
except Exception as e:
print(f"Failed: {e}")
if __name__ == "__main__":
watch_name = input("Enter watch name shown in BLE discovery (default: Watch ULTRA): ")
if watch_name == "":
watch_name = "Watch ULTRA"
asyncio.run(sync(watch_name))
|