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

Periodically switching into config mode on nRF51822 Beacon Kit

Hi,

I have implemented some code to periodically switching back and forth between the normal and the config mode. I can see that the handler function is being called, but the beacon does not switch into the config mode. The following is what I implemented:

beacon_mode_t beacon_mode = beacon_mode_normal;

static void config_mode_timeout_handler(void * p_context) {

	if(beacon_mode == beacon_mode_normal)
	{
		beacon_mode = beacon_mode_config;
	}
	else
	{
		beacon_mode = beacon_mode_normal;
	}
	
	advertising_init(beacon_mode);

}

Apparently calling advertising_init with beacon_config_mode is not enough to do this, but I don't know what other functions I should be calling for this. Thanks a lot in advance!

Parents
  • @Sarah:

    If you have a look at our code in beacon_setup() in main.c you can find that we need to init some parameter such as gap, services, connection parameter, security when we are in config mode.

    For your application, since you are switching back and forth a lot, I would suggest you to do this configuration at the begining regardless which mode you will be running. Good thing is that you can have this configuration when you running in both modes.

    The main difference that effectively tells apart which mode is currently running is when calling advertising_init(). If you have called the configuration init as mentioned above, you should be fine. Note that you should better call sd_ble_gap_adv_stop() and sd_ble_gap_adv_start() again after you have changed the advertising flags and data in the advertising_init() function.

  • @Sarah: I don't see any reason it shouldn't work. The main difference between the 2 mode is the advertising type. When in normal mode it advertise with non connectable BLE_GAP_ADV_TYPE_ADV_NONCONN_IND type, when in configure more it's BLE_GAP_ADV_TYPE_ADV_IND type.

    I think you should check and make sure you have NRF_SUCCESS return when calling each of the functions when switching. To do that you can add a break point in the error assert handler, and look for the err_code, line and file name that cause the issue.

Reply
  • @Sarah: I don't see any reason it shouldn't work. The main difference between the 2 mode is the advertising type. When in normal mode it advertise with non connectable BLE_GAP_ADV_TYPE_ADV_NONCONN_IND type, when in configure more it's BLE_GAP_ADV_TYPE_ADV_IND type.

    I think you should check and make sure you have NRF_SUCCESS return when calling each of the functions when switching. To do that you can add a break point in the error assert handler, and look for the err_code, line and file name that cause the issue.

Children
No Data
Related