[RFC PATCH 2/2] plugin: gemalto: enable netmon

2021-01-10 Thread Sergey Matyukevich
Enable netmon functionality for Gemalto ELS81x modems.
---
 plugins/gemalto.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/plugins/gemalto.c b/plugins/gemalto.c
index 28ee3aff..135e2d26 100644
--- a/plugins/gemalto.c
+++ b/plugins/gemalto.c
@@ -48,6 +48,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -622,6 +623,7 @@ static void gemalto_post_sim(struct ofono_modem *modem)
 static void gemalto_post_online(struct ofono_modem *modem)
 {
struct gemalto_data *data = ofono_modem_get_data(modem);
+   const char *model = ofono_modem_get_string(modem, "Model");
 
DBG("%p", modem);
 
@@ -634,6 +636,10 @@ static void gemalto_post_online(struct ofono_modem *modem)
ofono_call_settings_create(modem, 0, "atmodem", data->app);
ofono_call_meter_create(modem, 0, "atmodem", data->app);
ofono_call_barring_create(modem, 0, "atmodem", data->app);
+
+   if (!g_strcmp0(model, GEMALTO_MODEL_ELS81x))
+   ofono_netmon_create(modem, OFONO_VENDOR_GEMALTO,
+   "gemaltomodem", data->app);
 }
 
 static struct ofono_modem_driver gemalto_driver = {
___
ofono mailing list -- ofono@ofono.org
To unsubscribe send an email to ofono-le...@ofono.org


[RFC PATCH 1/2] gemalto: add netmon driver

2021-01-10 Thread Sergey Matyukevich
Implement network monitoring driver for gemalto modems that
are able to provide serving cell information and basic
measurements using AT+CQS and AT^SMONI commands.
---
 Makefile.am |   3 +-
 drivers/gemaltomodem/gemaltomodem.c |   2 +
 drivers/gemaltomodem/gemaltomodem.h |   3 +
 drivers/gemaltomodem/netmon.c   | 609 
 4 files changed, 616 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gemaltomodem/netmon.c

diff --git a/Makefile.am b/Makefile.am
index c0631081..5e7614c1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -483,7 +483,8 @@ builtin_sources += drivers/atmodem/atutil.h \
drivers/gemaltomodem/gemaltomodem.c \
drivers/gemaltomodem/location-reporting.c \
drivers/gemaltomodem/voicecall.c \
-   drivers/gemaltomodem/gprs-context.c
+   drivers/gemaltomodem/gprs-context.c \
+   drivers/gemaltomodem/netmon.c
 
 builtin_modules += xmm7modem
 builtin_sources += drivers/atmodem/atutil.h \
diff --git a/drivers/gemaltomodem/gemaltomodem.c 
b/drivers/gemaltomodem/gemaltomodem.c
index 4b20dd1b..f7e4ff3e 100644
--- a/drivers/gemaltomodem/gemaltomodem.c
+++ b/drivers/gemaltomodem/gemaltomodem.c
@@ -38,6 +38,7 @@ static int gemaltomodem_init(void)
gemalto_location_reporting_init();
gemalto_gprs_context_init();
gemalto_voicecall_init();
+   gemalto_netmon_init();
 
return 0;
 }
@@ -47,6 +48,7 @@ static void gemaltomodem_exit(void)
gemalto_location_reporting_exit();
gemalto_gprs_context_exit();
gemalto_voicecall_exit();
+   gemalto_netmon_exit();
 }
 
 OFONO_PLUGIN_DEFINE(gemaltomodem, "Gemalto modem driver", VERSION,
diff --git a/drivers/gemaltomodem/gemaltomodem.h 
b/drivers/gemaltomodem/gemaltomodem.h
index dc0d346b..ae8f2141 100644
--- a/drivers/gemaltomodem/gemaltomodem.h
+++ b/drivers/gemaltomodem/gemaltomodem.h
@@ -30,3 +30,6 @@ extern void gemalto_voicecall_exit();
 
 extern void gemalto_gprs_context_init();
 extern void gemalto_gprs_context_exit();
+
+extern void gemalto_netmon_init(void);
+extern void gemalto_netmon_exit(void);
diff --git a/drivers/gemaltomodem/netmon.c b/drivers/gemaltomodem/netmon.c
new file mode 100644
index ..93e6d02f
--- /dev/null
+++ b/drivers/gemaltomodem/netmon.c
@@ -0,0 +1,609 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include 
+#endif
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include "gatchat.h"
+#include "gatresult.h"
+
+#include "common.h"
+#include "gemaltomodem.h"
+#include "drivers/atmodem/vendor.h"
+
+static const char *smoni_prefix[] = { "^SMONI:", NULL };
+static const char *csq_prefix[] = { "+CSQ:", NULL };
+
+struct netmon_driver_data {
+   GAtChat *chat;
+};
+
+struct req_cb_data {
+   gint ref_count; /* Ref count */
+
+   struct ofono_netmon *netmon;
+   ofono_netmon_cb_t cb;
+   void *data;
+
+   struct ofono_network_operator op;
+
+   int rssi;   /* CSQ: received signal strength indicator (RSSI) */
+
+   union {
+   struct {
+   int arfcn;  /* SMONI: Absolute Radio Frequency 
Channel Number */
+   int bcch;   /* SMONI: Receiving level of the BCCH 
carrier in dBm */
+   int lac;/* SMONI: Location Area Code */
+   int ci; /* SMONI: Cell ID */
+   } gsm;
+   struct {
+   int uarfcn; /* SMONI: UTRAN Absolute Radio 
Frequency Channel Number */
+   int psc;/* SMONI: Primary Scrambling Code */
+   int ecn0;   /* SMONI: Carrier to noise ratio in dB 
*/
+   int rscp;   /* SMONI: Received Signal Code Power in 
dBm */
+   int lac;/* SMONI: Location Area Code */
+   int ci; /* SMONI: Cell ID */
+   } umts;
+   struct {
+   int euarfcn;/* SMONI: E-UTRA Absolute Radio 
Frequency Channel Number */
+   int rsrp;   /* SMONI: Reference Signal 

[RFC PATCH 0/2] gemalto: netmon driver

2021-01-10 Thread Sergey Matyukevich
Hello Denis and all,

This patch series implements netmon driver for gemalto modems that are
able to provide basic measurements using AT+CQS and AT^SMONI commands.

This patch series is intendedly marked as RFC. In addition to general
feedback for this v1 I would like to clarify the right way to handle
negative values that can be returned by modem. For instance, this
is the case for the values measured in dBm including EC/n0 and RSCP.
Currently such values are discarded by CELL_INFO_DICT_APPEND macro.

Regards,
Sergey


Sergey Matyukevich (2):
  gemalto: add netmon driver
  plugin: gemalto: enable netmon

 Makefile.am |   3 +-
 drivers/gemaltomodem/gemaltomodem.c |   2 +
 drivers/gemaltomodem/gemaltomodem.h |   3 +
 drivers/gemaltomodem/netmon.c   | 609 
 plugins/gemalto.c   |   6 +
 5 files changed, 622 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gemaltomodem/netmon.c
___
ofono mailing list -- ofono@ofono.org
To unsubscribe send an email to ofono-le...@ofono.org