gprs: data bearer for telit with PSNT

Telit neither supports '+CPSB' nor reports the data bearer through
'+CGREG'. It has its own +PSNT command.
This commit is contained in:
August Mayer 2012-08-16 10:11:16 +02:00 committed by Denis Kenzior
parent b264440737
commit 4293e4ea63
1 changed files with 40 additions and 0 deletions

View File

@ -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);