Return-Path: Message-ID: <47581231.3010505@access-company.com> Date: Thu, 06 Dec 2007 16:16:01 +0100 From: =?ISO-8859-1?Q?Fr=E9d=E9ric_Dalleau?= MIME-Version: 1.0 To: BlueZ development References: <4757DCBD.40602@access-company.com> <1196941226.12292.192.camel@violet> In-Reply-To: <1196941226.12292.192.camel@violet> Content-Type: multipart/mixed; boundary="------------090909000705020901050508" Subject: Re: [Bluez-devel] [Patch] org.bluez.audio.headset.Connect() to handsfree Reply-To: BlueZ development List-Id: BlueZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: bluez-devel-bounces@lists.sourceforge.net Errors-To: bluez-devel-bounces@lists.sourceforge.net This is a multi-part message in MIME format. --------------090909000705020901050508 Content-Type: multipart/alternative; boundary="------------090105080808090506050709" --------------090105080808090506050709 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Right! Here is an updated patch. It adds a parameter to headset_init() to know whether hfp is enabled or not. Let me know what you think, Regards, Frederic Marcel Holtmann wrote: > Hi Frederic, > > >> As of today, when calling org.bluez.audio.headset.Connect(), the hfp >> profile is searched only if the headset->hfp_handle is initialized. >> This member variable is initialized upon CreateDevice the first time the >> device is created (during resolve_services). >> The variable is not initialized when the audio service is restarted, so >> after restarting audio service, it is no longer possible to connect to hfp. >> > > we had to disable HFP with a config setting since we are not fully > supporting it at the moment. So this must depend on the config setting > if we search for HFP and if we consider it for the connect. By default > we only support HSP. > > Regards > > Marcel > > > > > ------------------------------------------------------------------------- > SF.Net email is sponsored by: The Future of Linux Business White Paper > from Novell. From the desktop to the data center, Linux is going > mainstream. Let it simplify your IT future. > http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 > _______________________________________________ > Bluez-devel mailing list > Bluez-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/bluez-devel > --------------090105080808090506050709 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Right!

Here is an updated patch. It adds a parameter to headset_init() to know whether hfp is enabled or not.

Let me know what you think,
Regards,

Frederic


Marcel Holtmann wrote:
Hi Frederic,

  
As of today, when calling org.bluez.audio.headset.Connect(), the hfp 
profile is searched only if the headset->hfp_handle is initialized.
This member variable is initialized upon CreateDevice the first time the 
device is created (during resolve_services).
The variable is not initialized when the audio service is restarted, so 
after restarting audio service, it is no longer possible to connect to hfp.
    

we had to disable HFP with a config setting since we are not fully
supporting it at the moment. So this must depend on the config setting
if we search for HFP and if we consider it for the connect. By default
we only support HSP.

Regards

Marcel




-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
  

--------------090105080808090506050709-- --------------090909000705020901050508 Content-Type: text/x-patch; name="handsfreeconnect.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="handsfreeconnect.patch" diff --git a/audio/headset.c b/audio/headset.c index 6cb5406..98d2836 100644 --- a/audio/headset.c +++ b/audio/headset.c @@ -99,6 +99,7 @@ struct headset { int data_start; int data_length; + int enable_hfp; headset_type_t type; headset_state_t state; @@ -111,6 +112,7 @@ struct headset { }; static int rfcomm_connect(struct device *device, struct pending_connect *c); +static int get_handles(struct device *device, struct pending_connect *c); static void pending_connect_free(struct pending_connect *c) { @@ -640,11 +642,21 @@ static void get_record_reply(DBusPendingCall *call, void *data) goto failed_not_supported; } - if ((uuid.type == SDP_UUID32 && + if (hs->type == SVC_HEADSET && + ((uuid.type == SDP_UUID32 && uuid.value.uuid32 != HEADSET_SVCLASS_ID) || (uuid.type == SDP_UUID16 && - uuid.value.uuid16 != HEADSET_SVCLASS_ID)) { - error("Service classes did not contain the expected UUID"); + uuid.value.uuid16 != HEADSET_SVCLASS_ID))) { + error("Service classes did not contain the expected UUID hsp"); + goto failed_not_supported; + } + + if (hs->type == SVC_HANDSFREE && + ((uuid.type == SDP_UUID32 && + uuid.value.uuid32 != HANDSFREE_SVCLASS_ID) || + (uuid.type == SDP_UUID16 && + uuid.value.uuid16 != HANDSFREE_SVCLASS_ID))) { + error("Service classes did not contain the expected UUID hfp"); goto failed_not_supported; } @@ -750,7 +762,17 @@ static void get_handles_reply(DBusPendingCall *call, void *data) } if (array_len < 1) { - debug("No record handles found"); + + if(hs->type == SVC_HANDSFREE) { + debug("No record handles found for hfp"); + hs->type = SVC_HEADSET; + get_handles(device, c); + dbus_message_unref(reply); + return; + } + + debug("No record handles found for hsp"); + if (c->msg) error_not_supported(device->conn, c->msg); goto failed; @@ -862,7 +884,7 @@ static int rfcomm_connect(struct device *device, struct pending_connect *c) if (!g_slist_find(hs->pending, c)) hs->pending = g_slist_append(hs->pending, c); - hs->type = hs->hfp_handle ? SVC_HANDSFREE : SVC_HEADSET; + hs->type = hs->enable_hfp ? SVC_HANDSFREE : SVC_HEADSET; if (hs->state == HEADSET_STATE_DISCONNECTED) return get_handles(device, c); @@ -1368,8 +1390,8 @@ void headset_update(struct device *dev, sdp_record_t *record, uint16_t svc) headset_set_channel(headset, record); } -struct headset *headset_init(struct device *dev, sdp_record_t *record, - uint16_t svc) +struct headset *headset_init(struct device *dev, int enable_hfp, + sdp_record_t *record, uint16_t svc) { struct headset *hs; @@ -1377,6 +1399,7 @@ struct headset *headset_init(struct device *dev, sdp_record_t *record, hs->rfcomm_ch = -1; hs->sp_gain = -1; hs->mic_gain = -1; + hs->enable_hfp = enable_hfp; if (!record) goto register_iface; diff --git a/audio/headset.h b/audio/headset.h index 5e19cd9..b151dbd 100644 --- a/audio/headset.h +++ b/audio/headset.h @@ -54,8 +54,8 @@ typedef enum { typedef void (*headset_stream_cb_t) (struct device *dev, void *user_data); -struct headset *headset_init(struct device *dev, sdp_record_t *record, - uint16_t svc); +struct headset *headset_init(struct device *dev, int enable_hfp, + sdp_record_t *record, uint16_t svc); void headset_free(struct device *dev); diff --git a/audio/manager.c b/audio/manager.c index 507f60a..6f690f9 100644 --- a/audio/manager.c +++ b/audio/manager.c @@ -108,6 +108,7 @@ static GIOChannel *hs_server = NULL; static GIOChannel *hf_server = NULL; static const struct enabled_interfaces *enabled; +static gboolean enable_hfp = FALSE; static void get_next_record(struct audio_sdp_data *data); static DBusHandlerResult get_handles(const char *uuid, @@ -213,7 +214,7 @@ done: return uuid16; } -static gboolean server_is_enabled(uint16_t svc) +gboolean server_is_enabled(uint16_t svc) { gboolean ret; @@ -254,6 +255,7 @@ static void handle_record(sdp_record_t *record, struct device *device) headset_update(device, record, uuid16); else device->headset = headset_init(device, + enable_hfp, record, uuid16); break; case HEADSET_AGW_SVCLASS_ID: @@ -265,6 +267,7 @@ static void handle_record(sdp_record_t *record, struct device *device) headset_update(device, record, uuid16); else device->headset = headset_init(device, + enable_hfp, record, uuid16); break; case HANDSFREE_AGW_SVCLASS_ID: @@ -645,7 +648,7 @@ struct device *manager_device_connected(bdaddr_t *bda, const char *uuid) if (device->headset) return device; - device->headset = headset_init(device, NULL, 0); + device->headset = headset_init(device, enable_hfp, NULL, 0); if (!device->headset) return NULL; @@ -1070,7 +1073,7 @@ static void parse_stored_devices(char *key, char *value, void *data) bacpy(&device->store, src); if (enabled->headset && strstr(value, "headset")) - device->headset = headset_init(device, NULL, 0); + device->headset = headset_init(device, enable_hfp, NULL, 0); if (enabled->sink && strstr(value, "sink")) device->sink = sink_init(device); if (enabled->control && strstr(value, "control")) @@ -1561,6 +1564,8 @@ static int headset_server_init(DBusConnection *conn, gboolean no_hfp) if (no_hfp) return 0; + enable_hfp = TRUE; + chan = DEFAULT_HF_AG_CHANNEL; hf_server = server_socket(&chan); --------------090909000705020901050508 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 --------------090909000705020901050508 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel --------------090909000705020901050508--