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, 2 months
[PATCH 0/5] ubloxmodem support +UCGED mode 2
by Djalal Harouni
Hello,
These patches support +UCGED mode 2 for ubloxmodem to collect some
Network environment statistics.
For now it only returns the following:
EARFCN E-UTRA Absolute Radio Frequency Channel Number (official name)
EBAND E-UTRA Band
CQI Channel Quality Indicator
Questions:
EBAND in ublox documentation is called LBand in +UCGED command doc.
It refers to E-UTRA Band , so I did go with the name EBAND instead of
LBAND, not sure if this is the right thing to do ?
If other values of +UCGED are useful upstream I will try to send them.
Will also follow up with a patch that allows older firmware to make use
of +UCGED mode 3.
Djalal Harouni (5):
netmon: add NETMON_INFO_{EARFCN|EBAND|CQI}
doc: document netmon EARFCN, EBand and CQI properties
netmon: handle OFONO_NETMON_INFO_{EARFCN|EBAND|CQI}
test:netmon: support EARFCN, Eband and CQI in testing
ublox:netmon: support +UCGED and get EARFCN, EBAND and CQI
4 years, 1 month
[PATCH 0/4] support MC7430 Sierra modem
by Christophe Ronco
Hi,
I have made some patch to add the support of the MC7430 Sierra modem.
This is a QMI modem.
I chose to use qmimodem sim driver instead of qmimodem simlegacy driver
because:
- a QMI command used in sim-legacy is not supported by MC7430
- UIM commands are more powerfull than DMS commands
I had some other problems fixed in following patches.
With these patches I am able to see the MC7430 modem as a service in
connman over ofono and to connect and disconnect it.
Patch can be applied to ofono 1.19.
Christophe
Christophe Ronco (4):
MC7430: use qmimodem sim driver
MC7430: add read_imsi feature to qmimodem sim driver
MC7430: fix get signal strength
MC7430: fix QMI notification messages handling
drivers/qmimodem/nas.h | 2 +-
drivers/qmimodem/qmi.c | 2 +-
drivers/qmimodem/sim.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++----
plugins/gobi.c | 2 +-
plugins/udevng.c | 2 --
5 files changed, 82 insertions(+), 12 deletions(-)
--
2.11.0
4 years, 1 month
Modem auto enable
by Enrico Sau
Hi all,
I'm working with a Telit modem and I noticed that in some computers ofono
performs an "auto enable" setting. In some other cases I have to set the
"Powered" property manually.
Does anyone know why?
How can I always have the auto enable feature?
Thank you,
Enrico
4 years, 2 months
[PATCH] sms.c: fix typo
by marko.sulejic@hale.at
From: Marko Šulejić <marko.sulejic(a)hale.at>
---
drivers/atmodem/sms.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/atmodem/sms.c b/drivers/atmodem/sms.c
index f93dd23..b6876b0 100644
--- a/drivers/atmodem/sms.c
+++ b/drivers/atmodem/sms.c
@@ -742,7 +742,7 @@ static void at_sms_initialized(struct ofono_sms *sms)
static void at_sms_not_supported(struct ofono_sms *sms)
{
- ofono_error("SMS not supported by this modem. If this is in error"
+ ofono_error("SMS not supported by this modem. If this is an error"
" please submit patches to support this hardware");
ofono_sms_remove(sms);
--
2.7.4
4 years, 2 months
[PATCH 2/2] ril_intel: changes for lte modem
by ANTARA BORWANKAR
plugin modified to bring up lte atom and
set MODEM_PROP_LTE_CAPABLE to TRUE
---
plugins/ril_intel.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/plugins/ril_intel.c b/plugins/ril_intel.c
index 69e848b..06bcaa9 100644
--- a/plugins/ril_intel.c
+++ b/plugins/ril_intel.c
@@ -130,10 +130,15 @@ static void ril_radio_state_changed(struct ril_msg *message,
static int ril_probe(struct ofono_modem *modem)
{
struct ril_data *rd;
+ ofono_bool_t lte_cap;
DBG("");
rd = g_new0(struct ril_data, 1);
+
+ lte_cap = getenv("OFONO_RIL_RAT_LTE") ? TRUE : FALSE;
+ ofono_modem_set_boolean(modem, MODEM_PROP_LTE_CAPABLE, lte_cap);
+
ofono_modem_set_data(modem, rd);
return 0;
@@ -437,7 +442,10 @@ static void ril_post_sim(struct ofono_modem *modem)
struct ofono_gprs *gprs;
struct ofono_gprs_context *gc;
- ofono_sms_create(modem, OFONO_RIL_VENDOR_IMC_SOFIA3GR,
+ if (ofono_modem_get_boolean(modem, MODEM_PROP_LTE_CAPABLE))
+ ofono_sms_create(modem, 0, "rilmodem", rd->ril);
+ else
+ ofono_sms_create(modem, OFONO_RIL_VENDOR_IMC_SOFIA3GR,
"rilmodem", rd->ril);
gprs = ofono_gprs_create(modem, 0, "rilmodem", rd->ril);
@@ -448,6 +456,9 @@ static void ril_post_sim(struct ofono_modem *modem)
OFONO_GPRS_CONTEXT_TYPE_INTERNET);
ofono_gprs_add_context(gprs, gc);
}
+
+ if (ofono_modem_get_boolean(modem, MODEM_PROP_LTE_CAPABLE))
+ ofono_lte_create(modem, "rilmodem", rd->ril);
}
static void ril_post_online(struct ofono_modem *modem)
@@ -455,8 +466,13 @@ static void ril_post_online(struct ofono_modem *modem)
struct ril_data *rd = ofono_modem_get_data(modem);
ofono_netreg_create(modem, 0, "rilmodem", rd->ril);
- ofono_radio_settings_create(modem, OFONO_RIL_VENDOR_IMC_SOFIA3GR,
- "rilmodem", rd->ril);
+
+ if (ofono_modem_get_boolean(modem, MODEM_PROP_LTE_CAPABLE))
+ ofono_radio_settings_create(modem, 0, "rilmodem", rd->ril);
+ else
+ ofono_radio_settings_create(modem, OFONO_RIL_VENDOR_IMC_SOFIA3GR,
+ "rilmodem", rd->ril);
+
ofono_ussd_create(modem, 0, "rilmodem", rd->ril);
ofono_netmon_create(modem, 0, "rilmodem", rd->ril);
}
--
1.9.1
4 years, 2 months
[PATCH 1/2] ril_intel: renamed ril_sofia3gr to ril_intel
by ANTARA BORWANKAR
renamed ril_sofia3gr.c to ril_intel.c
---
Makefile.am | 4 +-
plugins/ril_intel.c | 606 +++++++++++++++++++++++++++++++++++++++++++++++++
plugins/ril_sofia3gr.c | 606 -------------------------------------------------
3 files changed, 608 insertions(+), 608 deletions(-)
create mode 100644 plugins/ril_intel.c
delete mode 100644 plugins/ril_sofia3gr.c
diff --git a/Makefile.am b/Makefile.am
index 0f25f1f..a817565 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -127,8 +127,8 @@ builtin_sources += plugins/ril.c plugins/ril.h
builtin_modules += infineon
builtin_sources += plugins/infineon.c
-builtin_modules += ril_sofia3gr
-builtin_sources += plugins/ril_sofia3gr.c
+builtin_modules += ril_intel
+builtin_sources += plugins/ril_intel.c
builtin_modules += rilmodem
builtin_sources += drivers/rilmodem/rilmodem.h \
diff --git a/plugins/ril_intel.c b/plugins/ril_intel.c
new file mode 100644
index 0000000..69e848b
--- /dev/null
+++ b/plugins/ril_intel.c
@@ -0,0 +1,606 @@
+/*
+ *
+ * oFono - Open Source Telephony - RIL-based devices
+ *
+ * Copyright (C) 2008-2015 Intel Corporation. All rights reserved.
+ * Copyright (C) 2012-2014 Canonical Ltd.
+ * Copyright (C) 2013 Jolla Ltd.
+ *
+ * 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
+
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdbool.h>
+
+#include <unistd.h>
+#include <glib.h>
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include <ofono/plugin.h>
+#include <ofono/log.h>
+#include <ofono/types.h>
+#include <ofono/modem.h>
+#include <ofono/devinfo.h>
+#include <ofono/netreg.h>
+#include <ofono/sms.h>
+#include <ofono/sim.h>
+#include <ofono/gprs.h>
+#include <ofono/gprs-context.h>
+#include <ofono/radio-settings.h>
+#include <ofono/ussd.h>
+#include <ofono/netmon.h>
+
+#include <gril/gril.h>
+
+#include "drivers/rilmodem/rilmodem.h"
+#include "drivers/rilmodem/vendor.h"
+#include "gdbus.h"
+
+#include "ofono.h"
+
+#define THERMAL_MANAGEMENT_INTERFACE OFONO_SERVICE ".sofia3gr.ThermalManagement"
+
+struct ril_data {
+ GRil *ril;
+};
+
+struct ril_thermal_management {
+ DBusMessage *pending;
+ struct ofono_modem *modem;
+ dbus_bool_t throttling;
+};
+
+static int ril_send_power(GRil *ril, ofono_bool_t online,
+ GRilResponseFunc func,
+ gpointer user_data,
+ GDestroyNotify destroy)
+{
+ struct parcel rilp;
+
+ DBG("%d", online);
+
+ parcel_init(&rilp);
+ parcel_w_int32(&rilp, 1);
+ parcel_w_int32(&rilp, online);
+
+ g_ril_append_print_buf(ril, "(%d)", online);
+
+ return g_ril_send(ril, RIL_REQUEST_RADIO_POWER, &rilp,
+ func, user_data, destroy);
+}
+
+static void ril_debug(const char *str, void *user_data)
+{
+ const char *prefix = user_data;
+
+ ofono_info("%s%s", prefix, str);
+}
+
+static void ril_radio_state_changed(struct ril_msg *message,
+ gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct ril_data *rd = ofono_modem_get_data(modem);
+ struct parcel rilp;
+ int radio_state;
+
+ g_ril_init_parcel(message, &rilp);
+ radio_state = parcel_r_int32(&rilp);
+
+ if (rilp.malformed) {
+ ofono_error("%s: malformed parcel received", __func__);
+ ofono_modem_set_powered(modem, FALSE);
+ return;
+ }
+
+ g_ril_append_print_buf(rd->ril, "(state: %s)",
+ ril_radio_state_to_string(radio_state));
+ g_ril_print_unsol(rd->ril, message);
+
+ switch (radio_state) {
+ case RADIO_STATE_ON:
+ break;
+ case RADIO_STATE_UNAVAILABLE:
+ ofono_modem_set_powered(modem, FALSE);
+ break;
+ case RADIO_STATE_OFF:
+ break;
+ }
+}
+
+static int ril_probe(struct ofono_modem *modem)
+{
+ struct ril_data *rd;
+
+ DBG("");
+
+ rd = g_new0(struct ril_data, 1);
+ ofono_modem_set_data(modem, rd);
+
+ return 0;
+}
+
+static void ril_remove(struct ofono_modem *modem)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ struct ril_data *rd = ofono_modem_get_data(modem);
+ const char *path = ofono_modem_get_path(modem);
+
+ if (g_dbus_unregister_interface(conn, path,
+ THERMAL_MANAGEMENT_INTERFACE))
+ ofono_modem_remove_interface(modem,
+ THERMAL_MANAGEMENT_INTERFACE);
+
+ ofono_modem_set_data(modem, NULL);
+
+ g_ril_unref(rd->ril);
+ g_free(rd);
+}
+
+static void set_rf_power_status_cb(struct ril_msg *message, gpointer user_data)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ struct ril_thermal_management *tm = user_data;
+ struct ril_data *rd = ofono_modem_get_data(tm->modem);
+ const char *path = ofono_modem_get_path(tm->modem);
+
+ DBG("");
+
+ if (message->error != RIL_E_SUCCESS) {
+ ofono_error("%s RILD reply failure: %s",
+ g_ril_request_id_to_string(rd->ril, message->req),
+ ril_error_to_string(message->error));
+
+ __ofono_dbus_pending_reply(&tm->pending,
+ __ofono_error_failed(tm->pending));
+ return;
+ }
+
+ /* Change the throttling state */
+ tm->throttling = tm->throttling ? false : true;
+
+ __ofono_dbus_pending_reply(&tm->pending,
+ dbus_message_new_method_return(tm->pending));
+
+ ofono_dbus_signal_property_changed(conn, path,
+ THERMAL_MANAGEMENT_INTERFACE,
+ "TransmitPowerThrottling",
+ DBUS_TYPE_BOOLEAN,
+ &tm->throttling);
+}
+
+static DBusMessage *set_rf_power_status(DBusMessage *msg,
+ dbus_bool_t enable,
+ void *data)
+{
+ struct ril_thermal_management *tm = data;
+ struct ril_data *rd = ofono_modem_get_data(tm->modem);
+ struct parcel rilp;
+
+ int cmd_id;
+ char buf[4];
+
+ DBG("");
+
+ if (tm->pending)
+ return __ofono_error_busy(msg);
+
+ parcel_init(&rilp);
+ parcel_w_int32(&rilp, 2);
+ /* RIL_OEM_HOOK_STRING_SET_RF_POWER_STATUS = 0x000000AC */
+ cmd_id = 0x000000AC;
+ sprintf(buf, "%d", cmd_id);
+ parcel_w_string(&rilp, buf);
+
+ memset(buf, 0, sizeof(buf));
+ sprintf(buf, "%d", enable ? 1 : 0);
+ parcel_w_string(&rilp, buf);
+
+ g_ril_append_print_buf(rd->ril, "{cmd_id=0x%02X,arg=%s}", cmd_id, buf);
+
+ if (g_ril_send(rd->ril, RIL_REQUEST_OEM_HOOK_STRINGS, &rilp,
+ set_rf_power_status_cb, tm, NULL) == 0)
+ return __ofono_error_failed(msg);
+
+ tm->pending = dbus_message_ref(msg);
+
+ return NULL;
+}
+
+static DBusMessage *thermal_management_set_property(DBusConnection *conn,
+ DBusMessage *msg,
+ void *data)
+{
+ struct ril_thermal_management *tm = data;
+ DBusMessageIter iter;
+ DBusMessageIter var;
+ const char *name;
+ dbus_bool_t throttling;
+
+ DBG("");
+
+ if (!ofono_modem_get_online(tm->modem))
+ return __ofono_error_not_available(msg);
+
+ if (!dbus_message_iter_init(msg, &iter))
+ return __ofono_error_invalid_args(msg);
+
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
+ return __ofono_error_invalid_args(msg);
+
+ dbus_message_iter_get_basic(&iter, &name);
+
+ if (!strcmp(name, "TransmitPowerThrottling")) {
+ dbus_message_iter_next(&iter);
+
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT)
+ return __ofono_error_invalid_args(msg);
+
+ dbus_message_iter_recurse(&iter, &var);
+
+ if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BOOLEAN)
+ return __ofono_error_invalid_args(msg);
+
+ dbus_message_iter_get_basic(&var, &throttling);
+
+ if (tm->throttling == throttling)
+ /* Ignore set request if new state == current state */
+ return dbus_message_new_method_return(msg);
+
+ return set_rf_power_status(msg, throttling, tm);
+ }
+
+ return __ofono_error_invalid_args(msg);
+}
+
+static DBusMessage *thermal_management_get_properties(DBusConnection *conn,
+ DBusMessage *msg,
+ void *data)
+{
+ struct ril_thermal_management *tm = data;
+ DBusMessage *reply;
+ DBusMessageIter iter;
+ DBusMessageIter dict;
+
+ DBG("");
+
+ reply = dbus_message_new_method_return(msg);
+ if (reply == NULL)
+ return NULL;
+
+ dbus_message_iter_init_append(reply, &iter);
+
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ OFONO_PROPERTIES_ARRAY_SIGNATURE,
+ &dict);
+
+ ofono_dbus_dict_append(&dict, "TransmitPowerThrottling",
+ DBUS_TYPE_BOOLEAN,
+ &tm->throttling);
+
+ dbus_message_iter_close_container(&iter, &dict);
+
+ return reply;
+}
+
+static const GDBusMethodTable thermal_management_methods[] = {
+ { GDBUS_METHOD("GetProperties",
+ NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
+ thermal_management_get_properties) },
+ { GDBUS_ASYNC_METHOD("SetProperty",
+ GDBUS_ARGS({ "property", "s" }, { "value", "v" }),
+ NULL, thermal_management_set_property) },
+ {}
+};
+
+static const GDBusSignalTable thermal_management_signals[] = {
+ { GDBUS_SIGNAL("PropertyChanged",
+ GDBUS_ARGS({ "name", "s" }, { "value", "v" })) },
+ { }
+};
+
+static void thermal_management_cleanup(void *data)
+{
+ struct ril_thermal_management *tm = data;
+
+ if (tm->pending)
+ __ofono_dbus_pending_reply(&tm->pending,
+ __ofono_error_canceled(tm->pending));
+
+ g_free(tm);
+}
+
+static void get_rf_power_status_cb(struct ril_msg *message, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct ril_data *rd = ofono_modem_get_data(modem);
+ struct ril_thermal_management *tm;
+ DBusConnection *conn = ofono_dbus_get_connection();
+ struct parcel rilp;
+ gint numstr;
+ gchar *power_status;
+ char *endptr;
+ int enabled;
+ const char *path = ofono_modem_get_path(modem);
+
+ DBG("");
+
+ if (message->error != RIL_E_SUCCESS) {
+ ofono_error("%s RILD reply failure: %s",
+ g_ril_request_id_to_string(rd->ril, message->req),
+ ril_error_to_string(message->error));
+ return;
+ }
+
+ g_ril_init_parcel(message, &rilp);
+
+ numstr = parcel_r_int32(&rilp);
+ if (numstr < 1) {
+ ofono_error("RILD reply empty !");
+ return;
+ }
+
+ power_status = parcel_r_string(&rilp);
+ if (power_status == NULL || power_status == '\0')
+ return;
+
+ enabled = strtol(power_status, &endptr, 10);
+ /*
+ * power_status == endptr => conversion error
+ * *endptr != '\0' => partial conversion
+ */
+ if (power_status == endptr || *endptr != '\0')
+ return;
+
+ tm = g_try_new0(struct ril_thermal_management, 1);
+ if (tm == NULL)
+ return;
+
+ tm->modem = modem;
+ tm->throttling = (enabled > 0) ? true : false;
+
+
+ if (!g_dbus_register_interface(conn, path, THERMAL_MANAGEMENT_INTERFACE,
+ thermal_management_methods,
+ thermal_management_signals,
+ NULL, tm, thermal_management_cleanup)) {
+ ofono_error("Could not register %s interface under %s",
+ THERMAL_MANAGEMENT_INTERFACE, path);
+ g_free(tm);
+ return;
+ }
+
+ ofono_modem_add_interface(modem, THERMAL_MANAGEMENT_INTERFACE);
+}
+
+static int ril_thermal_management_enable(struct ofono_modem *modem)
+{
+ struct ril_data *rd = ofono_modem_get_data(modem);
+ struct parcel rilp;
+
+ int cmd_id;
+ char buf[4];
+
+ DBG("");
+
+ parcel_init(&rilp);
+ parcel_w_int32(&rilp, 1);
+ /* RIL_OEM_HOOK_STRING_GET_RF_POWER_STATUS = 0x000000AB */
+ cmd_id = 0x000000AB;
+ sprintf(buf, "%d", cmd_id);
+ parcel_w_string(&rilp, buf);
+
+ g_ril_append_print_buf(rd->ril, "{cmd_id=0x%02X}", cmd_id);
+
+ if (g_ril_send(rd->ril, RIL_REQUEST_OEM_HOOK_STRINGS, &rilp,
+ get_rf_power_status_cb, modem, NULL) > 0)
+ return 0;
+
+ /* Error path */
+
+ return -EIO;
+}
+
+static void ril_pre_sim(struct ofono_modem *modem)
+{
+ struct ril_data *rd = ofono_modem_get_data(modem);
+
+ DBG("");
+
+ ofono_devinfo_create(modem, 0, "rilmodem", rd->ril);
+ ofono_sim_create(modem, 0, "rilmodem", rd->ril);
+ ril_thermal_management_enable(modem);
+}
+
+static void ril_post_sim(struct ofono_modem *modem)
+{
+ struct ril_data *rd = ofono_modem_get_data(modem);
+ struct ofono_gprs *gprs;
+ struct ofono_gprs_context *gc;
+
+ ofono_sms_create(modem, OFONO_RIL_VENDOR_IMC_SOFIA3GR,
+ "rilmodem", rd->ril);
+
+ gprs = ofono_gprs_create(modem, 0, "rilmodem", rd->ril);
+ gc = ofono_gprs_context_create(modem, 0, "rilmodem", rd->ril);
+
+ if (gc) {
+ ofono_gprs_context_set_type(gc,
+ OFONO_GPRS_CONTEXT_TYPE_INTERNET);
+ ofono_gprs_add_context(gprs, gc);
+ }
+}
+
+static void ril_post_online(struct ofono_modem *modem)
+{
+ struct ril_data *rd = ofono_modem_get_data(modem);
+
+ ofono_netreg_create(modem, 0, "rilmodem", rd->ril);
+ ofono_radio_settings_create(modem, OFONO_RIL_VENDOR_IMC_SOFIA3GR,
+ "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)
+{
+ struct cb_data *cbd = user_data;
+ ofono_modem_online_cb_t cb = cbd->cb;
+
+ DBG("%d", message->error);
+
+ if (message->error == RIL_E_SUCCESS)
+ CALLBACK_WITH_SUCCESS(cb, cbd->data);
+ else
+ CALLBACK_WITH_FAILURE(cb, cbd->data);
+}
+
+static void ril_set_online(struct ofono_modem *modem, ofono_bool_t online,
+ ofono_modem_online_cb_t cb, void *data)
+{
+ struct ril_data *rd = ofono_modem_get_data(modem);
+ struct cb_data *cbd = cb_data_new(cb, data, rd);
+
+ if (ril_send_power(rd->ril, online, ril_set_online_cb, cbd, g_free) > 0)
+ return;
+
+ CALLBACK_WITH_FAILURE(cb, cbd->data);
+ g_free(cbd);
+}
+
+static void ril_init_power(struct ril_msg *message, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ ofono_bool_t powered;
+
+ DBG("%d", message->error);
+
+ powered = message->error != RIL_E_SUCCESS ? FALSE : TRUE;
+ ofono_modem_set_powered(modem, powered);
+}
+
+static void ril_connected(struct ril_msg *message, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct ril_data *rd = ofono_modem_get_data(modem);
+
+ DBG("");
+
+ /* Set Modem Offline */
+ if (ril_send_power(rd->ril, FALSE, ril_init_power, modem, NULL) > 0)
+ return;
+
+ ofono_modem_set_powered(modem, FALSE);
+}
+
+static int ril_enable(struct ofono_modem *modem)
+{
+ struct ril_data *rd = ofono_modem_get_data(modem);
+
+ DBG("");
+
+ rd->ril = g_ril_new("/tmp/rild", OFONO_RIL_VENDOR_AOSP);
+ if (rd->ril == NULL) {
+ ofono_error("g_ril_new() failed to create modem!");
+ return -EIO;
+ }
+
+ if (getenv("OFONO_RIL_TRACE"))
+ g_ril_set_trace(rd->ril, TRUE);
+
+ if (getenv("OFONO_RIL_HEX_TRACE"))
+ g_ril_set_debugf(rd->ril, ril_debug, "IntelModem:");
+
+ g_ril_register(rd->ril, RIL_UNSOL_RIL_CONNECTED,
+ ril_connected, modem);
+
+ g_ril_register(rd->ril, RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED,
+ ril_radio_state_changed, modem);
+
+ return -EINPROGRESS;
+}
+
+static void ril_send_power_off_cb(struct ril_msg *message, gpointer user_data)
+{
+ struct ofono_modem *modem = (struct ofono_modem *) user_data;
+ struct ril_data *rd = ofono_modem_get_data(modem);
+
+ g_ril_unref(rd->ril);
+
+ ofono_modem_set_powered(modem, FALSE);
+}
+
+static int ril_disable(struct ofono_modem *modem)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ struct ril_data *rd = ofono_modem_get_data(modem);
+ const char *path = ofono_modem_get_path(modem);
+ struct parcel rilp;
+ int cmd_id;
+ char buf[4];
+
+ DBG("%p", modem);
+
+ if (g_dbus_unregister_interface(conn, path,
+ THERMAL_MANAGEMENT_INTERFACE))
+ ofono_modem_remove_interface(modem,
+ THERMAL_MANAGEMENT_INTERFACE);
+
+ /* RIL_OEM_HOOK_STRING_SET_MODEM_OFF = 0x000000CF */
+ cmd_id = 0x000000CF;
+ sprintf(buf, "%d", cmd_id);
+ parcel_init(&rilp);
+ parcel_w_int32(&rilp, 1);
+ parcel_w_string(&rilp, buf);
+
+ g_ril_append_print_buf(rd->ril, "{cmd_id=0x%02X}", cmd_id);
+
+ g_ril_send(rd->ril, RIL_REQUEST_OEM_HOOK_STRINGS, &rilp,
+ ril_send_power_off_cb, modem, NULL);
+
+ return -EINPROGRESS;
+}
+
+static struct ofono_modem_driver ril_driver = {
+ .name = "ril_intel",
+ .probe = ril_probe,
+ .remove = ril_remove,
+ .enable = ril_enable,
+ .disable = ril_disable,
+ .pre_sim = ril_pre_sim,
+ .post_sim = ril_post_sim,
+ .post_online = ril_post_online,
+ .set_online = ril_set_online,
+};
+
+static int ril_init(void)
+{
+ return ofono_modem_driver_register(&ril_driver);
+}
+
+static void ril_exit(void)
+{
+ ofono_modem_driver_unregister(&ril_driver);
+}
+
+OFONO_PLUGIN_DEFINE(ril_intel, "Intel RIL-based modem driver", VERSION,
+ OFONO_PLUGIN_PRIORITY_DEFAULT, ril_init, ril_exit)
diff --git a/plugins/ril_sofia3gr.c b/plugins/ril_sofia3gr.c
deleted file mode 100644
index bba34df..0000000
--- a/plugins/ril_sofia3gr.c
+++ /dev/null
@@ -1,606 +0,0 @@
-/*
- *
- * oFono - Open Source Telephony - RIL-based devices
- *
- * Copyright (C) 2008-2015 Intel Corporation. All rights reserved.
- * Copyright (C) 2012-2014 Canonical Ltd.
- * Copyright (C) 2013 Jolla Ltd.
- *
- * 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
-
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include <unistd.h>
-#include <glib.h>
-
-#define OFONO_API_SUBJECT_TO_CHANGE
-#include <ofono/plugin.h>
-#include <ofono/log.h>
-#include <ofono/types.h>
-#include <ofono/modem.h>
-#include <ofono/devinfo.h>
-#include <ofono/netreg.h>
-#include <ofono/sms.h>
-#include <ofono/sim.h>
-#include <ofono/gprs.h>
-#include <ofono/gprs-context.h>
-#include <ofono/radio-settings.h>
-#include <ofono/ussd.h>
-#include <ofono/netmon.h>
-
-#include <gril/gril.h>
-
-#include "drivers/rilmodem/rilmodem.h"
-#include "drivers/rilmodem/vendor.h"
-#include "gdbus.h"
-
-#include "ofono.h"
-
-#define THERMAL_MANAGEMENT_INTERFACE OFONO_SERVICE ".sofia3gr.ThermalManagement"
-
-struct ril_data {
- GRil *ril;
-};
-
-struct ril_thermal_management {
- DBusMessage *pending;
- struct ofono_modem *modem;
- dbus_bool_t throttling;
-};
-
-static int ril_send_power(GRil *ril, ofono_bool_t online,
- GRilResponseFunc func,
- gpointer user_data,
- GDestroyNotify destroy)
-{
- struct parcel rilp;
-
- DBG("%d", online);
-
- parcel_init(&rilp);
- parcel_w_int32(&rilp, 1);
- parcel_w_int32(&rilp, online);
-
- g_ril_append_print_buf(ril, "(%d)", online);
-
- return g_ril_send(ril, RIL_REQUEST_RADIO_POWER, &rilp,
- func, user_data, destroy);
-}
-
-static void ril_debug(const char *str, void *user_data)
-{
- const char *prefix = user_data;
-
- ofono_info("%s%s", prefix, str);
-}
-
-static void ril_radio_state_changed(struct ril_msg *message,
- gpointer user_data)
-{
- struct ofono_modem *modem = user_data;
- struct ril_data *rd = ofono_modem_get_data(modem);
- struct parcel rilp;
- int radio_state;
-
- g_ril_init_parcel(message, &rilp);
- radio_state = parcel_r_int32(&rilp);
-
- if (rilp.malformed) {
- ofono_error("%s: malformed parcel received", __func__);
- ofono_modem_set_powered(modem, FALSE);
- return;
- }
-
- g_ril_append_print_buf(rd->ril, "(state: %s)",
- ril_radio_state_to_string(radio_state));
- g_ril_print_unsol(rd->ril, message);
-
- switch (radio_state) {
- case RADIO_STATE_ON:
- break;
- case RADIO_STATE_UNAVAILABLE:
- ofono_modem_set_powered(modem, FALSE);
- break;
- case RADIO_STATE_OFF:
- break;
- }
-}
-
-static int ril_probe(struct ofono_modem *modem)
-{
- struct ril_data *rd;
-
- DBG("");
-
- rd = g_new0(struct ril_data, 1);
- ofono_modem_set_data(modem, rd);
-
- return 0;
-}
-
-static void ril_remove(struct ofono_modem *modem)
-{
- DBusConnection *conn = ofono_dbus_get_connection();
- struct ril_data *rd = ofono_modem_get_data(modem);
- const char *path = ofono_modem_get_path(modem);
-
- if (g_dbus_unregister_interface(conn, path,
- THERMAL_MANAGEMENT_INTERFACE))
- ofono_modem_remove_interface(modem,
- THERMAL_MANAGEMENT_INTERFACE);
-
- ofono_modem_set_data(modem, NULL);
-
- g_ril_unref(rd->ril);
- g_free(rd);
-}
-
-static void set_rf_power_status_cb(struct ril_msg *message, gpointer user_data)
-{
- DBusConnection *conn = ofono_dbus_get_connection();
- struct ril_thermal_management *tm = user_data;
- struct ril_data *rd = ofono_modem_get_data(tm->modem);
- const char *path = ofono_modem_get_path(tm->modem);
-
- DBG("");
-
- if (message->error != RIL_E_SUCCESS) {
- ofono_error("%s RILD reply failure: %s",
- g_ril_request_id_to_string(rd->ril, message->req),
- ril_error_to_string(message->error));
-
- __ofono_dbus_pending_reply(&tm->pending,
- __ofono_error_failed(tm->pending));
- return;
- }
-
- /* Change the throttling state */
- tm->throttling = tm->throttling ? false : true;
-
- __ofono_dbus_pending_reply(&tm->pending,
- dbus_message_new_method_return(tm->pending));
-
- ofono_dbus_signal_property_changed(conn, path,
- THERMAL_MANAGEMENT_INTERFACE,
- "TransmitPowerThrottling",
- DBUS_TYPE_BOOLEAN,
- &tm->throttling);
-}
-
-static DBusMessage *set_rf_power_status(DBusMessage *msg,
- dbus_bool_t enable,
- void *data)
-{
- struct ril_thermal_management *tm = data;
- struct ril_data *rd = ofono_modem_get_data(tm->modem);
- struct parcel rilp;
-
- int cmd_id;
- char buf[4];
-
- DBG("");
-
- if (tm->pending)
- return __ofono_error_busy(msg);
-
- parcel_init(&rilp);
- parcel_w_int32(&rilp, 2);
- /* RIL_OEM_HOOK_STRING_SET_RF_POWER_STATUS = 0x000000AC */
- cmd_id = 0x000000AC;
- sprintf(buf, "%d", cmd_id);
- parcel_w_string(&rilp, buf);
-
- memset(buf, 0, sizeof(buf));
- sprintf(buf, "%d", enable ? 1 : 0);
- parcel_w_string(&rilp, buf);
-
- g_ril_append_print_buf(rd->ril, "{cmd_id=0x%02X,arg=%s}", cmd_id, buf);
-
- if (g_ril_send(rd->ril, RIL_REQUEST_OEM_HOOK_STRINGS, &rilp,
- set_rf_power_status_cb, tm, NULL) == 0)
- return __ofono_error_failed(msg);
-
- tm->pending = dbus_message_ref(msg);
-
- return NULL;
-}
-
-static DBusMessage *thermal_management_set_property(DBusConnection *conn,
- DBusMessage *msg,
- void *data)
-{
- struct ril_thermal_management *tm = data;
- DBusMessageIter iter;
- DBusMessageIter var;
- const char *name;
- dbus_bool_t throttling;
-
- DBG("");
-
- if (!ofono_modem_get_online(tm->modem))
- return __ofono_error_not_available(msg);
-
- if (!dbus_message_iter_init(msg, &iter))
- return __ofono_error_invalid_args(msg);
-
- if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
- return __ofono_error_invalid_args(msg);
-
- dbus_message_iter_get_basic(&iter, &name);
-
- if (!strcmp(name, "TransmitPowerThrottling")) {
- dbus_message_iter_next(&iter);
-
- if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT)
- return __ofono_error_invalid_args(msg);
-
- dbus_message_iter_recurse(&iter, &var);
-
- if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BOOLEAN)
- return __ofono_error_invalid_args(msg);
-
- dbus_message_iter_get_basic(&var, &throttling);
-
- if (tm->throttling == throttling)
- /* Ignore set request if new state == current state */
- return dbus_message_new_method_return(msg);
-
- return set_rf_power_status(msg, throttling, tm);
- }
-
- return __ofono_error_invalid_args(msg);
-}
-
-static DBusMessage *thermal_management_get_properties(DBusConnection *conn,
- DBusMessage *msg,
- void *data)
-{
- struct ril_thermal_management *tm = data;
- DBusMessage *reply;
- DBusMessageIter iter;
- DBusMessageIter dict;
-
- DBG("");
-
- reply = dbus_message_new_method_return(msg);
- if (reply == NULL)
- return NULL;
-
- dbus_message_iter_init_append(reply, &iter);
-
- dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
- OFONO_PROPERTIES_ARRAY_SIGNATURE,
- &dict);
-
- ofono_dbus_dict_append(&dict, "TransmitPowerThrottling",
- DBUS_TYPE_BOOLEAN,
- &tm->throttling);
-
- dbus_message_iter_close_container(&iter, &dict);
-
- return reply;
-}
-
-static const GDBusMethodTable thermal_management_methods[] = {
- { GDBUS_METHOD("GetProperties",
- NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
- thermal_management_get_properties) },
- { GDBUS_ASYNC_METHOD("SetProperty",
- GDBUS_ARGS({ "property", "s" }, { "value", "v" }),
- NULL, thermal_management_set_property) },
- {}
-};
-
-static const GDBusSignalTable thermal_management_signals[] = {
- { GDBUS_SIGNAL("PropertyChanged",
- GDBUS_ARGS({ "name", "s" }, { "value", "v" })) },
- { }
-};
-
-static void thermal_management_cleanup(void *data)
-{
- struct ril_thermal_management *tm = data;
-
- if (tm->pending)
- __ofono_dbus_pending_reply(&tm->pending,
- __ofono_error_canceled(tm->pending));
-
- g_free(tm);
-}
-
-static void get_rf_power_status_cb(struct ril_msg *message, gpointer user_data)
-{
- struct ofono_modem *modem = user_data;
- struct ril_data *rd = ofono_modem_get_data(modem);
- struct ril_thermal_management *tm;
- DBusConnection *conn = ofono_dbus_get_connection();
- struct parcel rilp;
- gint numstr;
- gchar *power_status;
- char *endptr;
- int enabled;
- const char *path = ofono_modem_get_path(modem);
-
- DBG("");
-
- if (message->error != RIL_E_SUCCESS) {
- ofono_error("%s RILD reply failure: %s",
- g_ril_request_id_to_string(rd->ril, message->req),
- ril_error_to_string(message->error));
- return;
- }
-
- g_ril_init_parcel(message, &rilp);
-
- numstr = parcel_r_int32(&rilp);
- if (numstr < 1) {
- ofono_error("RILD reply empty !");
- return;
- }
-
- power_status = parcel_r_string(&rilp);
- if (power_status == NULL || power_status == '\0')
- return;
-
- enabled = strtol(power_status, &endptr, 10);
- /*
- * power_status == endptr => conversion error
- * *endptr != '\0' => partial conversion
- */
- if (power_status == endptr || *endptr != '\0')
- return;
-
- tm = g_try_new0(struct ril_thermal_management, 1);
- if (tm == NULL)
- return;
-
- tm->modem = modem;
- tm->throttling = (enabled > 0) ? true : false;
-
-
- if (!g_dbus_register_interface(conn, path, THERMAL_MANAGEMENT_INTERFACE,
- thermal_management_methods,
- thermal_management_signals,
- NULL, tm, thermal_management_cleanup)) {
- ofono_error("Could not register %s interface under %s",
- THERMAL_MANAGEMENT_INTERFACE, path);
- g_free(tm);
- return;
- }
-
- ofono_modem_add_interface(modem, THERMAL_MANAGEMENT_INTERFACE);
-}
-
-static int ril_thermal_management_enable(struct ofono_modem *modem)
-{
- struct ril_data *rd = ofono_modem_get_data(modem);
- struct parcel rilp;
-
- int cmd_id;
- char buf[4];
-
- DBG("");
-
- parcel_init(&rilp);
- parcel_w_int32(&rilp, 1);
- /* RIL_OEM_HOOK_STRING_GET_RF_POWER_STATUS = 0x000000AB */
- cmd_id = 0x000000AB;
- sprintf(buf, "%d", cmd_id);
- parcel_w_string(&rilp, buf);
-
- g_ril_append_print_buf(rd->ril, "{cmd_id=0x%02X}", cmd_id);
-
- if (g_ril_send(rd->ril, RIL_REQUEST_OEM_HOOK_STRINGS, &rilp,
- get_rf_power_status_cb, modem, NULL) > 0)
- return 0;
-
- /* Error path */
-
- return -EIO;
-}
-
-static void ril_pre_sim(struct ofono_modem *modem)
-{
- struct ril_data *rd = ofono_modem_get_data(modem);
-
- DBG("");
-
- ofono_devinfo_create(modem, 0, "rilmodem", rd->ril);
- ofono_sim_create(modem, 0, "rilmodem", rd->ril);
- ril_thermal_management_enable(modem);
-}
-
-static void ril_post_sim(struct ofono_modem *modem)
-{
- struct ril_data *rd = ofono_modem_get_data(modem);
- struct ofono_gprs *gprs;
- struct ofono_gprs_context *gc;
-
- ofono_sms_create(modem, OFONO_RIL_VENDOR_IMC_SOFIA3GR,
- "rilmodem", rd->ril);
-
- gprs = ofono_gprs_create(modem, 0, "rilmodem", rd->ril);
- gc = ofono_gprs_context_create(modem, 0, "rilmodem", rd->ril);
-
- if (gc) {
- ofono_gprs_context_set_type(gc,
- OFONO_GPRS_CONTEXT_TYPE_INTERNET);
- ofono_gprs_add_context(gprs, gc);
- }
-}
-
-static void ril_post_online(struct ofono_modem *modem)
-{
- struct ril_data *rd = ofono_modem_get_data(modem);
-
- ofono_netreg_create(modem, 0, "rilmodem", rd->ril);
- ofono_radio_settings_create(modem, OFONO_RIL_VENDOR_IMC_SOFIA3GR,
- "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)
-{
- struct cb_data *cbd = user_data;
- ofono_modem_online_cb_t cb = cbd->cb;
-
- DBG("%d", message->error);
-
- if (message->error == RIL_E_SUCCESS)
- CALLBACK_WITH_SUCCESS(cb, cbd->data);
- else
- CALLBACK_WITH_FAILURE(cb, cbd->data);
-}
-
-static void ril_set_online(struct ofono_modem *modem, ofono_bool_t online,
- ofono_modem_online_cb_t cb, void *data)
-{
- struct ril_data *rd = ofono_modem_get_data(modem);
- struct cb_data *cbd = cb_data_new(cb, data, rd);
-
- if (ril_send_power(rd->ril, online, ril_set_online_cb, cbd, g_free) > 0)
- return;
-
- CALLBACK_WITH_FAILURE(cb, cbd->data);
- g_free(cbd);
-}
-
-static void ril_init_power(struct ril_msg *message, gpointer user_data)
-{
- struct ofono_modem *modem = user_data;
- ofono_bool_t powered;
-
- DBG("%d", message->error);
-
- powered = message->error != RIL_E_SUCCESS ? FALSE : TRUE;
- ofono_modem_set_powered(modem, powered);
-}
-
-static void ril_connected(struct ril_msg *message, gpointer user_data)
-{
- struct ofono_modem *modem = user_data;
- struct ril_data *rd = ofono_modem_get_data(modem);
-
- DBG("");
-
- /* Set Modem Offline */
- if (ril_send_power(rd->ril, FALSE, ril_init_power, modem, NULL) > 0)
- return;
-
- ofono_modem_set_powered(modem, FALSE);
-}
-
-static int ril_enable(struct ofono_modem *modem)
-{
- struct ril_data *rd = ofono_modem_get_data(modem);
-
- DBG("");
-
- rd->ril = g_ril_new("/tmp/rild", OFONO_RIL_VENDOR_AOSP);
- if (rd->ril == NULL) {
- ofono_error("g_ril_new() failed to create modem!");
- return -EIO;
- }
-
- if (getenv("OFONO_RIL_TRACE"))
- g_ril_set_trace(rd->ril, TRUE);
-
- if (getenv("OFONO_RIL_HEX_TRACE"))
- g_ril_set_debugf(rd->ril, ril_debug, "Sofia3GR:");
-
- g_ril_register(rd->ril, RIL_UNSOL_RIL_CONNECTED,
- ril_connected, modem);
-
- g_ril_register(rd->ril, RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED,
- ril_radio_state_changed, modem);
-
- return -EINPROGRESS;
-}
-
-static void ril_send_power_off_cb(struct ril_msg *message, gpointer user_data)
-{
- struct ofono_modem *modem = (struct ofono_modem *) user_data;
- struct ril_data *rd = ofono_modem_get_data(modem);
-
- g_ril_unref(rd->ril);
-
- ofono_modem_set_powered(modem, FALSE);
-}
-
-static int ril_disable(struct ofono_modem *modem)
-{
- DBusConnection *conn = ofono_dbus_get_connection();
- struct ril_data *rd = ofono_modem_get_data(modem);
- const char *path = ofono_modem_get_path(modem);
- struct parcel rilp;
- int cmd_id;
- char buf[4];
-
- DBG("%p", modem);
-
- if (g_dbus_unregister_interface(conn, path,
- THERMAL_MANAGEMENT_INTERFACE))
- ofono_modem_remove_interface(modem,
- THERMAL_MANAGEMENT_INTERFACE);
-
- /* RIL_OEM_HOOK_STRING_SET_MODEM_OFF = 0x000000CF */
- cmd_id = 0x000000CF;
- sprintf(buf, "%d", cmd_id);
- parcel_init(&rilp);
- parcel_w_int32(&rilp, 1);
- parcel_w_string(&rilp, buf);
-
- g_ril_append_print_buf(rd->ril, "{cmd_id=0x%02X}", cmd_id);
-
- g_ril_send(rd->ril, RIL_REQUEST_OEM_HOOK_STRINGS, &rilp,
- ril_send_power_off_cb, modem, NULL);
-
- return -EINPROGRESS;
-}
-
-static struct ofono_modem_driver ril_driver = {
- .name = "ril_sofia3gr",
- .probe = ril_probe,
- .remove = ril_remove,
- .enable = ril_enable,
- .disable = ril_disable,
- .pre_sim = ril_pre_sim,
- .post_sim = ril_post_sim,
- .post_online = ril_post_online,
- .set_online = ril_set_online,
-};
-
-static int ril_init(void)
-{
- return ofono_modem_driver_register(&ril_driver);
-}
-
-static void ril_exit(void)
-{
- ofono_modem_driver_unregister(&ril_driver);
-}
-
-OFONO_PLUGIN_DEFINE(ril_sofia3gr, "SoFiA 3GR RIL-based modem driver", VERSION,
- OFONO_PLUGIN_PRIORITY_DEFAULT, ril_init, ril_exit)
--
1.9.1
4 years, 2 months
[PATCH 1/2] rilmodem: Add lte atom driver
by Ankit Navik
Adds rilmodem driver for setting the default APN command.
The default APN is manage by config storage.
---
Makefile.am | 3 +-
drivers/rilmodem/lte.c | 158 ++++++++++++++++++++++++++++++++++++++++++++
drivers/rilmodem/rilmodem.c | 2 +
drivers/rilmodem/rilmodem.h | 3 +
4 files changed, 165 insertions(+), 1 deletion(-)
create mode 100644 drivers/rilmodem/lte.c
diff --git a/Makefile.am b/Makefile.am
index 07adeab..0f25f1f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -153,7 +153,8 @@ builtin_sources += drivers/rilmodem/rilmodem.h \
drivers/rilmodem/netmon.c \
drivers/rilmodem/stk.c \
drivers/rilmodem/cbs.c \
- drivers/infineonmodem/infineon_constants.h
+ drivers/infineonmodem/infineon_constants.h \
+ drivers/rilmodem/lte.c
endif
if ISIMODEM
diff --git a/drivers/rilmodem/lte.c b/drivers/rilmodem/lte.c
new file mode 100644
index 0000000..d196be8
--- /dev/null
+++ b/drivers/rilmodem/lte.c
@@ -0,0 +1,158 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 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 <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <glib.h>
+
+#include <ofono/modem.h>
+#include <ofono/gprs-context.h>
+#include <ofono/log.h>
+#include <ofono/lte.h>
+
+#include <gril/gril.h>
+#include <gril/grilutil.h>
+
+#include "rilmodem.h"
+
+struct ril_lte_data {
+ GRil *ril;
+};
+
+static void ril_lte_set_default_attach_info_cb(struct ril_msg *message,
+ gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_lte_cb_t cb = cbd->cb;
+ struct ofono_lte *lte = cbd->user;
+ struct ril_lte_data *ld = ofono_lte_get_data(lte);
+ DBG("");
+
+ if (message->error == RIL_E_SUCCESS) {
+ g_ril_print_response_no_args(ld->ril, message);
+ CALLBACK_WITH_SUCCESS(cb, cbd->data);
+ } else {
+ ofono_error("%s: RIL error %s", __func__,
+ ril_error_to_string(message->error));
+ CALLBACK_WITH_FAILURE(cb, cbd->data);
+ }
+}
+
+static void ril_lte_set_default_attach_info(const struct ofono_lte *lte,
+ const struct ofono_lte_default_attach_info *info,
+ ofono_lte_cb_t cb, void *data)
+{
+ struct ril_lte_data *ld = ofono_lte_get_data(lte);
+ struct cb_data *cbd = cb_data_new(cb, data, (struct ofono_lte *)lte);
+ struct parcel rilp;
+ char buf[OFONO_GPRS_MAX_APN_LENGTH + 1];
+
+ DBG("%s", info->apn);
+
+ parcel_init(&rilp);
+ parcel_w_int32(&rilp, 5);
+
+ if (strlen(info->apn) > 0) {
+ sprintf(buf, "%s", info->apn);
+ parcel_w_string(&rilp, buf);
+ } else
+ parcel_w_string(&rilp, ""); /* apn */
+
+ parcel_w_string(&rilp, "ip"); /* protocol */
+ parcel_w_int32(&rilp, 0); /* auth type */
+ parcel_w_string(&rilp, ""); /* username */
+ parcel_w_string(&rilp, ""); /* password */
+
+ if (g_ril_send(ld->ril, RIL_REQUEST_SET_INITIAL_ATTACH_APN, &rilp,
+ ril_lte_set_default_attach_info_cb, cbd, g_free) > 0)
+ return;
+
+ g_free(cbd);
+ CALLBACK_WITH_FAILURE(cb, data);
+}
+
+static gboolean lte_delayed_register(gpointer user_data)
+{
+ struct ofono_lte *lte = user_data;
+
+ DBG("");
+
+ ofono_lte_register(lte);
+
+ return FALSE;
+}
+
+static int ril_lte_probe(struct ofono_lte *lte, void *user_data)
+{
+ GRil *ril = user_data;
+ struct ril_lte_data *ld;
+
+ DBG("");
+
+ ld = g_try_new0(struct ril_lte_data, 1);
+ if (ld == NULL)
+ return -ENOMEM;
+
+ ld->ril = g_ril_clone(ril);
+
+ ofono_lte_set_data(lte, ld);
+
+ g_idle_add(lte_delayed_register, lte);
+
+ return 0;
+}
+
+static void ril_lte_remove(struct ofono_lte *lte)
+{
+ struct ril_lte_data *ld = ofono_lte_get_data(lte);
+
+ DBG("");
+
+ ofono_lte_set_data(lte, NULL);
+
+ g_ril_unref(ld->ril);
+ g_free(ld);
+}
+
+static struct ofono_lte_driver driver = {
+ .name = RILMODEM,
+ .probe = ril_lte_probe,
+ .remove = ril_lte_remove,
+ .set_default_attach_info = ril_lte_set_default_attach_info,
+};
+
+void ril_lte_init(void)
+{
+ ofono_lte_driver_register(&driver);
+}
+
+void ril_lte_exit(void)
+{
+ ofono_lte_driver_unregister(&driver);
+}
diff --git a/drivers/rilmodem/rilmodem.c b/drivers/rilmodem/rilmodem.c
index ace1621..be1d0ed 100644
--- a/drivers/rilmodem/rilmodem.c
+++ b/drivers/rilmodem/rilmodem.c
@@ -54,6 +54,7 @@ static int rilmodem_init(void)
ril_netmon_init();
ril_stk_init();
ril_cbs_init();
+ ril_lte_init();
return 0;
}
@@ -78,6 +79,7 @@ static void rilmodem_exit(void)
ril_netmon_exit();
ril_stk_exit();
ril_cbs_exit();
+ ril_lte_exit();
}
OFONO_PLUGIN_DEFINE(rilmodem, "RIL modem driver", VERSION,
diff --git a/drivers/rilmodem/rilmodem.h b/drivers/rilmodem/rilmodem.h
index cde955e..dd63365 100644
--- a/drivers/rilmodem/rilmodem.h
+++ b/drivers/rilmodem/rilmodem.h
@@ -78,3 +78,6 @@ extern void ril_stk_exit(void);
extern void ril_cbs_init(void);
extern void ril_cbs_exit(void);
+
+extern void ril_lte_init(void);
+extern void ril_lte_exit(void);
--
1.9.1
4 years, 2 months
[PATCH 2/2] rilmodem: set LTE preferred in rat mode
by Ankit Navik
---
drivers/rilmodem/radio-settings.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rilmodem/radio-settings.c b/drivers/rilmodem/radio-settings.c
index d6d0ad9..36befca 100644
--- a/drivers/rilmodem/radio-settings.c
+++ b/drivers/rilmodem/radio-settings.c
@@ -111,7 +111,7 @@ static void ril_set_rat_mode(struct ofono_radio_settings *rs,
struct radio_data *rd = ofono_radio_settings_get_data(rs);
struct cb_data *cbd = cb_data_new(cb, data, rs);
struct parcel rilp;
- int pref = PREF_NET_TYPE_GSM_WCDMA;
+ int pref = PREF_NET_TYPE_LTE_GSM_WCDMA;
switch (mode) {
case OFONO_RADIO_ACCESS_MODE_ANY:
--
1.9.1
4 years, 2 months
[PATCH v3 0/7] ubloxmodem add netmon interface
by 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
4 years, 2 months