summaryrefslogtreecommitdiffstats
path: root/plugins/sap.c
diff options
context:
space:
mode:
authorGustavo F. Padovan <padovan@profusion.mobi>2011-09-26 14:26:57 -0300
committerDenis Kenzior <denkenz@gmail.com>2011-09-26 13:38:12 -0500
commitc30e7265d9a5771ed969328c42dc09975410a4c1 (patch)
tree6a8bd431471aad66b34fa62dc385c63bd39ac3d7 /plugins/sap.c
parent4f3b9ff36c453824c48af6490b6b706699869e3d (diff)
downloadofono-c30e7265d9a5771ed969328c42dc09975410a4c1.tar.bz2
sap: add support to connect the RFCOMM link
Diffstat (limited to 'plugins/sap.c')
-rw-r--r--plugins/sap.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/plugins/sap.c b/plugins/sap.c
index ea3c1dd1..169bb7f5 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -38,11 +38,14 @@
#include <ofono/modem.h>
#include "bluetooth.h"
+#include "util.h"
#ifndef DBUS_TYPE_UNIX_FD
#define DBUS_TYPE_UNIX_FD -1
#endif
+#define BLUEZ_SERIAL_INTERFACE BLUEZ_SERVICE ".Serial"
+
static DBusConnection *connection;
static GHashTable *modem_hash = NULL;
static struct ofono_modem *sap_hw_modem = NULL;
@@ -109,12 +112,52 @@ static void sap_remove(struct ofono_modem *modem)
DBG("%p", modem);
}
+static void sap_connect_reply(DBusPendingCall *call, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ DBusError derr;
+ DBusMessage *reply;
+
+ DBG("");
+
+ reply = dbus_pending_call_steal_reply(call);
+
+ if (ofono_modem_get_powered(modem))
+ goto done;
+
+ dbus_error_init(&derr);
+ if (!dbus_set_error_from_message(&derr, reply))
+ goto done;
+
+ DBG("Connect reply: %s", derr.message);
+
+ ofono_modem_set_powered(modem, FALSE);
+
+ dbus_error_free(&derr);
+
+done:
+ dbus_message_unref(reply);
+}
+
/* power up hardware */
static int sap_enable(struct ofono_modem *modem)
{
struct sap_data *data = ofono_modem_get_data(modem);
+ int status;
+ const char *str = "sap";
+
+ DBG("%p", modem);
+
+ status = bluetooth_send_with_reply(data->server_path,
+ BLUEZ_SERIAL_INTERFACE, "ConnectFD",
+ NULL, sap_connect_reply, modem, NULL,
+ DBUS_TIMEOUT, DBUS_TYPE_STRING,
+ &str, DBUS_TYPE_INVALID);
+
+ if (status < 0)
+ return -EINVAL;
- return data->sap_driver->enable(data->hw_modem);
+ return -EINPROGRESS;
}
static int sap_disable(struct ofono_modem *modem)