2015-09-10 06:45:46

by Nazmul Alam

[permalink] [raw]
Subject: mgmt-api callback not firing properly

I am using mgmt-api to send command to the bluetooth kernel driver.

The problem is that sometimes the callback of the mgmt_send() command
is not fired even though the return value of the mgmt_send() is
indicating a success.

is there any special case which may cause this kind of issue?

using bluez 5.31 and 4.1+ kernel.

Thanks in advance.


2015-09-16 05:16:20

by Nazmul Alam

[permalink] [raw]
Subject: Re: mgmt-api callback not firing properly

Hello Marcel,
I think you are right. Invoking the commands in a sequential way does the job.

Thanks for your heads up.


>>> are you utilizing src/shared/mgmt.c for your code. That one has proper handling for queuing the commands. It however means that the next command is only send when the previous one completed? Which command do you have problems with. There are a few special ones that require mgmt_reply to be used.
>>
>> Yes I am using src/shared/mgmt.c for my code. The problem occurs when
>> I try to issue the MGMT_OP_START_DISCOVERY &
>> MGMT_OP_ADD_ADVERTISING/MGMT_OP_REMOVE_ADVERTISING simultaneously,
>> sometimes the callback doesn't fire for the later call.
>>
>> According to one of your reply to a thread, I changed the guarding
>> code of the kernel driver and simultaneous scanning / advertising is
>> working. But sometimes the callback is not firing (randomly).
>>
>> I am using the mainloop_run() in a pthread. Is this can be a issue?
>
> our code is not thread safe. So that might be a problem. Since I have not heard from issues with missing callbacks in bluetoothd and that is running exactly the same code.
>
> Regards
>
> Marcel
>

2015-09-12 10:23:27

by Marcel Holtmann

[permalink] [raw]
Subject: Re: mgmt-api callback not firing properly

Hi,

>> are you utilizing src/shared/mgmt.c for your code. That one has proper handling for queuing the commands. It however means that the next command is only send when the previous one completed? Which command do you have problems with. There are a few special ones that require mgmt_reply to be used.
>
> Yes I am using src/shared/mgmt.c for my code. The problem occurs when
> I try to issue the MGMT_OP_START_DISCOVERY &
> MGMT_OP_ADD_ADVERTISING/MGMT_OP_REMOVE_ADVERTISING simultaneously,
> sometimes the callback doesn't fire for the later call.
>
> According to one of your reply to a thread, I changed the guarding
> code of the kernel driver and simultaneous scanning / advertising is
> working. But sometimes the callback is not firing (randomly).
>
> I am using the mainloop_run() in a pthread. Is this can be a issue?

our code is not thread safe. So that might be a problem. Since I have not heard from issues with missing callbacks in bluetoothd and that is running exactly the same code.

Regards

Marcel


2015-09-10 16:04:21

by Nazmul Alam

[permalink] [raw]
Subject: Re: mgmt-api callback not firing properly

Hello Marcel,
Thank you for your reply.


> are you utilizing src/shared/mgmt.c for your code. That one has proper ha=
ndling for queuing the commands. It however means that the next command is =
only send when the previous one completed? Which command do you have proble=
ms with. There are a few special ones that require mgmt_reply to be used.

Yes I am using src/shared/mgmt.c for my code. The problem occurs when
I try to issue the MGMT_OP_START_DISCOVERY &
MGMT_OP_ADD_ADVERTISING/MGMT_OP_REMOVE_ADVERTISING simultaneously,
sometimes the callback doesn't fire for the later call.

According to one of your reply to a thread, I changed the guarding
code of the kernel driver and simultaneous scanning / advertising is
working. But sometimes the callback is not firing (randomly).

I am using the mainloop_run() in a pthread. Is this can be a issue?


Regards,

2015-09-10 13:21:29

by Marcel Holtmann

[permalink] [raw]
Subject: Re: mgmt-api callback not firing properly

Hi Nazmul,

> I am using mgmt-api to send command to the bluetooth kernel driver.
>
> The problem is that sometimes the callback of the mgmt_send() command
> is not fired even though the return value of the mgmt_send() is
> indicating a success.
>
> is there any special case which may cause this kind of issue?
>
> using bluez 5.31 and 4.1+ kernel.

are you utilizing src/shared/mgmt.c for your code. That one has proper handling for queuing the commands. It however means that the next command is only send when the previous one completed? Which command do you have problems with. There are a few special ones that require mgmt_reply to be used.

Regards

Marcel