Hello. I am using ble_app_uart from sdk14.2. I use pca100401, softdevice s132.
Advertising is generated using timer RTC. Board advertises and stops advertising without errors if I it starts and I do not connect to it. However, when trying to reconnect after one connection and disconnection event with android device I receive an error. Error message in J-link RTT viewer states that error occurs at ..\..\..\main.c:1416 which is:
This is my main.c code:
/**@brief Application main function.
*/
int main(void)
{
uint32_t err_code;
//bool erase_bonds;
timers_init();
uart_init();
log_init();
// buttons_leds_init(&erase_bonds);
ble_stack_init();
gap_params_init();
gatt_init();
services_init();
advertising_init();
conn_params_init();
SEGGER_RTT_WriteString(0, "Hello World_SEGGER!\n");
//NRF_LOG_INFO("UART Start_NRF_LOG_INFO!");
/******************* MY CHANGES ****************/
gpio_config();
gpiote_init();
fstorage_init();
my_flash_begin();
timers_start();
nrf_gpio_pin_write(LED_2,0);
nrf_gpio_pin_write(LED_1,1);
/******************* MY CHANGES ****************/
while(1)
{
if(begin_flag == 1)
{
if(advertising_started==0)
{
advertising_started =1;
device_beginning_service();
sprintf((char*)string18,"advertising started\r\n");
SEGGER_RTT_WriteString(0,(char*)string18);
err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
APP_ERROR_CHECK(err_code);
}
}
This is the error I receive in J-link RTT viewer:
ble_advertising.h states that error means: the module is not initialized.
I am thinking that it might be problem with connection or disconnection events. Here is how I describe them:
case BLE_GAP_EVT_CONNECTED:
SEGGER_RTT_WriteString(0,"CONNECTION HAPPENED\n\r");
nrf_gpio_pin_write(LED_3, 0);
nrf_gpio_pin_write(LED_2, 1);
nrf_gpio_pin_write(LED_1, 1);
// NRF_LOG_INFO("Connected");
app_timer_stop_all();
/* err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
APP_ERROR_CHECK(err_code);*/
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
break;
case BLE_GAP_EVT_DISCONNECTED:
SEGGER_RTT_WriteString(0,"DISCONNECTION HAPPENED\n\r");
nrf_gpio_pin_write(LED_2, 0);
nrf_gpio_pin_write(LED_1, 1);
nrf_gpio_pin_write(LED_3, 1);
begin_flag = 0;
advertising_started = 0;
app_timer_stop_all();
err_code = app_timer_start(m_sleep_timer_id, SLEEP_TIMER_INTERVAL, NULL); //start sleeping timer
APP_ERROR_CHECK(err_code);
// LED indication will be changed when advertising starts.
m_conn_handle = BLE_CONN_HANDLE_INVALID;
break;
Would like to receive any suggestions why this is happening. Thank you.