[PATCHv3 1/3] hfpmodem: Retry AT+CLCC request after outgoing callsetup
by Timo Mueller
From: Timo Mueller <timo.mueller(a)bmw-carit.de>
Currently the list of current calls is requested right after an
outgoing callsetup has been reported by the AG device. If the AG
device updates the list after reporting the callsetup the +CLCC
response may not contain the new call and it is not registered
with oFono.
In this case AT+CLCC should be requested again once after a small
delay.
AT sequence that exhibited the failure (AG device was a Nokia N9
placing an outgoing call)
< \r\n+CIEV: 5,2\r\n
> AT+CLCC\r
< \r\nOK\r\n
< \r\n+VGS=7\r\n
< \r\n+VGM=7\r\n
< \r\n+CIEV: 5,3\r\n
< \r\n+CIEV: 4,1\r\n
< \r\n+CIEV: 5,0\r\n
---
v3: Splitted clcc_poll_cb to avoid parsing of the clcc result twice
when a dialing call was found in the response.
drivers/hfpmodem/voicecall.c | 45 +++++++++++++++++++++++++++++++++++++++-----
1 file changed, 40 insertions(+), 5 deletions(-)
diff --git a/drivers/hfpmodem/voicecall.c b/drivers/hfpmodem/voicecall.c
index 33dd05e..9b05dbc 100644
--- a/drivers/hfpmodem/voicecall.c
+++ b/drivers/hfpmodem/voicecall.c
@@ -203,11 +203,10 @@ static void release_with_status(struct ofono_voicecall *vc, int status)
}
}
-static void clcc_poll_cb(gboolean ok, GAtResult *result, gpointer user_data)
+static void handle_clcc_response(gboolean ok, GSList *calls, gpointer user_data)
{
struct ofono_voicecall *vc = user_data;
struct voicecall_data *vd = ofono_voicecall_get_data(vc);
- GSList *calls;
GSList *n, *o;
struct ofono_call *nc, *oc;
unsigned int num_active = 0;
@@ -217,8 +216,6 @@ static void clcc_poll_cb(gboolean ok, GAtResult *result, gpointer user_data)
if (!ok)
return;
- calls = at_util_parse_clcc(result);
-
n = calls;
o = vd->calls;
@@ -295,6 +292,43 @@ static void clcc_poll_cb(gboolean ok, GAtResult *result, gpointer user_data)
vc);
}
+static void clcc_poll_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ GSList *calls;
+
+ if (!ok)
+ return;
+
+ calls = at_util_parse_clcc(result);
+
+ handle_clcc_response(ok, calls, user_data);
+}
+
+static void clcc_poll_dialing_cb(gboolean ok, GAtResult *result,
+ gpointer user_data)
+{
+ struct ofono_voicecall *vc = user_data;
+ struct voicecall_data *vd = ofono_voicecall_get_data(vc);
+ GSList *calls, *dialing;
+
+ if (!ok)
+ return;
+
+ calls = at_util_parse_clcc(result);
+ dialing = find_dialing(calls);
+
+ if (dialing == NULL) {
+ if (vd->clcc_source)
+ g_source_remove(vd->clcc_source);
+
+ vd->clcc_source = g_timeout_add(POLL_CLCC_DELAY,
+ poll_clcc, vc);
+ return;
+ }
+
+ handle_clcc_response(ok, calls, user_data);
+}
+
static gboolean poll_clcc(gpointer user_data)
{
struct ofono_voicecall *vc = user_data;
@@ -977,7 +1011,8 @@ static void ciev_callsetup_notify(struct ofono_voicecall *vc,
* from AG: query and create call.
*/
g_at_chat_send(vd->chat, "AT+CLCC", clcc_prefix,
- clcc_poll_cb, vc, NULL);
+ clcc_poll_dialing_cb, vc, NULL);
+
break;
case 3:
--
1.7.11.7
8 years
[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)
8 years, 1 month
[PATCH 0/8] Sierra Wireless CDMA modem support
by Forest Bond
From: Forest Bond <forest.bond(a)rapidrollout.com>
This series adds support for Sierra Wireless CDMA modems. Tested with
the MC5728V on the Sprint CDMA network.
Forest Bond (8):
sierramodem: Add skeleton for Sierra Wireless modem driver
sierramodem: Add skeleton cdma netreg driver
sierramodem: Add ERI parsing functions
sierramodem: Report network registration status
sierra: Create GPRS context in post_sim function
sierra: Initialize GSM error reporting separately
sierra: Support CDMA modems
udevng: Support single-interface sierra devices
Makefile.am | 8 +
drivers/sierramodem/cdma-netreg.c | 385 +++++++++++++++++++++++++++++++++++++
drivers/sierramodem/eri.c | 282 +++++++++++++++++++++++++++
drivers/sierramodem/eri.h | 23 +++
drivers/sierramodem/sierramodem.c | 50 +++++
drivers/sierramodem/sierramodem.h | 26 +++
plugins/sierra.c | 117 +++++++++---
plugins/udevng.c | 43 ++++-
8 files changed, 900 insertions(+), 34 deletions(-)
create mode 100644 drivers/sierramodem/cdma-netreg.c
create mode 100644 drivers/sierramodem/eri.c
create mode 100644 drivers/sierramodem/eri.h
create mode 100644 drivers/sierramodem/sierramodem.c
create mode 100644 drivers/sierramodem/sierramodem.h
--
Forest Bond
http://www.alittletooquiet.net
http://www.rapidrollout.com
8 years, 1 month
[PATCH v0 00/10] handsfree-audio: Add Agent NewConnection()
by Claudio Takahasi
This patch series moves the SCO connection handling from hfp_hf_bluez5.c
to src/handsfree-audio.c, and adds the Agent NewConnection() method call
to pass the SCO file descriptor from oFono to the Agent implementation.
Claudio Takahasi (10):
bluetooth: Add new Bluetooth header
handsfree-audio: Move SCO to handsfree-audio.c
handsfree-audio: Remove modem dependency
handsfree-audio: Add NewConnection
handsfree-audio: Check local SCO address
handsfree-audio: Reject SCO if Card is not ready
handsfree-audio: Reject SCO if agent is unavailable
handsfree-audio: Check CVSD when registering agent
handsfree-audio: Add function to get hfp version
hfp_hf_bluez5: Fix hard-coded hfp version
Makefile.am | 2 +-
include/handsfree-audio.h | 1 +
plugins/bluez5.c | 17 -----
plugins/bluez5.h | 41 ------------
plugins/hfp_hf_bluez5.c | 105 +-----------------------------
src/bluetooth.h | 71 ++++++++++++++++++++
src/handsfree-audio.c | 162 +++++++++++++++++++++++++++++++++++++++++++++-
7 files changed, 235 insertions(+), 164 deletions(-)
create mode 100644 src/bluetooth.h
--
1.7.11.7
8 years, 1 month
[PATCH 1/3] bluez5: Add role parameter to bt_register_profile
by Paulo Borges
This commit allows asymmetric profiles that do not have UUIDs
available to uniquely identify which role is been registered.
---
plugins/bluez5.c | 5 ++++-
plugins/bluez5.h | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/plugins/bluez5.c b/plugins/bluez5.c
index 788f3a2..04dd39d 100644
--- a/plugins/bluez5.c
+++ b/plugins/bluez5.c
@@ -110,7 +110,7 @@ done:
int bt_register_profile(DBusConnection *conn, const char *uuid,
uint16_t version, const char *name,
- const char *object)
+ const char *object, const char* role)
{
DBusMessageIter iter, dict;
DBusPendingCall *c;
@@ -129,6 +129,9 @@ int bt_register_profile(DBusConnection *conn, const char *uuid,
ofono_dbus_dict_append(&dict, "Name", DBUS_TYPE_STRING, &name);
ofono_dbus_dict_append(&dict, "Version", DBUS_TYPE_UINT16, &version);
+ if (role)
+ ofono_dbus_dict_append(&dict, "Role", DBUS_TYPE_STRING, &role);
+
dbus_message_iter_close_container(&iter, &dict);
if (!dbus_connection_send_with_reply(conn, msg, &c, -1)) {
diff --git a/plugins/bluez5.h b/plugins/bluez5.h
index 1432068..17e925f 100644
--- a/plugins/bluez5.h
+++ b/plugins/bluez5.h
@@ -71,7 +71,7 @@ int bt_bacmp(const bdaddr_t *ba1, const bdaddr_t *ba2);
int bt_register_profile(DBusConnection *conn, const char *uuid,
uint16_t version, const char *name,
- const char *object);
+ const char *object, const char *role);
void bt_unregister_profile(DBusConnection *conn, const char *object);
--
1.7.9.5
8 years, 1 month
[PATCH] bluez5: Move ref / unref handsfree audio
by Paulo Borges
This commit moves the ref / unref to hfp_hf_bluez5 to make
bluez5 more generic and reusable.
---
plugins/bluez5.c | 15 +--------------
plugins/hfp_hf_bluez5.c | 5 +++++
2 files changed, 6 insertions(+), 14 deletions(-)
diff --git a/plugins/bluez5.c b/plugins/bluez5.c
index 788f3a2..9233a2b 100644
--- a/plugins/bluez5.c
+++ b/plugins/bluez5.c
@@ -35,7 +35,6 @@
#include <ofono/dbus.h>
#include <ofono/plugin.h>
#include <ofono/log.h>
-#include <ofono/handsfree-audio.h>
#include <gdbus/gdbus.h>
#include "bluez5.h"
@@ -257,17 +256,5 @@ void bt_disconnect_profile(DBusConnection *conn,
cb, user_data);
}
-static int bluez5_init(void)
-{
- ofono_handsfree_audio_ref();
-
- return 0;
-}
-
-static void bluez5_exit(void)
-{
- ofono_handsfree_audio_unref();
-}
-
OFONO_PLUGIN_DEFINE(bluez5, "BlueZ 5 Utils Plugin", VERSION,
- OFONO_PLUGIN_PRIORITY_DEFAULT, bluez5_init, bluez5_exit)
+ OFONO_PLUGIN_PRIORITY_DEFAULT, NULL, NULL)
diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index 7057d71..ad52027 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -47,6 +47,7 @@
#include <ofono/voicecall.h>
#include <ofono/call-volume.h>
#include <ofono/handsfree.h>
+#include <ofono/handsfree-audio.h>
#include <drivers/hfpmodem/slc.h>
@@ -683,6 +684,8 @@ static int hfp_init(void)
g_dbus_client_set_proxy_handlers(bluez, proxy_added, NULL,
property_changed, NULL);
+ ofono_handsfree_audio_ref();
+
return 0;
}
@@ -698,6 +701,8 @@ static void hfp_exit(void)
if (sco_watch > 0)
g_source_remove(sco_watch);
+
+ ofono_handsfree_audio_unref();
}
OFONO_PLUGIN_DEFINE(hfp_bluez5, "External Hands-Free Profile Plugin", VERSION,
--
1.7.9.5
8 years, 1 month
[PATCH] Add GPRS, mux, volume control support in SIMCOM sim900 modem module
by r.r.zaripov@gmail.com
From: Renat Zaripov <r.r.zaripov(a)gmail.com>
---
plugins/sim900.c | 162 +++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 137 insertions(+), 25 deletions(-)
diff --git a/plugins/sim900.c b/plugins/sim900.c
index 496faa6..f228c0e 100644
--- a/plugins/sim900.c
+++ b/plugins/sim900.c
@@ -29,6 +29,7 @@
#include <glib.h>
#include <gatchat.h>
#include <gattty.h>
+#include <gatmux.h>
#define OFONO_API_SUBJECT_TO_CHANGE
#include <ofono/plugin.h>
@@ -44,13 +45,28 @@
#include <ofono/history.h>
#include <ofono/log.h>
#include <ofono/voicecall.h>
+#include <ofono/call-volume.h>
#include <drivers/atmodem/vendor.h>
+#define NUM_DLC 5
+
+#define SETUP_DLC 0
+#define VOICE_DLC 1
+#define NETREG_DLC 2
+#define SMS_DLC 3
+#define GPRS_DLC 4
+
+
+static char *dlc_prefixes[NUM_DLC] = { "Voice: ", "Net: ", "SMS: ", "GPRS: " , "Setup: "};
+
static const char *none_prefix[] = { NULL };
struct sim900_data {
- GAtChat *modem;
+ GIOChannel *device;
+ GAtMux *mux;
+ GAtChat *dlcs[NUM_DLC];
+ guint frame_size;
};
static int sim900_probe(struct ofono_modem *modem)
@@ -76,7 +92,7 @@ static void sim900_remove(struct ofono_modem *modem)
ofono_modem_set_data(modem, NULL);
- g_at_chat_unref(data->modem);
+ g_at_chat_unref(data->dlcs[SETUP_DLC]);
g_free(data);
}
@@ -91,6 +107,7 @@ static void sim900_debug(const char *str, void *user_data)
static GAtChat *open_device(struct ofono_modem *modem,
const char *key, char *debug)
{
+ struct sim900_data *data = ofono_modem_get_data(modem);
const char *device;
GAtSyntax *syntax;
GIOChannel *channel;
@@ -119,10 +136,33 @@ static GAtChat *open_device(struct ofono_modem *modem,
if (channel == NULL)
return NULL;
+ data->device = channel;
syntax = g_at_syntax_new_gsm_permissive();
chat = g_at_chat_new(channel, syntax);
g_at_syntax_unref(syntax);
+ if (chat == NULL)
+ return NULL;
+
+ if (getenv("OFONO_AT_DEBUG"))
+ g_at_chat_set_debug(chat, sim900_debug, debug);
+
+ return chat;
+}
+
+
+static GAtChat *create_chat(GIOChannel *channel, struct ofono_modem *modem,
+ char *debug)
+{
+ GAtSyntax *syntax;
+ GAtChat *chat;
+
+ if (channel == NULL)
+ return NULL;
+
+ syntax = g_at_syntax_new_gsmv1();
+ chat = g_at_chat_new(channel, syntax);
+ g_at_syntax_unref(syntax);
g_io_channel_unref(channel);
if (chat == NULL)
@@ -134,6 +174,65 @@ static GAtChat *open_device(struct ofono_modem *modem,
return chat;
}
+static void setup_internal_mux(struct ofono_modem *modem)
+{
+ struct sim900_data *data = ofono_modem_get_data(modem);
+ int i;
+
+ DBG("");
+
+ data->frame_size = 128;
+
+ data->mux = g_at_mux_new_gsm0710_basic(data->device, data->frame_size);
+ if (data->mux == NULL)
+ goto error;
+
+ if (getenv("OFONO_MUX_DEBUG"))
+ g_at_mux_set_debug(data->mux, sim900_debug, "MUX: ");
+
+ if(!g_at_mux_start(data->mux))
+ goto error;
+
+ for (i = 0; i < NUM_DLC; i++) {
+ GIOChannel *channel = g_at_mux_create_channel(data->mux);
+
+ data->dlcs[i] = create_chat(channel, modem, dlc_prefixes[i]);
+ if (data->dlcs[i] == NULL) {
+ ofono_error("Failed to create channel");
+ goto error;
+ }
+ }
+
+ ofono_modem_set_powered(modem, TRUE);
+
+ return;
+
+error:
+ ofono_modem_set_powered(modem, FALSE);
+}
+
+static void mux_setup_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct sim900_data *data = ofono_modem_get_data(modem);
+
+ DBG("");
+
+ g_at_chat_unref(data->dlcs[SETUP_DLC]);
+ data->dlcs[SETUP_DLC] = NULL;
+
+ if (!ok)
+ goto error;
+
+ setup_internal_mux(modem);
+
+ return;
+
+error:
+ ofono_modem_set_powered(modem, FALSE);
+}
+
+
static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
{
struct ofono_modem *modem = user_data;
@@ -142,11 +241,9 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
DBG("");
if (!ok) {
- g_at_chat_unref(data->modem);
- data->modem = NULL;
+ g_at_chat_unref(data->dlcs[SETUP_DLC]);
+ data->dlcs[SETUP_DLC] = NULL;
}
-
- ofono_modem_set_powered(modem, ok);
}
static int sim900_enable(struct ofono_modem *modem)
@@ -155,21 +252,22 @@ static int sim900_enable(struct ofono_modem *modem)
DBG("%p", modem);
- data->modem = open_device(modem, "Device", "Device: ");
- if (data->modem == NULL) {
- DBG("return -EINVAL");
+ data->dlcs[SETUP_DLC] = open_device(modem, "Device", "Setup: ");
+ if (data->dlcs[SETUP_DLC] == NULL)
return -EINVAL;
- }
- g_at_chat_send(data->modem, "ATE0", NULL, NULL, NULL, NULL);
+ g_at_chat_send(data->dlcs[SETUP_DLC], "ATE0", NULL, NULL, NULL, NULL);
/* For obtain correct sms service number */
- g_at_chat_send(data->modem, "AT+CSCS=\"GSM\"", NULL,
+ g_at_chat_send(data->dlcs[SETUP_DLC], "AT+CSCS=\"GSM\"", NULL,
NULL, NULL, NULL);
- g_at_chat_send(data->modem, "AT+CFUN=1", none_prefix,
+ g_at_chat_send(data->dlcs[SETUP_DLC], "AT+CFUN=1", none_prefix,
cfun_enable, modem, NULL);
+ g_at_chat_send(data->dlcs[SETUP_DLC], "AT+CMUX=0,0,5,128,10,3,30,10,2",
+ NULL, mux_setup_cb, modem, NULL);
+
return -EINPROGRESS;
}
@@ -181,8 +279,8 @@ static void cfun_disable(gboolean ok, GAtResult *result, gpointer user_data)
DBG("");
- g_at_chat_unref(data->modem);
- data->modem = NULL;
+ g_at_chat_unref(data->dlcs[SETUP_DLC]);
+ data->dlcs[SETUP_DLC] = NULL;
if (ok)
ofono_modem_set_powered(modem, FALSE);
@@ -194,10 +292,10 @@ static int sim900_disable(struct ofono_modem *modem)
DBG("%p", modem);
- g_at_chat_cancel_all(data->modem);
- g_at_chat_unregister_all(data->modem);
+ g_at_chat_cancel_all(data->dlcs[SETUP_DLC]);
+ g_at_chat_unregister_all(data->dlcs[SETUP_DLC]);
- g_at_chat_send(data->modem, "AT+CFUN=4", none_prefix,
+ g_at_chat_send(data->dlcs[SETUP_DLC], "AT+CFUN=4", none_prefix,
cfun_disable, modem, NULL);
return -EINPROGRESS;
@@ -210,9 +308,9 @@ static void sim900_pre_sim(struct ofono_modem *modem)
DBG("%p", modem);
- ofono_devinfo_create(modem, 0, "atmodem", data->modem);
+ ofono_devinfo_create(modem, 0, "atmodem", data->dlcs[VOICE_DLC]);
sim = ofono_sim_create(modem, OFONO_VENDOR_SIMCOM, "atmodem",
- data->modem);
+ data->dlcs[VOICE_DLC]);
if (sim)
ofono_sim_inserted_notify(sim, TRUE);
@@ -221,12 +319,25 @@ static void sim900_pre_sim(struct ofono_modem *modem)
static void sim900_post_sim(struct ofono_modem *modem)
{
struct sim900_data *data = ofono_modem_get_data(modem);
+ struct ofono_gprs *gprs;
+ struct ofono_gprs_context *gc;
DBG("%p", modem);
- ofono_phonebook_create(modem, 0, "atmodem", data->modem);
+ ofono_phonebook_create(modem, 0, "atmodem", data->dlcs[VOICE_DLC]);
ofono_sms_create(modem, OFONO_VENDOR_SIMCOM, "atmodem",
- data->modem);
+ data->dlcs[SMS_DLC]);
+
+ gprs = ofono_gprs_create(modem, 0,
+ "atmodem", data->dlcs[GPRS_DLC]);
+ if (gprs == NULL)
+ return;
+
+ gc = ofono_gprs_context_create(modem, OFONO_VENDOR_SIMCOM,
+ "atmodem", data->dlcs[GPRS_DLC]);
+ if (gc)
+ ofono_gprs_add_context(gprs, gc);
+
}
static void sim900_post_online(struct ofono_modem *modem)
@@ -235,9 +346,10 @@ static void sim900_post_online(struct ofono_modem *modem)
DBG("%p", modem);
- ofono_netreg_create(modem, OFONO_VENDOR_SIMCOM, "atmodem", data->modem);
- ofono_ussd_create(modem, 0, "atmodem", data->modem);
- ofono_voicecall_create(modem, 0, "atmodem", data->modem);
+ ofono_netreg_create(modem, OFONO_VENDOR_SIMCOM, "atmodem", data->dlcs[VOICE_DLC]);
+ ofono_ussd_create(modem, 0, "atmodem", data->dlcs[VOICE_DLC]);
+ ofono_voicecall_create(modem, 0, "atmodem", data->dlcs[VOICE_DLC]);
+ ofono_call_volume_create(modem, 0, "atmodem", data->dlcs[VOICE_DLC]);
}
static struct ofono_modem_driver sim900_driver = {
--
1.7.10.4
8 years, 1 month
[PATCH v0 0/7] hfp_hf_bluez5: Register Audio Cards in handsfree manager
by Claudio Takahasi
This patch series contains the changes in the hfp_hf_bluez5 plugin to
create/register/remove audio cards.
Claudio Takahasi (7):
handsfree-audio: Switch argument order when creating card
hfp_hf_bluez5: Add registering Audio Card
hfp_hf_bluez5: Add local Bluetooth address to Audio Card
hfp_hf_bluez5: Remove Audio Card when SLC fails
hfp_hf_bluez5: Remove Audio Card when SLC is disconnected
hfp_hf_bluez5: Remove Audio Card when modem is disabled
hfp_hf_bluez5: Remove Audio Card when disconnection is requested
include/handsfree-audio.h | 4 ++--
plugins/hfp_hf_bluez5.c | 42 ++++++++++++++++++++++++++++++++++++++++++
src/handsfree-audio.c | 4 ++--
3 files changed, 46 insertions(+), 4 deletions(-)
--
1.7.11.7
8 years, 1 month
[PATCH v3 1/6] hfp_hf_bluez5: Add registering Audio Card
by Claudio Takahasi
This patch registers the Handsfree Audio Card when the service level
connection is established.
---
plugins/hfp_hf_bluez5.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index 7057d71..87d7e91 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -46,6 +46,7 @@
#include <ofono/netreg.h>
#include <ofono/voicecall.h>
#include <ofono/call-volume.h>
+#include <ofono/handsfree-audio.h>
#include <ofono/handsfree.h>
#include <drivers/hfpmodem/slc.h>
@@ -61,6 +62,7 @@
struct hfp {
struct hfp_slc_info info;
DBusMessage *msg;
+ struct ofono_handsfree_card *card;
};
static GDBusClient *bluez = NULL;
@@ -88,6 +90,8 @@ static void slc_established(gpointer userdata)
hfp->msg = NULL;
ofono_info("Service level connection established");
+
+ ofono_handsfree_card_register(hfp->card);
}
static void slc_failed(gpointer userdata)
@@ -315,8 +319,11 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
{
struct hfp *hfp;
struct ofono_modem *modem;
+ struct sockaddr_rc saddr;
+ socklen_t optlen;
DBusMessageIter entry;
const char *device;
+ char remote[18];
int fd, err;
DBG("Profile handler NewConnection");
@@ -353,8 +360,22 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
"Not enough resources");
}
+ memset(&saddr, 0, sizeof(saddr));
+ optlen = sizeof(saddr);
+
+ if (getpeername(fd, (struct sockaddr *) &saddr, &optlen) < 0) {
+ err = errno;
+ ofono_error("RFCOMM getpeername(): %s (%d)", strerror(err),
+ err);
+ close(fd);
+ goto invalid;
+ }
+
+ bt_ba2str(&saddr.rc_bdaddr, remote);
+
hfp = ofono_modem_get_data(modem);
hfp->msg = dbus_message_ref(msg);
+ hfp->card = ofono_handsfree_card_create(remote, NULL);
return NULL;
--
1.7.11.7
8 years, 1 month
[PATCH v0 0/8] handsfree-audio: Audio Card registration
by Claudio Takahasi
This patch series adds the initial Handsfree Audio Card hierarchy
implementation.
Open issues:
* Define Audio Card object path: it is using modem path in this series
Not implemented in this series:
* SCO audio connection
* LocalAddress property
Claudio Takahasi (8):
handsfree-audio: Add atom modem tracking
handsfree-audio: Add Audio Card registration
handsfree-audio: Add Audio Card GetProperties
handsfree-audio: Add emitting CardAdded
handsfree-audio: Add function to append properties
handsfree-audio: Add emitting CardRemoved
handsfree-audio: Add registered cards tracking
handsfree-audio: Add GetCards
src/handsfree-audio.c | 196 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 194 insertions(+), 2 deletions(-)
--
1.7.11.7
8 years, 1 month