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

ANCS with MTU > 23

I tried to set up the ANCS example. It works fine. But how is it possible to set a higher MTU. I set the NRF_BLE_GATT_MAX_MTU_SIZE to 247. But the Log says after a connect:

nrf_ble_gatt:DEBUG:Requesting to update ATT MTU to 247 bytes on connection 0x0.
 0> nrf_ble_gatt:ERROR:sd_ble_gattc_exchange_mtu_request() returned unexpected value 0x7.
 0> nrf_ble_gatt:DEBUG:Requesting to update data length to 251 on connection 0x0.
 0> nrf_ble_gatt:ERROR:sd_ble_gap_data_length_update() (request) on connection 0x0 returned unexpected value 0x13.
 0> nrf_ble_gatt:DEBUG:Peer on connection 0x0 requested a data length of 251 bytes.
 0> nrf_ble_gatt:DEBUG:Updating data length to 251 bytes on connection 0x0.
 0> nrf_ble_gatt:ERROR:sd_ble_gap_data_length_update() (reply) returned unexpected value 0x13.

How can i set up a higher MTU? nrf52832 with SD 4.0.1 sdk 13

Parents
  • Okay i got a fix. @Coldson on my ios 10 i can reach a MTU of 247 Bytes:

    <pre>
    nrf_ble_gatt:DEBUG:Requesting to update ATT MTU to 247 bytes on connection 0x0.
     0> nrf_ble_gatt:DEBUG:Requesting to update data length to 251 on connection 0x0.
     0> nrf_ble_gatt:DEBUG:Data length updated to 251 on connection 0x0.
     0> nrf_ble_gatt:DEBUG:max_rx_octets: 251
     0> nrf_ble_gatt:DEBUG:max_tx_octets: 251
     0> nrf_ble_gatt:DEBUG:max_rx_time: 2120
     0> nrf_ble_gatt:DEBUG:max_tx_time: 2120
     0> nrf_ble_gatt:DEBUG:ATT MTU updated to 247 bytes on connection 0x0 (response).
     0> :INFO:GATT ATT MTU on connection 0x0 changed to 247.
     0> nrf_ble_gatt:DEBUG:Peer on connection 0x0 requested a data length of 251 bytes.
     0> nrf_ble_gatt:DEBUG:Updating data length to 251 bytes on connection 0x0.
     0> nrf_ble_gatt:DEBUG:Data length updated to 251 on connection 0x0.
     0> nrf_ble_gatt:DEBUG:max_rx_octets: 251
     0> nrf_ble_gatt:DEBUG:max_tx_octets: 251
     0> nrf_ble_gatt:DEBUG:max_rx_time: 2120
     0> nrf_ble_gatt:DEBUG:max_tx_time: 2120
     0> :INFO:Connection secured: role: 1, conn_handle: 0x0, procedure: 1.
    </pre>
    

    U need to change the BLE-Stack part to:

    <pre>
    // Configure the maximum number of connections.
    	memset(&ble_cfg, 0, sizeof(ble_cfg));
    	ble_cfg.gap_cfg.role_count_cfg.periph_role_count  = 1;
    	ble_cfg.gap_cfg.role_count_cfg.central_role_count = 0;
    	ble_cfg.gap_cfg.role_count_cfg.central_sec_count  = 0;
    	err_code = sd_ble_cfg_set(BLE_GAP_CFG_ROLE_COUNT, &ble_cfg, ram_start);
    	APP_ERROR_CHECK(err_code);
    
        // Configure the maximum ATT MTU.
       memset(&ble_cfg, 0x00, sizeof(ble_cfg));
       ble_cfg.conn_cfg.conn_cfg_tag                 = CONN_CFG_TAG;
       ble_cfg.conn_cfg.params.gatt_conn_cfg.att_mtu = NRF_BLE_GATT_MAX_MTU_SIZE;
       err_code = sd_ble_cfg_set(BLE_CONN_CFG_GATT, &ble_cfg, ram_start);
       APP_ERROR_CHECK(err_code);
    
       // Configure the maximum event length.
       memset(&ble_cfg, 0x00, sizeof(ble_cfg));
       ble_cfg.conn_cfg.conn_cfg_tag                     = CONN_CFG_TAG;
       ble_cfg.conn_cfg.params.gap_conn_cfg.event_length = 320;
       ble_cfg.conn_cfg.params.gap_conn_cfg.conn_count   = BLE_GAP_CONN_COUNT_DEFAULT;
       err_code = sd_ble_cfg_set(BLE_CONN_CFG_GAP, &ble_cfg, ram_start);
       APP_ERROR_CHECK(err_code);
    </pre>
    

    the GATT Init part to:

    <pre>
    err_code = nrf_ble_gatt_att_mtu_periph_set(&m_gatt, NRF_BLE_GATT_MAX_MTU_SIZE);
    	APP_ERROR_CHECK(err_code);
    
    	uint8_t data_length = ((uint8_t)NRF_BLE_GATT_MAX_MTU_SIZE + 4);
    	nrf_ble_gatt_data_length_set(&m_gatt, BLE_CONN_HANDLE_INVALID, data_length);
    
    	ble_opt_t opt;
    
    	memset(&opt, 0x00, sizeof(opt));
    	opt.common_opt.conn_evt_ext.enable = 1;
    
    	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", 1, err_code);
    </pre>
    

    and add this part to advertise init part (on the end):

    <pre>
    ble_advertising_conn_cfg_tag_set(CONN_CFG_TAG);
    </pre>
    
Reply
  • Okay i got a fix. @Coldson on my ios 10 i can reach a MTU of 247 Bytes:

    <pre>
    nrf_ble_gatt:DEBUG:Requesting to update ATT MTU to 247 bytes on connection 0x0.
     0> nrf_ble_gatt:DEBUG:Requesting to update data length to 251 on connection 0x0.
     0> nrf_ble_gatt:DEBUG:Data length updated to 251 on connection 0x0.
     0> nrf_ble_gatt:DEBUG:max_rx_octets: 251
     0> nrf_ble_gatt:DEBUG:max_tx_octets: 251
     0> nrf_ble_gatt:DEBUG:max_rx_time: 2120
     0> nrf_ble_gatt:DEBUG:max_tx_time: 2120
     0> nrf_ble_gatt:DEBUG:ATT MTU updated to 247 bytes on connection 0x0 (response).
     0> :INFO:GATT ATT MTU on connection 0x0 changed to 247.
     0> nrf_ble_gatt:DEBUG:Peer on connection 0x0 requested a data length of 251 bytes.
     0> nrf_ble_gatt:DEBUG:Updating data length to 251 bytes on connection 0x0.
     0> nrf_ble_gatt:DEBUG:Data length updated to 251 on connection 0x0.
     0> nrf_ble_gatt:DEBUG:max_rx_octets: 251
     0> nrf_ble_gatt:DEBUG:max_tx_octets: 251
     0> nrf_ble_gatt:DEBUG:max_rx_time: 2120
     0> nrf_ble_gatt:DEBUG:max_tx_time: 2120
     0> :INFO:Connection secured: role: 1, conn_handle: 0x0, procedure: 1.
    </pre>
    

    U need to change the BLE-Stack part to:

    <pre>
    // Configure the maximum number of connections.
    	memset(&ble_cfg, 0, sizeof(ble_cfg));
    	ble_cfg.gap_cfg.role_count_cfg.periph_role_count  = 1;
    	ble_cfg.gap_cfg.role_count_cfg.central_role_count = 0;
    	ble_cfg.gap_cfg.role_count_cfg.central_sec_count  = 0;
    	err_code = sd_ble_cfg_set(BLE_GAP_CFG_ROLE_COUNT, &ble_cfg, ram_start);
    	APP_ERROR_CHECK(err_code);
    
        // Configure the maximum ATT MTU.
       memset(&ble_cfg, 0x00, sizeof(ble_cfg));
       ble_cfg.conn_cfg.conn_cfg_tag                 = CONN_CFG_TAG;
       ble_cfg.conn_cfg.params.gatt_conn_cfg.att_mtu = NRF_BLE_GATT_MAX_MTU_SIZE;
       err_code = sd_ble_cfg_set(BLE_CONN_CFG_GATT, &ble_cfg, ram_start);
       APP_ERROR_CHECK(err_code);
    
       // Configure the maximum event length.
       memset(&ble_cfg, 0x00, sizeof(ble_cfg));
       ble_cfg.conn_cfg.conn_cfg_tag                     = CONN_CFG_TAG;
       ble_cfg.conn_cfg.params.gap_conn_cfg.event_length = 320;
       ble_cfg.conn_cfg.params.gap_conn_cfg.conn_count   = BLE_GAP_CONN_COUNT_DEFAULT;
       err_code = sd_ble_cfg_set(BLE_CONN_CFG_GAP, &ble_cfg, ram_start);
       APP_ERROR_CHECK(err_code);
    </pre>
    

    the GATT Init part to:

    <pre>
    err_code = nrf_ble_gatt_att_mtu_periph_set(&m_gatt, NRF_BLE_GATT_MAX_MTU_SIZE);
    	APP_ERROR_CHECK(err_code);
    
    	uint8_t data_length = ((uint8_t)NRF_BLE_GATT_MAX_MTU_SIZE + 4);
    	nrf_ble_gatt_data_length_set(&m_gatt, BLE_CONN_HANDLE_INVALID, data_length);
    
    	ble_opt_t opt;
    
    	memset(&opt, 0x00, sizeof(opt));
    	opt.common_opt.conn_evt_ext.enable = 1;
    
    	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", 1, err_code);
    </pre>
    

    and add this part to advertise init part (on the end):

    <pre>
    ble_advertising_conn_cfg_tag_set(CONN_CFG_TAG);
    </pre>
    
Children
Related