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

error code 13313 (0x3401) returned by ble_nus_string_send ?

Hi, Everyone

I am developing based on ble_app_uart at nrf52832 (softdevice s132)

I modified the program slightly.

- After the connection is confirmed

- Send 100 bytes of data to Phone every 150ms

- Suspend transmission if connection is lost

#define NRF_BLE_GATT_MAX_MTU_SIZE 103

void gatt_init(void)
{
    ......
    err_code = nrf_ble_gatt_att_mtu_periph_set(&m_gatt, NRF_BLE_GATT_MAX_MTU_SIZE);

   ......

}

static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
    uint32_t err_code;

    switch (p_ble_evt->header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:

        ........
       app_timer_start(send_some_uart_data, APP_TIMER_TICKS(150), NULL);
       break;

       case BLE_GAP_EVT_DISCONNECTED:
               .........
              m_conn_handle = BLE_CONN_HANDLE_INVALID;
             err_code = app_timer_stop(send_some_uart_data) ;
            break;

       ..........

}

void send_some_uart_data_handler(void * p_context)
{
    ret_code_t err_code;
    uint8_t string[] = "aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhhhiiiiiiiiiiiiijjjjjjjjjj\n\r";
    uint16_t length = sizeof(string);
    do
    {
         err_code = ble_nus_string_send(&m_nus, string, &length);
        if ( (err_code != NRF_ERROR_INVALID_STATE) && (err_code != NRF_ERROR_BUSY) )
        {
            APP_ERROR_CHECK(err_code); <- err_code :13313 
         }
     } while (err_code == NRF_ERROR_BUSY);

}

The first time i connect to the Bluetooth on my phone, the nRFToolBox-> UART is good for receiving.
However, if i attempt to reconnect after disconnecting, 13313 err_code will occur at ble_nus_string_send(&m_nus, string, &length);
Related