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

BLE-NUS | Error Code 10

Hi there,

I have tested out the BLE-NUS SDK firmware on the NRF51422 SDK Board, and it responded well. When I ported the exact same code over to my custom board, I received auto disconnection and error code 10 upon connection to the board from the nRF UART App.

When the baud rate is >4800, the peripheral is unrecoverable. When i changed the baud rate to 2400, the BLE-NUS is discoverable but the above mentioned disconnection happens.

This is the segment of the main function:

static void ble_evt_dispatch(ble_evt_t * p_ble_evt) { ble_conn_params_on_ble_evt(p_ble_evt); ble_nus_on_ble_evt(&m_nus, p_ble_evt); on_ble_evt(p_ble_evt); ble_advertising_on_ble_evt(p_ble_evt); }

static void sys_evt_dispatch(uint32_t sys_evt) { ble_advertising_on_sys_evt(sys_evt); pstorage_sys_event_handler(sys_evt); -- for pstorage use; not shown }

static void gap_params_init(void) { uint32_t err_code; ble_gap_conn_params_t gap_conn_params; ble_gap_conn_sec_mode_t sec_mode;

BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);

err_code = sd_ble_gap_device_name_set(&sec_mode,
                                      (const uint8_t *) DEVICE_NAME,
                                      strlen(DEVICE_NAME));
APP_ERROR_CHECK(err_code);

memset(&gap_conn_params, 0, sizeof(gap_conn_params));

gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
gap_conn_params.slave_latency     = SLAVE_LATENCY;
gap_conn_params.conn_sup_timeout  = CONN_SUP_TIMEOUT;

err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
APP_ERROR_CHECK(err_code);

}

static void scheduler_init(void) { APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE); }

static void services_init(void) { uint32_t err_code; ble_nus_init_t nus_init;

memset(&nus_init, 0, sizeof(nus_init));

nus_init.data_handler = nus_data_handler;

err_code = ble_nus_init(&m_nus, &nus_init);
APP_ERROR_CHECK(err_code);

}

static void conn_params_init(void) { uint32_t err_code; ble_conn_params_init_t cp_init;

memset(&cp_init, 0, sizeof(cp_init));

cp_init.p_conn_params                  = NULL;
cp_init.first_conn_params_update_delay = FIRST_CONN_PARAMS_UPDATE_DELAY;
cp_init.next_conn_params_update_delay  = NEXT_CONN_PARAMS_UPDATE_DELAY;
cp_init.max_conn_params_update_count   = MAX_CONN_PARAMS_UPDATE_COUNT;
cp_init.start_on_notify_cccd_handle    = BLE_GATT_HANDLE_INVALID;
cp_init.disconnect_on_fail             = false;
cp_init.evt_handler                    = on_conn_params_evt;
cp_init.error_handler                  = conn_params_error_handler;

err_code = ble_conn_params_init(&cp_init);
APP_ERROR_CHECK(err_code);

}

static void uart_init(void) { uint32_t err_code; const app_uart_comm_params_t comm_params = { RX_PIN_NUMBER, // RX Pin TX_PIN_NUMBER, // TX Pin RTS_PIN_NUMBER, // RTS Pin CTS_PIN_NUMBER, // CTS Pin APP_UART_FLOW_CONTROL_DISABLED, false, UART_BAUDRATE_BAUDRATE_Baud2400 };

APP_UART_FIFO_INIT(&comm_params,
                   UART_RX_BUF_SIZE,
                   UART_TX_BUF_SIZE,
                   uart_event_handle,
				   APP_IRQ_PRIORITY_LOW,
                   err_code);
APP_ERROR_CHECK(err_code);

}

static void advertising_init(void) { uint32_t err_code; ble_advdata_t advdata; ble_advdata_t scanrsp;

memset(&advdata, 0, sizeof(advdata));
advdata.name_type          = BLE_ADVDATA_FULL_NAME;
advdata.include_appearance = false;
advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;

memset(&scanrsp, 0, sizeof(scanrsp));
scanrsp.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
scanrsp.uuids_complete.p_uuids  = m_adv_uuids;

ble_adv_modes_config_t options = {0};
options.ble_adv_fast_enabled  = BLE_ADV_FAST_ENABLED;
options.ble_adv_fast_interval = APP_ADV_INTERVAL;
options.ble_adv_fast_timeout  = APP_ADV_TIMEOUT_IN_SECONDS;

err_code = ble_advertising_init(&advdata, &scanrsp, &options, on_adv_evt, NULL);
APP_ERROR_CHECK(err_code);

}

int main(void) {

ble_stack_init(); 	// Initializes the S110 Soft Device -- LFCLK; and BLE event interrupt
APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false);

scheduler_init();
gap_params_init();
services_init();
advertising_init();
conn_params_init();
uart_init();
ble_advertising_start(BLE_ADV_MODE_FAST);

// Enter main loop.
for (;;)
{
    app_sched_execute();
    power_manage();
}

}

image description

Wireshark logs:

log1.pcapng log2.pcapng

Parents
  • FormerMember
    0 FormerMember

    The log shows that something goes wrong in the connection initiation: the master transmits a connection request, but it never transmit a new packet in the transmit window. The figure below shows the connection initiation sequence. You can find "the same" message sequence chart in the Bluetooth Core Specification v. 4.2, Vol. 6, Part D, chapter 5.1 and a description in Part B, chapter 4.5.4.

    image description

    The above connection establisment should look like the following in wireshark: image description

Reply
  • FormerMember
    0 FormerMember

    The log shows that something goes wrong in the connection initiation: the master transmits a connection request, but it never transmit a new packet in the transmit window. The figure below shows the connection initiation sequence. You can find "the same" message sequence chart in the Bluetooth Core Specification v. 4.2, Vol. 6, Part D, chapter 5.1 and a description in Part B, chapter 4.5.4.

    image description

    The above connection establisment should look like the following in wireshark: image description

Children
No Data
Related