UAM_EVENT_SCAN_COMPLETED, /**< Scan completed */
UAM_EVENT_SERVICE_REGISTERED, /**< Service registered */
UAM_EVENT_SERVICE_UNREGISTERED, /**< Service registered */
+ UAM_EVENT_SENSOR_STATUS_CHANGED, /**< Sensor status changed */
UAM_EVENT_MAX, /**< Max. event number */
} uam_event_e;
* @since_tizen 5.5
*/
typedef struct {
+ unsigned int status; /**< Sensor status */
unsigned int sensor_bitmask; /**< sensor bitmask of discovered sensor */
long timestamp; /**< Latest timestamp when sensor was discoverd */
int accuracy; /**< Accuracy info from sensor sensor */
#define UAM_SIGNAL_SCAN_COMPLETED "ScanCompleted"
#define UAM_SIGNAL_SERVICE_REGISTERED "ServiceRegistered"
#define UAM_SIGNAL_SERVICE_UNREGISTERED "ServiceUnregistered"
+#define UAM_SIGNAL_SENSOR_STATUS_CHANGED "SensorStatusChanged"
#define CASE_TO_STR(x) case x: return #x;
Name: ua-manager
Summary: User awareness manager
-Version: 0.11.7
+Version: 0.12.0
Release: 1
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
CASE_TO_STR(UAM_EVENT_SCAN_COMPLETED)
CASE_TO_STR(UAM_EVENT_SERVICE_REGISTERED)
CASE_TO_STR(UAM_EVENT_SERVICE_UNREGISTERED)
+ CASE_TO_STR(UAM_EVENT_SENSOR_STATUS_CHANGED)
default:
return "UNKNOWN ERROR";
}
static gboolean is_registered = FALSE;
static uam_event_handler_data_t *event_handler_data = NULL;
+static void __uam_copy_sensor_data(uam_sensor_info_s *sensor_info, int status,
+ unsigned int bitmask, long int timestamp, int accuracy, int count, double *values)
+{
+ FUNC_ENTRY;
+
+ ret_if(NULL == sensor_info);
+
+ memset(sensor_info, 0, sizeof(uam_sensor_info_s));
+ sensor_info->status = status;
+ sensor_info->sensor_bitmask = 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_INFO("status [%d] sensor bitmask [%u] timestamp [%ld] accuracy [%d]" \
+ "count [%d] value0 [%f] value1 [%f] value2 [%f] value3 [%f]",
+ sensor_info->status, 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]);
+
+ FUNC_EXIT;
+}
+
static void __uam_send_event(int event, int result,
void *data, void *callback, void *user_data)
{
int accuracy, count;
double values[UAM_SENSOR_MAX_VALUES];
- g_variant_get(parameters, "(uxiidddd)", &sensor_bitmask, ×tamp,
+ g_variant_get(parameters, "(uiiidddd)", &sensor_bitmask, ×tamp,
&accuracy, &count, &values[0], &values[1],
&values[2], &values[3]);
memset(&sensor_info, 0, sizeof(uam_sensor_info_s));
int accuracy, count;
double values[UAM_SENSOR_MAX_VALUES];
- g_variant_get(parameters, "(uxiidddd)", &sensor_bitmask, ×tamp,
+ g_variant_get(parameters, "(uiiidddd)", &sensor_bitmask, ×tamp,
&accuracy, &count, &values[0], &values[1],
&values[2], &values[3]);
memset(&sensor_info, 0, sizeof(uam_sensor_info_s));
event = UAM_EVENT_SERVICE_UNREGISTERED;
__uam_send_event(event, result, &svc_info,
event_info->cb, event_info->user_data);
+ } else if (0 == strcasecmp(signal_name, UAM_SIGNAL_SENSOR_STATUS_CHANGED)) {
+ uam_sensor_info_s sensor_info;
+ unsigned int sensor_bitmask;
+ long int timestamp;
+ int status, accuracy, count;
+ double values[UAM_SENSOR_MAX_VALUES];
+
+ g_variant_get(parameters, "(uuiiidddd)", &status, &sensor_bitmask, ×tamp,
+ &accuracy, &count, &values[0], &values[1],&values[2], &values[3]);
+
+ __uam_copy_sensor_data(&sensor_info, status, sensor_bitmask, timestamp,
+ accuracy, count, values);
+
+ event = UAM_EVENT_SENSOR_STATUS_CHANGED;
+
+ __uam_send_event(event, result, &sensor_info,
+ event_info->cb, event_info->user_data);
} else {
UAM_WARN("Unknown signal received: %s", signal_name);
}
int _uam_core_add_ibeacon_adv(unsigned int adv_len, const char *iadv);
+void _uam_core_handle_status_changed(unsigned int sensor,
+ unsigned int type, void *info);
+
#ifdef __cplusplus
}
#endif
uas_callbacks_t ble_cbs = {
.state_changed_cb = ble_state_changed_callback,
.detection_state_cb = ble_detection_state_changed_cb,
+ .detection_status_cb = NULL,
.detected_cb = ble_lpm_detection_callback,
.device_detected_cb = ble_device_detection_callback,
.device_added_cb = ble_device_added_callback,
uas_callbacks_t light_cbs = {
.state_changed_cb = light_state_changed_callback,
.detection_state_cb = light_detection_state_changed_cb,
+ .detection_status_cb = NULL,
.detected_cb = light_detection_callback,
.device_detected_cb = NULL,
.device_added_cb = NULL,
FUNC_EXIT;
}
+
+static void motion_detection_status_changed_cb(uas_detection_type_e type,
+ void *sensor_info)
+{
+ FUNC_ENTRY;
+
+ uas_sensor_info_t *info = NULL;
+ uam_sensor_info_s *motion_info = NULL;
+
+ UAM_ERR("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);
+
+ _uam_core_handle_status_changed(UAM_SENSOR_BITMASK_MOTION, type, motion_info);
+
+ g_free(motion_info);
+
+ FUNC_EXIT;
+}
+
void motion_detection_callback(uas_detection_type_e type, void *sensor_info)
{
FUNC_ENTRY;
uas_callbacks_t motion_cbs = {
.state_changed_cb = motion_state_changed_callback,
.detection_state_cb = motion_detection_state_changed_cb,
+ .detection_status_cb = motion_detection_status_changed_cb,
.detected_cb = motion_detection_callback,
.device_detected_cb = NULL,
.device_added_cb = NULL,
}
}
-uam_sensor_info_s *_pm_util_uas_sensor_info_to_uam_sensor_info(const uas_sensor_info_t *info)
+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;
uas_callbacks_t wifi_cbs = {
.state_changed_cb = wifi_state_changed_callback,
.detection_state_cb = wifi_detection_state_changed_cb,
+ .detection_status_cb = NULL,
.detected_cb = wifi_lpm_detection_callback,
.device_detected_cb = wifi_device_detection_callback,
.device_added_cb = wifi_device_added_callback,
#include <time.h>
#include "ua-api.h"
+#include "ua-plugin.h"
#include "ua-internal.h"
#include "ua-manager-common.h"
#include "ua-plugin-manager.h"
if (NULL == sensor_info) {
_uam_manager_send_event(NULL, UAM_EVENT_PRESENCE_DETECTED,
- g_variant_new("(uxiidddd)", sensor, 0, 0, 0, 0, 0, 0, 0));
+ g_variant_new("(uiiidddd)", sensor, 0, 0, 0, 0, 0, 0, 0));
UAM_DBG("Sent UAM_EVENT_PRESENCE_DETECTED for 0x%8.8X", sensor);
FUNC_EXIT;
return;
if (UAM_SENSOR_BITMASK_LIGHT != sensor) {
_uam_manager_send_event(NULL, UAM_EVENT_PRESENCE_DETECTED,
- g_variant_new("(uxiidddd)", sensor, sensor_info->timestamp,
+ g_variant_new("(uiiidddd)", 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);
continue;
_uam_manager_send_event(mon->name, UAM_EVENT_PRESENCE_DETECTED,
- g_variant_new("(uxiidddd)", sensor, sensor_info->timestamp,
+ g_variant_new("(uiiidddd)", 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 to %s for 0x%8.8X",
if (NULL == sensor_info) {
_uam_manager_send_event(NULL, UAM_EVENT_ABSENCE_DETECTED,
- g_variant_new("(uxiidddd)", sensor, 0, 0, 0, 0, 0, 0, 0));
+ g_variant_new("(uiiidddd)", sensor, 0, 0, 0, 0, 0, 0, 0));
UAM_DBG("Sent UAM_EVENT_ABSENCE_DETECTED for 0x%8.8X", sensor);
FUNC_EXIT;
return;
if (UAM_SENSOR_BITMASK_LIGHT != sensor) {
_uam_manager_send_event(NULL, UAM_EVENT_ABSENCE_DETECTED,
- g_variant_new("(uxiidddd)", sensor, sensor_info->timestamp,
+ g_variant_new("(uiiidddd)", 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_ABSENCE_DETECTED for 0x%8.8X", sensor);
continue;
_uam_manager_send_event(mon->name, UAM_EVENT_ABSENCE_DETECTED,
- g_variant_new("(uxiidddd)", sensor, sensor_info->timestamp,
+ g_variant_new("(uiiidddd)", 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_ABSENCE_DETECTED for 0x%8.8X", sensor);
FUNC_EXIT;
return UAM_ERROR_NONE;
}
+
+void _uam_core_handle_status_changed(unsigned int sensor, unsigned int type,
+ void *info)
+{
+ FUNC_ENTRY;
+
+ uam_sensor_info_s *sensor_info = info;
+
+ ret_if(NULL == info);
+
+ sensor_info->status = type;
+
+ UAM_INFO("sensor: 0x%8.8X, detection_type: %d", sensor, type);
+
+ if (UAS_ABSENCE == type) {
+ _uam_manager_send_event(NULL, UAM_EVENT_SENSOR_STATUS_CHANGED,
+ g_variant_new("(uuiiidddd)", type, sensor, 0, 0, 0, 0, 0, 0, 0));
+ UAM_DBG("Sent UAM_EVENT_ABSENCE_DETECTED for 0x%8.8X", sensor);
+ } else {
+ _uam_manager_send_event(NULL, UAM_EVENT_SENSOR_STATUS_CHANGED,
+ g_variant_new("(uuiiidddd)", type, 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]));
+ }
+
+ FUNC_EXIT;
+}
+
case UAM_EVENT_SERVICE_UNREGISTERED:
signal = UAM_SIGNAL_SERVICE_UNREGISTERED;
break;
+ case UAM_EVENT_SENSOR_STATUS_CHANGED:
+ signal = UAM_SIGNAL_SENSOR_STATUS_CHANGED;
+ break;
default:
UAM_ERR("Unhandled event");
return UAM_ERROR_INTERNAL;
typedef void (*uas_detection_state_changed_callback)(int state);
/*
+ * Callback to be invoked on Presen/Absence detection status during detection operation
+ * by plug-in's which do not support User identification.
+ */
+typedef void (*uas_detection_status_changed_callback)(uas_detection_type_e type,
+ void *sensor_info);
+
+/*
* Callback to be invoked on Presen/Absence detection by plug-in's which do
* not support User identification.
*/
*
* [Param] device - Device for which Presence/Absence is detected.
*/
-typedef void (*uas_device_detection_callback)(uas_detection_type_e type, uas_device_info_t *device);
+typedef void (*uas_device_detection_callback)(uas_detection_type_e type,
+ uas_device_info_t *device);
/*
* Callback to be invoked in response to add_device() API
* [Param] device - Found registerd device info if event is UAS_ACTIVE_DEVICE_FOUND
* or, NULL if event is UAS_ACTIVE_SCAN_COMPLETED.
*/
-typedef void (*uas_active_device_scan_callback)(
+typedef void (*uas_device_active_scan_callback)(
uas_active_scan_event_e event, const uas_device_info_t *device);
/* UA plug-in callback structure */
typedef struct {
- uas_state_changed_callback state_changed_cb;
- uas_detection_state_changed_callback detection_state_cb;
- uas_detection_callback detected_cb;
- uas_device_detection_callback device_detected_cb;
- uas_device_added_callback device_added_cb;
- uas_active_device_scan_callback active_scan_cb;
+ uas_state_changed_callback state_changed_cb; /**< 0:Not ready 1:Ready */
+ uas_detection_state_changed_callback detection_state_cb; /**< 0:Stop 1:Start */
+ uas_detection_status_changed_callback detection_status_cb; /**< 1: change with param */
+ uas_detection_callback detected_cb; /**< For environmental sensors */
+ uas_device_detection_callback device_detected_cb; /**< For connectivity sensors */
+ uas_device_added_callback device_added_cb; /**< For connectivity sensors */
+ uas_device_active_scan_callback active_scan_cb; /**< For connectivity sensors */
} uas_callbacks_t;
typedef struct {