break;
}
case UAM_EVENT_DETECTION_STOPPED: {
- _ua_monitor_handle_detection_stopped();
+ uam_detection_stopped_event_data_s *event_data = event_param->data;
+ ret_if(NULL == event_data);
+ ret_if(NULL == event_data->service);
+
+ _ua_monitor_handle_detection_stopped(event_data->service,
+ event_data->cycle_state);
break;
}
case UAM_EVENT_SENSOR_STATE_READY: {
FUNC_EXIT;
}
-static void __ua_user_state_clean()
+static void __ua_user_state_clean(char *svc_name)
{
FUNC_ENTRY;
GSList *l;
for (l = ua_monitor_list; NULL != l; l = g_slist_next(l)) {
ua_monitor_s *monitor = l->data;
- if (!monitor)
+ if (!monitor || g_strcmp0(monitor->service, svc_name))
continue;
g_slist_free_full(monitor->user_state, __ua_free_user_state_info_t);
+ monitor->presence_detected_bitmask = 0;
+ monitor->absence_detected_bitmask = 0;
monitor->user_state = NULL;
monitor->env_user_cb_sent = FALSE;
}
return;
}
-static void __ua_send_presence_detection()
+static void __ua_send_presence_detection(char *svc_name)
{
FUNC_ENTRY;
GSList *l;
for (l = ua_monitor_list; NULL != l; l = g_slist_next(l)) {
ua_monitor_s *monitor = l->data;
- if (!monitor)
+ if (!monitor || g_strcmp0(monitor->service, svc_name))
continue;
if (monitor->presence_mode != UA_DETECT_MODE_ANY_SENSOR) {
}
}
- monitor->presence_detected_bitmask = 0;
+ /* Only reset environmental sensors presence data */
+ monitor->presence_detected_bitmask &=
+ ~(UA_SENSOR_MOTION | UA_SENSOR_LIGHT);
}
FUNC_EXIT;
return;
}
-static void __ua_send_absence_detection()
+static void __ua_send_absence_detection(char *svc_name)
{
FUNC_ENTRY;
GSList *l;
for (l = ua_monitor_list; NULL != l; l = g_slist_next(l)) {
ua_monitor_s *monitor = l->data;
- if (!monitor)
+ if (!monitor || g_strcmp0(monitor->service, svc_name))
continue;
UA_INFO("monitor->sensor_bitmask: 0x%8.8X, monitor->absence_detected_bitmask: 0x%8.8X",
}
}
- monitor->absence_detected_bitmask = 0;
+ /* Only reset environmental sensors presence data */
+ monitor->absence_detected_bitmask &=
+ ~(UA_SENSOR_MOTION | UA_SENSOR_LIGHT);
}
FUNC_EXIT;
FUNC_EXIT;
}
-void _ua_monitor_handle_detection_stopped()
+void _ua_monitor_handle_detection_stopped(char *svc_name,
+ uam_cycle_state_e cycle_state)
{
FUNC_ENTRY;
- __ua_send_presence_detection();
- __ua_send_absence_detection();
- __ua_user_state_clean();
+ __ua_send_presence_detection(svc_name);
+ __ua_send_absence_detection(svc_name);
+
+ if (cycle_state == UAM_DETECTION_CYCLE_END)
+ __ua_user_state_clean(svc_name);
FUNC_EXIT;
}