Re: [PATCH v3 7/7] test: support OFONO_NETMON_INFO_{RXLEV|RSCP|ECN0|RSRQ|RSRP}

2016-11-30 Thread Denis Kenzior

Hi Djalal,

On 11/30/2016 06:31 AM, Djalal Harouni wrote:

Display the following fields if they are returned.

RXLEV:  Received Signal Strength
RSCP:   Received Signal Code Power
ECN0:   Received Energy Ratio
RSRQ:   Reference Signal Received Quality
RSRP:   Reference Signal Received Power
---
  test/get-serving-cell-info | 20 
  1 file changed, 20 insertions(+)



Applied, thanks.

Regards,
-Denis


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


Re: [PATCH v3 4/7] ubloxmodem: add the netmon driver

2016-11-30 Thread Denis Kenzior

Hi Djalal,

On 11/30/2016 06:31 AM, Djalal Harouni wrote:

This adds a netmon driver for ublox. The driver support both +COPS and
+CESQ commands to return the previously added ofono netmon types:

RSCP: Received Signal Code Power
ECN0: Received Energy Ratio
RSRQ: Reference Signal Received Quality
RSRP: Reference Signal Received Power
---
  drivers/ubloxmodem/netmon.c | 336 
  drivers/ubloxmodem/ubloxmodem.c |   2 +
  drivers/ubloxmodem/ubloxmodem.h |   3 +
  3 files changed, 341 insertions(+)
  create mode 100644 drivers/ubloxmodem/netmon.c

diff --git a/drivers/ubloxmodem/netmon.c b/drivers/ubloxmodem/netmon.c
new file mode 100644
index 000..e5adf59
--- /dev/null
+++ b/drivers/ubloxmodem/netmon.c
@@ -0,0 +1,336 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2016  EndoCode AG. All rights reserved.
+ *
+ *  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
+
+#define _GNU_SOURCE
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+#include "gatchat.h"
+#include "gatresult.h"
+
+#include "common.h"
+#include "netreg.h"


This should probably be  and moved up above.


+#include "ubloxmodem.h"
+#include "drivers/atmodem/vendor.h"
+
+static const char *cops_prefix[] = { "+COPS:", NULL };
+static const char *cesq_prefix[] = { "+CESQ:", NULL };
+
+struct netmon_driver_data {
+   GAtChat *chat;
+};
+
+struct req_cb_data {
+   struct ofono_netmon *netmon;
+
+   ofono_netmon_cb_t cb;
+   void *data;
+
+   struct ofono_network_operator op;
+
+   int rxlev;  /* CESQ: Received Signal Strength Indication */
+   int ber;/* CESQ: Bit Error Rate */
+   int rscp;   /* CESQ: Received Signal Code Powe */
+   int rsrp;   /* CESQ: Reference Signal Received Power */
+   int ecn0;   /* CESQ: Received Energy Ratio */
+   int rsrq;   /* CESQ: Reference Signal Received Quality */
+};
+
+/*
+ * Returns the appropriate radio access technology.
+ *
+ * If we can not resolve to a specific radio access technolgy
+ * we return OFONO_NETMON_CELL_TYPE_GSM by default.
+ */
+static int ublox_map_radio_access_technology(int tech)
+{
+   switch (tech) {
+   case ACCESS_TECHNOLOGY_GSM:
+   case ACCESS_TECHNOLOGY_GSM_COMPACT:
+   return OFONO_NETMON_CELL_TYPE_GSM;
+   case ACCESS_TECHNOLOGY_UTRAN:
+   case ACCESS_TECHNOLOGY_UTRAN_HSDPA:
+   case ACCESS_TECHNOLOGY_UTRAN_HSUPA:
+   case ACCESS_TECHNOLOGY_UTRAN_HSDPA_HSUPA:
+   return OFONO_NETMON_CELL_TYPE_UMTS;
+   case ACCESS_TECHNOLOGY_EUTRAN:
+   return OFONO_NETMON_CELL_TYPE_LTE;
+   }
+
+   return OFONO_NETMON_CELL_TYPE_GSM;
+}
+
+static inline struct req_cb_data *req_cb_data_new0(void *cb, void *data, void 
*user)


This line > 80 chars


+{
+   struct req_cb_data *ret = g_new0(struct req_cb_data, 1);


g_new0 cannot fail.  g_try_new0 can, but its not useful in this case. 
I'd just keep g_new0 and skip the ret checking below, as well as inside 
request_update()



+   if (ret == NULL)
+   return NULL;
+
+   ret->cb = cb;
+   ret->data = data;
+   ret->netmon = user;
+   ret->rxlev = -1;
+   ret->ber = -1;
+   ret->rscp = -1;
+   ret->rsrp = -1;
+   ret->ecn0 = -1;
+   ret->rsrq = -1;
+
+   return ret;
+}
+
+static gboolean ublox_delayed_register(gpointer user_data)
+{
+   struct ofono_netmon *netmon = user_data;
+
+   ofono_netmon_register(netmon);
+
+   return FALSE;
+}
+
+static void ublox_netmon_finish_success(struct req_cb_data *cbd)
+{
+   struct ofono_netmon *nm = cbd->netmon;
+
+   ofono_netmon_serving_cell_notify(nm,
+cbd->op.tech,
+OFONO_NETMON_INFO_RXLEV, cbd->rxlev,
+OFONO_NETMON_INFO_BER, cbd->ber,
+OFONO_NETMON_INFO_RSCP, cbd->rscp,
+OFONO_NETMON_INFO_ECN0, cbd->ecn0,
+OFONO_NETMON_INFO_RSRQ, cbd->rsrq,
+OFONO_NETMON_INFO_RSRP, cbd->rsrp,
+

Re: [PATCH v3 2/7] netmon: handle OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP} in D-Bus

2016-11-30 Thread Denis Kenzior

Hi Djalal,

On 11/30/2016 06:31 AM, Djalal Harouni wrote:

Handle the previously added types in D-Bus.

Documentation for these values is in next patch.
---
  src/netmon.c | 28 
  1 file changed, 28 insertions(+)



Tweaked the commit description and ...


diff --git a/src/netmon.c b/src/netmon.c
index eb18b9c..2a8c524 100644
--- a/src/netmon.c
+++ b/src/netmon.c
@@ -180,6 +180,34 @@ void ofono_netmon_serving_cell_notify(struct ofono_netmon 
*netmon,
intval, uint8_t, DBUS_TYPE_BYTE);
break;

+   case OFONO_NETMON_INFO_RSCP:
+   intval = va_arg(arglist, int);
+
+   CELL_INFO_DICT_APPEND(, "ReceivedSignalCodePower",
+   intval, uint8_t, DBUS_TYPE_BYTE);
+   break;
+
+   case OFONO_NETMON_INFO_ECN0:
+   intval = va_arg(arglist, int);
+
+   CELL_INFO_DICT_APPEND(, "ReceivedEnergyRatio",
+   intval, uint8_t, DBUS_TYPE_BYTE);
+   break;
+
+   case OFONO_NETMON_INFO_RSRQ:
+   intval = va_arg(arglist, int);
+
+   CELL_INFO_DICT_APPEND(, 
"ReferenceSignalReceivedQuality",
+   intval, uint8_t, DBUS_TYPE_BYTE);
+   break;
+
+   case OFONO_NETMON_INFO_RSRP:
+   intval = va_arg(arglist, int);
+
+   CELL_INFO_DICT_APPEND(, 
"ReferenceSignalReceivedPower",
+   intval, uint8_t, DBUS_TYPE_BYTE);
+   break;
+


The above 2 CELL_INFO_DICT_APPEND lines were > 80 characters.  So I 
amended the patch to fix that.



case OFONO_NETMON_INFO_INVALID:
break;
}



Applied, thanks!

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


Re: [PATCH v3 3/7] doc: documentation for OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP}

2016-11-30 Thread Denis Kenzior

Hi Djalal,

On 11/30/2016 06:31 AM, Djalal Harouni wrote:

This adds documentation for the following fields in
networkmonitor-api.txt

RSCP: Received Signal Code Power
ECN0: Received Energy Ratio
RSRQ: Reference Signal Received Quality
RSRP: Reference Signal Received Power
---
  doc/networkmonitor-api.txt | 22 ++
  1 file changed, 22 insertions(+)



Tweaked the commit description slightly and applied.  Thanks!

Regards,
-Denis

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


Re: [PATCH v3 1/7] netmon: add OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP}

2016-11-30 Thread Denis Kenzior

Hi Djalal,

On 11/30/2016 06:31 AM, Djalal Harouni wrote:

Add more ofono netmon info types that will be served through the netmon
interface. The main user of this now will be the ublox modem.

RSCP: Received Signal Code Power
ECN0: Received Energy Ratio
RSRQ: Reference Signal Received Quality
RSRP: Reference Signal Received Power

Patches using these types to follow.
---
  include/netmon.h | 4 
  1 file changed, 4 insertions(+)



I tweaked the commit header and applied this patch.  Thanks!

Regards,
-Denis

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


[PATCH v3 4/7] ubloxmodem: add the netmon driver

2016-11-30 Thread Djalal Harouni
This adds a netmon driver for ublox. The driver support both +COPS and
+CESQ commands to return the previously added ofono netmon types:

RSCP: Received Signal Code Power
ECN0: Received Energy Ratio
RSRQ: Reference Signal Received Quality
RSRP: Reference Signal Received Power
---
 drivers/ubloxmodem/netmon.c | 336 
 drivers/ubloxmodem/ubloxmodem.c |   2 +
 drivers/ubloxmodem/ubloxmodem.h |   3 +
 3 files changed, 341 insertions(+)
 create mode 100644 drivers/ubloxmodem/netmon.c

diff --git a/drivers/ubloxmodem/netmon.c b/drivers/ubloxmodem/netmon.c
new file mode 100644
index 000..e5adf59
--- /dev/null
+++ b/drivers/ubloxmodem/netmon.c
@@ -0,0 +1,336 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2016  EndoCode AG. All rights reserved.
+ *
+ *  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
+
+#define _GNU_SOURCE
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+#include "gatchat.h"
+#include "gatresult.h"
+
+#include "common.h"
+#include "netreg.h"
+#include "ubloxmodem.h"
+#include "drivers/atmodem/vendor.h"
+
+static const char *cops_prefix[] = { "+COPS:", NULL };
+static const char *cesq_prefix[] = { "+CESQ:", NULL };
+
+struct netmon_driver_data {
+   GAtChat *chat;
+};
+
+struct req_cb_data {
+   struct ofono_netmon *netmon;
+
+   ofono_netmon_cb_t cb;
+   void *data;
+
+   struct ofono_network_operator op;
+
+   int rxlev;  /* CESQ: Received Signal Strength Indication */
+   int ber;/* CESQ: Bit Error Rate */
+   int rscp;   /* CESQ: Received Signal Code Powe */
+   int rsrp;   /* CESQ: Reference Signal Received Power */
+   int ecn0;   /* CESQ: Received Energy Ratio */
+   int rsrq;   /* CESQ: Reference Signal Received Quality */
+};
+
+/*
+ * Returns the appropriate radio access technology.
+ *
+ * If we can not resolve to a specific radio access technolgy
+ * we return OFONO_NETMON_CELL_TYPE_GSM by default.
+ */
+static int ublox_map_radio_access_technology(int tech)
+{
+   switch (tech) {
+   case ACCESS_TECHNOLOGY_GSM:
+   case ACCESS_TECHNOLOGY_GSM_COMPACT:
+   return OFONO_NETMON_CELL_TYPE_GSM;
+   case ACCESS_TECHNOLOGY_UTRAN:
+   case ACCESS_TECHNOLOGY_UTRAN_HSDPA:
+   case ACCESS_TECHNOLOGY_UTRAN_HSUPA:
+   case ACCESS_TECHNOLOGY_UTRAN_HSDPA_HSUPA:
+   return OFONO_NETMON_CELL_TYPE_UMTS;
+   case ACCESS_TECHNOLOGY_EUTRAN:
+   return OFONO_NETMON_CELL_TYPE_LTE;
+   }
+
+   return OFONO_NETMON_CELL_TYPE_GSM;
+}
+
+static inline struct req_cb_data *req_cb_data_new0(void *cb, void *data, void 
*user)
+{
+   struct req_cb_data *ret = g_new0(struct req_cb_data, 1);
+   if (ret == NULL)
+   return NULL;
+
+   ret->cb = cb;
+   ret->data = data;
+   ret->netmon = user;
+   ret->rxlev = -1;
+   ret->ber = -1;
+   ret->rscp = -1;
+   ret->rsrp = -1;
+   ret->ecn0 = -1;
+   ret->rsrq = -1;
+
+   return ret;
+}
+
+static gboolean ublox_delayed_register(gpointer user_data)
+{
+   struct ofono_netmon *netmon = user_data;
+
+   ofono_netmon_register(netmon);
+
+   return FALSE;
+}
+
+static void ublox_netmon_finish_success(struct req_cb_data *cbd)
+{
+   struct ofono_netmon *nm = cbd->netmon;
+
+   ofono_netmon_serving_cell_notify(nm,
+cbd->op.tech,
+OFONO_NETMON_INFO_RXLEV, cbd->rxlev,
+OFONO_NETMON_INFO_BER, cbd->ber,
+OFONO_NETMON_INFO_RSCP, cbd->rscp,
+OFONO_NETMON_INFO_ECN0, cbd->ecn0,
+OFONO_NETMON_INFO_RSRQ, cbd->rsrq,
+OFONO_NETMON_INFO_RSRP, cbd->rsrp,
+OFONO_NETMON_INFO_INVALID);
+
+   CALLBACK_WITH_SUCCESS(cbd->cb, cbd->data);
+   g_free(cbd);
+}
+
+static void cesq_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   enum cesq_ofono_netmon_info {
+   CESQ_RXLEV,
+   CESQ_BER,
+   CESQ_RSCP,
+   CESQ_ECN0,

[PATCH v3 2/7] netmon: handle OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP} in D-Bus

2016-11-30 Thread Djalal Harouni
Handle the previously added types in D-Bus.

Documentation for these values is in next patch.
---
 src/netmon.c | 28 
 1 file changed, 28 insertions(+)

diff --git a/src/netmon.c b/src/netmon.c
index eb18b9c..2a8c524 100644
--- a/src/netmon.c
+++ b/src/netmon.c
@@ -180,6 +180,34 @@ void ofono_netmon_serving_cell_notify(struct ofono_netmon 
*netmon,
intval, uint8_t, DBUS_TYPE_BYTE);
break;
 
+   case OFONO_NETMON_INFO_RSCP:
+   intval = va_arg(arglist, int);
+
+   CELL_INFO_DICT_APPEND(, "ReceivedSignalCodePower",
+   intval, uint8_t, DBUS_TYPE_BYTE);
+   break;
+
+   case OFONO_NETMON_INFO_ECN0:
+   intval = va_arg(arglist, int);
+
+   CELL_INFO_DICT_APPEND(, "ReceivedEnergyRatio",
+   intval, uint8_t, DBUS_TYPE_BYTE);
+   break;
+
+   case OFONO_NETMON_INFO_RSRQ:
+   intval = va_arg(arglist, int);
+
+   CELL_INFO_DICT_APPEND(, 
"ReferenceSignalReceivedQuality",
+   intval, uint8_t, DBUS_TYPE_BYTE);
+   break;
+
+   case OFONO_NETMON_INFO_RSRP:
+   intval = va_arg(arglist, int);
+
+   CELL_INFO_DICT_APPEND(, 
"ReferenceSignalReceivedPower",
+   intval, uint8_t, DBUS_TYPE_BYTE);
+   break;
+
case OFONO_NETMON_INFO_INVALID:
break;
}
-- 
2.5.5

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


[PATCH v3 6/7] build: build the ublox netmon driver

2016-11-30 Thread Djalal Harouni
---
 Makefile.am | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Makefile.am b/Makefile.am
index 3d7774b..07adeab 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -383,6 +383,7 @@ builtin_sources += drivers/atmodem/atutil.h \
drivers/ubloxmodem/ubloxmodem.h \
drivers/ubloxmodem/ubloxmodem.c \
drivers/ubloxmodem/gprs-context.c \
+   drivers/ubloxmodem/netmon.c \
drivers/ubloxmodem/lte.c
 
 
-- 
2.5.5

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


[PATCH v3 3/7] doc: documentation for OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP}

2016-11-30 Thread Djalal Harouni
This adds documentation for the following fields in
networkmonitor-api.txt

RSCP: Received Signal Code Power
ECN0: Received Energy Ratio
RSRQ: Reference Signal Received Quality
RSRP: Reference Signal Received Power
---
 doc/networkmonitor-api.txt | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/doc/networkmonitor-api.txt b/doc/networkmonitor-api.txt
index 703f19b..0d2fe3f 100644
--- a/doc/networkmonitor-api.txt
+++ b/doc/networkmonitor-api.txt
@@ -81,3 +81,25 @@ byte Strength [optional, gsm, umts]
 
Contains the signal strength.  Valid values are 0-31.  Refer to 
in 27.007, Section 8.5.
+
+byte ReceivedSignalCodePower [optional, umts]
+
+Contains the Received Signal Code Power.  Valid range of values
+is 0-96. Refer to  in 27.007, Section 8.69 for more details.
+
+byte ReceivedEnergyRatio [optional, umts]
+
+Contains the Ratio of received energy per PN chip to the total
+received power spectral density.  Valid range of values is 0-49.
+Refer to  in 27.007, Section 8.69 for more details.
+
+byte ReferenceSignalReceivedQuality [optional, lte]
+
+Contains the Reference Signal Received Quality.  Valid range of
+values is 0-34. Refer to  in 27.007, Section 8.69 for more
+details.
+
+byte ReferenceSignalReceivedPower [optional, lte]
+
+Contains the Reference Signal Received Power.  Valid range of values
+is 0-97. Refer to  in 27.007, Section 8.69 for more details.
-- 
2.5.5

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


[PATCH v3 7/7] test: support OFONO_NETMON_INFO_{RXLEV|RSCP|ECN0|RSRQ|RSRP}

2016-11-30 Thread Djalal Harouni
Display the following fields if they are returned.

RXLEV:  Received Signal Strength
RSCP:   Received Signal Code Power
ECN0:   Received Energy Ratio
RSRQ:   Reference Signal Received Quality
RSRP:   Reference Signal Received Power
---
 test/get-serving-cell-info | 20 
 1 file changed, 20 insertions(+)

diff --git a/test/get-serving-cell-info b/test/get-serving-cell-info
index 05dc9fe..94e1c54 100755
--- a/test/get-serving-cell-info
+++ b/test/get-serving-cell-info
@@ -26,6 +26,11 @@ cid = 'CellId'
 psc = 'PrimaryScramblingCode'
 rssi = 'Strength'
 ber = 'BitErrorRate'
+rxlev = 'ReceivedSignalStrength'
+rscp = 'ReceivedSignalCodePower'
+ecn0 = 'ReceivedEnergyRatio'
+rsrq = 'ReferenceSignalReceivedQuality'
+rsrp = 'ReferenceSignalReceivedPower'
 
 print("Current serving cell information:")
 
@@ -50,7 +55,22 @@ if psc in servingcell:
 if rssi in servingcell:
print("[ Signal Strength = %d]" % (servingcell[rssi]))
 
+if rxlev in servingcell:
+   print("[ Received Signal Strength = %d]" % (servingcell[rxlev]))
+
 if ber in servingcell:
print("[ Bit Error Rate = %d]" % (servingcell[ber]))
 
+if rscp in servingcell:
+   print("[ Received Signal Code Power = %d]" % (servingcell[rscp]))
+
+if ecn0 in servingcell:
+   print("[ Received Energy Ratio = %d]" % (servingcell[ecn0]))
+
+if rsrq in servingcell:
+   print("[ Reference Signal Received Quality = %d]" % 
(servingcell[rsrq]))
+
+if rsrp in servingcell:
+   print("[ Reference Signal Received Power = %d]" % 
(servingcell[rsrp]))
+
 print('')
-- 
2.5.5

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


[PATCH v3 1/7] netmon: add OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP}

2016-11-30 Thread Djalal Harouni
Add more ofono netmon info types that will be served through the netmon
interface. The main user of this now will be the ublox modem.

RSCP: Received Signal Code Power
ECN0: Received Energy Ratio
RSRQ: Reference Signal Received Quality
RSRP: Reference Signal Received Power

Patches using these types to follow.
---
 include/netmon.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/include/netmon.h b/include/netmon.h
index ec8a2e1..47d7a9c 100644
--- a/include/netmon.h
+++ b/include/netmon.h
@@ -59,6 +59,10 @@ enum ofono_netmon_info {
OFONO_NETMON_INFO_RSSI, /* int */
OFONO_NETMON_INFO_TIMING_ADVANCE, /* int */
OFONO_NETMON_INFO_PSC, /* int */
+   OFONO_NETMON_INFO_RSCP, /* int */
+   OFONO_NETMON_INFO_ECN0, /* int */
+   OFONO_NETMON_INFO_RSRQ, /* int */
+   OFONO_NETMON_INFO_RSRP, /* int */
OFONO_NETMON_INFO_INVALID,
 };
 
-- 
2.5.5

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


[PATCH v3 0/7] ubloxmodem add netmon interface

2016-11-30 Thread Djalal Harouni
Hi,

These patches add netmon interface to ubloxmodem. This allows to query
and get data returned by +CESQ command through D-Bus.

The following types will be exposed as Network Monitor Property Types.
RSCP: Received Signal Code Power
ECN0: Received Energy Ratio
RSRQ: Reference Signal Received Quality
RSRP: Reference Signal Received Power


Thank you!

Changes since v2
  * Fixed subject of header message: we have 0/7 patches and not 0/5
  * Tag all subject of patches with v3, easy to read.
  * Fixed a bug we have to return when finishing please see:
https://lists.ofono.org/pipermail/ofono/2016-November/016693.html


Changes since v1:
  * Re-worked patches to follow 'Submitting patches' section.
Each top-level directory change should be in a separate patch
  * Removed OFONO_NETMON_INFO_OPERATOR
  * Documented all added fields in networkmonitor-api.txt
  * We only use one channel for communication, dropped the other one.
  * Fixed a cbd memory leak, now we try to be conservative and always
report what we have collected so far. We only fail hard in case
+COPS failed or sending +CESQ failed. Otherwise we report the result
and make sure to free cbd.
  * Various fixes to follow the coding style.


v2 is here:
https://lists.ofono.org/pipermail/ofono/2016-November/016685.html

V1 is here:
https://lists.ofono.org/pipermail/ofono/2016-November/016671.html


Djalal Harouni (7):
  netmon: add OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP}
  netmon: handle OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP} in D-Bus
  doc: documentation for OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP}
  ubloxmodem: add the netmon driver
  ubloxmodem: register and initialize the netmon driver
  build: build the ublox netmon driver
  test: support OFONO_NETMON_INFO_{RXLEV|RSCP|ECN0|RSRQ|RSRP}

 Makefile.am |   1 +
 doc/networkmonitor-api.txt  |  22 +++
 drivers/ubloxmodem/netmon.c | 335 
 drivers/ubloxmodem/ubloxmodem.c |   2 +
 drivers/ubloxmodem/ubloxmodem.h |   3 +
 include/netmon.h|   4 +
 plugins/ublox.c |   3 +
 src/netmon.c|  28 
 test/get-serving-cell-info  |  20 +++
 9 files changed, 418 insertions(+)
 create mode 100644 drivers/ubloxmodem/netmon.c
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


Re: [PATCH 4/7] ubloxmodem: add the netmon driver

2016-11-30 Thread Djalal Harouni
On 30 November 2016 at 13:13, Djalal Harouni  wrote:
> This adds a netmon driver for ublox. The driver support both +COPS and
> +CESQ commands to return the previously added ofono netmon types:
>
> RSCP: Received Signal Code Power
> ECN0: Received Energy Ratio
> RSRQ: Reference Signal Received Quality
> RSRP: Reference Signal Received Power
> ---
>  drivers/ubloxmodem/netmon.c | 335 
> 
>  drivers/ubloxmodem/ubloxmodem.c |   2 +
>  drivers/ubloxmodem/ubloxmodem.h |   3 +
>  3 files changed, 340 insertions(+)
>  create mode 100644 drivers/ubloxmodem/netmon.c
>
> diff --git a/drivers/ubloxmodem/netmon.c b/drivers/ubloxmodem/netmon.c
> new file mode 100644
> index 000..3cc31a0
> --- /dev/null
> +++ b/drivers/ubloxmodem/netmon.c
> @@ -0,0 +1,335 @@
> +/*
> + *
> + *  oFono - Open Source Telephony
> + *
> + *  Copyright (C) 2016  EndoCode AG. All rights reserved.
> + *
> + *  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
> +
> +#define _GNU_SOURCE
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +
> +#include "gatchat.h"
> +#include "gatresult.h"
> +
> +#include "common.h"
> +#include "netreg.h"
> +#include "ubloxmodem.h"
> +#include "drivers/atmodem/vendor.h"
> +
> +static const char *cops_prefix[] = { "+COPS:", NULL };
> +static const char *cesq_prefix[] = { "+CESQ:", NULL };
> +
> +struct netmon_driver_data {
> +   GAtChat *chat;
> +};
> +
> +struct req_cb_data {
> +   struct ofono_netmon *netmon;
> +
> +   ofono_netmon_cb_t cb;
> +   void *data;
> +
> +   struct ofono_network_operator op;
> +
> +   int rxlev;  /* CESQ: Received Signal Strength Indication */
> +   int ber;/* CESQ: Bit Error Rate */
> +   int rscp;   /* CESQ: Received Signal Code Powe */
> +   int rsrp;   /* CESQ: Reference Signal Received Power */
> +   int ecn0;   /* CESQ: Received Energy Ratio */
> +   int rsrq;   /* CESQ: Reference Signal Received Quality */
> +};
> +
> +/*
> + * Returns the appropriate radio access technology.
> + *
> + * If we can not resolve to a specific radio access technolgy
> + * we return OFONO_NETMON_CELL_TYPE_GSM by default.
> + */
> +static int ublox_map_radio_access_technology(int tech)
> +{
> +   switch (tech) {
> +   case ACCESS_TECHNOLOGY_GSM:
> +   case ACCESS_TECHNOLOGY_GSM_COMPACT:
> +   return OFONO_NETMON_CELL_TYPE_GSM;
> +   case ACCESS_TECHNOLOGY_UTRAN:
> +   case ACCESS_TECHNOLOGY_UTRAN_HSDPA:
> +   case ACCESS_TECHNOLOGY_UTRAN_HSUPA:
> +   case ACCESS_TECHNOLOGY_UTRAN_HSDPA_HSUPA:
> +   return OFONO_NETMON_CELL_TYPE_UMTS;
> +   case ACCESS_TECHNOLOGY_EUTRAN:
> +   return OFONO_NETMON_CELL_TYPE_LTE;
> +   }
> +
> +   return OFONO_NETMON_CELL_TYPE_GSM;
> +}
> +
> +static inline struct req_cb_data *req_cb_data_new0(void *cb, void *data, 
> void *user)
> +{
> +   struct req_cb_data *ret = g_new0(struct req_cb_data, 1);
> +   if (ret == NULL)
> +   return NULL;
> +
> +   ret->cb = cb;
> +   ret->data = data;
> +   ret->netmon = user;
> +   ret->rxlev = -1;
> +   ret->ber = -1;
> +   ret->rscp = -1;
> +   ret->rsrp = -1;
> +   ret->ecn0 = -1;
> +   ret->rsrq = -1;
> +
> +   return ret;
> +}
> +
> +static gboolean ublox_delayed_register(gpointer user_data)
> +{
> +   struct ofono_netmon *netmon = user_data;
> +
> +   ofono_netmon_register(netmon);
> +
> +   return FALSE;
> +}
> +
> +static void ublox_netmon_finish_success(struct req_cb_data *cbd)
> +{
> +   struct ofono_netmon *nm = cbd->netmon;
> +
> +   ofono_netmon_serving_cell_notify(nm,
> +cbd->op.tech,
> +OFONO_NETMON_INFO_RXLEV, cbd->rxlev,
> +OFONO_NETMON_INFO_BER, cbd->ber,
> +OFONO_NETMON_INFO_RSCP, cbd->rscp,
> +OFONO_NETMON_INFO_ECN0, cbd->ecn0,
> +OFONO_NETMON_INFO_RSRQ, cbd->rsrq,
> +

[PATCH 3/7] doc: documentation for OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP}

2016-11-30 Thread Djalal Harouni
This adds documentation for the following fields in
networkmonitor-api.txt

RSCP: Received Signal Code Power
ECN0: Received Energy Ratio
RSRQ: Reference Signal Received Quality
RSRP: Reference Signal Received Power
---
 doc/networkmonitor-api.txt | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/doc/networkmonitor-api.txt b/doc/networkmonitor-api.txt
index 703f19b..0d2fe3f 100644
--- a/doc/networkmonitor-api.txt
+++ b/doc/networkmonitor-api.txt
@@ -81,3 +81,25 @@ byte Strength [optional, gsm, umts]
 
Contains the signal strength.  Valid values are 0-31.  Refer to 
in 27.007, Section 8.5.
+
+byte ReceivedSignalCodePower [optional, umts]
+
+Contains the Received Signal Code Power.  Valid range of values
+is 0-96. Refer to  in 27.007, Section 8.69 for more details.
+
+byte ReceivedEnergyRatio [optional, umts]
+
+Contains the Ratio of received energy per PN chip to the total
+received power spectral density.  Valid range of values is 0-49.
+Refer to  in 27.007, Section 8.69 for more details.
+
+byte ReferenceSignalReceivedQuality [optional, lte]
+
+Contains the Reference Signal Received Quality.  Valid range of
+values is 0-34. Refer to  in 27.007, Section 8.69 for more
+details.
+
+byte ReferenceSignalReceivedPower [optional, lte]
+
+Contains the Reference Signal Received Power.  Valid range of values
+is 0-97. Refer to  in 27.007, Section 8.69 for more details.
-- 
2.5.5

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


[PATCH 1/7] netmon: add OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP}

2016-11-30 Thread Djalal Harouni
Add more ofono netmon info types that will be served through the netmon
interface. The main user of this now will be the ublox modem.

RSCP: Received Signal Code Power
ECN0: Received Energy Ratio
RSRQ: Reference Signal Received Quality
RSRP: Reference Signal Received Power

Patches using these types to follow.
---
 include/netmon.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/include/netmon.h b/include/netmon.h
index ec8a2e1..47d7a9c 100644
--- a/include/netmon.h
+++ b/include/netmon.h
@@ -59,6 +59,10 @@ enum ofono_netmon_info {
OFONO_NETMON_INFO_RSSI, /* int */
OFONO_NETMON_INFO_TIMING_ADVANCE, /* int */
OFONO_NETMON_INFO_PSC, /* int */
+   OFONO_NETMON_INFO_RSCP, /* int */
+   OFONO_NETMON_INFO_ECN0, /* int */
+   OFONO_NETMON_INFO_RSRQ, /* int */
+   OFONO_NETMON_INFO_RSRP, /* int */
OFONO_NETMON_INFO_INVALID,
 };
 
-- 
2.5.5

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


[PATCH 7/7] test: support OFONO_NETMON_INFO_{RXLEV|RSCP|ECN0|RSRQ|RSRP}

2016-11-30 Thread Djalal Harouni
Display the following fields if they are returned.

RXLEV:  Received Signal Strength
RSCP:   Received Signal Code Power
ECN0:   Received Energy Ratio
RSRQ:   Reference Signal Received Quality
RSRP:   Reference Signal Received Power
---
 test/get-serving-cell-info | 20 
 1 file changed, 20 insertions(+)

diff --git a/test/get-serving-cell-info b/test/get-serving-cell-info
index 05dc9fe..94e1c54 100755
--- a/test/get-serving-cell-info
+++ b/test/get-serving-cell-info
@@ -26,6 +26,11 @@ cid = 'CellId'
 psc = 'PrimaryScramblingCode'
 rssi = 'Strength'
 ber = 'BitErrorRate'
+rxlev = 'ReceivedSignalStrength'
+rscp = 'ReceivedSignalCodePower'
+ecn0 = 'ReceivedEnergyRatio'
+rsrq = 'ReferenceSignalReceivedQuality'
+rsrp = 'ReferenceSignalReceivedPower'
 
 print("Current serving cell information:")
 
@@ -50,7 +55,22 @@ if psc in servingcell:
 if rssi in servingcell:
print("[ Signal Strength = %d]" % (servingcell[rssi]))
 
+if rxlev in servingcell:
+   print("[ Received Signal Strength = %d]" % (servingcell[rxlev]))
+
 if ber in servingcell:
print("[ Bit Error Rate = %d]" % (servingcell[ber]))
 
+if rscp in servingcell:
+   print("[ Received Signal Code Power = %d]" % (servingcell[rscp]))
+
+if ecn0 in servingcell:
+   print("[ Received Energy Ratio = %d]" % (servingcell[ecn0]))
+
+if rsrq in servingcell:
+   print("[ Reference Signal Received Quality = %d]" % 
(servingcell[rsrq]))
+
+if rsrp in servingcell:
+   print("[ Reference Signal Received Power = %d]" % 
(servingcell[rsrp]))
+
 print('')
-- 
2.5.5

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


[PATCH v2 0/5] ubloxmodem add netmon interface

2016-11-30 Thread Djalal Harouni
Hi,

These patches add netmon interface to ubloxmodem. This allows to query
and get data returned by +CESQ command through D-Bus.

The following types will be exposed as Network Monitor Property Types.
RSCP: Received Signal Code Power
ECN0: Received Energy Ratio
RSRQ: Reference Signal Received Quality
RSRP: Reference Signal Received Power


V1 is here:
https://lists.ofono.org/pipermail/ofono/2016-November/016671.html

Thank you!

Changes since v1:
  * Re-worked patches to follow 'Submitting patches' section.
Each top-level directory change should be in a separate patch
  * Removed OFONO_NETMON_INFO_OPERATOR
  * Documented all added fields in networkmonitor-api.txt
  * We only use one channel for communication, dropped the other one.
  * Fixed a cbd memory leak, now we try to be conservative and always
report what we have collected so far. We only fail hard in case
+COPS failed or sending +CESQ failed. Otherwise we report the result
and make sure to free cbd.
  * Various fixes to follow the coding style.


Djalal Harouni (7):
  netmon: add OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP}
  netmon: handle OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP} in D-Bus
  doc: documentation for OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP}
  ubloxmodem: add the netmon driver
  ubloxmodem: register and initialize the netmon driver
  build: build the ublox netmon driver
  test: support OFONO_NETMON_INFO_{RXLEV|RSCP|ECN0|RSRQ|RSRP}

 Makefile.am |   1 +
 doc/networkmonitor-api.txt  |  22 +++
 drivers/ubloxmodem/netmon.c | 335 
 drivers/ubloxmodem/ubloxmodem.c |   2 +
 drivers/ubloxmodem/ubloxmodem.h |   3 +
 include/netmon.h|   4 +
 plugins/ublox.c |   3 +
 src/netmon.c|  28 
 test/get-serving-cell-info  |  20 +++
 9 files changed, 418 insertions(+)
 create mode 100644 drivers/ubloxmodem/netmon.c
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


[PATCH 6/7] build: build the ublox netmon driver

2016-11-30 Thread Djalal Harouni
---
 Makefile.am | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Makefile.am b/Makefile.am
index 3d7774b..07adeab 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -383,6 +383,7 @@ builtin_sources += drivers/atmodem/atutil.h \
drivers/ubloxmodem/ubloxmodem.h \
drivers/ubloxmodem/ubloxmodem.c \
drivers/ubloxmodem/gprs-context.c \
+   drivers/ubloxmodem/netmon.c \
drivers/ubloxmodem/lte.c
 
 
-- 
2.5.5

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


[PATCH 2/7] netmon: handle OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP} in D-Bus

2016-11-30 Thread Djalal Harouni
Handle the previously added types in D-Bus.

Documentation for these values is in next patch.
---
 src/netmon.c | 28 
 1 file changed, 28 insertions(+)

diff --git a/src/netmon.c b/src/netmon.c
index eb18b9c..2a8c524 100644
--- a/src/netmon.c
+++ b/src/netmon.c
@@ -180,6 +180,34 @@ void ofono_netmon_serving_cell_notify(struct ofono_netmon 
*netmon,
intval, uint8_t, DBUS_TYPE_BYTE);
break;
 
+   case OFONO_NETMON_INFO_RSCP:
+   intval = va_arg(arglist, int);
+
+   CELL_INFO_DICT_APPEND(, "ReceivedSignalCodePower",
+   intval, uint8_t, DBUS_TYPE_BYTE);
+   break;
+
+   case OFONO_NETMON_INFO_ECN0:
+   intval = va_arg(arglist, int);
+
+   CELL_INFO_DICT_APPEND(, "ReceivedEnergyRatio",
+   intval, uint8_t, DBUS_TYPE_BYTE);
+   break;
+
+   case OFONO_NETMON_INFO_RSRQ:
+   intval = va_arg(arglist, int);
+
+   CELL_INFO_DICT_APPEND(, 
"ReferenceSignalReceivedQuality",
+   intval, uint8_t, DBUS_TYPE_BYTE);
+   break;
+
+   case OFONO_NETMON_INFO_RSRP:
+   intval = va_arg(arglist, int);
+
+   CELL_INFO_DICT_APPEND(, 
"ReferenceSignalReceivedPower",
+   intval, uint8_t, DBUS_TYPE_BYTE);
+   break;
+
case OFONO_NETMON_INFO_INVALID:
break;
}
-- 
2.5.5

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


[PATCH 5/7] ubloxmodem: register and initialize the netmon driver

2016-11-30 Thread Djalal Harouni
---
 plugins/ublox.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/plugins/ublox.c b/plugins/ublox.c
index 6d77df8..2ced577 100644
--- a/plugins/ublox.c
+++ b/plugins/ublox.c
@@ -38,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -323,6 +324,8 @@ static void ublox_post_online(struct ofono_modem *modem)
struct ublox_data *data = ofono_modem_get_data(modem);
 
ofono_netreg_create(modem, data->vendor_family, "atmodem", data->aux);
+
+   ofono_netmon_create(modem, data->vendor_family, "ubloxmodem", 
data->aux);
 }
 
 static struct ofono_modem_driver ublox_driver = {
-- 
2.5.5

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


[PATCH 4/7] ubloxmodem: add the netmon driver

2016-11-30 Thread Djalal Harouni
This adds a netmon driver for ublox. The driver support both +COPS and
+CESQ commands to return the previously added ofono netmon types:

RSCP: Received Signal Code Power
ECN0: Received Energy Ratio
RSRQ: Reference Signal Received Quality
RSRP: Reference Signal Received Power
---
 drivers/ubloxmodem/netmon.c | 335 
 drivers/ubloxmodem/ubloxmodem.c |   2 +
 drivers/ubloxmodem/ubloxmodem.h |   3 +
 3 files changed, 340 insertions(+)
 create mode 100644 drivers/ubloxmodem/netmon.c

diff --git a/drivers/ubloxmodem/netmon.c b/drivers/ubloxmodem/netmon.c
new file mode 100644
index 000..3cc31a0
--- /dev/null
+++ b/drivers/ubloxmodem/netmon.c
@@ -0,0 +1,335 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2016  EndoCode AG. All rights reserved.
+ *
+ *  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
+
+#define _GNU_SOURCE
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+#include "gatchat.h"
+#include "gatresult.h"
+
+#include "common.h"
+#include "netreg.h"
+#include "ubloxmodem.h"
+#include "drivers/atmodem/vendor.h"
+
+static const char *cops_prefix[] = { "+COPS:", NULL };
+static const char *cesq_prefix[] = { "+CESQ:", NULL };
+
+struct netmon_driver_data {
+   GAtChat *chat;
+};
+
+struct req_cb_data {
+   struct ofono_netmon *netmon;
+
+   ofono_netmon_cb_t cb;
+   void *data;
+
+   struct ofono_network_operator op;
+
+   int rxlev;  /* CESQ: Received Signal Strength Indication */
+   int ber;/* CESQ: Bit Error Rate */
+   int rscp;   /* CESQ: Received Signal Code Powe */
+   int rsrp;   /* CESQ: Reference Signal Received Power */
+   int ecn0;   /* CESQ: Received Energy Ratio */
+   int rsrq;   /* CESQ: Reference Signal Received Quality */
+};
+
+/*
+ * Returns the appropriate radio access technology.
+ *
+ * If we can not resolve to a specific radio access technolgy
+ * we return OFONO_NETMON_CELL_TYPE_GSM by default.
+ */
+static int ublox_map_radio_access_technology(int tech)
+{
+   switch (tech) {
+   case ACCESS_TECHNOLOGY_GSM:
+   case ACCESS_TECHNOLOGY_GSM_COMPACT:
+   return OFONO_NETMON_CELL_TYPE_GSM;
+   case ACCESS_TECHNOLOGY_UTRAN:
+   case ACCESS_TECHNOLOGY_UTRAN_HSDPA:
+   case ACCESS_TECHNOLOGY_UTRAN_HSUPA:
+   case ACCESS_TECHNOLOGY_UTRAN_HSDPA_HSUPA:
+   return OFONO_NETMON_CELL_TYPE_UMTS;
+   case ACCESS_TECHNOLOGY_EUTRAN:
+   return OFONO_NETMON_CELL_TYPE_LTE;
+   }
+
+   return OFONO_NETMON_CELL_TYPE_GSM;
+}
+
+static inline struct req_cb_data *req_cb_data_new0(void *cb, void *data, void 
*user)
+{
+   struct req_cb_data *ret = g_new0(struct req_cb_data, 1);
+   if (ret == NULL)
+   return NULL;
+
+   ret->cb = cb;
+   ret->data = data;
+   ret->netmon = user;
+   ret->rxlev = -1;
+   ret->ber = -1;
+   ret->rscp = -1;
+   ret->rsrp = -1;
+   ret->ecn0 = -1;
+   ret->rsrq = -1;
+
+   return ret;
+}
+
+static gboolean ublox_delayed_register(gpointer user_data)
+{
+   struct ofono_netmon *netmon = user_data;
+
+   ofono_netmon_register(netmon);
+
+   return FALSE;
+}
+
+static void ublox_netmon_finish_success(struct req_cb_data *cbd)
+{
+   struct ofono_netmon *nm = cbd->netmon;
+
+   ofono_netmon_serving_cell_notify(nm,
+cbd->op.tech,
+OFONO_NETMON_INFO_RXLEV, cbd->rxlev,
+OFONO_NETMON_INFO_BER, cbd->ber,
+OFONO_NETMON_INFO_RSCP, cbd->rscp,
+OFONO_NETMON_INFO_ECN0, cbd->ecn0,
+OFONO_NETMON_INFO_RSRQ, cbd->rsrq,
+OFONO_NETMON_INFO_RSRP, cbd->rsrp,
+OFONO_NETMON_INFO_INVALID);
+
+   CALLBACK_WITH_SUCCESS(cbd->cb, cbd->data);
+   g_free(cbd);
+}
+
+static void cesq_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   enum cesq_ofono_netmon_info {
+   CESQ_RXLEV,
+   CESQ_BER,
+   CESQ_RSCP,
+   CESQ_ECN0,

Re: [PATCH 3/5] ubloxmodem: add the netmon driver

2016-11-30 Thread Djalal Harouni
Hi Denis,

On 29 November 2016 at 18:32, Denis Kenzior  wrote:
> Hi Djalal,
>
>
> On 11/25/2016 08:00 AM, dja...@endocode.com wrote:
>>
>> From: Djalal Harouni 
>>
>> This adds a netmon driver for ublox. The driver support both +COPS and
>> +CESQ commands to return the previously added ofono netmon types:
>>
>> RSCP: Received Signal Code Power
>> ECN0: Received Energy Ratio
>> RSRQ: Reference Signal Received Quality
>> RSRP: Reference Signal Received Power
>> OPERATOR: the operator
>> ---
>>   Makefile.am |   1 +
>>   drivers/ubloxmodem/netmon.c | 339
>> 
>>   2 files changed, 340 insertions(+)
>>   create mode 100644 drivers/ubloxmodem/netmon.c
>>
>> diff --git a/Makefile.am b/Makefile.am
>> index 3d7774b..07adeab 100644
>> --- a/Makefile.am
>> +++ b/Makefile.am
>> @@ -383,6 +383,7 @@ builtin_sources += drivers/atmodem/atutil.h \
>> drivers/ubloxmodem/ubloxmodem.h \
>> drivers/ubloxmodem/ubloxmodem.c \
>> drivers/ubloxmodem/gprs-context.c \
>> +   drivers/ubloxmodem/netmon.c \
>> drivers/ubloxmodem/lte.c
>>
>>
>> diff --git a/drivers/ubloxmodem/netmon.c b/drivers/ubloxmodem/netmon.c
>> new file mode 100644
>> index 000..6b9d74f
>> --- /dev/null
>> +++ b/drivers/ubloxmodem/netmon.c
>> @@ -0,0 +1,339 @@
>> +/*
>> + *
>> + *  oFono - Open Source Telephony
>> + *
>> + *  Copyright (C) 2016  EndoCode AG. All rights reserved.
>> + *
>> + *  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
>> +
>> +#define _GNU_SOURCE
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include 
>> +
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include "gatchat.h"
>> +#include "gatresult.h"
>> +
>> +#include "common.h"
>> +#include "netreg.h"
>> +#include "ubloxmodem.h"
>> +#include "drivers/atmodem/vendor.h"
>> +
>> +static const char *cops_prefix[] = { "+COPS:", NULL };
>> +static const char *cesq_prefix[] = { "+CESQ:", NULL };
>> +
>> +struct netmon_driver_data {
>> +   GAtChat *modem;
>> +   GAtChat *aux;
>> +};
>
>
> Why do you need both the modem and the aux port?  I only see you using the
> aux port.

Ok fixed in v2. we need only one channel.

>> +
>> +struct req_cb_data {
>> +   struct ofono_netmon *netmon;
>> +
>> +   ofono_netmon_cb_t cb;
>> +   void *data;
>> +
>> +   struct ofono_network_operator op;
>> +
>> +   int rxlev;  /* CESQ: Received Signal Strength Indication */
>> +   int ber;/* CESQ: Bit Error Rate */
>> +   int rscp;   /* CESQ: Received Signal Code Powe */
>> +   int rsrp;   /* CESQ: Reference Signal Received Power */
>> +   double ecn0;/* CESQ: Received Energy Ratio */
>> +   double rsrq;/* CESQ: Reference Signal Received Quality */
>
>
> Why are these doubles?

Fixed.


>
>> +};
>> +
>> +/*
>> + * Returns the appropriate radio access technology.
>> + *
>> + * If we can not resolve to a specific radio access technolgy
>> + * we return OFONO_NETMON_CELL_TYPE_GSM by default.
>> + */
>> +static int ublox_map_radio_access_technology(int tech)
>> +{
>> +   switch (tech) {
>> +   case ACCESS_TECHNOLOGY_GSM:
>> +   case ACCESS_TECHNOLOGY_GSM_COMPACT:
>> +   return OFONO_NETMON_CELL_TYPE_GSM;
>> +   case ACCESS_TECHNOLOGY_UTRAN:
>> +   case ACCESS_TECHNOLOGY_UTRAN_HSDPA:
>> +   case ACCESS_TECHNOLOGY_UTRAN_HSUPA:
>> +   case ACCESS_TECHNOLOGY_UTRAN_HSDPA_HSUPA:
>> +   return OFONO_NETMON_CELL_TYPE_UMTS;
>> +   case ACCESS_TECHNOLOGY_EUTRAN:
>> +   return OFONO_NETMON_CELL_TYPE_LTE;
>> +   }
>> +
>> +   return OFONO_NETMON_CELL_TYPE_GSM;
>> +}
>> +
>> +static inline struct req_cb_data *req_cb_data_new0(void *cb, void *data,
>> void *user)
>> +{
>> +   struct req_cb_data *ret = g_new0(struct req_cb_data, 1);
>> +   if (ret == NULL)
>> +   return NULL;
>> +
>> +
>> +   ret->cb = cb;
>> +   ret->data = data;
>> +   ret->netmon = user;
>> +   ret->rxlev = -1;
>> +   ret->ber = -1;
>> +   ret->rscp = -1;
>> +   ret->rsrp = -1;
>> +   ret->ecn0 = -1;
>> +   

Re: [PATCH 4/5] ubloxmodem: intialize and register the netmon driver

2016-11-30 Thread Djalal Harouni
On 29 November 2016 at 17:53, Denis Kenzior  wrote:
> Hi Djalal,
>
> On 11/25/2016 08:00 AM, dja...@endocode.com wrote:
>>
>> From: Djalal Harouni 
>>
>> This patch allows to intialize and register the ublox netmon driver.
>> ---
>>   drivers/ubloxmodem/ubloxmodem.c | 2 ++
>>   drivers/ubloxmodem/ubloxmodem.h | 3 +++
>>   plugins/ublox.c | 3 +++
>>   3 files changed, 8 insertions(+)
>>
>
> This patch isn't broken down properly.  See HACKING, 'Submitting patches'
> section.  Each top-level directory change should be in a separate patch.
> E.g. one patch for drivers/* and one patch for plugins/*.
>
> It might be easier to simply squash drivers/ubloxmodem/ubloxmodem.[ch]
> changes into patch 3.

Oups sorry about that. Hopefully fixed in v2.

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


Re: [PATCH 2/5] netmon: handle OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP|OPERATOR} in D-Bus

2016-11-30 Thread Djalal Harouni
Hi Denis,

On 29 November 2016 at 17:49, Denis Kenzior  wrote:
> Hi Djalal,
>
> On 11/25/2016 08:00 AM, dja...@endocode.com wrote:
>>
>> From: Djalal Harouni 
>>
>> Handle the previously added types in D-Bus.
>> ---
>>   src/netmon.c | 40 +++-
>>   1 file changed, 39 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/netmon.c b/src/netmon.c
>> index eb18b9c..c87980a 100644
>> --- a/src/netmon.c
>> +++ b/src/netmon.c
>> @@ -78,7 +78,8 @@ void ofono_netmon_serving_cell_notify(struct
>> ofono_netmon *netmon,
>> const char *technology = cell_type_to_tech_name(type);
>> char *mcc = NULL;
>> char *mnc = NULL;
>> -   int intval;
>> +   char *op = NULL;
>> +   int intval = -1;
>
>
> Why the initializer?  Our rule of thumb is not to initialize in order to let
> the compiler (hopefully) or valgrind catch instances of uninitialized
> variable use (e.g. bugs).

Ok dropped that one too, but in this case it does not matter, va_arg()
is undefined any way...

>
>> netmon->reply = dbus_message_new_method_return(netmon->pending);
>>
>> if (netmon->reply == NULL)
>> @@ -180,6 +181,43 @@ void ofono_netmon_serving_cell_notify(struct
>> ofono_netmon *netmon,
>> intval, uint8_t, DBUS_TYPE_BYTE);
>> break;
>>
>> +   case OFONO_NETMON_INFO_RSCP:
>> +   intval = va_arg(arglist, int);
>> +
>> +   CELL_INFO_DICT_APPEND(,
>> "ReceivedSignalCodePower",
>> +   intval, uint8_t, DBUS_TYPE_BYTE);
>> +   break;
>> +
>> +   case OFONO_NETMON_INFO_ECN0:
>> +   intval = va_arg(arglist, int);
>> +
>> +   CELL_INFO_DICT_APPEND(,
>> "ReceivedEnergyRatio",
>> +   intval, uint8_t, DBUS_TYPE_BYTE);
>> +   break;
>> +
>> +   case OFONO_NETMON_INFO_RSRQ:
>> +   intval = va_arg(arglist, int);
>> +
>> +   CELL_INFO_DICT_APPEND(,
>> "ReferenceSignalReceivedQuality",
>> +   intval, uint8_t, DBUS_TYPE_BYTE);
>> +   break;
>> +
>> +   case OFONO_NETMON_INFO_RSRP:
>> +   intval = va_arg(arglist, int);
>> +
>> +   CELL_INFO_DICT_APPEND(,
>> "ReferenceSignalReceivedPower",
>> +   intval, uint8_t, DBUS_TYPE_BYTE);
>> +   break;
>> +
>
>
> This looks fine, however there should be a patch documenting these and their
> respective value ranges inside doc/netmon-api.txt.

OK documented in netmonmonitor-api.txt of v2 of the patches. Thank you!

>> +   case OFONO_NETMON_INFO_OPERATOR:
>> +   op = va_arg(arglist, char *);
>> +
>> +   if (op && strlen(op))
>> +   ofono_dbus_dict_append(, "Operator",
>> +   DBUS_TYPE_STRING, );
>> +
>> +   break;
>> +
>> case OFONO_NETMON_INFO_INVALID:
>> break;
>> }
>>
>
> Regards,
> -Denis
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


Re: [PATCH 1/5] netmon: add OFONO_NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP|OPERATOR}

2016-11-30 Thread Djalal Harouni
Hi Denis,

On 29 November 2016 at 17:43, Denis Kenzior  wrote:
> Hi Djalal,
>
>
> On 11/25/2016 08:00 AM, dja...@endocode.com wrote:
>>
>> From: Djalal Harouni 
>>
>> Add more ofono netmon info types that will be served through the netmon
>> interface. The main user of this now will be the ublox modem.
>>
>> RSCP: Received Signal Code Power
>> ECN0: Received Energy Ratio
>> RSRQ: Reference Signal Received Quality
>> RSRP: Reference Signal Received Power
>> OPERATOR: the operator
>>
>> Patches using these types to follow.
>> ---
>>   include/netmon.h | 5 +
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/include/netmon.h b/include/netmon.h
>> index ec8a2e1..abde225 100644
>> --- a/include/netmon.h
>> +++ b/include/netmon.h
>> @@ -59,6 +59,11 @@ enum ofono_netmon_info {
>> OFONO_NETMON_INFO_RSSI, /* int */
>> OFONO_NETMON_INFO_TIMING_ADVANCE, /* int */
>> OFONO_NETMON_INFO_PSC, /* int */
>> +   OFONO_NETMON_INFO_RSCP, /* int */
>> +   OFONO_NETMON_INFO_ECN0, /* int */
>> +   OFONO_NETMON_INFO_RSRQ, /* int */
>> +   OFONO_NETMON_INFO_RSRP, /* int */
>> +   OFONO_NETMON_INFO_OPERATOR, /* char *, up to 24 digits */
>
>
> MCC & MNC are not enough?  This API is intended for various location
> services which hardly care about the text representation of the operator.
> They'd rather know the lac & ci, and possibly the mcc & mnc.
>
> I'm not sure if its worth including this as it is likely just coming from an
> MCCMNC database in the modem and this info is available via
> NetworkRegistration anyway.

Ok I dropped that one and will try to see how we can fix this at our end.

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