Hello,
My setup is: ble_uart_app example, custom board with nrf51822, sdk 6, s110, nrf connect for pc.
I am advertising with my peripheral device. Whitelist is being applied to connections. I am able to connect to the devices which static addresses are in whitelist. Connections from devices who are not in the whitelist are droped like expected. Unfortunately when master disconnects from peripheral using NRF connect for pc the peripheral does not start advertising again. In keil debbuger I do spot an interesting thing. This is before connecting, device is initialized here properly:
After disconnection I see that capture and compare CC[0] register interupt is being disabled. Then this CC[0] event is triggered I start advertising. So, this is the case I do not see peripheral advertising after disconnection. In addition to this, I see that CC[0] value gets really high without a reason. This is how it looks in debbuger:
This is my code for advertising with whitelist:
static void advertising_start(void) /*Function for starting advertising.*/
{
uint32_t err_code;
ble_gap_adv_params_t adv_params;
ble_gap_whitelist_t whitelist;
ble_gap_addr_t * p_whitelist_addr[1];
ble_gap_addr_t whitelist_addr={BLE_GAP_ADDR_TYPE_RANDOM_STATIC,{0x7C,0xAB,0x54,0xF6,0x7E,0xC3}} ;
uint8_t addr[6] = {0x7C,0xAB,0x54,0xF6,0x7E,0xC3};
uint8_t adv_data[15] = {0x07,0x09,0x4E,0x6F,0x72,0x64,0x69,0x63,0x02,0x01,0x04,0x03,0x03,0x0F,0x18};
uint8_t adv_data_length = 15;
//Setting up the advertising data with scan response data = Null
err_code = sd_ble_gap_adv_data_set(adv_data, adv_data_length, NULL, NULL);
memset(&adv_params, 0, sizeof(adv_params)); //clear adv param
adv_params.type = BLE_GAP_ADV_TYPE_ADV_IND;
adv_params.p_peer_addr = NULL;
adv_params.fp = BLE_GAP_ADV_FP_FILTER_CONNREQ;//BLE_GAP_ADV_FP_ANY;//BLE_GAP_ADV_FP_FILTER_BOTH
adv_params.interval = APP_ADV_INTERVAL;
adv_params.timeout = APP_ADV_TIMEOUT_IN_SECONDS;
p_whitelist_addr[0] = &whitelist_addr;
whitelist.addr_count = 1;
whitelist.pp_addrs = p_whitelist_addr;
whitelist.pp_irks = NULL;
whitelist.irk_count =0;
adv_params.p_whitelist = &whitelist;
err_code = sd_ble_gap_adv_start(&adv_params); // Start advertising
APP_ERROR_CHECK(err_code); //check for errors
// nrf_gpio_pin_set(ADVERTISING_LED_PIN_NO); //indiccate advertising on LED 0
nrf_gpio_pin_write(GPIO_TOGGLE_TICK_EVENT_1, 0);
}
I would appreciate any ideas on what is happening in here.
--------------------------UPDATE--------------------------
This is how I perceive my problem while debbuging:
DK advertise, CC[0] and CC[1] values are as defined by me aswell as interupt settings.
Connection event happends two devices are connected. Somehow strangely CC[0] value changes into a huge number. I could not find the reason of this.
after disconnection it is possibile to see the change int RTC1 interrupt registers settings. Change in those registers causes to stop RTC1 which will not trigger advertising.