mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-15 23:42:52 +00:00
gatt_client/att_server: track mtu exchanged in hci_connection->att_connection
This commit is contained in:
parent
388fa7c4de
commit
dde9ff1e19
@ -369,6 +369,7 @@ static uint16_t handle_exchange_mtu_request(att_connection_t * att_connection, u
|
||||
// find min(local max mtu, remote mtu) >= ATT_DEFAULT_MTU and use as mtu for this connection
|
||||
uint16_t min_mtu = btstack_min(client_rx_mtu, att_connection->max_mtu);
|
||||
uint16_t new_mtu = btstack_max(ATT_DEFAULT_MTU, min_mtu);
|
||||
att_connection->mtu_exchanged = true;
|
||||
att_connection->mtu = new_mtu;
|
||||
|
||||
response_buffer[0] = ATT_EXCHANGE_MTU_RESPONSE;
|
||||
|
@ -109,6 +109,7 @@ typedef struct att_connection {
|
||||
hci_con_handle_t con_handle;
|
||||
uint16_t mtu; // initialized to ATT_DEFAULT_MTU (23), negotiated during MTU exchange
|
||||
uint16_t max_mtu; // local maximal L2CAP_MTU, set to l2cap_max_le_mtu()
|
||||
bool mtu_exchanged;
|
||||
uint8_t encryption_key_size;
|
||||
uint8_t authenticated;
|
||||
uint8_t authorized;
|
||||
|
@ -1319,8 +1319,17 @@ static void gatt_client_att_packet_handler(uint8_t packet_type, uint16_t handle,
|
||||
if (size < 3u) break;
|
||||
uint16_t remote_rx_mtu = little_endian_read_16(packet, 1);
|
||||
uint16_t local_rx_mtu = l2cap_max_le_mtu();
|
||||
gatt_client->mtu = (remote_rx_mtu < local_rx_mtu) ? remote_rx_mtu : local_rx_mtu;
|
||||
uint16_t mtu = (remote_rx_mtu < local_rx_mtu) ? remote_rx_mtu : local_rx_mtu;
|
||||
|
||||
// set gatt client mtu
|
||||
gatt_client->mtu = mtu;
|
||||
gatt_client->mtu_state = MTU_EXCHANGED;
|
||||
|
||||
// set per connection mtu state
|
||||
hci_connection_t * hci_connection = hci_connection_for_handle(handle);
|
||||
hci_connection->att_connection.mtu = gatt_client->mtu;
|
||||
hci_connection->att_connection.mtu_exchanged = true;
|
||||
|
||||
emit_gatt_mtu_exchanged_result_event(gatt_client, gatt_client->mtu);
|
||||
break;
|
||||
}
|
||||
|
@ -2221,7 +2221,11 @@ static void event_handle_le_connection_complete(const uint8_t * packet){
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO: store - role, peer address type, conn_interval, conn_latency, supervision timeout, master clock
|
||||
// init unenhanced att bearer mtu
|
||||
conn->att_connection.mtu = ATT_DEFAULT_MTU;
|
||||
conn->att_connection.mtu_exchanged = false;
|
||||
|
||||
// TODO: store - role, peer address type, conn_interval, conn_latency, supervision timeout, master clock
|
||||
|
||||
// restart timer
|
||||
// btstack_run_loop_set_timer(&conn->timeout, HCI_CONNECTION_TIMEOUT_MS);
|
||||
|
Loading…
x
Reference in New Issue
Block a user