From: Daniel Wagner <[email protected]>
Not all modems (e.g. dunmodem) do automatically power up the
ConnectionManager interface.
---
plugins/ofono.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 47 insertions(+), 1 deletions(-)
diff --git a/plugins/ofono.c b/plugins/ofono.c
index ab28a0e..0c0acbd 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -85,6 +85,9 @@ struct modem_data {
/* ConnectionManager Interface */
connman_bool_t attached;
+ connman_bool_t cm_powered;
+
+ connman_bool_t set_cm_powered;
/* SimManager Interface */
char *imsi;
@@ -320,6 +323,35 @@ static int modem_set_online(struct modem_data *modem)
modem_set_online_reply);
}
+static void cm_set_powered_reply(struct modem_data *modem,
+ connman_bool_t success)
+{
+ DBG("%s", modem->path);
+
+ if (success == TRUE) {
+ /*
+ * Don't handle do anything on success here. oFono will send
+ * the change via PropertyChanged singal.
+ */
+ return;
+ }
+
+ modem->set_cm_powered = FALSE;
+}
+
+static int cm_set_powered(struct modem_data *modem)
+{
+ DBG("%s", modem->path);
+
+ modem->set_cm_powered = TRUE;
+
+ return set_property(modem, modem->path,
+ OFONO_CM_INTERFACE,
+ "Powered", DBUS_TYPE_BOOLEAN,
+ &modem->set_cm_powered,
+ cm_set_powered_reply);
+}
+
static int modem_set_powered(struct modem_data *modem)
{
DBG("%s", modem->path);
@@ -496,6 +528,14 @@ static gboolean cm_changed(DBusConnection *connection,
DBusMessage *message,
dbus_message_iter_get_basic(&value, &modem->attached);
DBG("%s Attached %d", modem->path, modem->attached);
+ } else if (g_str_equal(key, "Powered") == TRUE) {
+ dbus_message_iter_get_basic(&value, &modem->cm_powered);
+
+ DBG("%s ConnnectionManager Powered %d", modem->path,
+ modem->cm_powered);
+
+ if (modem->cm_powered == FALSE)
+ cm_set_powered(modem);
}
return TRUE;
@@ -520,8 +560,14 @@ static void cm_properties_reply(struct modem_data *modem,
DBusMessageIter *dict)
DBG("%s Attached %d", modem->path,
modem->attached);
+ } else if (g_str_equal(key, "Powered") == TRUE) {
+ dbus_message_iter_get_basic(&value, &modem->cm_powered);
- return;
+ DBG("%s ConnnectionManager Powered %d", modem->path,
+ modem->cm_powered);
+
+ if (modem->cm_powered == FALSE)
+ cm_set_powered(modem);
}
dbus_message_iter_next(dict);
--
1.7.8.110.g4cb5d1
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman