diff --git a/ble/att.c b/ble/att.c index 14f10c731..e37afb5ef 100644 --- a/ble/att.c +++ b/ble/att.c @@ -290,10 +290,13 @@ static uint16_t handle_exchange_mtu_request(att_connection_t * att_connection, u uint8_t * response_buffer){ uint16_t client_rx_mtu = READ_BT_16(request_buffer, 1); - if (client_rx_mtu < att_connection->mtu){ - att_connection->mtu = client_rx_mtu; - } + if (client_rx_mtu < l2cap_le_max_mtu()){ + att_connection->mtu = client_rx_mtu; + } else { + att_connection->mtu = l2cap_le_max_mtu(); + } + response_buffer[0] = ATT_EXCHANGE_MTU_RESPONSE; bt_store_16(response_buffer, 1, att_connection->mtu); return 3; diff --git a/ble/att_server.c b/ble/att_server.c index d3cb42a43..840202098 100644 --- a/ble/att_server.c +++ b/ble/att_server.c @@ -126,7 +126,7 @@ static void att_event_packet_handler (uint8_t packet_type, uint16_t channel, uin bt_flip_addr(att_client_address, &packet[8]); // reset connection properties att_connection.con_handle = READ_BT_16(packet, 4); - att_connection.mtu = l2cap_max_le_mtu(); + att_connection.mtu = ATT_DEFAULT_MTU; att_connection.encryption_key_size = 0; att_connection.authenticated = 0; att_connection.authorized = 0;