All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] atmodem/gprs: initial Gemalto vendor-specific support
@ 2018-09-23  5:23 Giacinto Cifelli
  2018-09-27 16:03 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: Giacinto Cifelli @ 2018-09-23  5:23 UTC (permalink / raw)
  To: ofono

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

---
 drivers/atmodem/gprs.c | 128 +++++++++++++++++++++++++++++++++++++++--
 1 file changed, 123 insertions(+), 5 deletions(-)

diff --git a/drivers/atmodem/gprs.c b/drivers/atmodem/gprs.c
index fc0d8aa3..84ee5c7d 100644
--- a/drivers/atmodem/gprs.c
+++ b/drivers/atmodem/gprs.c
@@ -672,6 +672,91 @@ static void ublox_ureg_notify(GAtResult *result, gpointer user_data)
 	ofono_gprs_bearer_notify(gprs, bearer);
 }
 
+static void gemalto_ciev_ceer_notify(GAtResult *result, gpointer user_data)
+{
+	struct ofono_gprs *gprs = user_data;
+	const char *report;
+	GAtResultIter iter;
+
+	g_at_result_iter_init(&iter, result);
+
+	if (!g_at_result_iter_next(&iter, "+CIEV: ceer,"))
+		return;
+	/*
+	 * No need to check release cause group
+	 * as we only subscribe to no. 5
+	 */
+	if (!g_at_result_iter_skip_next(&iter))
+		return;
+	if (!g_at_result_iter_next_string(&iter, &report))
+		return;
+
+	/* TODO: Handle more of these? */
+
+	if (g_str_equal(report, "Regular deactivation")) {
+		ofono_gprs_detached_notify(gprs);
+		return;
+	}
+}
+
+static void gemalto_ciev_bearer_notify(GAtResult *result, gpointer user_data)
+{
+	struct ofono_gprs *gprs = user_data;
+	int bearer;
+	GAtResultIter iter;
+
+	g_at_result_iter_init(&iter, result);
+
+	if (!g_at_result_iter_next(&iter, "+CIEV: psinfo,"))
+		return;
+	if (!g_at_result_iter_next_number(&iter, &bearer))
+		return;
+
+	/* Go from Gemalto representation to oFono representation */
+	switch (bearer) {
+	case 0: /* GPRS/EGPRS not available */
+		/* Same as "no bearer"? */
+		bearer = 0;
+		break;
+	case 1: /* GPRS available, ignore this one */
+		return;
+	case 2: /* GPRS attached */
+		bearer = 1;
+		break;
+	case 3: /* EGPRS available, ignore this one */
+		return;
+	case 4: /* EGPRS attached */
+		bearer = 2;
+		break;
+	case 5: /* UMTS available, ignore this one */
+		return;
+	case 6: /* UMTS attached */
+		bearer = 3;
+		break;
+	case 7: /* HSDPA available, ignore this one */
+		return;
+	case 8: /* HSDPA attached */
+		bearer = 5;
+		break;
+	case 9: /* HSDPA/HSUPA available, ignore this one */
+		return;
+	case 10: /* HSDPA/HSUPA attached */
+		bearer = 6;
+		break;
+	/* TODO: Limit these cases to ALS3? */
+	case 16: /* E-UTRA available, ignore this one */
+		return;
+	case 17: /* E-UTRA attached */
+		bearer = 7;
+		break;
+	default: /* Assume that non-parsable values mean "no bearer" */
+		bearer = 0;
+		break;
+	}
+
+	ofono_gprs_bearer_notify(gprs, bearer);
+}
+
 static void cpsb_notify(GAtResult *result, gpointer user_data)
 {
 	struct ofono_gprs *gprs = user_data;
@@ -696,8 +781,13 @@ static void gprs_initialized(struct ofono_gprs *gprs)
 {
 	struct gprs_data *gd = ofono_gprs_get_data(gprs);
 
-	g_at_chat_send(gd->chat, "AT+CGAUTO=0", none_prefix, NULL, NULL,
-								NULL);
+	switch (gd->vendor) {
+	case OFONO_VENDOR_GEMALTO:
+		break;
+	default:
+		g_at_chat_send(gd->chat, "AT+CGAUTO=0", none_prefix, NULL, NULL,
+									NULL);
+	}
 
 	switch (gd->vendor) {
 	case OFONO_VENDOR_MBM:
@@ -710,6 +800,12 @@ static void gprs_initialized(struct ofono_gprs *gprs)
 		g_at_chat_send(gd->chat, "AT+CGEREP=1", none_prefix,
 			NULL, NULL, NULL);
 		break;
+	case OFONO_VENDOR_GEMALTO:
+		g_at_chat_send(gd->chat, "AT+CGEREP=2", NULL,
+					NULL, NULL, NULL);
+		g_at_chat_send(gd->chat, "AT^SIND=\"psinfo\",1", none_prefix,
+			NULL, NULL, NULL);
+		break;
 	default:
 		g_at_chat_send(gd->chat, "AT+CGEREP=2,1", none_prefix,
 			NULL, NULL, NULL);
@@ -744,6 +840,12 @@ static void gprs_initialized(struct ofono_gprs *gprs)
 		g_at_chat_send(gd->chat, "AT#PSNT=1", none_prefix,
 						NULL, NULL, NULL);
 		break;
+	case OFONO_VENDOR_GEMALTO:
+		g_at_chat_register(gd->chat, "+CIEV: psinfo,",
+			gemalto_ciev_bearer_notify, FALSE, gprs, NULL);
+		g_at_chat_register(gd->chat, "+CIEV: ceer,",
+			gemalto_ciev_ceer_notify, FALSE, gprs, NULL);
+		break;
 	default:
 		g_at_chat_register(gd->chat, "+CPSB:", cpsb_notify,
 						FALSE, gprs, NULL);
@@ -815,7 +917,13 @@ retry:
 
 	g_at_result_iter_close_list(&iter);
 
-	if (cgreg1) {
+	if (gd->vendor == OFONO_VENDOR_GEMALTO) {
+		/*
+		 * Gemalto prefers to print as much information as available
+		 * for support purposes
+		 */
+		sprintf(buf, "AT+%s=%d",ind, range[1]);
+	} else if (cgreg1) {
 		sprintf(buf,"AT+%s=1", ind);
 	} else if (cgreg2) {
 		sprintf(buf,"AT+%s=2", ind);
@@ -931,6 +1039,8 @@ static int at_gprs_probe(struct ofono_gprs *gprs,
 {
 	GAtChat *chat = data;
 	struct gprs_data *gd;
+	int autoattach;
+	struct ofono_modem* modem=ofono_gprs_get_modem(gprs);
 
 	gd = g_try_new0(struct gprs_data, 1);
 	if (gd == NULL)
@@ -941,8 +1051,16 @@ static int at_gprs_probe(struct ofono_gprs *gprs,
 
 	ofono_gprs_set_data(gprs, gd);
 
-	g_at_chat_send(gd->chat, "AT+CGDCONT=?", cgdcont_prefix,
-			at_cgdcont_test_cb, gprs, NULL);
+	if (gd->vendor == OFONO_VENDOR_GEMALTO) {
+		autoattach=ofono_modem_get_integer(modem, "GemaltoAutoAttach");
+		/* set autoattach */
+		gd->auto_attach = (autoattach == 1);
+		/* skip the cgdcont scanning: set manually */
+		test_and_set_regstatus(gprs);
+	} else {
+		g_at_chat_send(gd->chat, "AT+CGDCONT=?", cgdcont_prefix,
+						at_cgdcont_test_cb, gprs, NULL);
+	}
 
 	return 0;
 }
-- 
2.17.1


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

* Re: [PATCH] atmodem/gprs: initial Gemalto vendor-specific support
  2018-09-23  5:23 [PATCH] atmodem/gprs: initial Gemalto vendor-specific support Giacinto Cifelli
@ 2018-09-27 16:03 ` Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2018-09-27 16:03 UTC (permalink / raw)
  To: ofono

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

Hi Giacinto,

On 09/23/2018 12:23 AM, Giacinto Cifelli wrote:
> ---
>   drivers/atmodem/gprs.c | 128 +++++++++++++++++++++++++++++++++++++++--
>   1 file changed, 123 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/atmodem/gprs.c b/drivers/atmodem/gprs.c
> index fc0d8aa3..84ee5c7d 100644
> --- a/drivers/atmodem/gprs.c
> +++ b/drivers/atmodem/gprs.c
> @@ -672,6 +672,91 @@ static void ublox_ureg_notify(GAtResult *result, gpointer user_data)
>   	ofono_gprs_bearer_notify(gprs, bearer);
>   }
>   
> +static void gemalto_ciev_ceer_notify(GAtResult *result, gpointer user_data)
> +{
> +	struct ofono_gprs *gprs = user_data;
> +	const char *report;
> +	GAtResultIter iter;
> +
> +	g_at_result_iter_init(&iter, result);
> +
> +	if (!g_at_result_iter_next(&iter, "+CIEV: ceer,"))
> +		return;
> +	/*
> +	 * No need to check release cause group
> +	 * as we only subscribe to no. 5
> +	 */
> +	if (!g_at_result_iter_skip_next(&iter))
> +		return;
> +	if (!g_at_result_iter_next_string(&iter, &report))
> +		return;
> +
> +	/* TODO: Handle more of these? */
> +
> +	if (g_str_equal(report, "Regular deactivation")) {
> +		ofono_gprs_detached_notify(gprs);
> +		return;
> +	}
> +}
> +
> +static void gemalto_ciev_bearer_notify(GAtResult *result, gpointer user_data)
> +{
> +	struct ofono_gprs *gprs = user_data;
> +	int bearer;
> +	GAtResultIter iter;
> +
> +	g_at_result_iter_init(&iter, result);
> +
> +	if (!g_at_result_iter_next(&iter, "+CIEV: psinfo,"))
> +		return;
> +	if (!g_at_result_iter_next_number(&iter, &bearer))
> +		return;
> +
> +	/* Go from Gemalto representation to oFono representation */
> +	switch (bearer) {
> +	case 0: /* GPRS/EGPRS not available */
> +		/* Same as "no bearer"? */
> +		bearer = 0;
> +		break;
> +	case 1: /* GPRS available, ignore this one */
> +		return;
> +	case 2: /* GPRS attached */
> +		bearer = 1;
> +		break;
> +	case 3: /* EGPRS available, ignore this one */
> +		return;
> +	case 4: /* EGPRS attached */
> +		bearer = 2;
> +		break;
> +	case 5: /* UMTS available, ignore this one */
> +		return;
> +	case 6: /* UMTS attached */
> +		bearer = 3;
> +		break;
> +	case 7: /* HSDPA available, ignore this one */
> +		return;
> +	case 8: /* HSDPA attached */
> +		bearer = 5;
> +		break;
> +	case 9: /* HSDPA/HSUPA available, ignore this one */
> +		return;
> +	case 10: /* HSDPA/HSUPA attached */
> +		bearer = 6;
> +		break;
> +	/* TODO: Limit these cases to ALS3? */
> +	case 16: /* E-UTRA available, ignore this one */
> +		return;
> +	case 17: /* E-UTRA attached */
> +		bearer = 7;
> +		break;
> +	default: /* Assume that non-parsable values mean "no bearer" */
> +		bearer = 0;
> +		break;
> +	}
> +
> +	ofono_gprs_bearer_notify(gprs, bearer);
> +}
> +
>   static void cpsb_notify(GAtResult *result, gpointer user_data)
>   {
>   	struct ofono_gprs *gprs = user_data;
> @@ -696,8 +781,13 @@ static void gprs_initialized(struct ofono_gprs *gprs)
>   {
>   	struct gprs_data *gd = ofono_gprs_get_data(gprs);
>   
> -	g_at_chat_send(gd->chat, "AT+CGAUTO=0", none_prefix, NULL, NULL,
> -								NULL);
> +	switch (gd->vendor) {
> +	case OFONO_VENDOR_GEMALTO:
> +		break;
> +	default:
> +		g_at_chat_send(gd->chat, "AT+CGAUTO=0", none_prefix, NULL, NULL,
> +									NULL);
> +	}
>   
>   	switch (gd->vendor) {
>   	case OFONO_VENDOR_MBM:
> @@ -710,6 +800,12 @@ static void gprs_initialized(struct ofono_gprs *gprs)
>   		g_at_chat_send(gd->chat, "AT+CGEREP=1", none_prefix,
>   			NULL, NULL, NULL);
>   		break;
> +	case OFONO_VENDOR_GEMALTO:
> +		g_at_chat_send(gd->chat, "AT+CGEREP=2", NULL,
> +					NULL, NULL, NULL);
> +		g_at_chat_send(gd->chat, "AT^SIND=\"psinfo\",1", none_prefix,
> +			NULL, NULL, NULL);
> +		break;
>   	default:
>   		g_at_chat_send(gd->chat, "AT+CGEREP=2,1", none_prefix,
>   			NULL, NULL, NULL);
> @@ -744,6 +840,12 @@ static void gprs_initialized(struct ofono_gprs *gprs)
>   		g_at_chat_send(gd->chat, "AT#PSNT=1", none_prefix,
>   						NULL, NULL, NULL);
>   		break;
> +	case OFONO_VENDOR_GEMALTO:
> +		g_at_chat_register(gd->chat, "+CIEV: psinfo,",
> +			gemalto_ciev_bearer_notify, FALSE, gprs, NULL);
> +		g_at_chat_register(gd->chat, "+CIEV: ceer,",
> +			gemalto_ciev_ceer_notify, FALSE, gprs, NULL);
> +		break;
>   	default:
>   		g_at_chat_register(gd->chat, "+CPSB:", cpsb_notify,
>   						FALSE, gprs, NULL);
> @@ -815,7 +917,13 @@ retry:
>   
>   	g_at_result_iter_close_list(&iter);
>   
> -	if (cgreg1) {
> +	if (gd->vendor == OFONO_VENDOR_GEMALTO) {
> +		/*
> +		 * Gemalto prefers to print as much information as available
> +		 * for support purposes
> +		 */
> +		sprintf(buf, "AT+%s=%d",ind, range[1]);
> +	} else if (cgreg1) {

Given that +CGREG value of 3 is standard, you might as well have that as 
preferred.  I'm not sure you really want to enable n=4 or n=5 though.

>   		sprintf(buf,"AT+%s=1", ind);
>   	} else if (cgreg2) {
>   		sprintf(buf,"AT+%s=2", ind);

This looks fishy and not against upstream.  Why are you messing with the 
preference order?  You now just changed +CGREG=1 as preferred even when 
+CGREG=2 is supported.  That is wrong.

> @@ -931,6 +1039,8 @@ static int at_gprs_probe(struct ofono_gprs *gprs,
>   {
>   	GAtChat *chat = data;
>   	struct gprs_data *gd;
> +	int autoattach;
> +	struct ofono_modem* modem=ofono_gprs_get_modem(gprs);
>   
>   	gd = g_try_new0(struct gprs_data, 1);
>   	if (gd == NULL)
> @@ -941,8 +1051,16 @@ static int at_gprs_probe(struct ofono_gprs *gprs,
>   
>   	ofono_gprs_set_data(gprs, gd);
>   
> -	g_at_chat_send(gd->chat, "AT+CGDCONT=?", cgdcont_prefix,
> -			at_cgdcont_test_cb, gprs, NULL);
> +	if (gd->vendor == OFONO_VENDOR_GEMALTO) {
> +		autoattach=ofono_modem_get_integer(modem, "GemaltoAutoAttach");
> +		/* set autoattach */
> +		gd->auto_attach = (autoattach == 1);
> +		/* skip the cgdcont scanning: set manually */
> +		test_and_set_regstatus(gprs);
> +	} else {
> +		g_at_chat_send(gd->chat, "AT+CGDCONT=?", cgdcont_prefix,
> +						at_cgdcont_test_cb, gprs, NULL);
> +	}
>   
>   	return 0;
>   }
> 

This looks like it depends on another patch.  If some patch depends on 
another, then please send both as a series.  Otherwise I have no idea 
what is going on and can't apply these anyway.

Regards,
-Denis

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

end of thread, other threads:[~2018-09-27 16:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-23  5:23 [PATCH] atmodem/gprs: initial Gemalto vendor-specific support Giacinto Cifelli
2018-09-27 16:03 ` 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.