Skip to contentSkip to conversation

More generic support of Telit xE910 family

PATCH Applied Piotr Haber 2 participants 5 messages Jan 26, 2017 Kbuild

lore
Share & tools
lore
#0 lore raw

cover More generic support of Telit xE910 family

Telit xE910 is a family of modems from 2g (GE910) through 3.5g (HE910, UE910, DE910) to 4g (LE910).
They share a common programming interface.
So move he910 plugin to more generic xe910
and add support for UE910 (i was able to test on it). Also differentiate between variants in terms of voice calling and built-in GPS.

Piotr Haber (2):
plugins: rename he910 to xe910
plugins: Handle HE910 and UE910 variants

 Makefile.am                  |   4 +-
 plugins/udevng.c             |   6 +-
 plugins/{he910.c => xe910.c} | 237 ++++++++++++++++++++++++++++++++-----------
 3 files changed, 183 insertions(+), 64 deletions(-)
 rename plugins/{he910.c => xe910.c} (59%)
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/2 plugins: rename he910 to xe910

In preparation for more generic support
of Telit xE910 family.

---
 Makefile.am                  |  4 +--
 plugins/udevng.c             |  6 ++--
 plugins/{he910.c => xe910.c} | 70 ++++++++++++++++++++++----------------------
 3 files changed, 40 insertions(+), 40 deletions(-)
 rename plugins/{he910.c => xe910.c} (83%)
Makefile.am +2 -2
index f76971ec..6d134739 100644
@@ -491,8 +491,8 @@ builtin_sources += plugins/sim900.c
 builtin_modules += connman
 builtin_sources += plugins/connman.c
 
-builtin_modules += he910
-builtin_sources += plugins/he910.c
+builtin_modules += xe910
+builtin_sources += plugins/xe910.c
 
 builtin_modules += quectel
 builtin_sources += plugins/quectel.c
plugins/udevng.c +3 -3
index 50089129..2f1da62b 100644
@@ -654,7 +654,7 @@ static gboolean setup_telit(struct modem_info *modem)
 	return TRUE;
 }
 
-static gboolean setup_he910(struct modem_info *modem)
+static gboolean setup_xe910(struct modem_info *modem)
 {
 	const char *mdm = NULL, *aux = NULL, *gps = NULL;
 	GSList *list;
@@ -976,7 +976,7 @@ static struct {
 	{ "novatel",	setup_novatel	},
 	{ "nokia",	setup_nokia	},
 	{ "telit",	setup_telit	},
-	{ "he910",	setup_he910	},
+	{ "xe910",	setup_xe910	},
 	{ "simcom",	setup_simcom	},
 	{ "zte",	setup_zte	},
 	{ "icera",	setup_icera	},
@@ -1214,7 +1214,7 @@ static struct {
 	{ "simcom",	"option",	"05c6", "9000"	},
 	{ "telit",	"usbserial",	"1bc7"		},
 	{ "telit",	"option",	"1bc7"		},
-	{ "he910",	"cdc_acm",	"1bc7", "0021"	},
+	{ "xe910",	"cdc_acm",	"1bc7", "0021"	},
 	{ "nokia",	"option",	"0421", "060e"	},
 	{ "nokia",	"option",	"0421", "0623"	},
 	{ "samsung",	"option",	"04e8", "6889"	},
plugins/xe910.c renamed from plugins/he910.c +35 -35

176 lines not on this page · raw message

Signature · 1 line
2.11.0
#2 lore raw

Re: [PATCH 1/2] plugins: rename he910 to xe910

Hi Piotr,

Quoted 9 lines · Piotr Haber

In preparation for more generic support
of Telit xE910 family.

---
 Makefile.am                  |  4 +--
 plugins/udevng.c             |  6 ++--
 plugins/{he910.c => xe910.c} | 70 ++++++++++++++++++++++----------------------
 3 files changed, 40 insertions(+), 40 deletions(-)
 rename plugins/{he910.c => xe910.c} (83%)

Applied, thanks.

Regards,
-Denis

#3 lore raw

PATCH 2/2 plugins: Handle HE910 and UE910 variants

In reply to Piotr Haber

Telit modems HE910 and UE910 share the same USB vendor and device IDs (1bc7:0021) but they are different devices.
HE910 is HSPA Class 14/6 and UE910 is Class 8/6. Both come in voice-enabled variants. HE910 also comes in variants with built-in GPS.

---
 plugins/xe910.c | 167 ++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 143 insertions(+), 24 deletions(-)
plugins/xe910.c +143 -24
index 24fe1ade..9925879a 100644
@@ -62,12 +62,40 @@
 static const char *none_prefix[] = { NULL };
 static const char *qss_prefix[] = { "#QSS:", NULL };
 
+enum modem_model {
+    HE910 = 1,
+    UE910
+};
+
+static struct {
+	enum modem_model model;
+	const char *variant;
+	gboolean has_voice;
+	gboolean has_gps;
+} variants_list[] = {
+    { HE910,	NULL,	FALSE,	FALSE },
+    { HE910,	"G",	TRUE,	TRUE },
+    { HE910,	"GL",	TRUE,	FALSE },
+    { HE910,	"EUR",	TRUE,	FALSE },
+    { HE910,	"NAR",	TRUE,	FALSE },
+    { HE910,	"DG",	FALSE,	TRUE },
+    { HE910,	"EUG",	FALSE,	TRUE },
+    { HE910,	"NAG",	FALSE,	TRUE },
+    { UE910,	NULL,	FALSE,	FALSE },
+    { UE910,	"EUR",	TRUE,	FALSE },
+    { UE910,	"NAR",	TRUE,	FALSE },
+    { }
+};
+
 struct xe910_data {
 	GAtChat *chat;		/* AT chat */
 	GAtChat *modem;		/* Data port */
 	struct ofono_sim *sim;
 	ofono_bool_t have_sim;
 	ofono_bool_t sms_phonebook_added;
+	enum modem_model model;
+	gboolean has_voice;
+	gboolean has_gps;
 };
 
 static void xe910_debug(const char *str, void *user_data)
@@ -201,16 +229,8 @@ static void cfun_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)
 
 	DBG("%p", modem);
 
-	if (!ok) {
-		g_at_chat_unref(data->chat);
-		data->chat = NULL;
-
-		g_at_chat_unref(data->modem);
-		data->modem = NULL;
-
-		ofono_modem_set_powered(modem, FALSE);
-		return;
-	}
+	if (!ok)
+	    return;
 
 	/*
 	 * Switch data carrier detect signal off.
@@ -242,6 +262,97 @@ static void cfun_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)
 			qss_query_cb, modem, NULL);
 }
 
+static gboolean find_model_variant(struct ofono_modem *modem, const char * model_variant)
+{
+    struct xe910_data *data = ofono_modem_get_data(modem);
+    char model[32];
+    char variant[32];
+    gchar ** tokens;
+    int i;
+
+    if(!model_variant || model_variant[0] == '\0')
+	return FALSE;
+
+    DBG("%s", model_variant);
+
+    tokens = g_strsplit(model_variant, "-", 2);
+
+    if(!tokens || !tokens[0] || !tokens[1])
+	return FALSE;
+
+    g_strlcpy(model, tokens[0], sizeof(model));
+    g_strlcpy(variant, tokens[1], sizeof(variant));
+    g_strfreev(tokens);
+
+    if (g_str_equal(model, "HE910"))
+	data->model = HE910;
+    else if (g_str_equal(model, "UE910"))
+	data->model = UE910;
+    else
+	return FALSE;
+
+    DBG("Model: %s", model);
+
+    for (i=0; variants_list[i].model; i++) {
+
+	if (variants_list[i].model != data->model)
+	    continue;
+
+	/* Set model defaults */
+	if (variants_list[i].variant == NULL) {
+	    data->has_voice = variants_list[i].has_voice;
+	    data->has_gps = variants_list[i].has_gps;
+	    continue;
+	}
+
+	/* Specific variant match */
+	if (g_str_equal(variant, variants_list[i].variant)) {
+	    DBG("Variant: %s", variant);
+	    data->has_voice = variants_list[i].has_voice;
+	    data->has_gps = variants_list[i].has_gps;
+	}
+    }
+
+    return TRUE;
+}
+
+static void cfun_gmm_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct xe910_data *data = ofono_modem_get_data(modem);
+	const char * model_variant;
+
+	DBG("%p", modem);
+
+	if (!ok)
+	    goto error;
+
+	/* Get +GMM response */
+	if(!at_util_parse_attr(result, "", &model_variant))
+	    goto error;
+
+	/* Try to find modem model and variant */
+	if(!find_model_variant(modem, model_variant)) {
+	    ofono_info("Unknown xE910 model/variant %s", model_variant);
+	    goto error;
+	}
+
+	/* Set phone functionality */
+	if (g_at_chat_send(data->chat, "AT+CFUN=1", none_prefix,
+				cfun_enable_cb, modem, NULL) > 0)
+	    return;
+
+error:
+	g_at_chat_unref(data->chat);
+	data->chat = NULL;
+
+	g_at_chat_unref(data->modem);
+	data->modem = NULL;
+
+	ofono_modem_set_powered(modem, FALSE);
+	return;
+}
+
 static int xe910_enable(struct ofono_modem *modem)
 {
 	struct xe910_data *data = ofono_modem_get_data(modem);
@@ -268,9 +379,11 @@ static int xe910_enable(struct ofono_modem *modem)
 	g_at_chat_send(data->chat, "ATE0 +CMEE=1", none_prefix,
 				NULL, NULL, NULL);
 
-	/* Set phone functionality */
-	g_at_chat_send(data->chat, "AT+CFUN=1", none_prefix,
-				cfun_enable_cb, modem, NULL);
+
+	/* Get modem model and variant */
+	g_at_chat_send(data->chat, "AT+GMM", NULL,
+				cfun_gmm_cb, modem, NULL);
+
 
 	return -EINPROGRESS;
 }
@@ -319,29 +432,35 @@ static void xe910_pre_sim(struct ofono_modem *modem)
 	ofono_devinfo_create(modem, 0, "atmodem", data->chat);
 	data->sim = ofono_sim_create(modem, OFONO_VENDOR_TELIT, "atmodem",
 					data->chat);
-	ofono_location_reporting_create(modem, 0, "telitmodem", data->chat);
+
+	if (data->has_gps)
+	    ofono_location_reporting_create(modem, 0, "telitmodem", data->chat);
 }
 
 static void xe910_post_online(struct ofono_modem *modem)
 {
 	struct xe910_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_voicecall_create(modem, 0, "atmodem", data->chat);
 	ofono_netreg_create(modem, OFONO_VENDOR_TELIT, "atmodem", data->chat);
-	ofono_ussd_create(modem, 0, "atmodem", data->chat);
-	ofono_call_forwarding_create(modem, 0, "atmodem", data->chat);
-	ofono_call_settings_create(modem, 0, "atmodem", data->chat);
-	ofono_call_meter_create(modem, 0, "atmodem", data->chat);
-	ofono_call_barring_create(modem, 0, "atmodem", data->chat);
-
-	mw = ofono_message_waiting_create(modem);
-	if (mw)
+
+	if(data->has_voice) {
+	    struct ofono_message_waiting *mw;
+
+	    ofono_voicecall_create(modem, 0, "atmodem", data->chat);
+	    ofono_ussd_create(modem, 0, "atmodem", data->chat);
+	    ofono_call_forwarding_create(modem, 0, "atmodem", data->chat);
+	    ofono_call_settings_create(modem, 0, "atmodem", data->chat);
+	    ofono_call_meter_create(modem, 0, "atmodem", data->chat);
+	    ofono_call_barring_create(modem, 0, "atmodem", data->chat);
+
+	    mw = ofono_message_waiting_create(modem);
+	    if (mw)
 		ofono_message_waiting_register(mw);
+	}
 
 	gprs = ofono_gprs_create(modem, OFONO_VENDOR_TELIT, "atmodem",
 					data->chat);
Signature · 1 line
2.11.0
#4 lore raw

Re: [PATCH 2/2] plugins: Handle HE910 and UE910 variants

Hi Piotr,

Quoted 10 lines · Piotr Haber

Telit modems HE910 and UE910 share the same USB vendor and device IDs (1bc7:0021) but they are different devices.
HE910 is HSPA Class 14/6 and UE910 is Class 8/6. Both come in voice-enabled variants. HE910 also comes in variants with built-in GPS.

---
 plugins/xe910.c | 167 ++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 143 insertions(+), 24 deletions(-)

I went ahead and applied a modified version of this patch. Mostly fixing all sorts of coding style issues (spaces being used for indentation, etc)

Please pay attention to our coding style guidelines.

Also, I modified the patch in 2 places:

Quoted 7 lines
plugins/xe910.c +0 -3
@@ -201,16 +229,8 @@ static void cfun_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)
 
 	DBG("%p", modem);
 
-	if (!ok) {
-		g_at_chat_unref(data->chat);
-		data->chat = NULL;

plugins/xe910.c static void cfun_enable_cb(gboolean ok, GAtResult *result, gpointer user_data) · line 234

Quoted 10 lines
plugins/xe910.c +2 -7
-
-		g_at_chat_unref(data->modem);
-		data->modem = NULL;
-
-		ofono_modem_set_powered(modem, FALSE);
-		return;
-	}
+	if (!ok)
+	    return;
 

I squished this change since you want to clean up properly if the CFUN fails.

Quoted 2 lines
plugins/xe910.c +0 -0
 	/*
 	 * Switch data carrier detect signal off.

<snip>

Quoted 25 lines
plugins/xe910.c +24 -0
+static void cfun_gmm_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct xe910_data *data = ofono_modem_get_data(modem);
+	const char * model_variant;
+
+	DBG("%p", modem);
+
+	if (!ok)
+	    goto error;
+
+	/* Get +GMM response */
+	if(!at_util_parse_attr(result, "", &model_variant))
+	    goto error;
 
+	/* Try to find modem model and variant */
+	if(!find_model_variant(modem, model_variant)) {
+	    ofono_info("Unknown xE910 model/variant %s", model_variant);
+	    goto error;
+	}
+
+	/* Set phone functionality */
+	if (g_at_chat_send(data->chat, "AT+CFUN=1", none_prefix,
+				cfun_enable_cb, modem, NULL) > 0)
+	    return;

plugins/xe910.c static void cfun_enable_cb(gboolean ok, GAtResult *result, gpointer user_data) · line 353

Quoted 10 lines
plugins/xe910.c +10 -0
+
+error:
+	g_at_chat_unref(data->chat);
+	data->chat = NULL;
+
+	g_at_chat_unref(data->modem);
+	data->modem = NULL;
+
+	ofono_modem_set_powered(modem, FALSE);
+	return;

I took out this pointless return statement.

plugins/xe910.c static void cfun_enable_cb(gboolean ok, GAtResult *result, gpointer user_data) · line 358

Quoted 5 lines
plugins/xe910.c +2 -0
+}
+
 static int xe910_enable(struct ofono_modem *modem)
 {
 	struct xe910_data *data = ofono_modem_get_data(modem);

Regards,
-Denis