Re: [PATCH 1/1] SIM detection: Fixing the logical error in using the number of slot and number of application

2018-03-12 Thread Denis Kenzior

Hi,

On 03/12/2018 09:07 AM, Eswaran Vinothkumar (BEG/PJ-IOT-EL) wrote:

 From d1ec66c643f005d558c403a68c7df04b0819aa79 Mon Sep 17 00:00:00 2001

From: "Eswaran Vinothkumar (BEG-PT/PJ-IOT1)"



Date: Mon, 12 Mar 2018 14:46:28 +0100

Subject: [PATCH] sim detection: Fix to take the right slot and application

number

---

drivers/qmimodem/sim.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)



I can't apply this patch..

Could you please use git send-email and resubmit?

Regards,
-Denis
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


Re: LTE atom support for gemalto modem

2018-03-12 Thread Denis Kenzior

Hi Gabriel,

I've been having a look at the recent LTE atom. I've noticed there was 
no vendor-specific parameter when registering it. I think we might have 
some problem with the atmodem driver as in the 
AT+CGDCONT=,... command, the context-id starts from 0 on 
some modems and from 1 on other ones (I won't denounce gemalto).


Hah, that was obviously a mistake.  Not sure who let that past review 
stage ;)


Anyway, it is fixed now upstream.

Regards,
-Denis
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


[PATCH 1/1] SIM detection: Fixing the logical error in using the number of slot and number of application

2018-03-12 Thread Eswaran Vinothkumar (BEG/PJ-IOT-EL)
>From d1ec66c643f005d558c403a68c7df04b0819aa79 Mon Sep 17 00:00:00 2001
From: "Eswaran Vinothkumar (BEG-PT/PJ-IOT1)"

Date: Mon, 12 Mar 2018 14:46:28 +0100
Subject: [PATCH] sim detection: Fix to take the right slot and application
number

---
drivers/qmimodem/sim.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/qmimodem/sim.c b/drivers/qmimodem/sim.c
index 71c7e04..99c6d68 100644
--- a/drivers/qmimodem/sim.c
+++ b/drivers/qmimodem/sim.c
@@ -557,7 +557,7 @@ static enum get_card_status_result 
handle_get_card_status_result(
index = 
GUINT16_FROM_LE(status->index_gw_pri);
-   if ((index & 0xff) == i && (index >> 8) == 
n) {
+  if ((index & 0xff) == n && (index >> 8) == 
i) {
   if (get_card_status(slot, info1, 
info2,

   sim_stat))
   res = 
GET_CARD_STATUS_RESULT_TEMP_ERROR;
--
2.7.4

Mit freundlichen Grüßen / Best regards

Vinothkumar Eswaran
BEG-PT/PJ-IOT-EL

___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


Wierd behaviour of ofono on MC7455 and Verizon sim card

2018-03-12 Thread Eswaran Vinothkumar (BEG/PJ-IOT-EL)
Hi,

On 03/08/2018 11:47 AM, Eswaran Vinothkumar (BEG/PJ-IOT-EL) wrote:
> Mar 08 17:14:51 alen-eval-kit ofonod[175]: 
> ../ofono-1.22/drivers/qmimodem/devinfo.c:string_cb()
> Mar 08 17:14:51 alen-eval-kit ofonod[175]: 
> ../ofono-1.22/drivers/qmimodem/devinfo.c:qmi_query_serial()
> Mar 08 17:14:51 alen-eval-kit ofonod[175]: 
> ../ofono-1.22/drivers/qmimodem/sim.c:get_card_status_cb()
> Mar 08 17:14:51 alen-eval-kit ofonod[175]: 
> ../ofono-1.22/src/sim.c:ofono_sim_add_state_watch() 0x198d658

You would have to check the logic inside get_card_status_cb() to figure out why 
the sim isn't being detected.

Hi,

Thanks for the hint. I looked into the source code of ofono and had identified 
the condition on which the sim card detection logic fails. 

The function handle_get_card_status_result() returns failure.  The Verizon SIM 
I used has 4 application running. The output of qmicli is shown below:

# qmicli -d /dev/cdc-wdm1 --uim-get-card-status [/dev/cdc-wdm1] Successfully 
got card status Provisioning applications:
Primary GW:   slot '0', application '2'
Primary 1X:   slot '0', application '0'
Secondary GW: session doesn't exist
Secondary 1X: session doesn't exist Card [0]:
Card state: 'present'
UPIN state: 'not-initialized'
UPIN retries: '0'
UPUK retries: '0'
Application [0]:
Application type:  'csim (4)'
Application state: 'ready'
Application ID:
A0:00:00:03:43:10:02:F3:10:FF:FF:89:02:00:00:FF
Personalization state: 'ready'
UPIN replaces PIN1: 'no'
PIN1 state: 'disabled'
PIN1 retries: '3'
PUK1 retries: '10'
PIN2 state: 'enabled-not-verified'
PIN2 retries: '3'
PUK2 retries: '10'
Application [1]:
Application type:  'isim (5)'
Application state: 'detected'
Application ID:
A0:00:00:00:87:10:04:F3:10:FF:FF:89:08:00:00:FF
Personalization state: 'unknown'
UPIN replaces PIN1: 'no'
PIN1 state: 'not-initialized'
PIN1 retries: '0'
PUK1 retries: '0'
PIN2 state: 'not-initialized'
PIN2 retries: '0'
PUK2 retries: '0'
Application [2]:
Application type:  'usim (2)'
Application state: 'ready'
Application ID:
A0:00:00:00:87:10:02:F3:10:FF:FF:89:08:00:00:FF
Personalization state: 'ready'
UPIN replaces PIN1: 'no'
PIN1 state: 'disabled'
PIN1 retries: '3'
PUK1 retries: '10'
PIN2 state: 'enabled-not-verified'
PIN2 retries: '3'
PUK2 retries: '10'
Application [3]:
Application type:  'unknown (0)'
Application state: 'detected'
Application ID:
A0:00:00:00:63:50:4B:43:53:2D:31:35
Personalization state: 'unknown'
UPIN replaces PIN1: 'no'
PIN1 state: 'not-initialized'
PIN1 retries: '0'
PUK1 retries: '0'
PIN2 state: 'not-initialized'
PIN2 retries: '0'
PUK2 retries: '0'


The sim detection logic fails in the condition : 

if ((index & 0xff) == i && (index >> 8) == n) {
if (get_card_status(slot, info1, 
info2,sim_stat))
{
res = GET_CARD_STATUS_RESULT_TEMP_ERROR;
}
else
{
res = GET_CARD_STATUS_RESULT_OK;
}
}

In the condition check the slot number and application number is interchanged. 
After fixing this, I could see that ofono is successfully detecting the sim 
cards.

I will send a patch in my next e-mail

Attached the patch to fix this issue. Please integrate it to the ofono .

Regards,
-Denis


0001-sim-detection-Fix-to-take-the-right-slot-and-application.patch
Description: 0001-sim-detection-Fix-to-take-the-right-slot-and-application.patch
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


AW: Wierd behaviour of ofono on MC7455 and Verizon sim card

2018-03-12 Thread Eswaran Vinothkumar (BEG/PJ-IOT-EL)
Hi,

On 03/08/2018 11:47 AM, Eswaran Vinothkumar (BEG/PJ-IOT-EL) wrote:
> Mar 08 17:14:51 alen-eval-kit ofonod[175]:
> ../ofono-1.22/drivers/qmimodem/devinfo.c:string_cb()
> Mar 08 17:14:51 alen-eval-kit ofonod[175]:
> ../ofono-1.22/drivers/qmimodem/devinfo.c:qmi_query_serial()
> Mar 08 17:14:51 alen-eval-kit ofonod[175]:
> ../ofono-1.22/drivers/qmimodem/sim.c:get_card_status_cb()
> Mar 08 17:14:51 alen-eval-kit ofonod[175]:
> ../ofono-1.22/src/sim.c:ofono_sim_add_state_watch() 0x198d658

You would have to check the logic inside get_card_status_cb() to figure out why 
the sim isn't being detected.

Hi,

Thanks for the hint. I looked into the source code of ofono and had identified 
the condition on which the sim card detection logic fails.

The function handle_get_card_status_result() returns failure.  The Verizon SIM 
I used has 4 application running. The output of qmicli is shown below:

# qmicli -d /dev/cdc-wdm1 --uim-get-card-status
[/dev/cdc-wdm1] Successfully got card status
Provisioning applications:
Primary GW:   slot '0', application '2'
Primary 1X:   slot '0', application '0'
Secondary GW: session doesn't exist
Secondary 1X: session doesn't exist
Card [0]:
Card state: 'present'
UPIN state: 'not-initialized'
UPIN retries: '0'
UPUK retries: '0'
Application [0]:
Application type:  'csim (4)'
Application state: 'ready'
Application ID:
A0:00:00:03:43:10:02:F3:10:FF:FF:89:02:00:00:FF
Personalization state: 'ready'
UPIN replaces PIN1: 'no'
PIN1 state: 'disabled'
PIN1 retries: '3'
PUK1 retries: '10'
PIN2 state: 'enabled-not-verified'
PIN2 retries: '3'
PUK2 retries: '10'
Application [1]:
Application type:  'isim (5)'
Application state: 'detected'
Application ID:
A0:00:00:00:87:10:04:F3:10:FF:FF:89:08:00:00:FF
Personalization state: 'unknown'
UPIN replaces PIN1: 'no'
PIN1 state: 'not-initialized'
PIN1 retries: '0'
PUK1 retries: '0'
PIN2 state: 'not-initialized'
PIN2 retries: '0'
PUK2 retries: '0'
Application [2]:
Application type:  'usim (2)'
Application state: 'ready'
Application ID:
A0:00:00:00:87:10:02:F3:10:FF:FF:89:08:00:00:FF
Personalization state: 'ready'
UPIN replaces PIN1: 'no'
PIN1 state: 'disabled'
PIN1 retries: '3'
PUK1 retries: '10'
PIN2 state: 'enabled-not-verified'
PIN2 retries: '3'
PUK2 retries: '10'
Application [3]:
Application type:  'unknown (0)'
Application state: 'detected'
Application ID:
A0:00:00:00:63:50:4B:43:53:2D:31:35
Personalization state: 'unknown'
UPIN replaces PIN1: 'no'
PIN1 state: 'not-initialized'
PIN1 retries: '0'
PUK1 retries: '0'
PIN2 state: 'not-initialized'
PIN2 retries: '0'
PUK2 retries: '0'


The sim detection logic fails in the condition :

if ((index & 0xff) == i && (index >> 8) == n) {
if (get_card_status(slot, info1, 
info2,sim_stat))
{
res = GET_CARD_STATUS_RESULT_TEMP_ERROR;
}
else
{
res = GET_CARD_STATUS_RESULT_OK;
}
}

In the condition check the slot number and application number is interchanged. 
After fixing this, I could see that ofono is successfully detecting the sim 
cards.

I will send a patch in my next e-mail

Regards,
-Denis
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


LTE atom support for gemalto modem

2018-03-12 Thread Gabriel Lucas

Hi everyone,

First of all, sorry for having spammed the mailing list with last patch 
serie. I thought some hadn't been accepted. Some patches are from 
Mariem, a colleague, who wasn't in the subscribers before and she was in 
the cc: field.


I've been having a look at the recent LTE atom. I've noticed there was 
no vendor-specific parameter when registering it. I think we might have 
some problem with the atmodem driver as in the 
AT+CGDCONT=,... command, the context-id starts from 0 on 
some modems and from 1 on other ones (I won't denounce gemalto).


I think adding the vendor ID as a parameter might cause heavy 
modifications so I wanted to have your opinion on how to handle this 
case the simpliest way.


Best Regards,

Gabriel Lucas

___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


[PATCH 4/6] gemalto: handle sim is inserted or removed URCs

2018-03-12 Thread Gabriel Lucas
From: Mariem Cherif 

---
 plugins/gemalto.c | 37 +
 1 file changed, 37 insertions(+)

diff --git a/plugins/gemalto.c b/plugins/gemalto.c
index 16ca463..c7fb783 100644
--- a/plugins/gemalto.c
+++ b/plugins/gemalto.c
@@ -497,6 +497,36 @@ static void gemalto_set_online(struct ofono_modem *modem, 
ofono_bool_t online,
g_free(cbd);
 }
 
+static void gemalto_ciev_notify(GAtResult *result, gpointer user_data)
+{
+   struct ofono_sim *sim = user_data;
+   const char *sim_status = "simstatus";
+   const char *ind_str;
+   int status;
+   GAtResultIter iter;
+
+   g_at_result_iter_init(&iter, result);
+
+   if (!g_at_result_iter_next(&iter, "+CIEV:"))
+   return;
+
+   if (!g_at_result_iter_next_unquoted_string(&iter, &ind_str))
+   return;
+
+   if (!g_str_equal(sim_status, ind_str))
+   return;
+
+   if (!g_at_result_iter_next_number(&iter, &status))
+   return;
+
+   DBG("sim status %d", status);
+   if (status == 0) {
+   ofono_sim_inserted_notify(sim, FALSE);
+   } else if(status == 1) {
+   ofono_sim_inserted_notify(sim, TRUE);
+   }
+}
+
 static void gemalto_pre_sim(struct ofono_modem *modem)
 {
struct gemalto_data *data = ofono_modem_get_data(modem);
@@ -509,6 +539,13 @@ static void gemalto_pre_sim(struct ofono_modem *modem)
sim = ofono_sim_create(modem, OFONO_VENDOR_CINTERION, "atmodem",
data->app);
 
+   /* Register for specific sim status reports */
+   g_at_chat_register(data->app, "+CIEV:",
+   gemalto_ciev_notify, FALSE, sim, NULL);
+
+   g_at_chat_send(data->app, "AT^SIND=\"simstatus\",1", none_prefix,
+   NULL, NULL, NULL);
+
if (sim && data->have_sim == TRUE)
ofono_sim_inserted_notify(sim, TRUE);
 }
-- 
1.9.1

___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


[PATCH 3/6] gemalto: acquire the network technology

2018-03-12 Thread Gabriel Lucas
From: Mariem Cherif 

---
 drivers/atmodem/network-registration.c | 45 ++
 1 file changed, 45 insertions(+)

diff --git a/drivers/atmodem/network-registration.c 
b/drivers/atmodem/network-registration.c
index a5e2af3..aec9c2d 100644
--- a/drivers/atmodem/network-registration.c
+++ b/drivers/atmodem/network-registration.c
@@ -48,6 +48,7 @@ static const char *cops_prefix[] = { "+COPS:", NULL };
 static const char *csq_prefix[] = { "+CSQ:", NULL };
 static const char *cind_prefix[] = { "+CIND:", NULL };
 static const char *cmer_prefix[] = { "+CMER:", NULL };
+static const char *smoni_prefix[] = { "^SMONI:", "", NULL };
 static const char *zpas_prefix[] = { "+ZPAS:", NULL };
 static const char *option_tech_prefix[] = { "_OCTI:", "_OUWCTI:", NULL };
 
@@ -178,6 +179,32 @@ static int option_parse_tech(GAtResult *result)
return tech;
 }
 
+static int cinterion_parse_tech(GAtResult *result)
+{
+   int tech = -1;
+   GAtResultIter iter;
+   GSList *l;
+   g_at_result_iter_init(&iter, result);
+   l = result->lines;
+   if (strstr(l->data, "^SMONI: ") != NULL) {
+   gchar **body = g_strsplit(l->data, "^SMONI: ", 2);
+   if (*body != NULL) {
+   gchar **data = g_strsplit(body[1], ",", 20);
+   if (*data != NULL) {
+   if (g_strcmp0(data[0], "2G") == 0) {
+   tech = ACCESS_TECHNOLOGY_GSM;
+   } else if (g_strcmp0 (data[0], "3G") == 0) {
+   tech = ACCESS_TECHNOLOGY_UTRAN;
+   } else if (g_strcmp0 (data[0], "4G") == 0) {
+   tech = ACCESS_TECHNOLOGY_EUTRAN;
+   }
+   }
+   g_strfreev(body);
+   }
+   }
+   return tech;
+}
+
 static void at_creg_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
struct cb_data *cbd = user_data;
@@ -205,6 +232,18 @@ static void at_creg_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
cb(&error, status, lac, ci, tech, cbd->data);
 }
 
+static void cinterion_query_tech_cb(gboolean ok, GAtResult *result,
+  gpointer user_data)
+{
+   struct tech_query *tq = user_data;
+   int tech;
+
+   tech = cinterion_parse_tech(result);
+
+   ofono_netreg_status_notify(tq->netreg,
+   tq->status, tq->lac, tq->ci, tech);
+}
+
 static void zte_tech_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
struct cb_data *cbd = user_data;
@@ -1518,6 +1557,12 @@ static void creg_notify(GAtResult *result, gpointer 
user_data)
option_query_tech_cb, tq, g_free) > 0)
return;
break;
+case OFONO_VENDOR_CINTERION:
+  if (g_at_chat_send(nd->chat, "AT^SMONI",
+  smoni_prefix,
+  cinterion_query_tech_cb, tq, g_free) > 0)
+  return;
+  break;
}
 
g_free(tq);
-- 
1.9.1

___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


[PATCH 4/6] gemalto: handle sim is inserted or removed URCs

2018-03-12 Thread Gabriel Lucas
From: Mariem Cherif 

---
 plugins/gemalto.c | 37 +
 1 file changed, 37 insertions(+)

diff --git a/plugins/gemalto.c b/plugins/gemalto.c
index 16ca463..c7fb783 100644
--- a/plugins/gemalto.c
+++ b/plugins/gemalto.c
@@ -497,6 +497,36 @@ static void gemalto_set_online(struct ofono_modem *modem, 
ofono_bool_t online,
g_free(cbd);
 }
 
+static void gemalto_ciev_notify(GAtResult *result, gpointer user_data)
+{
+   struct ofono_sim *sim = user_data;
+   const char *sim_status = "simstatus";
+   const char *ind_str;
+   int status;
+   GAtResultIter iter;
+
+   g_at_result_iter_init(&iter, result);
+
+   if (!g_at_result_iter_next(&iter, "+CIEV:"))
+   return;
+
+   if (!g_at_result_iter_next_unquoted_string(&iter, &ind_str))
+   return;
+
+   if (!g_str_equal(sim_status, ind_str))
+   return;
+
+   if (!g_at_result_iter_next_number(&iter, &status))
+   return;
+
+   DBG("sim status %d", status);
+   if (status == 0) {
+   ofono_sim_inserted_notify(sim, FALSE);
+   } else if(status == 1) {
+   ofono_sim_inserted_notify(sim, TRUE);
+   }
+}
+
 static void gemalto_pre_sim(struct ofono_modem *modem)
 {
struct gemalto_data *data = ofono_modem_get_data(modem);
@@ -509,6 +539,13 @@ static void gemalto_pre_sim(struct ofono_modem *modem)
sim = ofono_sim_create(modem, OFONO_VENDOR_CINTERION, "atmodem",
data->app);
 
+   /* Register for specific sim status reports */
+   g_at_chat_register(data->app, "+CIEV:",
+   gemalto_ciev_notify, FALSE, sim, NULL);
+
+   g_at_chat_send(data->app, "AT^SIND=\"simstatus\",1", none_prefix,
+   NULL, NULL, NULL);
+
if (sim && data->have_sim == TRUE)
ofono_sim_inserted_notify(sim, TRUE);
 }
-- 
1.9.1

___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


[PATCH 3/6] gemalto: acquire the network technology

2018-03-12 Thread Gabriel Lucas
From: Mariem Cherif 

---
 drivers/atmodem/network-registration.c | 45 ++
 1 file changed, 45 insertions(+)

diff --git a/drivers/atmodem/network-registration.c 
b/drivers/atmodem/network-registration.c
index a5e2af3..aec9c2d 100644
--- a/drivers/atmodem/network-registration.c
+++ b/drivers/atmodem/network-registration.c
@@ -48,6 +48,7 @@ static const char *cops_prefix[] = { "+COPS:", NULL };
 static const char *csq_prefix[] = { "+CSQ:", NULL };
 static const char *cind_prefix[] = { "+CIND:", NULL };
 static const char *cmer_prefix[] = { "+CMER:", NULL };
+static const char *smoni_prefix[] = { "^SMONI:", "", NULL };
 static const char *zpas_prefix[] = { "+ZPAS:", NULL };
 static const char *option_tech_prefix[] = { "_OCTI:", "_OUWCTI:", NULL };
 
@@ -178,6 +179,32 @@ static int option_parse_tech(GAtResult *result)
return tech;
 }
 
+static int cinterion_parse_tech(GAtResult *result)
+{
+   int tech = -1;
+   GAtResultIter iter;
+   GSList *l;
+   g_at_result_iter_init(&iter, result);
+   l = result->lines;
+   if (strstr(l->data, "^SMONI: ") != NULL) {
+   gchar **body = g_strsplit(l->data, "^SMONI: ", 2);
+   if (*body != NULL) {
+   gchar **data = g_strsplit(body[1], ",", 20);
+   if (*data != NULL) {
+   if (g_strcmp0(data[0], "2G") == 0) {
+   tech = ACCESS_TECHNOLOGY_GSM;
+   } else if (g_strcmp0 (data[0], "3G") == 0) {
+   tech = ACCESS_TECHNOLOGY_UTRAN;
+   } else if (g_strcmp0 (data[0], "4G") == 0) {
+   tech = ACCESS_TECHNOLOGY_EUTRAN;
+   }
+   }
+   g_strfreev(body);
+   }
+   }
+   return tech;
+}
+
 static void at_creg_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
struct cb_data *cbd = user_data;
@@ -205,6 +232,18 @@ static void at_creg_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
cb(&error, status, lac, ci, tech, cbd->data);
 }
 
+static void cinterion_query_tech_cb(gboolean ok, GAtResult *result,
+  gpointer user_data)
+{
+   struct tech_query *tq = user_data;
+   int tech;
+
+   tech = cinterion_parse_tech(result);
+
+   ofono_netreg_status_notify(tq->netreg,
+   tq->status, tq->lac, tq->ci, tech);
+}
+
 static void zte_tech_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
struct cb_data *cbd = user_data;
@@ -1518,6 +1557,12 @@ static void creg_notify(GAtResult *result, gpointer 
user_data)
option_query_tech_cb, tq, g_free) > 0)
return;
break;
+case OFONO_VENDOR_CINTERION:
+  if (g_at_chat_send(nd->chat, "AT^SMONI",
+  smoni_prefix,
+  cinterion_query_tech_cb, tq, g_free) > 0)
+  return;
+  break;
}
 
g_free(tq);
-- 
1.9.1

___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


[PATCH 5/6] sim: give access to the driver

2018-03-12 Thread Gabriel Lucas
---
 include/sim.h | 2 ++
 src/sim.c | 5 +
 2 files changed, 7 insertions(+)

diff --git a/include/sim.h b/include/sim.h
index fad4c0d..cf679db 100644
--- a/include/sim.h
+++ b/include/sim.h
@@ -217,6 +217,8 @@ struct ofono_sim *ofono_sim_create(struct ofono_modem 
*modem,
 void ofono_sim_register(struct ofono_sim *sim);
 void ofono_sim_remove(struct ofono_sim *sim);
 
+const struct ofono_sim_driver* ofono_sim_get_driver(struct ofono_sim *sim);
+
 void ofono_sim_set_data(struct ofono_sim *sim, void *data);
 void *ofono_sim_get_data(struct ofono_sim *sim);
 
diff --git a/src/sim.c b/src/sim.c
index eb9f56a..f56706f 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -3305,6 +3305,11 @@ void ofono_sim_remove(struct ofono_sim *sim)
__ofono_atom_free(sim->atom);
 }
 
+const struct ofono_sim_driver* ofono_sim_get_driver(struct ofono_sim *sim)
+{
+   return sim->driver;
+}
+
 void ofono_sim_set_data(struct ofono_sim *sim, void *data)
 {
sim->driver_data = data;
-- 
1.9.1

___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


[PATCH 0/6] gemalto's ALS3 and PHS8P support

2018-03-12 Thread Gabriel Lucas
This patch serie bring further support to PHS8P modem
and the same level of support for ALS3 modem. Here are
the lists on enhancements:
- ALS3 is detected by Ofono and uses the gemalto plugin
- SIM removing and insertion is supported
- The optional Technology property on NetworkRegistration
is supported
- We ensure that the modem is ready to work before
initializing it

Some of the enhancements are brought by workarounds because
of AT command interface limitations

Gabriel Lucas (4):
  gemalto: add detection of ALS3 modem
  gemalto: support ALS3 in gemalto's plugin
  sim: give access to the driver
  gemalto: fix sim reinsertion issue

Mariem Cherif (2):
  gemalto: acquire the network technology
  gemalto: handle sim is inserted or removed URCs

 drivers/atmodem/network-registration.c |  45 +
 include/sim.h  |   2 +
 plugins/gemalto.c  | 169 +++--
 plugins/udevng.c   |  18 
 src/sim.c  |   5 +
 5 files changed, 233 insertions(+), 6 deletions(-)

-- 
1.9.1

___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


[PATCH 6/6] gemalto: fix sim reinsertion issue

2018-03-12 Thread Gabriel Lucas
When the SIM card is reinserted in the holder,
the IRC +CIEV: simstatus,1 is emitted. The problem
is that the SIM isn't ready when it is received.
Hence, Ofono fails on CPIN? command and the modem
cannot be used. This patch make ofono retry the
CPIN? command until it succeeds.
---
 plugins/gemalto.c | 29 -
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/plugins/gemalto.c b/plugins/gemalto.c
index c7fb783..caa5912 100644
--- a/plugins/gemalto.c
+++ b/plugins/gemalto.c
@@ -497,6 +497,33 @@ static void gemalto_set_online(struct ofono_modem *modem, 
ofono_bool_t online,
g_free(cbd);
 }
 
+static void sim_pin_query_cb(const struct ofono_error *error,
+   enum ofono_sim_password_type pin_type,
+   void *data);
+
+static void gemalto_wait_after_plug(struct ofono_sim *sim) {
+   ofono_sim_get_driver(sim)->query_passwd_state(sim, sim_pin_query_cb, 
sim);
+}
+
+static gboolean cpin_timeout(gpointer sim) {
+   gemalto_wait_after_plug(sim);
+
+   return FALSE;
+}
+
+static void sim_pin_query_cb(const struct ofono_error *error,
+   enum ofono_sim_password_type pin_type,
+   void *data) {
+   struct ofono_sim *sim = data;
+
+   if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+   g_timeout_add(50, cpin_timeout, sim);
+   }
+   else {
+   ofono_sim_inserted_notify(sim, TRUE);
+   }
+}
+
 static void gemalto_ciev_notify(GAtResult *result, gpointer user_data)
 {
struct ofono_sim *sim = user_data;
@@ -523,7 +550,7 @@ static void gemalto_ciev_notify(GAtResult *result, gpointer 
user_data)
if (status == 0) {
ofono_sim_inserted_notify(sim, FALSE);
} else if(status == 1) {
-   ofono_sim_inserted_notify(sim, TRUE);
+   gemalto_wait_after_plug(sim);
}
 }
 
-- 
1.9.1

___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


[PATCH 2/6] gemalto: support ALS3 in gemalto's plugin

2018-03-12 Thread Gabriel Lucas
Force serial port opening options
Wait for modem to be ready to start
initializing it
Handle LTE
---
 plugins/gemalto.c | 105 ++
 1 file changed, 99 insertions(+), 6 deletions(-)

diff --git a/plugins/gemalto.c b/plugins/gemalto.c
index 3739d7b..16ca463 100644
--- a/plugins/gemalto.c
+++ b/plugins/gemalto.c
@@ -53,6 +53,10 @@
 
 #define HARDWARE_MONITOR_INTERFACE OFONO_SERVICE ".cinterion.HardwareMonitor"
 
+// Supported gemalto's modem
+#define GEMALTO_MODEL_PHS8P"0053"
+#define GEMALTO_MODEL_ALS3 "0061"
+
 static const char *none_prefix[] = { NULL };
 static const char *sctm_prefix[] = { "^SCTM:", NULL };
 static const char *sbv_prefix[] = { "^SBV:", NULL };
@@ -70,6 +74,8 @@ struct gemalto_data {
gboolean have_sim;
struct at_util_sim_state_query *sim_state_query;
struct gemalto_hardware_monitor *hm;
+   guint modem_ready_id;
+   guint trial_cmd_id;
 };
 
 static int gemalto_probe(struct ofono_modem *modem)
@@ -107,10 +113,24 @@ static GAtChat *open_device(const char *device)
GAtSyntax *syntax;
GIOChannel *channel;
GAtChat *chat;
+   GHashTable *options;
+
+   options = g_hash_table_new(g_str_hash, g_str_equal);
+   if (options == NULL)
+   return NULL;
+
+   g_hash_table_insert(options, "Baud", "115200");
+   g_hash_table_insert(options, "StopBits", "1");
+   g_hash_table_insert(options, "DataBits", "8");
+   g_hash_table_insert(options, "Parity", "none");
+   g_hash_table_insert(options, "XonXoff", "off");
+   g_hash_table_insert(options, "RtsCts", "on");
+   g_hash_table_insert(options, "Local", "on");
+   g_hash_table_insert(options, "Read", "on");
 
DBG("Opening device %s", device);
 
-   channel = g_at_tty_open(device, NULL);
+   channel = g_at_tty_open(device, options);
if (channel == NULL)
return NULL;
 
@@ -118,6 +138,7 @@ static GAtChat *open_device(const char *device)
chat = g_at_chat_new(channel, syntax);
g_at_syntax_unref(syntax);
g_io_channel_unref(channel);
+   g_hash_table_unref(options);
 
if (chat == NULL)
return NULL;
@@ -300,29 +321,33 @@ static int gemalto_hardware_monitor_enable(struct 
ofono_modem *modem)
return 0;
 }
 
-static int gemalto_enable(struct ofono_modem *modem)
+static void gemalto_initialize(struct ofono_modem *modem)
 {
struct gemalto_data *data = ofono_modem_get_data(modem);
const char *app, *mdm;
 
-   DBG("%p", modem);
+   /* Close devices */
+   g_at_chat_unref(data->mdm);
+   g_at_chat_unref(data->app);
+
+   DBG("");
 
app = ofono_modem_get_string(modem, "Application");
mdm = ofono_modem_get_string(modem, "Modem");
 
if (app == NULL || mdm == NULL)
-   return -EINVAL;
+   return;
 
/* Open devices */
data->app = open_device(app);
if (data->app == NULL)
-   return -EINVAL;
+   return;
 
data->mdm = open_device(mdm);
if (data->mdm == NULL) {
g_at_chat_unref(data->app);
data->app = NULL;
-   return -EINVAL;
+   return;
}
 
if (getenv("OFONO_AT_DEBUG")) {
@@ -340,6 +365,67 @@ static int gemalto_enable(struct ofono_modem *modem)
cfun_enable, modem, NULL);
 
gemalto_hardware_monitor_enable(modem);
+}
+
+static void gemalto_modem_ready(GAtResult *result, gpointer user_data)
+{
+   struct ofono_modem *modem = user_data;
+   struct gemalto_data *data = ofono_modem_get_data(modem);
+
+   DBG("");
+
+   g_at_chat_unregister(data->app, data->modem_ready_id);
+   g_at_chat_cancel(data->app, data->trial_cmd_id);
+
+   gemalto_initialize(modem);
+}
+
+static void gemalto_at_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   struct ofono_modem *modem = user_data;
+   struct gemalto_data *data = ofono_modem_get_data(modem);
+
+   g_at_chat_unregister(data->app, data->modem_ready_id);
+   gemalto_initialize(modem);
+}
+
+static gboolean gemalto_at_timeout(gpointer user_data)
+{
+   struct ofono_modem *modem = user_data;
+   struct gemalto_data *data = ofono_modem_get_data(modem);
+
+   data->trial_cmd_id = g_at_chat_send(data->app, "AT+CFUN?", none_prefix, 
gemalto_at_cb, modem, NULL);
+
+   return FALSE;
+}
+
+static int gemalto_enable(struct ofono_modem *modem)
+{
+   struct gemalto_data *data = ofono_modem_get_data(modem);
+   const char *app, *mdm;
+
+   DBG("%p", modem);
+
+   app = ofono_modem_get_string(modem, "Application");
+   mdm = ofono_modem_get_string(modem, "Modem");
+
+   if (app == NULL || mdm == NULL)
+   return -EINVAL;
+
+   /* Open devices */
+   data->app = open_device(app);
+   if (data->app == NULL)
+   return

[PATCH 3/6] gemalto: acquire the network technology

2018-03-12 Thread Gabriel Lucas
From: Mariem Cherif 

---
 drivers/atmodem/network-registration.c | 45 ++
 1 file changed, 45 insertions(+)

diff --git a/drivers/atmodem/network-registration.c 
b/drivers/atmodem/network-registration.c
index a5e2af3..aec9c2d 100644
--- a/drivers/atmodem/network-registration.c
+++ b/drivers/atmodem/network-registration.c
@@ -48,6 +48,7 @@ static const char *cops_prefix[] = { "+COPS:", NULL };
 static const char *csq_prefix[] = { "+CSQ:", NULL };
 static const char *cind_prefix[] = { "+CIND:", NULL };
 static const char *cmer_prefix[] = { "+CMER:", NULL };
+static const char *smoni_prefix[] = { "^SMONI:", "", NULL };
 static const char *zpas_prefix[] = { "+ZPAS:", NULL };
 static const char *option_tech_prefix[] = { "_OCTI:", "_OUWCTI:", NULL };
 
@@ -178,6 +179,32 @@ static int option_parse_tech(GAtResult *result)
return tech;
 }
 
+static int cinterion_parse_tech(GAtResult *result)
+{
+   int tech = -1;
+   GAtResultIter iter;
+   GSList *l;
+   g_at_result_iter_init(&iter, result);
+   l = result->lines;
+   if (strstr(l->data, "^SMONI: ") != NULL) {
+   gchar **body = g_strsplit(l->data, "^SMONI: ", 2);
+   if (*body != NULL) {
+   gchar **data = g_strsplit(body[1], ",", 20);
+   if (*data != NULL) {
+   if (g_strcmp0(data[0], "2G") == 0) {
+   tech = ACCESS_TECHNOLOGY_GSM;
+   } else if (g_strcmp0 (data[0], "3G") == 0) {
+   tech = ACCESS_TECHNOLOGY_UTRAN;
+   } else if (g_strcmp0 (data[0], "4G") == 0) {
+   tech = ACCESS_TECHNOLOGY_EUTRAN;
+   }
+   }
+   g_strfreev(body);
+   }
+   }
+   return tech;
+}
+
 static void at_creg_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
struct cb_data *cbd = user_data;
@@ -205,6 +232,18 @@ static void at_creg_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
cb(&error, status, lac, ci, tech, cbd->data);
 }
 
+static void cinterion_query_tech_cb(gboolean ok, GAtResult *result,
+  gpointer user_data)
+{
+   struct tech_query *tq = user_data;
+   int tech;
+
+   tech = cinterion_parse_tech(result);
+
+   ofono_netreg_status_notify(tq->netreg,
+   tq->status, tq->lac, tq->ci, tech);
+}
+
 static void zte_tech_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
struct cb_data *cbd = user_data;
@@ -1518,6 +1557,12 @@ static void creg_notify(GAtResult *result, gpointer 
user_data)
option_query_tech_cb, tq, g_free) > 0)
return;
break;
+case OFONO_VENDOR_CINTERION:
+  if (g_at_chat_send(nd->chat, "AT^SMONI",
+  smoni_prefix,
+  cinterion_query_tech_cb, tq, g_free) > 0)
+  return;
+  break;
}
 
g_free(tq);
-- 
1.9.1

___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


[PATCH 4/6] gemalto: handle sim is inserted or removed URCs

2018-03-12 Thread Gabriel Lucas
From: Mariem Cherif 

---
 plugins/gemalto.c | 37 +
 1 file changed, 37 insertions(+)

diff --git a/plugins/gemalto.c b/plugins/gemalto.c
index 16ca463..c7fb783 100644
--- a/plugins/gemalto.c
+++ b/plugins/gemalto.c
@@ -497,6 +497,36 @@ static void gemalto_set_online(struct ofono_modem *modem, 
ofono_bool_t online,
g_free(cbd);
 }
 
+static void gemalto_ciev_notify(GAtResult *result, gpointer user_data)
+{
+   struct ofono_sim *sim = user_data;
+   const char *sim_status = "simstatus";
+   const char *ind_str;
+   int status;
+   GAtResultIter iter;
+
+   g_at_result_iter_init(&iter, result);
+
+   if (!g_at_result_iter_next(&iter, "+CIEV:"))
+   return;
+
+   if (!g_at_result_iter_next_unquoted_string(&iter, &ind_str))
+   return;
+
+   if (!g_str_equal(sim_status, ind_str))
+   return;
+
+   if (!g_at_result_iter_next_number(&iter, &status))
+   return;
+
+   DBG("sim status %d", status);
+   if (status == 0) {
+   ofono_sim_inserted_notify(sim, FALSE);
+   } else if(status == 1) {
+   ofono_sim_inserted_notify(sim, TRUE);
+   }
+}
+
 static void gemalto_pre_sim(struct ofono_modem *modem)
 {
struct gemalto_data *data = ofono_modem_get_data(modem);
@@ -509,6 +539,13 @@ static void gemalto_pre_sim(struct ofono_modem *modem)
sim = ofono_sim_create(modem, OFONO_VENDOR_CINTERION, "atmodem",
data->app);
 
+   /* Register for specific sim status reports */
+   g_at_chat_register(data->app, "+CIEV:",
+   gemalto_ciev_notify, FALSE, sim, NULL);
+
+   g_at_chat_send(data->app, "AT^SIND=\"simstatus\",1", none_prefix,
+   NULL, NULL, NULL);
+
if (sim && data->have_sim == TRUE)
ofono_sim_inserted_notify(sim, TRUE);
 }
-- 
1.9.1

___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


[PATCH 1/6] gemalto: add detection of ALS3 modem

2018-03-12 Thread Gabriel Lucas
The product ID is added to the list of
modems to be detected by Ofono.
The gemalto plugin is used to handle the
ALS3 modem.
---
 plugins/udevng.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/plugins/udevng.c b/plugins/udevng.c
index 3c7d99e..d398c6e 100644
--- a/plugins/udevng.c
+++ b/plugins/udevng.c
@@ -1132,6 +1132,7 @@ static gboolean setup_gemalto(struct modem_info* modem)
DBG("%s %s %s %s %s", info->devnode, info->interface,
info->number, info->label, info->subsystem);
 
+   // PHS8-P
if (g_strcmp0(info->interface, "255/255/255") == 0) {
if (g_strcmp0(info->number, "01") == 0)
gps = info->devnode;
@@ -1144,6 +1145,20 @@ static gboolean setup_gemalto(struct modem_info* modem)
else if (g_strcmp0(info->subsystem, "usbmisc") == 0)
qmi = info->devnode;
}
+
+   // ALS3
+   if (g_strcmp0(info->interface, "2/2/1") == 0) {
+   if (g_strcmp0(info->number, "00") == 0)
+   mdm = info->devnode;
+   else if (g_strcmp0(info->number, "02") == 0)
+   app = info->devnode;
+   else if (g_strcmp0(info->number, "04") == 0)
+   gps = info->devnode;
+   }
+   if (g_strcmp0(info->interface, "2/6/0") == 0) {
+   if (g_strcmp0(info->subsystem, "net") == 0)
+   net = info->devnode;
+   }
}
 
DBG("application=%s gps=%s modem=%s network=%s qmi=%s",
@@ -1156,6 +1171,7 @@ static gboolean setup_gemalto(struct modem_info* modem)
ofono_modem_set_string(modem->modem, "GPS", gps);
ofono_modem_set_string(modem->modem, "Modem", mdm);
ofono_modem_set_string(modem->modem, "Device", qmi);
+   ofono_modem_set_string(modem->modem, "Model", modem->model);
ofono_modem_set_string(modem->modem, "NetworkInterface", net);
 
return TRUE;
@@ -1601,6 +1617,8 @@ static struct {
{ "gemalto","option",   "1e2d", "0053"  },
{ "gemalto","cdc_wdm",  "1e2d", "0053"  },
{ "gemalto","qmi_wwan", "1e2d", "0053"  },
+   { "gemalto","cdc_acm",  "1e2d", "0061"  },
+   { "gemalto","cdc_ether","1e2d", "0061"  },
{ "telit",  "cdc_ncm",  "1bc7", "0036"  },
{ "telit",  "cdc_acm",  "1bc7", "0036"  },
{ "xmm7xxx","cdc_acm",  "8087", "0930"  },
-- 
1.9.1

___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono