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

Multilink central disconnect problem

I wrote a peripheral similar to NUS. Then I use the multilink central to connect to 3 of them. First two are fine. But when the 3rd is added, the 3rd one would connect, but every 30 seconds, it would break the connection with code 0x13 (no resource?). I have tried different things but no improvement. The first two are always connected. This is with SDK v13. Any ideas?

Parents
  • FormerMember
    0 FormerMember

    The disconnect is because of this bug in the GATT module (nrf_ble_gatt.h/.c): nrf_ble_gatt.h locally sets and uses its own settings for the number of connections, which by default is '2'. Changing the defines in nrf_ble_gatt.h to the correct value, or redefining NRF_BLE_CENTRAL_LINK_COUNT/NRF_BLE_PERIPHERAL_LINK_COUNT should solve the problem.

    Update 19.06.17: To make the links stable for longer packets, the following changes have to be made:

    • Increase the connection interval: It takes more time to transmit longer packets, and each connected peripheral will require some time.

    • Configure the softdevice with the correct GAP and GATT parameters in ble_stack_init(), both for the central and the peripherals:

       memset(&ble_cfg, 0, sizeof(ble_cfg));
       ble_cfg.conn_cfg.params.gap_conn_cfg.conn_count     = PERIPHERAL_LINK_COUNT + CENTRAL_LINK_COUNT;
       ble_cfg.conn_cfg.params.gap_conn_cfg.event_length   = my_connection_event_length; 
       ble_cfg.conn_cfg.conn_cfg_tag                       = CONN_CFG_TAG;
      
       err_code = sd_ble_cfg_set(BLE_CONN_CFG_GAP, &ble_cfg, ram_start);
       APP_ERROR_CHECK(err_code);
      
       memset(&ble_cfg, 0, sizeof(ble_cfg));
       ble_cfg.conn_cfg.params.gatt_conn_cfg.att_mtu       = NRF_BLE_GATT_MAX_MTU_SIZE;
       ble_cfg.conn_cfg.conn_cfg_tag                       = CONN_CFG_TAG;
      
       err_code = sd_ble_cfg_set(BLE_CONN_CFG_GATT, &ble_cfg, ram_start);
       APP_ERROR_CHECK(err_code);
      
  • Thought this issue was solved but not yet. Things are fine with MTU=23 and 3 peripherals. After I change the MTU size to 247 on both ends, the discovery became much slower than when MTU=23. The connection also became unstable, it would disconnect the 3rd peripheral always, and even the first two would disconnect sometimes. Can you verify and tell me how to solve it?

    I have also added code as following for MTU=247 and called them with "true" in main():

    static void conn_evt_len_ext_set(bool status) { ret_code_t err_code; ble_opt_t opt;

    memset(&opt, 0x00, sizeof(opt));
    opt.common_opt.conn_evt_ext.enable = status ? 1 : 0;
    
    err_code = sd_ble_opt_set(BLE_COMMON_OPT_CONN_EVT_EXT, &opt);
    APP_ERROR_CHECK(err_code);
    
    NRF_LOG_DEBUG("Setting connection event length extension to %u: 0x%x\r\n", status, err_code);
    

    }

    static void data_len_ext_set(bool status) { uint8_t data_length = status ? (247 + LL_HEADER_LEN) : (23 + LL_HEADER_LEN); (void) nrf_ble_gatt_data_length_set(&m_gatt, BLE_CONN_HANDLE_INVALID, data_length); }

Reply
  • Thought this issue was solved but not yet. Things are fine with MTU=23 and 3 peripherals. After I change the MTU size to 247 on both ends, the discovery became much slower than when MTU=23. The connection also became unstable, it would disconnect the 3rd peripheral always, and even the first two would disconnect sometimes. Can you verify and tell me how to solve it?

    I have also added code as following for MTU=247 and called them with "true" in main():

    static void conn_evt_len_ext_set(bool status) { ret_code_t err_code; ble_opt_t opt;

    memset(&opt, 0x00, sizeof(opt));
    opt.common_opt.conn_evt_ext.enable = status ? 1 : 0;
    
    err_code = sd_ble_opt_set(BLE_COMMON_OPT_CONN_EVT_EXT, &opt);
    APP_ERROR_CHECK(err_code);
    
    NRF_LOG_DEBUG("Setting connection event length extension to %u: 0x%x\r\n", status, err_code);
    

    }

    static void data_len_ext_set(bool status) { uint8_t data_length = status ? (247 + LL_HEADER_LEN) : (23 + LL_HEADER_LEN); (void) nrf_ble_gatt_data_length_set(&m_gatt, BLE_CONN_HANDLE_INVALID, data_length); }

Children
No Data
Related