get device type
diff --git a/local_agent/translation_layer/gdm_manager.py b/local_agent/translation_layer/gdm_manager.py
index 4e33b4f..950f20e 100644
--- a/local_agent/translation_layer/gdm_manager.py
+++ b/local_agent/translation_layer/gdm_manager.py
@@ -14,10 +14,13 @@
 
 """Module for GDM manager."""
 import threading
-from typing import Any, Callable, Dict, List, Optional
+from typing import Any, Collection, List, Mapping, Optional, Set, Tuple, Type,Callable,Dict
 
 import gazoo_device
 from gazoo_device import errors as gdm_errors
+from gazoo_device.auxiliary_devices import chip_tool
+from gazoo_device.capabilities.matter_endpoints.interfaces import endpoint_base
+from gazoo_device.capabilities.matter_clusters.interfaces import cluster_base
 
 from local_agent import errors as agent_errors
 from local_agent import logger as logger_module
@@ -57,67 +60,81 @@
             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'
+            chip_tool_id = 'chip_tool-0000'
+            # device_type = 'chip_tool'
+            # serial_number = '00000000'
 
             connected_devices = self._mgr.get_devices('all')
 
-            if not device_id in connected_devices:
-                return
+            if not chip_tool_id in connected_devices:
+                return []
 
-            if not self._mgr.is_device_connected(device_id):
-                return
+            if not self._mgr.is_device_connected(chip_tool_id):
+                return []
 
-            with self._mgr.create_and_close_device(device_id) as device:
+            with self._mgr.create_and_close_device(chip_tool_id) as device:
+                if not isinstance(device, chip_tool.ChipTool):
+                    return []
+
                 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()))
+                # devices has to be commissioned to chip tool first
 
-            # connected_devices = self._mgr.get_devices('all')
-            # for device_id, info in connected_devices.items():
+                endpoint_instances_and_cluster_mapping = device.matter_endpoints.get_supported_endpoint_instances_and_cluster_flavors()
+                
+                for endpoint_instances_and_cluster_pair in endpoint_instances_and_cluster_mapping.items():
+                    endpoint_instance = endpoint_instances_and_cluster_pair[0]
+                    device_type = endpoint_instance.name
+                    
+                    # Skip root node
+                    if(device_type == "root_node"):
+                        continue
 
-            #     # The device has been removed.
-            #     if not self._mgr.is_device_connected(device_id):
-            #         continue
+                    device_id = endpoint_instance.id
+                    cluster_capabilities = sorted(cluster.get_capability_name() for cluster in endpoint_instances_and_cluster_pair[1])
 
-            #     # 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']
+                    
+                    # connected_devices = self._mgr.get_devices('all')
+                    # for device_id, info in connected_devices.items():
 
-            #         # 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()))
+                    #     # The device has been removed.
+                    #     if not self._mgr.is_device_connected(device_id):
+                    #         continue
 
-            #             # (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)
+                    #     # 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']
 
-				# Therefore, we only need to update the command handlers once.
-                self._update_handlers_cls_map(device_type, matter_endpoints)
+                    #         # 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(capabilities).union(*endpoint_clusters_mapping.values()))
 
-				# 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
+                    #             # (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)
 
-            devices.append(self._connected_devices[device_id])
+                    # Therefore, we only need to update the command handlers once.
+                    self._update_handlers_cls_map(device_type, device_type)
+
+                    # We could not get the serial number
+                    # Store the device information in cache.
+                    device_info = {
+                        'deviceId': device_id,
+                        'serialNumber': 'unknown',
+                        'deviceType': device_type,
+                        'capabilities': cluster_capabilities,
+                    }
+                    self._connected_devices[device_id] = device_info
+
+                    devices.append(self._connected_devices[device_id])
                 
         self._first_detection = False