summaryrefslogtreecommitdiffstats
path: root/plugins/hfp_hf_bluez5.c
diff options
context:
space:
mode:
authorVinicius Costa Gomes <vinicius.gomes@openbossa.org>2013-02-01 20:33:09 -0300
committerDenis Kenzior <denkenz@gmail.com>2013-02-14 08:47:10 -0600
commit233b1ecca45ad8f16870aee7f7ec2235dd49cd54 (patch)
tree22fe5228a73c994c9a138c63d344ba868299b948 /plugins/hfp_hf_bluez5.c
parenta2b698dc40dcdae827811c0df0a9e0665ce7d699 (diff)
downloadofono-233b1ecca45ad8f16870aee7f7ec2235dd49cd54.tar.bz2
hfp_hf_bluez5: Add support for Enabling/Disabling the modem
Now that we have the support for sending the correct messages to BlueZ, we are able to dynamically power up/down the HFP modem. We add another property to the modem to be able to get the D-Bus object path that represents the remote device.
Diffstat (limited to 'plugins/hfp_hf_bluez5.c')
-rw-r--r--plugins/hfp_hf_bluez5.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index 0d6bdd95..de580f28 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -180,6 +180,7 @@ static struct ofono_modem *modem_register(const char *device,
return NULL;
ofono_modem_set_string(modem, "Remote", device_address);
+ ofono_modem_set_string(modem, "DevicePath", device);
ofono_modem_set_name(modem, alias);
ofono_modem_register(modem);
@@ -219,19 +220,53 @@ static void hfp_remove(struct ofono_modem *modem)
ofono_modem_set_data(modem, NULL);
}
+static void connect_cb(gboolean success, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+
+ if (success)
+ return;
+
+ ofono_modem_set_powered(modem, FALSE);
+}
+
/* power up hardware */
static int hfp_enable(struct ofono_modem *modem)
{
+ const char *path;
+
DBG("%p", modem);
- return 0;
+ path = ofono_modem_get_string(modem, "DevicePath");
+
+ /*
+ * We call Device1.ConnectProfile() with our UUID, and we hope for the
+ * NewConnection() method to be called, if ConnectProfile() fails we
+ * force the modem to powered off
+ */
+ bt_connect_profile(ofono_dbus_get_connection(), path, HFP_AG_UUID,
+ connect_cb, modem);
+
+ return -EINPROGRESS;
}
static int hfp_disable(struct ofono_modem *modem)
{
+ const char *path;
+
DBG("%p", modem);
- return 0;
+ path = ofono_modem_get_string(modem, "DevicePath");
+
+ /*
+ * We call Device1.DisconnectProfile() for the connection to be
+ * dropped, which will cause the profile RequestDisconnection() method
+ * to be called which will bring the modem down
+ */
+ bt_disconnect_profile(ofono_dbus_get_connection(), path, HFP_AG_UUID,
+ NULL, NULL);
+
+ return -EINPROGRESS;
}
static void hfp_pre_sim(struct ofono_modem *modem)