Open Source Telephony
 help / color / mirror / Atom feed
* [PATCH 1/2] linktop: reimplemented with minimum features.
@ 2011-06-27  6:22 Amit Mendapara
  2011-06-27  6:22 ` [PATCH 2/2] udev: changed linktop device strings Amit Mendapara
  2011-06-27 15:34 ` [PATCH 1/2] linktop: reimplemented with minimum features Denis Kenzior
  0 siblings, 2 replies; 10+ messages in thread
From: Amit Mendapara @ 2011-06-27  6:22 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 8336 bytes --]

The device supports subset of ST-Ericsson AT command
extensions but nither STE nor the MBM plugin works with
these devices.

Fixes MeeGo bug #14784
---
 plugins/linktop.c |  120 +++++++++++++++++++++++------------------------------
 1 files changed, 52 insertions(+), 68 deletions(-)

diff --git a/plugins/linktop.c b/plugins/linktop.c
index 953f634..2eb1c55 100644
--- a/plugins/linktop.c
+++ b/plugins/linktop.c
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <glib.h>
 #include <gatchat.h>
@@ -34,10 +35,6 @@
 #define OFONO_API_SUBJECT_TO_CHANGE
 #include <ofono/plugin.h>
 #include <ofono/modem.h>
-#include <ofono/call-barring.h>
-#include <ofono/call-forwarding.h>
-#include <ofono/call-meter.h>
-#include <ofono/call-settings.h>
 #include <ofono/devinfo.h>
 #include <ofono/message-waiting.h>
 #include <ofono/netreg.h>
@@ -45,22 +42,20 @@
 #include <ofono/cbs.h>
 #include <ofono/sms.h>
 #include <ofono/ussd.h>
-#include <ofono/call-volume.h>
-#include <ofono/voicecall.h>
 #include <ofono/gprs.h>
 #include <ofono/gprs-context.h>
 #include <ofono/phonebook.h>
 #include <ofono/radio-settings.h>
 #include <ofono/log.h>
 
-#include <drivers/atmodem/vendor.h>
 #include <drivers/atmodem/atutil.h>
+#include <drivers/atmodem/vendor.h>
 
 static const char *none_prefix[] = { NULL };
 
 struct linktop_data {
 	GAtChat *modem;
-	GAtChat *control;
+	GAtChat *aux;
 	struct ofono_gprs *gprs;
 	struct ofono_gprs_context *gc;
 };
@@ -89,16 +84,16 @@ static void linktop_remove(struct ofono_modem *modem)
 	ofono_modem_set_data(modem, NULL);
 
 	g_at_chat_unref(data->modem);
-	g_at_chat_unref(data->control);
+	g_at_chat_unref(data->aux);
 
 	g_free(data);
 }
 
 static void linktop_debug(const char *str, void *user_data)
 {
-        const char *prefix = user_data;
+	const char *prefix = user_data;
 
-        ofono_info("%s%s", prefix, str);
+	ofono_info("%s%s", prefix, str);
 }
 
 static GAtChat *open_device(struct ofono_modem *modem,
@@ -138,10 +133,9 @@ static void linktop_disconnect(gpointer user_data)
 	struct ofono_modem *modem = user_data;
 	struct linktop_data *data = ofono_modem_get_data(modem);
 
-	DBG("");
+	DBG("%p, data->gc %p", modem, data->gc);
 
-	if (data->gc)
-		ofono_gprs_context_remove(data->gc);
+	ofono_gprs_context_remove(data->gc);
 
 	g_at_chat_unref(data->modem);
 	data->modem = NULL;
@@ -151,7 +145,7 @@ static void linktop_disconnect(gpointer user_data)
 		return;
 
 	g_at_chat_set_disconnect_function(data->modem,
-						linktop_disconnect, modem);
+			linktop_disconnect, modem);
 
 	ofono_info("Reopened GPRS context channel");
 
@@ -176,31 +170,25 @@ static int linktop_enable(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
-	data->modem = open_device(modem, "Modem", "Modem: ");
-	if (data->modem == NULL)
-		return -EINVAL;
+	data->aux = open_device(modem, "Aux", "Aux: ");
+	if (data->aux == NULL)
+		return -EIO;
 
-	g_at_chat_set_disconnect_function(data->modem,
-						linktop_disconnect, modem);
+	data->modem = open_device(modem, "Modem", "Modem: ");
+	if (data->modem == NULL) {
+		g_at_chat_unref(data->aux);
+		data->aux = NULL;
 
-	data->control = open_device(modem, "Control", "Control: ");
-	if (data->control == NULL) {
-		g_at_chat_unref(data->modem);
-		data->modem = NULL;
 		return -EIO;
 	}
 
-	g_at_chat_send(data->control, "ATE0 +CMEE=1", none_prefix,
-						NULL, NULL, NULL);
-
-	g_at_chat_send(data->modem, "AT", none_prefix,
-						NULL, NULL, NULL);
-
-	g_at_chat_send(data->modem, "AT &F", none_prefix,
-						NULL, NULL, NULL);
+	g_at_chat_set_disconnect_function(data->modem,
+						linktop_disconnect, modem);
 
-	g_at_chat_send(data->control, "AT+CFUN=4", none_prefix,
-					cfun_enable, modem, NULL);
+	g_at_chat_send(data->aux, "ATE0 +CMEE=1", none_prefix,
+					NULL, NULL, NULL);
+	g_at_chat_send(data->aux, "AT+CFUN=4", none_prefix,
+				cfun_enable, modem, NULL);
 
 	return -EINPROGRESS;
 }
@@ -212,8 +200,11 @@ static void cfun_disable(gboolean ok, GAtResult *result, gpointer user_data)
 
 	DBG("");
 
-	g_at_chat_unref(data->control);
-	data->control = NULL;
+	g_at_chat_unref(data->aux);
+	data->aux = NULL;
+
+	g_at_chat_unref(data->modem);
+	data->modem = NULL;
 
 	if (ok)
 		ofono_modem_set_powered(modem, FALSE);
@@ -232,13 +223,12 @@ static int linktop_disable(struct ofono_modem *modem)
 		data->modem = NULL;
 	}
 
-	if (data->control == NULL)
+	if (data->aux == NULL)
 		return 0;
 
-	g_at_chat_cancel_all(data->control);
-	g_at_chat_unregister_all(data->control);
-	g_at_chat_send(data->control, "AT+CFUN=4", none_prefix,
-					cfun_disable, modem, NULL);
+	g_at_chat_cancel_all(data->aux);
+	g_at_chat_unregister_all(data->aux);
+	g_at_chat_send(data->aux, "AT+CFUN=4", NULL, cfun_disable, modem, NULL);
 
 	return -EINPROGRESS;
 }
@@ -247,22 +237,25 @@ static void set_online_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct cb_data *cbd = user_data;
 	ofono_modem_online_cb_t cb = cbd->cb;
-	struct ofono_error error;
 
-	decode_at_error(&error, g_at_result_final_response(result));
-	cb(&error, cbd->data);
+	if (ok)
+		CALLBACK_WITH_SUCCESS(cb, cbd->data);
+	else
+		CALLBACK_WITH_FAILURE(cb, cbd->data);
 }
 
 static void linktop_set_online(struct ofono_modem *modem, ofono_bool_t online,
 				ofono_modem_online_cb_t cb, void *user_data)
 {
 	struct linktop_data *data = ofono_modem_get_data(modem);
-	GAtChat *chat = data->control;
+	GAtChat *chat = data->aux;
 	struct cb_data *cbd = cb_data_new(cb, user_data);
 	char const *command = online ? "AT+CFUN=1" : "AT+CFUN=4";
 
 	DBG("modem %p %s", modem, online ? "online" : "offline");
 
+	cbd->user = data;
+
 	if (g_at_chat_send(chat, command, NULL, set_online_cb, cbd, g_free))
 		return;
 
@@ -278,9 +271,8 @@ static void linktop_pre_sim(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
-	ofono_devinfo_create(modem, 0, "atmodem", data->control);
-	sim = ofono_sim_create(modem, 0, "atmodem", data->control);
-	ofono_voicecall_create(modem, 0, "stemodem", data->control);
+	ofono_devinfo_create(modem, 0, "atmodem", data->aux);
+	sim = ofono_sim_create(modem, 0, "atmodem", data->aux);
 
 	if (sim)
 		ofono_sim_inserted_notify(sim, TRUE);
@@ -292,35 +284,27 @@ static void linktop_post_sim(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
-	ofono_radio_settings_create(modem, 0, "stemodem", data->control);
-	ofono_phonebook_create(modem, 0, "atmodem", data->control);
-	ofono_sms_create(modem, 0, "atmodem", data->control);
+	ofono_radio_settings_create(modem, 0, "stemodem", data->aux);
+	ofono_phonebook_create(modem, 0, "atmodem", data->aux);
+	ofono_sms_create(modem, 0, "atmodem", data->aux);
 }
 
 static void linktop_post_online(struct ofono_modem *modem)
 {
 	struct linktop_data *data = ofono_modem_get_data(modem);
 	struct ofono_message_waiting *mw;
-	struct ofono_gprs *gprs;
-	struct ofono_gprs_context *gc;
 
 	DBG("%p", modem);
 
-	ofono_ussd_create(modem, 0, "atmodem", data->control);
-	ofono_call_forwarding_create(modem, 0, "atmodem", data->control);
-	ofono_call_settings_create(modem, 0, "atmodem", data->control);
-	ofono_netreg_create(modem, OFONO_VENDOR_MBM, "atmodem", data->control);
-	ofono_call_meter_create(modem, 0, "atmodem", data->control);
-	ofono_call_barring_create(modem, 0, "atmodem", data->control);
-	ofono_call_volume_create(modem, 0, "atmodem", data->control);
-	ofono_cbs_create(modem, 0, "atmodem", data->control);
-
-	gprs = ofono_gprs_create(modem, OFONO_VENDOR_MBM,
-					"atmodem", data->control);
-	gc = ofono_gprs_context_create(modem, 0, "atmodem", data->modem);
-
-	if (gprs && gc)
-		ofono_gprs_add_context(gprs, gc);
+	ofono_netreg_create(modem, 0, "atmodem", data->aux);
+	ofono_cbs_create(modem, 0, "atmodem", data->aux);
+	ofono_ussd_create(modem, 0, "atmodem", data->aux);
+
+	data->gprs = ofono_gprs_create(modem, 0, "atmodem", data->aux);
+	data->gc = ofono_gprs_context_create(modem, 0, "atmodem", data->modem);
+
+	if (data->gprs && data->gc)
+		ofono_gprs_add_context(data->gprs, data->gc);
 
 	mw = ofono_message_waiting_create(modem);
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread
* [PATCH 1/2] linktop: reimplemented linktop plugin with minimum features.
@ 2011-06-20  7:35 Amit Mendapara
  2011-06-20  7:35 ` [PATCH 2/2] udev: changed linktop device strings Amit Mendapara
  0 siblings, 1 reply; 10+ messages in thread
From: Amit Mendapara @ 2011-06-20  7:35 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 11264 bytes --]

The device supports subset of ST-Ericsson AT command extensions but nither
STE nor the MBM plugin works with these devices.

- Supports voice call and has builtin soundcard but unable to hear any sound.
- Supports sim toolkit commands but I am unable to test this feature.

Fixes MeeGo bug #14784
---
 plugins/linktop.c |  234 +++++++++++++++++++++++++----------------------------
 1 files changed, 112 insertions(+), 122 deletions(-)

diff --git a/plugins/linktop.c b/plugins/linktop.c
index 953f634..bd8aa3e 100644
--- a/plugins/linktop.c
+++ b/plugins/linktop.c
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <glib.h>
 #include <gatchat.h>
@@ -34,33 +35,30 @@
 #define OFONO_API_SUBJECT_TO_CHANGE
 #include <ofono/plugin.h>
 #include <ofono/modem.h>
-#include <ofono/call-barring.h>
-#include <ofono/call-forwarding.h>
-#include <ofono/call-meter.h>
-#include <ofono/call-settings.h>
 #include <ofono/devinfo.h>
 #include <ofono/message-waiting.h>
 #include <ofono/netreg.h>
 #include <ofono/sim.h>
-#include <ofono/cbs.h>
 #include <ofono/sms.h>
 #include <ofono/ussd.h>
-#include <ofono/call-volume.h>
-#include <ofono/voicecall.h>
 #include <ofono/gprs.h>
 #include <ofono/gprs-context.h>
 #include <ofono/phonebook.h>
 #include <ofono/radio-settings.h>
 #include <ofono/log.h>
 
-#include <drivers/atmodem/vendor.h>
 #include <drivers/atmodem/atutil.h>
+#include <drivers/atmodem/vendor.h>
 
+static const char *cpin_prefix[] = { "+CPIN:", NULL };
 static const char *none_prefix[] = { NULL };
 
 struct linktop_data {
-	GAtChat *modem;
-	GAtChat *control;
+	GAtChat *modem_port;
+	GAtChat *data_port;
+	guint cpin_poll_source;
+	guint cpin_poll_count;
+	gboolean have_sim;
 	struct ofono_gprs *gprs;
 	struct ofono_gprs_context *gc;
 };
@@ -88,25 +86,79 @@ static void linktop_remove(struct ofono_modem *modem)
 
 	ofono_modem_set_data(modem, NULL);
 
-	g_at_chat_unref(data->modem);
-	g_at_chat_unref(data->control);
+	g_at_chat_unref(data->data_port);
+	g_at_chat_unref(data->modem_port);
+
+	if (data->cpin_poll_source > 0)
+		g_source_remove(data->cpin_poll_source);
 
 	g_free(data);
 }
 
 static void linktop_debug(const char *str, void *user_data)
 {
-        const char *prefix = user_data;
+	const char *prefix = user_data;
+
+	ofono_info("%s%s", prefix, str);
+}
+
+static gboolean init_simpin_check(gpointer user_data);
+
+static void simpin_check(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct linktop_data *data = ofono_modem_get_data(modem);
+
+	DBG("");
+
+	/* Modem returns an error if SIM is not ready. */
+	if (!ok && data->cpin_poll_count++ < 5) {
+		data->cpin_poll_source =
+			g_timeout_add_seconds(1, init_simpin_check, modem);
+		return;
+	}
+
+	data->cpin_poll_count = 0;
+
+	/* There is probably no SIM if SIM is not ready after 5 seconds. */
+	data->have_sim = ok;
+
+	ofono_modem_set_powered(modem, TRUE);
+}
+
+static gboolean init_simpin_check(gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct linktop_data *data = ofono_modem_get_data(modem);
+
+	data->cpin_poll_source = 0;
 
-        ofono_info("%s%s", prefix, str);
+	g_at_chat_send(data->modem_port, "AT+CPIN?", cpin_prefix,
+			simpin_check, modem, NULL);
+
+	return FALSE;
+}
+
+static void cfun_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+
+	DBG("");
+
+	if (!ok) {
+		ofono_modem_set_powered(modem, FALSE);
+		return;
+	}
+
+	init_simpin_check(modem);
 }
 
 static GAtChat *open_device(struct ofono_modem *modem,
 				const char *key, char *debug)
 {
-	const char *device;
 	GAtSyntax *syntax;
 	GIOChannel *channel;
+	const char *device;
 	GAtChat *chat;
 
 	device = ofono_modem_get_string(modem, key);
@@ -126,94 +178,53 @@ static GAtChat *open_device(struct ofono_modem *modem,
 
 	if (chat == NULL)
 		return NULL;
-
+		
 	if (getenv("OFONO_AT_DEBUG"))
 		g_at_chat_set_debug(chat, linktop_debug, debug);
 
 	return chat;
 }
 
-static void linktop_disconnect(gpointer user_data)
-{
-	struct ofono_modem *modem = user_data;
-	struct linktop_data *data = ofono_modem_get_data(modem);
-
-	DBG("");
-
-	if (data->gc)
-		ofono_gprs_context_remove(data->gc);
-
-	g_at_chat_unref(data->modem);
-	data->modem = NULL;
-
-	data->modem = open_device(modem, "Modem", "Modem: ");
-	if (data->modem == NULL)
-		return;
-
-	g_at_chat_set_disconnect_function(data->modem,
-						linktop_disconnect, modem);
-
-	ofono_info("Reopened GPRS context channel");
-
-	data->gc = ofono_gprs_context_create(modem, 0, "atmodem", data->modem);
-
-	if (data->gprs && data->gc)
-		ofono_gprs_add_context(data->gprs, data->gc);
-}
-
-static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
-{
-	struct ofono_modem *modem = user_data;
-
-	DBG("");
-
-	ofono_modem_set_powered(modem, ok);
-}
-
 static int linktop_enable(struct ofono_modem *modem)
 {
 	struct linktop_data *data = ofono_modem_get_data(modem);
 
 	DBG("%p", modem);
 
-	data->modem = open_device(modem, "Modem", "Modem: ");
-	if (data->modem == NULL)
+	data->modem_port = open_device(modem, "ModemDevice", "Modem: ");
+	if (data->modem_port == NULL)
 		return -EINVAL;
 
-	g_at_chat_set_disconnect_function(data->modem,
-						linktop_disconnect, modem);
+	data->data_port = open_device(modem, "DataDevice", "Data: ");
+	if (data->data_port == NULL) {
+		g_at_chat_unref(data->modem_port);
+		data->modem_port = NULL;
 
-	data->control = open_device(modem, "Control", "Control: ");
-	if (data->control == NULL) {
-		g_at_chat_unref(data->modem);
-		data->modem = NULL;
 		return -EIO;
 	}
 
-	g_at_chat_send(data->control, "ATE0 +CMEE=1", none_prefix,
-						NULL, NULL, NULL);
-
-	g_at_chat_send(data->modem, "AT", none_prefix,
-						NULL, NULL, NULL);
-
-	g_at_chat_send(data->modem, "AT &F", none_prefix,
-						NULL, NULL, NULL);
-
-	g_at_chat_send(data->control, "AT+CFUN=4", none_prefix,
-					cfun_enable, modem, NULL);
-
+	g_at_chat_send(data->modem_port, "AT&F E0 V1 X4 &C1 +CMEE=1", none_prefix,
+				cfun_enable_cb, modem, NULL);
+	g_at_chat_send(data->data_port, "AT&F E0 V1 X4 &C1 +CMEE=1", none_prefix,
+				cfun_enable_cb, modem, NULL);
+	g_at_chat_send(data->modem_port, "AT+CFUN=4", none_prefix,
+				cfun_enable_cb, modem, NULL);
+	
 	return -EINPROGRESS;
 }
 
-static void cfun_disable(gboolean ok, GAtResult *result, gpointer user_data)
+static void cfun_disable_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct ofono_modem *modem = user_data;
 	struct linktop_data *data = ofono_modem_get_data(modem);
 
 	DBG("");
 
-	g_at_chat_unref(data->control);
-	data->control = NULL;
+	g_at_chat_unref(data->modem_port);
+	data->modem_port = NULL;
+
+	g_at_chat_unref(data->data_port);
+	data->data_port = NULL;
 
 	if (ok)
 		ofono_modem_set_powered(modem, FALSE);
@@ -225,20 +236,14 @@ static int linktop_disable(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
-	if (data->modem) {
-		g_at_chat_cancel_all(data->modem);
-		g_at_chat_unregister_all(data->modem);
-		g_at_chat_unref(data->modem);
-		data->modem = NULL;
-	}
-
-	if (data->control == NULL)
+	if (data->modem_port == NULL)
 		return 0;
 
-	g_at_chat_cancel_all(data->control);
-	g_at_chat_unregister_all(data->control);
-	g_at_chat_send(data->control, "AT+CFUN=4", none_prefix,
-					cfun_disable, modem, NULL);
+	g_at_chat_cancel_all(data->modem_port);
+	g_at_chat_unregister_all(data->modem_port);
+
+	g_at_chat_send(data->modem_port, "AT+CFUN=4", NULL,
+					cfun_disable_cb, modem, NULL);
 
 	return -EINPROGRESS;
 }
@@ -257,12 +262,14 @@ static void linktop_set_online(struct ofono_modem *modem, ofono_bool_t online,
 				ofono_modem_online_cb_t cb, void *user_data)
 {
 	struct linktop_data *data = ofono_modem_get_data(modem);
-	GAtChat *chat = data->control;
+	GAtChat *chat = data->modem_port;
 	struct cb_data *cbd = cb_data_new(cb, user_data);
 	char const *command = online ? "AT+CFUN=1" : "AT+CFUN=4";
 
 	DBG("modem %p %s", modem, online ? "online" : "offline");
 
+	cbd->user = data;
+
 	if (g_at_chat_send(chat, command, NULL, set_online_cb, cbd, g_free))
 		return;
 
@@ -278,49 +285,33 @@ static void linktop_pre_sim(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
-	ofono_devinfo_create(modem, 0, "atmodem", data->control);
-	sim = ofono_sim_create(modem, 0, "atmodem", data->control);
-	ofono_voicecall_create(modem, 0, "stemodem", data->control);
+	ofono_devinfo_create(modem, 0, "atmodem", data->modem_port);
+	sim = ofono_sim_create(modem, 0, "atmodem", data->modem_port);
 
-	if (sim)
+	if (data->have_sim && sim)
 		ofono_sim_inserted_notify(sim, TRUE);
 }
 
 static void linktop_post_sim(struct ofono_modem *modem)
 {
 	struct linktop_data *data = ofono_modem_get_data(modem);
-
-	DBG("%p", modem);
-
-	ofono_radio_settings_create(modem, 0, "stemodem", data->control);
-	ofono_phonebook_create(modem, 0, "atmodem", data->control);
-	ofono_sms_create(modem, 0, "atmodem", data->control);
-}
-
-static void linktop_post_online(struct ofono_modem *modem)
-{
-	struct linktop_data *data = ofono_modem_get_data(modem);
 	struct ofono_message_waiting *mw;
-	struct ofono_gprs *gprs;
-	struct ofono_gprs_context *gc;
 
 	DBG("%p", modem);
 
-	ofono_ussd_create(modem, 0, "atmodem", data->control);
-	ofono_call_forwarding_create(modem, 0, "atmodem", data->control);
-	ofono_call_settings_create(modem, 0, "atmodem", data->control);
-	ofono_netreg_create(modem, OFONO_VENDOR_MBM, "atmodem", data->control);
-	ofono_call_meter_create(modem, 0, "atmodem", data->control);
-	ofono_call_barring_create(modem, 0, "atmodem", data->control);
-	ofono_call_volume_create(modem, 0, "atmodem", data->control);
-	ofono_cbs_create(modem, 0, "atmodem", data->control);
-
-	gprs = ofono_gprs_create(modem, OFONO_VENDOR_MBM,
-					"atmodem", data->control);
-	gc = ofono_gprs_context_create(modem, 0, "atmodem", data->modem);
+	ofono_radio_settings_create(modem, 0, "stemodem", data->modem_port);
+	ofono_phonebook_create(modem, 0, "atmodem", data->modem_port);
+	ofono_sms_create(modem, 0, "atmodem", data->modem_port);
+	ofono_ussd_create(modem, 0, "atmodem", data->modem_port);
+	ofono_netreg_create(modem, 0, "atmodem", data->modem_port);
+	
+	data->gprs = ofono_gprs_create(modem, 0,
+					"atmodem", data->modem_port);
+	data->gc = ofono_gprs_context_create(modem, 0,
+					"atmodem", data->data_port);
 
-	if (gprs && gc)
-		ofono_gprs_add_context(gprs, gc);
+	if (data->gprs && data->gc)
+		ofono_gprs_add_context(data->gprs, data->gc);
 
 	mw = ofono_message_waiting_create(modem);
 
@@ -336,8 +327,7 @@ static struct ofono_modem_driver linktop_driver = {
 	.disable	= linktop_disable,
 	.set_online	= linktop_set_online,
 	.pre_sim	= linktop_pre_sim,
-	.post_sim	= linktop_post_sim,
-	.post_online	= linktop_post_online,
+	.post_sim	= linktop_post_sim
 };
 
 static int linktop_init(void)
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread
* [PATCH 1/2] linktop: reimplemented linktop plugin based on mbm with minimum features
@ 2011-06-15  7:13 Amit Mendapara
  2011-06-15  7:13 ` [PATCH 2/2] udev: changed linktop device strings Amit Mendapara
  0 siblings, 1 reply; 10+ messages in thread
From: Amit Mendapara @ 2011-06-15  7:13 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 14273 bytes --]

The AT commands listed with AT+CLAC matches with MBM supported devices.
However, the mbm plugin doesn't work for this devices and the specification is
also quite different.

I have also adopted some fixes from huawei plugin to fix MeeGo bug #14784

The device supports voice call but I am unable to hear any sound after
making calls even though the soundcard is detected by the kernel.

The device also supports sim toolkit commands but I am unable to test
this feature.

All these untested features will be added later.
---
 plugins/linktop.c |  299 +++++++++++++++++++++++++++++++++++------------------
 1 files changed, 199 insertions(+), 100 deletions(-)

diff --git a/plugins/linktop.c b/plugins/linktop.c
index 953f634..4083f17 100644
--- a/plugins/linktop.c
+++ b/plugins/linktop.c
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <glib.h>
 #include <gatchat.h>
@@ -34,10 +35,6 @@
 #define OFONO_API_SUBJECT_TO_CHANGE
 #include <ofono/plugin.h>
 #include <ofono/modem.h>
-#include <ofono/call-barring.h>
-#include <ofono/call-forwarding.h>
-#include <ofono/call-meter.h>
-#include <ofono/call-settings.h>
 #include <ofono/devinfo.h>
 #include <ofono/message-waiting.h>
 #include <ofono/netreg.h>
@@ -45,24 +42,27 @@
 #include <ofono/cbs.h>
 #include <ofono/sms.h>
 #include <ofono/ussd.h>
-#include <ofono/call-volume.h>
-#include <ofono/voicecall.h>
 #include <ofono/gprs.h>
 #include <ofono/gprs-context.h>
 #include <ofono/phonebook.h>
 #include <ofono/radio-settings.h>
 #include <ofono/log.h>
 
-#include <drivers/atmodem/vendor.h>
 #include <drivers/atmodem/atutil.h>
+#include <drivers/atmodem/vendor.h>
 
+static const char *cpin_prefix[] = { "+CPIN:", NULL };
 static const char *none_prefix[] = { NULL };
 
 struct linktop_data {
-	GAtChat *modem;
-	GAtChat *control;
+	GAtChat *modem_port;
+	GAtChat *data_port;
+	guint cpin_poll_source;
+	guint cpin_poll_count;
+	gboolean have_sim;
 	struct ofono_gprs *gprs;
 	struct ofono_gprs_context *gc;
+	guint reopen_source;
 };
 
 static int linktop_probe(struct ofono_modem *modem)
@@ -86,35 +86,86 @@ static void linktop_remove(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
+	if (data->reopen_source > 0) {
+		g_source_remove(data->reopen_source);
+		data->reopen_source = 0;
+	}
+
 	ofono_modem_set_data(modem, NULL);
 
-	g_at_chat_unref(data->modem);
-	g_at_chat_unref(data->control);
+	g_at_chat_unref(data->data_port);
+	g_at_chat_unref(data->modem_port);
+
+	if (data->cpin_poll_source > 0)
+		g_source_remove(data->cpin_poll_source);
 
 	g_free(data);
 }
 
 static void linktop_debug(const char *str, void *user_data)
 {
-        const char *prefix = user_data;
+	const char *prefix = user_data;
+
+	ofono_info("%s%s", prefix, str);
+}
+
+static gboolean init_simpin_check(gpointer user_data);
+
+static void simpin_check(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct linktop_data *data = ofono_modem_get_data(modem);
+
+	DBG("");
+
+	/* Modem returns an error if SIM is not ready. */
+	if (!ok && data->cpin_poll_count++ < 5) {
+		data->cpin_poll_source =
+			g_timeout_add_seconds(1, init_simpin_check, modem);
+		return;
+	}
+
+	data->cpin_poll_count = 0;
+
+	/* There is probably no SIM if SIM is not ready after 5 seconds. */
+	data->have_sim = ok;
+
+	ofono_modem_set_powered(modem, TRUE);
+}
+
+static gboolean init_simpin_check(gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct linktop_data *data = ofono_modem_get_data(modem);
+
+	data->cpin_poll_source = 0;
 
-        ofono_info("%s%s", prefix, str);
+	g_at_chat_send(data->modem_port, "AT+CPIN?", cpin_prefix,
+			simpin_check, modem, NULL);
+
+	return FALSE;
 }
 
-static GAtChat *open_device(struct ofono_modem *modem,
-				const char *key, char *debug)
+static void cfun_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+
+	DBG("");
+
+	if (!ok) {
+		ofono_modem_set_powered(modem, FALSE);
+		return;
+	}
+
+	init_simpin_check(modem);
+}
+
+static GAtChat *create_port(const char *device)
 {
-	const char *device;
 	GAtSyntax *syntax;
 	GIOChannel *channel;
 	GAtChat *chat;
 
-	device = ofono_modem_get_string(modem, key);
-	if (device == NULL)
-		return NULL;
-
-	DBG("%s %s", key, device);
-
 	channel = g_at_tty_open(device, NULL);
 	if (channel == NULL)
 		return NULL;
@@ -127,93 +178,130 @@ static GAtChat *open_device(struct ofono_modem *modem,
 	if (chat == NULL)
 		return NULL;
 
-	if (getenv("OFONO_AT_DEBUG"))
-		g_at_chat_set_debug(chat, linktop_debug, debug);
-
 	return chat;
 }
 
-static void linktop_disconnect(gpointer user_data)
+static void linktop_disconnect(gpointer user_data);
+
+static gboolean reopen_callback(gpointer user_data)
 {
 	struct ofono_modem *modem = user_data;
 	struct linktop_data *data = ofono_modem_get_data(modem);
+	const char *data_dev;
+
+	data_dev = ofono_modem_get_string(modem, "DataDevice");
+	data->data_port = create_port(data_dev);
+	/* retry once if failed */
+	if (data->data_port == NULL) {
+		if (data->reopen_source > 0)
+			return FALSE;
+
+		data->reopen_source = g_timeout_add_seconds(1,
+				reopen_callback, modem);
+		ofono_debug("opening data port failed, retrying...");
+		return FALSE;
+	}
 
-	DBG("");
-
-	if (data->gc)
-		ofono_gprs_context_remove(data->gc);
-
-	g_at_chat_unref(data->modem);
-	data->modem = NULL;
-
-	data->modem = open_device(modem, "Modem", "Modem: ");
-	if (data->modem == NULL)
-		return;
+	if (getenv("OFONO_AT_DEBUG"))
+		g_at_chat_set_debug(data->data_port, linktop_debug, "Data: ");
 
-	g_at_chat_set_disconnect_function(data->modem,
+	g_at_chat_set_disconnect_function(data->data_port,
 						linktop_disconnect, modem);
 
 	ofono_info("Reopened GPRS context channel");
 
-	data->gc = ofono_gprs_context_create(modem, 0, "atmodem", data->modem);
-
+	data->gc = ofono_gprs_context_create(modem, 0,
+					"atmodem", data->data_port);
 	if (data->gprs && data->gc)
 		ofono_gprs_add_context(data->gprs, data->gc);
+
+	data->reopen_source = 0;
+
+	return FALSE;
 }
 
-static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
+static void linktop_disconnect(gpointer user_data)
 {
 	struct ofono_modem *modem = user_data;
+	struct linktop_data *data = ofono_modem_get_data(modem);
 
-	DBG("");
+	DBG("%p, data->gc %p", modem, data->gc);
 
-	ofono_modem_set_powered(modem, ok);
+	/* gprs_context has been destructed and needs not reopen */
+	if (data->gc == NULL)
+		return
+	
+	ofono_gprs_context_remove(data->gc);
+
+	g_at_chat_unref(data->data_port);
+	data->data_port = NULL;
+
+	/* Waiting for the +CGEV: ME DEACT might also work */
+	if (data->reopen_source > 0)
+		g_source_remove(data->reopen_source);
+
+	data->reopen_source = g_timeout_add_seconds(1, reopen_callback, modem);
 }
 
 static int linktop_enable(struct ofono_modem *modem)
 {
 	struct linktop_data *data = ofono_modem_get_data(modem);
+	const char *modem_dev;
+	const char *data_dev;
 
 	DBG("%p", modem);
 
-	data->modem = open_device(modem, "Modem", "Modem: ");
-	if (data->modem == NULL)
-		return -EINVAL;
+	modem_dev = ofono_modem_get_string(modem, "ModemDevice");
+	data_dev = ofono_modem_get_string(modem, "DataDevice");
 
-	g_at_chat_set_disconnect_function(data->modem,
-						linktop_disconnect, modem);
+	DBG("%s, %s", modem_dev, data_dev);
 
-	data->control = open_device(modem, "Control", "Control: ");
-	if (data->control == NULL) {
-		g_at_chat_unref(data->modem);
-		data->modem = NULL;
+	if (modem_dev == NULL || data_dev == NULL)
+		return -EINVAL;
+
+	data->modem_port = create_port(modem_dev);
+	if (data->modem_port == NULL)
 		return -EIO;
-	}
 
-	g_at_chat_send(data->control, "ATE0 +CMEE=1", none_prefix,
-						NULL, NULL, NULL);
+	if (getenv("OFONO_AT_DEBUG"))
+		g_at_chat_set_debug(data->modem_port, linktop_debug, "Modem: ");
 
-	g_at_chat_send(data->modem, "AT", none_prefix,
-						NULL, NULL, NULL);
+	data->data_port = create_port(data_dev);
+	if (data->data_port == NULL) {
+		g_at_chat_unref(data->modem_port);
+		data->modem_port = NULL;
+
+		return -EIO;
+	}
 
-	g_at_chat_send(data->modem, "AT &F", none_prefix,
-						NULL, NULL, NULL);
+	if (getenv("OFONO_AT_DEBUG"))
+		g_at_chat_set_debug(data->data_port, linktop_debug, "Data: ");
 
-	g_at_chat_send(data->control, "AT+CFUN=4", none_prefix,
-					cfun_enable, modem, NULL);
+	g_at_chat_set_disconnect_function(data->data_port,
+						linktop_disconnect, modem);
 
+	g_at_chat_send(data->modem_port, "AT&F E0 V1 X4 &C1 +CMEE=1", none_prefix,
+				cfun_enable_cb, modem, NULL);
+	g_at_chat_send(data->data_port, "AT&F E0 V1 X4 &C1 +CMEE=1", none_prefix,
+				cfun_enable_cb, modem, NULL);
+	g_at_chat_send(data->modem_port, "AT+CFUN=4", none_prefix,
+				cfun_enable_cb, modem, NULL);
+	
 	return -EINPROGRESS;
 }
 
-static void cfun_disable(gboolean ok, GAtResult *result, gpointer user_data)
+static void cfun_disable_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct ofono_modem *modem = user_data;
 	struct linktop_data *data = ofono_modem_get_data(modem);
 
 	DBG("");
 
-	g_at_chat_unref(data->control);
-	data->control = NULL;
+	g_at_chat_unref(data->modem_port);
+	data->modem_port = NULL;
+
+	g_at_chat_unref(data->data_port);
+	data->data_port = NULL;
 
 	if (ok)
 		ofono_modem_set_powered(modem, FALSE);
@@ -225,20 +313,18 @@ static int linktop_disable(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
-	if (data->modem) {
-		g_at_chat_cancel_all(data->modem);
-		g_at_chat_unregister_all(data->modem);
-		g_at_chat_unref(data->modem);
-		data->modem = NULL;
+	if (data->reopen_source > 0) {
+		g_source_remove(data->reopen_source);
+		data->reopen_source = 0;
 	}
 
-	if (data->control == NULL)
+	if (data->modem_port == NULL)
 		return 0;
 
-	g_at_chat_cancel_all(data->control);
-	g_at_chat_unregister_all(data->control);
-	g_at_chat_send(data->control, "AT+CFUN=4", none_prefix,
-					cfun_disable, modem, NULL);
+	g_at_chat_cancel_all(data->modem_port);
+	g_at_chat_unregister_all(data->modem_port);
+	g_at_chat_send(data->modem_port, "AT+CFUN=4", NULL,
+					cfun_disable_cb, modem, NULL);
 
 	return -EINPROGRESS;
 }
@@ -253,17 +339,37 @@ static void set_online_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	cb(&error, cbd->data);
 }
 
+static void set_offline_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	ofono_modem_online_cb_t cb = cbd->cb;
+	struct ofono_error error;
+
+	if (ok) {
+		struct linktop_data *data = cbd->user;
+
+		data->gc = NULL;
+		data->gprs = NULL;
+	}
+
+	decode_at_error(&error, g_at_result_final_response(result));
+	cb(&error, cbd->data);
+}
+
 static void linktop_set_online(struct ofono_modem *modem, ofono_bool_t online,
 				ofono_modem_online_cb_t cb, void *user_data)
 {
 	struct linktop_data *data = ofono_modem_get_data(modem);
-	GAtChat *chat = data->control;
+	GAtChat *chat = data->modem_port;
 	struct cb_data *cbd = cb_data_new(cb, user_data);
 	char const *command = online ? "AT+CFUN=1" : "AT+CFUN=4";
 
 	DBG("modem %p %s", modem, online ? "online" : "offline");
 
-	if (g_at_chat_send(chat, command, NULL, set_online_cb, cbd, g_free))
+	cbd->user = data;
+
+	if (g_at_chat_send(chat, command, NULL,
+				online ? set_online_cb : set_offline_cb, cbd, g_free))
 		return;
 
 	g_free(cbd);
@@ -278,11 +384,10 @@ static void linktop_pre_sim(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
-	ofono_devinfo_create(modem, 0, "atmodem", data->control);
-	sim = ofono_sim_create(modem, 0, "atmodem", data->control);
-	ofono_voicecall_create(modem, 0, "stemodem", data->control);
+	ofono_devinfo_create(modem, 0, "atmodem", data->modem_port);
+	sim = ofono_sim_create(modem, 0, "atmodem", data->modem_port);
 
-	if (sim)
+	if (data->have_sim && sim)
 		ofono_sim_inserted_notify(sim, TRUE);
 }
 
@@ -292,35 +397,29 @@ static void linktop_post_sim(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
-	ofono_radio_settings_create(modem, 0, "stemodem", data->control);
-	ofono_phonebook_create(modem, 0, "atmodem", data->control);
-	ofono_sms_create(modem, 0, "atmodem", data->control);
+	ofono_radio_settings_create(modem, 0, "stemodem", data->modem_port);
+	ofono_phonebook_create(modem, 0, "atmodem", data->modem_port);
+	ofono_sms_create(modem, 0, "atmodem", data->modem_port);
 }
 
 static void linktop_post_online(struct ofono_modem *modem)
 {
 	struct linktop_data *data = ofono_modem_get_data(modem);
 	struct ofono_message_waiting *mw;
-	struct ofono_gprs *gprs;
-	struct ofono_gprs_context *gc;
 
 	DBG("%p", modem);
 
-	ofono_ussd_create(modem, 0, "atmodem", data->control);
-	ofono_call_forwarding_create(modem, 0, "atmodem", data->control);
-	ofono_call_settings_create(modem, 0, "atmodem", data->control);
-	ofono_netreg_create(modem, OFONO_VENDOR_MBM, "atmodem", data->control);
-	ofono_call_meter_create(modem, 0, "atmodem", data->control);
-	ofono_call_barring_create(modem, 0, "atmodem", data->control);
-	ofono_call_volume_create(modem, 0, "atmodem", data->control);
-	ofono_cbs_create(modem, 0, "atmodem", data->control);
-
-	gprs = ofono_gprs_create(modem, OFONO_VENDOR_MBM,
-					"atmodem", data->control);
-	gc = ofono_gprs_context_create(modem, 0, "atmodem", data->modem);
-
-	if (gprs && gc)
-		ofono_gprs_add_context(gprs, gc);
+	ofono_netreg_create(modem, 0, "atmodem", data->modem_port);
+	ofono_cbs_create(modem, 0, "atmodem", data->modem_port);
+	ofono_ussd_create(modem, 0, "atmodem", data->modem_port);
+
+	data->gprs = ofono_gprs_create(modem, 0,
+					"atmodem", data->modem_port);
+	data->gc = ofono_gprs_context_create(modem, 0,
+					"atmodem", data->data_port);
+
+	if (data->gprs && data->gc)
+		ofono_gprs_add_context(data->gprs, data->gc);
 
 	mw = ofono_message_waiting_create(modem);
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread
* [PATCH 1/2] linktop: reimplemented linktop plugin based on mbm
@ 2011-06-08  9:46 Amit Mendapara
  2011-06-08  9:46 ` [PATCH 2/2] udev: changed linktop device strings Amit Mendapara
  0 siblings, 1 reply; 10+ messages in thread
From: Amit Mendapara @ 2011-06-08  9:46 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 13953 bytes --]

The AT commands listed with AT+CLAC matches with MBM supported devices.
However, the mbm plugin doesn't work for this devices and the specification is
also quite different.

I have also adopted some fixes from huawei plugin to fix MeeGo bug #14784

Signed-off-by: Amit Mendapara <mendapara.amit@gmail.com>
---
 plugins/linktop.c |  301 ++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 208 insertions(+), 93 deletions(-)

diff --git a/plugins/linktop.c b/plugins/linktop.c
index 953f634..26536d8 100644
--- a/plugins/linktop.c
+++ b/plugins/linktop.c
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <glib.h>
 #include <gatchat.h>
@@ -42,6 +43,7 @@
 #include <ofono/message-waiting.h>
 #include <ofono/netreg.h>
 #include <ofono/sim.h>
+#include <ofono/stk.h>
 #include <ofono/cbs.h>
 #include <ofono/sms.h>
 #include <ofono/ussd.h>
@@ -53,16 +55,21 @@
 #include <ofono/radio-settings.h>
 #include <ofono/log.h>
 
-#include <drivers/atmodem/vendor.h>
 #include <drivers/atmodem/atutil.h>
+#include <drivers/atmodem/vendor.h>
 
+static const char *cpin_prefix[] = { "+CPIN:", NULL };
 static const char *none_prefix[] = { NULL };
 
 struct linktop_data {
-	GAtChat *modem;
-	GAtChat *control;
+	GAtChat *modem_port;
+	GAtChat *data_port;
+	guint cpin_poll_source;
+	guint cpin_poll_count;
+	gboolean have_sim;
 	struct ofono_gprs *gprs;
 	struct ofono_gprs_context *gc;
+	guint reopen_source;
 };
 
 static int linktop_probe(struct ofono_modem *modem)
@@ -86,35 +93,86 @@ static void linktop_remove(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
+	if (data->reopen_source > 0) {
+		g_source_remove(data->reopen_source);
+		data->reopen_source = 0;
+	}
+
 	ofono_modem_set_data(modem, NULL);
 
-	g_at_chat_unref(data->modem);
-	g_at_chat_unref(data->control);
+	g_at_chat_unref(data->data_port);
+	g_at_chat_unref(data->modem_port);
+
+	if (data->cpin_poll_source > 0)
+		g_source_remove(data->cpin_poll_source);
 
 	g_free(data);
 }
 
 static void linktop_debug(const char *str, void *user_data)
 {
-        const char *prefix = user_data;
+	const char *prefix = user_data;
+
+	ofono_info("%s%s", prefix, str);
+}
+
+static gboolean init_simpin_check(gpointer user_data);
+
+static void simpin_check(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct linktop_data *data = ofono_modem_get_data(modem);
 
-        ofono_info("%s%s", prefix, str);
+	DBG("");
+
+	/* Modem returns an error if SIM is not ready. */
+	if (!ok && data->cpin_poll_count++ < 5) {
+		data->cpin_poll_source =
+			g_timeout_add_seconds(1, init_simpin_check, modem);
+		return;
+	}
+
+	data->cpin_poll_count = 0;
+
+	/* There is probably no SIM if SIM is not ready after 5 seconds. */
+	data->have_sim = ok;
+
+	ofono_modem_set_powered(modem, TRUE);
 }
 
-static GAtChat *open_device(struct ofono_modem *modem,
-				const char *key, char *debug)
+static gboolean init_simpin_check(gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct linktop_data *data = ofono_modem_get_data(modem);
+
+	data->cpin_poll_source = 0;
+
+	g_at_chat_send(data->modem_port, "AT+CPIN?", cpin_prefix,
+			simpin_check, modem, NULL);
+
+	return FALSE;
+}
+
+static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+
+	DBG("");
+
+	if (!ok) {
+		ofono_modem_set_powered(modem, FALSE);
+		return;
+	}
+
+	init_simpin_check(modem);
+}
+
+static GAtChat *create_port(const char *device)
 {
-	const char *device;
 	GAtSyntax *syntax;
 	GIOChannel *channel;
 	GAtChat *chat;
 
-	device = ofono_modem_get_string(modem, key);
-	if (device == NULL)
-		return NULL;
-
-	DBG("%s %s", key, device);
-
 	channel = g_at_tty_open(device, NULL);
 	if (channel == NULL)
 		return NULL;
@@ -127,81 +185,116 @@ static GAtChat *open_device(struct ofono_modem *modem,
 	if (chat == NULL)
 		return NULL;
 
-	if (getenv("OFONO_AT_DEBUG"))
-		g_at_chat_set_debug(chat, linktop_debug, debug);
-
 	return chat;
 }
 
-static void linktop_disconnect(gpointer user_data)
+static void linktop_disconnect(gpointer user_data);
+
+static gboolean reopen_callback(gpointer user_data)
 {
 	struct ofono_modem *modem = user_data;
 	struct linktop_data *data = ofono_modem_get_data(modem);
+	const char *data_dev;
+
+	data_dev = ofono_modem_get_string(modem, "DataDevice");
+	data->data_port = create_port(data_dev);
+	/* retry once if failed */
+	if (data->data_port == NULL) {
+		if (data->reopen_source > 0)
+			return FALSE;
+
+		data->reopen_source = g_timeout_add_seconds(1,
+				reopen_callback, modem);
+		ofono_debug("opening data port failed, retrying...");
+		return FALSE;
+	}
 
-	DBG("");
-
-	if (data->gc)
-		ofono_gprs_context_remove(data->gc);
-
-	g_at_chat_unref(data->modem);
-	data->modem = NULL;
-
-	data->modem = open_device(modem, "Modem", "Modem: ");
-	if (data->modem == NULL)
-		return;
+	if (getenv("OFONO_AT_DEBUG"))
+		g_at_chat_set_debug(data->data_port, linktop_debug, "Data: ");
 
-	g_at_chat_set_disconnect_function(data->modem,
+	g_at_chat_set_disconnect_function(data->data_port,
 						linktop_disconnect, modem);
 
 	ofono_info("Reopened GPRS context channel");
 
-	data->gc = ofono_gprs_context_create(modem, 0, "atmodem", data->modem);
-
-	if (data->gprs && data->gc)
+	data->gc = ofono_gprs_context_create(modem, 0,
+					"atmodem", data->data_port);
+	if (data->gprs && data->gc) {
 		ofono_gprs_add_context(data->gprs, data->gc);
+	}
+
+	data->reopen_source = 0;
+
+	return FALSE;
 }
 
-static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
+static void linktop_disconnect(gpointer user_data)
 {
 	struct ofono_modem *modem = user_data;
+	struct linktop_data *data = ofono_modem_get_data(modem);
 
-	DBG("");
+	DBG("%p, data->gc %p", modem, data->gc);
+
+	/* gprs_context has been destructed and needs not reopen */
+	if (data->gc == NULL)
+		return
+	
+	ofono_gprs_context_remove(data->gc);
 
-	ofono_modem_set_powered(modem, ok);
+	g_at_chat_unref(data->data_port);
+	data->data_port = NULL;
+
+	/* Waiting for the +CGEV: ME DEACT might also work */
+	if (data->reopen_source > 0)
+		g_source_remove(data->reopen_source);
+
+	data->reopen_source = g_timeout_add_seconds(1, reopen_callback, modem);
 }
 
 static int linktop_enable(struct ofono_modem *modem)
 {
 	struct linktop_data *data = ofono_modem_get_data(modem);
+	const char *modem_dev;
+	const char *data_dev;
 
 	DBG("%p", modem);
 
-	data->modem = open_device(modem, "Modem", "Modem: ");
-	if (data->modem == NULL)
-		return -EINVAL;
+	modem_dev = ofono_modem_get_string(modem, "ModemDevice");
+	data_dev = ofono_modem_get_string(modem, "DataDevice");
 
-	g_at_chat_set_disconnect_function(data->modem,
-						linktop_disconnect, modem);
+	DBG("%s, %s", modem_dev, data_dev);
+
+	if (modem_dev == NULL || data_dev == NULL)
+		return -EINVAL;
 
-	data->control = open_device(modem, "Control", "Control: ");
-	if (data->control == NULL) {
-		g_at_chat_unref(data->modem);
-		data->modem = NULL;
+	data->modem_port = create_port(modem_dev);
+	if (data->modem_port == NULL)
 		return -EIO;
-	}
 
-	g_at_chat_send(data->control, "ATE0 +CMEE=1", none_prefix,
-						NULL, NULL, NULL);
+	if (getenv("OFONO_AT_DEBUG"))
+		g_at_chat_set_debug(data->modem_port, linktop_debug, "Modem: ");
+
+	data->data_port = create_port(data_dev);
+	if (data->data_port == NULL) {
+		g_at_chat_unref(data->modem_port);
+		data->modem_port = NULL;
 
-	g_at_chat_send(data->modem, "AT", none_prefix,
-						NULL, NULL, NULL);
+		return -EIO;
+	}
 
-	g_at_chat_send(data->modem, "AT &F", none_prefix,
-						NULL, NULL, NULL);
+	if (getenv("OFONO_AT_DEBUG"))
+		g_at_chat_set_debug(data->data_port, linktop_debug, "Data: ");
 
-	g_at_chat_send(data->control, "AT+CFUN=4", none_prefix,
-					cfun_enable, modem, NULL);
+	g_at_chat_set_disconnect_function(data->data_port,
+						linktop_disconnect, modem);
 
+	g_at_chat_send(data->modem_port, "AT&F E0 V1 X4 &C1 +CMEE=1", NULL,
+					NULL, NULL, NULL);
+	g_at_chat_send(data->data_port, "AT&F E0 V1 X4 &C1 +CMEE=1", NULL,
+					NULL, NULL, NULL);
+	g_at_chat_send(data->modem_port, "AT+CFUN=4", none_prefix,
+				cfun_enable, modem, NULL);
+	
 	return -EINPROGRESS;
 }
 
@@ -212,8 +305,11 @@ static void cfun_disable(gboolean ok, GAtResult *result, gpointer user_data)
 
 	DBG("");
 
-	g_at_chat_unref(data->control);
-	data->control = NULL;
+	g_at_chat_unref(data->modem_port);
+	data->modem_port = NULL;
+
+	g_at_chat_unref(data->data_port);
+	data->data_port = NULL;
 
 	if (ok)
 		ofono_modem_set_powered(modem, FALSE);
@@ -225,19 +321,17 @@ static int linktop_disable(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
-	if (data->modem) {
-		g_at_chat_cancel_all(data->modem);
-		g_at_chat_unregister_all(data->modem);
-		g_at_chat_unref(data->modem);
-		data->modem = NULL;
+	if (data->reopen_source > 0) {
+		g_source_remove(data->reopen_source);
+		data->reopen_source = 0;
 	}
 
-	if (data->control == NULL)
+	if (data->modem_port == NULL)
 		return 0;
 
-	g_at_chat_cancel_all(data->control);
-	g_at_chat_unregister_all(data->control);
-	g_at_chat_send(data->control, "AT+CFUN=4", none_prefix,
+	g_at_chat_cancel_all(data->modem_port);
+	g_at_chat_unregister_all(data->modem_port);
+	g_at_chat_send(data->modem_port, "AT+CFUN=4", NULL,
 					cfun_disable, modem, NULL);
 
 	return -EINPROGRESS;
@@ -253,17 +347,37 @@ static void set_online_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	cb(&error, cbd->data);
 }
 
+static void set_offline_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	ofono_modem_online_cb_t cb = cbd->cb;
+	struct ofono_error error;
+
+	if (ok) {
+		struct linktop_data *data = cbd->user;
+
+		data->gc = NULL;
+		data->gprs = NULL;
+	}
+
+	decode_at_error(&error, g_at_result_final_response(result));
+	cb(&error, cbd->data);
+}
+
 static void linktop_set_online(struct ofono_modem *modem, ofono_bool_t online,
 				ofono_modem_online_cb_t cb, void *user_data)
 {
 	struct linktop_data *data = ofono_modem_get_data(modem);
-	GAtChat *chat = data->control;
+	GAtChat *chat = data->modem_port;
 	struct cb_data *cbd = cb_data_new(cb, user_data);
 	char const *command = online ? "AT+CFUN=1" : "AT+CFUN=4";
 
 	DBG("modem %p %s", modem, online ? "online" : "offline");
 
-	if (g_at_chat_send(chat, command, NULL, set_online_cb, cbd, g_free))
+	cbd->user = data;
+
+	if (g_at_chat_send(chat, command, NULL,
+				online ? set_online_cb : set_offline_cb, cbd, g_free))
 		return;
 
 	g_free(cbd);
@@ -278,11 +392,11 @@ static void linktop_pre_sim(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
-	ofono_devinfo_create(modem, 0, "atmodem", data->control);
-	sim = ofono_sim_create(modem, 0, "atmodem", data->control);
-	ofono_voicecall_create(modem, 0, "stemodem", data->control);
+	ofono_devinfo_create(modem, 0, "atmodem", data->modem_port);
+	sim = ofono_sim_create(modem, 0, "atmodem", data->modem_port);
+	ofono_voicecall_create(modem, 0, "stemodem", data->modem_port);
 
-	if (sim)
+	if (data->have_sim && sim)
 		ofono_sim_inserted_notify(sim, TRUE);
 }
 
@@ -292,35 +406,36 @@ static void linktop_post_sim(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
-	ofono_radio_settings_create(modem, 0, "stemodem", data->control);
-	ofono_phonebook_create(modem, 0, "atmodem", data->control);
-	ofono_sms_create(modem, 0, "atmodem", data->control);
+	ofono_stk_create(modem, 0, "mbmmodem", data->modem_port);
+	ofono_radio_settings_create(modem, 0, "stemodem", data->modem_port);
+	ofono_phonebook_create(modem, 0, "atmodem", data->modem_port);
+	ofono_sms_create(modem, 0, "atmodem", data->modem_port);
 }
 
 static void linktop_post_online(struct ofono_modem *modem)
 {
 	struct linktop_data *data = ofono_modem_get_data(modem);
 	struct ofono_message_waiting *mw;
-	struct ofono_gprs *gprs;
-	struct ofono_gprs_context *gc;
 
 	DBG("%p", modem);
 
-	ofono_ussd_create(modem, 0, "atmodem", data->control);
-	ofono_call_forwarding_create(modem, 0, "atmodem", data->control);
-	ofono_call_settings_create(modem, 0, "atmodem", data->control);
-	ofono_netreg_create(modem, OFONO_VENDOR_MBM, "atmodem", data->control);
-	ofono_call_meter_create(modem, 0, "atmodem", data->control);
-	ofono_call_barring_create(modem, 0, "atmodem", data->control);
-	ofono_call_volume_create(modem, 0, "atmodem", data->control);
-	ofono_cbs_create(modem, 0, "atmodem", data->control);
-
-	gprs = ofono_gprs_create(modem, OFONO_VENDOR_MBM,
-					"atmodem", data->control);
-	gc = ofono_gprs_context_create(modem, 0, "atmodem", data->modem);
-
-	if (gprs && gc)
-		ofono_gprs_add_context(gprs, gc);
+	ofono_netreg_create(modem, 0, "atmodem", data->modem_port);
+	ofono_cbs_create(modem, 0, "atmodem", data->modem_port);
+	ofono_ussd_create(modem, 0, "atmodem", data->modem_port);
+	ofono_call_forwarding_create(modem, 0, "atmodem", data->modem_port);
+	ofono_call_settings_create(modem, 0, "atmodem", data->modem_port);
+	ofono_call_meter_create(modem, 0, "atmodem", data->modem_port);
+	ofono_call_barring_create(modem, 0, "atmodem", data->modem_port);
+	ofono_call_volume_create(modem, 0, "atmodem", data->modem_port);
+
+	data->gprs = ofono_gprs_create(modem, 0,
+					"atmodem", data->modem_port);
+	data->gc = ofono_gprs_context_create(modem, 0,
+					"atmodem", data->data_port);
+
+	if (data->gprs && data->gc) {
+		ofono_gprs_add_context(data->gprs, data->gc);
+	}
 
 	mw = ofono_message_waiting_create(modem);
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread
* [PATCH 1/2] linktop: reimplemented linktop plugin based on mbm
@ 2011-04-14 10:13 Amit Mendapara
  2011-04-14 10:13 ` [PATCH 2/2] udev: changed linktop device strings Amit Mendapara
  0 siblings, 1 reply; 10+ messages in thread
From: Amit Mendapara @ 2011-04-14 10:13 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 13057 bytes --]

The AT commands listed with AT+CLAC matches with MBM supported devices.
However, the mbm plugin doesn't work for this devices and the specification is
also quite different.

Fixes MeeGo bug #14784
---
 plugins/linktop.c |  268 +++++++++++++++++++++++++++++++++++------------------
 1 files changed, 177 insertions(+), 91 deletions(-)

diff --git a/plugins/linktop.c b/plugins/linktop.c
index 953f634..2f603a9 100644
--- a/plugins/linktop.c
+++ b/plugins/linktop.c
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <glib.h>
 #include <gatchat.h>
@@ -42,6 +43,7 @@
 #include <ofono/message-waiting.h>
 #include <ofono/netreg.h>
 #include <ofono/sim.h>
+#include <ofono/stk.h>
 #include <ofono/cbs.h>
 #include <ofono/sms.h>
 #include <ofono/ussd.h>
@@ -53,16 +55,21 @@
 #include <ofono/radio-settings.h>
 #include <ofono/log.h>
 
-#include <drivers/atmodem/vendor.h>
 #include <drivers/atmodem/atutil.h>
+#include <drivers/atmodem/vendor.h>
 
+static const char *cpin_prefix[] = { "+CPIN:", NULL };
 static const char *none_prefix[] = { NULL };
 
 struct linktop_data {
-	GAtChat *modem;
-	GAtChat *control;
+	GAtChat *modem_port;
+	GAtChat *data_port;
+	guint cpin_poll_source;
+	guint cpin_poll_count;
+	gboolean have_sim;
 	struct ofono_gprs *gprs;
 	struct ofono_gprs_context *gc;
+	guint reopen_source;
 };
 
 static int linktop_probe(struct ofono_modem *modem)
@@ -86,35 +93,86 @@ static void linktop_remove(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
+	if (data->reopen_source > 0) {
+		g_source_remove(data->reopen_source);
+		data->reopen_source = 0;
+	}
+
 	ofono_modem_set_data(modem, NULL);
 
-	g_at_chat_unref(data->modem);
-	g_at_chat_unref(data->control);
+	g_at_chat_unref(data->data_port);
+	g_at_chat_unref(data->modem_port);
+
+	if (data->cpin_poll_source > 0)
+		g_source_remove(data->cpin_poll_source);
 
 	g_free(data);
 }
 
 static void linktop_debug(const char *str, void *user_data)
 {
-        const char *prefix = user_data;
+	const char *prefix = user_data;
+
+	ofono_info("%s%s", prefix, str);
+}
+
+static gboolean init_simpin_check(gpointer user_data);
+
+static void simpin_check(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct linktop_data *data = ofono_modem_get_data(modem);
+
+	DBG("");
+
+	/* Modem returns an error if SIM is not ready. */
+	if (!ok && data->cpin_poll_count++ < 5) {
+		data->cpin_poll_source =
+			g_timeout_add_seconds(1, init_simpin_check, modem);
+		return;
+	}
+
+	data->cpin_poll_count = 0;
+
+	/* There is probably no SIM if SIM is not ready after 5 seconds. */
+	data->have_sim = ok;
+
+	ofono_modem_set_powered(modem, TRUE);
+}
+
+static gboolean init_simpin_check(gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct linktop_data *data = ofono_modem_get_data(modem);
+
+	data->cpin_poll_source = 0;
+
+	g_at_chat_send(data->modem_port, "AT+CPIN?", cpin_prefix,
+			simpin_check, modem, NULL);
+
+	return FALSE;
+}
+
+static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+
+	DBG("");
 
-        ofono_info("%s%s", prefix, str);
+	if (!ok) {
+		ofono_modem_set_powered(modem, FALSE);
+		return;
+	}
+
+	init_simpin_check(modem);
 }
 
-static GAtChat *open_device(struct ofono_modem *modem,
-				const char *key, char *debug)
+static GAtChat *create_port(const char *device)
 {
-	const char *device;
 	GAtSyntax *syntax;
 	GIOChannel *channel;
 	GAtChat *chat;
 
-	device = ofono_modem_get_string(modem, key);
-	if (device == NULL)
-		return NULL;
-
-	DBG("%s %s", key, device);
-
 	channel = g_at_tty_open(device, NULL);
 	if (channel == NULL)
 		return NULL;
@@ -127,81 +185,106 @@ static GAtChat *open_device(struct ofono_modem *modem,
 	if (chat == NULL)
 		return NULL;
 
-	if (getenv("OFONO_AT_DEBUG"))
-		g_at_chat_set_debug(chat, linktop_debug, debug);
-
 	return chat;
 }
 
-static void linktop_disconnect(gpointer user_data)
+static void linktop_disconnect(gpointer user_data);
+
+static gboolean reopen_callback(gpointer user_data)
 {
 	struct ofono_modem *modem = user_data;
 	struct linktop_data *data = ofono_modem_get_data(modem);
+	const char *data_dev;
 
-	DBG("");
+	data->reopen_source = 0;
 
-	if (data->gc)
-		ofono_gprs_context_remove(data->gc);
+	data_dev = ofono_modem_get_string(modem, "DataDevice");
 
-	g_at_chat_unref(data->modem);
-	data->modem = NULL;
+	data->data_port = create_port(data_dev);
+	if (data->data_port == NULL)
+		return FALSE;
 
-	data->modem = open_device(modem, "Modem", "Modem: ");
-	if (data->modem == NULL)
-		return;
+	if (getenv("OFONO_AT_DEBUG"))
+		g_at_chat_set_debug(data->data_port, linktop_debug, "Data: ");
 
-	g_at_chat_set_disconnect_function(data->modem,
+	g_at_chat_set_disconnect_function(data->data_port,
 						linktop_disconnect, modem);
 
 	ofono_info("Reopened GPRS context channel");
 
-	data->gc = ofono_gprs_context_create(modem, 0, "atmodem", data->modem);
-
-	if (data->gprs && data->gc)
+	data->gc = ofono_gprs_context_create(modem, 0,
+					"atmodem", data->data_port);
+	if (data->gprs && data->gc) {
 		ofono_gprs_add_context(data->gprs, data->gc);
+	}
+
+	return FALSE;
 }
 
-static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
+static void linktop_disconnect(gpointer user_data)
 {
 	struct ofono_modem *modem = user_data;
+	struct linktop_data *data = ofono_modem_get_data(modem);
 
 	DBG("");
 
-	ofono_modem_set_powered(modem, ok);
+	if (data->gc)
+		ofono_gprs_context_remove(data->gc);
+
+	g_at_chat_unref(data->data_port);
+	data->data_port = NULL;
+
+	/* Waiting for the +CGEV: ME DEACT might also work */
+	if (data->reopen_source > 0)
+		g_source_remove(data->reopen_source);
+
+	data->reopen_source = g_timeout_add_seconds(1, reopen_callback, modem);
 }
 
 static int linktop_enable(struct ofono_modem *modem)
 {
 	struct linktop_data *data = ofono_modem_get_data(modem);
+	const char *modem_dev;
+	const char *data_dev;
 
 	DBG("%p", modem);
 
-	data->modem = open_device(modem, "Modem", "Modem: ");
-	if (data->modem == NULL)
-		return -EINVAL;
+	modem_dev = ofono_modem_get_string(modem, "ModemDevice");
+	data_dev = ofono_modem_get_string(modem, "DataDevice");
 
-	g_at_chat_set_disconnect_function(data->modem,
-						linktop_disconnect, modem);
+	DBG("%s, %s", modem_dev, data_dev);
+
+	if (modem_dev == NULL || data_dev == NULL)
+		return -EINVAL;
 
-	data->control = open_device(modem, "Control", "Control: ");
-	if (data->control == NULL) {
-		g_at_chat_unref(data->modem);
-		data->modem = NULL;
+	data->modem_port = create_port(modem_dev);
+	if (data->modem_port == NULL)
 		return -EIO;
-	}
 
-	g_at_chat_send(data->control, "ATE0 +CMEE=1", none_prefix,
-						NULL, NULL, NULL);
+	if (getenv("OFONO_AT_DEBUG"))
+		g_at_chat_set_debug(data->modem_port, linktop_debug, "Modem: ");
 
-	g_at_chat_send(data->modem, "AT", none_prefix,
-						NULL, NULL, NULL);
+	data->data_port = create_port(data_dev);
+	if (data->data_port == NULL) {
+		g_at_chat_unref(data->modem_port);
+		data->modem_port = NULL;
 
-	g_at_chat_send(data->modem, "AT &F", none_prefix,
-						NULL, NULL, NULL);
+		return -EIO;
+	}
 
-	g_at_chat_send(data->control, "AT+CFUN=4", none_prefix,
-					cfun_enable, modem, NULL);
+	if (getenv("OFONO_AT_DEBUG"))
+		g_at_chat_set_debug(data->data_port, linktop_debug, "Data: ");
+
+	g_at_chat_set_disconnect_function(data->data_port,
+						linktop_disconnect, modem);
 
+	g_at_chat_send(data->modem_port, "AT&F E0 V1 X4 &C1 +CMEE=1", NULL,
+					NULL, NULL, NULL);
+	g_at_chat_send(data->data_port, "AT&F E0 V1 X4 &C1 +CMEE=1", NULL,
+					NULL, NULL, NULL);
+	g_at_chat_send(data->modem_port, "AT+CFUN=4", none_prefix,
+				cfun_enable, modem, NULL);
+	
 	return -EINPROGRESS;
 }
 
@@ -212,8 +295,11 @@ static void cfun_disable(gboolean ok, GAtResult *result, gpointer user_data)
 
 	DBG("");
 
-	g_at_chat_unref(data->control);
-	data->control = NULL;
+	g_at_chat_unref(data->modem_port);
+	data->modem_port = NULL;
+
+	g_at_chat_unref(data->data_port);
+	data->data_port = NULL;
 
 	if (ok)
 		ofono_modem_set_powered(modem, FALSE);
@@ -225,19 +311,17 @@ static int linktop_disable(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
-	if (data->modem) {
-		g_at_chat_cancel_all(data->modem);
-		g_at_chat_unregister_all(data->modem);
-		g_at_chat_unref(data->modem);
-		data->modem = NULL;
+	if (data->reopen_source > 0) {
+		g_source_remove(data->reopen_source);
+		data->reopen_source = 0;
 	}
 
-	if (data->control == NULL)
+	if (data->modem_port == NULL)
 		return 0;
 
-	g_at_chat_cancel_all(data->control);
-	g_at_chat_unregister_all(data->control);
-	g_at_chat_send(data->control, "AT+CFUN=4", none_prefix,
+	g_at_chat_cancel_all(data->modem_port);
+	g_at_chat_unregister_all(data->modem_port);
+	g_at_chat_send(data->modem_port, "AT+CFUN=4", NULL,
 					cfun_disable, modem, NULL);
 
 	return -EINPROGRESS;
@@ -247,17 +331,18 @@ static void set_online_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct cb_data *cbd = user_data;
 	ofono_modem_online_cb_t cb = cbd->cb;
-	struct ofono_error error;
 
-	decode_at_error(&error, g_at_result_final_response(result));
-	cb(&error, cbd->data);
+	if (ok)
+		CALLBACK_WITH_SUCCESS(cb, cbd->data);
+	else
+		CALLBACK_WITH_FAILURE(cb, cbd->data);
 }
 
 static void linktop_set_online(struct ofono_modem *modem, ofono_bool_t online,
 				ofono_modem_online_cb_t cb, void *user_data)
 {
 	struct linktop_data *data = ofono_modem_get_data(modem);
-	GAtChat *chat = data->control;
+	GAtChat *chat = data->modem_port;
 	struct cb_data *cbd = cb_data_new(cb, user_data);
 	char const *command = online ? "AT+CFUN=1" : "AT+CFUN=4";
 
@@ -278,11 +363,11 @@ static void linktop_pre_sim(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
-	ofono_devinfo_create(modem, 0, "atmodem", data->control);
-	sim = ofono_sim_create(modem, 0, "atmodem", data->control);
-	ofono_voicecall_create(modem, 0, "stemodem", data->control);
+	ofono_devinfo_create(modem, 0, "atmodem", data->modem_port);
+	sim = ofono_sim_create(modem, 0, "atmodem", data->modem_port);
+	ofono_voicecall_create(modem, 0, "stemodem", data->modem_port);
 
-	if (sim)
+	if (data->have_sim && sim)
 		ofono_sim_inserted_notify(sim, TRUE);
 }
 
@@ -292,35 +377,36 @@ static void linktop_post_sim(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
-	ofono_radio_settings_create(modem, 0, "stemodem", data->control);
-	ofono_phonebook_create(modem, 0, "atmodem", data->control);
-	ofono_sms_create(modem, 0, "atmodem", data->control);
+	ofono_stk_create(modem, 0, "mbmmodem", data->modem_port);
+	ofono_radio_settings_create(modem, 0, "stemodem", data->modem_port);
+	ofono_phonebook_create(modem, 0, "atmodem", data->modem_port);
+	ofono_sms_create(modem, 0, "atmodem", data->modem_port);
 }
 
 static void linktop_post_online(struct ofono_modem *modem)
 {
 	struct linktop_data *data = ofono_modem_get_data(modem);
 	struct ofono_message_waiting *mw;
-	struct ofono_gprs *gprs;
-	struct ofono_gprs_context *gc;
 
 	DBG("%p", modem);
 
-	ofono_ussd_create(modem, 0, "atmodem", data->control);
-	ofono_call_forwarding_create(modem, 0, "atmodem", data->control);
-	ofono_call_settings_create(modem, 0, "atmodem", data->control);
-	ofono_netreg_create(modem, OFONO_VENDOR_MBM, "atmodem", data->control);
-	ofono_call_meter_create(modem, 0, "atmodem", data->control);
-	ofono_call_barring_create(modem, 0, "atmodem", data->control);
-	ofono_call_volume_create(modem, 0, "atmodem", data->control);
-	ofono_cbs_create(modem, 0, "atmodem", data->control);
-
-	gprs = ofono_gprs_create(modem, OFONO_VENDOR_MBM,
-					"atmodem", data->control);
-	gc = ofono_gprs_context_create(modem, 0, "atmodem", data->modem);
-
-	if (gprs && gc)
-		ofono_gprs_add_context(gprs, gc);
+	ofono_netreg_create(modem, 0, "atmodem", data->modem_port);
+	ofono_cbs_create(modem, 0, "atmodem", data->modem_port);
+	ofono_ussd_create(modem, 0, "atmodem", data->modem_port);
+	ofono_call_forwarding_create(modem, 0, "atmodem", data->modem_port);
+	ofono_call_settings_create(modem, 0, "atmodem", data->modem_port);
+	ofono_call_meter_create(modem, 0, "atmodem", data->modem_port);
+	ofono_call_barring_create(modem, 0, "atmodem", data->modem_port);
+	ofono_call_volume_create(modem, 0, "atmodem", data->modem_port);
+
+	data->gprs = ofono_gprs_create(modem, 0,
+					"atmodem", data->modem_port);
+	data->gc = ofono_gprs_context_create(modem, 0,
+					"atmodem", data->data_port);
+
+	if (data->gprs && data->gc) {
+		ofono_gprs_add_context(data->gprs, data->gc);
+	}
 
 	mw = ofono_message_waiting_create(modem);
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-06-28  4:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-27  6:22 [PATCH 1/2] linktop: reimplemented with minimum features Amit Mendapara
2011-06-27  6:22 ` [PATCH 2/2] udev: changed linktop device strings Amit Mendapara
2011-06-27 15:35   ` Denis Kenzior
2011-06-27 15:34 ` [PATCH 1/2] linktop: reimplemented with minimum features Denis Kenzior
2011-06-28  4:13   ` Amit Mendapara
  -- strict thread matches above, loose matches on Subject: below --
2011-06-20  7:35 [PATCH 1/2] linktop: reimplemented linktop plugin " Amit Mendapara
2011-06-20  7:35 ` [PATCH 2/2] udev: changed linktop device strings Amit Mendapara
2011-06-15  7:13 [PATCH 1/2] linktop: reimplemented linktop plugin based on mbm with minimum features Amit Mendapara
2011-06-15  7:13 ` [PATCH 2/2] udev: changed linktop device strings Amit Mendapara
2011-06-08  9:46 [PATCH 1/2] linktop: reimplemented linktop plugin based on mbm Amit Mendapara
2011-06-08  9:46 ` [PATCH 2/2] udev: changed linktop device strings Amit Mendapara
2011-06-11 14:05   ` Denis Kenzior
2011-04-14 10:13 [PATCH 1/2] linktop: reimplemented linktop plugin based on mbm Amit Mendapara
2011-04-14 10:13 ` [PATCH 2/2] udev: changed linktop device strings Amit Mendapara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox