mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-28 19:20:54 +00:00
auto-pts: larger response buffer, send event for BTP_GATT_OP_READ_UUID on gatt query complete
This commit is contained in:
parent
ea4b5aab54
commit
fc823f601c
@ -158,13 +158,13 @@ void btp_socket_process(btstack_data_source_t *socket_ds, btstack_data_source_ca
|
|||||||
* send BTP packet
|
* send BTP packet
|
||||||
*/
|
*/
|
||||||
void btp_socket_send_packet(uint16_t service_id, uint8_t opcode, uint8_t controller_index, uint16_t length, const uint8_t *data){
|
void btp_socket_send_packet(uint16_t service_id, uint8_t opcode, uint8_t controller_index, uint16_t length, const uint8_t *data){
|
||||||
if (socket_ds.source.fd == 0) return;
|
|
||||||
|
|
||||||
#ifdef LOG_BTP
|
#ifdef LOG_BTP
|
||||||
log_info("btp_socket_send_packet: service_id %0x, opcode %02x, controller_index 0x%02x, length %u", service_id, opcode, controller_index, length);
|
log_info("btp_socket_send_packet: service_id %0x, opcode %02x, controller_index 0x%02x, length %u", service_id, opcode, controller_index, length);
|
||||||
log_info_hexdump(data, length);
|
log_info_hexdump(data, length);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (socket_ds.source.fd == 0) return;
|
||||||
|
|
||||||
uint8_t header[BTP_HEADER_LEN];
|
uint8_t header[BTP_HEADER_LEN];
|
||||||
header[0] = service_id;
|
header[0] = service_id;
|
||||||
header[1] = opcode;
|
header[1] = opcode;
|
||||||
|
@ -80,8 +80,8 @@ static btstack_timer_source_t gap_connection_timer;
|
|||||||
// Global response buffer
|
// Global response buffer
|
||||||
static uint8_t response_service_id;
|
static uint8_t response_service_id;
|
||||||
static uint8_t response_op;
|
static uint8_t response_op;
|
||||||
static uint8_t response_buffer[200];
|
|
||||||
static uint16_t response_len;
|
static uint16_t response_len;
|
||||||
|
static uint8_t response_buffer[512];
|
||||||
|
|
||||||
static uint8_t value_buffer[512];
|
static uint8_t value_buffer[512];
|
||||||
|
|
||||||
@ -448,11 +448,11 @@ static void btp_append_blob(uint16_t len, const uint8_t * data){
|
|||||||
|
|
||||||
static void btp_append_uuid(uint16_t uuid16, const uint8_t * uuid128){
|
static void btp_append_uuid(uint16_t uuid16, const uint8_t * uuid128){
|
||||||
if (uuid16 == 0){
|
if (uuid16 == 0){
|
||||||
response_buffer[response_len++] = 16;
|
btp_append_uint8(16);
|
||||||
reverse_128(uuid128, &response_buffer[response_len]);
|
reverse_128(uuid128, &response_buffer[response_len]);
|
||||||
response_len += 16;
|
response_len += 16;
|
||||||
} else {
|
} else {
|
||||||
response_buffer[response_len++] = 2;
|
btp_append_uint8(2);
|
||||||
btp_append_uint16(uuid16);
|
btp_append_uint16(uuid16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -505,9 +505,6 @@ static void gatt_client_packet_handler(uint8_t packet_type, uint16_t channel, ui
|
|||||||
value_len = gatt_event_characteristic_value_query_result_get_value_length(packet);
|
value_len = gatt_event_characteristic_value_query_result_get_value_length(packet);
|
||||||
btp_append_uint16(value_len);
|
btp_append_uint16(value_len);
|
||||||
btp_append_blob(value_len, gatt_event_characteristic_value_query_result_get_value(packet));
|
btp_append_blob(value_len, gatt_event_characteristic_value_query_result_get_value(packet));
|
||||||
uint8_t op = response_op;
|
|
||||||
response_op = 0;
|
|
||||||
btp_socket_send_packet(response_service_id, op, 0, response_len, response_buffer);
|
|
||||||
} else {
|
} else {
|
||||||
MESSAGE("GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT but not op pending");
|
MESSAGE("GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT but not op pending");
|
||||||
}
|
}
|
||||||
@ -518,10 +515,13 @@ static void gatt_client_packet_handler(uint8_t packet_type, uint16_t channel, ui
|
|||||||
response_op = 0;
|
response_op = 0;
|
||||||
switch (op){
|
switch (op){
|
||||||
case BTP_GATT_OP_READ:
|
case BTP_GATT_OP_READ:
|
||||||
|
case BTP_GATT_OP_READ_UUID:
|
||||||
case BTP_GATT_OP_READ_LONG:
|
case BTP_GATT_OP_READ_LONG:
|
||||||
// if we got here, the read failed
|
if (response_len == 0){
|
||||||
btp_append_uint8(gatt_event_query_complete_get_att_status(packet));
|
// if we got here, the read failed and we report the att status
|
||||||
btp_append_uint16(0);
|
btp_append_uint8(gatt_event_query_complete_get_att_status(packet));
|
||||||
|
btp_append_uint16(0);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case BTP_GATT_OP_WRITE_LONG:
|
case BTP_GATT_OP_WRITE_LONG:
|
||||||
case BTP_GATT_OP_WRITE:
|
case BTP_GATT_OP_WRITE:
|
||||||
@ -1529,6 +1529,7 @@ static void usage(void){
|
|||||||
case CONSOLE_STATE_GATT_CLIENT:
|
case CONSOLE_STATE_GATT_CLIENT:
|
||||||
printf("BTstack BTP Client for auto-pts framework: GATT Client console interface\n");
|
printf("BTstack BTP Client for auto-pts framework: GATT Client console interface\n");
|
||||||
printf("a - read attribute with handle 0009\n");
|
printf("a - read attribute with handle 0009\n");
|
||||||
|
printf("a - discover characteristics with handle 0001-ffff\n");
|
||||||
printf("l - write long attribute with handle 00ca\n");
|
printf("l - write long attribute with handle 00ca\n");
|
||||||
printf("x - Back to main\n");
|
printf("x - Back to main\n");
|
||||||
break;
|
break;
|
||||||
@ -1549,6 +1550,7 @@ static void stdin_process(char cmd){
|
|||||||
const uint8_t rpa_adv[] = { 0x08, 0x00, 0x08, 0x06, 'T', 'e', 's', 't', 'e', 'r', 0xff, 0xff, 0xff, 0xff, 0x02, };
|
const uint8_t rpa_adv[] = { 0x08, 0x00, 0x08, 0x06, 'T', 'e', 's', 't', 'e', 'r', 0xff, 0xff, 0xff, 0xff, 0x02, };
|
||||||
const uint8_t non_rpa_adv[] = { 0x08, 0x00, 0x08, 0x06, 'T', 'e', 's', 't', 'e', 'r', 0xff, 0xff, 0xff, 0xff, 0x03, };
|
const uint8_t non_rpa_adv[] = { 0x08, 0x00, 0x08, 0x06, 'T', 'e', 's', 't', 'e', 'r', 0xff, 0xff, 0xff, 0xff, 0x03, };
|
||||||
const uint8_t gc_read_0009[] = { 0, 1,2,3,4,5,6, 0x09, 0x00};
|
const uint8_t gc_read_0009[] = { 0, 1,2,3,4,5,6, 0x09, 0x00};
|
||||||
|
const uint8_t gc_discover_characteristics_0000_ffff[] = { 0, 1,2,3,4,5,6, 0x01, 0x00, 0xff, 0xff};
|
||||||
const uint8_t gc_write_long_00ca[] = {
|
const uint8_t gc_write_long_00ca[] = {
|
||||||
0x00, 0xEF, 0x32, 0x07, 0xDC, 0x1B, 0x00, 0xCA, 0x00, 0x00, 0x00, 0x23, 0x00, 0x12, 0x12, 0x12,
|
0x00, 0xEF, 0x32, 0x07, 0xDC, 0x1B, 0x00, 0xCA, 0x00, 0x00, 0x00, 0x23, 0x00, 0x12, 0x12, 0x12,
|
||||||
0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12,
|
0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12,
|
||||||
@ -1663,6 +1665,9 @@ static void stdin_process(char cmd){
|
|||||||
case 'a':
|
case 'a':
|
||||||
btp_packet_handler(BTP_SERVICE_ID_GATT, BTP_GATT_OP_READ, 0, sizeof(gc_read_0009), gc_read_0009);
|
btp_packet_handler(BTP_SERVICE_ID_GATT, BTP_GATT_OP_READ, 0, sizeof(gc_read_0009), gc_read_0009);
|
||||||
break;
|
break;
|
||||||
|
case 'c':
|
||||||
|
btp_packet_handler(BTP_SERVICE_ID_GATT, BTP_GATT_OP_DISC_ALL_CHRC, 0, sizeof(gc_discover_characteristics_0000_ffff), gc_discover_characteristics_0000_ffff);
|
||||||
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
btp_packet_handler(BTP_SERVICE_ID_GATT, BTP_GATT_OP_WRITE_LONG, 0, sizeof(gc_write_long_00ca), gc_write_long_00ca);
|
btp_packet_handler(BTP_SERVICE_ID_GATT, BTP_GATT_OP_WRITE_LONG, 0, sizeof(gc_write_long_00ca), gc_write_long_00ca);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user