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, 3 months
[PATCH] netmon: Make sure we don't pass NULL message to g_dbus_send_message
by Slava Monich
Also that we don't lose the reply message.
---
src/netmon.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/netmon.c b/src/netmon.c
index 9d6de07..eb18b9c 100644
--- a/src/netmon.c
+++ b/src/netmon.c
@@ -199,9 +199,24 @@ static void serving_cell_info_callback(const struct ofono_error *error,
struct ofono_netmon *netmon = data;
DBusMessage *reply = netmon->reply;
- if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
+ 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);
+ }
+ netmon->reply = NULL;
__ofono_dbus_pending_reply(&netmon->pending, reply);
}
--
1.9.1
4 years, 5 months
[PATCH 1/4] unit: add rilmodem test engine
by Alfonso Sánchez-Beato
Add rilmodem test engine. This engine is an improvement on the rilmodem
test server that allows us to test generic interactions with the
rilmodem driver. Instead of just be able to check content of received/
sent bytes on the rild socket, we can now specify a set of steps for a
test that include interactions with the atom. The step types are
- TST_ACTION_SEND: The harness sends a parcel
- TST_ACTION_CALL: The harness calls a driver function
- TST_EVENT_RECEIVE: The driver sends a parcel
- TST_EVENT_CALL: The driver calls a harness (atom) function
---
unit/rilmodem-test-engine.c | 280 ++++++++++++++++++++++++++++++++++++++++++++
unit/rilmodem-test-engine.h | 74 ++++++++++++
2 files changed, 354 insertions(+)
create mode 100644 unit/rilmodem-test-engine.c
create mode 100644 unit/rilmodem-test-engine.h
diff --git a/unit/rilmodem-test-engine.c b/unit/rilmodem-test-engine.c
new file mode 100644
index 0000000..c569360
--- /dev/null
+++ b/unit/rilmodem-test-engine.c
@@ -0,0 +1,280 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2016 Canonical 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
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+
+#include <ofono/types.h>
+
+#include <gril.h>
+
+#include "rilmodem-test-engine.h"
+
+#define MAX_REQUEST_SIZE 4096
+#define RIL_SERVER_SOCK_PATH "/tmp/unittestril"
+
+static GMainLoop *mainloop;
+
+struct engine_data {
+ int server_sk;
+ int connected_sk;
+ guint connection_watch;
+ rilmodem_test_engine_cb_t connect_func;
+ GIOChannel *server_io;
+ char *sock_name;
+ struct rilmodem_test_data rtd;
+ int step_i;
+ void *user_data;
+};
+
+static void send_parcel(struct engine_data *ed)
+{
+ GIOStatus status;
+ gsize wbytes;
+ const struct rilmodem_test_step *step = &ed->rtd.steps[ed->step_i];
+
+ status = g_io_channel_write_chars(ed->server_io,
+ step->parcel_data,
+ step->parcel_size,
+ &wbytes, NULL);
+
+ g_assert(wbytes == step->parcel_size);
+ g_assert(status == G_IO_STATUS_NORMAL);
+
+ status = g_io_channel_flush(ed->server_io, NULL);
+ g_assert(status == G_IO_STATUS_NORMAL);
+
+ rilmodem_test_engine_next_step(ed);
+}
+
+static gboolean on_rx_data(GIOChannel *chan, GIOCondition cond, gpointer data)
+{
+ struct engine_data *ed = data;
+ GIOStatus status;
+ gsize rbytes;
+ gchar *buf;
+ const struct rilmodem_test_step *step;
+
+ /* We have closed the socket */
+ if (cond == G_IO_NVAL)
+ return FALSE;
+
+ buf = g_malloc0(MAX_REQUEST_SIZE);
+
+ status = g_io_channel_read_chars(ed->server_io, buf, MAX_REQUEST_SIZE,
+ &rbytes, NULL);
+ g_assert(status == G_IO_STATUS_NORMAL);
+
+ /* Check this is the expected step */
+ step = &ed->rtd.steps[ed->step_i];
+ g_assert(step->type == TST_EVENT_RECEIVE);
+
+ g_assert(rbytes == step->parcel_size);
+
+ /* validate received parcel */
+ g_assert(!memcmp(buf, step->parcel_data, rbytes));
+
+ rilmodem_test_engine_next_step(ed);
+
+ return TRUE;
+}
+
+static gboolean on_socket_connected(GIOChannel *chan, GIOCondition cond,
+ gpointer data)
+{
+ struct engine_data *ed = data;
+ struct sockaddr saddr;
+ unsigned int len = sizeof(saddr);
+ GIOStatus status;
+
+ g_assert(cond == G_IO_IN);
+
+ ed->connected_sk = accept(ed->server_sk, &saddr, &len);
+ g_assert(ed->connected_sk != -1);
+
+ ed->server_io = g_io_channel_unix_new(ed->connected_sk);
+ g_assert(ed->server_io != NULL);
+
+ status = g_io_channel_set_encoding(ed->server_io, NULL, NULL);
+ g_assert(status == G_IO_STATUS_NORMAL);
+
+ g_io_channel_set_buffered(ed->server_io, FALSE);
+ g_io_channel_set_close_on_unref(ed->server_io, TRUE);
+
+ if (ed->connect_func)
+ ed->connect_func(ed->user_data);
+
+ ed->connection_watch =
+ g_io_add_watch_full(ed->server_io, G_PRIORITY_DEFAULT,
+ G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+ on_rx_data, ed, NULL);
+ g_io_channel_unref(ed->server_io);
+
+ return FALSE;
+}
+
+void rilmodem_test_engine_remove(struct engine_data *ed)
+{
+ if (ed->connection_watch)
+ g_source_remove(ed->connection_watch);
+
+ g_assert(ed->server_sk);
+ close(ed->server_sk);
+ remove(ed->sock_name);
+ g_free(ed->sock_name);
+ g_free(ed);
+}
+
+struct engine_data *rilmodem_test_engine_create(
+ rilmodem_test_engine_cb_t connect,
+ const struct rilmodem_test_data *test_data,
+ void *data)
+{
+ GIOChannel *io;
+ struct sockaddr_un addr;
+ int retval;
+ struct engine_data *ed;
+
+ ed = g_new0(struct engine_data, 1);
+
+ ed->connect_func = connect;
+ ed->user_data = data;
+ ed->rtd = *test_data;
+
+ ed->server_sk = socket(AF_UNIX, SOCK_STREAM, 0);
+ g_assert(ed->server_sk);
+
+ ed->sock_name =
+ g_strdup_printf(RIL_SERVER_SOCK_PATH"%u", (unsigned) getpid());
+
+ memset(&addr, 0, sizeof(addr));
+ addr.sun_family = AF_UNIX;
+ strncpy(addr.sun_path, ed->sock_name, sizeof(addr.sun_path) - 1);
+
+ /* Unlink any existing socket for this session */
+ unlink(addr.sun_path);
+
+ retval = bind(ed->server_sk, (struct sockaddr *) &addr, sizeof(addr));
+ g_assert(retval >= 0);
+
+ retval = listen(ed->server_sk, 0);
+ g_assert(retval >= 0);
+
+ io = g_io_channel_unix_new(ed->server_sk);
+ g_assert(io != NULL);
+
+ g_io_channel_set_close_on_unref(io, TRUE);
+ g_io_add_watch_full(io, G_PRIORITY_DEFAULT,
+ G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+ on_socket_connected, ed, NULL);
+
+ g_io_channel_unref(io);
+
+ return ed;
+}
+
+void rilmodem_test_engine_write_socket(struct engine_data *ed,
+ const unsigned char *buf,
+ const size_t buf_len)
+{
+ GIOStatus status;
+ gsize wbytes;
+
+ status = g_io_channel_write_chars(ed->server_io,
+ (const char *) buf,
+ buf_len,
+ &wbytes, NULL);
+
+ g_assert(status == G_IO_STATUS_NORMAL);
+
+ status = g_io_channel_flush(ed->server_io, NULL);
+
+ g_assert(status == G_IO_STATUS_NORMAL);
+}
+
+const char *rilmodem_test_engine_get_socket_name(struct engine_data *ed)
+{
+ return ed->sock_name;
+}
+
+static gboolean action_call(gpointer data)
+{
+ struct engine_data *ed = data;
+ const struct rilmodem_test_step *step;
+
+ step = &ed->rtd.steps[ed->step_i];
+
+ step->call_action(ed->user_data);
+
+ return FALSE;
+}
+
+void rilmodem_test_engine_next_step(struct engine_data *ed)
+{
+ const struct rilmodem_test_step *step;
+
+ ed->step_i++;
+
+ if (ed->step_i >= ed->rtd.num_steps) {
+ /* Finish the test */
+ g_main_loop_quit(mainloop);
+ return;
+ }
+
+ step = &ed->rtd.steps[ed->step_i];
+
+ /* If next step is an action, execute it */
+ switch (step->type) {
+ case TST_ACTION_SEND:
+ send_parcel(ed);
+ break;
+ case TST_ACTION_CALL:
+ g_idle_add(action_call, ed);
+ break;
+ case TST_EVENT_RECEIVE:
+ case TST_EVENT_CALL:
+ break;
+ };
+}
+
+const struct rilmodem_test_step *rilmodem_test_engine_get_current_step(
+ struct engine_data *ed)
+{
+ const struct rilmodem_test_step *step = &ed->rtd.steps[ed->step_i];
+
+ return step;
+}
+
+void rilmodem_test_engine_start(struct engine_data *ed)
+{
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ g_main_loop_run(mainloop);
+ g_main_loop_unref(mainloop);
+}
diff --git a/unit/rilmodem-test-engine.h b/unit/rilmodem-test-engine.h
new file mode 100644
index 0000000..185d9bc
--- /dev/null
+++ b/unit/rilmodem-test-engine.h
@@ -0,0 +1,74 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2016 Canonical 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
+ *
+ */
+
+struct engine_data;
+
+enum test_step_type {
+ TST_ACTION_SEND,
+ TST_ACTION_CALL,
+ TST_EVENT_RECEIVE,
+ TST_EVENT_CALL,
+};
+
+typedef void (*rilmodem_test_engine_cb_t)(void *data);
+
+struct rilmodem_test_step {
+ enum test_step_type type;
+
+ union {
+ /* For TST_ACTION_CALL */
+ rilmodem_test_engine_cb_t call_action;
+ /* For TST_ACTION_SEND or TST_EVENT_RECEIVE */
+ struct {
+ const char *parcel_data;
+ const size_t parcel_size;
+ };
+ /* For TST_EVENT_CALL */
+ struct {
+ void (*call_func)(void);
+ void (*check_func)(void);
+ };
+ };
+};
+
+struct rilmodem_test_data {
+ const struct rilmodem_test_step *steps;
+ int num_steps;
+};
+
+void rilmodem_test_engine_remove(struct engine_data *ed);
+
+struct engine_data *rilmodem_test_engine_create(
+ rilmodem_test_engine_cb_t connect,
+ const struct rilmodem_test_data *test_data,
+ void *data);
+
+void rilmodem_test_engine_write_socket(struct engine_data *ed,
+ const unsigned char *buf,
+ const size_t buf_len);
+
+const char *rilmodem_test_engine_get_socket_name(struct engine_data *ed);
+
+void rilmodem_test_engine_next_step(struct engine_data *ed);
+const struct rilmodem_test_step *rilmodem_test_engine_get_current_step(
+ struct engine_data *ed);
+
+void rilmodem_test_engine_start(struct engine_data *ed);
--
2.9.3
4 years, 5 months
[PATCH] gprs-context: Remove unused field from struct ofono_gprs_primary_context
by Slava Monich
---
include/gprs-context.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/include/gprs-context.h b/include/gprs-context.h
index c4910f2..ab67326 100644
--- a/include/gprs-context.h
+++ b/include/gprs-context.h
@@ -55,7 +55,6 @@ enum ofono_gprs_auth_method {
struct ofono_gprs_primary_context {
unsigned int cid;
- int direction;
char apn[OFONO_GPRS_MAX_APN_LENGTH + 1];
char username[OFONO_GPRS_MAX_USERNAME_LENGTH + 1];
char password[OFONO_GPRS_MAX_PASSWORD_LENGTH + 1];
--
1.9.1
4 years, 6 months
IPV6 question
by Enrico Sau
Hi all,
As far as I understand, ofono doen't support IPV6 over ppp due to the fact
that IPV6 compression protocol implementation is missing.
Is that right?
Thank you,
Enrico
4 years, 6 months
[PATCH] gatmux: add telit specific mux implementation.
by Antoine Aubert
quote from telit: Initiator is the station that take the initiative to initialize the multiplexer (i.e. sends the
SABM command at DLCI 0 ) and the responder is the station that accepts the initialization
of the multiplexer (i.e. sends the UA response at DLCI 0)
In Telit implementation module is NEVER an initiator since it is up to controller to send the
SABM command to DLCI 0
---
gatchat/gatmux.c | 24 ++++++++++++++++++++++++
gatchat/gatmux.h | 2 ++
2 files changed, 26 insertions(+)
diff --git a/gatchat/gatmux.c b/gatchat/gatmux.c
index 9beeece..5785822 100644
--- a/gatchat/gatmux.c
+++ b/gatchat/gatmux.c
@@ -35,6 +35,7 @@
#include "ringbuffer.h"
#include "gatmux.h"
#include "gsm0710.h"
+#include "drivers/atmodem/vendor.h"
static const char *cmux_prefix[] = { "+CMUX:", NULL };
static const char *none_prefix[] = { NULL };
@@ -87,6 +88,7 @@ struct _GAtMux {
char buf[MUX_BUFFER_SIZE]; /* Buffer on the main mux */
int buf_used; /* Bytes of buf being used */
gboolean shutdown;
+ unsigned int vendor; /* Specific vendor */
};
struct mux_setup_data {
@@ -566,6 +568,8 @@ GAtMux *g_at_mux_new(GIOChannel *channel, const GAtMuxDriver *driver)
mux->channel = channel;
g_io_channel_ref(channel);
+ mux->vendor = OFONO_VENDOR_GENERIC;
+
g_io_channel_set_close_on_unref(channel, TRUE);
return mux;
@@ -669,6 +673,16 @@ gboolean g_at_mux_set_debug(GAtMux *mux, GAtDebugFunc func, gpointer user_data)
return TRUE;
}
+gboolean g_at_mux_set_vendor(GAtMux *mux, unsigned int vendor)
+{
+ if (mux == NULL)
+ return FALSE;
+
+ mux->vendor = vendor;
+
+ return TRUE;
+}
+
GIOChannel *g_at_mux_create_channel(GAtMux *mux)
{
GAtMuxChannel *mux_channel;
@@ -951,6 +965,16 @@ static gboolean gsm0710_packet(GAtMux *mux, int dlc, guint8 control,
resp[1] = ((len << 1) | 0x01);
memcpy(resp + 2, data, len);
write_frame(mux, 0, GSM0710_DATA, resp, len + 2);
+
+ /* In Telit implementation module is NEVER an initiator
+ * since it is up to controller to send the SABM command to DLCI 0
+ */
+ if (mux->vendor == OFONO_VENDOR_TELIT) {
+ resp[0] = GSM0710_STATUS_SET;
+ resp[3] = 0x0D;
+ write_frame(mux, 0, GSM0710_DATA, resp, len + 2);
+ }
+
}
return TRUE;
diff --git a/gatchat/gatmux.h b/gatchat/gatmux.h
index 4d77c72..ab1962c 100644
--- a/gatchat/gatmux.h
+++ b/gatchat/gatmux.h
@@ -69,6 +69,8 @@ gboolean g_at_mux_set_disconnect_function(GAtMux *mux,
gboolean g_at_mux_set_debug(GAtMux *mux, GAtDebugFunc func, gpointer user_data);
+gboolean g_at_mux_set_vendor(GAtMux *mux, unsigned int vendor);
+
GIOChannel *g_at_mux_create_channel(GAtMux *mux);
/*!
--
2.7.4
4 years, 6 months
[PATCH] gatmux: fix channel remove on error.
by Antoine Aubert
In case of invalid IO, read_watch is not reset. Fix crash on destroy
gatmux.
Signed-off-by: Antoine Aubert <a.aubert(a)overkiz.com>
---
gatchat/gatmux.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/gatchat/gatmux.c b/gatchat/gatmux.c
index 9beeece..896ddff 100644
--- a/gatchat/gatmux.c
+++ b/gatchat/gatmux.c
@@ -186,8 +186,10 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond,
GIOStatus status;
gsize bytes_read;
- if (cond & G_IO_NVAL)
+ if (cond & G_IO_NVAL) {
+ mux->read_watch = 0;
return FALSE;
+ }
debug(mux, "received data");
@@ -223,14 +225,20 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond,
}
}
- if (cond & (G_IO_HUP | G_IO_ERR))
+ if (cond & (G_IO_HUP | G_IO_ERR)) {
+ mux->read_watch = 0;
return FALSE;
+ }
- if (status != G_IO_STATUS_NORMAL && status != G_IO_STATUS_AGAIN)
+ if (status != G_IO_STATUS_NORMAL && status != G_IO_STATUS_AGAIN) {
+ mux->read_watch = 0;
return FALSE;
+ }
- if (mux->buf_used == sizeof(mux->buf))
+ if (mux->buf_used == sizeof(mux->buf)) {
+ mux->read_watch = 0;
return FALSE;
+ }
return TRUE;
}
--
2.7.4
4 years, 6 months
[PATCH] main: Make -d option repeatable
by Slava Monich
Concatenating the patterns makes more sense than using the last
supplied value and leaking the previous allocated patterns.
---
src/main.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/main.c b/src/main.c
index 46bb90b..b43bb4e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -137,10 +137,19 @@ static gboolean option_version = FALSE;
static gboolean parse_debug(const char *key, const char *value,
gpointer user_data, GError **error)
{
- if (value)
- option_debug = g_strdup(value);
- else
+ if (value) {
+ if (option_debug) {
+ char *prev = option_debug;
+
+ option_debug = g_strconcat(prev, ",", value, NULL);
+ g_free(prev);
+ } else {
+ option_debug = g_strdup(value);
+ }
+ } else {
+ g_free(option_debug);
option_debug = g_strdup("*");
+ }
return TRUE;
}
@@ -262,5 +271,7 @@ cleanup:
__ofono_log_cleanup();
+ g_free(option_debug);
+
return 0;
}
--
1.9.1
4 years, 6 months