[PATCH] ifxmodem: Adding fast dormancy support to Infineon modem
by Robertino Benis
Initial patch to add fast dormancy to Infineon modem. Timeout is not
supported yet.
Thanks,
-- r.
---
drivers/ifxmodem/radio-settings.c | 40 ++++++++++++++++++++++++++++++++++++-
1 files changed, 39 insertions(+), 1 deletions(-)
diff --git a/drivers/ifxmodem/radio-settings.c b/drivers/ifxmodem/radio-settings.c
index 89e97e7..68077db 100644
--- a/drivers/ifxmodem/radio-settings.c
+++ b/drivers/ifxmodem/radio-settings.c
@@ -27,6 +27,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
+#include <stdint.h>
#include <errno.h>
#include <glib.h>
@@ -45,6 +46,7 @@ static const char *xrat_prefix[] = { "+XRAT:", NULL };
struct radio_settings_data {
GAtChat *chat;
+ uint16_t fast_dormancy;
};
static void xrat_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
@@ -196,12 +198,48 @@ static void ifx_radio_settings_remove(struct ofono_radio_settings *rs)
g_free(rsd);
}
+static void update_fast_dormancy(struct radio_settings_data *rsd)
+{
+ char buf[20];
+
+ snprintf(buf, sizeof(buf), "AT+XFDOR=%u", rsd->fast_dormancy);
+
+ if (g_at_chat_send(rsd->chat, buf, NULL, NULL, NULL, NULL) > 0)
+ DBG("3G fast dormancy %s.",
+ rsd->fast_dormancy ? "enabled" : "disabled");
+ else
+ DBG("3G fast dormancy unchanged.");
+}
+
+static void ifx_set_fast_dormancy(struct ofono_radio_settings *rs,
+ int enable,
+ ofono_radio_settings_fast_dormancy_set_cb_t cb,
+ void *data)
+{
+ struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+ rsd->fast_dormancy = enable ? 1 : 0;
+ update_fast_dormancy(rsd);
+ CALLBACK_WITH_SUCCESS(cb, data);
+}
+
+static void ifx_query_fast_dormancy(struct ofono_radio_settings *rs,
+ ofono_radio_settings_fast_dormancy_query_cb_t cb,
+ void *data)
+{
+ struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+
+ /* there is no read AT command */
+ CALLBACK_WITH_SUCCESS(cb, rsd->fast_dormancy, data);
+}
+
static struct ofono_radio_settings_driver driver = {
.name = "ifxmodem",
.probe = ifx_radio_settings_probe,
.remove = ifx_radio_settings_remove,
.query_rat_mode = ifx_query_rat_mode,
- .set_rat_mode = ifx_set_rat_mode
+ .set_rat_mode = ifx_set_rat_mode,
+ .query_fast_dormancy = ifx_query_fast_dormancy,
+ .set_fast_dormancy = ifx_set_fast_dormancy
};
void ifx_radio_settings_init()
--
1.7.0.4
11 years, 10 months
[PATCH] function g_mkstemp_full in src/storage.c
by George Matveev
---
configure.ac | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 6aeab7c..c0f4217 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,8 +67,8 @@ AC_CHECK_LIB(c, signalfd, dummy=yes,
AC_CHECK_LIB(dl, dlopen, dummy=yes,
AC_MSG_ERROR(dynamic linking loader is required))
-PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes,
- AC_MSG_ERROR(GLib >= 2.16 is required))
+PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.22, dummy=yes,
+ AC_MSG_ERROR(GLib >= 2.22 is required))
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
--
1.5.6.5
11 years, 10 months
[PATCH] build: Update glib version in configure.ac
by George Matveev
function g_mkstemp_full in src/storage.c
requires glib version 2.22 or higher
---
configure.ac | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 6aeab7c..c0f4217 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,8 +67,8 @@ AC_CHECK_LIB(c, signalfd, dummy=yes,
AC_CHECK_LIB(dl, dlopen, dummy=yes,
AC_MSG_ERROR(dynamic linking loader is required))
-PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes,
- AC_MSG_ERROR(GLib >= 2.16 is required))
+PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.22, dummy=yes,
+ AC_MSG_ERROR(GLib >= 2.22 is required))
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
--
1.5.6.5
11 years, 10 months
[PATCH] build: Update glib version in configure.ac
by George Matveev
function g_mkstemp_full in src/storage.c
requires glib version 2.22 or higher
---
configure.ac | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 6aeab7c..c0f4217 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,8 +67,8 @@ AC_CHECK_LIB(c, signalfd, dummy=yes,
AC_CHECK_LIB(dl, dlopen, dummy=yes,
AC_MSG_ERROR(dynamic linking loader is required))
-PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes,
- AC_MSG_ERROR(GLib >= 2.16 is required))
+PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.22, dummy=yes,
+ AC_MSG_ERROR(GLib >= 2.22 is required))
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
--
1.5.6.5
11 years, 10 months
[PATCH 1/3] Add TTY (hearing impaired) support
by Lucas De Marchi
---
Makefile.am | 5 +-
include/dbus.h | 1 +
include/text-telephony.h | 71 ++++++++++
src/modem.c | 1 +
src/ofono.h | 2 +
src/text-telephony.c | 333 ++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 411 insertions(+), 2 deletions(-)
create mode 100644 include/text-telephony.h
create mode 100644 src/text-telephony.c
diff --git a/Makefile.am b/Makefile.am
index f841b4c..ee1313d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,7 +13,8 @@ include_HEADERS = include/log.h include/plugin.h include/history.h \
include/cbs.h include/call-volume.h \
include/gprs.h include/gprs-context.h \
include/radio-settings.h include/stk.h \
- include/audio-settings.h include/nettime.h
+ include/audio-settings.h include/nettime.h \
+ include/text-telephony.h
nodist_include_HEADERS = include/version.h
@@ -318,7 +319,7 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) src/ofono.ver \
src/radio-settings.c src/stkutil.h src/stkutil.c \
src/nettime.c src/stkagent.c src/stkagent.h \
src/simfs.c src/simfs.h src/audio-settings.c \
- src/smsagent.c src/smsagent.h
+ src/smsagent.c src/smsagent.h src/text-telephony.c
src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
diff --git a/include/dbus.h b/include/dbus.h
index 59b2aae..9e29afb 100644
--- a/include/dbus.h
+++ b/include/dbus.h
@@ -48,6 +48,7 @@ extern "C" {
#define OFONO_PHONEBOOK_INTERFACE "org.ofono.Phonebook"
#define OFONO_RADIO_SETTINGS_INTERFACE "org.ofono.RadioSettings"
#define OFONO_AUDIO_SETTINGS_INTERFACE "org.ofono.AudioSettings"
+#define OFONO_TEXT_TELEPHONY_INTERFACE "org.ofono.TextTelephony"
#define OFONO_SIM_MANAGER_INTERFACE "org.ofono.SimManager"
#define OFONO_VOICECALL_INTERFACE "org.ofono.VoiceCall"
#define OFONO_VOICECALL_MANAGER_INTERFACE "org.ofono.VoiceCallManager"
diff --git a/include/text-telephony.h b/include/text-telephony.h
new file mode 100644
index 0000000..fafa7dd
--- /dev/null
+++ b/include/text-telephony.h
@@ -0,0 +1,71 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * Copyright (C) 2010 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
+ *
+ */
+
+#ifndef __OFONO_TEXT_TELEPHONY_H
+#define __OFONO_TEXT_TELEPHONY_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ofono/types.h>
+
+struct ofono_text_telephony;
+
+typedef void (*ofono_text_telephony_set_cb_t)(const struct ofono_error *error,
+ void *data);
+typedef void (*ofono_text_telephony_query_cb_t)(const struct ofono_error *error,
+ ofono_bool_t enable, void *data);
+
+struct ofono_text_telephony_driver {
+ const char *name;
+ int (*probe)(struct ofono_text_telephony *tt, unsigned int vendor,
+ void *data);
+ void (*remove)(struct ofono_text_telephony *tt);
+ void (*query_tty)(struct ofono_text_telephony *tt,
+ ofono_text_telephony_query_cb_t cb,
+ void *data);
+ void (*set_tty)(struct ofono_text_telephony *tt,
+ int enable,
+ ofono_text_telephony_set_cb_t cb,
+ void *data);
+};
+
+int ofono_text_telephony_driver_register(const struct ofono_text_telephony_driver *d);
+void ofono_text_telephony_driver_unregister(const struct ofono_text_telephony_driver *d);
+
+struct ofono_text_telephony *ofono_text_telephony_create(struct ofono_modem *modem,
+ unsigned int vendor,
+ const char *driver,
+ void *data);
+
+void ofono_text_telephony_register(struct ofono_text_telephony *tt);
+void ofono_text_telephony_remove(struct ofono_text_telephony *tt);
+
+void ofono_text_telephony_set_data(struct ofono_text_telephony *tt, void *data);
+void *ofono_text_telephony_get_data(struct ofono_text_telephony *tt);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_TEXT_TELEPHONY_H */
diff --git a/src/modem.c b/src/modem.c
index 3776461..6f1db7c 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -857,6 +857,7 @@ static const struct {
{ OFONO_SIM_MANAGER_INTERFACE, "sim" },
{ OFONO_STK_INTERFACE, "stk" },
{ OFONO_CONNECTION_MANAGER_INTERFACE, "gprs" },
+ { OFONO_TEXT_TELEPHONY_INTERFACE, "tty" },
{ },
};
diff --git a/src/ofono.h b/src/ofono.h
index 4d76d20..5218f42 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -124,6 +124,7 @@ enum ofono_atom_type {
OFONO_ATOM_TYPE_AUDIO_SETTINGS = 19,
OFONO_ATOM_TYPE_STK = 20,
OFONO_ATOM_TYPE_NETTIME = 21,
+ OFONO_ATOM_TYPE_TEXT_TELEPHONY = 22
};
enum ofono_atom_watch_condition {
@@ -197,6 +198,7 @@ gboolean __ofono_call_settings_is_busy(struct ofono_call_settings *cs);
#include <ofono/gprs-context.h>
#include <ofono/radio-settings.h>
#include <ofono/audio-settings.h>
+#include <ofono/text-telephony.h>
#include <ofono/voicecall.h>
diff --git a/src/text-telephony.c b/src/text-telephony.c
new file mode 100644
index 0000000..4640bd8
--- /dev/null
+++ b/src/text-telephony.c
@@ -0,0 +1,333 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * Copyright (C) 2010 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 <string.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <gdbus.h>
+
+#include "ofono.h"
+#include "common.h"
+
+static GSList *g_drivers = NULL;
+
+struct ofono_text_telephony {
+ DBusMessage *pending;
+ ofono_bool_t powered;
+ ofono_bool_t powered_pending;
+ const struct ofono_text_telephony_driver *driver;
+ void *driver_data;
+ struct ofono_atom *atom;
+};
+
+static DBusMessage *tt_get_properties_reply(DBusMessage *msg,
+ struct ofono_text_telephony *tt)
+{
+ DBusMessage *reply;
+ DBusMessageIter iter;
+ DBusMessageIter dict;
+ dbus_bool_t value;
+
+ reply = dbus_message_new_method_return(msg);
+ if (!reply)
+ return NULL;
+
+ dbus_message_iter_init_append(reply, &iter);
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ OFONO_PROPERTIES_ARRAY_SIGNATURE,
+ &dict);
+
+ value = tt->powered;
+ ofono_dbus_dict_append(&dict, "Powered", DBUS_TYPE_BOOLEAN, &value);
+ dbus_message_iter_close_container(&iter, &dict);
+
+ return reply;
+}
+
+static void tt_set_powered(struct ofono_text_telephony *tt,
+ ofono_bool_t enable)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path = __ofono_atom_get_path(tt->atom);
+ dbus_bool_t value = enable;
+
+ if (tt->powered == enable)
+ return;
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_TEXT_TELEPHONY_INTERFACE,
+ "Powered",
+ DBUS_TYPE_BOOLEAN, &value);
+ tt->powered = enable;
+}
+
+static void tt_set_powered_callback(const struct ofono_error *error,
+ void *data)
+{
+ struct ofono_text_telephony *tt = data;
+ DBusMessage *reply;
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+ DBG("Error setting powered property");
+
+ tt->powered_pending = tt->powered;
+
+ reply = __ofono_error_failed(tt->pending);
+ __ofono_dbus_pending_reply(&tt->pending, reply);
+
+ return;
+ }
+
+ reply = dbus_message_new_method_return(tt->pending);
+ __ofono_dbus_pending_reply(&tt->pending, reply);
+
+ tt_set_powered(tt, tt->powered_pending);
+}
+
+static void tt_send_properties_reply(struct ofono_text_telephony *tt)
+{
+ DBusMessage *reply;
+
+ reply = tt_get_properties_reply(tt->pending, tt);
+ __ofono_dbus_pending_reply(&tt->pending, reply);
+}
+
+static void tt_query_powered_callback(const struct ofono_error *error,
+ ofono_bool_t enable, void *data)
+{
+ struct ofono_text_telephony *tt = data;
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+ DBusMessage *reply;
+
+ ofono_debug("Error during powered query");
+
+ reply = __ofono_error_failed(tt->pending);
+ __ofono_dbus_pending_reply(&tt->pending, reply);
+
+ return;
+ }
+
+ tt_set_powered(tt, enable);
+ tt_send_properties_reply(tt);
+}
+
+static DBusMessage *tt_get_properties(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_text_telephony *tt = data;
+
+ if (tt->pending)
+ return __ofono_error_busy(msg);
+
+ tt->pending = dbus_message_ref(msg);
+ tt->driver->query_tty(tt, tt_query_powered_callback, tt);
+
+ return NULL;
+}
+
+static DBusMessage *tt_set_property(DBusConnection *conn, DBusMessage *msg,
+ void *data)
+{
+ struct ofono_text_telephony *tt = data;
+ DBusMessageIter iter;
+ DBusMessageIter var;
+ const char *property;
+
+ if (tt->pending)
+ return __ofono_error_busy(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, &property);
+ 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 (g_strcmp0(property, "Powered") == 0) {
+ dbus_bool_t value;
+ int target;
+
+ if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BOOLEAN)
+ return __ofono_error_invalid_args(msg);
+
+ dbus_message_iter_get_basic(&var, &value);
+ target = value;
+
+ if (tt->powered == target)
+ return dbus_message_new_method_return(msg);
+
+ tt->pending = dbus_message_ref(msg);
+ tt->powered_pending = target;
+
+ tt->driver->set_tty(tt, target,
+ tt_set_powered_callback, tt);
+ return NULL;
+ }
+
+ return __ofono_error_invalid_args(msg);
+}
+
+static GDBusMethodTable tt_methods[] = {
+ { "GetProperties", "", "a{sv}", tt_get_properties,
+ G_DBUS_METHOD_FLAG_ASYNC },
+ { "SetProperty", "sv", "", tt_set_property,
+ G_DBUS_METHOD_FLAG_ASYNC },
+ { }
+};
+
+static GDBusSignalTable tt_signals[] = {
+ { "PropertyChanged", "sv" },
+ { }
+};
+
+int ofono_text_telephony_driver_register(const struct ofono_text_telephony_driver *d)
+{
+ DBG("driver: %p, name: %s", d, d->name);
+
+ if (!d || !d->probe)
+ return -EINVAL;
+
+ g_drivers = g_slist_prepend(g_drivers, (void *)d);
+
+ return 0;
+}
+
+void ofono_text_telephony_driver_unregister(const struct ofono_text_telephony_driver *d)
+{
+ DBG("driver: %p, name: %s", d, d->name);
+
+ if (!d)
+ return;
+
+ g_drivers = g_slist_remove(g_drivers, (void *)d);
+}
+
+static void text_telephony_unregister(struct ofono_atom *atom)
+{
+ struct ofono_text_telephony *tt = __ofono_atom_get_data(atom);
+ const char *path = __ofono_atom_get_path(tt->atom);
+ DBusConnection *conn = ofono_dbus_get_connection();
+ struct ofono_modem *modem = __ofono_atom_get_modem(tt->atom);
+
+ ofono_modem_remove_interface(modem, OFONO_TEXT_TELEPHONY_INTERFACE);
+ g_dbus_unregister_interface(conn, path, OFONO_TEXT_TELEPHONY_INTERFACE);
+}
+
+static void text_telephony_remove(struct ofono_atom *atom)
+{
+ struct ofono_text_telephony *tt = __ofono_atom_get_data(atom);
+
+ DBG("atom: %p", atom);
+
+ if (!tt)
+ return;
+
+ if (tt->driver && tt->driver->remove)
+ tt->driver->remove(tt);
+
+ g_free(tt);
+}
+
+struct ofono_text_telephony *ofono_text_telephony_create(struct ofono_modem *modem,
+ unsigned int vendor,
+ const char *driver,
+ void *data)
+{
+ struct ofono_text_telephony *tt;
+ GSList *l;
+ if (!driver)
+ return NULL;
+
+ tt = g_try_new0(struct ofono_text_telephony, 1);
+ if (!tt)
+ return NULL;
+
+ tt->atom = __ofono_modem_add_atom(modem, OFONO_ATOM_TYPE_TEXT_TELEPHONY,
+ text_telephony_remove, tt);
+
+ tt->powered = -1;
+
+ for (l = g_drivers; l; l = l->next) {
+ const struct ofono_text_telephony_driver *drv = l->data;
+
+ if (g_strcmp0(drv->name, driver) != 0)
+ continue;
+
+ if (drv->probe(tt, vendor, data) < 0)
+ continue;
+
+ tt->driver = drv;
+ break;
+ }
+
+ return tt;
+}
+
+void ofono_text_telephony_register(struct ofono_text_telephony *tt)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ struct ofono_modem *modem = __ofono_atom_get_modem(tt->atom);
+ const char *path = __ofono_atom_get_path(tt->atom);
+
+ if (!g_dbus_register_interface(conn, path,
+ OFONO_TEXT_TELEPHONY_INTERFACE,
+ tt_methods, tt_signals,
+ NULL, tt, NULL)) {
+ ofono_error("Could not create %s interface",
+ OFONO_TEXT_TELEPHONY_INTERFACE);
+
+ return;
+ }
+
+ ofono_modem_add_interface(modem, OFONO_TEXT_TELEPHONY_INTERFACE);
+ __ofono_atom_register(tt->atom, text_telephony_unregister);
+}
+
+void ofono_text_telephony_remove(struct ofono_text_telephony *tt)
+{
+ __ofono_atom_free(tt->atom);
+}
+
+void ofono_text_telephony_set_data(struct ofono_text_telephony *tt,
+ void *data)
+{
+ tt->driver_data = data;
+}
+
+void *ofono_text_telephony_get_data(struct ofono_text_telephony *tt)
+{
+ return tt->driver_data;
+}
--
1.7.3.2
11 years, 10 months
[PATCH 2/3] phonesim: implement TTY interface
by Lucas De Marchi
---
plugins/phonesim.c | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 144 insertions(+), 4 deletions(-)
diff --git a/plugins/phonesim.c b/plugins/phonesim.c
index d2faf42..8c31df4 100644
--- a/plugins/phonesim.c
+++ b/plugins/phonesim.c
@@ -54,6 +54,7 @@
#include <ofono/stk.h>
#include <ofono/sms.h>
#include <ofono/ssn.h>
+#include <ofono/text-telephony.h>
#include <ofono/ussd.h>
#include <ofono/voicecall.h>
#include <ofono/gprs.h>
@@ -64,6 +65,7 @@
#include <drivers/atmodem/atutil.h>
static const char *none_prefix[] = { NULL };
+static const char *ptty_prefix[] = { "+PTTY:", NULL };
static int next_iface = 0;
struct phonesim_data {
@@ -78,6 +80,11 @@ struct gprs_context_data {
char *interface;
};
+struct text_telephony_data {
+ GAtChat *chat;
+ char *interface;
+};
+
static void at_cgact_up_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct cb_data *cbd = user_data;
@@ -190,12 +197,140 @@ static void phonesim_context_remove(struct ofono_gprs_context *gc)
g_free(gcd);
}
+static int phonesim_tty_probe(struct ofono_text_telephony *tt,
+ unsigned int vendor, void *data)
+{
+ GAtChat *chat = data;
+ struct text_telephony_data *ttd;
+
+ ttd = g_try_new0(struct text_telephony_data, 1);
+ if (!ttd)
+ return -ENOMEM;
+
+ ttd->chat = g_at_chat_clone(chat);
+ ttd->interface = g_strdup_printf("dummy%d", next_iface++);
+
+ ofono_text_telephony_set_data(tt, ttd);
+ ofono_text_telephony_register(tt);
+
+ return 0;
+}
+
+static void phonesim_tty_remove(struct ofono_text_telephony *tt)
+{
+ struct text_telephony_data *ttd = ofono_text_telephony_get_data(tt);
+
+ DBG("");
+
+ ofono_text_telephony_set_data(tt, NULL);
+
+ g_at_chat_unref(ttd->chat);
+ g_free(ttd->interface);
+
+ g_free(ttd);
+}
+
+static void tty_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ struct ofono_error error;
+ GAtResultIter iter;
+ ofono_text_telephony_query_cb_t cb = cbd->cb;
+ int value;
+
+ decode_at_error(&error, g_at_result_final_response(result));
+
+ if (!ok) {
+ cb(&error, -1, cbd->data);
+ return;
+ }
+
+ g_at_result_iter_init(&iter, result);
+
+ if (g_at_result_iter_next(&iter, "+PTTY:") == FALSE)
+ goto error;
+
+ if (g_at_result_iter_next_number(&iter, &value) == FALSE)
+ goto error;
+
+ cb(&error, value, cbd->data);
+
+ return;
+
+error:
+
+ CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
+}
+
+static void phonesim_tty_query(struct ofono_text_telephony *tt,
+ ofono_text_telephony_query_cb_t cb, void *data)
+{
+ struct text_telephony_data *ttd = ofono_text_telephony_get_data(tt);
+ struct cb_data *cbd = cb_data_new(cb, data);
+
+ DBG("");
+
+ if (!cbd)
+ goto error;
+
+ if (g_at_chat_send(ttd->chat, "AT+PTTY?", ptty_prefix,
+ tty_query_cb, cbd, g_free) > 0)
+ return;
+
+error:
+ g_free(cbd);
+
+ CALLBACK_WITH_FAILURE(cb, 0, data);
+}
+
+static void tty_set_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_text_telephony_set_cb_t cb = cbd->cb;
+ struct ofono_error error;
+
+ decode_at_error(&error, g_at_result_final_response(result));
+ cb(&error, cbd->data);
+}
+
+static void phonesim_tty_set(struct ofono_text_telephony *tt, int enable,
+ ofono_text_telephony_set_cb_t cb, void *data)
+{
+ struct text_telephony_data *ttd = ofono_text_telephony_get_data(tt);
+ struct cb_data *cbd = cb_data_new(cb, data);
+ char buf[12];
+
+ DBG("");
+
+ if (!cbd)
+ goto error;
+
+ enable = !!enable;
+ snprintf(buf, sizeof(buf), "AT+PTTY=%d", enable);
+
+ if (g_at_chat_send(ttd->chat, buf, none_prefix,
+ tty_set_cb, cbd, g_free) > 0)
+ return;
+
+error:
+ CALLBACK_WITH_FAILURE(cb, data);
+ g_free(cbd);
+}
+
static struct ofono_gprs_context_driver context_driver = {
+ .name = "phonesim",
+ .probe = phonesim_context_probe,
+ .remove = phonesim_context_remove,
+ .activate_primary = phonesim_activate_primary,
+ .deactivate_primary = phonesim_deactivate_primary,
+};
+
+static struct ofono_text_telephony_driver tty_driver = {
.name = "phonesim",
- .probe = phonesim_context_probe,
- .remove = phonesim_context_remove,
- .activate_primary = phonesim_activate_primary,
- .deactivate_primary = phonesim_deactivate_primary,
+ .probe = phonesim_tty_probe,
+ .remove = phonesim_tty_remove,
+ .query_tty = phonesim_tty_query,
+ .set_tty = phonesim_tty_set,
};
static int phonesim_probe(struct ofono_modem *modem)
@@ -465,6 +600,7 @@ static void phonesim_post_sim(struct ofono_modem *modem)
DBG("%p", modem);
+ ofono_text_telephony_create(modem, 0, "phonesim", data->chat);
ofono_phonebook_create(modem, 0, "atmodem", data->chat);
if (!data->calypso)
@@ -630,6 +766,8 @@ static int phonesim_init(void)
ofono_gprs_context_driver_register(&context_driver);
+ ofono_text_telephony_driver_register(&tty_driver);
+
parse_config(CONFIGDIR "/phonesim.conf");
return 0;
@@ -648,6 +786,8 @@ static void phonesim_exit(void)
g_slist_free(modem_list);
modem_list = NULL;
+ ofono_text_telephony_driver_unregister(&tty_driver);
+
ofono_gprs_context_driver_unregister(&context_driver);
ofono_modem_driver_unregister(&phonesim_driver);
--
1.7.3.2
11 years, 10 months
[PATCH 1/3] Add ofono_modem_reset()
by Gustavo F. Padovan
Some modems can screw up everything and then we will need to do a silent
reset of the modem. This patch take the modem back to the OFFLINE state.
---
include/modem.h | 2 ++
src/modem.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 45 insertions(+), 1 deletions(-)
diff --git a/include/modem.h b/include/modem.h
index 7b13ee0..a92eb88 100644
--- a/include/modem.h
+++ b/include/modem.h
@@ -46,6 +46,8 @@ int ofono_modem_register(struct ofono_modem *modem);
ofono_bool_t ofono_modem_is_registered(struct ofono_modem *modem);
void ofono_modem_remove(struct ofono_modem *modem);
+void ofono_modem_reset(struct ofono_modem *modem);
+
void ofono_modem_set_powered(struct ofono_modem *modem, ofono_bool_t powered);
ofono_bool_t ofono_modem_get_powered(struct ofono_modem *modem);
diff --git a/src/modem.c b/src/modem.c
index 6d346c3..e57f8fc 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -70,6 +70,7 @@ struct ofono_modem {
guint interface_update;
ofono_bool_t powered;
ofono_bool_t powered_pending;
+ ofono_bool_t reset;
guint timeout;
ofono_bool_t online;
GHashTable *properties;
@@ -433,6 +434,8 @@ static void sim_state_watch(enum ofono_sim_state new_state, void *user)
if (modem->driver->set_online == NULL)
modem_change_state(modem, MODEM_STATE_ONLINE);
+ modem->reset = FALSE;
+
break;
}
}
@@ -784,7 +787,8 @@ void ofono_modem_set_powered(struct ofono_modem *modem, ofono_bool_t powered)
return;
}
- ofono_dbus_signal_property_changed(conn, modem->path,
+ if (!modem->reset)
+ ofono_dbus_signal_property_changed(conn, modem->path,
OFONO_MODEM_INTERFACE,
"Powered", DBUS_TYPE_BOOLEAN,
&dbus_powered);
@@ -799,6 +803,17 @@ void ofono_modem_set_powered(struct ofono_modem *modem, ofono_bool_t powered)
} else
modem_change_state(modem, MODEM_STATE_POWER_OFF);
+ if (modem->reset && !powering_down) {
+ if (!modem->powered) {
+ int err = set_powered(modem, TRUE);
+
+ if (err == -EINPROGRESS)
+ return;
+
+ modem_change_state(modem, MODEM_STATE_PRE_SIM);
+ }
+ }
+
out:
if (powering_down && powered == FALSE) {
modems_remaining -= 1;
@@ -806,6 +821,7 @@ out:
if (modems_remaining == 0)
__ofono_exit();
}
+
}
ofono_bool_t ofono_modem_get_powered(struct ofono_modem *modem)
@@ -1565,6 +1581,32 @@ void ofono_modem_remove(struct ofono_modem *modem)
g_free(modem);
}
+static gboolean __reset_modem(void *data)
+{
+ struct ofono_modem *modem = data;
+ int err;
+
+ modem->reset = TRUE;
+
+ err = set_powered(modem, FALSE);
+ if (err == -EINPROGRESS)
+ return FALSE;
+
+ err = set_powered(modem, TRUE);
+ if (err == -EINPROGRESS)
+ return FALSE;
+
+ modem_change_state(modem, MODEM_STATE_PRE_SIM);
+ return FALSE;
+}
+
+void ofono_modem_reset(struct ofono_modem *modem)
+{
+ DBG("%p", modem);
+
+ g_idle_add(__reset_modem, modem);
+}
+
int ofono_modem_driver_register(const struct ofono_modem_driver *d)
{
DBG("driver: %p, name: %s", d, d->name);
--
1.7.3.1
11 years, 10 months
[RFC] plugin/ste: Use D-Bus API from Modem Init Daemon for autoconfig.
by Sjur Brændeland
From: Sjur Brændeland <sjur.brandeland(a)stericsson.com>
This patch introduces auto discovery of ST-Ericsson modems.
ST-Ericsson modems are managed by a Modem Init Daemon which
is responsible for start/stop/restart flashing etc. The
STE plugin monitors the modem state exposed from the
Modem Init Damon Dbus API. When the modem is in state "on"
the STE modem is created and registered.
The reason for not using the standard udev paradigm is that
the CAIF device is up before the modem is ready to setup AT channels.
For flashless modems CAIF is used as part of the boot. The Modem Init
Daemon is managing the flashless boot procedure and sets the State to
"on" when the modem is available.
---
plugins/ste.c | 146 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 145 insertions(+), 1 deletions(-)
diff --git a/plugins/ste.c b/plugins/ste.c
index 508ad58..3e6b895 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -32,6 +32,7 @@
#include <unistd.h>
#include <net/if.h>
+#include <gdbus.h>
#include <glib.h>
#include <gatchat.h>
@@ -73,6 +74,144 @@ struct ste_data {
gboolean have_sim;
};
+/*
+ * ST-Ericsson's modem init daemon defines the signal StateChange
+ * and the method GetState. When state is "on" the STE modem is
+ * created and registered.
+ */
+#define STATUS_CHANGED "StateChange"
+#define MID_SERVICE "com.stericsson.mid"
+#define MID_INTERFACE MID_SERVICE ".Modem"
+#define GET_STATE "GetState"
+#define MID_STATE_ON "on"
+#define MID_STATE_DISCONNECT "disconnect"
+#define TIMEOUT 5000
+
+static struct ofono_modem *ste_modem;
+static guint mid_api_watch;
+static guint mid_state_watch;
+
+static void handle_stemodem(const char *state)
+{
+
+ if (strcmp(state, MID_STATE_ON) == 0) {
+ int err;
+
+ if (ste_modem != NULL)
+ return;
+
+ ste_modem = ofono_modem_create("ste", "ste");
+ DBG("register STE modem");
+ err = ofono_modem_register(ste_modem);
+ } else {
+ if (ste_modem == NULL)
+ return;
+ ofono_modem_remove(ste_modem);
+ ste_modem = NULL;
+ }
+}
+
+static void mid_getstate_reply(DBusPendingCall *call, void *user_data)
+{
+ DBusMessage *reply;
+ char *state;
+
+ reply = dbus_pending_call_steal_reply(call);
+
+ if (dbus_message_is_error(reply, DBUS_ERROR_SERVICE_UNKNOWN)) {
+ ofono_error("STE Modem Init Daemon is unavailable");
+ goto error;
+ }
+
+ if (dbus_message_get_args(reply, NULL, DBUS_TYPE_STRING, &state,
+ DBUS_TYPE_INVALID) == FALSE) {
+ ofono_error("STE Modem Init Damon: bad signature for GetState");
+ goto error;
+ }
+
+ handle_stemodem(state);
+error:
+ dbus_message_unref(reply);
+}
+
+static gboolean mid_signal_status_change(DBusConnection *connection,
+ DBusMessage *message, void *user_data)
+{
+ const char *state = NULL;
+
+ if (dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &state,
+ DBUS_TYPE_INVALID) == FALSE) {
+ ofono_error("STE Modem Init Daemon: invalid signal signature");
+ return FALSE;
+ }
+
+ handle_stemodem(state);
+ return TRUE;
+}
+
+static void mid_connect(DBusConnection *connection, void *user_data)
+{
+ DBusMessage *message;
+ DBusPendingCall *call;
+
+ message = dbus_message_new_method_call(MID_SERVICE, "/",
+ MID_INTERFACE, "GetState");
+ if (!message) {
+ ofono_error("Unable to allocate new D-Bus message");
+ goto error;
+ }
+
+ dbus_message_set_auto_start(message, FALSE);
+
+ if (dbus_connection_send_with_reply(connection, message,
+ &call, TIMEOUT) == FALSE) {
+ ofono_error("Sending D-Bus message failed");
+ goto error;
+ }
+
+ if (call == NULL) {
+ DBG("D-Bus connection not available");
+ goto error;
+ }
+
+ dbus_pending_call_set_notify(call, mid_getstate_reply, NULL, NULL);
+ dbus_pending_call_unref(call);
+error:
+ dbus_message_unref(message);
+}
+
+static void mid_disconnect(DBusConnection *connection, void *user_data)
+{
+ handle_stemodem(MID_STATE_DISCONNECT);
+}
+
+static int modem_initd_setup()
+{
+ DBusConnection *connection;
+
+ connection = ofono_dbus_get_connection();
+ if (connection == NULL)
+ return -EIO;
+
+ mid_api_watch = g_dbus_add_service_watch(connection, MID_SERVICE,
+ mid_connect, mid_disconnect, NULL, NULL);
+
+ mid_state_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
+ MID_INTERFACE,
+ STATUS_CHANGED,
+ mid_signal_status_change,
+ NULL, NULL);
+
+ return 0;
+}
+
+static void modem_initd_teardown()
+{
+ DBusConnection *connection = ofono_dbus_get_connection();
+ g_dbus_remove_watch(connection, mid_state_watch);
+ g_dbus_remove_watch(connection, mid_api_watch);
+}
+
static int ste_probe(struct ofono_modem *modem)
{
struct ste_data *data;
@@ -382,12 +521,17 @@ static struct ofono_modem_driver ste_driver = {
static int ste_init(void)
{
- return ofono_modem_driver_register(&ste_driver);
+ int err;
+ err = ofono_modem_driver_register(&ste_driver);
+ if (err < 0)
+ return err;
+ return modem_initd_setup();
}
static void ste_exit(void)
{
ofono_modem_driver_unregister(&ste_driver);
+ modem_initd_teardown();
}
OFONO_PLUGIN_DEFINE(ste, "ST-Ericsson modem driver", VERSION,
--
1.6.3.3
11 years, 10 months
[PATCH] util: Remove extra tab
by Jeevaka Badrappan
---
src/util.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/util.c b/src/util.c
index 94b2fca..511683a 100644
--- a/src/util.c
+++ b/src/util.c
@@ -956,7 +956,7 @@ unsigned char *unpack_7bit_own_buf(const unsigned char *in, long len,
* character.
*/
if (ussd && (((out - buf) % 8) == 0) && (*(out - 1) == '\r'))
- out = out - 1;
+ out = out - 1;
if (terminator)
*out = terminator;
--
1.7.0.4
11 years, 10 months
[PATCH 1/4] Simplify ofono_modem_set_powered() logic
by Gustavo F. Padovan
---
src/modem.c | 47 +++++++++++++++++++++++++----------------------
1 files changed, 25 insertions(+), 22 deletions(-)
diff --git a/src/modem.c b/src/modem.c
index 3776461..3fb6809 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -752,6 +752,7 @@ static GDBusSignalTable modem_signals[] = {
void ofono_modem_set_powered(struct ofono_modem *modem, ofono_bool_t powered)
{
DBusConnection *conn = ofono_dbus_get_connection();
+ dbus_bool_t dbus_powered = powered;
if (modem->timeout > 0) {
g_source_remove(modem->timeout);
@@ -771,32 +772,34 @@ void ofono_modem_set_powered(struct ofono_modem *modem, ofono_bool_t powered)
modem->powered_pending = powered;
- if (modem->powered != powered) {
- dbus_bool_t dbus_powered = powered;
- modem->powered = powered;
+ if (modem->powered == powered)
+ goto out;
- if (modem->driver == NULL) {
- ofono_error("Calling ofono_modem_set_powered on a"
- "modem with no driver is not valid, "
- "please fix the modem driver.");
- return;
- }
+ modem->powered = powered;
- ofono_dbus_signal_property_changed(conn, modem->path,
- OFONO_MODEM_INTERFACE,
- "Powered", DBUS_TYPE_BOOLEAN,
- &dbus_powered);
+ if (modem->driver == NULL) {
+ ofono_error("Calling ofono_modem_set_powered on a"
+ "modem with no driver is not valid, "
+ "please fix the modem driver.");
+ return;
+ }
- if (powered) {
- modem_change_state(modem, MODEM_STATE_PRE_SIM);
+ ofono_dbus_signal_property_changed(conn, modem->path,
+ OFONO_MODEM_INTERFACE,
+ "Powered", DBUS_TYPE_BOOLEAN,
+ &dbus_powered);
- /* Force SIM Ready for devies with no sim atom */
- if (__ofono_modem_find_atom(modem,
- OFONO_ATOM_TYPE_SIM) == NULL)
- sim_state_watch(OFONO_SIM_STATE_READY, modem);
- } else
- modem_change_state(modem, MODEM_STATE_POWER_OFF);
- }
+ if (powered) {
+ modem_change_state(modem, MODEM_STATE_PRE_SIM);
+
+ /* Force SIM Ready for devies with no sim atom */
+ if (__ofono_modem_find_atom(modem,
+ OFONO_ATOM_TYPE_SIM) == NULL)
+ sim_state_watch(OFONO_SIM_STATE_READY, modem);
+ } else
+ modem_change_state(modem, MODEM_STATE_POWER_OFF);
+
+out:
if (powering_down && powered == FALSE) {
modems_remaining -= 1;
--
1.7.3.1
11 years, 10 months