When using SDK 3.0.6 with the fully hosted proximity reporter project stopping and starting the advertisement causes a Hard Fault. This happens in the following scenarios when used by the PROXR_TASK:
1. Calling app_adv_stop and app_adv_start directly.
2. Sending a message to the APP_TASK to start/stop (based on the default handlers for app_adv_timer_handler and app_wakeup_handler (APP_ADV_TIMER and APP_WAKEUP_MSG message)).
3. Sending a timed message to the APP_TASK to start/stop. The hard fault seems to happen right away, regardless of the timeout value.
The only thing that works is in the APP_TASK, at the end of the app_adv_func function adding a timed message to APP_ADV_TIMER that calls app_adv_stop and sends a timed message to APP_WAKEUP_MSG that calls app_adv_start.
What is the correct way to control the advertisement not from the APP_TASK? We need to control it via commands received by our profile task.

Hi
If I understand you correctly, you want to start or stop advertising as a result of sending something to the peripheral while in a connected state? Or are you just attempting to shange the advertising data?
I need to start and stop the advertising as a result of a UART command (I've implemented a proprietary UART protocol that bypasses the default UART protocol. So far this works correctly). There is no need to change the advertising data, nor do I need to stop advertising during connected state (there is a separate command for disconnecting from an active connection).
I receive a UART command to stop or start the advertising in the context of the PROXR_TASK, and I need to be able to stop or start the advertising accordingly.
Hi,
Your option 2 above should work just fine then ("Sending a message to the APP_TASK to start/stop ").
This call will do this:
ke_msg_send_basic(APP_ADV_DONE,TASK_APP,TASK_APP);
You need to enumerate the new primitive APP_ADV_DONE (in app_api.h):
/// APP Task messages
enum APP_MSG
APP_MODULE_INIT_CMP_EVT = KE_FIRST_MSG(TASK_APP),
APP_ADV_DONE,
You will of course need to define a handler for that message app_task_handlers.h
{APP_ADV_DONE, (ke_msg_func_t)app_adv_done_handler},
Define the handler in your app_xxx_proj.c (and a prototype in .h file):
int app_adv_done_handler(
ke_msg_id_t const msgid,
ke_task_id_t const dest_id,
ke_task_id_t const src_id
)
{
app_adv_stop();
return (KE_MSG_CONSUMED);
}
As it turns out, the hard fault was in an unrelated piece of code. The code you've suggested worked correctly, thank you very much.
Hi,
Happy to hear that you solved the issue.