char device_id[UAM_DEVICE_ID_MAX_STRING_LEN]; /**< Device's uniquie ID */
uam_ble_payload_s payload; /**< BLE Payload to parse BLE devices*/
gboolean discriminant; /**< Determines whether to judge PRESENCE/ABSENCE */
- long last_seen; /**< Latest timestamp when device was discoverd */
+ unsigned long long last_seen; /**< Latest timestamp when device was discoverd */
} uam_device_info_s;
/**
typedef struct {
unsigned int status; /**< Sensor status */
unsigned int sensor_bitmask; /**< sensor bitmask of discovered sensor */
- long timestamp; /**< Latest timestamp when sensor was discoverd */
+ unsigned long 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 */
unsigned int sensor_bitmask; /**< Detecting sensor's bitmask */
char account[UAM_USER_ACCOUNT_MAX_STRING_LEN]; /**< User account */
char service[UAM_SERVICE_MAX_STRING_LEN]; /**< Service name */
- long timestamp; /**< Timestamp of detection */
+ unsigned long long timestamp; /**< Timestamp of detection */
char device_id[UAM_DEVICE_ID_MAX_STRING_LEN]; /**< Device's unique ID */
} uam_detection_event_data_s;
Name: ua-manager
Summary: User awareness manager
-Version: 0.12.0
+Version: 0.12.1
Release: 1
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
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)
+ unsigned int bitmask, unsigned long long timestamp, int accuracy, int count, double *values)
{
FUNC_ENTRY;
sensor_info->values[i] = values[i];
}
- UAM_INFO("status [%d] sensor bitmask [%u] timestamp [%ld] accuracy [%d]" \
+ UAM_INFO("status [%d] sensor bitmask [%u] timestamp [%llu] 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],
const char *account = NULL;
const char *service = NULL;
const char *device_id = NULL;
- long timestamp;
+ unsigned long long timestamp;
- g_variant_get(parameters, "(u&s&s&sx)", &sensor_bitmask, &account,
+ g_variant_get(parameters, "(u&s&s&st)", &sensor_bitmask, &account,
&service, &device_id, ×tamp);
UAM_DBG("Sensor: 0x%8.8X, User: %s, Device: %s", sensor_bitmask,
unsigned int sensor_bitmask;
char *account = NULL;
char *service = NULL;
- long timestamp;
+ unsigned long long timestamp;
- g_variant_get(parameters, "(u&s&sx)", &sensor_bitmask, &account,
+ g_variant_get(parameters, "(u&s&st)", &sensor_bitmask, &account,
&service, ×tamp);
UAM_DBG("Sensor: 0x%8.8X, User: %s", sensor_bitmask, account);
} else if (0 == strcasecmp(signal_name, UAM_SIGNAL_PRESENCE_DETECTED)) {
uam_sensor_info_s sensor_info;
unsigned int sensor_bitmask;
- long int timestamp;
+ unsigned long long timestamp;
int accuracy, count;
double values[UAM_SENSOR_MAX_VALUES];
- g_variant_get(parameters, "(uiiidddd)", &sensor_bitmask, ×tamp,
+ g_variant_get(parameters, "(utiidddd)", &sensor_bitmask, ×tamp,
&accuracy, &count, &values[0], &values[1],
&values[2], &values[3]);
- memset(&sensor_info, 0, sizeof(uam_sensor_info_s));
+
+ __uam_copy_sensor_data(&sensor_info, 0, sensor_bitmask, timestamp,
+ accuracy, count, values);
+
event = UAM_EVENT_PRESENCE_DETECTED;
- 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]);
+
__uam_send_event(event, result, &sensor_info,
event_info->cb, event_info->user_data);
} else if (0 == strcasecmp(signal_name, UAM_SIGNAL_ABSENCE_DETECTED)) {
uam_sensor_info_s sensor_info;
unsigned int sensor_bitmask;
- long int timestamp;
+ unsigned long long timestamp;
int accuracy, count;
double values[UAM_SENSOR_MAX_VALUES];
- g_variant_get(parameters, "(uiiidddd)", &sensor_bitmask, ×tamp,
+ g_variant_get(parameters, "(utiidddd)", &sensor_bitmask, ×tamp,
&accuracy, &count, &values[0], &values[1],
&values[2], &values[3]);
- memset(&sensor_info, 0, sizeof(uam_sensor_info_s));
+
+ __uam_copy_sensor_data(&sensor_info, 0, sensor_bitmask, timestamp,
+ accuracy, count, values);
+
event = UAM_EVENT_ABSENCE_DETECTED;
- 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]);
+
__uam_send_event(event, result, &sensor_info,
event_info->cb, event_info->user_data);
} else if (0 == strcasecmp(signal_name, UAM_SIGNAL_SENSOR_STATE_READY)) {
} else if (0 == strcasecmp(signal_name, UAM_SIGNAL_SENSOR_STATUS_CHANGED)) {
uam_sensor_info_s sensor_info;
unsigned int sensor_bitmask;
- long int timestamp;
+ unsigned long long timestamp;
int status, accuracy, count;
double values[UAM_SENSOR_MAX_VALUES];
- g_variant_get(parameters, "(uuiiidddd)", &status, &sensor_bitmask, ×tamp,
+ g_variant_get(parameters, "(uutiidddd)", &status, &sensor_bitmask, ×tamp,
&accuracy, &count, &values[0], &values[1],&values[2], &values[3]);
__uam_copy_sensor_data(&sensor_info, status, sensor_bitmask, timestamp,
uam_tech_type_e tech_type;
GSList *addresses;
int presence_state;
- long timestamp;
+ unsigned long long timestamp;
gboolean discriminant;
struct uam_db_device_info *device;
GSList *svc_list;
char *account;
GSList *devices;
// int presence_state;
- long timestamp;
+ unsigned long long timestamp;
} uam_db_user_info_t;
int user_id;
uam_device_info_s dev_info;
int presence_state;
- long timestamp;
+ unsigned long long timestamp;
} db_device_info_t;
/* db init/deinit */
/* insert */
int _uam_device_db_insert_device_info(
- int user_id, const uam_device_info_s *dev_info, int presence_state, long timestamp);
+ int user_id, const uam_device_info_s *dev_info, int presence_state,
+ unsigned long long timestamp);
/* update */
int _uam_device_db_update_device_timestamp(
- char *device_id, int tech_type, char *address, long timestamp);
+ char *device_id, int tech_type, char *address, unsigned long long timestamp);
int _uam_device_db_update_device_presence(
char *device_id, int tech_type, char *address, int presence_state);
int _uam_device_db_update_device_ip_address(
uas_sensor_info_t *info = NULL;
uam_sensor_info_s *motion_info = NULL;
- UAM_ERR("Motion: %s", type == UAS_PRESENCE ? "PRESENCE" : "ABSENCE");
+ UAM_DBG("Motion: %s", type == UAS_PRESENCE ? "PRESENCE" : "ABSENCE");
if (sensor_info)
info = sensor_info;
sensor_info->values[i] = info->values[i];
}
- UAM_INFO("t [%ld] Accuaracy [%d] Count [%d] Lux [%f] CCT [%f] Lv[%f] Cv[%f]",
+ UAM_INFO("t [%llu] 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]);
(*device_list)[indx].discriminant = tech->discriminant;
(*device_list)[indx].last_seen = tech->timestamp;
(*device_list)[indx++].type = tech->tech_type;
- UAM_INFO("%s-%d-%s-%s-%ld-%d-%d-0x%2.2X", (*device_list)[indx-1].device_id,
+ UAM_INFO("%s-%d-%s-%s-%llu-%d-%d-0x%2.2X", (*device_list)[indx-1].device_id,
(*device_list)[indx-1].type, (*device_list)[indx-1].mac, (*device_list)[indx-1].ipv4_addr,
(*device_list)[indx-1].last_seen, (*device_list)[indx-1].operating_system,
(*device_list)[indx-1].discriminant, (*device_list)[indx-1].payload.service_id);
static void __uam_core_add_dev_to_list(
uam_db_user_info_t *user, const uam_device_info_s *dev_info,
- int presence_state, long long timestamp, GSList *svc_list)
+ int presence_state, unsigned long long timestamp, GSList *svc_list)
{
FUNC_ENTRY;
uam_db_tech_info_t *tech;
int ret = UAM_ERROR_NONE;
uam_db_user_info_t *user = NULL;
GSList *svc_list = NULL;
- long long timestamp;
+ unsigned long long timestamp;
/* Send reply over dbus for add device API */
l = _uam_manager_get_request_list();
svc_list = g_slist_append(svc_list, service);
}
- timestamp = time(NULL);
+ timestamp = (unsigned long long)time(NULL);
__uam_core_add_dev_to_list(user, dev_info,
UAM_PRESENCE_STATE_PRESENT, timestamp, svc_list);
if (NULL == sensor_info) {
_uam_manager_send_event(NULL, UAM_EVENT_PRESENCE_DETECTED,
- g_variant_new("(uiiidddd)", sensor, 0, 0, 0, 0, 0, 0, 0));
+ g_variant_new("(utiidddd)", 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("(uiiidddd)", sensor, sensor_info->timestamp,
+ g_variant_new("(utiidddd)", 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("(uiiidddd)", sensor, sensor_info->timestamp,
+ g_variant_new("(utiidddd)", 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("(uiiidddd)", sensor, 0, 0, 0, 0, 0, 0, 0));
+ g_variant_new("(utiidddd)", 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("(uiiidddd)", sensor, sensor_info->timestamp,
+ g_variant_new("(utiidddd)", 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("(uiiidddd)", sensor, sensor_info->timestamp,
+ g_variant_new("(utiidddd)", 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);
if (UAM_DETECT_PRESENCE != mon->mode)
continue;
- user->timestamp = (long) time(NULL);
+ user->timestamp = (unsigned long long) time(NULL);
UAM_INFO("sensor [%d]", sensor);
_uam_manager_send_event(mon->name,
UAM_EVENT_USER_PRESENCE_DETECTED,
- g_variant_new("(usssx)", sensor,
+ g_variant_new("(ussst)", sensor,
user->account, svc->name,
device_id, user->timestamp));
UAM_DBG("Sent UAM_EVENT_USER_PRESENCE_DETECTED to %s"
tech = l->data;
tech->presence_state = UAM_PRESENCE_STATE_PRESENT;
- tech->timestamp = time(NULL);
+ tech->timestamp = (unsigned long long)time(NULL);
/* Check if IP address was updated then update in DB */
if (UAM_TECH_TYPE_WIFI == dev_info->type) {
if (!user)
continue;
- user->timestamp = (long) time(NULL);
+ user->timestamp = (unsigned long long) time(NULL);
_uam_manager_send_event(mon->name,
UAM_EVENT_USER_ABSENCE_DETECTED,
- g_variant_new("(ussx)", sensor,
+ g_variant_new("(usst)", sensor,
user->account, svc->name,
user->timestamp));
UAM_DBG("Sent UAM_EVENT_USER_ABSENCE_DETECTED to %s"
" for 0x%8.8X, User: %s Service: %s"
- " timestamp [%ld]",
+ " timestamp [%llu]",
mon->name, sensor, user->account,
svc->name, user->timestamp);
}
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));
+ g_variant_new("(uutiidddd)", 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,
+ g_variant_new("(uutiidddd)", 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]));
}
}
int _uam_device_db_update_device_timestamp(char *device_id, int tech_type,
- char *address, long timestamp)
+ char *address, unsigned long long timestamp)
{
int error_code = UAM_ERROR_NONE;
sqlite3_stmt *stmt = update_timestamp;
goto handle_error;
}
- UAM_DBG("Device timestamp updated [%ld]", timestamp);
+ UAM_DBG("Device timestamp updated [%llu]", timestamp);
handle_error:
sqlite3_reset(stmt);
}
int _uam_device_db_insert_device_info(int user_id,
- const uam_device_info_s *dev_info, int presence_state, long timestamp)
+ const uam_device_info_s *dev_info, int presence_state, unsigned long long timestamp)
{
FUNC_ENTRY;
int error_code = UAM_ERROR_NONE;
retv_if(NULL == dev_info, UAM_ERROR_INVALID_PARAMETER);
- UAM_INFO("%s-%d-%s-%s-%ld-%d-%d-%d-%d-0x%2.2X", dev_info->device_id,
+ UAM_INFO("%s-%d-%s-%s-%llu-%d-%d-%d-%d-0x%2.2X", dev_info->device_id,
dev_info->type, dev_info->mac, dev_info->ipv4_addr,
timestamp, presence_state, dev_info->operating_system, dev_info->discriminant,
user_id, dev_info->payload.service_id);
UAM_BLE_PAYLOAD_DUID_LEN);
info->dev_info.payload.device_icon = *(char *)sqlite3_column_text(stmt, 12);
- UAM_INFO("%s-%d-%s-%s-%ld-%d-%d-%d-%d-0x%2.2X",
+ UAM_INFO("%s-%d-%s-%s-%llu-%d-%d-%d-%d-0x%2.2X",
info->dev_info.device_id,
info->dev_info.type,
info->dev_info.mac,
UAM_BLE_PAYLOAD_DUID_LEN);
info->dev_info.payload.device_icon = *(char *)sqlite3_column_text(stmt, 12);
- UAM_INFO("%s-%d-%s-%s-%ld-%d-%d-%d-%d-0x%2.2X",
+ UAM_INFO("%s-%d-%s-%s-%llu-%d-%d-%d-%d-0x%2.2X",
info->dev_info.device_id,
info->dev_info.type,
info->dev_info.mac,
/* Sensor information structure */
typedef struct {
- long int timestamp;
+ unsigned long long timestamp;
int accuracy;
int count;
double *values;