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

How to configure MTU of nRF52840 dongle?

Hi,

When I used nRF52840 dongle (connectivity_5.1.0_usb_with_s132_5.1.0.uf2 firmware) to receive peripheral device notifications, nRF52840 dongle can only receive 20 bytes. The peripheral device has been configured to send 240 bytes notification and Iphone received 240 bytes notifications correctly.

static uint32_t ble_cfg_set(uint8_t conn_cfg_tag)

{

...

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

ble_cfg.gap_cfg.role_count_cfg.periph_role_count = 0;
ble_cfg.gap_cfg.role_count_cfg.central_role_count = 1;
ble_cfg.gap_cfg.role_count_cfg.central_sec_count = 0;

error_code = sd_ble_cfg_set(m_adapter, BLE_GAP_CFG_ROLE_COUNT, &ble_cfg, ram_start);
if (error_code != NRF_SUCCESS)
{
printf("sd_ble_cfg_set() failed when attempting to set BLE_GAP_CFG_ROLE_COUNT.\n");
return error_code;
}

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 = 240; 

error_code = sd_ble_cfg_set(m_adapter, BLE_CONN_CFG_GATTC, &ble_cfg, ram_start);
if (error_code != NRF_SUCCESS)
{
printf("sd_ble_cfg_set() failed when attempting to set BLE_CONN_CFG_GATTC. \n");
return error_code;
}

...

}

static void on_hvx(const ble_gattc_evt_t *const p_ble_gattc_evt)
{
if (p_ble_gattc_evt->params.hvx.handle >= m_hrm_char_handle ||
p_ble_gattc_evt->params.hvx.handle <= m_hrm_cccd_handle) 
{
printf("Received data length: %d\n", p_ble_gattc_evt->params.hvx.len);//Received data length:20
}
}

Parents
  • The peripheral device has been configured to send 240 bytes notification and Iphone received 240 bytes notifications correctly.

     What happens to the peripheral if it enters a connection that doesn't support more than 23 bytes of MTU? Does it still send 240 bytes?

    I suspect that the connectivity_5.1.0_usb_with_s132_5.1.0.uf2 doesn't support MTU higher than 23 bytes, and then it would be impossible to send more than 20 bytes of payload in a packet.

    Where exactly did you find connectivity_5.1.0_usb_with_s132_5.1.0.uf2?

    Perhaps you rather want to look into the SDK16.0.0\examples\connectivity\ble_connectivity - example?

    Or even use some custom ble_peripheral? 

    Even before that, I would suggest that you get hold of an nRF52840 DK for your development. The dongle doesn't have a debugger, so it is very hard to actually develop on the dongle. Once it is working on a DK you can port it to the dongle, if you need the dongle's form factor.

    Best regards,

    Edvin

Reply
  • The peripheral device has been configured to send 240 bytes notification and Iphone received 240 bytes notifications correctly.

     What happens to the peripheral if it enters a connection that doesn't support more than 23 bytes of MTU? Does it still send 240 bytes?

    I suspect that the connectivity_5.1.0_usb_with_s132_5.1.0.uf2 doesn't support MTU higher than 23 bytes, and then it would be impossible to send more than 20 bytes of payload in a packet.

    Where exactly did you find connectivity_5.1.0_usb_with_s132_5.1.0.uf2?

    Perhaps you rather want to look into the SDK16.0.0\examples\connectivity\ble_connectivity - example?

    Or even use some custom ble_peripheral? 

    Even before that, I would suggest that you get hold of an nRF52840 DK for your development. The dongle doesn't have a debugger, so it is very hard to actually develop on the dongle. Once it is working on a DK you can port it to the dongle, if you need the dongle's form factor.

    Best regards,

    Edvin

Children
Related