WIP: use chip tool on host to detect success
diff --git a/local_agent/local_agent.py b/local_agent/local_agent.py index 25398d1..9ca947f 100644 --- a/local_agent/local_agent.py +++ b/local_agent/local_agent.py
@@ -95,9 +95,9 @@ requests. """ - _REPORT_INFO_INTERVAL_SECONDS = 30 + _REPORT_INFO_INTERVAL_SECONDS = 30000 _REPORT_INFO_THREAD_TERMINATION_WAIT_SECONDS = 10 - _POLL_RPC_COOL_DOWN_SECONDS = 1 + _POLL_RPC_COOL_DOWN_SECONDS = 10000 _POLL_RPC_THREAD_TERMINATION_WAIT_SECONDS = 10 _MAIN_THREAD_KEEP_ALIVE_COOLDOWN_SECONDS = 1 @@ -612,3 +612,5 @@ scheme=ams_scheme) proc = LocalAgentProcess(client=client, artifacts_dir=artifacts_dir) proc.run() + +main()
diff --git a/local_agent/translation_layer/gdm_manager.py b/local_agent/translation_layer/gdm_manager.py index 91048b2..4e33b4f 100644 --- a/local_agent/translation_layer/gdm_manager.py +++ b/local_agent/translation_layer/gdm_manager.py
@@ -56,47 +56,68 @@ with self._mgr_lock: self._mgr.detect(force_overwrite=self._first_detection, log_directory=_DEVICE_DETECTION_LOG_DIR) + + device_id = 'chip_tool-0000' + device_type = 'chip_tool' + serial_number = '00000000' + connected_devices = self._mgr.get_devices('all') - for device_id, info in connected_devices.items(): - # The device has been removed. - if not self._mgr.is_device_connected(device_id): - continue + if not device_id in connected_devices: + return - # The first time this device is detected. - if device_id not in self._connected_devices: - serial_number = info['persistent']['serial_number'] - device_type = info['persistent']['device_type'] + if not self._mgr.is_device_connected(device_id): + return - # Retrieve the Matter endpoints and clusters in the first detection. - with self._mgr.create_and_close_device(device_id) as device: - # If the device is not Matter device - if not device.has_capabilities(["matter_endpoints"]): - matter_endpoints = [] - cluster_capabilities = [] - else: - matter_endpoints = device.matter_endpoints.get_supported_endpoints() - endpoint_clusters_mapping = device.matter_endpoints.get_supported_endpoints_and_clusters() - cluster_capabilities = list(set().union(*endpoint_clusters_mapping.values())) + with self._mgr.create_and_close_device(device_id) as device: + device.set_property("matter_node_id", 6666) + # devices has to be commissioned to chip tool first + matter_endpoints = device.matter_endpoints.get_supported_endpoints() + endpoint_clusters_mapping = device.matter_endpoints.get_supported_endpoints_and_clusters() + cluster_capabilities = list(set().union(*endpoint_clusters_mapping.values())) - # Additional non-Matter capabilities. - if device.has_capabilities([common.PWRPC_COMMON_CAPABILITY]): - matter_endpoints.append(common.PWRPC_COMMON_CAPABILITY) - cluster_capabilities.append(common.PWRPC_COMMON_CAPABILITY) + # connected_devices = self._mgr.get_devices('all') + # for device_id, info in connected_devices.items(): - # Therefore, we only need to update the command handlers once. - self._update_handlers_cls_map(device_type, matter_endpoints) + # # The device has been removed. + # if not self._mgr.is_device_connected(device_id): + # continue - # Store the device information in cache. - device_info = { - 'deviceId': device_id, - 'serialNumber': serial_number, - 'deviceType': device_type, - 'capabilities': cluster_capabilities, - } - self._connected_devices[device_id] = device_info + # # The first time this device is detected. + # if device_id not in self._connected_devices: + # serial_number = info['persistent']['serial_number'] + # device_type = info['persistent']['device_type'] - devices.append(self._connected_devices[device_id]) + # # Retrieve the Matter endpoints and clusters in the first detection. + # with self._mgr.create_and_close_device(device_id) as device: + # # If the device is not Matter device + # if not device.has_capabilities(["matter_endpoints"]): + # matter_endpoints = [] + # cluster_capabilities = [] + # else: + # # devices has to be commissioned to chip tool first + # matter_endpoints = device.matter_endpoints.get_supported_endpoints() + # endpoint_clusters_mapping = device.matter_endpoints.get_supported_endpoints_and_clusters() + # cluster_capabilities = list(set(capabilities).union(*endpoint_clusters_mapping.values())) + + # # (deprecate) Additional non-Matter capabilities. + # if device.has_capabilities([common.PWRPC_COMMON_CAPABILITY]): + # matter_endpoints.append(common.PWRPC_COMMON_CAPABILITY) + # cluster_capabilities.append(common.PWRPC_COMMON_CAPABILITY) + + # Therefore, we only need to update the command handlers once. + self._update_handlers_cls_map(device_type, matter_endpoints) + + # Store the device information in cache. + device_info = { + 'deviceId': device_id, + 'serialNumber': serial_number, + 'deviceType': device_type, + 'capabilities': cluster_capabilities, + } + self._connected_devices[device_id] = device_info + + devices.append(self._connected_devices[device_id]) self._first_detection = False @@ -167,3 +188,11 @@ """Closes all open devices in GDM.""" with self._mgr_lock: self._mgr.close_open_devices() + + + +def update_handlers_cls_map( + device_type: str, capabilities: List[str]) -> None: + return +mgr = GdmManager(update_handlers_cls_map) +mgr.detect_devices()
diff --git a/setup.py b/setup.py index c813edf..5b92dc6 100644 --- a/setup.py +++ b/setup.py
@@ -36,8 +36,7 @@ VERSION = get_version() LICENSE = 'Copyright 2022 Google LLC' -REQUIRED_MODULES = [ - 'gazoo-device >= 1.67.0', 'inflection', 'requests >= 2.25.0', 'wheel'] +REQUIRED_MODULES = ['inflection', 'requests >= 2.25.0', 'wheel'] TEST_REQUIRED_MODULES = { 'test': ['coverage', 'immutabledict', 'parameterized']}