#define UAM_IBEACON_ADV_MAX_LEN 31
/**
+ * @brief Maximum number of values from sensor.
+ * @since_tizen 5.5
+ */
+#define UAM_SENSOR_MAX_VALUES 4
+
+/**
* @brief Enumerations macro of UA framework event codes.
* @since_tizen 5.5
*/
} uam_device_info_s;
/**
+ * @brief Light info structure.
+ * @since_tizen 5.5
+ */
+typedef struct {
+ unsigned int sensor_bitmask; /**< sensor bitmask of discovered sensor */
+ long timestamp; /**< Latest timestamp when sensor was discoverd */
+ int accuracy; /**< Accuracy info from sensor sensor */
+ int count; /**< count of values from sensor sensor */
+ double values[UAM_SENSOR_MAX_VALUES]; /**< info from sensor */
+} uam_sensor_info_s;
+
+/**
* @brief User info structure.
* @since_tizen 5.5
*/
Name: ua-manager
Summary: User awareness manager
-Version: 0.9.6
+Version: 0.10.0
Release: 1
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
__uam_send_event(event, result, &event_data,
event_info->cb, event_info->user_data);
} else if (0 == strcasecmp(signal_name, UAM_SIGNAL_PRESENCE_DETECTED)) {
+ uam_sensor_info_s sensor_info;
unsigned int sensor_bitmask;
-
- g_variant_get(parameters, "(u)", &sensor_bitmask);
+ long int timestamp;
+ int accuracy, count;
+ double values[UAM_SENSOR_MAX_VALUES];
+
+ UAM_DBG("Get sensor values");
+ memset(&sensor_info, 0, sizeof(uam_sensor_info_s));
+ memset(&sensor_info.values, 0, UAM_SENSOR_MAX_VALUES);
+ g_variant_get(parameters, "(uxiidddd)", &sensor_bitmask, ×tamp,
+ &accuracy, &count, &values[0], &values[1],
+ &values[2], &values[2]);
+ sensor_info.sensor_bitmask = sensor_bitmask;
+ sensor_info.timestamp = timestamp;
+ sensor_info.accuracy = accuracy;
+ sensor_info.count = count;
+ for (int i = 0; i < UAM_SENSOR_MAX_VALUES; i++) {
+ sensor_info.values[i] = values[i];
+ }
+
+ UAM_DBG("sensor bitmask [%u] timestamp [%ld] accuracy [%d] count [%d] " \
+ "value0 [%f] value1 [%f] value2 [%f] value3 [%f]",
+ sensor_info.sensor_bitmask, sensor_info.timestamp,
+ sensor_info.accuracy, sensor_info.count, sensor_info.values[0],
+ sensor_info.values[1], sensor_info.values[2], sensor_info.values[3]);
event = UAM_EVENT_PRESENCE_DETECTED;
- __uam_send_event(event, result, &sensor_bitmask,
+ __uam_send_event(event, result, &sensor_info,
event_info->cb, event_info->user_data);
} else if (0 == strcasecmp(signal_name, UAM_SIGNAL_ABSENCE_DETECTED)) {
unsigned int sensor_bitmask;
int user_id, const uam_device_info_s *dev_info);
void _uam_core_handle_presence_detected(unsigned int sensor,
- int user_id, uam_device_info_s *dev_info);
+ int user_id, void *sensor_info);
void _uam_core_handle_absence_detected(unsigned int sensor,
- int user_id, uam_device_info_s *dev_info);
+ int user_id, void *sensor_info);
void _uam_core_cleanup_monitor(char *name);
FUNC_EXIT;
}
-static void ble_lpm_detection_callback(uas_detection_type_e type)
+static void ble_lpm_detection_callback(uas_detection_type_e type, void *sensor_info)
{
FUNC_ENTRY;
#include <ua-plugin.h>
#include <ua-plugin-manager.h>
+#include "ua-pm-util.h"
void light_state_changed_callback(int state)
{
FUNC_EXIT;
}
-void light_detection_callback(uas_detection_type_e type)
+void light_detection_callback(uas_detection_type_e type, void *sensor_info)
{
FUNC_ENTRY;
+ uas_sensor_info_t *info;
+ uam_sensor_info_s *light_info = NULL;
UAM_DBG("Light: %s", type == UAS_PRESENCE ? "PRESENCE" : "ABSENCE");
+ info = sensor_info;
+ light_info = _pm_util_uas_sensor_info_to_uam_sensor_info(info);
if (UAS_PRESENCE == type) {
UAM_DBG("Presence detected by light sensor");
- _uam_core_handle_presence_detected(UAM_SENSOR_BITMASK_LIGHT, 0, NULL);
+ _uam_core_handle_presence_detected(UAM_SENSOR_BITMASK_LIGHT, 0, light_info);
} else {
UAM_DBG("Absence detected by light sensor");
- _uam_core_handle_absence_detected(UAM_SENSOR_BITMASK_LIGHT, 0, NULL);
+ _uam_core_handle_absence_detected(UAM_SENSOR_BITMASK_LIGHT, 0, light_info);
}
FUNC_EXIT;
#include <ua-plugin.h>
#include <ua-plugin-manager.h>
+#include "ua-pm-util.h"
void motion_state_changed_callback(int state)
{
FUNC_EXIT;
}
-void motion_detection_callback(uas_detection_type_e type)
+void motion_detection_callback(uas_detection_type_e type, void *sensor_info)
{
FUNC_ENTRY;
+ uas_sensor_info_t *info = NULL;
+ uam_sensor_info_s *motion_info = NULL;
UAM_DBG("Motion: %s", type == UAS_PRESENCE ? "PRESENCE" : "ABSENCE");
+ if (sensor_info)
+ info = sensor_info;
+ motion_info = _pm_util_uas_sensor_info_to_uam_sensor_info(info);
+
if (UAS_PRESENCE == type) {
UAM_DBG("Presence detected by motion sensor");
- _uam_core_handle_presence_detected(UAM_SENSOR_BITMASK_MOTION, 0, NULL);
+ _uam_core_handle_presence_detected(UAM_SENSOR_BITMASK_MOTION, 0, motion_info);
} else {
UAM_DBG("Absence detected by motion sensor");
- _uam_core_handle_absence_detected(UAM_SENSOR_BITMASK_MOTION, 0, NULL);
+ _uam_core_handle_absence_detected(UAM_SENSOR_BITMASK_MOTION, 0, motion_info);
}
FUNC_EXIT;
return 0;
}
}
+
+uam_sensor_info_s *_pm_util_uas_sensor_info_to_uam_sensor_info(const uas_sensor_info_t *info)
+{
+ FUNC_ENTRY;
+ uam_sensor_info_s *sensor_info;
+ unsigned int i = 0;
+ retv_if(NULL == info, NULL);
+
+ sensor_info = g_new0(uam_sensor_info_s, 1);
+ retv_if(NULL == sensor_info, NULL);
+
+ sensor_info->timestamp = info->timestamp;
+ sensor_info->accuracy = info->accuracy;
+ sensor_info->count = info->count;
+ for (i = 0; i < info->count; i++) {
+ sensor_info->values[i] = info->values[i];
+ }
+
+ UAM_INFO("t [%ld] Accuaracy [%d] Count [%d] Lux [%f] CCT [%f] Lv[%f] Cv[%f]",
+ sensor_info->timestamp, sensor_info->accuracy, sensor_info->count,
+ sensor_info->values[0], sensor_info->values[1], sensor_info->values[2],
+ sensor_info->values[3]);
+
+ FUNC_EXIT;
+ return sensor_info;
+}
uam_active_scan_event_e _pm_util_uas_scan_event_to_uam_scan_event(uas_active_scan_event_e event);
+uam_sensor_info_s *_pm_util_uas_sensor_info_to_uam_sensor_info(const uas_sensor_info_t *info);
+
#ifdef __cplusplus
}
#endif
FUNC_EXIT;
}
-static void wifi_lpm_detection_callback(uas_detection_type_e type)
+static void wifi_lpm_detection_callback(uas_detection_type_e type, void *sensor_info)
{
FUNC_ENTRY;
}
void _uam_core_handle_presence_detected(unsigned int sensor,
- int user_id, uam_device_info_s *dev_info)
+ int user_id, void *info)
{
FUNC_ENTRY;
uam_db_user_info_t *user;
uam_db_device_info_t *device;
uam_db_tech_info_t *tech;
GSList *l;
+ uam_device_info_s *dev_info = NULL;
+ uam_sensor_info_s *sensor_info = NULL;
UAM_INFO("sensor: 0x%8.8X, user_id: %d", sensor, user_id);
+ sensor_info = g_new0(uam_sensor_info_s, 1);
+ if (info && (UAM_SENSOR_BITMASK_LIGHT == sensor || UAM_SENSOR_BITMASK_MOTION == sensor))
+ sensor_info = info;
+ if (info && (UAM_SENSOR_BITMASK_BLE == sensor || UAM_SENSOR_BITMASK_WIFI == sensor))
+ dev_info = info;
+
_uam_ppm_send_presence_detection_event(sensor);
if (NULL == dev_info) {
_uam_manager_send_event(NULL, UAM_EVENT_PRESENCE_DETECTED,
- g_variant_new("(u)", sensor));
+ g_variant_new("(uxiidddd)", sensor, sensor_info->timestamp,
+ sensor_info->accuracy, sensor_info->count, sensor_info->values[0],
+ sensor_info->values[1], sensor_info->values[2], sensor_info->values[3]));
UAM_DBG("Sent UAM_EVENT_PRESENCE_DETECTED for 0x%8.8X", sensor);
FUNC_EXIT;
return;
}
void _uam_core_handle_absence_detected(unsigned int sensor,
- int user_id, uam_device_info_s *dev_info)
+ int user_id, void *info)
{
FUNC_ENTRY;
uam_db_user_info_t *user;
uam_db_device_info_t *device;
uam_db_tech_info_t *tech;
GSList *l;
+ uam_device_info_s *dev_info = NULL;
UAM_INFO("sensor: 0x%8.8X, user_id: %d", sensor, user_id);
+ if (info && (UAM_SENSOR_BITMASK_BLE == sensor || UAM_SENSOR_BITMASK_WIFI == sensor))
+ dev_info = info;
+
if (NULL == dev_info) {
_uam_manager_send_event(NULL, UAM_EVENT_ABSENCE_DETECTED,
g_variant_new("(u)", sensor));
uas_ble_payload_t *payload;
} uas_device_info_t;
+/* Sensor information structure */
+typedef struct {
+ long int timestamp;
+ int accuracy;
+ int count;
+ double *values;
+} uas_sensor_info_t;
+
/* Active scan event types */
typedef enum {
UAS_ACTIVE_DEVICE_FOUND = 0x01,
* Callback to be invoked on Presen/Absence detection by plug-in's which do
* not support User identification.
*/
-typedef void (*uas_detection_callback)(uas_detection_type_e type);
+typedef void (*uas_detection_callback)(uas_detection_type_e type, void *sensor_info);
/*
* Callback to be invoked on Presen/Absence detection by plug-in's which