return UAM_ERROR_INVALID_PARAMETER;
}
+ UAM_DBG("Valid user_id [%d]", user_id);
+
*user = l->data;
return UAM_ERROR_NONE;
}
static int __uam_core_search_device(uam_device_info_s *dev_info,
- int user_id, uam_db_user_info_t *user, uam_db_device_info_t **device)
+ uam_db_user_info_t *user, uam_db_device_info_t **device)
{
GSList *l = g_slist_find_custom(user->devices,
dev_info->device_id, __compare_device_id);
if (NULL == l) {
- UAM_ERR("Valid user_id [%d] but Invalid device_id [%s]",
- user_id, dev_info->device_id);
+ UAM_ERR("Invalid device_id [%s]", dev_info->device_id);
return UAM_ERROR_INVALID_PARAMETER;
}
*device = l->data;
+ if (!((*device)->supported_techs & dev_info->type)) {
+ UAM_ERR("Valid device_id [%s] but Invalid tech type [%d]",
+ dev_info->device_id, dev_info->type);
+ return UAM_ERROR_INVALID_PARAMETER;
+ }
return UAM_ERROR_NONE;
}
return UAM_ERROR_NONE;
}
+static int __uam_core_search_user_device_tech(int user_id,
+ uam_device_info_s *dev_info, uam_db_tech_info_t **tech)
+{
+ uam_db_user_info_t *user = NULL;
+ uam_db_device_info_t *device = NULL;
+
+ /* fetch the app_num info for the corresponding user_id */
+ _uam_core_get_app_num_from_userid(user_id, &dev_info->app_num);
+
+ retv_if(UAM_ERROR_NONE != __uam_core_search_user(user_id, &user), UAM_ERROR_INVALID_PARAMETER);
+
+ retv_if(UAM_ERROR_NONE != __uam_core_search_device(dev_info, user, &device), UAM_ERROR_INVALID_PARAMETER);
+
+ retv_if(UAM_ERROR_NONE != __uam_core_search_tech(dev_info, device, tech), UAM_ERROR_INVALID_PARAMETER);
+ return UAM_ERROR_NONE;
+}
+
int _uam_core_handle_presence_detected(unsigned int sensor,
int user_id, void *info, uam_ble_payload_s *payload)
{
int ret = UAM_ERROR_NONE;
GSList *l;
- uam_db_user_info_t *user = NULL;
- uam_db_device_info_t *device = NULL;
uam_db_tech_info_t *tech = NULL;
uam_device_info_s *dev_info = NULL;
retv_if(0 > user_id, UAM_ERROR_INVALID_PARAMETER);
- /* fetch the app_num info for the corresponding user_id */
- _uam_core_get_app_num_from_userid(user_id, &dev_info->app_num);
-
- retv_if(UAM_ERROR_NONE != __uam_core_search_user(user_id, &user), UAM_ERROR_INVALID_PARAMETER);
+ retv_if(UAM_ERROR_NONE != __uam_core_search_user_device_tech(user_id,
+ dev_info, &tech), UAM_ERROR_INVALID_PARAMETER);
- retv_if(UAM_ERROR_NONE != __uam_core_search_device(dev_info, user_id, user, &device), UAM_ERROR_INVALID_PARAMETER);
- if (!(device->supported_techs & dev_info->type)) {
- UAM_ERR("Valid device_id [%s] but Invalid tech type [%d]",
- dev_info->device_id, dev_info->type);
- return UAM_ERROR_INVALID_PARAMETER;
- }
-
- retv_if(UAM_ERROR_NONE != __uam_core_search_tech(dev_info, device, &tech), UAM_ERROR_INVALID_PARAMETER);
tech->presence_state = UAM_PRESENCE_STATE_PRESENT;
tech->last_seen = dev_info->last_seen;
FUNC_ENTRY;
int ret = UAM_ERROR_NONE;
- uam_db_user_info_t *user = NULL;
- uam_db_device_info_t *device = NULL;
uam_db_tech_info_t *tech = NULL;
uam_device_info_s *dev_info = NULL;
retv_if(0 > user_id, UAM_ERROR_INVALID_PARAMETER);
- /* fetch the app_num info for the corresponding user_id */
- _uam_core_get_app_num_from_userid(user_id, &dev_info->app_num);
-
- /* Search user */
- retv_if(UAM_ERROR_NONE != __uam_core_search_user(user_id, &user), UAM_ERROR_INVALID_PARAMETER);
-
- /* Search device */
- retv_if(UAM_ERROR_NONE != __uam_core_search_device(dev_info, user_id, user, &device), UAM_ERROR_INVALID_PARAMETER);
- if (!(device->supported_techs & dev_info->type)) {
- UAM_ERR("Valid device_id [%s] but Invalid tech type [%d]",
- dev_info->device_id, dev_info->type);
- return UAM_ERROR_INVALID_PARAMETER;
- }
-
- /* Search tech */
- retv_if(UAM_ERROR_NONE != __uam_core_search_tech(dev_info, device, &tech), UAM_ERROR_INVALID_PARAMETER);
+ retv_if(UAM_ERROR_NONE != __uam_core_search_user_device_tech(user_id,
+ dev_info, &tech), UAM_ERROR_INVALID_PARAMETER);
/* Send user location event */
__send_user_location_event(tech, sensor, dev_info);