Skip to content

Commit

Permalink
add a bunch of logging
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Feb 9, 2024
1 parent 92c527c commit bbc80f9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion matter_server/server/device_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ async def initialize(self) -> None:
)
self.fabric_id_hex = hex(self.compressed_fabric_id)[2:]
LOGGER.debug("CHIP Device Controller Initialized")
LOGGER.info(
"Compressed Fabric ID: %s - HEX: %s",
self.compressed_fabric_id,
self.fabric_id_hex,
)

async def start(self) -> None:
"""Handle logic on controller start."""
Expand Down Expand Up @@ -180,13 +185,15 @@ async def start(self) -> None:
self.server.storage.remove(DATA_KEY_NODES, node_id_str)
LOGGER.info("Loaded %s nodes from stored configuration", len(self._nodes))
# set-up mdns browser
LOGGER.info("Starting mdns discovery....")
self._aiozc = AsyncZeroconf(ip_version=IPVersion.All)
services = [MDNS_TYPE_OPERATIONAL_NODE, MDNS_TYPE_COMMISSIONABLE_NODE]
self._aiobrowser = AsyncServiceBrowser(
self._aiozc.zeroconf,
services,
handlers=[self._on_mdns_service_state_change],
)
LOGGER.info("Mdns discovery initialized....")

async def stop(self) -> None:
"""Handle logic on server stop."""
Expand Down Expand Up @@ -1168,10 +1175,14 @@ def _on_mdns_service_state_change(
return
if service_type == MDNS_TYPE_OPERATIONAL_NODE:
name = name.lower()
LOGGER.info("Received %s MDNS event for %s", state_change, name)
if not name.startswith(self.fabric_id_hex):
# filter out messages that are not for our fabric
LOGGER.warning(
"Ignore MDNS event for %s due to a fabric mismatch", name
)
return
LOGGER.debug("Received %s MDNS event for %s", state_change, name)

if state_change not in (
ServiceStateChange.Added,
ServiceStateChange.Updated,
Expand Down

0 comments on commit bbc80f9

Please sign in to comment.