-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscanForSpecificBluetoothDevices.py
56 lines (46 loc) · 1.33 KB
/
scanForSpecificBluetoothDevices.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Scan for Specific Bluetooth Devices.py
# 220521 rg v1
#
# https://pypi.org/project/bleak/
#
#
import asyncio
from bleak import BleakClient
from bleak import BleakScanner
address = ""
# NOT USED
#address = "E3:9E:7C:46:41:F8"
#MODEL_NBR_UUID = "D0CC6BEC-3905-874A-CC20-5F94225A7D28"
#address = MODEL_NBR_UUID
#address = '6e400001-b5a3-f393-e0a9-e50e24dcca9e'
async def main(address):
global dev
print( '\n\nSCANNING for any GoDice' )
devices = await BleakScanner.discover()
flag = True
for d in devices:
if flag and "GoDice" in d.name :
dev = d
print("\n--------------------------------")
print(d)
type(d)
print( dir(d) )
print('Name' , d.name )
print( 'Dice?:' , 'GoDice' in d.name )
print('Address' , d.address )
print('Details' , d.details )
print('Meta' , d.metadata )
print('RSSI' , d.rssi )
flag = True
# if "GoDice" in d:
# print(d)
"""
if 0:
print( '\n\nACCESS DEVICE - doesnt work yet for GoDice' )
async with BleakClient(address) as client:
model_number = await client.read_gatt_char(MODEL_NBR_UUID)
print("Model Number: {0}".format("".join(map(chr, model_number))))
"""
asyncio.run(
main(address)
)