1

ANCS with MTU > 23

Gotthcha gravatar image

asked 2017-07-16 22:15:30 +0200

Petter gravatar image

updated 2017-07-17 13:36:40 +0200

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

edit retag flag offensive close delete report spam

2 answers

Sort by » oldest newest most voted
1
maxcoldson gravatar image

answered 2017-07-17 04:09:13 +0200

Petter gravatar image

updated 2017-07-17 13:36:54 +0200

@Gotthcha

I have try to modify MTU size before, but on CSR and BRCM platform.

And I have a question for u, which version u r current using? iOS 10?

As I remember, when in iOS 7 MTU size on the iPhone can only up to 128 byte

iOS 8 MTU size 135, iOS 9 MTU size 158, iOS 10 MTU size is 185 byte,

This image below is the nRF52832 connect with iOS 9,

image description

Can U just using 185 byte or less, and give it a try?

BTW: "Invalid Parameter" is the error code 0x07 u got.

#define     NRF_ERROR_INVALID_PARAM   (NRF_ERROR_BASE_NUM + 7)
edit flag offensive delete publish link more
1
Gotthcha gravatar image

answered 2017-07-17 11:38:21 +0200

Petter gravatar image

updated 2017-07-17 13:37:24 +0200

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>
edit flag offensive delete publish link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer. Do not ask a new question or reply to an answer here.

[hide preview]

Question Tools

1 follower

Stats

Asked: 2017-07-16 22:15:30 +0200

Seen: 37 times

Last updated: Jul 17