Hi Dialog,
my custom application should advertise and initiate a connection simultaneously, but only Advertising works.
Code snippet:
ble_gap_role_set(GAP_PERIPHERAL_ROLE | GAP_CENTRAL_ROLE);
...
ble_gap_adv_start(GAP_CONN_MODE_UNDIRECTED);
ble_gap_connect(&bd_addr, &cp);
What could be the problem?
Thanks
Armin
Device:
Hi ArminL,
I am afraid that something like this is not possible, concurrent central/peripheral is valid only while connected (check the multilink demo), you wont be able to advertise and scan/connect at the same time.
Thanks MT_dialog
Hi MT_dialog,
ok, this is a problem, because the application should always be able to connect either to a central or peripheral.
So I have to invoke the advertise and scan procedures alternately, maybe with a timer.
Can you give me a clue, how this problem could be solved?
Thanks
Armin
Hi ArminL,
Yes, you should be able to do that, you can alter Scanning and Advertising on steady intervals via a Free RTOS timers, just set up your timer and in the callback or the timer stop advertising. After the advertising has completed (you get the advertising completion callback you can either start to scan or initiate a connection). Have in mind that the Scanning is procedure that is terminated automatically, so you dont have the timer for measuring the scanning procedure if you like, the scanning will automatically timeout in 8 seconds.
The procedure goes like this:
Thanks MT_dialog
Hi MT_dialog,
I've implemented this procedure similar to your explanation.
In the case application is connected to a central (connection interval 30ms) and connection procedure is still active (with scan window 30ms), application sometimes seems to crash. The connection to the Central is discontinued and connection procedure stops.
What could be the problem?
Is it a problem if a connection event occurs during scan window?
Thanks
Armin
Hi ArminL,
So, you have the device in dual mode GAP_PERIPHERAL_ROLE | GAP_CENTRAL_ROLE and switching between scanning and advertising, and when you start a connection from your phone for example you see that sometimes the devices crashes ?
The device in order to be connected it requires two advertising messages, so if your phone receives the last adv message before the 68x starts the scanning its not going to crash, the phone will receive the advertising message and will start a connection procedure. The connection procure will go on until the 68x switches back to the advertising mode and then the connection will be complete. Then if you continue to scan or advertise and you are still connected the 68x device will try to schedule all the events. In order to debug what you are seeing you will have to attach the debugger and check where the device stalls. At least on my side, replicating your setup (correct me if i am wrong about the setup) i didn't see any issues with the default connection of an android phone around 48ms (the central defines the connection interval of a connection unless a connection parameter update is issued and again the central will decide if it will accept the parameters).
Thanks MT_dialog
Hi MT_dialog,
it's an iOS phone. While my application is connected to a phone (connection event every ~30ms), my application continues the scanning procedure to connect to a peripheral (scan window 30ms). In this situation, my application crashes sometimes.
我将检查我的应用的调试器tion stalls.
Thanks
Armin