Hello,
i got problem wher program cant go in while loop in main while advertising is running. Im using ble uart template. So was thinking to stop advertising when button is pressed but i didnt find solution noowher how to stop advertising. In beacon mode i can acces to while loop in main.
Here is my funtion to start advertising.
void advertising_start(void) { uint32_t err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST ); APP_ERROR_CHECK(err_code); }
Kev said:program cant go in while loop in main while advertising is running
What, exactly, do you mean by that.
It doesn't seem to make much sense - pretty much all of the SDK examples enter their main while loop while they are advertising!
To Stop (and re-start) advertising, see:
https://devzone.nordicsemi.com/f/nordic-q-a/48461/restart-advertisement-timeout-before-its-actual-timeout-restart-whenever-there-is-a-button-press
void Button_Handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action){ ready_to_flash_led = true ; SET_LED(LED_1, ON); } while(1){ if(ready_to_flash_led == true ){ write_flash_led(0x30); ready_to_flash_led = false; } }
Here is my button handler. When i press button LED goes on, but in main while loop on if sentence doesnt trigger writing to flash function. If i run code in beacon mode or advertising in idle mode it goes into while loop.
is ready_to_flash_led declared as volatile?
Kev said:if sentence doesnt trigger writing to flash function
How do you know?
Solved problem.
Jolly Good!
Now please verify the answer.
Also, for the benefit of others who may come along with a similar question, please describe how you solved it.