This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Problem with advertising reset

Hi, I try to turn off the advertising after the first connection and then turn it on after pressing the button, this is what I wrote:

void radio_notification_evt_handler(bool radio_evt)
{
    if (radio_evt)
    {
		//radio going active
		LEDS_INVERT(BSP_LED_1_MASK);
		if (connection_occurance) sd_ble_gap_adv_stop();
    } 
}

//

void GPIOTE_IRQHandler(void)
{
		printf("Are you here?");
		ble_advertising_start(BLE_ADV_MODE_FAST);
		if(NRF_GPIOTE->EVENTS_PORT)
                   		NRF_GPIOTE->EVENTS_PORT = 0;
}

Program comes to the handler of button interrupt but there the program is crashing. This problem is quite suprising for me, because I reset advertising in other application and there it's work well. Only difference is that in the other case I turn off and immediately turn on advertising, and in this application I wait for button.

Parents
  • I am not familiar with advertising module (i just don't use it to advertise), but i think this is because you cannot call SVC from higher priority context. I assume your GPIOTE IRQ have higher priority than SVC, so it causes hardfault. You just have to leave somehow from interrupt context (just set a flag in irq handler?) and start advertising by checking the flag. about ble_evt_dispatch and sys_evt_dispatch - they are used to propagate BLE and SOC events in app, you can read about it here and here

Reply
  • I am not familiar with advertising module (i just don't use it to advertise), but i think this is because you cannot call SVC from higher priority context. I assume your GPIOTE IRQ have higher priority than SVC, so it causes hardfault. You just have to leave somehow from interrupt context (just set a flag in irq handler?) and start advertising by checking the flag. about ble_evt_dispatch and sys_evt_dispatch - they are used to propagate BLE and SOC events in app, you can read about it here and here

Children
No Data
Related