All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] gemalto: add PLS8 support
@ 2017-08-30 16:30 Sebastian Arnd
  2017-08-30 16:30 ` [PATCH v2 2/3] " Sebastian Arnd
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Sebastian Arnd @ 2017-08-30 16:30 UTC (permalink / raw)
  To: ofono

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

diff --git a/plugins/gemalto.c b/plugins/gemalto.c
index 011713e..dcd8f14 100644
--- a/plugins/gemalto.c
+++ b/plugins/gemalto.c
@@ -67,6 +67,7 @@ struct gemalto_data {
 	GAtChat *mdm;
 	struct ofono_sim *sim;
 	gboolean have_sim;
+	gboolean have_net;
 	struct at_util_sim_state_query *sim_state_query;
 	struct gemalto_hardware_monitor *hm;
 };
@@ -101,18 +102,31 @@ static void gemalto_debug(const char *str, void *user_data)
 	ofono_info("%s%s", prefix, str);
 }
 
-static GAtChat *open_device(const char *device)
+static GAtChat *open_device(const char *device, char *device_debug_name)
 {
 	GAtSyntax *syntax;
 	GIOChannel *channel;
 	GAtChat *chat;
+	GHashTable *options;
 
 	DBG("Opening device %s", device);
 
-	channel = g_at_tty_open(device, NULL);
+	options = g_hash_table_new(g_str_hash, g_str_equal);
+	if (options == NULL)
+		return NULL;
+	/*
+	 * The modem does not answer when the "Baud" attibute is missing
+	 * The supplied value is not making any change. But the "Baud"
+	 * paramenter is needed.
+	 */
+	g_hash_table_insert(options, "Baud", "115200");
+
+	channel = g_at_tty_open(device, options);
+	g_hash_table_destroy(options);
 	if (channel == NULL)
 		return NULL;
 
+
 	syntax = g_at_syntax_new_gsm_permissive();
 	chat = g_at_chat_new(channel, syntax);
 	g_at_syntax_unref(syntax);
@@ -121,6 +135,9 @@ static GAtChat *open_device(const char *device)
 	if (chat == NULL)
 		return NULL;
 
+	if (getenv("OFONO_AT_DEBUG"))
+		g_at_chat_set_debug(chat, gemalto_debug, device_debug_name);
+
 	return chat;
 }
 
@@ -299,47 +316,54 @@ static int gemalto_hardware_monitor_enable(struct ofono_modem *modem)
 	return 0;
 }
 
+
 static int gemalto_enable(struct ofono_modem *modem)
 {
 	struct gemalto_data *data = ofono_modem_get_data(modem);
-	const char *app, *mdm;
+	const char *app, *mdm, *net;
 
 	DBG("%p", modem);
 
 	app = ofono_modem_get_string(modem, "Application");
 	mdm = ofono_modem_get_string(modem, "Modem");
+	net = ofono_modem_get_string(modem, "NetworkInterface");
 
-	if (app == NULL || mdm == NULL)
+	if (net != NULL)
+		data->have_net = TRUE;
+	else
+		data->have_net = FALSE;
+
+	if (app == NULL || (mdm == NULL && !data->have_net))
 		return -EINVAL;
 
 	/* Open devices */
-	data->app = open_device(app);
+	data->app = open_device(app, "App");
 	if (data->app == NULL)
 		return -EINVAL;
 
-	data->mdm = open_device(mdm);
-	if (data->mdm == NULL) {
-		g_at_chat_unref(data->app);
-		data->app = NULL;
-		return -EINVAL;
-	}
-
-	if (getenv("OFONO_AT_DEBUG")) {
-		g_at_chat_set_debug(data->app, gemalto_debug, "App");
-		g_at_chat_set_debug(data->mdm, gemalto_debug, "Mdm");
+	/* Mdm device is only requiered when there is no net interface */
+	if (!data->have_net) {
+		data->mdm = open_device(mdm, "Mdm");
+		if (data->mdm == NULL) {
+			g_at_chat_unref(data->app);
+			data->app = NULL;
+			return -EINVAL;
+		}
+		g_at_chat_send(data->mdm, "ATE0", none_prefix,
+						NULL, NULL, NULL);
+		g_at_chat_send(data->mdm, "AT&C0", none_prefix,
+						NULL, NULL, NULL);
 	}
 
-	g_at_chat_send(data->mdm, "ATE0", none_prefix, NULL, NULL, NULL);
-	g_at_chat_send(data->app, "ATE0 +CMEE=1", none_prefix,
-			NULL, NULL, NULL);
-	g_at_chat_send(data->mdm, "AT&C0", none_prefix, NULL, NULL, NULL);
+	g_at_chat_send(data->app, "ATE0", none_prefix, NULL, NULL, NULL);
+	g_at_chat_send(data->app, "AT+CMEE=1", none_prefix, NULL, NULL, NULL);
 	g_at_chat_send(data->app, "AT&C0", none_prefix, NULL, NULL, NULL);
-
 	g_at_chat_send(data->app, "AT+CFUN=4", none_prefix,
-			cfun_enable, modem, NULL);
+						cfun_enable, modem, NULL);
 
 	gemalto_hardware_monitor_enable(modem);
 
+
 	return -EINPROGRESS;
 }
 
@@ -402,7 +426,8 @@ static void gemalto_set_online(struct ofono_modem *modem, ofono_bool_t online,
 
 	DBG("modem %p %s", modem, online ? "online" : "offline");
 
-	if (g_at_chat_send(data->app, command, NULL, set_online_cb, cbd, g_free))
+	if (g_at_chat_send(data->app, command, NULL,
+					set_online_cb, cbd, g_free))
 		return;
 
 	CALLBACK_WITH_FAILURE(cb, cbd->data);
@@ -419,7 +444,8 @@ static void gemalto_pre_sim(struct ofono_modem *modem)
 
 	ofono_devinfo_create(modem, 0, "atmodem", data->app);
 	ofono_location_reporting_create(modem, 0, "gemaltomodem", data->app);
-	sim = ofono_sim_create(modem, 0, "atmodem", data->app);
+	sim = ofono_sim_create(modem, OFONO_VENDOR_CINTERION,
+							"atmodem", data->app);
 
 	if (sim && data->have_sim == TRUE)
 		ofono_sim_inserted_notify(sim, TRUE);
@@ -438,7 +464,12 @@ static void gemalto_post_sim(struct ofono_modem *modem)
 	ofono_sms_create(modem, OFONO_VENDOR_CINTERION, "atmodem", data->app);
 
 	gprs = ofono_gprs_create(modem, 0, "atmodem", data->app);
-	gc = ofono_gprs_context_create(modem, 0, "atmodem", data->mdm);
+
+	if (data->have_net)
+		gc = ofono_gprs_context_create(modem, 0,
+						"gemaltowwanmodem", data->app);
+	else
+		gc = ofono_gprs_context_create(modem, 0, "atmodem", data->mdm);
 
 	if (gprs && gc)
 		ofono_gprs_add_context(gprs, gc);
@@ -450,7 +481,8 @@ static void gemalto_post_online(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
-	ofono_netreg_create(modem, OFONO_VENDOR_CINTERION, "atmodem", data->app);
+	ofono_netreg_create(modem, OFONO_VENDOR_CINTERION,
+							"atmodem", data->app);
 }
 
 static struct ofono_modem_driver gemalto_driver = {
diff --git a/plugins/udevng.c b/plugins/udevng.c
index aa28bcb..68c8386 100644
--- a/plugins/udevng.c
+++ b/plugins/udevng.c
@@ -1080,13 +1080,24 @@ static gboolean setup_gemalto(struct modem_info* modem)
 				net = info->devnode;
 			else if (g_strcmp0(info->subsystem, "usbmisc") == 0)
 				qmi = info->devnode;
+		} else if (g_strcmp0(info->interface, "2/2/1") == 0) {
+			if (g_strcmp0(info->number, "00") == 0)
+				mdm = info->devnode;
+			else if (g_strcmp0(info->number, "02") == 0)
+				app = info->devnode;
+			else if (g_strcmp0(info->number, "04") == 0)
+				gps = info->devnode;
+		} else if (g_strcmp0(info->interface, "2/6/0") == 0 &&
+			  g_strcmp0(info->number, "0a") == 0) {
+				net = info->devnode;
 		}
+
 	}
 
 	DBG("application=%s gps=%s modem=%s network=%s qmi=%s",
 			app, gps, mdm, net, qmi);
 
-	if (app == NULL || mdm == NULL)
+	if (app == NULL || (mdm == NULL && net == NULL))
 		return FALSE;
 
 	ofono_modem_set_string(modem->modem, "Application", app);
@@ -1499,6 +1510,8 @@ static struct {
 	{ "gemalto",	"option",	"1e2d",	"0053"	},
 	{ "gemalto",	"cdc_wdm",	"1e2d",	"0053"	},
 	{ "gemalto",	"qmi_wwan",	"1e2d",	"0053"	},
+	{ "gemalto",	"cdc_acm",	"1e2d",	"0061"	},
+	{ "gemalto",	"cdc_ether",	"1e2d",	"0061"	},
 	{ "telit",	"cdc_ncm",	"1bc7", "0036"	},
 	{ "telit",	"cdc_acm",	"1bc7", "0036"	},
 	{ }
-- 
2.1.4


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

end of thread, other threads:[~2017-09-04 13:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-30 16:30 [PATCH v2 1/3] gemalto: add PLS8 support Sebastian Arnd
2017-08-30 16:30 ` [PATCH v2 2/3] " Sebastian Arnd
2017-08-30 19:22   ` Denis Kenzior
2017-09-04 13:28     ` Reinhard Speyerer
2017-08-30 16:30 ` [PATCH v2 3/3] " Sebastian Arnd
2017-08-30 19:05   ` Denis Kenzior
2017-08-30 18:54 ` [PATCH v2 1/3] " Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.