1
0

fix(gateway): replace UUID filter with manufacturer data preamble filter

This commit is contained in:
DjeAvd
2026-05-07 13:28:08 +02:00
committed by Klagarge
parent 3eabb6eb16
commit bb5e14d263

View File

@@ -113,22 +113,18 @@ class Gateway:
log.info(f"Published to {topic} : {payload}")
def on_device_found(self, device, adv_data):
"""BLE scan callback — filters on Thingy:52 service UUID and decodes payload."""
uuids = [str(u).lower() for u in adv_data.service_uuids]
if self.service_uuid.lower() not in uuids:
"""BLE scan callback — filters on Adrien's preamble (0xffff) in manufacturer data."""
if not adv_data.manufacturer_data:
return
# Try manufacturer data first, then service data
raw = None
if adv_data.manufacturer_data:
raw = list(adv_data.manufacturer_data.values())[0]
elif adv_data.service_data:
raw = list(adv_data.service_data.values())[0]
if raw is None:
log.debug(f"{device.address} | no payload data found")
# Filter on preamble 0xffff (company id defined in firmware spec)
if len(raw) < 2 or raw[0] != 0xff or raw[1] != 0xff:
return
log.debug(f"{device.address} | Thingy detected, raw: {list(raw)}")
data = self.decode_payload(raw)
if not data:
log.warning(f"{device.address} | empty decoded payload")