All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ] client: Fix default controller in interactive mode
@ 2017-08-31  4:23 ERAMOTO Masaya
  2017-08-31  5:02 ` Yunhan Wang
  0 siblings, 1 reply; 5+ messages in thread
From: ERAMOTO Masaya @ 2017-08-31  4:23 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: yunhanw

Since 4e111f3448a126786f3620be1b5ce969456edc65, when a attached adapter
is tried to operate in the interactive mode and another adapter is 
attached newly, the default controller is changed to the another adapter.

In the interactive mode, because the default controller should change by
select command, this patch fixes to not change the default controller
when another adapter is attached.
---
 client/main.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/client/main.c b/client/main.c
index 825647d..7ab95dc 100644
--- a/client/main.c
+++ b/client/main.c
@@ -527,9 +527,14 @@ static void device_added(GDBusProxy *proxy)
 
 static void adapter_added(GDBusProxy *proxy)
 {
-	default_ctrl = g_malloc0(sizeof(struct adapter));
-	default_ctrl->proxy = proxy;
-	ctrl_list = g_list_append(ctrl_list, default_ctrl);
+	struct adapter *adapter = g_malloc0(sizeof(struct adapter));
+
+	adapter->proxy = proxy;
+	ctrl_list = g_list_append(ctrl_list, adapter);
+
+	if (!default_ctrl)
+		default_ctrl = adapter;
+
 	print_adapter(proxy, COLORED_NEW);
 }
 
-- 
2.7.4


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

* Re: [PATCH BlueZ] client: Fix default controller in interactive mode
  2017-08-31  4:23 [PATCH BlueZ] client: Fix default controller in interactive mode ERAMOTO Masaya
@ 2017-08-31  5:02 ` Yunhan Wang
  2017-08-31  8:06   ` ERAMOTO Masaya
  2017-08-31  8:10   ` Luiz Augusto von Dentz
  0 siblings, 2 replies; 5+ messages in thread
From: Yunhan Wang @ 2017-08-31  5:02 UTC (permalink / raw)
  To: ERAMOTO Masaya; +Cc: linux-bluetooth

Hi, ERAMOTO

With this change, when second adapter is enumerated.
default_ctrl->ad_proxy would be assigned with advertising proxy from
second adapter, but default_ctrl->proxy is still first adapter proxy.

Yes, when there are two adapters, the newest adapter is chosen as
default one.  It is not good when you have adapter A in test, and
later attach another adapter B. But if you make all adapters ready
before your test is running, then you can use "select" to choose the
default adapter.

Thanks
Best wishes
Yunhan

On Wed, Aug 30, 2017 at 9:23 PM, ERAMOTO Masaya
<eramoto.masaya@jp.fujitsu.com> wrote:
> Since 4e111f3448a126786f3620be1b5ce969456edc65, when a attached adapter
> is tried to operate in the interactive mode and another adapter is
> attached newly, the default controller is changed to the another adapter.
>
> In the interactive mode, because the default controller should change by
> select command, this patch fixes to not change the default controller
> when another adapter is attached.
> ---
>  client/main.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/client/main.c b/client/main.c
> index 825647d..7ab95dc 100644
> --- a/client/main.c
> +++ b/client/main.c
> @@ -527,9 +527,14 @@ static void device_added(GDBusProxy *proxy)
>
>  static void adapter_added(GDBusProxy *proxy)
>  {
> -       default_ctrl = g_malloc0(sizeof(struct adapter));
> -       default_ctrl->proxy = proxy;
> -       ctrl_list = g_list_append(ctrl_list, default_ctrl);
> +       struct adapter *adapter = g_malloc0(sizeof(struct adapter));
> +
> +       adapter->proxy = proxy;
> +       ctrl_list = g_list_append(ctrl_list, adapter);
> +
> +       if (!default_ctrl)
> +               default_ctrl = adapter;
> +
>         print_adapter(proxy, COLORED_NEW);
>  }
>
> --
> 2.7.4
>

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

* Re: [PATCH BlueZ] client: Fix default controller in interactive mode
  2017-08-31  5:02 ` Yunhan Wang
@ 2017-08-31  8:06   ` ERAMOTO Masaya
  2017-09-01  3:58     ` Yunhan Wang
  2017-08-31  8:10   ` Luiz Augusto von Dentz
  1 sibling, 1 reply; 5+ messages in thread
From: ERAMOTO Masaya @ 2017-08-31  8:06 UTC (permalink / raw)
  To: Yunhan Wang; +Cc: linux-bluetooth

Hi Yunhan,

Thanks for your reply.

On 08/31/2017 02:02 PM, Yunhan Wang wrote:
> Hi, ERAMOTO
> 
> With this change, when second adapter is enumerated.
> default_ctrl->ad_proxy would be assigned with advertising proxy from
> second adapter, but default_ctrl->proxy is still first adapter proxy.

I understood your commit 4e111f3448.

> Yes, when there are two adapters, the newest adapter is chosen as
> default one.  It is not good when you have adapter A in test, and
> later attach another adapter B. But if you make all adapters ready
> before your test is running, then you can use "select" to choose the
> default adapter.

I worry about the case that bluetootctl is not run on test phase
but on operation phase (end-users may attach adapters freely). In
addition, now bluetoothctl seems to be inconsistent when adapters
without advertising (e.g. with only BR/EDR) are used.

Do you have any ideas how to fix this behavior? Or do not we need
to worry about above?


Regards,
Eramoto

> Thanks
> Best wishes
> Yunhan
> 
> On Wed, Aug 30, 2017 at 9:23 PM, ERAMOTO Masaya
> <eramoto.masaya@jp.fujitsu.com> wrote:
>> Since 4e111f3448a126786f3620be1b5ce969456edc65, when a attached adapter
>> is tried to operate in the interactive mode and another adapter is
>> attached newly, the default controller is changed to the another adapter.
>>
>> In the interactive mode, because the default controller should change by
>> select command, this patch fixes to not change the default controller
>> when another adapter is attached.
>> ---
>>  client/main.c | 11 ++++++++---
>>  1 file changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/client/main.c b/client/main.c
>> index 825647d..7ab95dc 100644
>> --- a/client/main.c
>> +++ b/client/main.c
>> @@ -527,9 +527,14 @@ static void device_added(GDBusProxy *proxy)
>>
>>  static void adapter_added(GDBusProxy *proxy)
>>  {
>> -       default_ctrl = g_malloc0(sizeof(struct adapter));
>> -       default_ctrl->proxy = proxy;
>> -       ctrl_list = g_list_append(ctrl_list, default_ctrl);
>> +       struct adapter *adapter = g_malloc0(sizeof(struct adapter));
>> +
>> +       adapter->proxy = proxy;
>> +       ctrl_list = g_list_append(ctrl_list, adapter);
>> +
>> +       if (!default_ctrl)
>> +               default_ctrl = adapter;
>> +
>>         print_adapter(proxy, COLORED_NEW);
>>  }
>>
>> --
>> 2.7.4
>>
> 
> 


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

* Re: [PATCH BlueZ] client: Fix default controller in interactive mode
  2017-08-31  5:02 ` Yunhan Wang
  2017-08-31  8:06   ` ERAMOTO Masaya
@ 2017-08-31  8:10   ` Luiz Augusto von Dentz
  1 sibling, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2017-08-31  8:10 UTC (permalink / raw)
  To: Yunhan Wang; +Cc: ERAMOTO Masaya, linux-bluetooth

Hi Eramoto, Yunhan,

On Thu, Aug 31, 2017 at 8:02 AM, Yunhan Wang <yunhanw@google.com> wrote:
> Hi, ERAMOTO
>
> With this change, when second adapter is enumerated.
> default_ctrl->ad_proxy would be assigned with advertising proxy from
> second adapter, but default_ctrl->proxy is still first adapter proxy.

Sounds like a bug if we cannot detect where the ad proxy should be added.

> Yes, when there are two adapters, the newest adapter is chosen as
> default one.  It is not good when you have adapter A in test, and
> later attach another adapter B. But if you make all adapters ready
> before your test is running, then you can use "select" to choose the
> default adapter.

This is bogus since we are not even printing anything when the default
changes. The user should have full control over what is the selected
adapter, the only exception is when the current default adapter is
removed it should automatically select a new default if there is at
least one available.

> Thanks
> Best wishes
> Yunhan
>
> On Wed, Aug 30, 2017 at 9:23 PM, ERAMOTO Masaya
> <eramoto.masaya@jp.fujitsu.com> wrote:
>> Since 4e111f3448a126786f3620be1b5ce969456edc65, when a attached adapter
>> is tried to operate in the interactive mode and another adapter is
>> attached newly, the default controller is changed to the another adapter.
>>
>> In the interactive mode, because the default controller should change by
>> select command, this patch fixes to not change the default controller
>> when another adapter is attached.
>> ---
>>  client/main.c | 11 ++++++++---
>>  1 file changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/client/main.c b/client/main.c
>> index 825647d..7ab95dc 100644
>> --- a/client/main.c
>> +++ b/client/main.c
>> @@ -527,9 +527,14 @@ static void device_added(GDBusProxy *proxy)
>>
>>  static void adapter_added(GDBusProxy *proxy)
>>  {
>> -       default_ctrl = g_malloc0(sizeof(struct adapter));
>> -       default_ctrl->proxy = proxy;
>> -       ctrl_list = g_list_append(ctrl_list, default_ctrl);
>> +       struct adapter *adapter = g_malloc0(sizeof(struct adapter));
>> +
>> +       adapter->proxy = proxy;
>> +       ctrl_list = g_list_append(ctrl_list, adapter);
>> +
>> +       if (!default_ctrl)
>> +               default_ctrl = adapter;

We might as well print the new add something to print_adapter to tell
if it is the default, also like I mentioned above if the default
adapter is removed we should select a new default and hint it to the
user.

>> +
>>         print_adapter(proxy, COLORED_NEW);
>>  }
>>
>> --
>> 2.7.4
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Luiz Augusto von Dentz

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

* Re: [PATCH BlueZ] client: Fix default controller in interactive mode
  2017-08-31  8:06   ` ERAMOTO Masaya
@ 2017-09-01  3:58     ` Yunhan Wang
  0 siblings, 0 replies; 5+ messages in thread
From: Yunhan Wang @ 2017-09-01  3:58 UTC (permalink / raw)
  To: ERAMOTO Masaya; +Cc: linux-bluetooth

Hi, Luiz and Eramoto

Thanks for comments. Just send the patch to address this issue. Please
kindly have a review.

Best wishes
Yunhan

On Thu, Aug 31, 2017 at 1:06 AM, ERAMOTO Masaya
<eramoto.masaya@jp.fujitsu.com> wrote:
> Hi Yunhan,
>
> Thanks for your reply.
>
> On 08/31/2017 02:02 PM, Yunhan Wang wrote:
>> Hi, ERAMOTO
>>
>> With this change, when second adapter is enumerated.
>> default_ctrl->ad_proxy would be assigned with advertising proxy from
>> second adapter, but default_ctrl->proxy is still first adapter proxy.
>
> I understood your commit 4e111f3448.
>
>> Yes, when there are two adapters, the newest adapter is chosen as
>> default one.  It is not good when you have adapter A in test, and
>> later attach another adapter B. But if you make all adapters ready
>> before your test is running, then you can use "select" to choose the
>> default adapter.
>
> I worry about the case that bluetootctl is not run on test phase
> but on operation phase (end-users may attach adapters freely). In
> addition, now bluetoothctl seems to be inconsistent when adapters
> without advertising (e.g. with only BR/EDR) are used.
>
> Do you have any ideas how to fix this behavior? Or do not we need
> to worry about above?
>
>
> Regards,
> Eramoto
>
>> Thanks
>> Best wishes
>> Yunhan
>>
>> On Wed, Aug 30, 2017 at 9:23 PM, ERAMOTO Masaya
>> <eramoto.masaya@jp.fujitsu.com> wrote:
>>> Since 4e111f3448a126786f3620be1b5ce969456edc65, when a attached adapter
>>> is tried to operate in the interactive mode and another adapter is
>>> attached newly, the default controller is changed to the another adapter.
>>>
>>> In the interactive mode, because the default controller should change by
>>> select command, this patch fixes to not change the default controller
>>> when another adapter is attached.
>>> ---
>>>  client/main.c | 11 ++++++++---
>>>  1 file changed, 8 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/client/main.c b/client/main.c
>>> index 825647d..7ab95dc 100644
>>> --- a/client/main.c
>>> +++ b/client/main.c
>>> @@ -527,9 +527,14 @@ static void device_added(GDBusProxy *proxy)
>>>
>>>  static void adapter_added(GDBusProxy *proxy)
>>>  {
>>> -       default_ctrl = g_malloc0(sizeof(struct adapter));
>>> -       default_ctrl->proxy = proxy;
>>> -       ctrl_list = g_list_append(ctrl_list, default_ctrl);
>>> +       struct adapter *adapter = g_malloc0(sizeof(struct adapter));
>>> +
>>> +       adapter->proxy = proxy;
>>> +       ctrl_list = g_list_append(ctrl_list, adapter);
>>> +
>>> +       if (!default_ctrl)
>>> +               default_ctrl = adapter;
>>> +
>>>         print_adapter(proxy, COLORED_NEW);
>>>  }
>>>
>>> --
>>> 2.7.4
>>>
>>
>>
>

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

end of thread, other threads:[~2017-09-01  3:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-31  4:23 [PATCH BlueZ] client: Fix default controller in interactive mode ERAMOTO Masaya
2017-08-31  5:02 ` Yunhan Wang
2017-08-31  8:06   ` ERAMOTO Masaya
2017-09-01  3:58     ` Yunhan Wang
2017-08-31  8:10   ` Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.