From 559e517e9ce73df1e8c0732cdee9e8cec64c8d53 Mon Sep 17 00:00:00 2001 From: "matthias.ringwald@gmail.com" Date: Thu, 7 Mar 2013 16:32:49 +0000 Subject: [PATCH] query local supported features during HCI setup --- src/hci.c | 15 +++++++++++++-- src/hci.h | 5 ++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/hci.c b/src/hci.c index c399130df..7f3a15365 100644 --- a/src/hci.c +++ b/src/hci.c @@ -450,6 +450,14 @@ static void event_handler(uint8_t *packet, int size){ if (COMMAND_COMPLETE_EVENT(packet, hci_write_scan_enable)){ hci_emit_discoverable_enabled(hci_stack.discoverable); } + if (COMMAND_COMPLETE_EVENT(packet, hci_read_local_supported_features)){ + memcpy(hci_stack.local_supported_features, &packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE], 8); + log_info("Local Supported Features: 0x%02x%02x%02x%02x%02x%02x%02x%02x", + hci_stack.local_supported_features[0], hci_stack.local_supported_features[1], + hci_stack.local_supported_features[2], hci_stack.local_supported_features[3], + hci_stack.local_supported_features[4], hci_stack.local_supported_features[5], + hci_stack.local_supported_features[6], hci_stack.local_supported_features[7]); + } break; case HCI_EVENT_COMMAND_STATUS: @@ -1122,6 +1130,9 @@ void hci_run(){ hci_send_cmd(&hci_write_scan_enable, (hci_stack.connectable << 1) | hci_stack.discoverable); // page scan break; case 7: + hci_send_cmd(&hci_read_local_supported_features); + break; + case 8: #ifndef EMBEDDED { char hostname[30]; @@ -1130,12 +1141,12 @@ void hci_run(){ hci_send_cmd(&hci_write_local_name, hostname); break; } - case 8: + case 9: #ifdef USE_BLUETOOL hci_send_cmd(&hci_write_class_of_device, 0x007a020c); // Smartphone break; - case 9: + case 10: #endif #endif // done. diff --git a/src/hci.h b/src/hci.h index 82d91715a..64e3379d6 100644 --- a/src/hci.h +++ b/src/hci.h @@ -278,6 +278,9 @@ typedef struct { uint8_t total_num_acl_packets; uint16_t acl_data_packet_length; + /* local supported features */ + uint8_t local_supported_features[8]; + // usable packet types given acl_data_packet_length and HCI_ACL_BUFFER_SIZE uint16_t packet_types; @@ -357,7 +360,7 @@ void hci_register_packet_handler(void (*handler)(uint8_t packet_type, uint8_t *p // Requests the change of BTstack power mode. int hci_power_control(HCI_POWER_MODE mode); -// Allows to control if device is dicoverable. OFF by default. +// Allows to control if device is discoverable. OFF by default. void hci_discoverable_control(uint8_t enable); // Creates and sends hci command packets based on a template and