66from bleak .backends .scanner import AdvertisementData
77from typing import List
88
9- LEDGER_SERVICE_UUID_EUROPA = "13d63400-2c97-3004-0000-4c6564676572"
10- LEDGER_SERVICE_UUID_STAX = "13d63400-2c97-6004-0000-4c6564676572"
11- LEDGER_SERVICE_UUID_NANOX = "13d63400-2c97-0004-0000-4c6564676572"
9+ SERVICE_UUIDS = [
10+ "13d63400-2c97-3004-0000-4c6564676572" , #flex
11+ "13d63400-2c97-6004-0000-4c6564676572" , #stax
12+ "13d63400-2c97-0004-0000-4c6564676572" , #nanox
13+ "13d63400-2c97-8004-0000-4c6564676572" , #apex
14+ ]
1215
1316TAG_ID = b"\x05 "
1417
@@ -35,17 +38,14 @@ def __init__(self):
3538 self .devices = []
3639
3740 def __scan_callback (self , device : BLEDevice , advertisement_data : AdvertisementData ):
38- if (
39- LEDGER_SERVICE_UUID_STAX in advertisement_data .service_uuids
40- or LEDGER_SERVICE_UUID_NANOX in advertisement_data .service_uuids
41- or LEDGER_SERVICE_UUID_EUROPA in advertisement_data .service_uuids
42- ):
43- device_is_in_list = False
44- for dev in self .devices :
45- if device .address == dev [0 ]:
46- device_is_in_list = True
47- if not device_is_in_list :
48- self .devices .append ((device .address , device .name ))
41+ for uuid in advertisement_data .service_uuids :
42+ if uuid in SERVICE_UUIDS :
43+ device_is_in_list = False
44+ for dev in self .devices :
45+ if device .address == dev [0 ]:
46+ device_is_in_list = True
47+ if not device_is_in_list :
48+ self .devices .append ((device .address , device .name ))
4949
5050 async def scan (self ):
5151 scanner = BleakScanner (
@@ -76,11 +76,7 @@ async def _get_client(address: str) -> BleakClient:
7676 characteristic_write_with_rsp = None
7777 characteristic_write_cmd = None
7878 for service in client .services :
79- if service .uuid in [
80- LEDGER_SERVICE_UUID_NANOX ,
81- LEDGER_SERVICE_UUID_STAX ,
82- LEDGER_SERVICE_UUID_EUROPA ,
83- ]:
79+ if service .uuid in SERVICE_UUIDS :
8480 for char in service .characteristics :
8581 if "0001" in char .uuid :
8682 characteristic_notify = char
0 commit comments