Skip to main content
RMoc.1
Associate II
March 16, 2023
Question

Enable Data Length Extension (DLE) and increase MTU size BlueNRG M2

  • March 16, 2023
  • 2 replies
  • 2816 views

I am using BLUENRG M2SA and would like to enable data length extension and increase the MTU size. I read the PM0257 programming manual and made the following changes.

#define CLIENT_MAX_MTU_SIZE 185
 
void hci_le_connection_complete_event(uint8_t Status,
 uint16_t Connection_Handle,
 uint8_t Role,
 uint8_t Peer_Address_Type,
 uint8_t Peer_Address[6],
 uint16_t Conn_Interval,
 uint16_t Conn_Latency,
 uint16_t Supervision_Timeout,
 uint8_t Master_Clock_Accuracy)
{
 connected = true;
}
 
void aci_att_exchange_mtu_resp_event(uint16_t Connection_Handle,
 uint16_t Server_RX_MTU)
{
 if (Server_RX_MTU <= CLIENT_MAX_MTU_SIZE)
 {
 write_len = Server_RX_MTU - 3;
 }
 else
 {
 write_len = CLIENT_MAX_MTU_SIZE - 3;
 }
 
 if ((mtu_exchanged_wait == 0) || ((mtu_exchanged_wait == 1)))
 {
 if (mtu_exchanged_wait == 0)
 {
 mtu_exchanged_wait = 2;
 }
 mtu_exchanged = true;
 }
}
 
void hci_le_data_length_change_event(uint16_t Connection_Handle,
 uint16_t MaxTxOctets,
 uint16_t MaxTxTime,
 uint16_t MaxRxOctets,
 uint16_t MaxRxTime)
{
}
 
 
static void User_Process(void)
{
 tBleStatus ret;
 
 if (connected)
 {
 if ((mtu_exchanged == false) && (mtu_exchanged_wait == 0))
 {
 mtu_exchanged_wait = 1;
 ret = aci_gatt_exchange_config(connection_handle);
 if (ret != BLE_STATUS_SUCCESS)
 {
 // Handle error
 }
 
 ret = hci_le_set_data_length(connection_handle, CLIENT_MAX_MTU_SIZE, TX_OCTETS_TO_TIME(CLIENT_MAX_MTU_SIZE));
 if (ret != BLE_STATUS_SUCCESS)
 {
 // Handle error
 }
 }
 }
}
 
void send_data(void)
{
 aci_gatt_update_char_value_ext(handle,
 serv_handle,
 char_handle,
 1, 170, 0, 170, buff);
}

I am trying to send 170 bytes of data per packet. Is the above method correct?

I am not getting hci_le_data_length_change_event callback when connected to some phones. The phone specs mention that it has BLE v4.2, still unable to get callback. How to resolve this issue?

2 replies

Billy OWEN
ST Employee
March 17, 2023

Hi @RMoc.1​ 

The forum moderator had marked your post as needing a little more investigation and direct support. An online support case has been created on your behalf, please stand by for just a moment and you will hear from us.

Regards,

Billy

RMoc.1
RMoc.1Author
Associate II
March 20, 2023

Thanks for the update @Billy OWEN​.

Just to add, I have flashed the module with DTM_SPI_M2SA firmware from BLUENRG1-DK -- BlueNRG-1, BlueNRG-2 DK SW package v3.2.3 to use as a network co processor. Also the HS_SPEED_XTAL = HS_CRYSTAL_32MHZ, LS_SOURCE = LS_SOURCE_32KHZ & SMPS_INDUCTOR = SMSP_10uH changes are made in the firmware.

Visitor II
November 21, 2024

Dear ST, I have the same issue. I applied all the changes suggested in the application note pm0257 and also used by user RMoc.1 above. However, even if I can transmit data > 20 bytes, I am not able to receive data > 20 bytes. Can you please help?

Thank you.