BlueZ/Device: Add function bluez_device_network_connect() 40/19040/1
authorWu Jiangbo <jiangbox.wu@intel.com>
Tue, 1 Apr 2014 10:23:37 +0000 (18:23 +0800)
committerWu Jiangbo <jiangbox.wu@intel.com>
Fri, 4 Apr 2014 11:33:20 +0000 (19:33 +0800)
Change-Id: Icfa6e34fd67c85c2d76adce7f10d2c4d6cf8f62c
Signed-off-by: Wu Jiangbo <jiangbox.wu@intel.com>
include/bluez.h
lib/bluez.c

index 87fc316..20503a0 100644 (file)
@@ -242,6 +242,10 @@ GList *bluez_adapter_get_devices(
                                struct _bluez_adapter *adapter);
 
 /* device functions */
+int bluez_device_network_connect(
+                               struct _bluez_device *device,
+                               const gchar *role);
+
 typedef void (*bluez_device_paired_cb_t)(
                                struct _bluez_device *device,
                                gboolean paired,
index a45dea5..44a155d 100644 (file)
@@ -1721,6 +1721,31 @@ GList *bluez_adapter_get_devices(struct _bluez_adapter *adapter)
 
 /* Device Functions */
 
+int bluez_device_network_connect(struct _bluez_device *device,
+                                               const gchar *role)
+{
+       struct simple_reply_data *reply_data;
+
+       reply_data = g_try_new0(struct simple_reply_data, 1);
+       if (reply_data == NULL) {
+               ERROR("no memory");
+               return -1;
+       }
+
+       reply_data->proxy = device->network_proxy;
+
+       DBG("%p", device->network_proxy);
+       if (!device->network_proxy)
+               return -1;
+
+       g_dbus_proxy_call(device->network_proxy, "Connect",
+                               g_variant_new("(s)", role),
+                               0, -1, NULL,
+                               simple_reply_callback, reply_data);
+
+       return 0;
+}
+
 void bluez_device_set_paired_changed_cb(struct _bluez_device *device,
                                        bluez_device_paired_cb_t cb,
                                        gpointer user_data)