UA_WIFI_LOCATION_ERR(
"wifi_location_request_destroy failed");
}
+ g_request = NULL;
ret = wifi_location_deinitialize();
retv_if_with_log(WIFI_LOCATION_ERROR_NONE != ret,
return g_request;
}
-int _wifi_location_plugin_add_registered_device(gpointer data)
+int _wifi_location_plugin_add_dev(gpointer data)
{
FUNC_ENTER;
uas_wifi_location_info_t *dev = data;
int ret = WIFI_LOCATION_ERROR_NONE;
wifi_location_peer_type_e peer_type =
WIFI_LOCATION_PEER_TYPE_WIFI_AWARE;
+ unsigned char mac[6] = {0, };
retv_if(NULL == dev, UAS_STATUS_FAIL);
return status;
}
+ sscanf(dev->mac_addr, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
+ &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
+
/* Add device */
- ret = wifi_location_request_add_peer(g_request,
- (unsigned char*)dev->mac_addr, peer_type);
+ ret = wifi_location_request_add_peer(g_request, mac, peer_type);
if (WIFI_LOCATION_ERROR_NONE == ret)
status = UAS_STATUS_SUCCESS;
else
return status;
}
+gboolean _wifi_location_plugin_add_registered_device(gpointer data)
+{
+ FUNC_ENTER;
+ uas_wifi_location_info_t *dev = data;
+ int status = UAS_STATUS_FAIL;
+ retv_if(NULL == dev, FALSE);
+
+ status = _wifi_location_plugin_add_dev(data);
+ if (UAS_STATUS_SUCCESS != status)
+ UA_WIFI_LOCATION_ERR(
+ "_wifi_location_plugin_add_registered_device failed");
+
+ FUNC_EXIT;
+ return FALSE;
+}
+
gboolean _wifi_location_plugin_add_device(gpointer data)
{
FUNC_ENTER;
int status = UAS_STATUS_FAIL;
retv_if(NULL == dev, FALSE);
- status = _wifi_location_plugin_add_registered_device(data);
+ status = _wifi_location_plugin_add_dev(data);
_wifi_location_plugin_handle_device_added(status, dev);
g_free(dev);
void *user_data)
{
FUNC_ENTER;
- unsigned char *mac = NULL;
+ unsigned char *mac = (unsigned char *)g_new0(unsigned char*,
+ MAC_ADDRESS_ARRAY_SIZE);
+ char mac_string[MAC_ADDRESS_MAX_LEN] = {""};
int distance_mm = 0;
- int ret;
+ int ret = WIFI_LOCATION_ERROR_NONE;
if(WIFI_LOCATION_ERROR_NONE != error) {
UA_WIFI_LOCATION_ERR("failed error %d", error);
}
ret = wifi_location_result_get_mac(result, &mac);
- if(WIFI_LOCATION_ERROR_NONE != ret)
+ if (WIFI_LOCATION_ERROR_NONE != ret) {
UA_WIFI_LOCATION_ERR("wifi_location_result_get_mac " \
"failed error %d", ret);
- else
- UA_WIFI_LOCATION_DBG("Result received for mac %s", mac);
+ } else {
+ UA_WIFI_LOCATION_DBG("Result received for mac "
+ "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
+ mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+ }
+
+ snprintf(mac_string, MAC_ADDRESS_MAX_LEN,
+ "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
+ mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+ UA_WIFI_LOCATION_DBG("Result received for mac %s", mac_string);
ret = wifi_location_result_get_distance_mm(result, &distance_mm);
if(WIFI_LOCATION_ERROR_NONE != ret)
else
UA_WIFI_LOCATION_DBG("Result distance(mm) %d", distance_mm);
- _wifi_location_plugin_handle_device_found((const char*)mac, distance_mm);
+ _wifi_location_plugin_handle_device_found(
+ (const char*)mac_string, distance_mm);
FUNC_EXIT;
}