[PATCH] Simcom support
by Anthony Viallard
Add SIMCOM support.
I developped this with the SIM5216E chipset and ofono 1.12.
- SMS and GPRS work (in the same time) ;
- SIM card presence check ;
- No voice part because I can't test it ;
- Use default characters set instead GSM because it works like that
for what I'm doing (SMS+GPRS) (by default, the set is IRA for SIM5216E).
Also, the SIMCOM doc affraids me about problems when using GSM
(this setting causes easily software flow control (XON /XOFF) problems.).
Signed-off-by: Anthony Viallard <homer242 at gmail.com>
--- ofono-1.12.orig/Makefile.am 2012-04-20 21:06:29.000000000 +0200
+++ ofono-1.12/Makefile.am 2013-01-21 17:17:48.089627277 +0100
@@ -371,6 +371,9 @@ builtin_sources += plugins/samsung.c
builtin_modules += sim900
builtin_sources += plugins/sim900.c
+builtin_modules += simcom
+builtin_sources += plugins/simcom.c
+
if BLUETOOTH
builtin_modules += bluetooth
builtin_sources += plugins/bluetooth.c plugins/bluetooth.h
--- ofono-1.12.orig/drivers/atmodem/sms.c 2012-04-20 21:06:29.000000000 +0200
+++ ofono-1.12/drivers/atmodem/sms.c 2013-01-21 16:48:44.460627485 +0100
@@ -805,6 +807,7 @@ static gboolean build_cnmi_string(char *
case OFONO_VENDOR_NOVATEL:
case OFONO_VENDOR_HUAWEI:
case OFONO_VENDOR_ZTE:
+ case OFONO_VENDOR_SIMCOM:
/* MSM devices advertise support for mode 2, but return an
* error if we attempt to actually use it. */
mode = "1";
diff -pruN ofono-1.12.orig/drivers/atmodem/sim.c ofono-1.12/drivers/atmodem/sim.c
--- ofono-1.12.orig/drivers/atmodem/sim.c 2013-01-23 11:38:22.959609087 +0100
+++ ofono-1.12/drivers/atmodem/sim.c 2013-01-23 11:57:52.602608948 +0100
@@ -1023,12 +1023,18 @@ static void at_pin_send_cb(gboolean ok,
FALSE, cbd, g_free);
return;
case OFONO_VENDOR_ZTE:
case OFONO_VENDOR_ALCATEL:
case OFONO_VENDOR_HUAWEI:
+ case OFONO_VENDOR_SIMCOM:
/*
* On ZTE modems, after pin is entered, SIM state is checked
* by polling CPIN as their modem doesn't provide unsolicited
* notification of SIM readiness.
+ *
+ * On SIMCOM modems, SIM is busy after pin is entered (we've
+ * got an "+CME ERROR: 14" at "AT+CPIN?" request) and ofono
+ * don't catch the "+CPIN: READY" message sent by the modem
+ * when SIM is ready. So, use extra CPIN to check the state.
*/
sd->sim_state_query = at_util_sim_state_query_new(sd->chat,
2, 20, sim_state_cb, cbd,
diff -purN ofono-1.12/drivers/atmodem/network-registration.c ofono-patched/drivers/atmodem/network-registration.c
--- ofono-1.12/drivers/atmodem/network-registration.c 2013-01-18 15:04:03.598659165 +0100
+++ ofono-patched/drivers/atmodem/network-registration.c 2013-01-18 14:54:03.256659236 +0100
@@ -1411,6 +1411,14 @@ static void at_creg_set_cb(gboolean ok,
}
switch (nd->vendor) {
+ case OFONO_VENDOR_SIMCOM:
+ /* Register for CSQ changes */
+ g_at_chat_send(nd->chat, "AT+AUTOCSQ=1,1", none_prefix,
+ NULL, NULL, NULL);
+
+ g_at_chat_register(nd->chat, "+CSQ:",
+ csq_notify, FALSE, netreg, NULL);
+ break;
case OFONO_VENDOR_PHONESIM:
g_at_chat_register(nd->chat, "+CSQ:",
csq_notify, FALSE, netreg, NULL);
@@ -1534,7 +1537,6 @@ static void at_creg_set_cb(gboolean ok,
break;
case OFONO_VENDOR_NOKIA:
case OFONO_VENDOR_SAMSUNG:
- case OFONO_VENDOR_SIMCOM:
/* Signal strength reporting via CIND is not supported */
break;
default:
--- /dev/null 2013-01-28 10:34:59.843091650 +0100
+++ ofono-1.12/plugins/simcom.c 2013-02-15 16:16:38.058552544 +0100
@@ -0,0 +1,401 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2011 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
+
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <glib.h>
+#include <gatchat.h>
+#include <gattty.h>
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include <ofono/plugin.h>
+#include <ofono/modem.h>
+#include <ofono/devinfo.h>
+#include <ofono/netreg.h>
+#include <ofono/sim.h>
+#include <ofono/cbs.h>
+#include <ofono/sms.h>
+#include <ofono/ussd.h>
+#include <ofono/gprs.h>
+#include <ofono/gprs-context.h>
+#include <ofono/radio-settings.h>
+#include <ofono/phonebook.h>
+#include <ofono/log.h>
+
+#include <drivers/atmodem/atutil.h>
+#include <drivers/atmodem/vendor.h>
+
+#define MAX_IGNITION_POOL_CALL 7
+
+#define CMEERR_SIMBUSY 14
+
+static const char *none_prefix[] = { NULL };
+
+struct simcom_data {
+ GAtChat *modem;
+ GAtChat *data;
+ guint ignition_pool;
+ unsigned int ignition_pool_call;
+ unsigned int at_ignition_pending;
+ ofono_bool_t have_sim;
+};
+
+/* Callback and helpers functions */
+static void simcom_debug(const char *str, void *user_data)
+{
+ const char *prefix = user_data;
+
+ ofono_info("%s%s", prefix, str);
+}
+
+static gboolean simcom_ignition(gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct simcom_data *data = ofono_modem_get_data(modem);
+
+ ++data->ignition_pool_call;
+
+ if(data->at_ignition_pending > 0)
+ {
+ if(data->ignition_pool_call > MAX_IGNITION_POOL_CALL)
+ {
+ ofono_error("Ignition timeout");
+ return FALSE;
+ }
+
+ /* Waiting reply of AT commands */
+ DBG("Waiting AT reply...");
+ return TRUE;
+ }
+
+ ofono_modem_set_powered(modem, TRUE);
+
+ return FALSE;
+}
+
+static void simcom_sim_status(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct ofono_error error;
+ struct simcom_data *data = ofono_modem_get_data(modem);
+
+ --data->at_ignition_pending;
+
+ if(!ok)
+ {
+ decode_at_error(&error, g_at_result_final_response(result));
+ if(error.type == OFONO_ERROR_TYPE_CME)
+ {
+ if(error.error == CMEERR_SIMBUSY)
+ {
+ DBG("System is busy. Retry...");
+ g_at_chat_send(data->data, "AT+CPIN?",
+ none_prefix,
+ simcom_sim_status, modem,
+ NULL);
+ ++data->at_ignition_pending;
+ return;
+ }
+ }
+
+ data->have_sim = FALSE;
+ return;
+ }
+
+ /* If doesn't have an "fatal" error on AT+CPIN request,
+ * we can guess there a SIM card ...
+ */
+ data->have_sim = TRUE;
+}
+
+static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct simcom_data *data = ofono_modem_get_data(modem);
+
+ DBG("");
+
+ if (!ok) {
+ g_at_chat_unref(data->modem);
+ data->modem = NULL;
+
+ g_at_chat_unref(data->data);
+ data->data = NULL;
+
+ ofono_modem_set_powered(modem, FALSE);
+ return;
+ }
+
+ /* Get model and sim card status */
+ data->at_ignition_pending = 0;
+
+ g_at_chat_send(data->data, "AT+CPIN?", none_prefix,
+ simcom_sim_status, modem, NULL);
+ ++data->at_ignition_pending;
+
+ data->ignition_pool = g_timeout_add_seconds(1,
+ simcom_ignition,
+ modem);
+}
+
+static void cfun_disable(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct simcom_data *data = ofono_modem_get_data(modem);
+
+ DBG("");
+
+ g_at_chat_unref(data->data);
+ data->data = NULL;
+
+ if (ok)
+ ofono_modem_set_powered(modem, FALSE);
+}
+
+static GAtChat *open_device(struct ofono_modem *modem,
+ const char *key,
+ char *debug)
+{
+ const char *device;
+ GIOChannel *channel;
+ GAtSyntax *syntax;
+ GAtChat *chat;
+ /* GHashTable *options; */
+
+ device = ofono_modem_get_string(modem, key);
+ if (device == NULL)
+ {
+ ofono_error("Failed to get modem '%s'", key);
+ return NULL;
+ }
+
+ DBG("%s %s", key, device);
+
+ /* options = g_hash_table_new(g_str_hash, g_str_equal); */
+ /* if (options == NULL) */
+ /* return NULL; */
+
+ /* g_hash_table_insert(options, "Baud", "115200"); */
+ /* g_hash_table_insert(options, "Parity", "none"); */
+ /* g_hash_table_insert(options, "StopBits", "1"); */
+ /* g_hash_table_insert(options, "DataBits", "8"); */
+ /* g_hash_table_insert(options, "XonXoff", "off"); */
+ /* g_hash_table_insert(options, "RtsCts", "on"); */
+ /* g_hash_table_insert(options, "Local", "on"); */
+ /* g_hash_table_insert(options, "Read", "on"); */
+
+ channel = g_at_tty_open(device, NULL);
+
+ /* g_hash_table_destroy(options); */
+
+ if (channel == NULL)
+ {
+ ofono_error("Failed to get tty for '%s'", key);
+ return NULL;
+ }
+
+ syntax = g_at_syntax_new_gsm_permissive();
+ chat = g_at_chat_new(channel, syntax);
+ g_at_syntax_unref(syntax);
+
+ g_io_channel_unref(channel);
+
+ if (chat == NULL)
+ {
+ ofono_error("Failed to get chat for '%s'", key);
+ return NULL;
+ }
+
+ //if (getenv("OFONO_AT_DEBUG"))
+ g_at_chat_set_debug(chat, simcom_debug, debug);
+
+ return chat;
+}
+
+/* Modem interface function */
+static int simcom_probe(struct ofono_modem *modem)
+{
+ struct simcom_data *data;
+
+ DBG("%p", modem);
+
+ data = g_try_new0(struct simcom_data, 1);
+ if (data == NULL)
+ return -ENOMEM;
+
+ ofono_modem_set_data(modem, data);
+
+ return 0;
+}
+
+static void simcom_remove(struct ofono_modem *modem)
+{
+ struct simcom_data *data = ofono_modem_get_data(modem);
+
+ DBG("%p", modem);
+
+ if(data->ignition_pool > 0)
+ {
+ g_source_remove(data->ignition_pool);
+ data->ignition_pool = 0;
+ }
+
+ ofono_modem_set_data(modem, NULL);
+
+ /* Cleanup after hot-unplug */
+ g_at_chat_unref(data->data);
+
+ g_free(data);
+}
+
+static int simcom_enable(struct ofono_modem *modem)
+{
+ struct simcom_data *data = ofono_modem_get_data(modem);
+
+ DBG("%p", modem);
+
+ data->modem = open_device(modem, "Modem", "Modem: ");
+ if (data->modem == NULL)
+ return -EINVAL;
+
+ data->data = open_device(modem, "Data", "Data: ");
+ if (data->data == NULL) {
+ g_at_chat_unref(data->modem);
+ data->modem = NULL;
+ return -EIO;
+ }
+
+ g_at_chat_set_slave(data->modem, data->data);
+
+ g_at_chat_blacklist_terminator(data->data,
+ G_AT_CHAT_TERMINATOR_NO_CARRIER);
+
+ /* init modem */
+ g_at_chat_send(data->modem, "ATE0 +CMEE=1", NULL, NULL, NULL, NULL);
+ g_at_chat_send(data->data, "ATE0 +CMEE=1", NULL, NULL, NULL, NULL);
+
+ g_at_chat_send(data->data, "AT+CFUN=1", none_prefix,
+ cfun_enable, modem, NULL);
+
+ return -EINPROGRESS;
+}
+
+static int simcom_disable(struct ofono_modem *modem)
+{
+ struct simcom_data *data = ofono_modem_get_data(modem);
+
+ DBG("%p", modem);
+
+ g_at_chat_cancel_all(data->modem);
+ g_at_chat_unregister_all(data->modem);
+
+ g_at_chat_unref(data->modem);
+ data->modem = NULL;
+
+ g_at_chat_cancel_all(data->data);
+ g_at_chat_unregister_all(data->data);
+
+ g_at_chat_send(data->data, "AT+CFUN=4", none_prefix,
+ cfun_disable, modem, NULL);
+
+ return -EINPROGRESS;
+}
+
+static void simcom_pre_sim(struct ofono_modem *modem)
+{
+ struct simcom_data *data = ofono_modem_get_data(modem);
+ struct ofono_sim *sim;
+
+ DBG("%p", modem);
+
+ ofono_devinfo_create(modem, 0, "atmodem", data->data);
+ sim = ofono_sim_create(modem, OFONO_VENDOR_SIMCOM, "atmodem",
+ data->data);
+
+ if (sim)
+ ofono_sim_inserted_notify(sim, data->have_sim);
+}
+
+static void simcom_post_sim(struct ofono_modem *modem)
+{
+ struct simcom_data *data = ofono_modem_get_data(modem);
+ struct ofono_message_waiting *mw;
+ struct ofono_gprs *gprs;
+ struct ofono_gprs_context *gc;
+
+ DBG("%p", modem);
+
+ ofono_phonebook_create(modem, 0, "atmodem", data->data);
+
+ ofono_sms_create(modem, OFONO_VENDOR_SIMCOM, "atmodem",
+ data->data);
+
+ /* gprs things */
+ gprs = ofono_gprs_create(modem, 0, "atmodem", data->data);
+ gc = ofono_gprs_context_create(modem, 0, "atmodem", data->modem);
+
+ if(gprs && gc)
+ {
+ ofono_gprs_add_context(gprs, gc);
+ }
+}
+
+static void simcom_post_online(struct ofono_modem *modem)
+{
+ struct simcom_data *data = ofono_modem_get_data(modem);
+
+ DBG("%p", modem);
+
+ ofono_netreg_create(modem, OFONO_VENDOR_SIMCOM, "atmodem", data->data);
+ ofono_cbs_create(modem, 0, "atmodem", data->data);
+ ofono_ussd_create(modem, 0, "atmodem", data->data);
+}
+
+static struct ofono_modem_driver simcom_driver = {
+ .name = "simcom",
+ .probe = simcom_probe,
+ .remove = simcom_remove,
+ .enable = simcom_enable,
+ .disable = simcom_disable,
+ .pre_sim = simcom_pre_sim,
+ .post_sim = simcom_post_sim,
+ .post_online = simcom_post_online,
+};
+
+static int simcom_init(void)
+{
+ return ofono_modem_driver_register(&simcom_driver);
+}
+
+static void simcom_exit(void)
+{
+ ofono_modem_driver_unregister(&simcom_driver);
+}
+
+OFONO_PLUGIN_DEFINE(simcom, "SIMCOM modem driver", VERSION,
+ OFONO_PLUGIN_PRIORITY_DEFAULT,
+ simcom_init, simcom_exit)
2 weeks, 6 days
[PATCH_v4 0/5] Private network request to ConnMan
by Guillaume Zajac
Hi,
Changelog from v3 is:
- Add private-network source/include
- ConnMan plugin is independant from emulator
- Each application that need VPN will pass a callback as argument
when private network is requested. This callback will contain the
private network settings.
Guillaume Zajac (5):
gatppp: Add new contructor to use external fd
private-network: add callback typedef drivers and settings
private-network: add request/release functions and new feature to
Makefile.am
emulator: add request/release private network calls
connman: add plugin in oFono to request request/release private
network
Makefile.am | 10 +-
gatchat/gatppp.c | 33 +++++-
gatchat/gatppp.h | 1 +
gatchat/ppp.h | 2 +-
gatchat/ppp_net.c | 40 ++++---
include/private-network.h | 59 +++++++++
plugins/connman.c | 297 +++++++++++++++++++++++++++++++++++++++++++++
src/emulator.c | 49 ++++++--
src/ofono.h | 6 +
src/private-network.c | 89 ++++++++++++++
10 files changed, 556 insertions(+), 30 deletions(-)
create mode 100644 include/private-network.h
create mode 100644 plugins/connman.c
create mode 100644 src/private-network.c
3 weeks, 1 day
Business
by Daser Jnr.
Hi all
>From a business point of view, can some one tell me what i can do with ofono
Cheers
Daser S.
2 months, 2 weeks
[PATCH] make it build against musl
by Sergey Alirzaev
ifdef away GNU libc extensions and use a POSIXly correct pointer type
---
gatchat/ppp_net.c | 2 +-
src/log.c | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/gatchat/ppp_net.c b/gatchat/ppp_net.c
index 813ed9b..914ca53 100644
--- a/gatchat/ppp_net.c
+++ b/gatchat/ppp_net.c
@@ -67,7 +67,7 @@ gboolean ppp_net_set_mtu(struct ppp_net *net, guint16 mtu)
strncpy(ifr.ifr_name, net->if_name, sizeof(ifr.ifr_name));
ifr.ifr_mtu = mtu;
- err = ioctl(sk, SIOCSIFMTU, (caddr_t) &ifr);
+ err = ioctl(sk, SIOCSIFMTU, (void *) &ifr);
close(sk);
diff --git a/src/log.c b/src/log.c
index febc874..6331b0d 100644
--- a/src/log.c
+++ b/src/log.c
@@ -30,7 +30,9 @@
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
+#ifdef __GLIBC__
#include <execinfo.h>
+#endif
#include <dlfcn.h>
#include "ofono.h"
@@ -113,6 +115,7 @@ void ofono_debug(const char *format, ...)
va_end(ap);
}
+#ifdef __GLIBC__
static void print_backtrace(unsigned int offset)
{
void *frames[99];
@@ -240,6 +243,7 @@ static void signal_setup(sighandler_t handler)
sigaction(SIGABRT, &sa, NULL);
sigaction(SIGPIPE, &sa, NULL);
}
+#endif
extern struct ofono_debug_desc __start___debug[];
extern struct ofono_debug_desc __stop___debug[];
@@ -305,7 +309,9 @@ int __ofono_log_init(const char *program, const char *debug,
if (detach == FALSE)
option |= LOG_PERROR;
+#ifdef __GLIBC__
signal_setup(signal_handler);
+#endif
openlog(basename(program), option, LOG_DAEMON);
@@ -320,7 +326,9 @@ void __ofono_log_cleanup(void)
closelog();
+#ifdef __GLIBC__
signal_setup(SIG_DFL);
+#endif
g_strfreev(enabled);
}
--
2.4.1
6 years, 10 months
RE: Query on ppp0 interface for HE910 device
by Mike Williams
>Whenever the connman daemon switches from cellular to wifi automatically, ofonod >removes the ppp0 interface.
>On the oterhway round the ofono daemon is not doing the addition of the ppp0 interface.
I can reproduce this on an HE910 I just started testing. Basically,
the ofono cellular service never reappears to connman after connman
disconnects it.
# connmanctl technologies
/net/connman/technology/cellular
Name = Cellular
Type = cellular
Powered = True
Connected = False
Tethering = False
/net/connman/technology/ethernet
Name = Wired
Type = ethernet
Powered = True
Connected = False
Tethering = False
# connmanctl services
*AR Wired ethernet_001122edb058_cable
*A T-Mobile cellular_310260008772362_context1
# connmanctl disable ethernet
Disabled ethernet
# macb f0028000.ethernet eth0: link down
# connmanctl services
*AR T-Mobile cellular_310260008772362_context1
# connmanctl enable ethernet
IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
Enabled ethernet
# macb f0028000.ethernet eth0: link up (100/Full)
IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
# connmanctl services
*AR Wired ethernet_001122edb058_cable
#
The cellular service will never reappear.
ofono debug log:
ofonod[1543]: PPP: lcp: pppcp_process_terminate_ack: current state 4:CLOSING
ofonod[1543]: PPP: lcp: pppcp_generate_event: current state 4:CLOSING
ofonod[1543]: PPP: event: 11 (RTA), action: 802, new_state: 2 (CLOSED)
ofonod[1543]: PPP: lcp: pppcp_this_layer_finished: current state 2:CLOSED
ofonod[1543]: PPP: gatchat/gatppp.c:ppp_enter_phase() 0
ofonod[1543]: PPP: gatchat/gatppp.c:ppp_dead()
ofonod[1543]: drivers/atmodem/gprs-context.c:ppp_disconnect() Reason: 6
ofonod[1543]: Aux: < \r\n+CGEV: ME DEACT IP, "22.226.202.227", 1\r\n
ofonod[1543]: Aux: < \r\n
ofonod[1543]: Aux: < +CGREG: 0\r\n\r\n+CGEV: NW DETACH\r\n
ofonod[1543]: src/gprs.c:ofono_gprs_status_notify() /he910_0 status 0
ofonod[1543]: src/gprs.c:ofono_gprs_detached_notify() /he910_0
ofonod[1543]: Aux: < \r\n
ofonod[1543]: Aux: < +CGREG: 0\r\n\r\n+CREG: 1,"2004","076277F",2\r\n
ofonod[1543]: src/gprs.c:ofono_gprs_status_notify() /he910_0 status 0
ofonod[1543]: src/network.c:ofono_netreg_status_notify() /he910_0
status 1 tech 2
ofonod[1543]: src/gprs.c:netreg_status_changed() 1
ofonod[1543]: Aux: > AT+COPS=3,2\r
ofonod[1543]: Aux: < \r\nOK\r\n
ofonod[1543]: Aux: > AT+COPS?\r
ofonod[1543]: Aux: < \r\n
ofonod[1543]: Aux: < +COPS: 0,2,"310260",2\r\n\r\nOK\r\n
ofonod[1543]: drivers/atmodem/network-registration.c:cops_numeric_cb()
Cops numeric got mcc: 310, mnc: 260
ofonod[1543]: Aux: > AT+CIND?\r
ofonod[1543]: Aux: < \r\n
ofonod[1543]: Aux: < +CIND: 0,3,1,0,0,0,0,0,2\r\n\r\nOK\r\n
ofonod[1543]: Aux: > AT+COPS=3,0\r
ofonod[1543]: Aux: < \r\nOK\r\n
ofonod[1543]: Aux: > AT+COPS?\r
ofonod[1543]: Aux: < \r\n
ofonod[1543]: Aux: < +COPS: 0,0,"T-Mobile",2\r\n\r\nOK\r\n
ofonod[1543]: drivers/atmodem/network-registration.c:cops_cb()
cops_cb: T-Mobile, 310 260 2
ofonod[1543]: src/network.c:current_operator_callback() 0xcb600, 0xd0cb0
Contexts for that modem still appear when when listing them via dbus:
dbus-send --system --print-reply --dest=org.ofono /he910_0
org.ofono.ConnectionManager.GetContexts
method return sender=:1.36 -> dest=:1.48 reply_serial=2
array [
struct {
object path "/he910_0/context1"
array [
dict entry(
string "Name"
variant string "LTE"
)
dict entry(
string "Active"
variant boolean false
)
dict entry(
string "Type"
variant string "internet"
)
<Truncated>
Manually trying to activate that context fails:
# dbus-send --system --print-reply --dest=org.ofono /he910_0/context1 org.ofono.
ConnectionContext.SetProperty string:Active variant:boolean:true
Error org.ofono.Error.NotAttached: GPRS is not attached
Thanks,
Mike
6 years, 11 months
bug reactivating primary context?
by Mike Williams
All,
Using connman/ofono to connect to a cellular network, the first time
activating the GPRS context works. After deactivation, the next
activation fails with an unknown error. I believe this is related to
this issue:
https://lists.01.org/pipermail/ofono/2015-May/015745.html
Looking through the code, it looks like at_gprs_activate_primary() fails at:
if (g_at_chat_send(gcd->chat, buf, none_prefix,
at_cgdcont_cb, gc, NULL) > 0)
return;
g_at_chat_send() is returning NULL from at_chat_send_common() because
the chat command_queue is NULL.
See ofono debug trace below with OFONO_PPP_DEBUG and OFONO_AT_DEBUG enabled:
ofonod[1366]: PPP: gatchat/gatppp.c:ppp_enter_phase() 4
ofonod[1366]: drivers/atmodem/gprs-context.c:ppp_connect()
ofonod[1366]: IP: 21.186.242.106
ofonod[1366]: DNS: 10.177.0.34, 10.168.187.116
ofonod[1366]: src/gprs.c:pri_activate_callback() 0xcd5b0
ofonod[1366]: plugins/udev.c:udev_event() subsystem net add
ofonod[1366]: plugins/udev.c:udev_event() subsystem net finished
ofonod[1366]: PCUI: < \r\n^MODE: 5,7\r\n
ofonod[1366]: plugins/udevng.c:check_modem_list()
ofonod[1366]: PCUI: <
\r\n^DSFLOWRPT:00000002,000000BB,00000041,0000000000000177,0000000000000082,0010E000,001F4000\r\n
ofonod[1366]: drivers/atmodem/gprs-context.c:at_gprs_deactivate_primary() cid 1
ofonod[1366]: PPP: lcp: pppcp_generate_event: current state 9:OPENED
ofonod[1366]: PPP: event: 3 (Close), action: 8224, new_state: 4 (CLOSING)
ofonod[1366]: PPP: lcp: pppcp_initialize_restart_count: current state 9:OPENED
ofonod[1366]: PPP: lcp: pppcp_send_terminate_request: current state 9:OPENED
ofonod[1366]: PPP: ipcp: pppcp_generate_event: current state 9:OPENED
ofonod[1366]: PPP: event: 1 (Down), action: 201, new_state: 1 (STARTING)
ofonod[1366]: PPP: gatchat/gatppp.c:ppp_enter_phase() 5
ofonod[1366]: plugins/udevng.c:remove_device() /sys/devices/virtual/net/ppp0
ofonod[1366]: plugins/udev.c:udev_event() subsystem net remove
ofonod[1366]: plugins/udev.c:remove_modem() /devices/virtual/net/ppp0
ofonod[1366]: plugins/udev.c:udev_event() subsystem net finished
ofonod[1366]: PPP: lcp: pppcp_process_terminate_ack: current state 4:CLOSING
ofonod[1366]: PPP: lcp: pppcp_generate_event: current state 4:CLOSING
ofonod[1366]: PPP: event: 11 (RTA), action: 802, new_state: 2 (CLOSED)
ofonod[1366]: PPP: lcp: pppcp_this_layer_finished: current state 2:CLOSED
ofonod[1366]: PPP: gatchat/gatppp.c:ppp_enter_phase() 0
ofonod[1366]: PCUI: < \r\n^MODE: 5,4\r\n
ofonod[1366]: PPP: gatchat/gatppp.c:ppp_dead()
ofonod[1366]: drivers/atmodem/gprs-context.c:ppp_disconnect() Reason: 6
ofonod[1366]: drivers/atmodem/gprs-context.c:at_gprs_activate_primary() cid 1
ofonod[1366]: src/gprs.c:pri_activate_callback() 0xcd5b0
ofonod[1366]: src/gprs.c:pri_activate_callback() Activating context
failed with error: Unknown error type
ofonod[1366]: PCUI: < \r\n^RSSI: 3\r\n
ofonod[1366]: src/network.c:ofono_netreg_strength_notify() strength 9
I have a test script that can reproduce this issue 100%. If necessary,
I can send it along.
This is using ofono 1.16 and connman 1.29 on a custom embedded system
generated by buildroot. I have three small patches applied, one for
ofono I got from the mailing list to support the e173, another for
ofono to allow duplicate APNs, and a third for connman to allow
autoconnecting cellular modems by specifying 'cellular' in
DefaultAutoConnectTechnologies. Unfortunately, I need all three to
enable my setup so I cannot test a pure source release.
Thanks,
Mike
6 years, 11 months
[PATCH] Connecting a phone with mpty call does not trigger CLCC polling
by Kuba Pawlak
If there is more then one active or held call, we are in mpty calls.
We won't get indicator update if any of them is released by CHLD=1x.
So we have to poll it.
---
drivers/hfpmodem/voicecall.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/hfpmodem/voicecall.c b/drivers/hfpmodem/voicecall.c
index afeb35f..5d044a9 100644
--- a/drivers/hfpmodem/voicecall.c
+++ b/drivers/hfpmodem/voicecall.c
@@ -1134,6 +1134,10 @@ static void hfp_clcc_cb(gboolean ok, GAtResult *result, gpointer user_data)
struct ofono_voicecall *vc = user_data;
struct voicecall_data *vd = ofono_voicecall_get_data(vc);
unsigned int mpty_ids;
+ GSList *n;
+ struct ofono_call *nc;
+ unsigned int num_active = 0;
+ unsigned int num_held = 0;
if (!ok)
return;
@@ -1142,6 +1146,22 @@ static void hfp_clcc_cb(gboolean ok, GAtResult *result, gpointer user_data)
g_slist_foreach(vd->calls, voicecall_notify, vc);
ofono_voicecall_mpty_hint(vc, mpty_ids);
+
+ n = vd->calls;
+
+ while (n) {
+ nc = n ? n->data : NULL;
+ if (nc && (nc->status == CALL_STATUS_ACTIVE))
+ num_active++;
+
+ if (nc && (nc->status == CALL_STATUS_HELD))
+ num_held++;
+
+ n = n->next;
+ }
+
+ if ((num_active > 1 || num_held > 1) && !vd->clcc_source)
+ vd->clcc_source = g_timeout_add(POLL_CLCC_INTERVAL, poll_clcc, vc);
}
static void hfp_voicecall_initialized(gboolean ok, GAtResult *result,
--
1.7.11.7
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052
6 years, 11 months
[PATCH] gprs: Add comment to gprs_reset_contexts
by Alfonso Sanchez-Beato
---
src/gprs.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/gprs.c b/src/gprs.c
index 9c15abf..f21fe6e 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -2318,6 +2318,11 @@ static DBusMessage *gprs_reset_contexts(DBusConnection *conn,
if (gprs->pending)
return __ofono_error_busy(msg);
+ /*
+ * We want __ofono_error_busy to take precedence over
+ * __ofono_error_not_allowed errors, so we check it first.
+ */
+
for (l = gprs->contexts; l; l = l->next) {
struct pri_context *ctx = l->data;
--
2.1.4
6 years, 12 months
[PATCH 0/3] Add method to force re-provisioning of contexts
by Alfonso Sanchez-Beato
This series of patches implement a way to force re-provisioning of the
ConnectionManager contexts. Although the idea is similar to a previous
approach which was posted to the list, it is quite different as it
wipes all existing contexts and then runs the provisioning code. The
implemented method checks different conditions to make the reset safe
for clients.
Alfonso Sanchez-Beato (3):
gprs: Add DBus method to reset contexts
doc: Add description for ResetContexts method
test: Add script for resetting contexts
doc/connman-api.txt | 10 ++++
src/gprs.c | 144 +++++++++++++++++++++++++++++++++++++++++++---------
test/reset-contexts | 20 ++++++++
3 files changed, 150 insertions(+), 24 deletions(-)
create mode 100644 test/reset-contexts
--
2.1.4
6 years, 12 months
[PATCH 1/4] gprs: Add DBus method to reset contexts
by Alfonso Sanchez-Beato
Add DBus method that removes the current contexts and re-provisions
using the APN database.
---
src/gprs.c | 142 ++++++++++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 118 insertions(+), 24 deletions(-)
diff --git a/src/gprs.c b/src/gprs.c
index 05ab499..64fa6f1 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -149,6 +149,8 @@ struct pri_context {
static void gprs_netreg_update(struct ofono_gprs *gprs);
static void gprs_deactivate_next(struct ofono_gprs *gprs);
+static void provision_contexts(struct ofono_gprs *gprs, const char *mcc,
+ const char *mnc, const char *spn);
static GSList *g_drivers = NULL;
static GSList *g_context_drivers = NULL;
@@ -1885,6 +1887,36 @@ static struct pri_context *add_context(struct ofono_gprs *gprs,
return context;
}
+static void send_context_added_signal(struct ofono_gprs *gprs,
+ struct pri_context *context,
+ DBusConnection *conn)
+{
+ const char *path;
+ DBusMessage *signal;
+ DBusMessageIter iter;
+ DBusMessageIter dict;
+
+ path = __ofono_atom_get_path(gprs->atom);
+ signal = dbus_message_new_signal(path,
+ OFONO_CONNECTION_MANAGER_INTERFACE,
+ "ContextAdded");
+ if (!signal)
+ return;
+
+ dbus_message_iter_init_append(signal, &iter);
+
+ path = context->path;
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &path);
+
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ OFONO_PROPERTIES_ARRAY_SIGNATURE,
+ &dict);
+ append_context_properties(context, &dict);
+ dbus_message_iter_close_container(&iter, &dict);
+
+ g_dbus_send_message(conn, signal);
+}
+
static DBusMessage *gprs_add_context(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -1894,7 +1926,6 @@ static DBusMessage *gprs_add_context(DBusConnection *conn,
const char *name;
const char *path;
enum ofono_gprs_context_type type;
- DBusMessage *signal;
if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &typestr,
DBUS_TYPE_INVALID))
@@ -1916,29 +1947,7 @@ static DBusMessage *gprs_add_context(DBusConnection *conn,
g_dbus_send_reply(conn, msg, DBUS_TYPE_OBJECT_PATH, &path,
DBUS_TYPE_INVALID);
- path = __ofono_atom_get_path(gprs->atom);
- signal = dbus_message_new_signal(path,
- OFONO_CONNECTION_MANAGER_INTERFACE,
- "ContextAdded");
-
- if (signal) {
- DBusMessageIter iter;
- DBusMessageIter dict;
-
- dbus_message_iter_init_append(signal, &iter);
-
- path = context->path;
- dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
- &path);
-
- dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
- OFONO_PROPERTIES_ARRAY_SIGNATURE,
- &dict);
- append_context_properties(context, &dict);
- dbus_message_iter_close_container(&iter, &dict);
-
- g_dbus_send_message(conn, signal);
- }
+ send_context_added_signal(gprs, context, conn);
return NULL;
}
@@ -2173,6 +2182,89 @@ static DBusMessage *gprs_get_contexts(DBusConnection *conn,
return reply;
}
+static void remove_non_active_context(struct ofono_gprs *gprs,
+ struct pri_context *ctx, DBusConnection *conn)
+{
+ char *path;
+ const char *atompath;
+
+ if (gprs->settings) {
+ g_key_file_remove_group(gprs->settings, ctx->key, NULL);
+ storage_sync(gprs->imsi, SETTINGS_STORE, gprs->settings);
+ }
+
+ /* Make a backup copy of path for signal emission below */
+ path = g_strdup(ctx->path);
+
+ context_dbus_unregister(ctx);
+ gprs->contexts = g_slist_remove(gprs->contexts, ctx);
+
+ atompath = __ofono_atom_get_path(gprs->atom);
+ g_dbus_emit_signal(conn, atompath, OFONO_CONNECTION_MANAGER_INTERFACE,
+ "ContextRemoved", DBUS_TYPE_OBJECT_PATH, &path,
+ DBUS_TYPE_INVALID);
+ g_free(path);
+}
+
+static DBusMessage *gprs_reset_contexts(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_gprs *gprs = data;
+ struct ofono_modem *modem = __ofono_atom_get_modem(gprs->atom);
+ struct ofono_sim *sim = __ofono_atom_find(OFONO_ATOM_TYPE_SIM, modem);
+ DBusMessage *reply;
+ GSList *l;
+
+ if (gprs->pending)
+ return __ofono_error_busy(msg);
+
+ for (l = gprs->contexts; l; l = l->next) {
+ struct pri_context *ctx = l->data;
+
+ if (ctx->pending)
+ return __ofono_error_busy(msg);
+ }
+
+ if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_INVALID))
+ return __ofono_error_invalid_args(msg);
+
+ if (gprs->powered)
+ return __ofono_error_not_allowed(msg);
+
+ for (l = gprs->contexts; l; l = l->next) {
+ struct pri_context *ctx = l->data;
+
+ if (ctx->active)
+ return __ofono_error_not_allowed(msg);
+ }
+
+ reply = dbus_message_new_method_return(msg);
+ if (reply == NULL)
+ return NULL;
+
+ /* Remove first the current contexts, re-provision after */
+
+ while (gprs->contexts != NULL) {
+ struct pri_context *ctx = gprs->contexts->data;
+ remove_non_active_context(gprs, ctx, conn);
+ }
+
+ gprs->last_context_id = 0;
+
+ provision_contexts(gprs, ofono_sim_get_mcc(sim),
+ ofono_sim_get_mnc(sim), ofono_sim_get_spn(sim));
+
+ if (gprs->contexts == NULL) /* Automatic provisioning failed */
+ add_context(gprs, NULL, OFONO_GPRS_CONTEXT_TYPE_INTERNET);
+
+ for (l = gprs->contexts; l; l = l->next) {
+ struct pri_context *ctx = l->data;
+ send_context_added_signal(gprs, ctx, conn);
+ }
+
+ return reply;
+}
+
static const GDBusMethodTable manager_methods[] = {
{ GDBUS_METHOD("GetProperties",
NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
@@ -2192,6 +2284,8 @@ static const GDBusMethodTable manager_methods[] = {
{ GDBUS_METHOD("GetContexts", NULL,
GDBUS_ARGS({ "contexts_with_properties", "a(oa{sv})" }),
gprs_get_contexts) },
+ { GDBUS_ASYNC_METHOD("ResetContexts", NULL, NULL,
+ gprs_reset_contexts) },
{ }
};
--
2.1.4
6 years, 12 months