Add helper API to display Zigbee profile id and device id
authorsaerome kim <saerome.kim@samsung.com>
Thu, 16 Feb 2017 11:39:27 +0000 (20:39 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Thu, 11 May 2017 09:07:20 +0000 (18:07 +0900)
Change-Id: I43bb205041685ef26667138168535e24f8c1fa67
Signed-off-by: saerome kim <saerome.kim@samsung.com>
include/zb-ha.h
include/zb-zdo.h
lib/zbl-zdo.c
test/zdo-device.c

index 21a5274ca6b01f4337687d4a7f84c4345a9fcef7..741511b62f6966c9fc20019f758d942041b48fae 100644 (file)
 #define __TIZEN_NETWORK_ZIGBEE_HA_H__
 
 /**
- * @brief HA profile id
+ * @brief Zigbee profile id
  *
  * @since_tizen 3.0
  */
-#define ZB_HA_PROFILE_ID 0x0104
+typedef enum {
+       ZB_PROFILE_HOME_AUTOMATION = 0x0104,
+} zb_profile_id_e;
 
 /**
  * @brief Devices specified the HA profile
index bcdb1a52363f5c6bc70a3cec6a4f69155c2582b6..d1fbd2eb16b042257aa2c5ed3aea6d4093be81da 100644 (file)
 #include <zdo/zb-zdo-svc-disc.h>
 #include <zdo/zb-zdo-bind-mgr.h>
 
+
+/**
+ * @brief Return readabble Zigbee profile id
+ * @details Return Zigbee profile id
+ *
+ * @since_tizen 3.0
+ *
+ * @param[in] profile_id ZigBee profile id
+ *
+ * @return pointer of profile id string
+ *
+ */
+const char* zb_get_profile_id_string(int profile_id);
+
+/**
+ * @brief Return readabble Zigbee device id
+ * @details Return Zigbee device id
+ *
+ * @since_tizen 3.0
+ *
+ * @param[in] device_id ZigBee device id
+ *
+ * @return pointer of device id string
+ *
+ */
+const char* zb_get_device_id_string(int device_id);
+
 /**
  * @brief Create simple descriptor
  * @details Create simple descriptor handle
index 5ed4301bf39716ce7ad05ca0115fecd7880af18b..bffaa2be36c6be0149f2601736e3ad709c8bf4c2 100644 (file)
@@ -17,6 +17,7 @@
 #include <error.h>
 #include <stdlib.h>
 
+#include <zb-ha.h>
 #include <zb-type.h>
 #include <zb-error.h>
 #include <zdo/zb-zdo-type.h>
 #include "zbl-dbus.h"
 #include "zb-common.h"
 
+#define CASE_TO_STR(x) case x: return #x;
+
+API const char* zb_get_profile_id_string(int profile_id)
+{
+       switch(profile_id) {
+       CASE_TO_STR(ZB_PROFILE_HOME_AUTOMATION)
+               default:
+               return "ZB_UNKNOWN_PROFILE";
+       }
+}
+
+API const char* zb_get_device_id_string(int device_id)
+{
+       switch (device_id) {
+       /* General devices */
+       CASE_TO_STR(ZB_HA_ON_OFF_SWITCH)
+       CASE_TO_STR(ZB_HA_LEVEL_CONTROL_SWITCH)
+       CASE_TO_STR(ZB_HA_ON_OFF_OUTPUT)
+       CASE_TO_STR(ZB_HA_LEVEL_CONTROLLABLE_OUTPUT)
+       CASE_TO_STR(ZB_HA_SCENE_SELECOTOR)
+       CASE_TO_STR(ZB_HA_CONFIGURATION_TOOL)
+       CASE_TO_STR(ZB_HA_REMOTE_CONTROL)
+       CASE_TO_STR(ZB_HA_COMBINED_INTERFACE)
+       CASE_TO_STR(ZB_HA_RANGE_EXTENDER)
+       CASE_TO_STR(ZB_HA_MAINS_POWER_OUTLET)
+       CASE_TO_STR(ZB_HA_DOOR_LOCK)
+       CASE_TO_STR(ZB_HA_DOOR_LOCK_CONTROLLER)
+       CASE_TO_STR(ZB_HA_SIMPLE_SENSOR)
+       CASE_TO_STR(ZB_HA_CONSUMPTION_AWARENESS_DEVICE)
+       CASE_TO_STR(ZB_HA_HOME_GATEWAY)
+       CASE_TO_STR(ZB_HA_SMART_PLUG)
+       CASE_TO_STR(ZB_HA_WHITE_GOODS)
+       CASE_TO_STR(ZB_HA_METER_INTERFACE)
+       /* Lighting devices */
+       CASE_TO_STR(ZB_HA_ON_OFF_LIGHT)
+       CASE_TO_STR(ZB_HA_DIMMABLE_LIGHT)
+       CASE_TO_STR(ZB_HA_COLOR_DIMMABLE_LIGHT)
+       CASE_TO_STR(ZB_HA_ON_OFF_LIGHT_SWITCH)
+       CASE_TO_STR(ZB_HA_DIMMER_SWITCH)
+       CASE_TO_STR(ZB_HA_COLOR_DIMMER_SWITCH)
+       CASE_TO_STR(ZB_HA_LIGHT_SENSOR)
+       CASE_TO_STR(ZB_HA_OCUPANCY_SENSOR)
+       /* Closures devices */
+       CASE_TO_STR(ZB_HA_SHADE)
+       CASE_TO_STR(ZB_HA_SHADE_CONTROLLER)
+       CASE_TO_STR(ZB_HA_WINDOW_COVERING_DEVICE)
+       CASE_TO_STR(ZB_HA_WINDOW_COVERING_CONTROLLER)
+       /* HVAC devices */
+       CASE_TO_STR(ZB_HA_HEATING_COLLING_UNIT)
+       CASE_TO_STR(ZB_HA_THERMOSTAT)
+       CASE_TO_STR(ZB_HA_TEMPERATURE_SENSOR)
+       CASE_TO_STR(ZB_HA_PUMP)
+       CASE_TO_STR(ZB_HA_PUMP_CONTROLLER)
+       CASE_TO_STR(ZB_HA_PRESSURE_SENSOR)
+       CASE_TO_STR(ZB_HA_FLOW_SENSOR)
+       CASE_TO_STR(ZB_HA_MINI_SPLIT_AC)
+       /* Intruder Alarms system */
+       CASE_TO_STR(ZB_HA_ISA_CONTROL_AND_INDICATING_EQUIPMENT)
+       CASE_TO_STR(ZB_HA_ISA_ANCILLARY_CONTROL_EQUIPMENT)
+       CASE_TO_STR(ZB_HA_ISA_ZONE)
+       default:
+               return "ZB_HA_UNKNOWN_DEVICE";
+       }
+}
+
 API int zb_simple_desc_create(zb_zdo_simple_desc_h *handle)
 {
        RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
index 3696a7058e781d170ed695cb18df5d6e8bd58f82..97b7c32b06da3fa4879d7b8495ef8ee053adb6a0 100644 (file)
@@ -74,7 +74,7 @@ static void zigbee_active_ep_rsp(unsigned char status, nwk_addr addr16,
 static void zigbee_simple_desc_rsp(nwk_addr addr16, unsigned char len,
        const zb_zdo_simple_desc_h handle, void *user_data)
 {
-       int ret;
+       int i, ret;
        unsigned char param_u8;
        unsigned short param_u16;
        unsigned short *in_clusters;
@@ -93,13 +93,13 @@ static void zigbee_simple_desc_rsp(nwk_addr addr16, unsigned char len,
        if (ZIGBEE_ERROR_NONE != ret)
                msg("zb_simple_desc_get_profile_id() Fail(0x%X)", ret);
        else
-               msg("  profile_id = 0x%x", param_u16);
+               msg("  profile_id = 0x%x (%s)", param_u16, zb_get_profile_id_string(param_u16));
 
        ret = zb_simple_desc_get_device_id(handle, &param_u16);
        if (ZIGBEE_ERROR_NONE != ret)
                msg("zb_simple_desc_get_device_id() Fail(0x%X)", ret);
        else
-               msg("  device_id = 0x%x", param_u16);
+               msg("  device_id = 0x%x (%s)", param_u16, zb_get_device_id_string(param_u16));
 
        ret = zb_simple_desc_get_device_ver(handle, &param_u16);
        if (ZIGBEE_ERROR_NONE != ret)
@@ -117,9 +117,8 @@ static void zigbee_simple_desc_rsp(nwk_addr addr16, unsigned char len,
        if (ZIGBEE_ERROR_NONE != ret) {
                msg("zb_simple_desc_get_in_clusters() Fail(0x%X)", ret);
        } else {
-               msg("    %04X %04X %04X %04X %04X %04X %04X",
-                       in_clusters[0], in_clusters[1], in_clusters[2], in_clusters[3],
-                       in_clusters[4], in_clusters[5], in_clusters[6]);
+               for (i = 0; i < param_u8; i++)
+                       msg("    %04X (%s)", in_clusters[i], zb_get_cluster_name(in_clusters[i]));
        }
 
        ret = zb_simple_desc_get_num_of_out_clusters(handle, &param_u8);
@@ -131,8 +130,10 @@ static void zigbee_simple_desc_rsp(nwk_addr addr16, unsigned char len,
        ret = zb_simple_desc_get_out_clusters(handle, &out_clusters);
        if (ZIGBEE_ERROR_NONE != ret)
                msg("zb_simple_desc_get_out_clusters() Fail(0x%X)", ret);
-       else
-               msg("    %04X ", out_clusters[0]);
+       else {
+               for (i = 0; i < param_u8; i++)
+                       msg("    %04X (%s)", out_clusters[i], zb_get_cluster_name(out_clusters[i]));
+       }
 }
 
 static void zigbee_match_desc_rsp(unsigned char status, nwk_addr addr16,