Skip to contentSkip to conversation

HSP profile implementation

PATCH In review Frédéric Dalleau 4 participants 18 messages Mar 17, 2011 – Mar 21, 2011 Kbuild

lore
Share & tools
lore
#0 lore raw

v2 cover HSP profile implementation

This patch will start providing an HSP profile implementation in oFono. This is work in progress, and based of what was done for HFP profile. Finally added the audio connection, that will provide a base for discussion. To avoid emulator depend upon btio, there is a callback fom the emulator to the hsp plugin to connect audio,

Some question remains :

* How should pulse audio be notified?
* What is the behavior of hsp when receiving CKPD=200?

Next step will be to dial/hangup a call.

Frédéric Dalleau (9):
bluetooth: add functions for sco connection
emulator: add hsp emulator type
hsp_ag: add hsp atom type
hsp_ag: Initial plugin commit
hsp_ag: add modem watch
emulator: add CKPD support
emulator: add audio connection API
emulator: implement audio connection API
hsp_ag: add audio connection support

 Makefile.am         |    3 +
 include/emulator.h  |    8 ++
 plugins/bluetooth.c |  122 +++++++++++++++++++++++++++++++
 plugins/bluetooth.h |    7 ++
 plugins/hsp_ag.c    |  200 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/emulator.c      |   50 +++++++++++++
 src/ofono.h         |    1 +
 7 files changed, 391 insertions(+), 0 deletions(-)
 create mode 100644 plugins/hsp_ag.c
#1 lore raw

PATCH v2 1/9 bluetooth: add functions for sco connection

---
 plugins/bluetooth.c |  122 +++++++++++++++++++++++++++++++++++++++++++++++++++
 plugins/bluetooth.h |    7 +++
 2 files changed, 129 insertions(+), 0 deletions(-)
plugins/bluetooth.c +122 -0
index 7c2d5b0..89cc72d 100644
@@ -64,6 +64,14 @@ struct cb_data {
 	GIOChannel *io;
 };
 
+struct sco {
+	char laddress[18];
+	char raddress[18];
+	guint active_watch;
+	GIOChannel *active;
+	GIOChannel *listening;
+};
+
 void bluetooth_create_path(const char *dev_addr, const char *adapter_addr,
 				char *buf, int size)
 {
@@ -932,5 +940,119 @@ void bluetooth_unregister_server(struct server *server)
 	bluetooth_unref();
 }
 
+static gboolean sco_disconnect_cb(GIOChannel *io, GIOCondition cond,
+								gpointer data)
+{
+	struct sco *sco = data;
+
+	if(cond & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) {
+		DBG("");
+		sco->active = NULL;
+		sco->active_watch = 0;
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static void sco_connect_cb(GIOChannel *channel, GError *err, gpointer data)
+{
+	struct sco *sco = data;
+
+	if(err != NULL) {
+		DBG("Failed to connect SCO channel: %s", err->message);
+		return;
+	}
+
+	DBG("sco->active_watch %d sco->active %p sco->listening %p",
+			sco->active_watch, sco->active, sco->listening);
+
+	if(sco->active_watch)
+		return;
+
+	sco->active_watch = g_io_add_watch(channel,
+				G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+				sco_disconnect_cb, data);
+
+	if(sco->active)
+		g_io_channel_unref(sco->active);
+
+	sco->active = channel;
+	g_io_channel_set_close_on_unref(sco->active, TRUE);
+}
+
+void sco_connect(struct sco *sco)
+{
+	GError *err = NULL;
+
+	if(sco->active != NULL)
+		return;
+
+	sco->active = bt_io_connect(BT_IO_SCO, sco_connect_cb, sco,
+			NULL, &err, BT_IO_OPT_SOURCE, sco->laddress,
+			BT_IO_OPT_DEST, sco->raddress, BT_IO_OPT_INVALID);
+
+	if(sco->active)
+		g_io_channel_set_close_on_unref(sco->active, TRUE);
+
+	if(err != NULL) {
+		DBG("Failed to get device address: %s", err->message);
+		g_error_free(err);
+	}
+}
+
+void sco_disconnect(struct sco *sco)
+{
+	if(sco->active == NULL)
+		return;
+
+	g_source_remove(sco->active_watch);
+	sco->active_watch = 0;
+	sco->active = NULL;
+}
+
+struct sco *sco_register_server(GIOChannel *channel)
+{
+	struct sco *sco;
+	GError *err = NULL;
+
+	sco = g_try_malloc0(sizeof(struct sco));
+	if(sco == NULL)
+		return NULL;
+
+	sco->listening = bt_io_listen(BT_IO_SCO, sco_connect_cb, NULL, sco,
+			NULL, &err, BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
+			BT_IO_OPT_INVALID);
+
+	if(err != NULL) {
+		DBG("Failed to listen incoming SCO: %s", err->message);
+		g_error_free(err);
+		err = NULL;
+	}
+
+	if(sco->listening)
+		g_io_channel_set_close_on_unref(sco->listening, TRUE);
+
+	bt_io_get(channel, BT_IO_RFCOMM, &err, BT_IO_OPT_SOURCE, sco->laddress,
+			BT_IO_OPT_DEST, sco->raddress, BT_IO_OPT_INVALID);
+
+	if(err != NULL) {
+		DBG("Failed to get device address: %s", err->message);
+		g_error_free(err);
+	}
+
+	return sco;
+}
+
+void sco_unregister_server(struct sco *sco)
+{
+	sco_disconnect(sco);
+
+	if(sco->listening != NULL)
+		g_io_channel_unref(sco->listening);
+
+	g_free(sco);
+}
+
 OFONO_PLUGIN_DEFINE(bluetooth, "Bluetooth Utils Plugins", VERSION,
 			OFONO_PLUGIN_PRIORITY_DEFAULT, NULL, NULL)
plugins/bluetooth.h +7 -0
index 505d908..ba88e96 100644
@@ -42,6 +42,8 @@ struct bluetooth_profile {
 
 struct server;
 
+struct sco;
+
 typedef void (*ConnectFunc)(GIOChannel *io, GError *err, gpointer user_data);
 
 int bluetooth_register_uuid(const char *uuid,
@@ -52,6 +54,11 @@ struct server *bluetooth_register_server(guint8 channel, const char *sdp_record,
 					ConnectFunc cb, gpointer user_data);
 void bluetooth_unregister_server(struct server *server);
 
+void sco_connect(struct sco *sco);
+void sco_disconnect(struct sco *sco);
+struct sco *sco_register_server(GIOChannel *channel);
+void sco_unregister_server(struct sco *sco);
+
 void bluetooth_create_path(const char *dev_addr, const char *adapter_addr,
 							char *buf, int size);
 
Signature · 1 line
1.7.1
#5 lore raw

PATCH v2 2/9 emulator: add hsp emulator type

In reply to Frédéric Dalleau
---
 include/emulator.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
include/emulator.h +1 -0
index 71b7c24..e010606 100644
@@ -42,6 +42,7 @@ struct ofono_emulator_request;
 enum ofono_emulator_type {
 	OFONO_EMULATOR_TYPE_DUN,
 	OFONO_EMULATOR_TYPE_HFP,
+	OFONO_EMULATOR_TYPE_HSP,
 };
 
 enum ofono_emulator_request_type {
Signature · 1 line
1.7.1
#6 lore raw

PATCH v2 3/9 hsp_ag: add hsp atom type

In reply to Frédéric Dalleau
---
 src/emulator.c |    4 ++++
 src/ofono.h    |    1 +
 2 files changed, 5 insertions(+), 0 deletions(-)
src/emulator.c +4 -0
index c84f0a9..ce3fabd 100644
@@ -470,6 +470,8 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
 		g_at_server_register(em->server, "D", dial_cb, em, NULL);
 	else if (em->type == OFONO_EMULATOR_TYPE_HFP)
 		g_at_server_set_echo(em->server, FALSE);
+	else if (em->type == OFONO_EMULATOR_TYPE_HSP)
+		g_at_server_set_echo(em->server, FALSE);
 }
 
 static void emulator_remove(struct ofono_atom *atom)
@@ -493,6 +495,8 @@ struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
 		atom_t = OFONO_ATOM_TYPE_EMULATOR_DUN;
 	else if (type == OFONO_EMULATOR_TYPE_HFP)
 		atom_t = OFONO_ATOM_TYPE_EMULATOR_HFP;
+	else if (type == OFONO_EMULATOR_TYPE_HSP)
+		atom_t = OFONO_ATOM_TYPE_EMULATOR_HSP;
 	else
 		return NULL;
 
src/ofono.h +1 -0
index 1628df3..f294b87 100644
@@ -130,6 +130,7 @@ enum ofono_atom_type {
 	OFONO_ATOM_TYPE_SIM_AUTH,
 	OFONO_ATOM_TYPE_EMULATOR_DUN,
 	OFONO_ATOM_TYPE_EMULATOR_HFP,
+	OFONO_ATOM_TYPE_EMULATOR_HSP,
 	OFONO_ATOM_TYPE_LOCATION_REPORTING,
 };
 
Signature · 1 line
1.7.1
#7 lore raw

PATCH v2 4/9 hsp_ag: Initial plugin commit

In reply to Frédéric Dalleau
---
 Makefile.am      |    3 +
 plugins/hsp_ag.c |  115 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 118 insertions(+), 0 deletions(-)
 create mode 100644 plugins/hsp_ag.c
Makefile.am +3 -0
index 79bf364..50e7e96 100644
@@ -335,6 +335,9 @@ builtin_sources += plugins/hfp_ag.c plugins/bluetooth.h
 builtin_modules += dun_gw
 builtin_sources += plugins/dun_gw.c plugins/bluetooth.h
 
+builtin_modules += hsp_ag
+builtin_sources += plugins/hsp_ag.c plugins/bluetooth.h
+
 builtin_sources += $(btio_sources)
 builtin_cflags += @BLUEZ_CFLAGS@
 builtin_libadd += @BLUEZ_LIBS@
plugins/hsp_ag.c new file +115 -0

115 lines not on this page · raw message

Signature · 1 line
1.7.1
#8 lore raw

PATCH v2 5/9 hsp_ag: add modem watch

In reply to Frédéric Dalleau
---
 plugins/hsp_ag.c |   76 +++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 67 insertions(+), 9 deletions(-)
plugins/hsp_ag.c +67 -9
index a8e6f40..5a60269 100644
@@ -47,7 +47,9 @@
 
 #define HSP_RFCOMM_CHAN 17
 
-static struct server *hsp;
+static struct server *server;
+static guint modemwatch_id;
+static GList *modems;
 
 static const gchar *hsp_record =
 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
@@ -90,25 +92,81 @@ static const gchar *hsp_record =
 " </attribute>\n"
 "</record>\n";
 
-static void connect_cb(GIOChannel *channel, GError *err, gpointer user_data)
+static void connect_cb(GIOChannel *channel, GError *err, gpointer data)
+{	int fd;
+	struct ofono_emulator *em;
+	struct ofono_modem *modem;
+
+	/* Pick the first powered modem */
+	modem = modems->data;
+	DBG("Picked modem %p for emulator", modem);
+
+	em = ofono_emulator_create(modem, OFONO_EMULATOR_TYPE_HSP);
+	if (em == NULL)
+		return;
+
+	fd = g_io_channel_unix_get_fd(channel);
+
+	ofono_emulator_register(em, fd);
+
+	g_io_channel_set_close_on_unref(channel, FALSE);
+}
+
+static void voicecall_watch(struct ofono_atom *atom,
+				enum ofono_atom_watch_condition cond,
+				void *data)
 {
+	struct ofono_modem *modem = data;
+
+	if (cond == OFONO_ATOM_WATCH_CONDITION_REGISTERED) {
+		modems = g_list_append(modems, modem);
+
+		if (modems->next == NULL)
+			server = bluetooth_register_server(HSP_RFCOMM_CHAN,
+							hsp_record,
+							connect_cb,
+							NULL);
+	} else {
+		modems = g_list_remove(modems, modem);
+		if (modems == NULL &&  server != NULL) {
+			bluetooth_unregister_server(server);
+			server = NULL;
+		}
+	}
 }
 
-static int hsp_ag_init(void)
+static void modem_watch(struct ofono_modem *modem, gboolean added, void *user)
 {
-	hsp = bluetooth_register_server(HSP_RFCOMM_CHAN, hsp_record, connect_cb, NULL);
+	DBG("modem: %p, added: %d", modem, added);
 
-	if(!hsp)
-		return -1;
+	if (added == FALSE)
+		return;
+
+	__ofono_modem_add_atom_watch(modem, OFONO_ATOM_TYPE_VOICECALL,
+					voicecall_watch, modem, NULL);
+}
+
+static void call_modemwatch(struct ofono_modem *modem, void *user)
+{
+	modem_watch(modem, TRUE, user);
+}
+
+static int hsp_ag_init(void)
+{
+	modemwatch_id = __ofono_modemwatch_add(modem_watch, NULL, NULL);
+	__ofono_modem_foreach(call_modemwatch, NULL);
 
-	DBG("HSP Gateway profile starting");
 	return 0;
 }
 
 static void hsp_ag_exit(void)
 {
-	if(hsp)
-		bluetooth_unregister_server(hsp);
+	__ofono_modemwatch_remove(modemwatch_id);
+
+	if (server) {
+		bluetooth_unregister_server(server);
+		server = NULL;
+	}
 }
 
 OFONO_PLUGIN_DEFINE(hsp_ag, "Headset Gateway Profile", VERSION,
Signature · 1 line
1.7.1
#9 lore raw

PATCH v2 6/9 emulator: add CKPD support

In reply to Frédéric Dalleau
---
 src/emulator.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
src/emulator.c +30 -0
index ce3fabd..1d4fbc6 100644
@@ -387,6 +387,34 @@ fail:
 	}
 }
 
+static void ckpd_cb(GAtServer *server, GAtServerRequestType type,
+			GAtResult *result, gpointer user_data)
+{
+	switch (type) {
+	case G_AT_SERVER_REQUEST_TYPE_SET:
+	{
+		GAtResultIter iter;
+		int key;
+		g_at_result_iter_init(&iter, result);
+		g_at_result_iter_next(&iter, "");
+
+		if (g_at_result_iter_next_number(&iter, &key) == FALSE)
+			goto fail;
+
+		if (key != 200)
+			goto fail;
+
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+		break;
+	}
+
+	default:
+fail:
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
+		break;
+	}
+}
+
 static void emulator_add_indicator(struct ofono_emulator *em, const char* name,
 					int min, int max, int dflt)
 {
@@ -462,6 +490,8 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
 		g_at_server_register(em->server, "+BRSF", brsf_cb, em, NULL);
 		g_at_server_register(em->server, "+CIND", cind_cb, em, NULL);
 		g_at_server_register(em->server, "+CMER", cmer_cb, em, NULL);
+	} else if (em->type == OFONO_EMULATOR_TYPE_HSP) {
+		g_at_server_register(em->server, "+CKPD", ckpd_cb, em, NULL);
 	}
 
 	__ofono_atom_register(em->atom, emulator_unregister);
Signature · 1 line
1.7.1
#13 lore raw

PATCH v2 7/9 emulator: add audio connection API

In reply to Frédéric Dalleau
---
 include/emulator.h |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
include/emulator.h +7 -0
index e010606..1657f56 100644
@@ -56,6 +56,9 @@ typedef void (*ofono_emulator_request_cb_t)(struct ofono_emulator *em,
 					struct ofono_emulator_request *req,
 					void *data);
 
+typedef void (*ofono_emulator_audio_conn_cb_t)(struct ofono_emulator *em,
+					void *data);
+
 struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
 						enum ofono_emulator_type type);
 
@@ -94,6 +97,10 @@ enum ofono_emulator_request_type ofono_emulator_request_get_type(
 void ofono_emulator_set_indicator(struct ofono_emulator *em,
 					const char *name, int value);
 
+void ofono_emulator_set_audio_connect_handler(struct ofono_emulator *em,
+					ofono_emulator_audio_conn_cb_t cb,
+					void *user_data);
+
 #ifdef __cplusplus
 }
 #endif
Signature · 1 line
1.7.1
#14 lore raw

PATCH v2 8/9 emulator: implement audio connection API

In reply to Frédéric Dalleau
---
 src/emulator.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
src/emulator.c +16 -0
index 1d4fbc6..2f39599 100644
@@ -49,6 +49,9 @@ struct ofono_emulator {
 	int events_mode;
 	gboolean events_ind;
 	GSList *indicators;
+	void *user_data;
+	ofono_emulator_audio_conn_cb_t conn_cb;
+	void *conn_user_data;
 };
 
 struct indicator {
@@ -390,6 +393,8 @@ fail:
 static void ckpd_cb(GAtServer *server, GAtServerRequestType type,
 			GAtResult *result, gpointer user_data)
 {
+	struct ofono_emulator *em = user_data;
+
 	switch (type) {
 	case G_AT_SERVER_REQUEST_TYPE_SET:
 	{
@@ -404,6 +409,9 @@ static void ckpd_cb(GAtServer *server, GAtServerRequestType type,
 		if (key != 200)
 			goto fail;
 
+		if(em->conn_cb != NULL)
+			em->conn_cb(em, em->conn_user_data);
+
 		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
 		break;
 	}
@@ -734,3 +742,11 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
 		return;
 	}
 }
+
+void ofono_emulator_set_audio_connect_handler(struct ofono_emulator *em,
+					ofono_emulator_audio_conn_cb_t cb,
+					void *user_data)
+{
+	em->conn_cb = cb;
+	em->conn_user_data = user_data;
+}
Signature · 1 line
1.7.1
#15 lore raw

PATCH v2 9/9 hsp_ag: add audio connection support

In reply to Frédéric Dalleau
---
 plugins/hsp_ag.c |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)
plugins/hsp_ag.c +27 -0
index 5a60269..73050aa 100644
@@ -92,10 +92,30 @@ static const gchar *hsp_record =
 " </attribute>\n"
 "</record>\n";
 
+static gboolean sco_unregister_cb(GIOChannel *channel,
+					GIOCondition cond, gpointer data)
+{
+	struct sco *sco = data;
+
+	if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
+		sco_unregister_server(sco);
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static void audio_connect_cb(struct ofono_emulator *em, void *data)
+{
+	struct sco *sco = data;
+	sco_connect(sco);
+}
+
 static void connect_cb(GIOChannel *channel, GError *err, gpointer data)
 {	int fd;
 	struct ofono_emulator *em;
 	struct ofono_modem *modem;
+	struct sco *sco;
 
 	/* Pick the first powered modem */
 	modem = modems->data;
@@ -110,6 +130,13 @@ static void connect_cb(GIOChannel *channel, GError *err, gpointer data)
 	ofono_emulator_register(em, fd);
 
 	g_io_channel_set_close_on_unref(channel, FALSE);
+
+	sco = sco_register_server(channel);
+
+	ofono_emulator_set_audio_connect_handler(em, audio_connect_cb, sco);
+
+	g_io_add_watch(channel,	G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+						sco_unregister_cb, sco);
 }
 
 static void voicecall_watch(struct ofono_atom *atom,
Signature · 1 line
1.7.1
#10 lore raw

Re: [PATCH v2 6/9] emulator: add CKPD support

In reply to Frédéric Dalleau

Hi Frédéric,

Quoted 29 lines · Frédéric Dalleau
---
 src/emulator.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
src/emulator.c +17 -0
index ce3fabd..1d4fbc6 100644
@@ -387,6 +387,34 @@ fail:
 	}
 }
 
+static void ckpd_cb(GAtServer *server, GAtServerRequestType type,
+			GAtResult *result, gpointer user_data)
+{
+	switch (type) {
+	case G_AT_SERVER_REQUEST_TYPE_SET:
+	{
+		GAtResultIter iter;
+		int key;
+		g_at_result_iter_init(&iter, result);
+		g_at_result_iter_next(&iter, "");
+
+		if (g_at_result_iter_next_number(&iter, &key) == FALSE)
+			goto fail;
+
+		if (key != 200)
+			goto fail;
+

src/emulator.c fail: · line 416

Quoted 10 lines
src/emulator.c +10 -0
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+		break;
+	}
+
+	default:
+fail:
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
+		break;
+	}
+}

Do you have a plan on what to do with these key presses?

src/emulator.c void ofono_emulator_register(struct ofono_emulator *em, int fd) · line 497

Quoted 13 lines
src/emulator.c +3 -0
+
 static void emulator_add_indicator(struct ofono_emulator *em, const char* name,
 					int min, int max, int dflt)
 {
@@ -462,6 +490,8 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
 		g_at_server_register(em->server, "+BRSF", brsf_cb, em, NULL);
 		g_at_server_register(em->server, "+CIND", cind_cb, em, NULL);
 		g_at_server_register(em->server, "+CMER", cmer_cb, em, NULL);
+	} else if (em->type == OFONO_EMULATOR_TYPE_HSP) {
+		g_at_server_register(em->server, "+CKPD", ckpd_cb, em, NULL);
 	}
 
 	__ofono_atom_register(em->atom, emulator_unregister);

Regards,
-Denis

#2 lore raw

Re: [PATCH v2 1/9] bluetooth: add functions for sco connection

In reply to Frédéric Dalleau

Hi Frédéric,

Quoted 5 lines · Frédéric Dalleau
---
 plugins/bluetooth.c |  122 +++++++++++++++++++++++++++++++++++++++++++++++++++
 plugins/bluetooth.h |    7 +++
 2 files changed, 129 insertions(+), 0 deletions(-)

So before you run too far with this I suggest you speak to Marcel and Johan on whether handling SCO audio inside oFono is a good idea. Personally I'd rather see this piece remain inside BlueZ, but I'm no longer an expert in this area.

Regards,
-Denis

#3 lore raw

Re: [PATCH v2 1/9] bluetooth: add functions for sco connection

Hi,

Quoted 9 lines · Denis Kenzior
Quoted 4 lines
---
 plugins/bluetooth.c |  122 +++++++++++++++++++++++++++++++++++++++++++++++++++
 plugins/bluetooth.h |    7 +++
 2 files changed, 129 insertions(+), 0 deletions(-)

So before you run too far with this I suggest you speak to Marcel and Johan on whether handling SCO audio inside oFono is a good idea. Personally I'd rather see this piece remain inside BlueZ, but I'm no longer an expert in this area.

AFAIK the plan is still to have only one interface towards PulseAudio as far as Bluetooth audio is concerned, and that's the Media interface in BlueZ. So oFono shouldn't need any SCO support as such. What will be needed though is for oFono to indicate to BlueZ once the SLC establishment signaling commands are complete (so SCO connections are neither accepted nor initiated before that) as well as for BlueZ to indicate to oFono when SCO has been established (so e.g. RING indications aren't sent prematurely in the case of in-band ring tone).

Johan

#16 lore raw
In reply to Frédéric Dalleau

Hi Frederic,

2011/3/17 Frédéric Dalleau <[email protected]>:

Quoted 9 lines

This patch will start providing an HSP profile implementation in oFono. This is work in progress, and based of what was done for HFP profile. Finally added the audio connection, that will provide a base for discussion. To avoid emulator depend upon btio, there is a callback fom the emulator to the hsp plugin to connect audio,

Some question remains :

* How should pulse audio be notified?

I suppose we should use the Media API to notify PA, it is already upstream, in that case oFono doesn't need to deal with SCO at all. If that is the plan then I suggest we first define a D-Bus spec on how to signal things like SLC and NREC to BlueZ, the record and socket listening/connection handling logic could also be done in BlueZ side so we use D-Bus to transfer the fd to oFono.

Quoted 1 line

* What is the behavior of hsp when receiving CKPD=200?

This is what oFono does in BlueZ:

void telephony_key_press_req(void *telephony_device, const char *keys)

{
	struct voice_call *active, *waiting;
	int err;

	DBG("telephony-ofono: got key press request for %s", keys);

	waiting = find_vc_with_status(CALL_STATUS_INCOMING);
	if (!waiting)
		waiting = find_vc_with_status(CALL_STATUS_DIALING);

	active = find_vc_with_status(CALL_STATUS_ACTIVE);

	if (waiting)
		err = answer_call(waiting);
	else if (active)
		err = release_call(active);
	else
		err = 0;

	if (err < 0)
		telephony_key_press_rsp(telephony_device,
							CME_ERROR_AG_FAILURE);
	else
		telephony_key_press_rsp(telephony_device, CME_ERROR_NONE);
}
Quoted 28 lines

Next step will be to dial/hangup a call.

Frédéric Dalleau (9):
 bluetooth: add functions for sco connection
 emulator: add hsp emulator type
 hsp_ag: add hsp atom type
 hsp_ag: Initial plugin commit
 hsp_ag: add modem watch
 emulator: add CKPD support
 emulator: add audio connection API
 emulator: implement audio connection API
 hsp_ag: add audio connection support

 Makefile.am         |    3 +
 include/emulator.h  |    8 ++
 plugins/bluetooth.c |  122 +++++++++++++++++++++++++++++++ plugins/bluetooth.h |    7 ++
 plugins/hsp_ag.c    |  200 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/emulator.c      |   50 +++++++++++++
 src/ofono.h         |    1 +

 7 files changed, 391 insertions(+), 0 deletions(-)

 create mode 100644 plugins/hsp_ag.c

_______________________________________________
ofono mailing list
ofono(a)ofono.org
http://lists.ofono.org/listinfo/ofono

Signature · 2 lines
Luiz Augusto von Dentz
Computer Engineer
#4 lore raw

Re: [PATCH v2 1/9] bluetooth: add functions for sco connection

In reply to Johan Hedberg

Hi Johan,

Quoted 3 lines

AFAIK the plan is still to have only one interface towards PulseAudio as far as Bluetooth audio is concerned, and that's the Media interface in BlueZ. So oFono shouldn't need any SCO support as such.

Thanks for feedback,

My understanding was that profiles had to be prototyped using btio, then moving to use bluez over dbus similar to hfp handsfree implementation. I have no real idea when this transition could occur...

Frédéric

#17 lore raw
In reply to Luiz Augusto von Dentz

Hi Luiz,

Quoted 4 lines

that is the plan then I suggest we first define a D-Bus spec on how to signal things like SLC and NREC to BlueZ, the record and socket listening/connection handling logic could also be done in BlueZ side so we use D-Bus to transfer the fd to oFono.

I didn't expect that yet, but if everybody agrees, why not!

Quoted 8 lines
Quoted 1 line

* What is the behavior of hsp when receiving CKPD=200?

This is what oFono does in BlueZ:

	if (waiting)
		err = answer_call(waiting);
	else if (active)
		err = release_call(active);
	else
		err = 0;

I'm fine with it!
If there is no call setup, is it worth trying to enable voice recognition?

Thanks,
Frédéric

#11 lore raw

Re: [PATCH v2 6/9] emulator: add CKPD support

In reply to Denis Kenzior
Quoted 1 line · Denis Kenzior

Do you have a plan on what to do with these key presses?

I was thinking about "Answer incoming call, audio transfer, and some funky double tap to release active call", but luiz suggested "Answer incoming call and release active call".

Are you trying to tell me this should go into voice call atom?

Frédéric

#12 lore raw

Re: [PATCH v2 6/9] emulator: add CKPD support

Hi Frédéric,

Quoted 7 lines · Frédéric Dalleau
Quoted 1 line · Denis Kenzior

Do you have a plan on what to do with these key presses?

I was thinking about "Answer incoming call, audio transfer, and some funky double tap to release active call", but luiz suggested "Answer incoming call and release active call".

Are you trying to tell me this should go into voice call atom?

No, I was just wondering. I have not spent any time thinking of HSP, but you also have to remember that there might be potential VoIP usecases with it as well.

Regards,
-Denis