All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 6/8] gprs: data bearer for telit with PSNT
@ 2012-08-13 13:23 Christopher Vogl
  2012-08-13 14:48 ` Denis Kenzior
  0 siblings, 1 reply; 6+ messages in thread
From: Christopher Vogl @ 2012-08-13 13:23 UTC (permalink / raw)
  To: ofono

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

From: August Mayer <august.mayer@hale.at>

Telit neither supports '+CPSB' nor reports the data bearer through
'+CGREG'. It has its own +PSNT command.
---
 drivers/atmodem/gprs.c |   76 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 76 insertions(+), 0 deletions(-)

diff --git a/drivers/atmodem/gprs.c b/drivers/atmodem/gprs.c
index f87548e..ffb8dfe 100644
--- a/drivers/atmodem/gprs.c
+++ b/drivers/atmodem/gprs.c
@@ -44,6 +44,7 @@
 
 static const char *cgreg_prefix[] = { "+CGREG:", NULL };
 static const char *cgdcont_prefix[] = { "+CGDCONT:", NULL };
+static const char *psnt_prefix[] = { "#PSNT:", NULL };
 static const char *none_prefix[] = { NULL };
 
 struct gprs_data {
@@ -247,6 +248,73 @@ static void huawei_mode_notify(GAtResult *result, gpointer user_data)
 	ofono_gprs_bearer_notify(gprs, bearer);
 }
 
+static gint psnt_to_bearer(gint network_type)
+{
+	gint bearer;
+
+	switch (network_type) {
+	case 0:
+		bearer = 1;	/* GPRS */
+		break;
+	case 1:
+		bearer = 2;	/* EDGE */
+		break;
+	case 2:
+		bearer = 3;	/* UMTS */
+		break;
+	case 3:
+		bearer = 5;	/* HSDPA */
+		break;
+	default:
+		bearer = 0;
+		break;
+	}
+
+	return bearer;
+}
+
+static void at_psnt_test_cb(gboolean ok, GAtResult *result,
+				gpointer user_data)
+{
+	struct ofono_gprs *gprs = user_data;
+	GAtResultIter iter;
+	gint nt, bearer;
+
+	g_at_result_iter_init(&iter, result);
+
+	if (!g_at_result_iter_next(&iter, "#PSNT:"))
+		return;
+
+	if (!g_at_result_iter_next_number(&iter, NULL))
+		return;
+
+	if (!g_at_result_iter_next_number(&iter, &nt))
+		return;
+
+	bearer = psnt_to_bearer(nt);
+
+	ofono_gprs_bearer_notify(gprs, bearer);
+}
+
+static void telit_mode_notify(GAtResult *result, gpointer user_data)
+{
+	struct ofono_gprs *gprs = user_data;
+	GAtResultIter iter;
+	gint nt, bearer;
+
+	g_at_result_iter_init(&iter, result);
+
+	if (!g_at_result_iter_next(&iter, "#PSNT:"))
+		return;
+
+	if (!g_at_result_iter_next_number(&iter, &nt))
+		return;
+
+	bearer = psnt_to_bearer(nt);
+
+	ofono_gprs_bearer_notify(gprs, bearer);
+}
+
 static void cpsb_notify(GAtResult *result, gpointer user_data)
 {
 	struct ofono_gprs *gprs = user_data;
@@ -281,6 +349,14 @@ static void gprs_initialized(gboolean ok, GAtResult *result, gpointer user_data)
 		g_at_chat_register(gd->chat, "^MODE:", huawei_mode_notify,
 						FALSE, gprs, NULL);
 		break;
+	case OFONO_VENDOR_TELIT:
+		g_at_chat_register(gd->chat, "#PSNT:", telit_mode_notify,
+						FALSE, gprs, NULL);
+		g_at_chat_send(gd->chat, "AT#PSNT=1", none_prefix,
+						NULL, NULL, NULL);
+		g_at_chat_send(gd->chat, "AT#PSNT?", psnt_prefix,
+			at_psnt_test_cb, gprs, NULL);
+		break;
 	default:
 		g_at_chat_register(gd->chat, "+CPSB:", cpsb_notify,
 						FALSE, gprs, NULL);
-- 
1.7.7.6


--
Scanned by MailScanner.


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

* Re: [PATCH 6/8] gprs: data bearer for telit with PSNT
  2012-08-13 13:23 [PATCH 6/8] gprs: data bearer for telit with PSNT Christopher Vogl
@ 2012-08-13 14:48 ` Denis Kenzior
  2012-08-14 15:39   ` Christopher Vogl
  0 siblings, 1 reply; 6+ messages in thread
From: Denis Kenzior @ 2012-08-13 14:48 UTC (permalink / raw)
  To: ofono

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

Hi Christopher,

On 08/13/2012 08:23 AM, Christopher Vogl wrote:
> From: August Mayer<august.mayer@hale.at>
>
> Telit neither supports '+CPSB' nor reports the data bearer through
> '+CGREG'. It has its own +PSNT command.
> ---
>   drivers/atmodem/gprs.c |   76 ++++++++++++++++++++++++++++++++++++++++++++++++
>   1 files changed, 76 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/atmodem/gprs.c b/drivers/atmodem/gprs.c
> index f87548e..ffb8dfe 100644
> --- a/drivers/atmodem/gprs.c
> +++ b/drivers/atmodem/gprs.c
> @@ -44,6 +44,7 @@
>
>   static const char *cgreg_prefix[] = { "+CGREG:", NULL };
>   static const char *cgdcont_prefix[] = { "+CGDCONT:", NULL };
> +static const char *psnt_prefix[] = { "#PSNT:", NULL };
>   static const char *none_prefix[] = { NULL };
>
>   struct gprs_data {
> @@ -247,6 +248,73 @@ static void huawei_mode_notify(GAtResult *result, gpointer user_data)
>   	ofono_gprs_bearer_notify(gprs, bearer);
>   }
>
> +static gint psnt_to_bearer(gint network_type)
> +{
> +	gint bearer;
> +
> +	switch (network_type) {
> +	case 0:
> +		bearer = 1;	/* GPRS */
> +		break;
> +	case 1:
> +		bearer = 2;	/* EDGE */
> +		break;
> +	case 2:
> +		bearer = 3;	/* UMTS */
> +		break;
> +	case 3:
> +		bearer = 5;	/* HSDPA */
> +		break;
> +	default:
> +		bearer = 0;
> +		break;
> +	}
> +
> +	return bearer;
> +}
> +
> +static void at_psnt_test_cb(gboolean ok, GAtResult *result,
> +				gpointer user_data)

Just a minor nitpick, but we usually call this '_query'.

> +{
> +	struct ofono_gprs *gprs = user_data;
> +	GAtResultIter iter;
> +	gint nt, bearer;
> +
> +	g_at_result_iter_init(&iter, result);
> +
> +	if (!g_at_result_iter_next(&iter, "#PSNT:"))
> +		return;
> +
> +	if (!g_at_result_iter_next_number(&iter, NULL))
> +		return;
> +
> +	if (!g_at_result_iter_next_number(&iter,&nt))
> +		return;
> +
> +	bearer = psnt_to_bearer(nt);
> +
> +	ofono_gprs_bearer_notify(gprs, bearer);
> +}
> +
> +static void telit_mode_notify(GAtResult *result, gpointer user_data)
> +{
> +	struct ofono_gprs *gprs = user_data;
> +	GAtResultIter iter;
> +	gint nt, bearer;
> +
> +	g_at_result_iter_init(&iter, result);
> +
> +	if (!g_at_result_iter_next(&iter, "#PSNT:"))
> +		return;
> +
> +	if (!g_at_result_iter_next_number(&iter,&nt))
> +		return;
> +
> +	bearer = psnt_to_bearer(nt);
> +
> +	ofono_gprs_bearer_notify(gprs, bearer);
> +}
> +
>   static void cpsb_notify(GAtResult *result, gpointer user_data)
>   {
>   	struct ofono_gprs *gprs = user_data;
> @@ -281,6 +349,14 @@ static void gprs_initialized(gboolean ok, GAtResult *result, gpointer user_data)
>   		g_at_chat_register(gd->chat, "^MODE:", huawei_mode_notify,
>   						FALSE, gprs, NULL);
>   		break;
> +	case OFONO_VENDOR_TELIT:
> +		g_at_chat_register(gd->chat, "#PSNT:", telit_mode_notify,
> +						FALSE, gprs, NULL);
> +		g_at_chat_send(gd->chat, "AT#PSNT=1", none_prefix,
> +						NULL, NULL, NULL);
> +		g_at_chat_send(gd->chat, "AT#PSNT?", psnt_prefix,
> +			at_psnt_test_cb, gprs, NULL);

Do you really need to query this?  In theory if we are turning off 
auto-attach, we should never be in a state where the bearer should be 
queried.

> +		break;
>   	default:
>   		g_at_chat_register(gd->chat, "+CPSB:", cpsb_notify,
>   						FALSE, gprs, NULL);

Regards,
-Denis

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

* Re: [PATCH 6/8] gprs: data bearer for telit with PSNT
  2012-08-14 15:39   ` Christopher Vogl
@ 2012-08-14  6:53     ` Denis Kenzior
  2012-08-16  8:11       ` [PATCH] " Christopher Vogl
  0 siblings, 1 reply; 6+ messages in thread
From: Denis Kenzior @ 2012-08-14  6:53 UTC (permalink / raw)
  To: ofono

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

Hi Christopher,

>> Do you really need to query this? In theory if we are turning off
>> auto-attach, we should never be in a state where the bearer should be
>> queried.
> Once '#PSNT=1' is sent, the modem emits #PSNT URCs even just after
> enabling the modem (e.g. after changing the SIM or setting the modem
> online again).

By the way, the gprs atom is meant to be put into the post_sim phase now.

> So if the value does not change incidentally in gprs phase, the modem
> will not send an URC. That's why I added the query. Is this ok in this
> case?

I still don't see how it can not change.  If you go offline you should 
be detached and only attaching once the gprs atom tells you to.  I 
presume the PSNT will change during / after the attach procedure 
completes, not before.  That means just the URC is enough.  Same with 
sim change, etc.

Lets get a version of this patch upstream without the query.  If you can 
show that we still need to query then I have no problems pushing that 
afterwards as well.

Regards,
-Denis

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

* Re: [PATCH 6/8] gprs: data bearer for telit with PSNT
  2012-08-13 14:48 ` Denis Kenzior
@ 2012-08-14 15:39   ` Christopher Vogl
  2012-08-14  6:53     ` Denis Kenzior
  0 siblings, 1 reply; 6+ messages in thread
From: Christopher Vogl @ 2012-08-14 15:39 UTC (permalink / raw)
  To: ofono

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

Hi Denis,

On 13/08/12 16:48, Denis Kenzior wrote:
> Hi Christopher,
>
> On 08/13/2012 08:23 AM, Christopher Vogl wrote:
>> From: August Mayer<august.mayer@hale.at>
>>
>> Telit neither supports '+CPSB' nor reports the data bearer through
>> '+CGREG'. It has its own +PSNT command.
>> ---
>>   drivers/atmodem/gprs.c |   76 
>> ++++++++++++++++++++++++++++++++++++++++++++++++
>>   1 files changed, 76 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/atmodem/gprs.c b/drivers/atmodem/gprs.c
>> index f87548e..ffb8dfe 100644
>> --- a/drivers/atmodem/gprs.c
>> +++ b/drivers/atmodem/gprs.c
>> @@ -44,6 +44,7 @@
>>
>>   static const char *cgreg_prefix[] = { "+CGREG:", NULL };
>>   static const char *cgdcont_prefix[] = { "+CGDCONT:", NULL };
>> +static const char *psnt_prefix[] = { "#PSNT:", NULL };
>>   static const char *none_prefix[] = { NULL };
>>
>>   struct gprs_data {
>> @@ -247,6 +248,73 @@ static void huawei_mode_notify(GAtResult 
>> *result, gpointer user_data)
>>       ofono_gprs_bearer_notify(gprs, bearer);
>>   }
>>
>> +static gint psnt_to_bearer(gint network_type)
>> +{
>> +    gint bearer;
>> +
>> +    switch (network_type) {
>> +    case 0:
>> +        bearer = 1;    /* GPRS */
>> +        break;
>> +    case 1:
>> +        bearer = 2;    /* EDGE */
>> +        break;
>> +    case 2:
>> +        bearer = 3;    /* UMTS */
>> +        break;
>> +    case 3:
>> +        bearer = 5;    /* HSDPA */
>> +        break;
>> +    default:
>> +        bearer = 0;
>> +        break;
>> +    }
>> +
>> +    return bearer;
>> +}
>> +
>> +static void at_psnt_test_cb(gboolean ok, GAtResult *result,
>> +                gpointer user_data)
>
> Just a minor nitpick, but we usually call this '_query'.
>
>> +{
>> +    struct ofono_gprs *gprs = user_data;
>> +    GAtResultIter iter;
>> +    gint nt, bearer;
>> +
>> +    g_at_result_iter_init(&iter, result);
>> +
>> +    if (!g_at_result_iter_next(&iter, "#PSNT:"))
>> +        return;
>> +
>> +    if (!g_at_result_iter_next_number(&iter, NULL))
>> +        return;
>> +
>> +    if (!g_at_result_iter_next_number(&iter,&nt))
>> +        return;
>> +
>> +    bearer = psnt_to_bearer(nt);
>> +
>> +    ofono_gprs_bearer_notify(gprs, bearer);
>> +}
>> +
>> +static void telit_mode_notify(GAtResult *result, gpointer user_data)
>> +{
>> +    struct ofono_gprs *gprs = user_data;
>> +    GAtResultIter iter;
>> +    gint nt, bearer;
>> +
>> +    g_at_result_iter_init(&iter, result);
>> +
>> +    if (!g_at_result_iter_next(&iter, "#PSNT:"))
>> +        return;
>> +
>> +    if (!g_at_result_iter_next_number(&iter,&nt))
>> +        return;
>> +
>> +    bearer = psnt_to_bearer(nt);
>> +
>> +    ofono_gprs_bearer_notify(gprs, bearer);
>> +}
>> +
>>   static void cpsb_notify(GAtResult *result, gpointer user_data)
>>   {
>>       struct ofono_gprs *gprs = user_data;
>> @@ -281,6 +349,14 @@ static void gprs_initialized(gboolean ok, 
>> GAtResult *result, gpointer user_data)
>>           g_at_chat_register(gd->chat, "^MODE:", huawei_mode_notify,
>>                           FALSE, gprs, NULL);
>>           break;
>> +    case OFONO_VENDOR_TELIT:
>> +        g_at_chat_register(gd->chat, "#PSNT:", telit_mode_notify,
>> +                        FALSE, gprs, NULL);
>> +        g_at_chat_send(gd->chat, "AT#PSNT=1", none_prefix,
>> +                        NULL, NULL, NULL);
>> +        g_at_chat_send(gd->chat, "AT#PSNT?", psnt_prefix,
>> +            at_psnt_test_cb, gprs, NULL);
>
> Do you really need to query this?  In theory if we are turning off 
> auto-attach, we should never be in a state where the bearer should be 
> queried.
Once '#PSNT=1' is sent, the modem emits #PSNT URCs even just after 
enabling the modem (e.g. after changing the SIM or setting the modem 
online again).
So if the value does not change incidentally in gprs phase, the modem 
will not send an URC. That's why I added the query. Is this ok in this case?

>
>> +        break;
>>       default:
>>           g_at_chat_register(gd->chat, "+CPSB:", cpsb_notify,
>>                           FALSE, gprs, NULL);
>
>

Regards,
Christopher

--
Scanned by MailScanner.


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

* Re: [PATCH] gprs: data bearer for telit with PSNT
  2012-08-16  8:11       ` [PATCH] " Christopher Vogl
@ 2012-08-16  6:12         ` Denis Kenzior
  0 siblings, 0 replies; 6+ messages in thread
From: Denis Kenzior @ 2012-08-16  6:12 UTC (permalink / raw)
  To: ofono

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

Hi Christopher / August,

On 08/16/2012 03:11 AM, Christopher Vogl wrote:
> From: August Mayer<august.mayer@hale.at>
>
> Telit neither supports '+CPSB' nor reports the data bearer through
> '+CGREG'. It has its own +PSNT command.
> ---
>   drivers/atmodem/gprs.c |   40 ++++++++++++++++++++++++++++++++++++++++
>   1 files changed, 40 insertions(+), 0 deletions(-)
>

Patch has been applied, however I had to manually fix two trailing 
whitespace violations:

Applying: gprs: data bearer for telit with PSNT
/home/denkenz/ofono-master/.git/rebase-apply/patch:44: trailing whitespace.
	
/home/denkenz/ofono-master/.git/rebase-apply/patch:46: trailing whitespace.
}
fatal: 2 lines add whitespace errors.

Regards,
-Denis

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

* [PATCH] gprs: data bearer for telit with PSNT
  2012-08-14  6:53     ` Denis Kenzior
@ 2012-08-16  8:11       ` Christopher Vogl
  2012-08-16  6:12         ` Denis Kenzior
  0 siblings, 1 reply; 6+ messages in thread
From: Christopher Vogl @ 2012-08-16  8:11 UTC (permalink / raw)
  To: ofono

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

From: August Mayer <august.mayer@hale.at>

Telit neither supports '+CPSB' nor reports the data bearer through
'+CGREG'. It has its own +PSNT command.
---
 drivers/atmodem/gprs.c |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/drivers/atmodem/gprs.c b/drivers/atmodem/gprs.c
index 65a8b7b..2182f03 100644
--- a/drivers/atmodem/gprs.c
+++ b/drivers/atmodem/gprs.c
@@ -247,6 +247,41 @@ static void huawei_mode_notify(GAtResult *result, gpointer user_data)
 	ofono_gprs_bearer_notify(gprs, bearer);
 }
 
+static void telit_mode_notify(GAtResult *result, gpointer user_data)
+{
+	struct ofono_gprs *gprs = user_data;
+	GAtResultIter iter;
+	gint nt, bearer;
+
+	g_at_result_iter_init(&iter, result);
+
+	if (!g_at_result_iter_next(&iter, "#PSNT:"))
+		return;
+
+	if (!g_at_result_iter_next_number(&iter,&nt))
+		return;
+
+	switch (nt) {
+	case 0:
+		bearer = 1;    /* GPRS */
+		break;
+	case 1:
+		bearer = 2;    /* EDGE */
+		break;
+	case 2:
+		bearer = 3;    /* UMTS */
+		break;
+	case 3:
+		bearer = 5;    /* HSDPA */
+		break;
+	default:
+		bearer = 0;
+		break;
+	}
+	
+	ofono_gprs_bearer_notify(gprs, bearer);
+} 
+
 static void cpsb_notify(GAtResult *result, gpointer user_data)
 {
 	struct ofono_gprs *gprs = user_data;
@@ -281,6 +316,11 @@ static void gprs_initialized(gboolean ok, GAtResult *result, gpointer user_data)
 		g_at_chat_register(gd->chat, "^MODE:", huawei_mode_notify,
 						FALSE, gprs, NULL);
 		break;
+	case OFONO_VENDOR_TELIT:
+		g_at_chat_register(gd->chat, "#PSNT:", telit_mode_notify,
+						FALSE, gprs, NULL);
+		g_at_chat_send(gd->chat, "AT#PSNT=1", none_prefix,
+						NULL, NULL, NULL);
 	default:
 		g_at_chat_register(gd->chat, "+CPSB:", cpsb_notify,
 						FALSE, gprs, NULL);
-- 
1.7.7.6


--
Scanned by MailScanner.


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

end of thread, other threads:[~2012-08-16  8:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-13 13:23 [PATCH 6/8] gprs: data bearer for telit with PSNT Christopher Vogl
2012-08-13 14:48 ` Denis Kenzior
2012-08-14 15:39   ` Christopher Vogl
2012-08-14  6:53     ` Denis Kenzior
2012-08-16  8:11       ` [PATCH] " Christopher Vogl
2012-08-16  6:12         ` 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.