add gatt_get_mtu daemon command and GATT_MTU response event

This commit is contained in:
Matthias Ringwald 2015-04-03 22:42:05 +02:00
parent 142d429464
commit bac1ffdb4f
4 changed files with 33 additions and 0 deletions

View File

@ -535,6 +535,13 @@ extern "C" {
#define GATT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT 0xA9
#define GATT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT 0xAA
/**
* @format H2
* @param handle
* @param MTU
*/
#define GATT_MTU 0xAB
/**
* @format H2
* @param handle

View File

@ -564,6 +564,19 @@ static void send_gatt_query_complete(connection_t * connection, uint16_t handle,
socket_connection_send_packet(connection, HCI_EVENT_PACKET, 0, event, sizeof(event));
}
static void send_gatt_mtu_event(connection_t * connection, uint16_t handle, uint16_t mtu){
uint8_t event[6];
int pos = 0;
event[pos++] = GATT_MTU;
event[pos++] = sizeof(event) - 2;
bt_store_16(event, pos, handle);
pos += 2;
bt_store_16(event, pos, mtu);
pos += 2;
hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event));
socket_connection_send_packet(connection, HCI_EVENT_PACKET, 0, event, sizeof(event));
}
linked_list_gatt_client_helper_t * daemon_setup_gatt_client_request(connection_t *connection, uint8_t *packet) {
hci_con_handle_t handle = READ_BT_16(packet, 3);
log_info("daemon_setup_gatt_client_request for handle 0x%02x", handle);
@ -1063,6 +1076,11 @@ static int btstack_command_handler(connection_t *connection, uint8_t *packet, ui
daemon_gatt_deserialize_characteristic(packet, 5, &characteristic);
gatt_client_write_client_characteristic_configuration(gatt_client_id, gatt_helper->con_handle, &characteristic, configuration);
break;
case GATT_GET_MTU:
handle = READ_BT_16(packet, 3);
gatt_client_get_mtu(handle, &mtu);
send_gatt_mtu_event(connection, handle, mtu);
break;
}
#endif
default:

View File

@ -230,6 +230,7 @@ extern "C" {
#define GATT_WRITE_CHARACTERISTIC_DESCRIPTOR 0X7F
#define GATT_WRITE_LONG_CHARACTERISTIC_DESCRIPTOR 0X80
#define GATT_WRITE_CLIENT_CHARACTERISTIC_CONFIGURATION 0X81
#define GATT_GET_MTU 0x82
//
#define IS_COMMAND(packet, command) (READ_BT_16(packet,0) == command.opcode)

View File

@ -1400,3 +1400,10 @@ const hci_cmd_t gatt_write_long_characteristic_descriptor_cmd = {
const hci_cmd_t gatt_write_client_characteristic_configuration_cmd = {
OPCODE(OGF_BTSTACK, GATT_WRITE_CLIENT_CHARACTERISTIC_CONFIGURATION), "HY2"
};
/**
* @param handle
*/
const hci_cmd_t gatt_get_mtu = {
OPCODE(OGF_BTSTACK, GATT_GET_MTU), "H"
};