* @since_tizen 5.5
*/
typedef struct {
- unsigned int status; /**< Sensor status 1:PRESENCE 2:ABSENCE */
+ unsigned int status; /**< Sensor status 1:PRESENCE 2:ABSENCE */
ua_sensor_h handle; /**< Sensor handle */
ua_sensor_e bitmask; /**< Sensor bitmask */
unsigned long long timestamp; /**< Timestamp */
ua_monitor_h handle,
void *user_data);
+/**
+ * @ingroup CAPI_NETWORK_UA_MODULE
+ * @brief Callback to be invoked if a sensor status changed (presence <-> absence)
+ * immediately during detection operation.
+ * @since_tizen 5.5
+ *
+ * @remarks The @a handle should not be released.
+ * @remarks The @a handle can be used only in the callback.
+ * @remarks The @a sensor_handles should not be released.
+ * @remarks The @a sensor_handles can be used only in the callback.
+ *
+ * @param[in] status #UA_SENSOR_PRESENCE is sensor detects presence. \n
+ * #UA_SENSOR_ABSENCE is sensor detects presence.
+ * @param[in] sensor Sensor type for which status was changed.
+ * @param[in] handle The monitor handle for which sensor type was added.
+ * @param[in] sensor_handles The list of sensor handles on which user is not detected.
+ * @param[in] user_data The user data passed in ua_monitor_set_sensor_status_cb().
+ *
+ * @exception
+ * @pre
+ * @post
+ *
+ * @see ua_monitor_set_sensor_state_cb()
+ */
+typedef void (*ua_sensor_status_changed_cb)(
+ ua_monitor_h handle,
+ ua_sensor_h sensor_handle,
+ void *user_data);
+
/**
* @ingroup CAPI_NETWORK_UA_MODULE
* @brief Callback to get all sensors for a handle.
ua_device_h device_handle,
void *user_data);
-/**
- * @ingroup CAPI_NETWORK_UA_MODULE
- * @brief Callback to be invoked if a sensor status changed (presence <-> absence)
- * immediately during detection operation.
- * @since_tizen 5.5
- *
- * @remarks The @a handle should not be released.
- * @remarks The @a handle can be used only in the callback.
- * @remarks The @a sensor_handles should not be released.
- * @remarks The @a sensor_handles can be used only in the callback.
- *
- * @param[in] status #UA_SENSOR_PRESENCE is sensor detects presence. \n
- * #UA_SENSOR_ABSENCE is sensor detects presence.
- * @param[in] sensor Sensor type for which status was changed.
- * @param[in] handle The monitor handle for which sensor type was added.
- * @param[in] sensor_handles The list of sensor handles on which user is not detected.
- * @param[in] user_data The user data passed in ua_monitor_set_sensor_status_cb().
- *
- * @exception
- * @pre
- * @post
- *
- * @see ua_monitor_set_sensor_state_cb()
- */
-typedef void (*ua_sensor_status_changed_cb)(
- ua_sensor_status_e status,
- ua_monitor_h handle,
- ua_sensor_h sensor_handle,
- void *user_data);
/**
* @ingroup CAPI_NETWORK_UA_MODULE
* @brief Initializes an user awareness framework.
ua_registered_dev_cb foreach_cb,
void *user_data);
+/**
+ * @ingroup CAPI_NETWORK_UA_MODULE
+ * @brief Gets sensor's status.
+ * @since_tizen 5.5
+ *
+ * @param[in] sensor_handle The sensor handle
+ * @param[out] status The sensor's status.
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #UA_ERROR_NONE Successful
+ * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @exception
+ * @pre
+ * @post
+ *
+ */
+int ua_sensor_get_status(
+ ua_sensor_h sensor_handle,
+ ua_sensor_status_e *status);
+
/**
* @ingroup CAPI_NETWORK_UA_MODULE
* @brief Gets sensor's timestamp.
Name: capi-network-ua
Summary: User Awareness Framework CAPI
-Version: 0.12.1
+Version: 0.12.2
Release: 1
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
ret = ua_sensor_get_by_sensor_info(sensor_info, &sensor_handle);
if (UA_ERROR_NONE != ret) {
- UA_INFO("ua_device_get_by_device_id returned %s",
+ UA_INFO("ua_sensor_get_by_sensor_info returned %s",
_ua_get_error_string(ret));
}
ret = ua_sensor_get_by_sensor_info(sensor_info, &sensor_handle);
if (UA_ERROR_NONE != ret) {
- UA_INFO("ua_device_get_by_device_id returned %s",
+ UA_INFO("ua_sensor_get_by_sensor_info returned %s",
_ua_get_error_string(ret));
}
void _ua_monitor_handle_sensor_status_changed(uam_sensor_info_s *info)
{
FUNC_ENTRY;
+
+ int ret;
GSList *l;
+ ua_sensor_h dummy;
+
ua_sensor_info_s *sensor_info;
ret_if(NULL == info);
sensor_info = _uam_to_ua_sensor_info(info);
ret_if(NULL == sensor_info);
+ ret = ua_sensor_get_by_sensor_info(sensor_info, &dummy);
+ if (UA_ERROR_NONE != ret) {
+ UA_INFO("ua_sensor_get_by_sensor_info returned %s",
+ _ua_get_error_string(ret));
+ }
+
for (l = ua_monitor_list; l; l = g_slist_next(l)) {
ua_monitor_s *monitor = l->data;
if (monitor->sensor_status_cb.callback)
((ua_sensor_status_changed_cb)monitor->sensor_status_cb.callback)(
- sensor_info->status, (ua_monitor_h)monitor, (ua_sensor_h)sensor_info,
+ (ua_monitor_h)monitor, (ua_sensor_h)sensor_info,
monitor->sensor_state_cb.user_data);
}
_ua_free_sensor_info(sensor_info);
return sensors;
}
+int ua_sensor_get_status(
+ ua_sensor_h sensor_handle,
+ ua_sensor_status_e *status)
+{
+ FUNC_ENTRY;
+ ua_sensor_info_s *sensor;
+
+ UA_VALIDATE_INPUT_PARAMETER(sensor_handle);
+ UA_INFO("Sensor Handle [%p]", sensor_handle);
+ sensor = (ua_sensor_info_s *)sensor_handle;
+
+ *status = sensor->status;
+
+ FUNC_EXIT;
+ return UA_ERROR_NONE;
+}
+
int ua_sensor_get_timestamp(
ua_sensor_h sensor_handle,
unsigned long long *timestamp)
UAT_MAC_TYPE_MAX
} uat_mac_type_e;
+typedef enum {
+ UAT_PRESENCE = 1,
+ UAT_ABSENCE = 2
+} uat_detection_type_e;
+
const char* uat_get_error_str(int err);
const char* uat_get_sensor_str(int sensors);
const char* uat_get_mac_type_str(int sensor);
static void __sensor_presence_detected_device(ua_device_h device_handle)
{
int ret;
- ua_mac_type_e mac_type;
char *mac = NULL;
+ ua_mac_type_e mac_type;
ret = ua_device_get_mac_address(device_handle, &mac);
if (UA_ERROR_NONE != ret) {
msg(" - ua_device_get_mac_type() ret: [0x%X] [%s]",
ret, uat_get_error_str(ret));
}
- msgb("Presence detected on [%s][%s]",
- __convert_device_mac_type_to_txt(mac_type), mac);
+ msgb("[%s] Presence detected on [%s]",
+ __convert_device_mac_type_to_txt(mac_type), mac);
g_free(mac);
}
-static void __sensor_presence_detected_sensor_info(ua_sensor_e sensor,
- ua_sensor_h sensor_handle)
+static void __sensor_detected_sensor_info(int type,
+ ua_sensor_e sensor, ua_sensor_h sensor_handle)
{
int ret;
- char buf[MENU_DATA_SIZE] = {0, };
- char final_buf[MENU_DATA_SIZE * 4] = {0, };
- unsigned long long timestamp;
- int info_count = 0;
- GSList *values = NULL;
double *value;
GSList *l = 0;
+ int info_count = 0;
+ GSList *values = NULL;
+ unsigned long long timestamp;
+ char buf[MENU_DATA_SIZE] = {0, };
+ char final_buf[MENU_DATA_SIZE * 4] = {0, };
ret = ua_sensor_get_timestamp(sensor_handle, ×tamp);
if (UA_ERROR_NONE != ret) {
strncat(final_buf, buf, sizeof(buf) - strlen(buf) - 1);
memset(buf, 0, MENU_DATA_SIZE);
}
- msgb("[%s] information detected at timestamp [%llu] value [%s]",
- uat_get_sensor_bitmask_str(sensor), timestamp,
- final_buf);
+
+ if (UAT_PRESENCE == type)
+ msgb("[%s] timestamp [%llu] value [%s]",
+ uat_get_sensor_bitmask_str(sensor), timestamp, final_buf);
+ else
+ msgp("[%s] timestamp [%llu] value [%s]",
+ uat_get_sensor_bitmask_str(sensor), timestamp, final_buf);
g_slist_free(values);
}
void *user_data)
{
char *pbuf = uat_get_time();
- msg("\n[%s] Sensor PRESENCE [%d]", pbuf, sensor);
+ msgb("\n[%s]", pbuf);
free(pbuf);
if (UA_SENSOR_BLE == (UA_SENSOR_BLE & sensor)) {
__sensor_presence_detected_device(device_handle);
/* For sensor information */
if (sensor_handle && (sensor & (UA_SENSOR_LIGHT | UA_SENSOR_MOTION)))
- __sensor_presence_detected_sensor_info(sensor, sensor_handle);
+ __sensor_detected_sensor_info(UAT_PRESENCE, sensor, sensor_handle);
}
static void __sensor_absence_detected_cb(int result, ua_monitor_h monitor,
ua_sensor_e sensor, ua_sensor_h sensor_handle, void *user_data)
{
char *pbuf = uat_get_time();
- msg("\n[%s] Sensor ABSENCE", pbuf);
+ msgp("\n[%s]", pbuf);
free(pbuf);
if (UA_SENSOR_BLE == (UA_SENSOR_BLE & sensor)) {
}
/* For sensor information */
if (sensor_handle && (sensor & (UA_SENSOR_LIGHT | UA_SENSOR_MOTION)))
- __sensor_presence_detected_sensor_info(sensor, sensor_handle);
+ __sensor_detected_sensor_info(UAT_ABSENCE, sensor, sensor_handle);
}
void __ua_test_scan_completed_cb(ua_active_scan_type_e result,
gpointer user_data)
{
int ret;
- char buf[MENU_DATA_SIZE] = {0, };
- char final_buf[MENU_DATA_SIZE * 4] = {0, };
- unsigned long long timestamp;
- int info_count = 0;
- GSList *values = NULL;
double *value;
GSList *l = 0;
+ int info_count = 0;
+ GSList *values = NULL;
+ int type = (int)user_data;
+ unsigned long long timestamp;
+ char buf[MENU_DATA_SIZE] = {0, };
+ char final_buf[MENU_DATA_SIZE * 4] = {0, };
+
ua_sensor_e bitmask;
ua_device_h sensor_handle = (ua_sensor_h)data;
strncat(final_buf, buf, sizeof(buf) - strlen(buf) - 1);
memset(buf, 0, MENU_DATA_SIZE);
}
- msgb("[%s] information detected at timestamp [%llu] value [%s]",
- uat_get_sensor_bitmask_str(bitmask), timestamp,
- final_buf);
+
+ if (UAT_PRESENCE == type)
+ msgbr("[%s] timestamp [%llu] value [%s]",
+ uat_get_sensor_bitmask_str(bitmask), timestamp, final_buf);
+ else
+ msgr("[%s] timestamp [%llu] value [%s]",
+ uat_get_sensor_bitmask_str(bitmask), timestamp, final_buf);
g_slist_free(values);
}
char *account = NULL;
char *pbuf = uat_get_time();
- msg("\n[%s]", pbuf);
+ msgr("\n[%s]", pbuf);
free(pbuf);
ret = ua_user_get_account(user_handle, &account);
msg(" - ua_user_get_account() ret: [0x%X] [%s]",
ret, uat_get_error_str(ret));
}
- msgp("[%s] ABSENCE detected [%s]", account, uat_get_error_str(result));
+ msgr("[%s] ABSENCE detected [%s]", account, uat_get_error_str(result));
g_slist_foreach(sensor_handles,
- __user_detected_foreach_sensors, NULL);
+ __user_detected_foreach_sensors, (void* )UAT_ABSENCE);
if (account) {
free(account);
msg(" - ua_device_get_mac_type() ret: [0x%X] [%s]",
ret, uat_get_error_str(ret));
}
- msgb("[%s] detected on [%s][%s]", account,
+ msgbr("[%s] detected on [%s][%s]", account,
__convert_device_mac_type_to_txt(mac_type), mac);
g_free(mac);
char *account = NULL;
char *pbuf = uat_get_time();
- msg("\n[%s]", pbuf);
+ msgbr("\n[%s]", pbuf);
free(pbuf);
if (user_handle) {
msg(" - ua_user_get_account() ret: [0x%X] [%s]",
ret, uat_get_error_str(ret));
}
- msgb("[%s] PRESENCE detected [%s]", account, uat_get_error_str(result));
- g_slist_foreach(device_handles,
- __user_presence_detected_foreach_devices,
- account);
+ msgbr("[%s] PRESENCE detected [%s]", account, uat_get_error_str(result));
+ g_slist_foreach(device_handles, __user_presence_detected_foreach_devices, account);
}
if (!account) {
- msgb("[No user information] PRESENCE detected [%s]", uat_get_error_str(result));
+ msgbr("[No user information] PRESENCE detected [%s]", uat_get_error_str(result));
}
g_slist_foreach(sensor_handles,
- __user_detected_foreach_sensors, NULL);
+ __user_detected_foreach_sensors, (void *)UAT_PRESENCE);
g_free(account);
}
static void __sensor_state_changed_cb(bool ready,
ua_sensor_e sensor, ua_monitor_h monitor, void *user_data)
{
- msgb("sensor: %s is %s",
+ msgn("sensor: %s is %s",
uat_get_sensor_bitmask_str(sensor), (ready ? "Ready" : "Not Ready"));
}
-static void __sensor_status_changed_cb(ua_sensor_status_e status,
- ua_monitor_h handle, ua_sensor_h sensor_handle, void *user_data)
+static void __sensor_status_changed_cb(ua_monitor_h handle,
+ ua_sensor_h sensor_handle, void *user_data)
{
int ret;
double *value;
GSList *l = 0;
- unsigned long long timestamp;
int info_count = 0;
ua_sensor_e sensor;
GSList *values = NULL;
+ ua_sensor_status_e status;
+ unsigned long long timestamp;
char buf[MENU_DATA_SIZE] = {0, };
char final_buf[MENU_DATA_SIZE * 4] = {0, };
char *pbuf = uat_get_time();
- msgr("\n[%s] Sensor Status Changed -> %s",
- pbuf, status == UA_SENSOR_PRESENCE ? "PRESENCE" : "ABSENCE");
+ msgc("\n[%s]", pbuf);
free(pbuf);
+ ret = ua_sensor_get_status(sensor_handle, &status);
+ if (UA_ERROR_NONE != ret) {
+ msg(" - ua_sensor_get_status() ret: [0x%X] [%s]",
+ ret, uat_get_error_str(ret));
+ }
+ msgc("[%s] Sensor Status Changed -> %s",
+ uat_get_sensor_bitmask_str(sensor),
+ status == UA_SENSOR_PRESENCE ? "PRESENCE" : "ABSENCE");
+
ret = ua_sensor_get_bitmask(sensor_handle, &sensor);
if (UA_ERROR_NONE != ret) {
msg(" - ua_sensor_get_bitmask() ret: [0x%X] [%s]",
strncat(final_buf, buf, sizeof(buf) - strlen(buf) - 1);
memset(buf, 0, MENU_DATA_SIZE);
}
- msgr("[%s] information detected at timestamp [%llu] value [%s]",
+ msgc("[%s] timestamp [%llu] value [%s]",
uat_get_sensor_bitmask_str(sensor), timestamp, final_buf);
g_slist_free(values);
msg("ua_monitor_unset_sensor_status_cb");
- ret = ua_monitor_unset_user_absence_detected_cb(g_ua_mon_h);
+ ret = ua_monitor_unset_sensor_status_cb(g_ua_mon_h);
msg(" - ua_monitor_unset_sensor_status_cb() ret: [0x%X] [%s]",
ret, uat_get_error_str(ret));
#define msgp(fmt, args...) do { fprintf(stdout, ANSI_COLOR_LIGHTMAGENTA fmt \
ANSI_COLOR_NORMAL "\n", ##args); fflush(stdout); } while (0)
+/* Bold (Cyan) */
+#define msgc(fmt, args...) do { fprintf(stdout, ANSI_COLOR_CYAN fmt \
+ ANSI_COLOR_NORMAL "\n", ##args); fflush(stdout); } while (0)
+
+/* Bold (Yellow) */
+#define msgy(fmt, args...) do { fprintf(stdout, ANSI_COLOR_YELLOW fmt \
+ ANSI_COLOR_NORMAL "\n", ##args); fflush(stdout); } while (0)
+
+/* Bold (Light Red) */
+#define msglr(fmt, args...) do { fprintf(stdout, ANSI_COLOR_LIGHTRED fmt \
+ ANSI_COLOR_NORMAL "\n", ##args); fflush(stdout); } while (0)
+
+/* Bold (Blue) */
+#define msgbr(fmt, args...) do { fprintf(stdout, ANSI_COLOR_BLUE fmt \
+ ANSI_COLOR_NORMAL "\n", ##args); fflush(stdout); } while (0)
+
+
#define msgt(n, fmt, args...) do { fprintf(stdout, "\e[%dC" fmt "\n", \
3 + ((n) * 2), ##args); fflush(stdout); } while (0)