[ofono-autoconnect PATCHv2 4/5] ofono: be proactive when connecting

Pekka.Pessi at nokia.com Pekka.Pessi at nokia.com
Wed Jan 26 06:50:39 PST 2011


From: Pekka Pessi <Pekka.Pessi at nokia.com>

Return error immediately if connection attempts are known to fail.
---
 plugins/ofono.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/plugins/ofono.c b/plugins/ofono.c
index 90b579d..3afe0f8 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -471,11 +471,25 @@ static void set_apn(struct connman_network *network)
 
 static int network_connect(struct connman_network *network)
 {
+	struct connman_device *device;
+	struct modem_data *modem;
+
 	DBG("network %p", network);
 
 	if (connman_network_get_index(network) >= 0)
 		return -EISCONN;
 
+	device = connman_network_get_device(network);
+	if (device == NULL)
+		return -ENODEV;
+
+	modem = connman_device_get_data(device);
+	if (modem == NULL)
+		return -ENODEV;
+
+	if (modem->powered == FALSE)
+		return -ENOLINK;
+
 	return set_network_active(network, TRUE);
 }
 
-- 
1.7.1




More information about the connman mailing list