atmodem/gprs: initial Gemalto vendor-specific support
PATCH 1/1 atmodem/gprs: initial Gemalto vendor-specific support
--- drivers/atmodem/gprs.c | 128 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 123 insertions(+), 5 deletions(-)
drivers/atmodem/gprs.c +123 -5
@@ -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 ; }
Signature · 1 line
2.17.1
Hi Giacinto,
Quoted 144 lines · Giacinto Cifelli
--- drivers/atmodem/gprs.c | 128 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 123 insertions(+), 5 deletions(-)drivers/atmodem/gprs.c +104
-2@@ -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:
drivers/atmodem/gprs.c retry: · line 926
Quoted 10 lines
drivers/atmodem/gprs.c +7
-1g_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.
drivers/atmodem/gprs.c retry: · line 929
Quoted 3 lines
drivers/atmodem/gprs.c +0
-0sprintf (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.
Quoted 19 lines
drivers/atmodem/gprs.c +5
-2@@ -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 */
drivers/atmodem/gprs.c static int at_gprs_probe(struct ofono_gprs *gprs, · line 1066
Quoted 10 lines
drivers/atmodem/gprs.c +7
-0+ 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