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, 1 month
[PATCH] devinfo: Add support of IMEISV
by Samrat Guha Niyogi
---
include/devinfo.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/devinfo.h b/include/devinfo.h
index a9acce9..9d1834f 100644
--- a/include/devinfo.h
+++ b/include/devinfo.h
@@ -46,6 +46,8 @@ struct ofono_devinfo_driver {
ofono_devinfo_query_cb_t cb, void *data);
void (*query_revision)(struct ofono_devinfo *info,
ofono_devinfo_query_cb_t cb, void *data);
+ void (*query_svn)(struct ofono_devinfo *info,
+ ofono_devinfo_query_cb_t cb, void *data);
};
int ofono_devinfo_driver_register(const struct ofono_devinfo_driver *d);
--
1.9.1
4 years, 9 months
[PATCH 6/6] test: Add get serving cell information script
by Nishanth V
---
Makefile.am | 3 ++-
test/get-serving-cell-info | 56 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+), 1 deletion(-)
create mode 100644 test/get-serving-cell-info
diff --git a/Makefile.am b/Makefile.am
index ce4c107..5cd9766 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -744,7 +744,8 @@ test_scripts = test/backtrace \
test/register-auto \
test/register-operator \
test/set-sms-smsc \
- test/set-sms-bearer
+ test/set-sms-bearer \
+ test/get-serving-cell-info
if TEST
testdir = $(pkglibdir)/test
diff --git a/test/get-serving-cell-info b/test/get-serving-cell-info
new file mode 100644
index 0000000..05dc9fe
--- /dev/null
+++ b/test/get-serving-cell-info
@@ -0,0 +1,56 @@
+#!/usr/bin/python3
+
+import dbus
+
+bus = dbus.SystemBus()
+
+manager = dbus.Interface(bus.get_object('org.ofono', '/'), 'org.ofono.Manager')
+
+modems = manager.GetModems()
+path = modems[0][0]
+
+monitor = dbus.Interface(bus.get_object('org.ofono', path),
+ 'org.ofono.NetworkMonitor')
+
+try:
+ servingcell = monitor.GetServingCellInformation()
+except dbus.DBusException as e:
+ print("Unable to get serving cell information")
+ exit()
+
+tech = 'Technology'
+mcc = 'MobileCountryCode'
+mnc = 'MobileNetworkCode'
+lac = 'LocationAreaCode'
+cid = 'CellId'
+psc = 'PrimaryScramblingCode'
+rssi = 'Strength'
+ber = 'BitErrorRate'
+
+print("Current serving cell information:")
+
+if tech in servingcell:
+ print(" [ Radio Access Technology = %s]" % (servingcell[tech]))
+
+if mcc in servingcell:
+ print(" [ Mobile Country Code = %s]" % (servingcell[mcc]))
+
+if mnc in servingcell:
+ print(" [ Mobile Network Code = %s]" % (servingcell[mnc]))
+
+if lac in servingcell:
+ print(" [ Location Area Code = %d]" % (servingcell[lac]))
+
+if cid in servingcell:
+ print(" [ Cell Identity = %d]" % (servingcell[cid]))
+
+if psc in servingcell:
+ print(" [ Primary Scrambling Code = %d]" % (servingcell[psc]))
+
+if rssi in servingcell:
+ print(" [ Signal Strength = %d]" % (servingcell[rssi]))
+
+if ber in servingcell:
+ print(" [ Bit Error Rate = %d]" % (servingcell[ber]))
+
+print('')
--
1.9.1
4 years, 9 months
[PATCH 1/6] include: Add netmon changes
by Nishanth V
---
include/dbus.h | 1 +
include/netmon.h | 14 ++++++++++++++
2 files changed, 15 insertions(+)
diff --git a/include/dbus.h b/include/dbus.h
index 3d39eff..99d45d6 100644
--- a/include/dbus.h
+++ b/include/dbus.h
@@ -60,6 +60,7 @@ extern "C" {
#define OFONO_GNSS_POSR_AGENT_INTERFACE "org.ofono.PositioningRequestAgent"
#define OFONO_HANDSFREE_INTERFACE OFONO_SERVICE ".Handsfree"
#define OFONO_SIRI_INTERFACE OFONO_SERVICE ".Siri"
+#define OFONO_NETMON_INTERFACE OFONO_SERVICE ".NetworkMonitor"
/* CDMA Interfaces */
#define OFONO_CDMA_VOICECALL_MANAGER_INTERFACE "org.ofono.cdma.VoiceCallManager"
diff --git a/include/netmon.h b/include/netmon.h
index 324d2f7..a8390c4 100644
--- a/include/netmon.h
+++ b/include/netmon.h
@@ -77,6 +77,20 @@ void ofono_netmon_serving_cell_notify(struct ofono_netmon *netmon,
enum ofono_netmon_cell_type type,
int info_type, ...);
+int ofono_netmon_driver_register(const struct ofono_netmon_driver *d);
+
+void ofono_netmon_driver_unregister(const struct ofono_netmon_driver *d);
+
+struct ofono_netmon *ofono_netmon_create(struct ofono_modem *modem,
+ unsigned int vendor, const char *driver, void *data);
+
+void ofono_netmon_register(struct ofono_netmon *netmon);
+
+void ofono_netmon_remove(struct ofono_netmon *netmon);
+
+void ofono_netmon_set_data(struct ofono_netmon *netmon, void *data);
+
+void *ofono_netmon_get_data(struct ofono_netmon *netmon);
#ifdef __cplusplus
}
--
1.9.1
4 years, 9 months
[PATCH] devinfo: Add support of IMEISV
by Samrat Guha Niyogi
---
test/test-modem | 3 +++
1 file changed, 3 insertions(+)
diff --git a/test/test-modem b/test/test-modem
index aa38b1f..59e9163 100755
--- a/test/test-modem
+++ b/test/test-modem
@@ -39,6 +39,9 @@ if __name__ == "__main__":
if 'Serial' in properties:
print("Serial: %s" % (properties['Serial']))
+ if 'SoftwareVersionNumber' in properties:
+ print("SoftwareVersionNumber: %s" % (properties['SoftwareVersionNumber']))
+
if 'Powered' in properties:
print("Powered: %s" % (properties['Powered']))
--
1.9.1
4 years, 9 months
[PATCH] devinfo: Add support of IMEISV
by Samrat Guha Niyogi
---
doc/modem-api.txt | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/doc/modem-api.txt b/doc/modem-api.txt
index 9fd23ba..c0a575f 100644
--- a/doc/modem-api.txt
+++ b/doc/modem-api.txt
@@ -90,6 +90,11 @@ Properties boolean Powered [readwrite]
"hfp") this corresponds to the Bluetooth Device
Address of the remote device.
+ string SoftwareVersionNumber [readonly, optional]
+
+ String representing the software version number of the
+ modem device.
+
array{string} Features [readonly]
List of currently enabled features. It uses simple
--
1.9.1
4 years, 9 months
[PATCH] devinfo: Add support of IMEISV
by Samrat Guha Niyogi
---
drivers/rilmodem/devinfo.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 43 insertions(+), 1 deletion(-)
diff --git a/drivers/rilmodem/devinfo.c b/drivers/rilmodem/devinfo.c
index bb1e642..2419762 100644
--- a/drivers/rilmodem/devinfo.c
+++ b/drivers/rilmodem/devinfo.c
@@ -96,6 +96,47 @@ static void ril_query_revision(struct ofono_devinfo *info,
CALLBACK_WITH_FAILURE(cb, NULL, data);
}
+static void query_svn_cb(struct ril_msg *message, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_devinfo_query_cb_t cb = cbd->cb;
+ GRil *ril = cbd->user;
+ struct parcel rilp;
+ char *imeisv;
+
+ if (message->error != RIL_E_SUCCESS)
+ goto error;
+
+ g_ril_init_parcel(message, &rilp);
+
+ imeisv = parcel_r_string(&rilp);
+
+ g_ril_append_print_buf(ril, "{%s}", imeisv);
+ g_ril_print_response(ril, message);
+
+ CALLBACK_WITH_SUCCESS(cb, imeisv, cbd->data);
+ g_free(imeisv);
+ return;
+
+error:
+ CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
+}
+
+static void ril_query_svn(struct ofono_devinfo *info,
+ ofono_devinfo_query_cb_t cb,
+ void *data)
+{
+ GRil *ril = ofono_devinfo_get_data(info);
+ struct cb_data *cbd = cb_data_new(cb, data, ril);
+
+ if (g_ril_send(ril, RIL_REQUEST_GET_IMEISV, NULL,
+ query_svn_cb, cbd, g_free) > 0)
+ return;
+
+ g_free(cbd);
+ CALLBACK_WITH_FAILURE(cb, NULL, data);
+}
+
static void query_serial_cb(struct ril_msg *message, gpointer user_data)
{
struct cb_data *cbd = user_data;
@@ -178,7 +219,8 @@ static struct ofono_devinfo_driver driver = {
.query_manufacturer = ril_query_manufacturer,
.query_model = ril_query_model,
.query_revision = ril_query_revision,
- .query_serial = ril_query_serial
+ .query_serial = ril_query_serial,
+ .query_svn = ril_query_svn
};
void ril_devinfo_init(void)
--
1.9.1
4 years, 9 months
[PATCH] devinfo: Add support of IMEISV
by Samrat Guha Niyogi
---
src/modem.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/src/modem.c b/src/modem.c
index 2de8d98..a4d4490 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -94,6 +94,7 @@ struct ofono_devinfo {
char *model;
char *revision;
char *serial;
+ char *svn;
unsigned int dun_watch;
const struct ofono_devinfo_driver *driver;
void *driver_data;
@@ -815,6 +816,11 @@ void __ofono_modem_append_properties(struct ofono_modem *modem,
ofono_dbus_dict_append(dict, "Serial",
DBUS_TYPE_STRING,
&info->serial);
+
+ if (info->svn)
+ ofono_dbus_dict_append(dict, "SoftwareVersionNumber",
+ DBUS_TYPE_STRING,
+ &info->svn);
}
interfaces = g_new0(char *, g_slist_length(modem->interface_list) + 1);
@@ -1343,6 +1349,32 @@ void ofono_modem_remove_interface(struct ofono_modem *modem,
modem->interface_update = g_idle_add(trigger_interface_update, modem);
}
+static void query_svn_cb(const struct ofono_error *error,
+ const char *svn, void *user)
+{
+ struct ofono_devinfo *info = user;
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path = __ofono_atom_get_path(info->atom);
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
+ return;
+
+ info->svn = g_strdup(svn);
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_MODEM_INTERFACE,
+ "SoftwareVersionNumber", DBUS_TYPE_STRING,
+ &info->svn);
+}
+
+static void query_svn(struct ofono_devinfo *info)
+{
+ if (info->driver->query_svn == NULL)
+ return;
+
+ info->driver->query_svn(info, query_svn_cb, info);
+}
+
static void query_serial_cb(const struct ofono_error *error,
const char *serial, void *user)
{
@@ -1351,7 +1383,7 @@ static void query_serial_cb(const struct ofono_error *error,
const char *path = __ofono_atom_get_path(info->atom);
if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
- return;
+ goto out;
info->serial = g_strdup(serial);
@@ -1359,6 +1391,8 @@ static void query_serial_cb(const struct ofono_error *error,
OFONO_MODEM_INTERFACE,
"Serial", DBUS_TYPE_STRING,
&info->serial);
+out:
+ query_svn(info);
}
static void query_serial(struct ofono_devinfo *info)
@@ -1619,6 +1653,9 @@ static void devinfo_unregister(struct ofono_atom *atom)
g_free(info->serial);
info->serial = NULL;
+
+ g_free(info->svn);
+ info->svn = NULL;
}
void ofono_devinfo_register(struct ofono_devinfo *info)
--
1.9.1
4 years, 9 months
[PATCH 5/6] sofia3gr: Add netmon support
by Nishanth V
---
plugins/ril_sofia3gr.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/plugins/ril_sofia3gr.c b/plugins/ril_sofia3gr.c
index 2cba72f..bdbc39d 100644
--- a/plugins/ril_sofia3gr.c
+++ b/plugins/ril_sofia3gr.c
@@ -46,6 +46,7 @@
#include <ofono/gprs-context.h>
#include <ofono/radio-settings.h>
#include <ofono/ussd.h>
+#include <ofono/netmon.h>
#include <gril/gril.h>
@@ -172,6 +173,7 @@ static void ril_post_online(struct ofono_modem *modem)
ofono_netreg_create(modem, 0, "rilmodem", rd->ril);
ofono_radio_settings_create(modem, 0, "rilmodem", rd->ril);
ofono_ussd_create(modem, 0, "rilmodem", rd->ril);
+ ofono_netmon_create(modem, 0, "rilmodem", rd->ril);
}
static void ril_set_online_cb(struct ril_msg *message, gpointer user_data)
--
1.9.1
4 years, 9 months
[PATCH 4/6] rilmodem: Add netmon support
by Nishanth V
---
Makefile.am | 1 +
drivers/rilmodem/netmon.c | 292 ++++++++++++++++++++++++++++++++++++++++++++
drivers/rilmodem/rilmodem.c | 2 +
drivers/rilmodem/rilmodem.h | 3 +
4 files changed, 298 insertions(+)
create mode 100644 drivers/rilmodem/netmon.c
diff --git a/Makefile.am b/Makefile.am
index ec648bd..ce4c107 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -150,6 +150,7 @@ builtin_sources += drivers/rilmodem/rilmodem.h \
drivers/rilmodem/call-forwarding.c \
drivers/rilmodem/radio-settings.c \
drivers/rilmodem/call-barring.c \
+ drivers/rilmodem/netmon.c \
drivers/infineonmodem/infineon_constants.h
endif
diff --git a/drivers/rilmodem/netmon.c b/drivers/rilmodem/netmon.c
new file mode 100644
index 0000000..5cdfa5e
--- /dev/null
+++ b/drivers/rilmodem/netmon.c
@@ -0,0 +1,292 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2016 Intel Corporation. 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 <config.h>
+#endif
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <errno.h>
+
+#include <glib.h>
+
+#include <ofono/log.h>
+#include <ofono/modem.h>
+#include <ofono/netmon.h>
+
+#include "gril.h"
+
+#include "rilmodem.h"
+
+/*
+ * Defined below are copy of
+ * RIL_CellInfoType defined in Ril.h
+ */
+#define NETMON_RIL_CELLINFO_TYPE_GSM 1
+#define NETMON_RIL_CELLINFO_TYPE_CDMA 2
+#define NETMON_RIL_CELLINFO_TYPE_LTE 3
+#define NETMON_RIL_CELLINFO_TYPE_UMTS 4
+#define NETMON_RIL_CELLINFO_TYPE_TDSCDMA 5
+
+/* size of RIL_CellInfoGsm */
+#define NETMON_RIL_CELLINFO_SIZE_GSM 24
+/* size of RIL_CellInfoCDMA */
+#define NETMON_RIL_CELLINFO_SIZE_CDMA 40
+/* size of RIL_CellInfoLte */
+#define NETMON_RIL_CELLINFO_SIZE_LTE 44
+/* size of RIL_CellInfoWcdma */
+#define NETMON_RIL_CELLINFO_SIZE_UMTS 28
+/* size of RIL_CellInfoTdscdma */
+#define NETMON_RIL_CELLINFO_SIZE_TDSCDMA 24
+
+struct netmon_data {
+ GRil *ril;
+};
+
+static gboolean ril_delayed_register(gpointer user_data)
+{
+ struct ofono_netmon *netmon = user_data;
+
+ ofono_netmon_register(netmon);
+
+ return FALSE;
+}
+
+static int ril_cell_type_to_size(int cell_type)
+{
+ switch (cell_type) {
+ case NETMON_RIL_CELLINFO_TYPE_GSM:
+ return NETMON_RIL_CELLINFO_SIZE_GSM;
+
+ case NETMON_RIL_CELLINFO_TYPE_CDMA:
+ return NETMON_RIL_CELLINFO_SIZE_CDMA;
+
+ case NETMON_RIL_CELLINFO_TYPE_LTE:
+ return NETMON_RIL_CELLINFO_SIZE_LTE;
+
+ case NETMON_RIL_CELLINFO_TYPE_UMTS:
+ return NETMON_RIL_CELLINFO_SIZE_UMTS;
+
+ case NETMON_RIL_CELLINFO_TYPE_TDSCDMA:
+ return NETMON_RIL_CELLINFO_SIZE_TDSCDMA;
+ }
+
+ return 0;
+}
+
+static void ril_netmon_update_cb(struct ril_msg *message, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_netmon_cb_t cb = cbd->cb;
+ struct ofono_netmon *netmon = cbd->data;
+ struct parcel rilp;
+ int skip_len;
+ int cell_info_cnt;
+ int cell_type;
+ int registered = 0;
+ int mcc, mnc;
+ int lac, cid, psc;
+ int rssi, ber;
+ char s_mcc[OFONO_MAX_MCC_LENGTH + 1];
+ char s_mnc[OFONO_MAX_MNC_LENGTH + 1];
+ int i, j;
+
+ if (message->error != RIL_E_SUCCESS)
+ goto error;
+
+ g_ril_init_parcel(message, &rilp);
+
+ cell_info_cnt = parcel_r_int32(&rilp);
+
+ for (i = 0; i < cell_info_cnt; i++) {
+ cell_type = parcel_r_int32(&rilp);
+
+ registered = parcel_r_int32(&rilp);
+
+ /* skipping timeStampType in Ril cell info which is not needed */
+ (void)parcel_r_int32(&rilp);
+
+ /*skipping timeStamp which is a uint64_t type */
+ (void)parcel_r_int32(&rilp);
+ (void)parcel_r_int32(&rilp);
+
+ if (registered)
+ break;
+
+ /*
+ * not serving cell,
+ * skip remainder of current cell info
+ */
+ skip_len = ril_cell_type_to_size(cell_type)/sizeof(int);
+
+ for (j = 0; j < skip_len; j++)
+ (void)parcel_r_int32(&rilp);
+
+ }
+
+ if (!registered)
+ goto error;
+
+ if (cell_type == NETMON_RIL_CELLINFO_TYPE_GSM) {
+ mcc = parcel_r_int32(&rilp);
+ mnc = parcel_r_int32(&rilp);
+ lac = parcel_r_int32(&rilp);
+ cid = parcel_r_int32(&rilp);
+ rssi = parcel_r_int32(&rilp);
+ ber = parcel_r_int32(&rilp);
+
+ if (mcc >= 0 && mcc <= 999)
+ snprintf(s_mcc, sizeof(s_mcc), "%03d", mcc);
+ else
+ strcpy(s_mcc, "");
+
+ if (mnc >= 0 && mnc <= 999)
+ snprintf(s_mnc, sizeof(s_mnc), "%03d", mnc);
+ else
+ strcpy(s_mnc, "");
+
+ lac = (lac >= 0 && lac <= 65535) ? lac : -1;
+
+ cid = (cid >= 0 && cid <= 65535) ? cid : -1;
+
+ rssi = (rssi >= 0 && rssi <= 31) ? rssi : -1;
+
+ ber = (ber >= 0 && ber <= 7) ? ber : -1;
+
+ ofono_netmon_serving_cell_notify(netmon, OFONO_NETMON_CELL_TYPE_GSM,
+ OFONO_NETMON_INFO_MCC, s_mcc,
+ OFONO_NETMON_INFO_MNC, s_mnc,
+ OFONO_NETMON_INFO_LAC, lac,
+ OFONO_NETMON_INFO_CI, cid,
+ OFONO_NETMON_INFO_RSSI, rssi,
+ OFONO_NETMON_INFO_BER, ber,
+ OFONO_NETMON_INFO_INVALID);
+
+ } else if (cell_type == NETMON_RIL_CELLINFO_TYPE_UMTS) {
+ mcc = parcel_r_int32(&rilp);
+ mnc = parcel_r_int32(&rilp);
+ lac = parcel_r_int32(&rilp);
+ cid = parcel_r_int32(&rilp);
+ psc = parcel_r_int32(&rilp);
+ rssi = parcel_r_int32(&rilp);
+ ber = parcel_r_int32(&rilp);
+
+ if (mcc >= 0 && mcc <= 999)
+ snprintf(s_mcc, sizeof(s_mcc), "%03d", mcc);
+ else
+ strcpy(s_mcc, "");
+
+ if (mnc >= 0 && mnc <= 999)
+ snprintf(s_mnc, sizeof(s_mnc), "%03d", mnc);
+ else
+ strcpy(s_mnc, "");
+
+ lac = (lac >= 0 && lac <= 65535) ? lac : -1;
+
+ cid = (cid >= 0 && cid <= 268435455) ? cid : -1;
+
+ psc = (psc >= 0 && rssi <= 511) ? psc : -1;
+
+ rssi = (rssi >= 0 && rssi <= 31) ? rssi : -1;
+
+ ber = (ber >= 0 && ber <= 7) ? ber : -1;
+
+ ofono_netmon_serving_cell_notify(netmon, OFONO_NETMON_CELL_TYPE_UMTS,
+ OFONO_NETMON_INFO_MCC, s_mcc,
+ OFONO_NETMON_INFO_MNC, s_mnc,
+ OFONO_NETMON_INFO_LAC, lac,
+ OFONO_NETMON_INFO_CI, cid,
+ OFONO_NETMON_INFO_PSC, psc,
+ OFONO_NETMON_INFO_RSSI, rssi,
+ OFONO_NETMON_INFO_BER, ber,
+ OFONO_NETMON_INFO_INVALID);
+
+ } else {
+ goto error;
+ }
+
+ CALLBACK_WITH_SUCCESS(cb, cbd->data);
+ return;
+
+error:
+ CALLBACK_WITH_FAILURE(cb, cbd->data);
+ return;
+}
+
+static int ril_netmon_probe(struct ofono_netmon *netmon,
+ unsigned int vendor, void *user)
+{
+ GRil *ril = user;
+
+ struct netmon_data *ud = g_new0(struct netmon_data, 1);
+
+ ud->ril = g_ril_clone(ril);
+
+ ofono_netmon_set_data(netmon, ud);
+
+ g_idle_add(ril_delayed_register, netmon);
+
+ return 0;
+}
+
+static void ril_netmon_remove(struct ofono_netmon *netmon)
+{
+ struct netmon_data *nmd = ofono_netmon_get_data(netmon);
+
+ ofono_netmon_set_data(netmon, NULL);
+
+ g_ril_unref(nmd->ril);
+}
+
+static void ril_netmon_request_update(struct ofono_netmon *netmon,
+ ofono_netmon_cb_t cb, void *data)
+{
+ struct netmon_data *nmd = ofono_netmon_get_data(netmon);
+ struct cb_data *cbd = cb_data_new(cb, data, nmd);
+
+ if (g_ril_send(nmd->ril, RIL_REQUEST_GET_CELL_INFO_LIST, NULL,
+ ril_netmon_update_cb, cbd, NULL) > 0)
+ return;
+
+ g_free(cbd);
+ CALLBACK_WITH_FAILURE(cb, data);
+}
+
+static struct ofono_netmon_driver driver = {
+ .name = RILMODEM,
+ .probe = ril_netmon_probe,
+ .remove = ril_netmon_remove,
+ .request_update = ril_netmon_request_update,
+};
+
+void ril_netmon_init(void)
+{
+ ofono_netmon_driver_register(&driver);
+}
+
+void ril_netmon_exit(void)
+{
+ ofono_netmon_driver_unregister(&driver);
+}
diff --git a/drivers/rilmodem/rilmodem.c b/drivers/rilmodem/rilmodem.c
index e693563..e4de3c2 100644
--- a/drivers/rilmodem/rilmodem.c
+++ b/drivers/rilmodem/rilmodem.c
@@ -51,6 +51,7 @@ static int rilmodem_init(void)
ril_call_forwarding_init();
ril_radio_settings_init();
ril_call_barring_init();
+ ril_netmon_init();
return 0;
}
@@ -72,6 +73,7 @@ static void rilmodem_exit(void)
ril_call_forwarding_exit();
ril_radio_settings_exit();
ril_call_barring_exit();
+ ril_netmon_exit();
}
OFONO_PLUGIN_DEFINE(rilmodem, "RIL modem driver", VERSION,
diff --git a/drivers/rilmodem/rilmodem.h b/drivers/rilmodem/rilmodem.h
index 987ce3c..f838b6b 100644
--- a/drivers/rilmodem/rilmodem.h
+++ b/drivers/rilmodem/rilmodem.h
@@ -69,3 +69,6 @@ extern void ril_call_barring_exit(void);
extern void ril_phonebook_init(void);
extern void ril_phonebook_exit(void);
+
+extern void ril_netmon_init(void);
+extern void ril_netmon_exit(void);
--
1.9.1
4 years, 9 months