* problem sim status
@ 2014-03-27 18:55 Eric BOUXIROT
2014-03-27 20:05 ` Denis Kenzior
0 siblings, 1 reply; 11+ messages in thread
From: Eric BOUXIROT @ 2014-03-27 18:55 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 305 bytes --]
hi,
i make an embedded platform with a 3G modem from Sierra Wireless
(SL808x series).
i have a problem with ofono (v1.14) that ask sim status too fast after
modem added resulting in CME Error 14 (SIM busy).
is there a way to delay the sim status query (+CPIN) ??
thank you all !
Eric.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: problem sim status
2014-03-27 18:55 problem sim status Eric BOUXIROT
@ 2014-03-27 20:05 ` Denis Kenzior
2014-03-27 20:21 ` Eric BOUXIROT
0 siblings, 1 reply; 11+ messages in thread
From: Denis Kenzior @ 2014-03-27 20:05 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 493 bytes --]
Hi Eric,
On 03/27/2014 01:55 PM, Eric BOUXIROT wrote:
> hi,
>
> i make an embedded platform with a 3G modem from Sierra Wireless (SL808x
> series).
> i have a problem with ofono (v1.14) that ask sim status too fast after
> modem added resulting in CME Error 14 (SIM busy).
>
> is there a way to delay the sim status query (+CPIN) ??
>
Try adding OFONO_VENDOR_SIERRA to the list of vendors that require CPIN?
retry logic. See drivers/atmodem/sim.c:1256
Regards,
-Denis
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: problem sim status
2014-03-27 20:05 ` Denis Kenzior
@ 2014-03-27 20:21 ` Eric BOUXIROT
2014-03-27 20:30 ` Denis Kenzior
0 siblings, 1 reply; 11+ messages in thread
From: Eric BOUXIROT @ 2014-03-27 20:21 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 981 bytes --]
Denis Kenzior a pensé très fort :
> Hi Eric,
>
> On 03/27/2014 01:55 PM, Eric BOUXIROT wrote:
>> hi,
>>
>> i make an embedded platform with a 3G modem from Sierra Wireless (SL808x
>> series).
>> i have a problem with ofono (v1.14) that ask sim status too fast after
>> modem added resulting in CME Error 14 (SIM busy).
>>
>> is there a way to delay the sim status query (+CPIN) ??
>>
>
> Try adding OFONO_VENDOR_SIERRA to the list of vendors that require CPIN?
> retry logic. See drivers/atmodem/sim.c:1256
>
> Regards,
> -Denis
ok, i will add this, but if i understand well, this is for +CPIN
request AFTER sending a PIN. (but i mean my modem need this too.)
my problem is when modem is added throught dbus/ofono, ofono send somes
init commands and finaly i mean sim-manager send an +CPIN request to
know if SIM is locked or not... THIS request fail with CME error 14
because of too fast query.
i will try to put a log in few minutes..
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: problem sim status
2014-03-27 20:21 ` Eric BOUXIROT
@ 2014-03-27 20:30 ` Denis Kenzior
2014-03-27 21:34 ` Eric BOUXIROT
2014-03-28 17:27 ` Eric BOUXIROT
0 siblings, 2 replies; 11+ messages in thread
From: Denis Kenzior @ 2014-03-27 20:30 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 678 bytes --]
Hi Eric,
> ok, i will add this, but if i understand well, this is for +CPIN request
> AFTER sending a PIN. (but i mean my modem need this too.)
>
> my problem is when modem is added throught dbus/ofono, ofono send somes
> init commands and finaly i mean sim-manager send an +CPIN request to
> know if SIM is locked or not... THIS request fail with CME error 14
> because of too fast query.
>
Ah, its one of those modems that doesn't have a sim ready notification.
In that case you probably need to run CPIN queries as part of the modem
power-up procedure. See examples in plugins/zte.c and plugins/speedup.c
(cfun_enable & sim_state_cb)
Regards,
-Denis
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: problem sim status
2014-03-27 20:30 ` Denis Kenzior
@ 2014-03-27 21:34 ` Eric BOUXIROT
2014-03-27 22:14 ` Eric BOUXIROT
2014-03-28 17:27 ` Eric BOUXIROT
1 sibling, 1 reply; 11+ messages in thread
From: Eric BOUXIROT @ 2014-03-27 21:34 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 436 bytes --]
> Ah, its one of those modems that doesn't have a sim ready notification.
> In that case you probably need to run CPIN queries as part of the modem
> power-up procedure. See examples in plugins/zte.c and plugins/speedup.c
> (cfun_enable & sim_state_cb)
yes ! that's work !
do you mean this patch can be integrated in one ofono release ?
for thoses interested, i will send my patch in next minutes. (let me
make it clean)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: problem sim status
2014-03-27 21:34 ` Eric BOUXIROT
@ 2014-03-27 22:14 ` Eric BOUXIROT
0 siblings, 0 replies; 11+ messages in thread
From: Eric BOUXIROT @ 2014-03-27 22:14 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2039 bytes --]
> for thoses interested, i will send my patch in next minutes. (let me make it
> clean)
this make an SL8083 Sierra modem to work with ofono. i mean that do not
change anything for others modems.
diff -uprN a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
--- a/drivers/atmodem/sim.c 2013-11-08 08:37:52.000000000 +0100
+++ b/drivers/atmodem/sim.c 2014-03-27 22:28:58.000000000 +0100
@@ -1254,6 +1254,7 @@ static void at_pin_send_cb(gboolean ok,
case OFONO_VENDOR_ALCATEL:
case OFONO_VENDOR_HUAWEI:
case OFONO_VENDOR_SIMCOM:
+ case OFONO_VENDOR_SIERRA:
/*
* On ZTE modems, after pin is entered, SIM state is checked
* by polling CPIN as their modem doesn't provide unsolicited
diff -uprN a/plugins/sierra.c b/plugins/sierra.c
--- a/plugins/sierra.c 2013-11-08 08:37:52.000000000 +0100
+++ b/plugins/sierra.c 2014-03-27 23:00:59.872241558 +0100
@@ -48,6 +48,7 @@ static const char *none_prefix[] = { NUL
struct sierra_data {
GAtChat *modem;
+ struct at_util_sim_state_query *sim_state_query;
};
static void sierra_debug(const char *str, void *user_data)
@@ -119,6 +120,17 @@ static GAtChat *open_device(struct ofono
return chat;
}
+static void sim_state_cb(gboolean present, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct sierra_data *data = ofono_modem_get_data(modem);
+
+ at_util_sim_state_query_free(data->sim_state_query);
+ data->sim_state_query = NULL;
+
+ ofono_modem_set_powered(modem, TRUE);
+}
+
static void cfun_enable(gboolean ok, GAtResult *result, gpointer
user_data)
{
struct ofono_modem *modem = user_data;
@@ -129,9 +141,13 @@ static void cfun_enable(gboolean ok, GAt
if (!ok) {
g_at_chat_unref(data->modem);
data->modem = NULL;
+
+ ofono_modem_set_powered(modem, FALSE);
}
- ofono_modem_set_powered(modem, ok);
+ data->sim_state_query = at_util_sim_state_query_new(data->modem,
+ 2, 20, sim_state_cb, modem,
+ NULL);
}
static int sierra_enable(struct ofono_modem *modem)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: problem sim status
2014-03-27 20:30 ` Denis Kenzior
2014-03-27 21:34 ` Eric BOUXIROT
@ 2014-03-28 17:27 ` Eric BOUXIROT
2014-03-28 17:31 ` Eric BOUXIROT
2014-03-28 20:54 ` Denis Kenzior
1 sibling, 2 replies; 11+ messages in thread
From: Eric BOUXIROT @ 2014-03-28 17:27 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2985 bytes --]
Denis Kenzior a écrit :
> Hi Eric,
>
>> ok, i will add this, but if i understand well, this is for +CPIN request
>> AFTER sending a PIN. (but i mean my modem need this too.)
>>
>> my problem is when modem is added throught dbus/ofono, ofono send somes
>> init commands and finaly i mean sim-manager send an +CPIN request to
>> know if SIM is locked or not... THIS request fail with CME error 14
>> because of too fast query.
>>
>
> Ah, its one of those modems that doesn't have a sim ready notification.
> In that case you probably need to run CPIN queries as part of the modem
> power-up procedure. See examples in plugins/zte.c and plugins/speedup.c
> (cfun_enable & sim_state_cb)
>
> Regards,
> -Denis
hi Denis,
is it normal that pre_sim function is called before ofono get modem
manufacturer and model ?
ofonod[406]: plugins/sierra.c:open_device() Modem /dev/ttyUSB2
ofonod[406]: Modem: > ATE0 &C0\r
ofonod[406]: Modem: < ATE0 &C0\r
ofonod[406]: Modem: < \r\nOK\r\n
ofonod[406]: Modem: > AT+CMEE=1\r
ofonod[406]: Modem: < \r\n+CREG: 2\r\n
ofonod[406]: Modem: < \r\n+CIEV: 2,1\r\n
ofonod[406]: Modem: < \r\n+CIEV: 4,1\r\n
ofonod[406]: Modem: < \r\nOK\r\n
ofonod[406]: Modem: > AT+CFUN=4\r
ofonod[406]: Modem: < \r\nOK\r\n
ofonod[406]: plugins/sierra.c:cfun_enable()
ofonod[406]: src/modem.c:get_modem_property() modem 0x12d290 property
Model
ofonod[406]: src/modem.c:modem_change_state() old state: 0, new state:
1
ofonod[406]: plugins/sierra.c:sierra_pre_sim() 0x12d290
ofonod[406]: src/modem.c:get_modem_property() modem 0x12d290 property
Model
ofonod[406]: plugins/sierra.c:sierra_pre_sim()
ofonod[406]: Modem: > AT+GCAP\r
ofonod[406]: src/sim.c:ofono_sim_add_state_watch() 0x12e628
ofonod[406]: src/sim.c:ofono_sim_add_state_watch() 0x12e628
ofonod[406]: src/sim.c:ofono_sim_add_state_watch() 0x12e628
ofonod[406]: Modem: < \r\nERROR\r\n
ofonod[406]: Modem: > AT+CRSM=192,12258,0,0,255\r
ofonod[406]: Modem: < \r\n+CME ERROR: 3\r\n
ofonod[406]: Modem: > AT+CGMI\r
ofonod[406]: Modem: < \r\nSierra Wireless, Incorporated\r\n\r\nOK\r\n
ofonod[406]: Modem: > AT+CGMM\r
ofonod[406]: Modem: < \r\nSL8083\r\n\r\nOK\r\n
ofonod[406]: Modem: > AT+CGMR\r
ofonod[406]: Modem: < \r\nS4_0_0_7AP R1384 CNSZXD00000155 2012/09/29
10:26:17\r\n\r\nOK\r\n
ofonod[406]: Modem: > AT+CGSN\r
ofonod[406]: Modem: < \r\n355131041136262\r\n\r\nOK\r\n
ofonod[406]: Modem: > AT+CRSM=192,28421,0,0,255\r
ofonod[406]: Modem: < \r\n+CIEV: 2,0\r\n\r\n+CIEV: 4,0\r\n\r\n+CREG:
0\r\n\r\n+CME ERROR: 3\r\n
ofonod[406]: Modem: > AT+CRSM=192,12037,0,0,255\r
ofonod[406]: Modem: < \r\n+CME ERROR: 3\r\n
ofonod[406]: Modem: > AT+CPIN?\r
ofonod[406]: Modem: < \r\n+CME ERROR: 14\r\n
ofonod[406]: Querying PIN authentication state failed
i would like to get model in presim to make a better patch using modem
model with a new enum in vendor list (like simcom)
how i can make pre_sim to wait for theses information available ?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: problem sim status
2014-03-28 17:27 ` Eric BOUXIROT
@ 2014-03-28 17:31 ` Eric BOUXIROT
2014-03-28 20:54 ` Denis Kenzior
1 sibling, 0 replies; 11+ messages in thread
From: Eric BOUXIROT @ 2014-03-28 17:31 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2386 bytes --]
> hi Denis,
>
> is it normal that pre_sim function is called before ofono get modem
> manufacturer and model ?
>
> ofonod[406]: plugins/sierra.c:open_device() Modem /dev/ttyUSB2
> ofonod[406]: Modem: > ATE0 &C0\r
> ofonod[406]: Modem: < ATE0 &C0\r
> ofonod[406]: Modem: < \r\nOK\r\n
> ofonod[406]: Modem: > AT+CMEE=1\r
> ofonod[406]: Modem: < \r\n+CREG: 2\r\n
> ofonod[406]: Modem: < \r\n+CIEV: 2,1\r\n
> ofonod[406]: Modem: < \r\n+CIEV: 4,1\r\n
> ofonod[406]: Modem: < \r\nOK\r\n
> ofonod[406]: Modem: > AT+CFUN=4\r
> ofonod[406]: Modem: < \r\nOK\r\n
> ofonod[406]: plugins/sierra.c:cfun_enable()
> ofonod[406]: src/modem.c:get_modem_property() modem 0x12d290 property Model
> ofonod[406]: src/modem.c:modem_change_state() old state: 0, new state: 1
> ofonod[406]: plugins/sierra.c:sierra_pre_sim() 0x12d290
> ofonod[406]: src/modem.c:get_modem_property() modem 0x12d290 property Model
> ofonod[406]: plugins/sierra.c:sierra_pre_sim()
> ofonod[406]: Modem: > AT+GCAP\r
> ofonod[406]: src/sim.c:ofono_sim_add_state_watch() 0x12e628
> ofonod[406]: src/sim.c:ofono_sim_add_state_watch() 0x12e628
> ofonod[406]: src/sim.c:ofono_sim_add_state_watch() 0x12e628
> ofonod[406]: Modem: < \r\nERROR\r\n
> ofonod[406]: Modem: > AT+CRSM=192,12258,0,0,255\r
> ofonod[406]: Modem: < \r\n+CME ERROR: 3\r\n
> ofonod[406]: Modem: > AT+CGMI\r
> ofonod[406]: Modem: < \r\nSierra Wireless, Incorporated\r\n\r\nOK\r\n
> ofonod[406]: Modem: > AT+CGMM\r
> ofonod[406]: Modem: < \r\nSL8083\r\n\r\nOK\r\n
> ofonod[406]: Modem: > AT+CGMR\r
> ofonod[406]: Modem: < \r\nS4_0_0_7AP R1384 CNSZXD00000155 2012/09/29
> 10:26:17\r\n\r\nOK\r\n
> ofonod[406]: Modem: > AT+CGSN\r
> ofonod[406]: Modem: < \r\n355131041136262\r\n\r\nOK\r\n
> ofonod[406]: Modem: > AT+CRSM=192,28421,0,0,255\r
> ofonod[406]: Modem: < \r\n+CIEV: 2,0\r\n\r\n+CIEV: 4,0\r\n\r\n+CREG:
> 0\r\n\r\n+CME ERROR: 3\r\n
> ofonod[406]: Modem: > AT+CRSM=192,12037,0,0,255\r
> ofonod[406]: Modem: < \r\n+CME ERROR: 3\r\n
> ofonod[406]: Modem: > AT+CPIN?\r
> ofonod[406]: Modem: < \r\n+CME ERROR: 14\r\n
> ofonod[406]: Querying PIN authentication state failed
>
>
> i would like to get model in presim to make a better patch using modem model
> with a new enum in vendor list (like simcom)
> how i can make pre_sim to wait for theses information available ?
sorry mistake.. (like wavecom modem)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: problem sim status
2014-03-28 17:27 ` Eric BOUXIROT
2014-03-28 17:31 ` Eric BOUXIROT
@ 2014-03-28 20:54 ` Denis Kenzior
2014-03-29 13:35 ` Eric BOUXIROT
1 sibling, 1 reply; 11+ messages in thread
From: Denis Kenzior @ 2014-03-28 20:54 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 586 bytes --]
Hi Eric,
> is it normal that pre_sim function is called before ofono get modem
> manufacturer and model ?
>
Yes. If you note, the devinfo atom is added in pre-sim.
> i would like to get model in presim to make a better patch using modem
> model with a new enum in vendor list (like simcom)
> how i can make pre_sim to wait for theses information available ?
Simply query the model/whichever numbers as part of your initialization
procedure. e.g. run AT+FOO for the information that you need. See how
the huawei plugin uses AT+ATI for example.
Regards,
-Denis
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: problem sim status
2014-03-28 20:54 ` Denis Kenzior
@ 2014-03-29 13:35 ` Eric BOUXIROT
2014-03-31 15:30 ` Denis Kenzior
0 siblings, 1 reply; 11+ messages in thread
From: Eric BOUXIROT @ 2014-03-29 13:35 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 8536 bytes --]
> Simply query the model/whichever numbers as part of your initialization
> procedure. e.g. run AT+FOO for the information that you need. See how
> the huawei plugin uses AT+ATI for example.
ok !
here the patch i used to support Sierra Wireless SL808x series modem.
*add retries for +CPIN waiting SIM is ready
*add +CPINC to get PIN retry count
*add OFONO_VENDOR_SIERRA_SL808X vendor for theses specifics Sierra models.
*change to new vendor automaticaly at modem_enable using +CGMM to get modem model
I mean it can be added in next release of ofono ?
diff -uprN a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
--- a/drivers/atmodem/sim.c 2013-11-08 08:37:52.000000000 +0100
+++ b/drivers/atmodem/sim.c 2014-03-29 13:36:42.000000000 +0100
@@ -63,6 +63,7 @@ static const char *zpinpuk_prefix[] = {
static const char *pinnum_prefix[] = { "%PINNUM:", NULL };
static const char *oercn_prefix[] = { "_OERCN:", NULL };
static const char *cpinr_prefixes[] = { "+CPINR:", "+CPINRE:", NULL };
+static const char *cpinc_prefix[] = { "+CPINC:", NULL };
static const char *epin_prefix[] = { "*EPIN:", NULL };
static const char *spic_prefix[] = { "+SPIC:", NULL };
static const char *pct_prefix[] = { "#PCT:", NULL };
@@ -165,6 +166,7 @@ static void at_sim_read_info(struct ofon
case OFONO_VENDOR_ZTE:
case OFONO_VENDOR_HUAWEI:
case OFONO_VENDOR_SIERRA:
+ case OFONO_VENDOR_SIERRA_SL808X:
case OFONO_VENDOR_SPEEDUP:
case OFONO_VENDOR_QUALCOMM_MSM:
case OFONO_VENDOR_SIMCOM:
@@ -616,6 +618,45 @@ error:
CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
}
+static void at_cpinc_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_sim_pin_retries_cb_t cb = cbd->cb;
+ const char *final = g_at_result_final_response(result);
+ GAtResultIter iter;
+ struct ofono_error error;
+ int retries[OFONO_SIM_PASSWORD_INVALID];
+ size_t i;
+ static enum ofono_sim_password_type password_types[] = {
+ OFONO_SIM_PASSWORD_SIM_PIN,
+ OFONO_SIM_PASSWORD_SIM_PIN2,
+ OFONO_SIM_PASSWORD_SIM_PUK,
+ OFONO_SIM_PASSWORD_SIM_PUK2,
+ };
+
+ decode_at_error(&error, final);
+
+ if (!ok) {
+ cb(&error, NULL, cbd->data);
+ return;
+ }
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, "+CPINC:"))
+ goto error;
+
+ BUILD_PIN_RETRIES_ARRAY(password_types, ARRAY_SIZE(password_types),
+ retries);
+
+ cb(&error, retries, cbd->data);
+
+ return;
+
+error:
+ CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
+}
+
static void xpincnt_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct cb_data *cbd = user_data;
@@ -1023,6 +1064,11 @@ static void at_pin_retries_query(struct
at_pct_cb, cbd, g_free) > 0)
return;
break;
+ case OFONO_VENDOR_SIERRA_SL808X:
+ if (g_at_chat_send(sd->chat, "AT+CPINC", cpinc_prefix,
+ at_cpinc_cb, cbd, g_free) > 0)
+ return;
+ break;
case OFONO_VENDOR_ALCATEL:
if (g_at_chat_send(sd->chat, "AT+PNNM?", pnnm_prefix,
at_pnnm_cb, cbd, g_free) > 0)
@@ -1254,6 +1300,7 @@ static void at_pin_send_cb(gboolean ok,
case OFONO_VENDOR_ALCATEL:
case OFONO_VENDOR_HUAWEI:
case OFONO_VENDOR_SIMCOM:
+ case OFONO_VENDOR_SIERRA_SL808X:
/*
* On ZTE modems, after pin is entered, SIM state is checked
* by polling CPIN as their modem doesn't provide unsolicited
diff -uprN a/drivers/atmodem/vendor.h b/drivers/atmodem/vendor.h
--- a/drivers/atmodem/vendor.h 2013-11-08 08:37:52.000000000 +0100
+++ b/drivers/atmodem/vendor.h 2014-03-28 17:32:33.850389573 +0100
@@ -31,6 +31,7 @@ enum ofono_vendor {
OFONO_VENDOR_ZTE,
OFONO_VENDOR_HUAWEI,
OFONO_VENDOR_SIERRA,
+ OFONO_VENDOR_SIERRA_SL808X,
OFONO_VENDOR_NOVATEL,
OFONO_VENDOR_WAVECOM,
OFONO_VENDOR_NOKIA,
diff -uprN a/drivers/swmodem/gprs-context.c b/drivers/swmodem/gprs-context.c
--- a/drivers/swmodem/gprs-context.c 2012-07-02 09:55:34.000000000 +0200
+++ b/drivers/swmodem/gprs-context.c 2014-03-28 17:47:26.338306480 +0100
@@ -41,6 +41,7 @@
#include "gattty.h"
#include "swmodem.h"
+#include <drivers/atmodem/vendor.h>
static const char *none_prefix[] = { NULL };
@@ -49,6 +50,7 @@ struct gprs_context_data {
unsigned int active_context;
ofono_gprs_context_cb_t cb;
void *cb_data;
+ unsigned int vendor;
};
static void at_scact_down_cb(gboolean ok, GAtResult *result,
@@ -100,8 +102,10 @@ static void at_scact_up_cb(gboolean ok,
snprintf(buf, sizeof(buf), "AT!SCPADDR=%u", gcd->active_context);
g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL);
- snprintf(buf, sizeof(buf), "AT+CGCONTRDP=%u", gcd->active_context);
- g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL);
+ if (gcd->vendor == OFONO_VENDOR_SIERRA) {
+ snprintf(buf, sizeof(buf), "AT+CGCONTRDP=%u", gcd->active_context);
+ g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL);
+ }
modem = ofono_gprs_context_get_modem(gc);
interface = ofono_modem_get_string(modem, "NetworkInterface");
@@ -227,6 +231,7 @@ static int sw_gprs_context_probe(struct
return -ENOMEM;
gcd->chat = g_at_chat_clone(chat);
+ gcd->vendor = vendor;
ofono_gprs_context_set_data(gc, gcd);
diff -uprN a/plugins/sierra.c b/plugins/sierra.c
--- a/plugins/sierra.c 2013-11-08 08:37:52.000000000 +0100
+++ b/plugins/sierra.c 2014-03-29 13:51:24.419037337 +0100
@@ -48,6 +48,8 @@ static const char *none_prefix[] = { NUL
struct sierra_data {
GAtChat *modem;
+ enum ofono_vendor vendor;
+ struct at_util_sim_state_query *sim_state_query;
};
static void sierra_debug(const char *str, void *user_data)
@@ -119,6 +121,17 @@ static GAtChat *open_device(struct ofono
return chat;
}
+static void sim_state_cb(gboolean present, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct sierra_data *data = ofono_modem_get_data(modem);
+
+ at_util_sim_state_query_free(data->sim_state_query);
+ data->sim_state_query = NULL;
+
+ ofono_modem_set_powered(modem, TRUE);
+}
+
static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
{
struct ofono_modem *modem = user_data;
@@ -129,9 +142,44 @@ static void cfun_enable(gboolean ok, GAt
if (!ok) {
g_at_chat_unref(data->modem);
data->modem = NULL;
+
+ if (data->vendor == OFONO_VENDOR_SIERRA_SL808X)
+ ofono_modem_set_powered(modem, FALSE);
}
- ofono_modem_set_powered(modem, ok);
+ if (data->vendor == OFONO_VENDOR_SIERRA_SL808X)
+ data->sim_state_query = at_util_sim_state_query_new(data->modem,
+ 2, 20, sim_state_cb, modem,
+ NULL);
+ else
+ ofono_modem_set_powered(modem, ok);
+}
+
+static void get_model(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct sierra_data *data = ofono_modem_get_data(modem);
+ struct ofono_error error;
+ const char *attr;
+ enum ofono_vendor vendor = 0;
+
+ DBG("");
+
+ data->vendor=OFONO_VENDOR_SIERRA;
+ decode_at_error(&error, g_at_result_final_response(result));
+
+ if (!ok)
+ goto done;
+
+ if (at_util_parse_attr(result, "", &attr) == TRUE)
+ if (!strncmp(attr,"SL808",5)) {
+ data->vendor=OFONO_VENDOR_SIERRA_SL808X;
+ DBG("Modem is SL808X series");
+ }
+
+done:
+ g_at_chat_send(data->modem, "AT+CFUN=4", none_prefix,
+ cfun_enable, modem, NULL);
}
static int sierra_enable(struct ofono_modem *modem)
@@ -148,8 +196,7 @@ static int sierra_enable(struct ofono_mo
/* This is separate because it is not supported by all modems. */
g_at_chat_send(data->modem, "AT+CMEE=1", NULL, NULL, NULL, NULL);
- g_at_chat_send(data->modem, "AT+CFUN=4", none_prefix,
- cfun_enable, modem, NULL);
+ g_at_chat_send(data->modem, "AT+CGMM", NULL, get_model, modem, NULL);
return -EINPROGRESS;
}
@@ -219,7 +266,7 @@ static void sierra_pre_sim(struct ofono_
DBG("%p", modem);
ofono_devinfo_create(modem, 0, "atmodem", data->modem);
- sim = ofono_sim_create(modem, OFONO_VENDOR_SIERRA,
+ sim = ofono_sim_create(modem, data->vendor,
"atmodem", data->modem);
if (sim)
@@ -237,7 +284,7 @@ static void sierra_post_sim(struct ofono
ofono_phonebook_create(modem, 0, "atmodem", data->modem);
gprs = ofono_gprs_create(modem, 0, "atmodem", data->modem);
- gc = ofono_gprs_context_create(modem, 0, "swmodem", data->modem);
+ gc = ofono_gprs_context_create(modem, data->vendor, "swmodem", data->modem);
if (gprs && gc)
ofono_gprs_add_context(gprs, gc);
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: problem sim status
2014-03-29 13:35 ` Eric BOUXIROT
@ 2014-03-31 15:30 ` Denis Kenzior
0 siblings, 0 replies; 11+ messages in thread
From: Denis Kenzior @ 2014-03-31 15:30 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 6578 bytes --]
Hi Eric,
On 03/29/2014 08:35 AM, Eric BOUXIROT wrote:
>> Simply query the model/whichever numbers as part of your initialization
>> procedure. e.g. run AT+FOO for the information that you need. See how
>> the huawei plugin uses AT+ATI for example.
>
> ok !
>
> here the patch i used to support Sierra Wireless SL808x series modem.
> *add retries for +CPIN waiting SIM is ready
> *add +CPINC to get PIN retry count
> *add OFONO_VENDOR_SIERRA_SL808X vendor for theses specifics Sierra models.
> *change to new vendor automaticaly at modem_enable using +CGMM to get modem model
>
> I mean it can be added in next release of ofono ?
Please break up your patches and submit them using git send-email.
Refer to HACKING document inside ofono's git tree for more details.
Browse previous patch submissions for ample examples of how we like our
patches to be structured.
Your patches should probably look roughly like this:
1. drivers/atmodem/vendor.h changes
2. drivers/atmodem/sim.c changes
3. drivers/swmodem/gprs-context.c changes
4. plugins/sierra.c changes
<snip>
> diff -uprN a/drivers/swmodem/gprs-context.c b/drivers/swmodem/gprs-context.c
> --- a/drivers/swmodem/gprs-context.c 2012-07-02 09:55:34.000000000 +0200
> +++ b/drivers/swmodem/gprs-context.c 2014-03-28 17:47:26.338306480 +0100
> @@ -41,6 +41,7 @@
> #include "gattty.h"
>
> #include "swmodem.h"
> +#include <drivers/atmodem/vendor.h>
>
> static const char *none_prefix[] = { NULL };
>
> @@ -49,6 +50,7 @@ struct gprs_context_data {
> unsigned int active_context;
> ofono_gprs_context_cb_t cb;
> void *cb_data;
> + unsigned int vendor;
> };
>
> static void at_scact_down_cb(gboolean ok, GAtResult *result,
> @@ -100,8 +102,10 @@ static void at_scact_up_cb(gboolean ok,
> snprintf(buf, sizeof(buf), "AT!SCPADDR=%u", gcd->active_context);
> g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL);
>
> - snprintf(buf, sizeof(buf), "AT+CGCONTRDP=%u", gcd->active_context);
> - g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL);
> + if (gcd->vendor == OFONO_VENDOR_SIERRA) {
> + snprintf(buf, sizeof(buf), "AT+CGCONTRDP=%u", gcd->active_context);
> + g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL);
> + }
I'm confused why you need this change. The CGCONTRDP command has no
effect, so it is safe to leave it in there even if it fails.
>
> modem = ofono_gprs_context_get_modem(gc);
> interface = ofono_modem_get_string(modem, "NetworkInterface");
> @@ -227,6 +231,7 @@ static int sw_gprs_context_probe(struct
> return -ENOMEM;
>
> gcd->chat = g_at_chat_clone(chat);
> + gcd->vendor = vendor;
>
> ofono_gprs_context_set_data(gc, gcd);
>
> diff -uprN a/plugins/sierra.c b/plugins/sierra.c
> --- a/plugins/sierra.c 2013-11-08 08:37:52.000000000 +0100
> +++ b/plugins/sierra.c 2014-03-29 13:51:24.419037337 +0100
> @@ -48,6 +48,8 @@ static const char *none_prefix[] = { NUL
>
> struct sierra_data {
> GAtChat *modem;
> + enum ofono_vendor vendor;
> + struct at_util_sim_state_query *sim_state_query;
> };
>
> static void sierra_debug(const char *str, void *user_data)
> @@ -119,6 +121,17 @@ static GAtChat *open_device(struct ofono
> return chat;
> }
>
> +static void sim_state_cb(gboolean present, gpointer user_data)
> +{
> + struct ofono_modem *modem = user_data;
> + struct sierra_data *data = ofono_modem_get_data(modem);
> +
> + at_util_sim_state_query_free(data->sim_state_query);
> + data->sim_state_query = NULL;
You don't set whether the SIM is present or not. Isn't this what you want?
> +
> + ofono_modem_set_powered(modem, TRUE);
> +}
> +
> static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
> {
> struct ofono_modem *modem = user_data;
> @@ -129,9 +142,44 @@ static void cfun_enable(gboolean ok, GAt
> if (!ok) {
> g_at_chat_unref(data->modem);
> data->modem = NULL;
> +
> + if (data->vendor == OFONO_VENDOR_SIERRA_SL808X)
> + ofono_modem_set_powered(modem, FALSE);
> }
>
> - ofono_modem_set_powered(modem, ok);
> + if (data->vendor == OFONO_VENDOR_SIERRA_SL808X)
> + data->sim_state_query = at_util_sim_state_query_new(data->modem,
> + 2, 20, sim_state_cb, modem,
> + NULL);
> + else
> + ofono_modem_set_powered(modem, ok);
> +}
> +
> +static void get_model(gboolean ok, GAtResult *result, gpointer user_data)
> +{
> + struct ofono_modem *modem = user_data;
> + struct sierra_data *data = ofono_modem_get_data(modem);
> + struct ofono_error error;
> + const char *attr;
> + enum ofono_vendor vendor = 0;
> +
> + DBG("");
> +
> + data->vendor=OFONO_VENDOR_SIERRA;
This is not according to our coding style.
> + decode_at_error(&error, g_at_result_final_response(result));
> +
> + if (!ok)
> + goto done;
> +
> + if (at_util_parse_attr(result, "", &attr) == TRUE)
> + if (!strncmp(attr,"SL808",5)) {
> + data->vendor=OFONO_VENDOR_SIERRA_SL808X;
> + DBG("Modem is SL808X series");
> + }
Again, fix the coding style here.
It would be better to rewrite this piece as:
if (at_util_parse_attr(...) == FALSE)
goto done;
if (!strncmp(...)) {
....
}
> +
> +done:
> + g_at_chat_send(data->modem, "AT+CFUN=4", none_prefix,
> + cfun_enable, modem, NULL);
> }
>
> static int sierra_enable(struct ofono_modem *modem)
> @@ -148,8 +196,7 @@ static int sierra_enable(struct ofono_mo
> /* This is separate because it is not supported by all modems. */
> g_at_chat_send(data->modem, "AT+CMEE=1", NULL, NULL, NULL, NULL);
>
> - g_at_chat_send(data->modem, "AT+CFUN=4", none_prefix,
> - cfun_enable, modem, NULL);
> + g_at_chat_send(data->modem, "AT+CGMM", NULL, get_model, modem, NULL);
>
> return -EINPROGRESS;
> }
> @@ -219,7 +266,7 @@ static void sierra_pre_sim(struct ofono_
> DBG("%p", modem);
>
> ofono_devinfo_create(modem, 0, "atmodem", data->modem);
> - sim = ofono_sim_create(modem, OFONO_VENDOR_SIERRA,
> + sim = ofono_sim_create(modem, data->vendor,
> "atmodem", data->modem);
>
> if (sim)
> @@ -237,7 +284,7 @@ static void sierra_post_sim(struct ofono
> ofono_phonebook_create(modem, 0, "atmodem", data->modem);
>
> gprs = ofono_gprs_create(modem, 0, "atmodem", data->modem);
> - gc = ofono_gprs_context_create(modem, 0, "swmodem", data->modem);
> + gc = ofono_gprs_context_create(modem, data->vendor, "swmodem", data->modem);
>
> if (gprs && gc)
> ofono_gprs_add_context(gprs, gc);
>
Regards,
-Denis
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-03-31 15:30 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-27 18:55 problem sim status Eric BOUXIROT
2014-03-27 20:05 ` Denis Kenzior
2014-03-27 20:21 ` Eric BOUXIROT
2014-03-27 20:30 ` Denis Kenzior
2014-03-27 21:34 ` Eric BOUXIROT
2014-03-27 22:14 ` Eric BOUXIROT
2014-03-28 17:27 ` Eric BOUXIROT
2014-03-28 17:31 ` Eric BOUXIROT
2014-03-28 20:54 ` Denis Kenzior
2014-03-29 13:35 ` Eric BOUXIROT
2014-03-31 15:30 ` 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.