Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 0/3] android/handsfree: Support multiply devices
@ 2014-11-13 15:52 Lukasz Rymanowski
  2014-11-13 15:52 ` [PATCH 1/3] android/handsfree: Send indicator notif to all connected devices Lukasz Rymanowski
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Lukasz Rymanowski @ 2014-11-13 15:52 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Lukasz Rymanowski

With those patches multilpy handsfree devices supports should be completed.

Compile tested.

Lukasz Rymanowski (3):
  android/handsfree: Send indicator notif to all connected devices
  android/handsfree: Send phone state to all connected devices
  android/handsfree: Remove find default device

 android/handsfree.c | 81 ++++++++++++++++++++++++++++-------------------------
 1 file changed, 43 insertions(+), 38 deletions(-)

-- 
1.8.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] android/handsfree: Send indicator notif to all connected devices
  2014-11-13 15:52 [PATCH 0/3] android/handsfree: Support multiply devices Lukasz Rymanowski
@ 2014-11-13 15:52 ` Lukasz Rymanowski
  2014-11-13 17:14   ` Szymon Janc
  2014-11-13 15:52 ` [PATCH 2/3] android/handsfree: Send phone state " Lukasz Rymanowski
  2014-11-13 15:52 ` [PATCH 3/3] android/handsfree: Remove find default device Lukasz Rymanowski
  2 siblings, 1 reply; 7+ messages in thread
From: Lukasz Rymanowski @ 2014-11-13 15:52 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Lukasz Rymanowski

---
 android/handsfree.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/android/handsfree.c b/android/handsfree.c
index 9a2fdd0..0001eb6 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -2038,24 +2038,31 @@ static void update_indicator(struct hf_device *dev, int ind, uint8_t val)
 	hfp_gw_send_info(dev->gw, "+CIEV: %u,%u", ind + 1, val);
 }
 
+static void device_status_notif(void *data, void *user_data)
+{
+	struct hf_device *dev = data;
+	struct hal_cmd_handsfree_device_status_notif *cmd = user_data;
+
+	update_indicator(dev, IND_SERVICE, cmd->state);
+	update_indicator(dev, IND_ROAM, cmd->type);
+	update_indicator(dev, IND_SIGNAL, cmd->signal);
+	update_indicator(dev, IND_BATTCHG, cmd->battery);
+}
+
 static void handle_device_status_notif(const void *buf, uint16_t len)
 {
 	const struct hal_cmd_handsfree_device_status_notif *cmd = buf;
-	struct hf_device *dev;
 	uint8_t status;
 
 	DBG("");
 
-	dev = find_default_device();
-	if (!dev) {
+	if (queue_isempty(devices)) {
 		status = HAL_STATUS_FAILED;
 		goto done;
 	}
 
-	update_indicator(dev, IND_SERVICE, cmd->state);
-	update_indicator(dev, IND_ROAM, cmd->type);
-	update_indicator(dev, IND_SIGNAL, cmd->signal);
-	update_indicator(dev, IND_BATTCHG, cmd->battery);
+	/* Cast cmd to void as queue api needs that */
+	queue_foreach(devices, device_status_notif, (void *) cmd);
 
 	status = HAL_STATUS_SUCCESS;
 
-- 
1.8.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] android/handsfree: Send phone state to all connected devices
  2014-11-13 15:52 [PATCH 0/3] android/handsfree: Support multiply devices Lukasz Rymanowski
  2014-11-13 15:52 ` [PATCH 1/3] android/handsfree: Send indicator notif to all connected devices Lukasz Rymanowski
@ 2014-11-13 15:52 ` Lukasz Rymanowski
  2014-11-13 15:52 ` [PATCH 3/3] android/handsfree: Remove find default device Lukasz Rymanowski
  2 siblings, 0 replies; 7+ messages in thread
From: Lukasz Rymanowski @ 2014-11-13 15:52 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Lukasz Rymanowski

---
 android/handsfree.c | 51 +++++++++++++++++++++++++++++----------------------
 1 file changed, 29 insertions(+), 22 deletions(-)

diff --git a/android/handsfree.c b/android/handsfree.c
index 0001eb6..9bb8f43 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -2485,27 +2485,10 @@ static void phone_state_idle(struct hf_device *dev, int num_active,
 	}
 }
 
-static void handle_phone_state_change(const void *buf, uint16_t len)
+static void phone_state_change(void *data, void *user_data)
 {
-	const struct hal_cmd_handsfree_phone_state_change *cmd = buf;
-	struct hf_device *dev;
-	uint8_t status;
-
-	if (len != sizeof(*cmd) + cmd->number_len || (cmd->number_len != 0 &&
-				cmd->number[cmd->number_len - 1] != '\0')) {
-		error("Invalid phone state change command, terminating");
-		raise(SIGTERM);
-		return;
-	}
-
-	DBG("active=%u hold=%u state=%u", cmd->num_active, cmd->num_held,
-								cmd->state);
-
-	dev = find_default_device();
-	if (!dev) {
-		status = HAL_STATUS_FAILED;
-		goto failed;
-	}
+	struct hf_device *dev = data;
+	struct hal_cmd_handsfree_phone_state_change *cmd = user_data;
 
 	switch (cmd->state) {
 	case HAL_HANDSFREE_CALL_STATE_DIALING:
@@ -2526,14 +2509,38 @@ static void handle_phone_state_change(const void *buf, uint16_t len)
 		DBG("unhandled new state %u (current state %u)", cmd->state,
 							dev->setup_state);
 
-		status = HAL_STATUS_FAILED;
-		goto failed;
+		return;
 	}
 
 	dev->num_active = cmd->num_active;
 	dev->num_held = cmd->num_held;
 	dev->setup_state = cmd->state;
 
+}
+
+static void handle_phone_state_change(const void *buf, uint16_t len)
+{
+	const struct hal_cmd_handsfree_phone_state_change *cmd = buf;
+	uint8_t status;
+
+	if (len != sizeof(*cmd) + cmd->number_len || (cmd->number_len != 0 &&
+				cmd->number[cmd->number_len - 1] != '\0')) {
+		error("Invalid phone state change command, terminating");
+		raise(SIGTERM);
+		return;
+	}
+
+	DBG("active=%u hold=%u state=%u", cmd->num_active, cmd->num_held,
+								cmd->state);
+
+	if (queue_isempty(devices)) {
+		status = HAL_STATUS_FAILED;
+		goto failed;
+	}
+
+	/* Cast cmd to void as queue api needs that */
+	queue_foreach(devices, phone_state_change, (void *) cmd);
+
 	status = HAL_STATUS_SUCCESS;
 
 failed:
-- 
1.8.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] android/handsfree: Remove find default device
  2014-11-13 15:52 [PATCH 0/3] android/handsfree: Support multiply devices Lukasz Rymanowski
  2014-11-13 15:52 ` [PATCH 1/3] android/handsfree: Send indicator notif to all connected devices Lukasz Rymanowski
  2014-11-13 15:52 ` [PATCH 2/3] android/handsfree: Send phone state " Lukasz Rymanowski
@ 2014-11-13 15:52 ` Lukasz Rymanowski
  2014-11-13 15:58   ` Lukasz Rymanowski
  2 siblings, 1 reply; 7+ messages in thread
From: Lukasz Rymanowski @ 2014-11-13 15:52 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Lukasz Rymanowski

Now when Android provide bdaddr in all hfp calls we can remove
find_defaul_device. We can use bdaddr to find device on the device
queue.
---
 android/handsfree.c | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/android/handsfree.c b/android/handsfree.c
index 9bb8f43..2c7d53d 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -273,13 +273,6 @@ static void device_destroy(struct hf_device *dev)
 	free(dev);
 }
 
-static struct hf_device *find_default_device(void)
-{
-	/* TODO should be replaced by find_device() eventually */
-
-	return queue_peek_head(devices);
-}
-
 static bool match_by_bdaddr(const void *data, const void *match_data)
 {
 	const struct hf_device *dev = data;
@@ -290,8 +283,6 @@ static bool match_by_bdaddr(const void *data, const void *match_data)
 
 static struct hf_device *find_device(const bdaddr_t *bdaddr)
 {
-	if (!bacmp(bdaddr, BDADDR_ANY))
-		return find_default_device();
 
 	return queue_find(devices, match_by_bdaddr, bdaddr);
 }
-- 
1.8.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] android/handsfree: Remove find default device
  2014-11-13 15:52 ` [PATCH 3/3] android/handsfree: Remove find default device Lukasz Rymanowski
@ 2014-11-13 15:58   ` Lukasz Rymanowski
  0 siblings, 0 replies; 7+ messages in thread
From: Lukasz Rymanowski @ 2014-11-13 15:58 UTC (permalink / raw)
  To: linux-bluetooth@vger.kernel.org; +Cc: Lukasz Rymanowski

Hi,

On 13 November 2014 16:52, Lukasz Rymanowski
<lukasz.rymanowski@tieto.com> wrote:
> Now when Android provide bdaddr in all hfp calls we can remove
> find_defaul_device. We can use bdaddr to find device on the device
> queue.
> ---

Ignore this patch. Just realized that we need this for kitkat support

\Lukasz

>  android/handsfree.c | 9 ---------
>  1 file changed, 9 deletions(-)
>
> diff --git a/android/handsfree.c b/android/handsfree.c
> index 9bb8f43..2c7d53d 100644
> --- a/android/handsfree.c
> +++ b/android/handsfree.c
> @@ -273,13 +273,6 @@ static void device_destroy(struct hf_device *dev)
>         free(dev);
>  }
>
> -static struct hf_device *find_default_device(void)
> -{
> -       /* TODO should be replaced by find_device() eventually */
> -
> -       return queue_peek_head(devices);
> -}
> -
>  static bool match_by_bdaddr(const void *data, const void *match_data)
>  {
>         const struct hf_device *dev = data;
> @@ -290,8 +283,6 @@ static bool match_by_bdaddr(const void *data, const void *match_data)
>
>  static struct hf_device *find_device(const bdaddr_t *bdaddr)
>  {
> -       if (!bacmp(bdaddr, BDADDR_ANY))
> -               return find_default_device();
>
>         return queue_find(devices, match_by_bdaddr, bdaddr);
>  }
> --
> 1.8.4
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] android/handsfree: Send indicator notif to all connected devices
  2014-11-13 15:52 ` [PATCH 1/3] android/handsfree: Send indicator notif to all connected devices Lukasz Rymanowski
@ 2014-11-13 17:14   ` Szymon Janc
  2014-11-13 17:24     ` Szymon Janc
  0 siblings, 1 reply; 7+ messages in thread
From: Szymon Janc @ 2014-11-13 17:14 UTC (permalink / raw)
  To: Lukasz Rymanowski; +Cc: linux-bluetooth

Hi Łukasz,

On Thursday 13 of November 2014 16:52:50 Lukasz Rymanowski wrote:
> ---
>  android/handsfree.c | 21 ++++++++++++++-------
>  1 file changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/android/handsfree.c b/android/handsfree.c
> index 9a2fdd0..0001eb6 100644
> --- a/android/handsfree.c
> +++ b/android/handsfree.c
> @@ -2038,24 +2038,31 @@ static void update_indicator(struct hf_device *dev, int ind, uint8_t val)
>  	hfp_gw_send_info(dev->gw, "+CIEV: %u,%u", ind + 1, val);
>  }
>  
> +static void device_status_notif(void *data, void *user_data)
> +{
> +	struct hf_device *dev = data;
> +	struct hal_cmd_handsfree_device_status_notif *cmd = user_data;

I think we should send this only to devices with SLC established.

> +
> +	update_indicator(dev, IND_SERVICE, cmd->state);
> +	update_indicator(dev, IND_ROAM, cmd->type);
> +	update_indicator(dev, IND_SIGNAL, cmd->signal);
> +	update_indicator(dev, IND_BATTCHG, cmd->battery);
> +}
> +
>  static void handle_device_status_notif(const void *buf, uint16_t len)
>  {
>  	const struct hal_cmd_handsfree_device_status_notif *cmd = buf;
> -	struct hf_device *dev;
>  	uint8_t status;
>  
>  	DBG("");
>  
> -	dev = find_default_device();
> -	if (!dev) {
> +	if (queue_isempty(devices)) {
>  		status = HAL_STATUS_FAILED;
>  		goto done;
>  	}
>  
> -	update_indicator(dev, IND_SERVICE, cmd->state);
> -	update_indicator(dev, IND_ROAM, cmd->type);
> -	update_indicator(dev, IND_SIGNAL, cmd->signal);
> -	update_indicator(dev, IND_BATTCHG, cmd->battery);
> +	/* Cast cmd to void as queue api needs that */
> +	queue_foreach(devices, device_status_notif, (void *) cmd);
>  
>  	status = HAL_STATUS_SUCCESS;
>  
> 

-- 
Best regards, 
Szymon Janc

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] android/handsfree: Send indicator notif to all connected devices
  2014-11-13 17:14   ` Szymon Janc
@ 2014-11-13 17:24     ` Szymon Janc
  0 siblings, 0 replies; 7+ messages in thread
From: Szymon Janc @ 2014-11-13 17:24 UTC (permalink / raw)
  To: Lukasz Rymanowski; +Cc: linux-bluetooth

Hi,

On Thursday 13 of November 2014 18:14:46 Szymon Janc wrote:
> Hi Łukasz,
> 
> On Thursday 13 of November 2014 16:52:50 Lukasz Rymanowski wrote:
> > ---
> >  android/handsfree.c | 21 ++++++++++++++-------
> >  1 file changed, 14 insertions(+), 7 deletions(-)
> > 
> > diff --git a/android/handsfree.c b/android/handsfree.c
> > index 9a2fdd0..0001eb6 100644
> > --- a/android/handsfree.c
> > +++ b/android/handsfree.c
> > @@ -2038,24 +2038,31 @@ static void update_indicator(struct hf_device *dev, int ind, uint8_t val)
> >  	hfp_gw_send_info(dev->gw, "+CIEV: %u,%u", ind + 1, val);
> >  }
> >  
> > +static void device_status_notif(void *data, void *user_data)
> > +{
> > +	struct hf_device *dev = data;
> > +	struct hal_cmd_handsfree_device_status_notif *cmd = user_data;
> 
> I think we should send this only to devices with SLC established.

This is handled by Framework anyway so I've applied patches 1 and 2. Thanks.

> 
> > +
> > +	update_indicator(dev, IND_SERVICE, cmd->state);
> > +	update_indicator(dev, IND_ROAM, cmd->type);
> > +	update_indicator(dev, IND_SIGNAL, cmd->signal);
> > +	update_indicator(dev, IND_BATTCHG, cmd->battery);
> > +}
> > +
> >  static void handle_device_status_notif(const void *buf, uint16_t len)
> >  {
> >  	const struct hal_cmd_handsfree_device_status_notif *cmd = buf;
> > -	struct hf_device *dev;
> >  	uint8_t status;
> >  
> >  	DBG("");
> >  
> > -	dev = find_default_device();
> > -	if (!dev) {
> > +	if (queue_isempty(devices)) {
> >  		status = HAL_STATUS_FAILED;
> >  		goto done;
> >  	}
> >  
> > -	update_indicator(dev, IND_SERVICE, cmd->state);
> > -	update_indicator(dev, IND_ROAM, cmd->type);
> > -	update_indicator(dev, IND_SIGNAL, cmd->signal);
> > -	update_indicator(dev, IND_BATTCHG, cmd->battery);
> > +	/* Cast cmd to void as queue api needs that */
> > +	queue_foreach(devices, device_status_notif, (void *) cmd);
> >  
> >  	status = HAL_STATUS_SUCCESS;
> >  
> > 
> 
> 

-- 
Best regards, 
Szymon Janc

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-11-13 17:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-13 15:52 [PATCH 0/3] android/handsfree: Support multiply devices Lukasz Rymanowski
2014-11-13 15:52 ` [PATCH 1/3] android/handsfree: Send indicator notif to all connected devices Lukasz Rymanowski
2014-11-13 17:14   ` Szymon Janc
2014-11-13 17:24     ` Szymon Janc
2014-11-13 15:52 ` [PATCH 2/3] android/handsfree: Send phone state " Lukasz Rymanowski
2014-11-13 15:52 ` [PATCH 3/3] android/handsfree: Remove find default device Lukasz Rymanowski
2014-11-13 15:58   ` Lukasz Rymanowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox