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

Stopping Eddystone advertisements

I am using Thingy (nrf52832) to advertise Eddystone UID and TLM packets in bursts. On a given event advertising starts with an interval of 200ms, then stops after specified amount of time. This sort of works. The problem is that after stopping, TLM packets are still advertised every ~10 seconds. I want to fully stop the advertising when the burst is complete.

I am using the eddystone library from Thingy SDK v2.1.0, and used the example "ble_app_eddystone" from NRF52 SDK v13.1.0 for guidance.

To stop advertising, I am using the following function from es_adv.h:

static void adv_stop(void)
{
ret_code_t err_code;

err_code = sd_ble_gap_adv_stop();
if (err_code != NRF_ERROR_INVALID_STATE)
{
APP_ERROR_CHECK(err_code);
}

es_adv_timing_stop();
}

As I understand it, this function should stop the eddystone advertising timers and disable advertising in the softdevice.

I noticed that when the intended advertisements are completed the eddystone event callback is called. This does not occur when the uninteded advertisements are sent, which leads me to believe that advertising in the softdevice has not been disabled.

I have tried playing around with the parameters in es_app_config.h to see if I can stop or change the frequency of the unintended advertising, without any success.

Any ideas?

Parents
  • Hi,

    In Thingy project, the Eddystone beacon module is using the timeslot functionality, so when you get certain radio events, it will request a timeslot to do the advertising. If you want to stop the Eddystone beacon, I believe the correct function to use is app_beacon_stop(), that will set the m_beacon.keep_running bool to false. Take a look at the file called advertiser_beacon_timeslot.c to see the implementation.

  • I will look into using the timeslot functionality for my purpose, thanks!

    Atm I am using the eddystone library from external/components/libraries/eddystone. Any suggestions on how I can resolve the issue with my current setup?

  • In the Thingy project, we are doing regular connectable advertising, so that a phone can connect to the thingy. But as an additional feature, we are also doing Eddystone beacon advertising in-between the regular connectable advertising, using the timeslot functionality.

    In the Eddystone example project, and in the eddystone libraries, the main feature is the eddystone beaconing, and we are not using the timeslot approach here.

    I don’t know how you have implemented this, but if you have added the eddystone libraries to the Thingy project, and started Eddystone advertising with es_adv_start_non_connctable_adv(), then it could be that you are doing both? In that case, you need to call both adv_stop() AND app_beacon_stop().

  • I have started a custom project, so not using any of the original Thingy code. Just using bits and pieces from the SDK. 

    Both connectable advertising and the timeslot functionality is disabled.

    I am modifying the timeslot module for my purposes now, so maybe that will do the trick. Would be great however to know why I am not able to disable advertising using the eddystone library from SDK13.

  • When testing this with the Eddystone example project in SDK 13.1 on the nRF52-DK, I have no problems stopping the advertising.

    I'm initializing BUTTON_2 like this:

    static void button_init(void)
    {
        ret_code_t              err_code;
        const uint8_t           buttons_cnt  = 2;
        
        static app_button_cfg_t buttons_cfgs[] =
        {
            {BUTTON_REGISTRATION, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_evt_handler},
            {BUTTON_2,APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_evt_handler}
        };
        
             err_code = app_button_init(buttons_cfgs, buttons_cnt, APP_TIMER_TICKS(100));
        APP_ERROR_CHECK(err_code);
    
        err_code = app_button_enable();
        APP_ERROR_CHECK(err_code);
    }

    And the button_evt_handler looks like this.

    static void button_evt_handler(uint8_t pin_no, uint8_t button_action)
    {
        ret_code_t              err_code;
      
        if(pin_no == BUTTON_REGISTRATION)
        {
            
            if (button_action == APP_BUTTON_PUSH && pin_no == BUTTON_1)
            {
                nrf_ble_es_on_start_connectable_advertising();
            }
        }
        
        if(pin_no == BUTTON_2)    
        {
                err_code = sd_ble_gap_adv_stop();
                if (err_code != NRF_ERROR_INVALID_STATE)
                {
                    APP_ERROR_CHECK(err_code);
                }
                es_adv_timing_stop();
        }
    }

    I also added #include "es_adv_timing.h" in main.c

    When I press button 2 on the DK, the advertising stops.

    Maybe you are running into the error-handler? If DEBUG is not defined as a preprocessor symbol, the default behavior is to reset the chip, and the advertising will then restart when the chip starts again. See this post.

    If this is not the case, you will need to debug. Place a breakpoint in functions that could be starting the advertising again, e.g. adv_start(), es_adv_timing_start(), connectable_adv_start(), etc. Then try to stop the advertising, and if you hit one of the breakpoints, then you should look at the call-stack to see where the functions are being called from.

  • When I call adv_stop() the default frame (which I have configured to be UID) stops. However, I've added an additional frame (TLM), and this frame is still advertised (at a lower frequency) after calling adv_stop(). I know the chip is not resetting, as I use an RTT debugger to monitor the activity.

    Maybe I have added the TLM frame in the wrong way. I used the function 'configure_slot(uint8_t slot_no, uint8_t length, uint8_t * p_frame_data) ' to set it up. 

    Anyways, I have setup the timeslot functionality instead. This works like a charm! I'm not going to spend more time debugging my issue with the other eddystone library, so will mark your first reply as the correct one.

    Thanks for the help!

Reply
  • When I call adv_stop() the default frame (which I have configured to be UID) stops. However, I've added an additional frame (TLM), and this frame is still advertised (at a lower frequency) after calling adv_stop(). I know the chip is not resetting, as I use an RTT debugger to monitor the activity.

    Maybe I have added the TLM frame in the wrong way. I used the function 'configure_slot(uint8_t slot_no, uint8_t length, uint8_t * p_frame_data) ' to set it up. 

    Anyways, I have setup the timeslot functionality instead. This works like a charm! I'm not going to spend more time debugging my issue with the other eddystone library, so will mark your first reply as the correct one.

    Thanks for the help!

Children
No Data
Related