* [PATCH 01/12] TODO: Task added for HFP-specific capabilities
2011-09-15 16:34 [PATCH 00/12] Bluetooth HFP-specific extensions Mikel Astiz
@ 2011-09-15 16:34 ` Mikel Astiz
2011-09-09 5:10 ` Denis Kenzior
2011-09-15 16:34 ` [PATCH 02/12] Add handsfree atom " Mikel Astiz
` (11 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Mikel Astiz @ 2011-09-15 16:34 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 547 bytes --]
---
TODO | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/TODO b/TODO
index 6d791ac..d5a6de3 100644
--- a/TODO
+++ b/TODO
@@ -117,6 +117,17 @@ SIM / SIM File system
Complexity: C1
+Bluetooth HFP
+=============
+
+- Support HFP-specific AT commands for the HF role, providing an appropriate
+ D-Bus API when needed. Some examples are AT+BIA, AT+BINP, AT+BLDN, AT+BVRA,
+ AT+BRSF, etc.
+
+ Priority: Medium
+ Complexity: C2
+
+
Modem Emulator
==============
--
1.7.6
^ permalink raw reply related [flat|nested] 27+ messages in thread* [PATCH 02/12] Add handsfree atom for HFP-specific capabilities
2011-09-15 16:34 [PATCH 00/12] Bluetooth HFP-specific extensions Mikel Astiz
2011-09-15 16:34 ` [PATCH 01/12] TODO: Task added for HFP-specific capabilities Mikel Astiz
@ 2011-09-15 16:34 ` Mikel Astiz
2011-09-09 5:13 ` Denis Kenzior
2011-09-16 15:56 ` Daniel Wagner
2011-09-15 16:34 ` [PATCH 03/12] hfpmodem: Driver implements handsfree atom Mikel Astiz
` (10 subsequent siblings)
12 siblings, 2 replies; 27+ messages in thread
From: Mikel Astiz @ 2011-09-15 16:34 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 10068 bytes --]
---
Makefile.am | 6 +-
include/dbus.h | 1 +
include/handsfree.h | 57 +++++++++++++
src/handsfree.c | 223 +++++++++++++++++++++++++++++++++++++++++++++++++++
src/ofono.h | 1 +
5 files changed, 286 insertions(+), 2 deletions(-)
create mode 100644 include/handsfree.h
create mode 100644 src/handsfree.c
diff --git a/Makefile.am b/Makefile.am
index 9baab0c..9142777 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -17,7 +17,8 @@ pkginclude_HEADERS = include/log.h include/plugin.h include/history.h \
include/gprs-provision.h include/emulator.h \
include/location-reporting.h \
include/cdma-connman.h include/gnss.h \
- include/private-network.h include/cdma-netreg.h
+ include/private-network.h include/cdma-netreg.h \
+ include/handsfree.h
nodist_pkginclude_HEADERS = include/version.h
@@ -422,7 +423,8 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) src/ofono.ver \
src/cdma-connman.c src/gnss.c \
src/gnssagent.c src/gnssagent.h \
src/cdma-smsutil.h src/cdma-smsutil.c \
- src/cdma-sms.c src/private-network.c src/cdma-netreg.c
+ src/cdma-sms.c src/private-network.c src/cdma-netreg.c \
+ src/handsfree.c
src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
diff --git a/include/dbus.h b/include/dbus.h
index 65bda72..5bf2669 100644
--- a/include/dbus.h
+++ b/include/dbus.h
@@ -58,6 +58,7 @@ extern "C" {
#define OFONO_LOCATION_REPORTING_INTERFACE OFONO_SERVICE ".LocationReporting"
#define OFONO_GNSS_INTERFACE "org.ofono.AssistedSatelliteNavigation"
#define OFONO_GNSS_POSR_AGENT_INTERFACE "org.ofono.PositioningRequestAgent"
+#define OFONO_HANDSFREE_INTERFACE OFONO_SERVICE ".Handsfree"
/* CDMA Interfaces */
#define OFONO_CDMA_VOICECALL_MANAGER_INTERFACE "org.ofono.cdma.VoiceCallManager"
diff --git a/include/handsfree.h b/include/handsfree.h
new file mode 100644
index 0000000..ddec353
--- /dev/null
+++ b/include/handsfree.h
@@ -0,0 +1,57 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-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_HANDSFREE_H
+#define __OFONO_HANDSFREE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ofono/types.h>
+
+struct ofono_handsfree;
+
+struct ofono_handsfree_driver {
+ const char *name;
+ int (*probe)(struct ofono_handsfree *hf, unsigned int vendor,
+ void *data);
+ void (*remove)(struct ofono_handsfree *hf);
+};
+
+int ofono_handsfree_driver_register(const struct ofono_handsfree_driver *d);
+void ofono_handsfree_driver_unregister(
+ const struct ofono_handsfree_driver *d);
+
+struct ofono_handsfree *ofono_handsfree_create(struct ofono_modem *modem,
+ unsigned int vendor, const char *driver, void *data);
+
+void ofono_handsfree_register(struct ofono_handsfree *hf);
+void ofono_handsfree_remove(struct ofono_handsfree *hf);
+
+void ofono_handsfree_set_data(struct ofono_handsfree *hf, void *data);
+void *ofono_handsfree_get_data(struct ofono_handsfree *hf);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_HANDSFREE_H */
diff --git a/src/handsfree.c b/src/handsfree.c
new file mode 100644
index 0000000..797fe69
--- /dev/null
+++ b/src/handsfree.c
@@ -0,0 +1,223 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-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
+
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include <glib.h>
+
+#include <ofono/log.h>
+#include <ofono/modem.h>
+#include <ofono/handsfree.h>
+
+#include <gdbus.h>
+#include "ofono.h"
+#include "common.h"
+
+static GSList *g_drivers = NULL;
+
+struct ofono_handsfree {
+ const struct ofono_handsfree_driver *driver;
+ void *driver_data;
+ struct ofono_atom *atom;
+};
+
+static DBusMessage *handsfree_get_properties(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBusMessage *reply;
+ DBusMessageIter iter;
+ DBusMessageIter dict;
+
+ reply = dbus_message_new_method_return(msg);
+ if (reply == NULL)
+ return NULL;
+
+ dbus_message_iter_init_append(reply, &iter);
+
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ OFONO_PROPERTIES_ARRAY_SIGNATURE,
+ &dict);
+ dbus_message_iter_close_container(&iter, &dict);
+
+ return reply;
+}
+
+static DBusMessage *handsfree_set_property(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBusMessageIter iter, var;
+ const char *name;
+
+ if (dbus_message_iter_init(msg, &iter) == FALSE)
+ return __ofono_error_invalid_args(msg);
+
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
+ return __ofono_error_invalid_args(msg);
+
+ dbus_message_iter_get_basic(&iter, &name);
+ 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);
+
+ return __ofono_error_invalid_args(msg);
+}
+
+static GDBusMethodTable handsfree_methods[] = {
+ { "GetProperties", "", "a{sv}", handsfree_get_properties,
+ G_DBUS_METHOD_FLAG_ASYNC },
+ { "SetProperty", "sv", "", handsfree_set_property,
+ G_DBUS_METHOD_FLAG_ASYNC },
+ { NULL, NULL, NULL, NULL }
+};
+
+static GDBusSignalTable handsfree_signals[] = {
+ { "PropertyChanged", "sv" },
+ { }
+};
+
+static void handsfree_remove(struct ofono_atom *atom)
+{
+ struct ofono_handsfree *hf = __ofono_atom_get_data(atom);
+
+ DBG("atom: %p", atom);
+
+ if (hf == NULL)
+ return;
+
+ if (hf->driver != NULL && hf->driver->remove != NULL)
+ hf->driver->remove(hf);
+
+ g_free(hf);
+}
+
+struct ofono_handsfree *ofono_handsfree_create(struct ofono_modem *modem,
+ unsigned int vendor,
+ const char *driver,
+ void *data)
+{
+ struct ofono_handsfree *hf;
+ GSList *l;
+
+ if (driver == NULL)
+ return NULL;
+
+ hf = g_try_new0(struct ofono_handsfree, 1);
+ if (hf == NULL)
+ return NULL;
+
+ hf->atom = __ofono_modem_add_atom(modem,
+ OFONO_ATOM_TYPE_HANDSFREE,
+ handsfree_remove, hf);
+
+ for (l = g_drivers; l; l = l->next) {
+ const struct ofono_handsfree_driver *drv = l->data;
+
+ if (g_strcmp0(drv->name, driver))
+ continue;
+
+ if (drv->probe(hf, vendor, data) < 0)
+ continue;
+
+ hf->driver = drv;
+ break;
+ }
+
+ return hf;
+}
+
+static void handsfree_unregister(struct ofono_atom *atom)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ struct ofono_modem *modem = __ofono_atom_get_modem(atom);
+ const char *path = __ofono_atom_get_path(atom);
+
+ ofono_modem_remove_interface(modem, OFONO_HANDSFREE_INTERFACE);
+ g_dbus_unregister_interface(conn, path,
+ OFONO_HANDSFREE_INTERFACE);
+}
+
+void ofono_handsfree_register(struct ofono_handsfree *hf)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ struct ofono_modem *modem = __ofono_atom_get_modem(hf->atom);
+ const char *path = __ofono_atom_get_path(hf->atom);
+
+ if (!g_dbus_register_interface(conn, path,
+ OFONO_HANDSFREE_INTERFACE,
+ handsfree_methods, handsfree_signals,
+ NULL, hf, NULL)) {
+ ofono_error("Could not create %s interface",
+ OFONO_HANDSFREE_INTERFACE);
+
+ return;
+ }
+
+ ofono_modem_add_interface(modem, OFONO_HANDSFREE_INTERFACE);
+
+ __ofono_atom_register(hf->atom, handsfree_unregister);
+}
+
+int ofono_handsfree_driver_register(const struct ofono_handsfree_driver *d)
+{
+ DBG("driver: %p, name: %s", d, d->name);
+
+ if (d->probe == NULL)
+ return -EINVAL;
+
+ g_drivers = g_slist_prepend(g_drivers, (void *) d);
+
+ return 0;
+}
+
+void ofono_handsfree_driver_unregister(
+ const struct ofono_handsfree_driver *d)
+{
+ DBG("driver: %p, name: %s", d, d->name);
+
+ g_drivers = g_slist_remove(g_drivers, (void *) d);
+}
+
+void ofono_handsfree_remove(struct ofono_handsfree *hf)
+{
+ __ofono_atom_free(hf->atom);
+}
+
+void ofono_handsfree_set_data(struct ofono_handsfree *hf, void *data)
+{
+ hf->driver_data = data;
+}
+
+void *ofono_handsfree_get_data(struct ofono_handsfree *hf)
+{
+ return hf->driver_data;
+}
diff --git a/src/ofono.h b/src/ofono.h
index 188c664..a5995b0 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -138,6 +138,7 @@ enum ofono_atom_type {
OFONO_ATOM_TYPE_GNSS,
OFONO_ATOM_TYPE_CDMA_SMS,
OFONO_ATOM_TYPE_CDMA_NETREG,
+ OFONO_ATOM_TYPE_HANDSFREE,
};
enum ofono_atom_watch_condition {
--
1.7.6
^ permalink raw reply related [flat|nested] 27+ messages in thread* Re: [PATCH 02/12] Add handsfree atom for HFP-specific capabilities
2011-09-15 16:34 ` [PATCH 02/12] Add handsfree atom " Mikel Astiz
@ 2011-09-09 5:13 ` Denis Kenzior
2011-09-16 15:56 ` Daniel Wagner
1 sibling, 0 replies; 27+ messages in thread
From: Denis Kenzior @ 2011-09-09 5:13 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 828 bytes --]
Hi Mikel,
On 09/15/2011 11:34 AM, Mikel Astiz wrote:
> ---
> Makefile.am | 6 +-
> include/dbus.h | 1 +
> include/handsfree.h | 57 +++++++++++++
> src/handsfree.c | 223 +++++++++++++++++++++++++++++++++++++++++++++++++++
> src/ofono.h | 1 +
> 5 files changed, 286 insertions(+), 2 deletions(-)
> create mode 100644 include/handsfree.h
> create mode 100644 src/handsfree.c
>
Patch has been applied, however thanks to the magic of git I split it
into three patches in line with our 'Submitting patches' guidelines.
When adding new atoms I like the patches to be structured this way:
- patch against include/dbus.h
- patch adding new include/fooatom.h + Makefile.am changes
- patch including new src/foo.c + Makefile.am and ofono.h changes
Regards,
-Denis
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 02/12] Add handsfree atom for HFP-specific capabilities
2011-09-15 16:34 ` [PATCH 02/12] Add handsfree atom " Mikel Astiz
2011-09-09 5:13 ` Denis Kenzior
@ 2011-09-16 15:56 ` Daniel Wagner
2011-09-09 5:14 ` Denis Kenzior
1 sibling, 1 reply; 27+ messages in thread
From: Daniel Wagner @ 2011-09-16 15:56 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 250 bytes --]
Hi Mikel,
> +++ b/include/handsfree.h
> @@ -0,0 +1,57 @@
> +/*
> + *
> + * oFono - Open Source Telephony
> + *
> + * Copyright (C) 2008-2010 Intel Corporation. All rights reserved.
BMW CarIT copyright statement? :)
cheers,
daniel
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 03/12] hfpmodem: Driver implements handsfree atom
2011-09-15 16:34 [PATCH 00/12] Bluetooth HFP-specific extensions Mikel Astiz
2011-09-15 16:34 ` [PATCH 01/12] TODO: Task added for HFP-specific capabilities Mikel Astiz
2011-09-15 16:34 ` [PATCH 02/12] Add handsfree atom " Mikel Astiz
@ 2011-09-15 16:34 ` Mikel Astiz
2011-09-09 6:14 ` Denis Kenzior
2011-09-15 16:34 ` [PATCH 04/12] hfp_hf: Plugin creates " Mikel Astiz
` (9 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Mikel Astiz @ 2011-09-15 16:34 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4273 bytes --]
---
Makefile.am | 3 +-
drivers/hfpmodem/handsfree.c | 98 ++++++++++++++++++++++++++++++++++++++++++
drivers/hfpmodem/hfpmodem.c | 2 +
drivers/hfpmodem/hfpmodem.h | 3 +
4 files changed, 105 insertions(+), 1 deletions(-)
create mode 100644 drivers/hfpmodem/handsfree.c
diff --git a/Makefile.am b/Makefile.am
index 9142777..8f7358e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -253,7 +253,8 @@ builtin_sources += drivers/atmodem/atutil.h \
drivers/hfpmodem/slc.c \
drivers/hfpmodem/voicecall.c \
drivers/hfpmodem/network-registration.c \
- drivers/hfpmodem/call-volume.c
+ drivers/hfpmodem/call-volume.c \
+ drivers/hfpmodem/handsfree.c
if PHONESIM
builtin_modules += phonesim
diff --git a/drivers/hfpmodem/handsfree.c b/drivers/hfpmodem/handsfree.c
new file mode 100644
index 0000000..9b7b986
--- /dev/null
+++ b/drivers/hfpmodem/handsfree.c
@@ -0,0 +1,98 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-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
+
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include <glib.h>
+#include <gatchat.h>
+#include <gatresult.h>
+
+#include <ofono/log.h>
+#include <ofono/modem.h>
+#include <ofono/handsfree.h>
+
+#include "hfpmodem.h"
+#include "slc.h"
+
+struct hf_data {
+ GAtChat *chat;
+};
+
+static gboolean hfp_handsfree_register(gpointer user_data)
+{
+ struct ofono_handsfree *hf = user_data;
+
+ ofono_handsfree_register(hf);
+
+ return FALSE;
+}
+
+static int hfp_handsfree_probe(struct ofono_handsfree *hf,
+ unsigned int vendor, void *data)
+{
+ struct hfp_slc_info *info = data;
+ struct hf_data *hd;
+
+ DBG("");
+ hd = g_new0(struct hf_data, 1);
+ hd->chat = g_at_chat_clone(info->chat);
+
+ ofono_handsfree_set_data(hf, hd);
+
+ g_idle_add(hfp_handsfree_register, hf);
+
+ return 0;
+}
+
+static void hfp_handsfree_remove(struct ofono_handsfree *hf)
+{
+ struct hf_data *hd = ofono_handsfree_get_data(hf);
+
+ ofono_handsfree_set_data(hf, NULL);
+
+ g_at_chat_unref(hd->chat);
+ g_free(hd);
+}
+
+static struct ofono_handsfree_driver driver = {
+ .name = "hfpmodem",
+ .probe = hfp_handsfree_probe,
+ .remove = hfp_handsfree_remove,
+};
+
+void hfp_handsfree_init(void)
+{
+ ofono_handsfree_driver_register(&driver);
+}
+
+void hfp_handsfree_exit(void)
+{
+ ofono_handsfree_driver_unregister(&driver);
+}
diff --git a/drivers/hfpmodem/hfpmodem.c b/drivers/hfpmodem/hfpmodem.c
index 8e8960b..e2b172d 100644
--- a/drivers/hfpmodem/hfpmodem.c
+++ b/drivers/hfpmodem/hfpmodem.c
@@ -37,6 +37,7 @@ static int hfpmodem_init(void)
hfp_voicecall_init();
hfp_netreg_init();
hfp_call_volume_init();
+ hfp_handsfree_init();
return 0;
}
@@ -46,6 +47,7 @@ static void hfpmodem_exit(void)
hfp_voicecall_exit();
hfp_netreg_exit();
hfp_call_volume_exit();
+ hfp_handsfree_exit();
}
OFONO_PLUGIN_DEFINE(hfpmodem, "Hands-Free Profile Driver", VERSION,
diff --git a/drivers/hfpmodem/hfpmodem.h b/drivers/hfpmodem/hfpmodem.h
index 0ad3ab7..643ec33 100644
--- a/drivers/hfpmodem/hfpmodem.h
+++ b/drivers/hfpmodem/hfpmodem.h
@@ -30,3 +30,6 @@ extern void hfp_call_volume_exit(void);
extern void hfp_voicecall_init(void);
extern void hfp_voicecall_exit(void);
+
+extern void hfp_handsfree_init(void);
+extern void hfp_handsfree_exit(void);
--
1.7.6
^ permalink raw reply related [flat|nested] 27+ messages in thread* [PATCH 04/12] hfp_hf: Plugin creates handsfree atom
2011-09-15 16:34 [PATCH 00/12] Bluetooth HFP-specific extensions Mikel Astiz
` (2 preceding siblings ...)
2011-09-15 16:34 ` [PATCH 03/12] hfpmodem: Driver implements handsfree atom Mikel Astiz
@ 2011-09-15 16:34 ` Mikel Astiz
2011-09-09 6:16 ` Denis Kenzior
2011-09-15 16:34 ` [PATCH 05/12] handsfree: Atom supports inband ringing status Mikel Astiz
` (8 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Mikel Astiz @ 2011-09-15 16:34 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 794 bytes --]
---
plugins/hfp_hf.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 6516e75..322edf3 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -41,6 +41,7 @@
#include <ofono/netreg.h>
#include <ofono/voicecall.h>
#include <ofono/call-volume.h>
+#include <ofono/handsfree.h>
#include <drivers/hfpmodem/slc.h>
@@ -469,6 +470,7 @@ static void hfp_pre_sim(struct ofono_modem *modem)
ofono_voicecall_create(modem, 0, "hfpmodem", &data->info);
ofono_netreg_create(modem, 0, "hfpmodem", &data->info);
ofono_call_volume_create(modem, 0, "hfpmodem", &data->info);
+ ofono_handsfree_create(modem, 0, "hfpmodem", &data->info);
}
static void hfp_post_sim(struct ofono_modem *modem)
--
1.7.6
^ permalink raw reply related [flat|nested] 27+ messages in thread* [PATCH 05/12] handsfree: Atom supports inband ringing status
2011-09-15 16:34 [PATCH 00/12] Bluetooth HFP-specific extensions Mikel Astiz
` (3 preceding siblings ...)
2011-09-15 16:34 ` [PATCH 04/12] hfp_hf: Plugin creates " Mikel Astiz
@ 2011-09-15 16:34 ` Mikel Astiz
2011-09-09 6:15 ` Denis Kenzior
2011-09-15 16:34 ` [PATCH 06/12] hfpmodem: Support for +BSIR unsol. result codes Mikel Astiz
` (7 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Mikel Astiz @ 2011-09-15 16:34 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2271 bytes --]
---
include/handsfree.h | 3 +++
src/handsfree.c | 26 ++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/include/handsfree.h b/include/handsfree.h
index ddec353..cd60975 100644
--- a/include/handsfree.h
+++ b/include/handsfree.h
@@ -37,6 +37,9 @@ struct ofono_handsfree_driver {
void (*remove)(struct ofono_handsfree *hf);
};
+void ofono_handsfree_set_inband_ringing(struct ofono_handsfree *hf,
+ ofono_bool_t enabled);
+
int ofono_handsfree_driver_register(const struct ofono_handsfree_driver *d);
void ofono_handsfree_driver_unregister(
const struct ofono_handsfree_driver *d);
diff --git a/src/handsfree.c b/src/handsfree.c
index 797fe69..2bf2284 100644
--- a/src/handsfree.c
+++ b/src/handsfree.c
@@ -43,17 +43,38 @@
static GSList *g_drivers = NULL;
struct ofono_handsfree {
+ ofono_bool_t inband_ringing;
const struct ofono_handsfree_driver *driver;
void *driver_data;
struct ofono_atom *atom;
};
+void ofono_handsfree_set_inband_ringing(struct ofono_handsfree *hf,
+ ofono_bool_t enabled)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path = __ofono_atom_get_path(hf->atom);
+ dbus_bool_t dbus_enabled = enabled;
+
+ if (hf->inband_ringing == enabled)
+ return;
+
+ hf->inband_ringing = enabled;
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_HANDSFREE_INTERFACE,
+ "InbandRinging", DBUS_TYPE_BOOLEAN,
+ &dbus_enabled);
+}
+
static DBusMessage *handsfree_get_properties(DBusConnection *conn,
DBusMessage *msg, void *data)
{
+ struct ofono_handsfree *hf = data;
DBusMessage *reply;
DBusMessageIter iter;
DBusMessageIter dict;
+ dbus_bool_t inband_ringing;
reply = dbus_message_new_method_return(msg);
if (reply == NULL)
@@ -64,6 +85,11 @@ static DBusMessage *handsfree_get_properties(DBusConnection *conn,
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
OFONO_PROPERTIES_ARRAY_SIGNATURE,
&dict);
+
+ inband_ringing = hf->inband_ringing;
+ ofono_dbus_dict_append(&dict, "InbandRinging", DBUS_TYPE_BOOLEAN,
+ &inband_ringing);
+
dbus_message_iter_close_container(&iter, &dict);
return reply;
--
1.7.6
^ permalink raw reply related [flat|nested] 27+ messages in thread* [PATCH 06/12] hfpmodem: Support for +BSIR unsol. result codes
2011-09-15 16:34 [PATCH 00/12] Bluetooth HFP-specific extensions Mikel Astiz
` (4 preceding siblings ...)
2011-09-15 16:34 ` [PATCH 05/12] handsfree: Atom supports inband ringing status Mikel Astiz
@ 2011-09-15 16:34 ` Mikel Astiz
2011-09-09 5:48 ` Denis Kenzior
2011-09-15 16:34 ` [PATCH 07/12] handsfree: Support for number requests (AT+BINP=1) Mikel Astiz
` (6 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Mikel Astiz @ 2011-09-15 16:34 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1415 bytes --]
---
drivers/hfpmodem/handsfree.c | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/drivers/hfpmodem/handsfree.c b/drivers/hfpmodem/handsfree.c
index 9b7b986..a3e7978 100644
--- a/drivers/hfpmodem/handsfree.c
+++ b/drivers/hfpmodem/handsfree.c
@@ -43,6 +43,7 @@
struct hf_data {
GAtChat *chat;
+ unsigned int vendor;
};
static gboolean hfp_handsfree_register(gpointer user_data)
@@ -54,6 +55,19 @@ static gboolean hfp_handsfree_register(gpointer user_data)
return FALSE;
}
+static void bsir_notify(GAtResult *result, gpointer user_data)
+{
+ struct ofono_handsfree *hf = user_data;
+ struct hf_data *hd = ofono_handsfree_get_data(hf);
+ int value;
+
+ if (at_util_parse_reg_unsolicited(result, "+BSIR:", &value,
+ NULL, NULL, NULL, hd->vendor) == FALSE)
+ return;
+
+ ofono_handsfree_set_inband_ringing(hf, (ofono_bool_t) value);
+}
+
static int hfp_handsfree_probe(struct ofono_handsfree *hf,
unsigned int vendor, void *data)
{
@@ -63,9 +77,12 @@ static int hfp_handsfree_probe(struct ofono_handsfree *hf,
DBG("");
hd = g_new0(struct hf_data, 1);
hd->chat = g_at_chat_clone(info->chat);
+ hd->vendor = vendor;
ofono_handsfree_set_data(hf, hd);
+ g_at_chat_register(hd->chat, "+BSIR:", bsir_notify, FALSE, hf, NULL);
+
g_idle_add(hfp_handsfree_register, hf);
return 0;
--
1.7.6
^ permalink raw reply related [flat|nested] 27+ messages in thread* Re: [PATCH 06/12] hfpmodem: Support for +BSIR unsol. result codes
2011-09-15 16:34 ` [PATCH 06/12] hfpmodem: Support for +BSIR unsol. result codes Mikel Astiz
@ 2011-09-09 5:48 ` Denis Kenzior
0 siblings, 0 replies; 27+ messages in thread
From: Denis Kenzior @ 2011-09-09 5:48 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1753 bytes --]
Hi Mikel,
On 09/15/2011 11:34 AM, Mikel Astiz wrote:
> ---
> drivers/hfpmodem/handsfree.c | 17 +++++++++++++++++
> 1 files changed, 17 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/hfpmodem/handsfree.c b/drivers/hfpmodem/handsfree.c
> index 9b7b986..a3e7978 100644
> --- a/drivers/hfpmodem/handsfree.c
> +++ b/drivers/hfpmodem/handsfree.c
> @@ -43,6 +43,7 @@
>
> struct hf_data {
> GAtChat *chat;
> + unsigned int vendor;
If you're not planning to use the vendor member for anything then it is
better left out.
> };
>
> static gboolean hfp_handsfree_register(gpointer user_data)
> @@ -54,6 +55,19 @@ static gboolean hfp_handsfree_register(gpointer user_data)
> return FALSE;
> }
>
> +static void bsir_notify(GAtResult *result, gpointer user_data)
> +{
> + struct ofono_handsfree *hf = user_data;
> + struct hf_data *hd = ofono_handsfree_get_data(hf);
> + int value;
> +
> + if (at_util_parse_reg_unsolicited(result, "+BSIR:", &value,
> + NULL, NULL, NULL, hd->vendor) == FALSE)
> + return;
> +
> + ofono_handsfree_set_inband_ringing(hf, (ofono_bool_t) value);
> +}
> +
> static int hfp_handsfree_probe(struct ofono_handsfree *hf,
> unsigned int vendor, void *data)
> {
> @@ -63,9 +77,12 @@ static int hfp_handsfree_probe(struct ofono_handsfree *hf,
> DBG("");
> hd = g_new0(struct hf_data, 1);
> hd->chat = g_at_chat_clone(info->chat);
> + hd->vendor = vendor;
>
> ofono_handsfree_set_data(hf, hd);
>
> + g_at_chat_register(hd->chat, "+BSIR:", bsir_notify, FALSE, hf, NULL);
> +
Just a minor nitpick, but I'd like this to be done in hfp_handsfree_register
> g_idle_add(hfp_handsfree_register, hf);
>
> return 0;
Regards,
-Denis
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 07/12] handsfree: Support for number requests (AT+BINP=1)
2011-09-15 16:34 [PATCH 00/12] Bluetooth HFP-specific extensions Mikel Astiz
` (5 preceding siblings ...)
2011-09-15 16:34 ` [PATCH 06/12] hfpmodem: Support for +BSIR unsol. result codes Mikel Astiz
@ 2011-09-15 16:34 ` Mikel Astiz
2011-09-09 6:16 ` Denis Kenzior
2011-09-15 16:34 ` [PATCH 08/12] handsfree: Expose RequestInput in D-Bus API Mikel Astiz
` (5 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Mikel Astiz @ 2011-09-15 16:34 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 847 bytes --]
---
include/handsfree.h | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/include/handsfree.h b/include/handsfree.h
index cd60975..18c6f26 100644
--- a/include/handsfree.h
+++ b/include/handsfree.h
@@ -30,11 +30,18 @@ extern "C" {
struct ofono_handsfree;
+typedef void (*ofono_handsfree_phone_cb_t)(const struct ofono_error *error,
+ const struct ofono_phone_number *number,
+ void *data);
+
struct ofono_handsfree_driver {
const char *name;
int (*probe)(struct ofono_handsfree *hf, unsigned int vendor,
void *data);
void (*remove)(struct ofono_handsfree *hf);
+ void (*request_phone_number) (struct ofono_handsfree *hf,
+ ofono_handsfree_phone_cb_t cb,
+ void *data);
};
void ofono_handsfree_set_inband_ringing(struct ofono_handsfree *hf,
--
1.7.6
^ permalink raw reply related [flat|nested] 27+ messages in thread* [PATCH 08/12] handsfree: Expose RequestInput in D-Bus API
2011-09-15 16:34 [PATCH 00/12] Bluetooth HFP-specific extensions Mikel Astiz
` (6 preceding siblings ...)
2011-09-15 16:34 ` [PATCH 07/12] handsfree: Support for number requests (AT+BINP=1) Mikel Astiz
@ 2011-09-15 16:34 ` Mikel Astiz
2011-09-09 6:01 ` Denis Kenzior
2011-09-15 16:34 ` [PATCH 09/12] hfpmodem: Support of number requests (AT+BINP=1) Mikel Astiz
` (4 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Mikel Astiz @ 2011-09-15 16:34 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2930 bytes --]
---
src/handsfree.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/src/handsfree.c b/src/handsfree.c
index 2bf2284..3138474 100644
--- a/src/handsfree.c
+++ b/src/handsfree.c
@@ -47,6 +47,7 @@ struct ofono_handsfree {
const struct ofono_handsfree_driver *driver;
void *driver_data;
struct ofono_atom *atom;
+ DBusMessage *pending;
};
void ofono_handsfree_set_inband_ringing(struct ofono_handsfree *hf,
@@ -118,11 +119,71 @@ static DBusMessage *handsfree_set_property(DBusConnection *conn,
return __ofono_error_invalid_args(msg);
}
+static void request_phone_number_cb(const struct ofono_error *error,
+ const struct ofono_phone_number *number,
+ void *data)
+{
+ struct ofono_handsfree *hf = data;
+ DBusMessage *reply;
+ const char *phone_number;
+
+ if (!hf->pending)
+ return;
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+ DBG("Phone number request callback returned error: %s",
+ telephony_error_to_str(error));
+
+ reply = __ofono_error_failed(hf->pending);
+ __ofono_dbus_pending_reply(&hf->pending, reply);
+ return;
+ }
+
+ phone_number = phone_number_to_string(number);
+ reply = dbus_message_new_method_return(hf->pending);
+ dbus_message_append_args(reply, DBUS_TYPE_STRING, &phone_number,
+ DBUS_TYPE_INVALID);
+ __ofono_dbus_pending_reply(&hf->pending, reply);
+}
+
+static DBusMessage *handsfree_request_input(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_handsfree *hf = data;
+ DBusMessageIter iter;
+ const char *name;
+
+ if (hf->pending)
+ return __ofono_error_busy(msg);
+
+ if (dbus_message_iter_init(msg, &iter) == FALSE)
+ return __ofono_error_invalid_args(msg);
+
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
+ return __ofono_error_invalid_args(msg);
+
+ dbus_message_iter_get_basic(&iter, &name);
+
+ if (g_str_equal(name, "PhoneNumber")) {
+ if (!hf->driver->request_phone_number)
+ return __ofono_error_not_supported(msg);
+
+ hf->pending = dbus_message_ref(msg);
+ hf->driver->request_phone_number(hf, request_phone_number_cb,
+ hf);
+ return NULL;
+ }
+
+ return __ofono_error_invalid_args(msg);
+}
+
static GDBusMethodTable handsfree_methods[] = {
{ "GetProperties", "", "a{sv}", handsfree_get_properties,
G_DBUS_METHOD_FLAG_ASYNC },
{ "SetProperty", "sv", "", handsfree_set_property,
G_DBUS_METHOD_FLAG_ASYNC },
+ { "RequestInput", "s", "v", handsfree_request_input,
+ G_DBUS_METHOD_FLAG_ASYNC },
{ NULL, NULL, NULL, NULL }
};
@@ -143,6 +204,9 @@ static void handsfree_remove(struct ofono_atom *atom)
if (hf->driver != NULL && hf->driver->remove != NULL)
hf->driver->remove(hf);
+ if (hf->pending)
+ dbus_message_unref(hf->pending);
+
g_free(hf);
}
--
1.7.6
^ permalink raw reply related [flat|nested] 27+ messages in thread* Re: [PATCH 08/12] handsfree: Expose RequestInput in D-Bus API
2011-09-15 16:34 ` [PATCH 08/12] handsfree: Expose RequestInput in D-Bus API Mikel Astiz
@ 2011-09-09 6:01 ` Denis Kenzior
0 siblings, 0 replies; 27+ messages in thread
From: Denis Kenzior @ 2011-09-09 6:01 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3772 bytes --]
Hi Mikel,
On 09/15/2011 11:34 AM, Mikel Astiz wrote:
> ---
> src/handsfree.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 64 insertions(+), 0 deletions(-)
>
> diff --git a/src/handsfree.c b/src/handsfree.c
> index 2bf2284..3138474 100644
> --- a/src/handsfree.c
> +++ b/src/handsfree.c
> @@ -47,6 +47,7 @@ struct ofono_handsfree {
> const struct ofono_handsfree_driver *driver;
> void *driver_data;
> struct ofono_atom *atom;
> + DBusMessage *pending;
> };
>
> void ofono_handsfree_set_inband_ringing(struct ofono_handsfree *hf,
> @@ -118,11 +119,71 @@ static DBusMessage *handsfree_set_property(DBusConnection *conn,
> return __ofono_error_invalid_args(msg);
> }
>
> +static void request_phone_number_cb(const struct ofono_error *error,
> + const struct ofono_phone_number *number,
> + void *data)
> +{
> + struct ofono_handsfree *hf = data;
> + DBusMessage *reply;
> + const char *phone_number;
> +
> + if (!hf->pending)
> + return;
Is this check really necessary?
> +
> + if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
> + DBG("Phone number request callback returned error: %s",
> + telephony_error_to_str(error));
> +
> + reply = __ofono_error_failed(hf->pending);
> + __ofono_dbus_pending_reply(&hf->pending, reply);
> + return;
> + }
> +
> + phone_number = phone_number_to_string(number);
> + reply = dbus_message_new_method_return(hf->pending);
> + dbus_message_append_args(reply, DBUS_TYPE_STRING, &phone_number,
> + DBUS_TYPE_INVALID);
> + __ofono_dbus_pending_reply(&hf->pending, reply);
> +}
> +
> +static DBusMessage *handsfree_request_input(DBusConnection *conn,
> + DBusMessage *msg, void *data)
> +{
> + struct ofono_handsfree *hf = data;
> + DBusMessageIter iter;
> + const char *name;
> +
> + if (hf->pending)
> + return __ofono_error_busy(msg);
> +
> + if (dbus_message_iter_init(msg, &iter) == FALSE)
> + return __ofono_error_invalid_args(msg);
> +
> + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
> + return __ofono_error_invalid_args(msg);
> +
> + dbus_message_iter_get_basic(&iter, &name);
> +
> + if (g_str_equal(name, "PhoneNumber")) {
> + if (!hf->driver->request_phone_number)
> + return __ofono_error_not_supported(msg);
> +
> + hf->pending = dbus_message_ref(msg);
> + hf->driver->request_phone_number(hf, request_phone_number_cb,
> + hf);
> + return NULL;
> + }
I'd rather not do it this way. I know +BINP is supposed to be
'extendable', but it hasn't been in what 5-6 years now? Using
RequestPhoneNumber or RequestNumberInput would probably be better.
> +
> + return __ofono_error_invalid_args(msg);
> +}
> +
> static GDBusMethodTable handsfree_methods[] = {
> { "GetProperties", "", "a{sv}", handsfree_get_properties,
> G_DBUS_METHOD_FLAG_ASYNC },
> { "SetProperty", "sv", "", handsfree_set_property,
> G_DBUS_METHOD_FLAG_ASYNC },
> + { "RequestInput", "s", "v", handsfree_request_input,
> + G_DBUS_METHOD_FLAG_ASYNC },
You might want to submit a formal API proposal first (e.g. in doc/)
before trying to implement the API. This would make discussing API
details easier.
> { NULL, NULL, NULL, NULL }
> };
>
> @@ -143,6 +204,9 @@ static void handsfree_remove(struct ofono_atom *atom)
> if (hf->driver != NULL && hf->driver->remove != NULL)
> hf->driver->remove(hf);
>
> + if (hf->pending)
> + dbus_message_unref(hf->pending);
> +
The rest of the code doesn't do this, though it probably should.
However, it probably belongs in _unregister, not _remove. Using
ofono_dbus_pending_reply might be better as well.
> g_free(hf);
> }
>
Regards,
-Denis
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 09/12] hfpmodem: Support of number requests (AT+BINP=1)
2011-09-15 16:34 [PATCH 00/12] Bluetooth HFP-specific extensions Mikel Astiz
` (7 preceding siblings ...)
2011-09-15 16:34 ` [PATCH 08/12] handsfree: Expose RequestInput in D-Bus API Mikel Astiz
@ 2011-09-15 16:34 ` Mikel Astiz
2011-09-09 6:04 ` Denis Kenzior
2011-09-15 16:34 ` [PATCH 10/12] handsfree: Read-only voice-recognition D-Bus prop Mikel Astiz
` (3 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Mikel Astiz @ 2011-09-15 16:34 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2228 bytes --]
---
drivers/hfpmodem/handsfree.c | 59 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 59 insertions(+), 0 deletions(-)
diff --git a/drivers/hfpmodem/handsfree.c b/drivers/hfpmodem/handsfree.c
index a3e7978..cd6afc7 100644
--- a/drivers/hfpmodem/handsfree.c
+++ b/drivers/hfpmodem/handsfree.c
@@ -41,6 +41,8 @@
#include "hfpmodem.h"
#include "slc.h"
+static const char *binp_prefix[] = { "+BINP:", NULL };
+
struct hf_data {
GAtChat *chat;
unsigned int vendor;
@@ -98,10 +100,67 @@ static void hfp_handsfree_remove(struct ofono_handsfree *hf)
g_free(hd);
}
+static void hfp_request_phone_number_cb(gboolean ok, GAtResult *result,
+ gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_handsfree_phone_cb_t cb = cbd->cb;
+ void *data = cbd->data;
+ GAtResultIter iter;
+ const char *num;
+ int type;
+ struct ofono_phone_number phone_number;
+
+ if (!ok)
+ goto fail;
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, "+BINP:"))
+ goto fail;
+
+ if (!g_at_result_iter_next_string(&iter, &num))
+ goto fail;
+
+ if (!g_at_result_iter_next_number(&iter, &type))
+ goto fail;
+
+ DBG("AT+BINP=1 response: %s %d", num, type);
+
+ strncpy(phone_number.number, num,
+ OFONO_MAX_PHONE_NUMBER_LENGTH);
+ phone_number.number[OFONO_MAX_PHONE_NUMBER_LENGTH] = '\0';
+ phone_number.type = type;
+
+ CALLBACK_WITH_SUCCESS(cb, &phone_number, data);
+ return;
+
+fail:
+ CALLBACK_WITH_FAILURE(cb, NULL, data);
+}
+
+static void hfp_request_phone_number(struct ofono_handsfree *hf,
+ ofono_handsfree_phone_cb_t cb,
+ void *data)
+{
+ struct hf_data *hd = ofono_handsfree_get_data(hf);
+ struct cb_data *cbd = cb_data_new(cb, data);
+
+ if (g_at_chat_send(hd->chat, "AT+BINP=1", binp_prefix,
+ hfp_request_phone_number_cb,
+ cbd, g_free) > 0)
+ return;
+
+ g_free(cbd);
+
+ CALLBACK_WITH_FAILURE(cb, NULL, data);
+}
+
static struct ofono_handsfree_driver driver = {
.name = "hfpmodem",
.probe = hfp_handsfree_probe,
.remove = hfp_handsfree_remove,
+ .request_phone_number = hfp_request_phone_number,
};
void hfp_handsfree_init(void)
--
1.7.6
^ permalink raw reply related [flat|nested] 27+ messages in thread* [PATCH 10/12] handsfree: Read-only voice-recognition D-Bus prop
2011-09-15 16:34 [PATCH 00/12] Bluetooth HFP-specific extensions Mikel Astiz
` (8 preceding siblings ...)
2011-09-15 16:34 ` [PATCH 09/12] hfpmodem: Support of number requests (AT+BINP=1) Mikel Astiz
@ 2011-09-15 16:34 ` Mikel Astiz
2011-09-09 6:13 ` Denis Kenzior
2011-09-15 16:34 ` [PATCH 11/12] handsfree: Writable voice-recogn. prop (AT+BVRA) Mikel Astiz
` (2 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Mikel Astiz @ 2011-09-15 16:34 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2459 bytes --]
---
include/handsfree.h | 2 ++
src/handsfree.c | 25 +++++++++++++++++++++++++
2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/include/handsfree.h b/include/handsfree.h
index 18c6f26..26a4c4f 100644
--- a/include/handsfree.h
+++ b/include/handsfree.h
@@ -46,6 +46,8 @@ struct ofono_handsfree_driver {
void ofono_handsfree_set_inband_ringing(struct ofono_handsfree *hf,
ofono_bool_t enabled);
+void ofono_handsfree_set_voice_recognition(struct ofono_handsfree *hf,
+ ofono_bool_t enabled);
int ofono_handsfree_driver_register(const struct ofono_handsfree_driver *d);
void ofono_handsfree_driver_unregister(
diff --git a/src/handsfree.c b/src/handsfree.c
index 3138474..4b0756b 100644
--- a/src/handsfree.c
+++ b/src/handsfree.c
@@ -44,6 +44,8 @@ static GSList *g_drivers = NULL;
struct ofono_handsfree {
ofono_bool_t inband_ringing;
+ ofono_bool_t voicerec_state;
+
const struct ofono_handsfree_driver *driver;
void *driver_data;
struct ofono_atom *atom;
@@ -68,6 +70,24 @@ void ofono_handsfree_set_inband_ringing(struct ofono_handsfree *hf,
&dbus_enabled);
}
+void ofono_handsfree_set_voice_recognition(struct ofono_handsfree *hf,
+ ofono_bool_t enabled)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path = __ofono_atom_get_path(hf->atom);
+ dbus_bool_t dbus_enabled = enabled;
+
+ if (hf->voicerec_state == enabled)
+ return;
+
+ hf->voicerec_state = enabled;
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_HANDSFREE_INTERFACE,
+ "VoiceRecognition", DBUS_TYPE_BOOLEAN,
+ &dbus_enabled);
+}
+
static DBusMessage *handsfree_get_properties(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -76,6 +96,7 @@ static DBusMessage *handsfree_get_properties(DBusConnection *conn,
DBusMessageIter iter;
DBusMessageIter dict;
dbus_bool_t inband_ringing;
+ dbus_bool_t voicerec_state;
reply = dbus_message_new_method_return(msg);
if (reply == NULL)
@@ -91,6 +112,10 @@ static DBusMessage *handsfree_get_properties(DBusConnection *conn,
ofono_dbus_dict_append(&dict, "InbandRinging", DBUS_TYPE_BOOLEAN,
&inband_ringing);
+ voicerec_state = hf->voicerec_state;
+ ofono_dbus_dict_append(&dict, "VoiceRecognition", DBUS_TYPE_BOOLEAN,
+ &voicerec_state);
+
dbus_message_iter_close_container(&iter, &dict);
return reply;
--
1.7.6
^ permalink raw reply related [flat|nested] 27+ messages in thread* Re: [PATCH 10/12] handsfree: Read-only voice-recognition D-Bus prop
2011-09-15 16:34 ` [PATCH 10/12] handsfree: Read-only voice-recognition D-Bus prop Mikel Astiz
@ 2011-09-09 6:13 ` Denis Kenzior
0 siblings, 0 replies; 27+ messages in thread
From: Denis Kenzior @ 2011-09-09 6:13 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2851 bytes --]
Hi Mikel,
On 09/15/2011 11:34 AM, Mikel Astiz wrote:
> ---
> include/handsfree.h | 2 ++
> src/handsfree.c | 25 +++++++++++++++++++++++++
> 2 files changed, 27 insertions(+), 0 deletions(-)
Can you split this patch into two, one for handsfree driver api changes
and one for the atom changes.
Also, I'd like the read-only and write-only patches to be combined.
>
> diff --git a/include/handsfree.h b/include/handsfree.h
> index 18c6f26..26a4c4f 100644
> --- a/include/handsfree.h
> +++ b/include/handsfree.h
> @@ -46,6 +46,8 @@ struct ofono_handsfree_driver {
>
> void ofono_handsfree_set_inband_ringing(struct ofono_handsfree *hf,
> ofono_bool_t enabled);
> +void ofono_handsfree_set_voice_recognition(struct ofono_handsfree *hf,
> + ofono_bool_t enabled);
>
> int ofono_handsfree_driver_register(const struct ofono_handsfree_driver *d);
> void ofono_handsfree_driver_unregister(
> diff --git a/src/handsfree.c b/src/handsfree.c
> index 3138474..4b0756b 100644
> --- a/src/handsfree.c
> +++ b/src/handsfree.c
> @@ -44,6 +44,8 @@ static GSList *g_drivers = NULL;
>
> struct ofono_handsfree {
> ofono_bool_t inband_ringing;
> + ofono_bool_t voicerec_state;
> +
> const struct ofono_handsfree_driver *driver;
> void *driver_data;
> struct ofono_atom *atom;
> @@ -68,6 +70,24 @@ void ofono_handsfree_set_inband_ringing(struct ofono_handsfree *hf,
> &dbus_enabled);
> }
>
> +void ofono_handsfree_set_voice_recognition(struct ofono_handsfree *hf,
> + ofono_bool_t enabled)
> +{
> + DBusConnection *conn = ofono_dbus_get_connection();
> + const char *path = __ofono_atom_get_path(hf->atom);
> + dbus_bool_t dbus_enabled = enabled;
> +
> + if (hf->voicerec_state == enabled)
> + return;
> +
> + hf->voicerec_state = enabled;
> +
> + ofono_dbus_signal_property_changed(conn, path,
> + OFONO_HANDSFREE_INTERFACE,
> + "VoiceRecognition", DBUS_TYPE_BOOLEAN,
> + &dbus_enabled);
> +}
> +
> static DBusMessage *handsfree_get_properties(DBusConnection *conn,
> DBusMessage *msg, void *data)
> {
> @@ -76,6 +96,7 @@ static DBusMessage *handsfree_get_properties(DBusConnection *conn,
> DBusMessageIter iter;
> DBusMessageIter dict;
> dbus_bool_t inband_ringing;
> + dbus_bool_t voicerec_state;
>
> reply = dbus_message_new_method_return(msg);
> if (reply == NULL)
> @@ -91,6 +112,10 @@ static DBusMessage *handsfree_get_properties(DBusConnection *conn,
> ofono_dbus_dict_append(&dict, "InbandRinging", DBUS_TYPE_BOOLEAN,
> &inband_ringing);
>
> + voicerec_state = hf->voicerec_state;
> + ofono_dbus_dict_append(&dict, "VoiceRecognition", DBUS_TYPE_BOOLEAN,
> + &voicerec_state);
> +
> dbus_message_iter_close_container(&iter, &dict);
>
> return reply;
Regards,
-Denis
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 11/12] handsfree: Writable voice-recogn. prop (AT+BVRA)
2011-09-15 16:34 [PATCH 00/12] Bluetooth HFP-specific extensions Mikel Astiz
` (9 preceding siblings ...)
2011-09-15 16:34 ` [PATCH 10/12] handsfree: Read-only voice-recognition D-Bus prop Mikel Astiz
@ 2011-09-15 16:34 ` Mikel Astiz
2011-09-15 16:34 ` [PATCH 12/12] hfpmodem: Support for AT+BVRA Mikel Astiz
2011-09-23 8:57 ` [PATCH 00/12] Bluetooth HFP-specific extensions =?unknown-8bit?q?R=C3=A9mi?= Denis-Courmont
12 siblings, 0 replies; 27+ messages in thread
From: Mikel Astiz @ 2011-09-15 16:34 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3286 bytes --]
---
include/handsfree.h | 5 +++++
src/handsfree.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/include/handsfree.h b/include/handsfree.h
index 26a4c4f..8f29dee 100644
--- a/include/handsfree.h
+++ b/include/handsfree.h
@@ -30,6 +30,8 @@ extern "C" {
struct ofono_handsfree;
+typedef void (*ofono_handsfree_cb_t)(const struct ofono_error *error,
+ void *data);
typedef void (*ofono_handsfree_phone_cb_t)(const struct ofono_error *error,
const struct ofono_phone_number *number,
void *data);
@@ -42,6 +44,9 @@ struct ofono_handsfree_driver {
void (*request_phone_number) (struct ofono_handsfree *hf,
ofono_handsfree_phone_cb_t cb,
void *data);
+ void (*voice_recognition)(struct ofono_handsfree *cv,
+ ofono_bool_t enabled,
+ ofono_handsfree_cb_t cb, void *data);
};
void ofono_handsfree_set_inband_ringing(struct ofono_handsfree *hf,
diff --git a/src/handsfree.c b/src/handsfree.c
index 4b0756b..9e53cac 100644
--- a/src/handsfree.c
+++ b/src/handsfree.c
@@ -45,6 +45,7 @@ static GSList *g_drivers = NULL;
struct ofono_handsfree {
ofono_bool_t inband_ringing;
ofono_bool_t voicerec_state;
+ ofono_bool_t pending_voicerec_state;
const struct ofono_handsfree_driver *driver;
void *driver_data;
@@ -121,12 +122,40 @@ static DBusMessage *handsfree_get_properties(DBusConnection *conn,
return reply;
}
+static void voicerec_set_cb(const struct ofono_error *error, void *data)
+{
+ struct ofono_handsfree *hf = data;
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path = __ofono_atom_get_path(hf->atom);
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+ __ofono_dbus_pending_reply(&hf->pending,
+ __ofono_error_failed(hf->pending));
+ return;
+ }
+
+ hf->voicerec_state = hf->pending_voicerec_state;
+
+ __ofono_dbus_pending_reply(&hf->pending,
+ dbus_message_new_method_return(hf->pending));
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_HANDSFREE_INTERFACE,
+ "VoiceRecognition",
+ DBUS_TYPE_BOOLEAN,
+ &hf->voicerec_state);
+}
+
static DBusMessage *handsfree_set_property(DBusConnection *conn,
DBusMessage *msg, void *data)
{
+ struct ofono_handsfree *hf = data;
DBusMessageIter iter, var;
const char *name;
+ if (hf->pending)
+ return __ofono_error_busy(msg);
+
if (dbus_message_iter_init(msg, &iter) == FALSE)
return __ofono_error_invalid_args(msg);
@@ -141,6 +170,24 @@ static DBusMessage *handsfree_set_property(DBusConnection *conn,
dbus_message_iter_recurse(&iter, &var);
+ if (g_str_equal(name, "VoiceRecognition") == TRUE) {
+ ofono_bool_t enabled;
+
+ if (!hf->driver->voice_recognition)
+ return __ofono_error_not_implemented(msg);
+
+ if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BOOLEAN)
+ return __ofono_error_invalid_args(msg);
+
+ dbus_message_iter_get_basic(&var, &enabled);
+
+ hf->pending_voicerec_state = enabled;
+ hf->pending = dbus_message_ref(msg);
+ hf->driver->voice_recognition(hf, enabled, voicerec_set_cb, hf);
+
+ return NULL;
+ }
+
return __ofono_error_invalid_args(msg);
}
--
1.7.6
^ permalink raw reply related [flat|nested] 27+ messages in thread* [PATCH 12/12] hfpmodem: Support for AT+BVRA
2011-09-15 16:34 [PATCH 00/12] Bluetooth HFP-specific extensions Mikel Astiz
` (10 preceding siblings ...)
2011-09-15 16:34 ` [PATCH 11/12] handsfree: Writable voice-recogn. prop (AT+BVRA) Mikel Astiz
@ 2011-09-15 16:34 ` Mikel Astiz
2011-09-09 6:17 ` Denis Kenzior
2011-09-23 8:57 ` [PATCH 00/12] Bluetooth HFP-specific extensions =?unknown-8bit?q?R=C3=A9mi?= Denis-Courmont
12 siblings, 1 reply; 27+ messages in thread
From: Mikel Astiz @ 2011-09-15 16:34 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2856 bytes --]
---
drivers/hfpmodem/handsfree.c | 49 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/drivers/hfpmodem/handsfree.c b/drivers/hfpmodem/handsfree.c
index cd6afc7..c061aa8 100644
--- a/drivers/hfpmodem/handsfree.c
+++ b/drivers/hfpmodem/handsfree.c
@@ -42,12 +42,25 @@
#include "slc.h"
static const char *binp_prefix[] = { "+BINP:", NULL };
+static const char *bvra_prefix[] = { "+BVRA:", NULL };
struct hf_data {
GAtChat *chat;
unsigned int vendor;
};
+static void hf_generic_set_cb(gboolean ok, GAtResult *result,
+ gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_handsfree_cb_t cb = cbd->cb;
+ struct ofono_error error;
+
+ decode_at_error(&error, g_at_result_final_response(result));
+
+ cb(&error, cbd->data);
+}
+
static gboolean hfp_handsfree_register(gpointer user_data)
{
struct ofono_handsfree *hf = user_data;
@@ -70,6 +83,19 @@ static void bsir_notify(GAtResult *result, gpointer user_data)
ofono_handsfree_set_inband_ringing(hf, (ofono_bool_t) value);
}
+static void bvra_notify(GAtResult *result, gpointer user_data)
+{
+ struct ofono_handsfree *hf = user_data;
+ struct hf_data *hd = ofono_handsfree_get_data(hf);
+ int value;
+
+ if (at_util_parse_reg_unsolicited(result, "+BVRA:", &value,
+ NULL, NULL, NULL, hd->vendor) == FALSE)
+ return;
+
+ ofono_handsfree_set_voice_recognition(hf, (ofono_bool_t) value);
+}
+
static int hfp_handsfree_probe(struct ofono_handsfree *hf,
unsigned int vendor, void *data)
{
@@ -84,6 +110,7 @@ static int hfp_handsfree_probe(struct ofono_handsfree *hf,
ofono_handsfree_set_data(hf, hd);
g_at_chat_register(hd->chat, "+BSIR:", bsir_notify, FALSE, hf, NULL);
+ g_at_chat_register(hd->chat, "+BVRA:", bvra_notify, FALSE, hf, NULL);
g_idle_add(hfp_handsfree_register, hf);
@@ -156,11 +183,33 @@ static void hfp_request_phone_number(struct ofono_handsfree *hf,
CALLBACK_WITH_FAILURE(cb, NULL, data);
}
+static void hfp_voice_recognition(struct ofono_handsfree *hf,
+ ofono_bool_t enabled,
+ ofono_handsfree_cb_t cb, void *data)
+{
+ struct hf_data *hd = ofono_handsfree_get_data(hf);
+ struct cb_data *cbd = cb_data_new(cb, data);
+ char buf[64];
+
+ snprintf(buf, sizeof(buf), "AT+BVRA=%d",
+ (int)(enabled));
+
+ if (g_at_chat_send(hd->chat, buf, bvra_prefix,
+ hf_generic_set_cb,
+ cbd, g_free) > 0)
+ return;
+
+ g_free(cbd);
+
+ CALLBACK_WITH_FAILURE(cb, data);
+}
+
static struct ofono_handsfree_driver driver = {
.name = "hfpmodem",
.probe = hfp_handsfree_probe,
.remove = hfp_handsfree_remove,
.request_phone_number = hfp_request_phone_number,
+ .voice_recognition = hfp_voice_recognition,
};
void hfp_handsfree_init(void)
--
1.7.6
^ permalink raw reply related [flat|nested] 27+ messages in thread* Re: [PATCH 00/12] Bluetooth HFP-specific extensions
2011-09-15 16:34 [PATCH 00/12] Bluetooth HFP-specific extensions Mikel Astiz
` (11 preceding siblings ...)
2011-09-15 16:34 ` [PATCH 12/12] hfpmodem: Support for AT+BVRA Mikel Astiz
@ 2011-09-23 8:57 ` =?unknown-8bit?q?R=C3=A9mi?= Denis-Courmont
12 siblings, 0 replies; 27+ messages in thread
From: =?unknown-8bit?q?R=C3=A9mi?= Denis-Courmont @ 2011-09-23 8:57 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 765 bytes --]
On Thursday 15 September 2011 19:34:31 ext Mikel Astiz, you wrote:
> Mikel Astiz (12):
> TODO: Task added for HFP-specific capabilities
> Add handsfree atom for HFP-specific capabilities
> hfpmodem: Driver implements handsfree atom
> hfp_hf: Plugin creates handsfree atom
> handsfree: Atom supports inband ringing status
> hfpmodem: Support for +BSIR unsol. result codes
> handsfree: Support for number requests (AT+BINP=1)
> handsfree: Expose RequestInput in D-Bus API
> hfpmodem: Support of number requests (AT+BINP=1)
> handsfree: Read-only voice-recognition D-Bus prop
> handsfree: Writable voice-recogn. prop (AT+BVRA)
> hfpmodem: Support for AT+BVRA
Documentation?
--
Rémi Denis-Courmont
http://www.remlab.net/
^ permalink raw reply [flat|nested] 27+ messages in thread