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);
+ msg("\n[%s] Sensor PRESENCE [%d]", pbuf, sensor);
free(pbuf);
- ua_sensor_info_s *info;
+ ua_sensor_info_s *info = NULL;
info = user_data;
+
if (UA_SENSOR_BLE == (UA_SENSOR_BLE & sensor)) {
msgb("[%s] PRESENCE detected [%s]",
uat_get_sensor_bitmask_str(UA_SENSOR_BLE), uat_get_error_str(result));
- __sensor_presence_detected_device(device_handle);
}
if (UA_SENSOR_WIFI == (UA_SENSOR_WIFI & sensor)) {
msgb("[%s] PRESENCE detected [%s]",
uat_get_sensor_bitmask_str(UA_SENSOR_WIFI), uat_get_error_str(result));
- __sensor_presence_detected_device(device_handle);
}
-
if (UA_SENSOR_LIGHT == (UA_SENSOR_LIGHT & sensor)) {
- /* For sensor information */
+ msgb("[%s] PRESENCE detected [%s]",
+ uat_get_sensor_bitmask_str(UA_SENSOR_LIGHT), uat_get_error_str(result));
+ }
+ if (UA_SENSOR_MOTION == (UA_SENSOR_MOTION & sensor)) {
+ msgb("[%s] PRESENCE detected [%s]",
+ uat_get_sensor_bitmask_str(UA_SENSOR_MOTION), uat_get_error_str(result));
+ }
+
+ /* For device information */
+ if (device_handle)
+ __sensor_presence_detected_device(device_handle);
+ /* For sensor information */
+ if (info && (sensor & (UA_SENSOR_LIGHT | UA_SENSOR_MOTION))) {
for (int i = 0; i < info->count ; i++) {
if (i >= 4)
break;
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,
- 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));
+ msgb("[%s] information detected at timestamp [%ld] value [%s]",
+ uat_get_sensor_bitmask_str(info->bitmask), info->timestamp,
+ final_buf);
}
}