[PATCH 2/3] netmon: adding get functionality for neighbouring cell information
by Antara Borwankar
Handled the get neighbouring cell information function which returns
an array of signal strength of all neighbouring cells.
---
src/netmon.c | 191 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 191 insertions(+)
diff --git a/src/netmon.c b/src/netmon.c
index 6c19df5..daa1875 100644
--- a/src/netmon.c
+++ b/src/netmon.c
@@ -50,6 +50,8 @@ struct ofono_netmon {
const struct ofono_netmon_driver *driver;
DBusMessage *pending;
DBusMessage *reply;
+ DBusMessageIter iter;
+ DBusMessageIter arr;
void *driver_data;
struct ofono_atom *atom;
struct netmon_agent *agent;
@@ -403,6 +405,192 @@ static DBusMessage *netmon_unregister_agent(DBusConnection *conn,
return dbus_message_new_method_return(msg);
}
+
+void ofono_netmon_neighbouring_cell_notify(struct ofono_netmon *netmon,
+ enum ofono_netmon_cell_type type,
+ int info_type, ...)
+{
+ va_list arglist;
+ DBusMessageIter dict;
+ DBusMessageIter strct;
+ enum ofono_netmon_info next_info_type = info_type;
+ const char *tech = cell_type_to_tech_name(type);
+ char *mcc;
+ char *mnc;
+ char *cell_id;
+ int intval;
+
+ if (netmon->pending == NULL)
+ return;
+
+ if(!netmon->reply) {
+ netmon->reply = dbus_message_new_method_return(netmon->pending);
+ dbus_message_iter_init_append(netmon->reply, &netmon->iter);
+
+ dbus_message_iter_open_container(&netmon->iter, DBUS_TYPE_ARRAY,
+ DBUS_STRUCT_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_ARRAY_AS_STRING
+ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ DBUS_TYPE_VARIANT_AS_STRING
+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING
+ DBUS_STRUCT_END_CHAR_AS_STRING,
+ &netmon->arr);
+ }
+
+ tech = cell_type_to_tech_name(type);
+
+ dbus_message_iter_open_container(&netmon->arr, DBUS_TYPE_STRUCT,
+ NULL, &strct);
+ dbus_message_iter_open_container(&strct, DBUS_TYPE_ARRAY,
+ OFONO_PROPERTIES_ARRAY_SIGNATURE,
+ &dict);
+
+ va_start(arglist, info_type);
+
+ if (tech == NULL)
+ goto done;
+
+ ofono_dbus_dict_append(&dict, "Technology",
+ DBUS_TYPE_STRING, &tech);
+
+ while (next_info_type != OFONO_NETMON_INFO_INVALID) {
+ switch (next_info_type) {
+ case OFONO_NETMON_INFO_MCC:
+ mcc = va_arg(arglist, char *);
+
+ if (mcc && strlen(mcc))
+ ofono_dbus_dict_append(&dict,
+ "MobileCountryCode",
+ DBUS_TYPE_STRING, &mcc);
+ break;
+
+ case OFONO_NETMON_INFO_MNC:
+ mnc = va_arg(arglist, char *);
+
+ if (mnc && strlen(mnc))
+ ofono_dbus_dict_append(&dict,
+ "MobileNetworkCode",
+ DBUS_TYPE_STRING, &mnc);
+ break;
+
+ case OFONO_NETMON_INFO_CI:
+ cell_id = va_arg(arglist, char *);
+
+ if (cell_id && strlen(cell_id))
+ ofono_dbus_dict_append(&dict,
+ "CellId",
+ DBUS_TYPE_STRING, &cell_id);
+ break;
+
+ case OFONO_NETMON_INFO_RXLEV:
+ intval = va_arg(arglist, int);
+
+ CELL_INFO_DICT_APPEND(&dict, "Strength",
+ intval, uint8_t, DBUS_TYPE_BYTE);
+ break;
+
+ case OFONO_NETMON_INFO_BER:
+ intval = va_arg(arglist, int);
+
+ CELL_INFO_DICT_APPEND(&dict, "BitErrorRate",
+ intval, uint8_t, DBUS_TYPE_BYTE);
+ break;
+
+ case OFONO_NETMON_INFO_RSCP:
+ intval = va_arg(arglist, int);
+
+ CELL_INFO_DICT_APPEND(&dict, "ReceivedSignalCodePower",
+ intval, uint8_t, DBUS_TYPE_BYTE);
+ break;
+
+ case OFONO_NETMON_INFO_ECN0:
+ intval = va_arg(arglist, int);
+
+ CELL_INFO_DICT_APPEND(&dict, "ReceivedEnergyRatio",
+ intval, uint8_t, DBUS_TYPE_BYTE);
+ break;
+
+ case OFONO_NETMON_INFO_RSRQ:
+ intval = va_arg(arglist, int);
+
+ CELL_INFO_DICT_APPEND(&dict,
+ "ReferenceSignalReceivedQuality",
+ intval, uint8_t, DBUS_TYPE_BYTE);
+ break;
+
+ case OFONO_NETMON_INFO_RSRP:
+ intval = va_arg(arglist, int);
+
+ CELL_INFO_DICT_APPEND(&dict,
+ "ReferenceSignalReceivedPower",
+ intval, uint8_t, DBUS_TYPE_BYTE);
+ break;
+
+ case OFONO_NETMON_INFO_INVALID:
+ default:
+ break;
+ }
+
+ next_info_type = va_arg(arglist, int);
+ }
+
+done:
+ va_end(arglist);
+
+ dbus_message_iter_close_container(&strct, &dict);
+ dbus_message_iter_close_container(&netmon->arr, &strct);
+}
+
+static void neighbouring_cell_info_callback(const struct ofono_error *error,
+ void *data)
+{
+ struct ofono_netmon *netmon = data;
+ DBusMessage *reply = netmon->reply;
+
+ DBG("");
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+ if (reply)
+ dbus_message_unref(reply);
+
+ reply = __ofono_error_failed(netmon->pending);
+ } else if (!reply) {
+ DBusMessageIter iter;
+ DBusMessageIter dict;
+
+ reply = dbus_message_new_method_return(netmon->pending);
+ dbus_message_iter_init_append(reply, &iter);
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ OFONO_PROPERTIES_ARRAY_SIGNATURE,
+ &dict);
+ dbus_message_iter_close_container(&iter, &dict);
+ } else {
+ dbus_message_iter_close_container(&netmon->iter, &netmon->arr);
+ }
+
+ netmon->reply = NULL;
+ __ofono_dbus_pending_reply(&netmon->pending, reply);
+}
+
+static DBusMessage *netmon_get_neighbouring_cell_info(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_netmon *netmon = data;
+
+ if (!netmon->driver->neighbouring_cell_update)
+ return __ofono_error_not_implemented(msg);
+
+ if (netmon->pending)
+ return __ofono_error_busy(msg);
+
+ netmon->pending = dbus_message_ref(msg);
+
+ netmon->driver->neighbouring_cell_update(netmon,
+ neighbouring_cell_info_callback, netmon);
+
+ return NULL;
+}
+
static const GDBusMethodTable netmon_methods[] = {
{ GDBUS_ASYNC_METHOD("GetServingCellInformation",
NULL, GDBUS_ARGS({ "cellinfo", "a{sv}" }),
@@ -413,6 +601,9 @@ static const GDBusMethodTable netmon_methods[] = {
{ GDBUS_METHOD("UnregisterAgent",
GDBUS_ARGS({ "agent", "o" }), NULL,
netmon_unregister_agent) },
+ { GDBUS_ASYNC_METHOD("GetNeighbouringCellInformation",
+ NULL, GDBUS_ARGS({ "cellinfo", "a(a{sv})" }),
+ netmon_get_neighbouring_cell_info) },
{ }
};
--
1.9.1
1 year, 7 months
[PATCH 0/4] RFC2: ublox serial modem support
by Philippe De Swert
After the comments on the last patchset, as requested I tried to take
the approach where the serial support is merged into the existing ublox driver.
Some notes/caveats:
1. Not sure if filtering on device path is the right approach to identify a serial modem
2. This will not really work unless we fix the CEREG/CREG mess
3. There is still the CHAP NO_AUTH ppp issue also
4. There is an issue with missing support for AT+CGDATA for SARA ublox modems. Did not
find a better way than mandate atd99 for all ublox modems based on vendor. Maybe there
is a cleaner/better way?
Philippe De Swert (4):
ubloxmodem: pre-eliminary support for ublox SARA serial modems
plugins/ublox: Enable serial connection for an ublox modem
udev: Recognize ublox serial modems
atmodem: Use atd99 as ppp command for ublox
drivers/atmodem/gprs-context.c | 11 ++++---
drivers/ubloxmodem/lte.c | 9 ++++++
drivers/ubloxmodem/netmon.c | 2 ++
drivers/ubloxmodem/ubloxmodem.c | 14 +++++++++
drivers/ubloxmodem/ubloxmodem.h | 2 ++
plugins/ublox.c | 55 ++++++++++++++++++++++++++++++++-
plugins/udevng.c | 7 +++++
7 files changed, 95 insertions(+), 5 deletions(-)
--
2.20.1
1 year, 7 months
[PATCH 3/3] xmm7modem: adding netmon changes for reporting neighbouring cell
by Antara Borwankar
Added netmon changes for xmm7modem driver to fetch neighbouring
cell information.
---
drivers/xmm7modem/netmon.c | 95 ++++++++++++++++++++++++++++++++++++----------
1 file changed, 76 insertions(+), 19 deletions(-)
diff --git a/drivers/xmm7modem/netmon.c b/drivers/xmm7modem/netmon.c
index ba70e2b..3ca0936 100644
--- a/drivers/xmm7modem/netmon.c
+++ b/drivers/xmm7modem/netmon.c
@@ -47,6 +47,7 @@ static const char *xmci_prefix[] = { "+XMCI:", NULL };
struct netmon_driver_data {
GAtChat *chat;
+ int xmci_mode;
};
enum xmci_ofono_type_info {
@@ -85,6 +86,7 @@ static void xmci_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct cb_data *cbd = user_data;
struct ofono_netmon *netmon = cbd->data;
+ struct netmon_driver_data *nmd = ofono_netmon_get_data(netmon);
ofono_netmon_cb_t cb = cbd->cb;
struct ofono_error error;
GAtResultIter iter;
@@ -96,6 +98,10 @@ static void xmci_cb(gboolean ok, GAtResult *result, gpointer user_data)
int ecn0 = -1;
int rsrq = -1;
int tech = -1;
+ int type = -1;
+ const char *cell_id;
+ char mcc[3];
+ char mnc[3];
DBG("ok %d", ok);
@@ -109,18 +115,21 @@ static void xmci_cb(gboolean ok, GAtResult *result, gpointer user_data)
g_at_result_iter_init(&iter, result);
while (g_at_result_iter_next(&iter, "+XMCI:")) {
- if (!g_at_result_iter_next_number(&iter, &number))
+ if (!g_at_result_iter_next_number(&iter, &type))
break;
- tech = xmm7modem_map_radio_access_technology(number);
+ tech = xmm7modem_map_radio_access_technology(type);
- switch (number) {
+ switch (type) {
+ case XMCI_GSM_NEIGH_CELL:
case XMCI_GSM_SERV_CELL:
- /* skip <MCC>,<MNC>,<LAC>,<CI>,<BSIC> */
- g_at_result_iter_skip_next(&iter);
- g_at_result_iter_skip_next(&iter);
- g_at_result_iter_skip_next(&iter);
+ /* <MCC>,<MNC>,<LAC>,<CI>,<BSIC> */
+ g_at_result_iter_next_number(&iter, &number);
+ snprintf(mcc, 3, "%d", number);
+ g_at_result_iter_next_number(&iter, &number);
+ snprintf(mnc, 3, "%d", number);
g_at_result_iter_skip_next(&iter);
+ g_at_result_iter_next_string(&iter, &cell_id);
g_at_result_iter_skip_next(&iter);
g_at_result_iter_next_number(&iter, &number);
@@ -129,15 +138,18 @@ static void xmci_cb(gboolean ok, GAtResult *result, gpointer user_data)
g_at_result_iter_next_number(&iter, &number);
ber = number != 99 ? number : ber;
break;
+ case XMCI_UMTS_NEIGH_CELL:
case XMCI_UMTS_SERV_CELL:
/*
- * skip <MCC>,<MNC>,<LAC>,<CI><PSC>,<DLUARFNC>,
+ * <MCC>,<MNC>,<LAC>,<CI><PSC>,<DLUARFNC>,
* <ULUARFCN>,<PATHLOSS>,<RSSI>
*/
+ g_at_result_iter_next_number(&iter, &number);
+ snprintf(mcc, 3, "%d", number);
+ g_at_result_iter_next_number(&iter, &number);
+ snprintf(mnc, 3, "%d", number);
g_at_result_iter_skip_next(&iter);
- g_at_result_iter_skip_next(&iter);
- g_at_result_iter_skip_next(&iter);
- g_at_result_iter_skip_next(&iter);
+ g_at_result_iter_next_string(&iter, &cell_id);
g_at_result_iter_skip_next(&iter);
g_at_result_iter_skip_next(&iter);
g_at_result_iter_skip_next(&iter);
@@ -150,15 +162,18 @@ static void xmci_cb(gboolean ok, GAtResult *result, gpointer user_data)
g_at_result_iter_next_number(&iter, &number);
ecn0 = number != 255 ? number : ecn0;
break;
+ case XMCI_LTE_NEIGH_CELL:
case XMCI_LTE_SERV_CELL:
/*
- * skip <MCC>,<MNC>,<TAC>,<CI>,<PCI>,<DLUARFNC>,
+ * <MCC>,<MNC>,<TAC>,<CI>,<PCI>,<DLUARFNC>,
* <ULUARFCN>,<PATHLOSS_LTE>
*/
+ g_at_result_iter_next_number(&iter, &number);
+ snprintf(mcc, 3, "%d", number);
+ g_at_result_iter_next_number(&iter, &number);
+ snprintf(mnc, 3, "%d", number);
g_at_result_iter_skip_next(&iter);
- g_at_result_iter_skip_next(&iter);
- g_at_result_iter_skip_next(&iter);
- g_at_result_iter_skip_next(&iter);
+ g_at_result_iter_next_string(&iter, &cell_id);
g_at_result_iter_skip_next(&iter);
g_at_result_iter_skip_next(&iter);
g_at_result_iter_skip_next(&iter);
@@ -174,8 +189,15 @@ static void xmci_cb(gboolean ok, GAtResult *result, gpointer user_data)
break;
}
- ofono_netmon_serving_cell_notify(netmon,
+ if ((nmd->xmci_mode == 0) &&
+ (type == XMCI_GSM_NEIGH_CELL ||
+ type == XMCI_UMTS_NEIGH_CELL ||
+ type == XMCI_LTE_NEIGH_CELL)) {
+ ofono_netmon_neighbouring_cell_notify(netmon,
tech,
+ OFONO_NETMON_INFO_MCC, mcc,
+ OFONO_NETMON_INFO_MNC, mnc,
+ OFONO_NETMON_INFO_CI, cell_id,
OFONO_NETMON_INFO_RXLEV, rxlev,
OFONO_NETMON_INFO_BER, ber,
OFONO_NETMON_INFO_RSCP, rscp,
@@ -183,10 +205,25 @@ static void xmci_cb(gboolean ok, GAtResult *result, gpointer user_data)
OFONO_NETMON_INFO_RSRQ, rsrq,
OFONO_NETMON_INFO_RSRP, rsrp,
OFONO_NETMON_INFO_INVALID);
-
- CALLBACK_WITH_SUCCESS(cb, cbd->data);
- break;
+ } else if ((nmd->xmci_mode == 1) &&
+ (type == XMCI_GSM_SERV_CELL ||
+ type == XMCI_UMTS_SERV_CELL ||
+ type == XMCI_LTE_SERV_CELL)) {
+ ofono_netmon_serving_cell_notify(netmon,
+ tech,
+ OFONO_NETMON_INFO_RXLEV, rxlev,
+ OFONO_NETMON_INFO_BER, ber,
+ OFONO_NETMON_INFO_RSCP, rscp,
+ OFONO_NETMON_INFO_ECN0, ecn0,
+ OFONO_NETMON_INFO_RSRQ, rsrq,
+ OFONO_NETMON_INFO_RSRP, rsrp,
+ OFONO_NETMON_INFO_INVALID);
+ break;
+ }
}
+
+ CALLBACK_WITH_SUCCESS(cb, cbd->data);
+ nmd->xmci_mode = -1;
}
static void xmm7modem_netmon_request_update(struct ofono_netmon *netmon,
@@ -194,6 +231,7 @@ static void xmm7modem_netmon_request_update(struct ofono_netmon *netmon,
{
struct netmon_driver_data *nmd = ofono_netmon_get_data(netmon);
struct cb_data *cbd = cb_data_new(cb, data);
+ nmd->xmci_mode = 1;
DBG("xmm7modem netmon request update");
@@ -205,6 +243,23 @@ static void xmm7modem_netmon_request_update(struct ofono_netmon *netmon,
CALLBACK_WITH_FAILURE(cb, data);
}
+static void xmm7modem_neighbouring_cell_update(struct ofono_netmon *netmon,
+ ofono_netmon_cb_t cb, void *data)
+{
+ struct netmon_driver_data *nmd = ofono_netmon_get_data(netmon);
+ struct cb_data *cbd = cb_data_new(cb, data);
+ nmd->xmci_mode = 0;
+
+ DBG("xmm7modem netmon request neighbouring cell update");
+
+ if (g_at_chat_send(nmd->chat, "AT+XMCI=0", xmci_prefix,
+ xmci_cb, cbd, g_free) > 0)
+ return;
+
+ g_free(cbd);
+ CALLBACK_WITH_FAILURE(cb, data);
+}
+
static gboolean ril_delayed_register(gpointer user_data)
{
struct ofono_netmon *netmon = user_data;
@@ -224,6 +279,7 @@ static int xmm7modem_netmon_probe(struct ofono_netmon *netmon,
nmd = g_new0(struct netmon_driver_data, 1);
nmd->chat = g_at_chat_clone(chat);
+ nmd->xmci_mode = -1;
ofono_netmon_set_data(netmon, nmd);
@@ -250,6 +306,7 @@ static const struct ofono_netmon_driver driver = {
.probe = xmm7modem_netmon_probe,
.remove = xmm7modem_netmon_remove,
.request_update = xmm7modem_netmon_request_update,
+ .neighbouring_cell_update = xmm7modem_neighbouring_cell_update,
};
void xmm_netmon_init(void)
--
1.9.1
1 year, 7 months
[PATCH 1/3] netmon: adding get function for neighbouring cell information
by Antara Borwankar
Added declaration of functions and structures required for getting
neighbouring cell information.
---
include/netmon.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/netmon.h b/include/netmon.h
index c8fcafa..a99d6ca 100644
--- a/include/netmon.h
+++ b/include/netmon.h
@@ -43,6 +43,8 @@ struct ofono_netmon_driver {
unsigned int enable,
unsigned int period,
ofono_netmon_cb_t cb, void *data);
+ void (*neighbouring_cell_update)(struct ofono_netmon *netmon,
+ ofono_netmon_cb_t cb, void *data);
};
enum ofono_netmon_cell_type {
@@ -104,6 +106,10 @@ void ofono_netmon_set_data(struct ofono_netmon *netmon, void *data);
void *ofono_netmon_get_data(struct ofono_netmon *netmon);
+void ofono_netmon_neighbouring_cell_notify(struct ofono_netmon *netmon,
+ enum ofono_netmon_cell_type type,
+ int info_type, ...);
+
#ifdef __cplusplus
}
#endif
--
1.9.1
1 year, 7 months