emit event for ATT MTU size

This commit is contained in:
Matthias Ringwald 2015-04-03 21:58:10 +02:00
parent a4965b3654
commit 1c00af99f7
2 changed files with 30 additions and 2 deletions

View File

@ -104,6 +104,21 @@ static void att_handle_value_indication_notify_client(uint8_t status, uint16_t c
(*att_client_packet_handler)(HCI_EVENT_PACKET, 0, &event[0], sizeof(event));
}
static void att_emit_mtu_event(uint16_t handle, uin16_t mtu){
if (!att_client_packet_handler) return;
uint8_t event[5];
int pos = 0;
event[pos++] = ATT_MTU_EXCHANGE_COMPLETE;
event[pos++] = sizeof(event) - 2;
bt_store_16(event, pos, handle);
pos += 2;
bt_store_16(event, pos, mtu);
pos += 2;
(*att_client_packet_handler)(HCI_EVENT_PACKET, 0, &event[0], sizeof(event));
}
static void att_handle_value_indication_timeout(timer_source_t *ts){
uint16_t att_handle = att_handle_value_indication_handle;
att_handle_value_indication_notify_client(ATT_HANDLE_VALUE_INDICATION_TIMEOUT, att_connection.con_handle, att_handle);
@ -289,6 +304,12 @@ static void att_run(void){
}
l2cap_send_prepared_connectionless(att_connection.con_handle, L2CAP_CID_ATTRIBUTE_PROTOCOL, att_response_size);
// notify client about MTU exchange result
if (att_response_buffer[0] == ATT_EXCHANGE_MTU_RESPONSE){
att_emit_mtu_event(att_connection.con_handle, att_connection.mtu);
}
break;
}
}

View File

@ -534,9 +534,16 @@ extern "C" {
#define GATT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT 0xA9
#define GATT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT 0xAA
/**
* @format H2
* @param handle
* @param MTU
*/
#define ATT_MTU_EXCHANGE_COMPLETE 0xB5
// data: event(8), len(8), status (8), hci_handle (16), attribute_handle (16)
#define ATT_HANDLE_VALUE_INDICATION_COMPLETE 0xB6
#define ATT_HANDLE_VALUE_INDICATION_COMPLETE 0xB6
// data: event(8), len(8), status (8), bnep service uuid (16)