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

Beacon wake up , Advertise, sleep on Switch Press

Hello,

We do not want our beacon on at all times. I suppose our need below has been asked before.

Is there a sample snippit of code, or a document on ble_app_beacon to help us execute this small main.c change?

ble_stack_init();
advertising_init();
nrf_gpio_cfg_input(BSP_BUTTON_0, NRF_GPIO_PIN_PULLUP);
nrf _gpio_cfg_input(BSP_BUTTON_1, NRF_GPIO_PIN_PULLUP);

// Some code to setup wake up event

     While (1)
    {
     System Off // not sure on detail for this for just detecting the switch event2
     GPIO Event //wait for switch press event on Beacon onboard switches
     System ON
     run advertising_start(); 
     wait 1000 ms
    }

We are compiling with nRF51822 SmartBeacon pca10028_nrf51422_xxac_s130

Thanks, we are just very new to this code, and would like to streamline the time to get this one change made. Any help would be appreciated.

Thanks to all

Parents
  • You can set the device to advertise for 1 second. When you get the BLE_GAP_EVT_TIMEOUT event from the SoftDevice (after 1 second of advertising) you can enter SYSTEM OFF sleep mode with GPIO wakeup. When the system wakes up from SYSTEM OFF sleep mode it will do a reset and hence start advertising for one second again. See this main file used for the ble_app_beacon example in SDK: main.c

    If you don’t want to reset when you wake up you can enter SYSTEM ON sleep mode (draws a couple of uA more than SYSTEM OFF sleep mode) with sd_app_evt_wait(). Configure gpio to give you interrupt on change (see pin_change_int example in SDK for this) and start advertise again for 1 second.

  • "nrf_delay_ms" declared implicity: you need to include nrf_delay.h in the file:

    #include "nrf_delay.h`
    

    The enumerated type mixed with another type warning was my fault, use this code instead:

    nrf_gpio_cfg_sense_input(BSP_BUTTON_0, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
    

    It is exactly the same (see the definitions for NRF_GPIO_PIN_PULLUP and NRF_GPIO_PIN_SENSE_LOW).

Reply Children
No Data
Related