Enable Data Length Extension (DLE) and increase MTU size BlueNRG M2
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?
