ofono with sim5320 module
by David Ashley
Hello, I'm at my wits' end trying to get ofono working with the
sim5320 module. I'm using the plugins/sim900.c module as a starting
point. I think the issue has something to do with the difference
between the MUX functionality between the 900 and the 5320. The sim900
supports the elaborate parameters sent on the
AT+CMUX=0,x,x,x,x, etc.
but the SIM5320 only supports
AT+CMUX=0
There's that... but also the way the sim900 plugin creates a
SETUP_DLC, initiates muxing, then deletes the setup DLC and creates 4
new DLC's... it didn't work for the sim5320 until I remapped the DLC's
somewhat like this:
#define NUM_DLC 4
#define VOICE_DLC 2
#define NETREG_DLC 1
//#define SMS_DLC 2
#define GPRS_DLC 3
#define SETUP_DLC 0
static char *dlc_prefixes[NUM_DLC] = {
[VOICE_DLC]="Voice: ",
[NETREG_DLC]="Net: ",
// [SMS_DLC]= "SMS: ",
[GPRS_DLC]= "GPRS: " ,
[SETUP_DLC]= "Setup: ",
};
Note I have to eliminate the SMS_DLC usage later in sim5320_post_sim:
// ofono_sms_create(modem, OFONO_VENDOR_SIMCOM, "atmodem",
// data->dlcs[SMS_DLC]);
OK everything is *ALMOST* working. ofonod interacts fine with
connmand, connmand tells ofonod to activate the sim5320, which
actually establishes a ppp connection and sets up a ppp device:
ppp0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-0
inet addr:30.97.132.47 P-t-P:30.97.132.47 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:0 (0.0 B) TX bytes:124 (124.0 B)
Here's the rub: No matter what I do, I never get any RX packets from
that ppp device, and even when it appears to TX packets (I'm trying to
ping out) the machine on the internet isn't actually receiving them.
I'm running on a beaglebone with a custom board with a sim5320 module on it.
I have no idea what to try... Any advice would be appreciated...
Thanks very much!!!!
-Dave
3 years, 2 months
[PATCH] huaweimodem: Fix DHCP parsing on 32-bit platforms
by Santtu Lakkala
strtol clamps returned value between INT_MIN and INT_MAX, causing
invalid value (255.255.255.127) being reported for any address
if last octet > 127 when sizeof(long) == 4.
---
drivers/huaweimodem/gprs-context.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/huaweimodem/gprs-context.c b/drivers/huaweimodem/gprs-context.c
index 3acd90c..dda5e32 100644
--- a/drivers/huaweimodem/gprs-context.c
+++ b/drivers/huaweimodem/gprs-context.c
@@ -80,7 +80,7 @@ static gboolean get_next_addr(GAtResultIter *iter, char **addr)
if (g_at_result_iter_next_unquoted_string(iter, &str) == FALSE)
return FALSE;
- val = strtol(str, NULL, 16);
+ val = strtoul(str, NULL, 16);
if (addr)
*addr = g_strdup_printf("%u.%u.%u.%u",
--
2.5.0
4 years, 6 months
[PATCH] sim: remove locked_pin reset from sim_free_main_state
by Samrat Guha Niyogi
---
src/sim.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/src/sim.c b/src/sim.c
index 0bbd1ef..ab5f2c6 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -2372,13 +2372,6 @@ static void sim_spn_close(struct ofono_sim *sim)
static void sim_free_main_state(struct ofono_sim *sim)
{
- int i;
-
- for (i = 0; i < OFONO_SIM_PASSWORD_INVALID; i++)
- sim->pin_retries[i] = -1;
-
- memset(sim->locked_pins, 0, sizeof(sim->locked_pins));
-
if (sim->imsi) {
g_free(sim->imsi);
sim->imsi = NULL;
@@ -2547,7 +2540,24 @@ void ofono_sim_inserted_notify(struct ofono_sim *sim, ofono_bool_t inserted)
sim_initialize(sim);
}
} else {
- sim->pin_type = OFONO_SIM_PASSWORD_NONE;
+ switch (sim->pin_type) {
+ case OFONO_SIM_PASSWORD_SIM_PIN:
+ case OFONO_SIM_PASSWORD_SIM_PUK:
+ case OFONO_SIM_PASSWORD_SIM_PIN2:
+ case OFONO_SIM_PASSWORD_SIM_PUK2:
+ sim->pin_type = OFONO_SIM_PASSWORD_NONE;
+ break;
+ default:
+ break;
+ }
+
+ sim->locked_pins[OFONO_SIM_PASSWORD_SIM_PIN] = FALSE;
+ sim->locked_pins[OFONO_SIM_PASSWORD_SIM_PIN2] = FALSE;
+
+ sim->pin_retries[OFONO_SIM_PASSWORD_SIM_PIN] = -1;
+ sim->pin_retries[OFONO_SIM_PASSWORD_SIM_PUK] = -1;
+ sim->pin_retries[OFONO_SIM_PASSWORD_SIM_PIN2] = -1;
+ sim->pin_retries[OFONO_SIM_PASSWORD_SIM_PUK2] = -1;
sim_free_state(sim);
}
--
1.9.1
4 years, 6 months
[PATCH] sim: fix cbd initialization in ril_query_facility_lock
by Samrat Guha Niyogi
---
drivers/rilmodem/sim.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rilmodem/sim.c b/drivers/rilmodem/sim.c
index b34723f..4509693 100644
--- a/drivers/rilmodem/sim.c
+++ b/drivers/rilmodem/sim.c
@@ -1453,7 +1453,7 @@ static void ril_query_facility_lock(struct ofono_sim *sim,
void *data)
{
struct sim_data *sd = ofono_sim_get_data(sim);
- struct cb_data *cbd = cb_data_new(cb, data, sim);
+ struct cb_data *cbd = cb_data_new(cb, data, sd);
struct parcel rilp;
parcel_init(&rilp);
--
1.9.1
4 years, 6 months
[PATCH] sim: fix num_params in ril_query_facility_lock_cb
by Samrat Guha Niyogi
---
drivers/rilmodem/sim.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/rilmodem/sim.c b/drivers/rilmodem/sim.c
index 74f9d6b..b34723f 100644
--- a/drivers/rilmodem/sim.c
+++ b/drivers/rilmodem/sim.c
@@ -1424,12 +1424,17 @@ static void ril_query_facility_lock_cb(struct ril_msg *message,
struct sim_data *sd = cbd->user;
struct parcel rilp;
ofono_bool_t status;
+ int numparams;
if (message->error != RIL_E_SUCCESS)
goto error;
g_ril_init_parcel(message, &rilp);
+ numparams = parcel_r_int32(&rilp);
+ if (numparams < 1)
+ goto error;
+
status = (ofono_bool_t) parcel_r_int32(&rilp);
g_ril_append_print_buf(sd->ril, "{%d}", status);
--
1.9.1
4 years, 6 months
[PATCH] sim: split ril_pin_change_state_cb based on functionality
by Samrat Guha Niyogi
split ril_pin_change_state_cb based on functionality w.r.t.
facility lock, puk and pin. Rename ril_pin_change_state to
more appropriate name ril_set_facility_lock and rename
ril_pin_change_state_cb to ril_enter_sim_pin_cb.
---
drivers/rilmodem/sim.c | 120 ++++++++++++++++++++++++++++++++++---------------
1 file changed, 84 insertions(+), 36 deletions(-)
diff --git a/drivers/rilmodem/sim.c b/drivers/rilmodem/sim.c
index 0eec10a..74f9d6b 100644
--- a/drivers/rilmodem/sim.c
+++ b/drivers/rilmodem/sim.c
@@ -79,7 +79,7 @@
* The same applies to the app_type.
*/
-static void ril_pin_change_state(struct ofono_sim *sim,
+static void ril_set_facility_lock(struct ofono_sim *sim,
enum ofono_sim_password_type passwd_type,
int enable, const char *passwd,
ofono_sim_lock_unlock_cb_t cb, void *data);
@@ -1083,7 +1083,7 @@ static void ril_query_passwd_state(struct ofono_sim *sim,
CALLBACK_WITH_SUCCESS(cb, sd->passwd_state, data);
}
-static void ril_pin_change_state_cb(struct ril_msg *message, gpointer user_data)
+static void ril_enter_sim_pin_cb(struct ril_msg *message, gpointer user_data)
{
struct cb_data *cbd = user_data;
ofono_sim_lock_unlock_cb_t cb = cbd->cb;
@@ -1101,38 +1101,17 @@ static void ril_pin_change_state_cb(struct ril_msg *message, gpointer user_data)
g_ril_init_parcel(message, &rilp);
- /* maguro/infineon: no data is returned */
- if (parcel_data_avail(&rilp) == 0)
- goto done;
-
parcel_r_int32(&rilp);
- switch (g_ril_vendor(sd->ril)) {
- case OFONO_RIL_VENDOR_AOSP:
- case OFONO_RIL_VENDOR_QCOM_MSIM:
- /*
- * The number of retries is valid only when a wrong password has
- * been introduced in Nexus 4. TODO: check Nexus 5 behaviour.
- */
- if (message->error == RIL_E_PASSWORD_INCORRECT)
- sd->retries[sd->passwd_type] = parcel_r_int32(&rilp);
- else
- sd->retries[sd->passwd_type] = -1;
-
- g_ril_append_print_buf(sd->ril, "{%d}",
- sd->retries[sd->passwd_type]);
- g_ril_print_response(sd->ril, message);
+ if (message->error == RIL_E_SUCCESS)
+ sd->retries[sd->passwd_type] = -1;
+ else
+ sd->retries[sd->passwd_type] = parcel_r_int32(&rilp);
- break;
- /* Taken care of elsewhere */
- case OFONO_RIL_VENDOR_INFINEON:
- case OFONO_RIL_VENDOR_MTK:
- break;
- default:
- break;
- }
+ g_ril_append_print_buf(sd->ril, "{%d}",
+ sd->retries[sd->passwd_type]);
+ g_ril_print_response(sd->ril, message);
-done:
if (message->error == RIL_E_SUCCESS) {
CALLBACK_WITH_SUCCESS(cb, cbd->data);
return;
@@ -1146,6 +1125,74 @@ done:
send_get_sim_status(sim);
}
+static void ril_enter_sim_puk_cb(struct ril_msg *message, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_sim_lock_unlock_cb_t cb = cbd->cb;
+ struct ofono_sim *sim = cbd->user;
+ struct sim_data *sd = ofono_sim_get_data(sim);
+ struct parcel rilp;
+
+ g_ril_init_parcel(message, &rilp);
+
+ parcel_r_int32(&rilp);
+
+ if (message->error != RIL_E_SUCCESS) {
+ sd->retries[OFONO_SIM_PASSWORD_SIM_PUK] = parcel_r_int32(&rilp);
+ } else {
+ sd->retries[OFONO_SIM_PASSWORD_SIM_PIN] = -1;
+ sd->retries[OFONO_SIM_PASSWORD_SIM_PUK] = -1;
+ }
+
+ g_ril_append_print_buf(sd->ril, "{%d}",
+ sd->retries[OFONO_SIM_PASSWORD_SIM_PUK]);
+ g_ril_print_response(sd->ril, message);
+
+ if (message->error == RIL_E_SUCCESS) {
+ CALLBACK_WITH_SUCCESS(cb, cbd->data);
+ return;
+ }
+
+ CALLBACK_WITH_FAILURE(cb, cbd->data);
+}
+
+static void ril_set_facility_lock_cb(struct ril_msg *message, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_sim_lock_unlock_cb_t cb = cbd->cb;
+ struct ofono_sim *sim = cbd->user;
+ struct sim_data *sd = ofono_sim_get_data(sim);
+ struct parcel rilp;
+
+ /*
+ * There is no reason to ask SIM status until
+ * unsolicited sim status change indication
+ * Looks like state does not change before that.
+ */
+ DBG("Enter password: type %d, result %d",
+ sd->passwd_type, message->error);
+
+ g_ril_init_parcel(message, &rilp);
+
+ parcel_r_int32(&rilp);
+
+ if (message->error == RIL_E_SUCCESS)
+ sd->retries[sd->passwd_type] = -1;
+ else
+ sd->retries[sd->passwd_type] = parcel_r_int32(&rilp);
+
+ g_ril_append_print_buf(sd->ril, "{%d}",
+ sd->retries[sd->passwd_type]);
+ g_ril_print_response(sd->ril, message);
+
+ if (message->error == RIL_E_SUCCESS) {
+ CALLBACK_WITH_SUCCESS(cb, cbd->data);
+ return;
+ }
+
+ CALLBACK_WITH_FAILURE(cb, cbd->data);
+}
+
static void ril_pin_send(struct ofono_sim *sim, const char *passwd,
ofono_sim_lock_unlock_cb_t cb, void *data)
{
@@ -1169,7 +1216,7 @@ static void ril_pin_send(struct ofono_sim *sim, const char *passwd,
g_ril_append_print_buf(sd->ril, "(%s,aid=%s)", passwd, sd->aid_str);
if (g_ril_send(sd->ril, RIL_REQUEST_ENTER_SIM_PIN, &rilp,
- ril_pin_change_state_cb, cbd, g_free) > 0)
+ ril_enter_sim_pin_cb, cbd, g_free) > 0)
return;
g_free(cbd);
@@ -1189,7 +1236,7 @@ static const char *const clck_cpwd_fac[] = {
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-static void ril_pin_change_state(struct ofono_sim *sim,
+static void ril_set_facility_lock(struct ofono_sim *sim,
enum ofono_sim_password_type passwd_type,
int enable, const char *passwd,
ofono_sim_lock_unlock_cb_t cb, void *data)
@@ -1199,6 +1246,7 @@ static void ril_pin_change_state(struct ofono_sim *sim,
struct parcel rilp;
sd->unlock_pending = FALSE;
+ sd->passwd_type = passwd_type;
if (passwd_type >= ARRAY_SIZE(clck_cpwd_fac) ||
clck_cpwd_fac[passwd_type] == NULL)
@@ -1220,7 +1268,7 @@ static void ril_pin_change_state(struct ofono_sim *sim,
sd->aid_str);
if (g_ril_send(sd->ril, RIL_REQUEST_SET_FACILITY_LOCK, &rilp,
- ril_pin_change_state_cb, cbd, g_free) > 0)
+ ril_set_facility_lock_cb, cbd, g_free) > 0)
return;
g_free(cbd);
@@ -1249,7 +1297,7 @@ static void ril_pin_send_puk(struct ofono_sim *sim,
puk, passwd, sd->aid_str);
if (g_ril_send(sd->ril, RIL_REQUEST_ENTER_SIM_PUK, &rilp,
- ril_pin_change_state_cb, cbd, g_free) > 0)
+ ril_enter_sim_puk_cb, cbd, g_free) > 0)
return;
g_free(cbd);
@@ -1287,7 +1335,7 @@ static void ril_change_passwd(struct ofono_sim *sim,
g_ril_append_print_buf(sd->ril, "(old=%s,new=%s,aid=%s)",
old_passwd, new_passwd, sd->aid_str);
- if (g_ril_send(sd->ril, request, &rilp, ril_pin_change_state_cb,
+ if (g_ril_send(sd->ril, request, &rilp, ril_enter_sim_pin_cb,
cbd, g_free) > 0)
return;
@@ -1446,7 +1494,7 @@ static struct ofono_sim_driver driver = {
.query_pin_retries = ril_query_pin_retries,
.reset_passwd = ril_pin_send_puk,
.change_passwd = ril_change_passwd,
- .lock = ril_pin_change_state,
+ .lock = ril_set_facility_lock,
.query_facility_lock = ril_query_facility_lock,
};
--
1.9.1
4 years, 6 months
[PATCH] sim: removal of extra ril_pin_send in ril_pin_change_state
by Samrat Guha Niyogi
---
drivers/rilmodem/sim.c | 39 ---------------------------------------
1 file changed, 39 deletions(-)
diff --git a/drivers/rilmodem/sim.c b/drivers/rilmodem/sim.c
index e411215..0eec10a 100644
--- a/drivers/rilmodem/sim.c
+++ b/drivers/rilmodem/sim.c
@@ -1176,23 +1176,6 @@ static void ril_pin_send(struct ofono_sim *sim, const char *passwd,
CALLBACK_WITH_FAILURE(cb, data);
}
-static void enter_pin_done(const struct ofono_error *error, void *data)
-{
- struct change_state_cbd *csd = data;
- struct sim_data *sd = ofono_sim_get_data(csd->sim);
-
- if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
- ofono_error("%s: wrong password", __func__);
- sd->unlock_pending = FALSE;
- CALLBACK_WITH_FAILURE(csd->cb, csd->data);
- } else {
- ril_pin_change_state(csd->sim, csd->passwd_type, csd->enable,
- csd->passwd, csd->cb, csd->data);
- }
-
- g_free(csd);
-}
-
static const char *const clck_cpwd_fac[] = {
[OFONO_SIM_PASSWORD_SIM_PIN] = "SC",
[OFONO_SIM_PASSWORD_SIM_PIN2] = "P2",
@@ -1215,28 +1198,6 @@ static void ril_pin_change_state(struct ofono_sim *sim,
struct cb_data *cbd;
struct parcel rilp;
- /*
- * If we want to unlock a password that has not been entered yet,
- * we enter it before trying to unlock. We need sd->unlock_pending as
- * the password still has not yet been refreshed when this function is
- * called from enter_pin_done().
- */
- if (ofono_sim_get_password_type(sim) == passwd_type
- && enable == FALSE && sd->unlock_pending == FALSE) {
- struct change_state_cbd *csd = g_malloc0(sizeof(*csd));
- csd->sim = sim;
- csd->passwd_type = passwd_type;
- csd->enable = enable;
- csd->passwd = passwd;
- csd->cb = cb;
- csd->data = data;
- sd->unlock_pending = TRUE;
-
- ril_pin_send(sim, passwd, enter_pin_done, csd);
-
- return;
- }
-
sd->unlock_pending = FALSE;
if (passwd_type >= ARRAY_SIZE(clck_cpwd_fac) ||
--
1.9.1
4 years, 6 months
[PATCH] sim: query facility during initialization in chain manner
by Samrat Guha Niyogi
query facility during initialization is modified from back
to back invocation to chain manner to keep it inline with
RIL design. All vendor RIL does not support back to back
handling since RIL telephony framework sends the request
synchronously.
---
src/sim.c | 42 ++++++++++++++++++++++++++----------------
1 file changed, 26 insertions(+), 16 deletions(-)
diff --git a/src/sim.c b/src/sim.c
index 6d9ed5d..0bbd1ef 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -2468,31 +2468,48 @@ static void sim_set_locked_pin(struct ofono_sim *sim,
g_strfreev(locked_pins);
}
-static void sim_query_fac_imsilock_cb(const struct ofono_error *error,
+static void sim_query_fac_pinlock_cb(const struct ofono_error *error,
ofono_bool_t status, void *data)
{
+ struct ofono_sim *sim = data;
+
if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
- return;
+ goto done;
- sim_set_locked_pin(data, OFONO_SIM_PASSWORD_PHSIM_PIN, status);
+ sim_set_locked_pin(data, OFONO_SIM_PASSWORD_SIM_PIN, status);
+
+done:
+ sim_initialize(sim);
}
static void sim_query_fac_networklock_cb(const struct ofono_error *error,
ofono_bool_t status, void *data)
{
+ struct ofono_sim *sim = data;
if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
- return;
+ goto done;
sim_set_locked_pin(data, OFONO_SIM_PASSWORD_PHNET_PIN, status);
+
+done:
+ sim->driver->query_facility_lock(sim,
+ OFONO_SIM_PASSWORD_SIM_PIN,
+ sim_query_fac_pinlock_cb, sim);
}
-static void sim_query_fac_pinlock_cb(const struct ofono_error *error,
+static void sim_query_fac_imsilock_cb(const struct ofono_error *error,
ofono_bool_t status, void *data)
{
+ struct ofono_sim *sim = data;
if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
- return;
+ goto done;
- sim_set_locked_pin(data, OFONO_SIM_PASSWORD_SIM_PIN, status);
+ sim_set_locked_pin(data, OFONO_SIM_PASSWORD_PHSIM_PIN, status);
+
+done:
+ sim->driver->query_facility_lock(sim,
+ OFONO_SIM_PASSWORD_PHNET_PIN,
+ sim_query_fac_networklock_cb, sim);
}
void ofono_sim_inserted_notify(struct ofono_sim *sim, ofono_bool_t inserted)
@@ -2526,16 +2543,9 @@ void ofono_sim_inserted_notify(struct ofono_sim *sim, ofono_bool_t inserted)
OFONO_SIM_PASSWORD_PHSIM_PIN,
sim_query_fac_imsilock_cb, sim);
- sim->driver->query_facility_lock(sim,
- OFONO_SIM_PASSWORD_PHNET_PIN,
- sim_query_fac_networklock_cb, sim);
-
- sim->driver->query_facility_lock(sim,
- OFONO_SIM_PASSWORD_SIM_PIN,
- sim_query_fac_pinlock_cb, sim);
+ } else {
+ sim_initialize(sim);
}
-
- sim_initialize(sim);
} else {
sim->pin_type = OFONO_SIM_PASSWORD_NONE;
--
1.9.1
4 years, 6 months