With 2.0.3 stack and and the BGM121 and BGM111 modules I can reproduce the following issue related to advertising. I am unable to test later stacks due to other issues with those, but this perhaps could be valuable to look at as I believe its related to advertising while connected.
When data is sent at a high rate using notifications while connected AND advertising is enabled the advertising will stop unexpectedly and it can't be restarted without resetting the module.
Steps to reproduce:
1. Module is configured to advertise using:
2. A client creates a connection to the module.
3. In response to the connection the module stops advertising using:
4. The module then immediately starts advertising using:
5. The client sets the CCC for a particular characteristic to receive notifications.
6. The module initiates a series of notifications 18 Bytes each for a total of 1000 Bytes usng:
The above is called in a soft timer with an interval of ~15ms. The response is checked and responses of "Out of Memory" will cause the data to be resent until successful.
Size of the notification and overall data is not too important, but larger data sets tend to trigger the issue more reliably.
Performing the above steps will cause the current advertising to stop on the module and trying to re-start advertisements as in step #1 will have no effect. The stack otherwise appears to function normally. Soft timers and the existing connection work as expected, however subsequent connections of course can not be made because advertising does not work. Only a module reset will restore the advertising functionality. There are no errors reported when calling gecko_cmd_le_gap_set_mode.
Thanks for the detailed description!
When you restart advertising, do you also set the custom advertising data again by calling gecko_cmd_le_gap_set_adv_data? You need to call this function again when restarting advertisements, even if the custom data has not been changed.
Yes, this is currently done. In fact, it was normally done periodically asynchronous to the advertising stopping and starting, but for testing purposes I just made this synchronous before I start advertising and the same issue persists.
This raises another question:
Currently when the user data changes while advertising (which is does frequently) I have been simply calling gecko_cmd_le_gap_set_adv_data and it seems to work fine. Should I instead be stopping, updating adv data then restarting every time? Note I tested this and it does not fix the issue I am seeing. Also seems very inefficient.
You can update advertising data without stopping advertising first.
I will report the issue that you described in the first post in our internal bug tracking system.
I also just tried this without custom advertising "le_gap_general_discoverable" and same result. Does not seem to be related to custom advertising.
Can you think of any internal mechanism that can detect if the module gets in this state so I can trigger a reset?
I devised what might be a temporary fix for now...
When I get an "out of memory" error using gecko_cmd_gatt_server_send_characteristic_notification I increase the send interval (soft timer) slightly. Eventually the interval is long enough to not trigger the error and the advertising seems stable.
Further evidence the issue may be the stack gets overwhelmed sending data.
Another way to trigger this and, at times, a crash of the module itself is to call gecko_cmd_gatt_server_send_characteristic_notification in a loop more than a couple times in a row. Lots of odd things happen here. One of 3 things can happen:
1. Behavior as described above with advertising stopping.
2. Connection gets dropped.
3. Module unresponsive.