Changed presence_detected_cb in ua-test.
authorsaerome.kim <saerome.kim@samsung.com>
Wed, 25 Sep 2019 23:49:06 +0000 (08:49 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Thu, 26 Sep 2019 06:47:28 +0000 (15:47 +0900)
This version display sensor information when be called sensor callback.
So we changed the name of the exsiting __device_presence_detected_cb and
__device_absence_cb to __sensor_presence/absence_cb.

Change-Id: I5b384d7e1917cad57d1545eab314ae653f0a675b
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
test/uat-detections.c

index 088eb014b300206fe0608fa17d2d7e2272c39723..3fc5a06868c4dd5c4bfca99e21a729521abbbe44 100644 (file)
@@ -48,9 +48,11 @@ static char g_presence_type[MENU_DATA_SIZE + 1] = "2"; /**< Selected PRESENCE ty
 static char g_absence_type[MENU_DATA_SIZE + 1] = "2"; /**< Selected ABSENCE type */
 static char g_scan_time_multiplier[MENU_DATA_SIZE + 1] = {0,}; /**< 10ms * what number */
 
-static void __device_presence_detected_cb(int result, ua_monitor_h monitor,
+static void __sensor_presence_detected_cb(int result, ua_monitor_h monitor,
                ua_sensor_e sensor, void *user_data)
 {
+       char buf[MENU_DATA_SIZE] = {0, };
+       char final_buf[MENU_DATA_SIZE * 4] = {0, };
        char *pbuf = uat_get_time();
        msg("\n[%s] Device PRESENCE [%d]", pbuf, sensor);
        free(pbuf);
@@ -65,18 +67,26 @@ static void __device_presence_detected_cb(int result, ua_monitor_h monitor,
                msgb("[%s] PRESENCE detected [%s]",
                        uat_get_sensor_bitmask_str(UA_SENSOR_WIFI), uat_get_error_str(result));
        }
+
        if (UA_SENSOR_LIGHT == (UA_SENSOR_LIGHT & sensor)) {
-               msgb("[%s] PRESENCE detected at timestamp [%ld] lux [%f] [%s]",
+               /* For sensor information */
+               for (int i = 0; i < info->count; i++) {
+                       snprintf(buf, MENU_DATA_SIZE, "%lF ", info->values[i]);
+                       strncat(final_buf, buf, sizeof(buf) - strlen(buf) - 1);
+                       memset(buf, 0, MENU_DATA_SIZE);
+               }
+               msgb("[%s] PRESENCE detected at timestamp [%ld] value [%s] [%s]",
                        uat_get_sensor_bitmask_str(UA_SENSOR_LIGHT), info->timestamp,
-                               info->values[0], uat_get_error_str(result));
+                               final_buf, uat_get_error_str(result));
        }
        if (UA_SENSOR_MOTION == (UA_SENSOR_MOTION & sensor)) {
                msgb("[%s] PRESENCE detected at timestamp [%ld] [%s]",
-                       uat_get_sensor_bitmask_str(UA_SENSOR_MOTION), info->timestamp, uat_get_error_str(result));
+                       uat_get_sensor_bitmask_str(UA_SENSOR_MOTION), info->timestamp,
+                       uat_get_error_str(result));
        }
 }
 
-static void __device_absence_detected_cb(int result, ua_monitor_h monitor,
+static void __sensor_absence_detected_cb(int result, ua_monitor_h monitor,
        ua_sensor_e sensor, void *user_data)
 {
        char *pbuf = uat_get_time();
@@ -314,7 +324,7 @@ static int run_ua_monitor_start_presence_detection(
 
        ret = ua_monitor_start_presence_detection(g_ua_mon_h,
                        (g_service_str[0] == '\0' ? NULL : g_service_h),
-                       detection_mode, __device_presence_detected_cb, g_ua_mon_h);
+                       detection_mode, __sensor_presence_detected_cb, g_ua_mon_h);
 
        msg(" - ua_monitor_start_presence_detection() ret: [0x%X] [%s]",
                ret, uat_get_error_str(ret));
@@ -375,7 +385,7 @@ static int run_ua_monitor_start_absence_detection(
 
        ret = ua_monitor_start_absence_detection(g_ua_mon_h,
                        (g_service_str[0] == '\0' ? NULL : g_service_h),
-                       detection_mode, __device_absence_detected_cb, g_ua_mon_h);
+                       detection_mode, __sensor_absence_detected_cb, g_ua_mon_h);
 
        msg(" - ua_monitor_start_absence_detection() ret: [0x%X] [%s]",
                ret, uat_get_error_str(ret));
@@ -454,7 +464,7 @@ static int run_ua_monitor_start_absence_presence(
 
        ret = ua_monitor_start_absence_detection(g_ua_mon_h,
                        (g_service_str[0] == '\0' ? NULL : g_service_h),
-                       detection_mode, __device_absence_detected_cb, g_ua_mon_h);
+                       detection_mode, __sensor_absence_detected_cb, g_ua_mon_h);
        msg(" - ua_monitor_start_absence_detection() ret: [0x%X] [%s]",
                    ret, uat_get_error_str(ret));
 
@@ -463,7 +473,7 @@ static int run_ua_monitor_start_absence_presence(
 
        ret = ua_monitor_start_presence_detection(g_ua_mon_h,
                        (g_service_str[0] == '\0' ? NULL : g_service_h),
-                       detection_mode, __device_presence_detected_cb, g_ua_mon_h);
+                       detection_mode, __sensor_presence_detected_cb, g_ua_mon_h);
        msg(" - ua_monitor_start_presence_detection() ret: [0x%X] [%s]",
                ret, uat_get_error_str(ret));