+void _bt_util_addr_type_to_addr_net_string(char *address,
+ unsigned char *addr)
+{
+ ret_if(address == NULL);
+ ret_if(addr == NULL);
+
+ snprintf(address, BT_ADDRESS_STR_LEN, "%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X", addr[0],
+ addr[1], addr[2], addr[3], addr[4], addr[5]);
+}
+
+static connection_profile_h __bt_get_net_profile(void *connection,
+ connection_iterator_type_e type,
+ unsigned char *address)
+{
+ int result;
+ gchar **split_string;
+ char net_address[BT_ADDRESS_STR_LEN + 1] = { 0 };
+ char *profile_name = NULL;
+ connection_profile_iterator_h profile_iter;
+ connection_profile_h profile_h;
+ connection_profile_type_e profile_type;
+
+ retv_if(connection == NULL, NULL);
+ retv_if(address == NULL, NULL);
+
+ BT_DBG("net_conn: %x", connection);
+
+ _bt_util_addr_type_to_addr_net_string(net_address, address);
+
+ result = connection_get_profile_iterator(connection,
+ type,
+ &profile_iter);
+ if (result != CONNECTION_ERROR_NONE) {
+ BT_ERR("Fail to get profile iterator [%d]", result);
+ return NULL;
+ }
+
+ while (connection_profile_iterator_has_next(profile_iter)) {
+ profile_name = NULL;
+ profile_h = NULL;
+ split_string = NULL;
+
+ if (connection_profile_iterator_next(profile_iter,
+ &profile_h) != CONNECTION_ERROR_NONE) {
+ BT_ERR("Fail to get profile handle");
+ return NULL;
+ }
+
+ if (connection_profile_get_type(profile_h,
+ &profile_type) != CONNECTION_ERROR_NONE) {
+ BT_ERR("Fail to get profile type");
+ continue;
+ }
+
+ if (profile_type != CONNECTION_PROFILE_TYPE_BT)
+ continue;
+
+ if (connection_profile_get_name(profile_h,
+ &profile_name) != CONNECTION_ERROR_NONE) {
+ BT_ERR("Fail to get profile name");
+ return NULL;
+ }
+
+ split_string = g_strsplit(profile_name, "_", 3);
+
+ g_free(profile_name);
+
+ if (g_strv_length(split_string) < 3)
+ continue;
+
+ if (g_ascii_strcasecmp(split_string[2], net_address) == 0) {
+ BT_DBG("matched profile");
+ g_strfreev(split_string);
+ return profile_h;
+ }
+
+ g_strfreev(split_string);
+ }
+
+ return NULL;
+}
+
+int _bt_is_network_connected(void *connection, unsigned char *address,
+ gboolean *is_connected)
+{
+ void *handle = NULL;
+ handle = __bt_get_net_profile(connection,
+ CONNECTION_ITERATOR_TYPE_CONNECTED,
+ address);
+ if (handle)
+ *is_connected = TRUE;
+ else
+ *is_connected = FALSE;
+
+ return BLUETOOTH_ERROR_NONE;
+}
+
+static void __bt_network_connect_cb(GDBusProxy *proxy, GAsyncResult *res,
+ gpointer user_data)