2023-08-31 05:36 AM
SO, Peripheral side here, using the marvelous stm32wb55 !
I would love to be able to start advertisement for a specific amount of time (e.g, 5 sec)
and then get and the response whether or not I got connected. ( ALL IN ONE COMMAND please!!)
Did someone implement it safely?
My concern is that I stop advertisement while having a connection event pending..
Now, I do not like the idea of processing all the events in queue ( how do I know where to stop? ) , or waiting for queue to be empty.. ( will it ever be? could get stuck there)
ST guys , is there a ready command for that? In the code examples I see you stopping it with task, but is there a way to start it for X seconds, and get an event saying "You got connected/ Or not" ? Looks like a handy command, that is probably not in BLE specification god...
Help please ( :
2023-08-31 06:59 AM
Hello @muslimah
Here is one way to implement advertisement for a specific time period and then get notified whether a connection was established or not using the STM32WB55 BLE stack
1. Start advertising using hci_le_set_advertise_enable(). Pass a timeout value in ms for how long to advertise.
2. Register a callback function using hci_le_register_app() that will be called when either:
- A connection complete event occurs, indicating a successful connection.
- The advertising timeout expires without a connection.
3. In the callback function, check the event type. If it's a connection complete event, a connection was established. If it's the advertising timeout, no connection occurred.
4. Return a status (e.g. return value or global variable) from the callback indicating the result - connected or not connected.
Hope this is helpful. If this answers your questions please mark it as best answer to be diffused.
Best regards
II
2023-09-11 05:30 AM
@Issamos , Interesting idea that I would like to test !
Start advertising using hci_le_set_advertise_enable(). Pass a timeout value in ms for how long to advertise.
I was looking for such a command as well, but could not find it. Closest if Direct Advertisement that I can't use.
What is the event I get when the advertising procedure stops? How can I register for it?
In code, the command gets a single parameter only, and I can not pass a time duration to it.
typedef __PACKED_STRUCT
{
uint8_t Advertising_Enable;
} hci_le_set_advertising_enable_cp0;
2023-09-12 03:47 AM
@Issamos HI, Was very excited reading your proposal !
I was actually getting back to the topic after leaving it a side for a bit, when I couldn't find
1. The command you are using that has an input of how long to advertise.
2. The event that says advertisement stopped.
Can you point me to the correct direction?