double *values; /**< Sensor data */
} ua_sensor_info_s;
+/**
+ * @brief location info data structure.
+ * @since_tizen 6.5
+ */
+typedef struct {
+ unsigned int distance; /**< Device distance in mm */
+ unsigned int x; /**< Device x coordinate */
+ unsigned int y; /**< Device y coordinate */
+ unsigned int z; /**< Device z coordinate */
+} ua_location_info_s;
+
/**
* @brief User state data structure.
* @since_tizen 6.5
void _ua_monitor_handle_user_absence_detected(
uam_sensor_info_s *sensor_info, char *service, char *account);
+/**
+ * @brief Calls the location callback when detected registerd devices.
+ * @since_tizen 6.5
+ *
+ * @param[in] bitmask Bitmask for sensors
+ * @param[in] service Service information
+ * @param[in] account Account information
+ *
+ * @exception
+ * @pre
+ * @post
+ */
+void _ua_monitor_handle_user_location_detected(
+ uam_sensor_info_s *sensor_info, char *service,
+ char *account, uam_device_info_s *device,
+ char *device_id);
+
/**
* @brief Calls the sensor status changed callback when notified of sensor status changed.
* @since_tizen 6.5
break;
}
+ case UAM_EVENT_USER_LOCATION_DETECTED: {
+ uam_detection_event_data_s *event_data = NULL;
+ uam_sensor_info_s *sensor_info = NULL;
+ uam_device_info_s *device_info = NULL;
+
+ event_data = event_param->data;
+ ret_if(NULL == event_data);
+ ret_if(NULL == event_data->service);
+ ret_if(NULL == event_data->account);
+ ret_if(NULL == event_data->device_id);
+
+ sensor_info = g_new0(uam_sensor_info_s, 1);
+ ret_if(NULL == sensor_info);
+
+ sensor_info->sensor_bitmask = event_data->sensor_bitmask;
+ sensor_info->timestamp = event_data->last_seen;
+
+ device_info = g_new0(uam_device_info_s, 1);
+ ret_if(NULL == device_info);
+ device_info->distance_mm = event_data->distance_mm;
+ device_info->x = event_data->x;
+ device_info->y = event_data->y;
+ device_info->z = event_data->z;
+
+ UA_INFO("sensor_info: bitmask[%u], timestamp [%llu]",
+ sensor_info->sensor_bitmask, sensor_info->timestamp);
+
+ _ua_monitor_handle_user_location_detected(
+ sensor_info, event_data->service,
+ event_data->account, device_info,
+ event_data->device_id);
+ g_free(sensor_info);
+
+ break;
+ }
case UAM_EVENT_PRESENCE_DETECTED: {
uam_sensor_info_s *sensor_info = NULL;
FUNC_EXIT;
}
+static void __ua_monitor_send_location_cb(ua_monitor_s *monitor,
+ ua_device_h device_handle, ua_sensor_info_s *sensor_info,
+ char* account, ua_location_info_s *location_info)
+{
+ FUNC_ENTRY;
+ ua_sensor_type_e bitmask = sensor_info->bitmask;
+ ua_sensor_h sensor_handle;
+ ua_service_info_s *service = NULL;
+ ua_service_h service_handle = NULL;
+ ua_service_h user_handle = NULL;
+ ua_location_h location_handle = NULL;
+ int ret;
+
+ /* Get sensor handle */
+ ret = _ua_sensor_get_by_sensor_info(sensor_info, &sensor_handle);
+ if (UA_ERROR_NONE != ret) {
+ UA_INFO("_ua_sensor_get_by_sensor_info returned %s",
+ _ua_get_error_string(ret));
+ }
+
+ /* Get service handle */
+ service = __ua_get_service_from_list(monitor->service);
+ if (service)
+ service_handle = service->service_handle;
+
+ /* Get user handle */
+ if (account)
+ user_handle = _ua_get_user_handle_by_account(account);
+
+ /* Get location handle */
+ location_handle = (ua_location_h)location_info;
+
+ /* Send location callback */
+ monitor->location_cb(UA_ERROR_NONE, monitor,
+ service_handle, bitmask, sensor_handle,
+ device_handle, user_handle, location_handle,
+ monitor->user_data);
+
+ FUNC_EXIT;
+ return;
+}
+
+static void __ua_sensor_location_detected(ua_monitor_s *monitor,
+ ua_sensor_info_s *sensor_info, char *account,
+ ua_location_info_s *location_info, char *device_id)
+{
+ FUNC_ENTRY;
+
+ int ret = UA_ERROR_NONE;
+ ua_device_h device_handle = NULL;
+ ua_sensor_type_e bitmask = sensor_info->bitmask;
+
+ ret_if(NULL == monitor);
+
+ if (!monitor->location_detection_started) {
+ FUNC_EXIT;
+ return;
+ }
+
+ /* Get device */
+ ret = ua_device_get_by_device_id(device_id,
+ _ua_sensor_to_dev_type(bitmask), &device_handle);
+ UA_INFO("ua_device_get_by_device_id returned %s",
+ _ua_get_error_string(ret));
+
+ __ua_monitor_send_location_cb(monitor, device_handle,
+ sensor_info, account, location_info);
+
+ FUNC_EXIT;
+}
+
+
void _ua_monitor_handle_scanned_device(int result, uam_device_info_s *uam_info)
{
FUNC_ENTRY;
FUNC_EXIT;
}
+void _ua_monitor_handle_user_location_detected(
+ uam_sensor_info_s *info, char *service, char *account,
+ uam_device_info_s *device_info, char *device_id)
+{
+ FUNC_ENTRY;
+ GSList *l;
+ ua_sensor_info_s *sensor_info;
+ ua_sensor_type_e bitmask;
+ ua_location_info_s *location_info;
+ ret_if(NULL == info || NULL == device_info);
+
+ sensor_info = _uam_to_ua_sensor_info(info);
+ ret_if(NULL == sensor_info);
+ bitmask = sensor_info->bitmask;
+
+ location_info = _uam_to_ua_location_info(device_info);
+ ret_if(NULL == location_info);
+
+ for (l = ua_monitor_list; l; l = g_slist_next(l)) {
+ ua_monitor_s *monitor = l->data;
+
+ if (!monitor || (!monitor->location_detection_started))
+ continue;
+
+ if (0 == (bitmask & monitor->sensor_bitmask))
+ continue;
+
+ if (!service || !g_strcmp0(service, monitor->service)) {
+ /* Location detection ongoing */
+ __ua_sensor_location_detected(monitor, sensor_info,
+ account, location_info, device_id);
+ }
+ }
+ _ua_free_sensor_info(sensor_info);
+ g_free(location_info);
+
+ FUNC_EXIT;
+}
+
void _ua_monitor_handle_detection_stopped(char *svc_name,
uam_cycle_state_e cycle_state)
{