Browse Source

Bluetooth: Read BLE vendor capability to proceed on Secure conn

- Read BLE vendor capability to proceed on enablement of
  secure connection support from Host.

- If BLE vendor capability is supported from the controller
  then secure connection is enabled from Host.

CRs-Fixed: 1041642
Change-Id: I64e79d4e6fff7d9f1b0ea7272250e8155f5888e2
Signed-off-by: Akhil Narang <akhilnarang.1999@gmail.com>
ten
Srinu Jella 6 years ago
parent
commit
de1daf3406
No account linked to committer's email address

+ 1
- 0
device/include/controller.h View File

@@ -85,6 +85,7 @@ typedef struct controller_t {
uint8_t (*get_ble_resolving_list_max_size)(void);
void (*set_ble_resolving_list_max_size)(int resolving_list_max_size);
uint8_t* (*get_local_supported_codecs)(uint8_t* number_of_codecs);
bool (*supports_ble_offload_features)(void);
uint8_t (*get_le_all_initiating_phys)(void);

} controller_t;

+ 20
- 7
device/src/controller.cc View File

@@ -85,6 +85,7 @@ static uint8_t number_of_local_supported_codecs = 0;

static bool readable;
static bool ble_supported;
static bool ble_offload_features_supported;
static bool simple_pairing_supported;
static bool secure_connections_supported;

@@ -182,14 +183,19 @@ static future_t* start_up(void) {
page_number++;
}

// read BLE offload features support from controller
response = AWAIT_COMMAND(packet_factory->make_ble_read_offload_features_support());
packet_parser->parse_ble_read_offload_features_response(response, &ble_offload_features_supported);
#if (SC_MODE_INCLUDED == TRUE)
secure_connections_supported =
HCI_SC_CTRLR_SUPPORTED(features_classic[2].as_array);
if (secure_connections_supported) {
response = AWAIT_COMMAND(
packet_factory->make_write_secure_connections_host_support(
HCI_SC_MODE_ENABLED));
packet_parser->parse_generic_command_complete(response);
if(ble_offload_features_supported) {
secure_connections_supported =
HCI_SC_CTRLR_SUPPORTED(features_classic[2].as_array);
if (secure_connections_supported) {
response = AWAIT_COMMAND(
packet_factory->make_write_secure_connections_host_support(
HCI_SC_MODE_ENABLED));
packet_parser->parse_generic_command_complete(response);
}
}
#endif

@@ -447,6 +453,12 @@ static bool supports_ble_periodic_advertising(void) {
return HCI_LE_PERIODIC_ADVERTISING_SUPPORTED(features_ble.as_array);
}

static bool supports_ble_offload_features(void) {
assert(readable);
assert(ble_supported);
return ble_offload_features_supported;
}

static uint16_t get_acl_data_size_classic(void) {
CHECK(readable);
return acl_data_size_classic;
@@ -584,6 +596,7 @@ static const controller_t interface = {
get_ble_resolving_list_max_size,
set_ble_resolving_list_max_size,
get_local_supported_codecs,
supports_ble_offload_features,
get_le_all_initiating_phys};

const controller_t* controller_get_interface() {

+ 1
- 0
hci/include/hci_packet_factory.h View File

@@ -46,6 +46,7 @@ typedef struct {
BT_HDR* (*make_ble_read_number_of_supported_advertising_sets)(void);
BT_HDR* (*make_ble_set_event_mask)(const bt_event_mask_t* event_mask);
BT_HDR* (*make_read_local_supported_codecs)(void);
BT_HDR *(*make_ble_read_offload_features_support)(void);
} hci_packet_factory_t;

const hci_packet_factory_t* hci_packet_factory_get_interface();

+ 3
- 0
hci/include/hci_packet_parser.h View File

@@ -83,6 +83,9 @@ typedef struct {
BT_HDR* response, uint8_t* number_of_local_supported_codecs,
uint8_t* local_supported_codecs);

void (*parse_ble_read_offload_features_response)(
BT_HDR *response,
bool *ble_offload_features_supported);
} hci_packet_parser_t;

const hci_packet_parser_t* hci_packet_parser_get_interface();

+ 19
- 0
hci/src/hci_layer.cc View File

@@ -672,7 +672,26 @@ static waiting_command_t* get_waiting_command(command_opcode_t opcode) {

return wait_entry;
}
// look for any command complete with improper VS Opcode
for (const list_node_t *node = list_begin(commands_pending_response);
node != list_end(commands_pending_response);
node = list_next(node)) {
waiting_command_t *wait_entry =
reinterpret_cast<waiting_command_t*> (list_node(node));

if (wait_entry && (wait_entry->opcode != opcode) &&
(((wait_entry->opcode & HCI_GRP_VENDOR_SPECIFIC) == HCI_GRP_VENDOR_SPECIFIC) &&
((opcode & HCI_GRP_VENDOR_SPECIFIC) == HCI_GRP_VENDOR_SPECIFIC))) {
LOG_DEBUG(LOG_TAG,"%s VS event found treat it as valid 0x%x", __func__, opcode);
}
else {
continue;
}

list_remove(commands_pending_response, wait_entry);

return wait_entry;
}
return NULL;
}


+ 6
- 1
hci/src/hci_packet_factory.cc View File

@@ -159,6 +159,10 @@ static BT_HDR* make_read_local_supported_codecs(void) {
return make_command_no_params(HCI_READ_LOCAL_SUPPORTED_CODECS);
}

static BT_HDR* make_ble_read_offload_features_support(void) {
return make_command_no_params(HCI_BLE_VENDOR_CAP_OCF);
}

static BT_HDR* make_ble_set_event_mask(const bt_event_mask_t* event_mask) {
uint8_t* stream;
uint8_t parameter_size = sizeof(bt_event_mask_t);
@@ -220,7 +224,8 @@ static const hci_packet_factory_t interface = {
make_ble_read_maximum_advertising_data_length,
make_ble_read_number_of_supported_advertising_sets,
make_ble_set_event_mask,
make_read_local_supported_codecs};
make_read_local_supported_codecs,
make_ble_read_offload_features_support};

const hci_packet_factory_t* hci_packet_factory_get_interface() {
buffer_allocator = buffer_allocator_get_interface();

+ 16
- 1
hci/src/hci_packet_parser.cc View File

@@ -85,6 +85,20 @@ static void parse_read_local_supported_codecs_response(
buffer_allocator->free(response);
}

static void parse_ble_read_offload_features_response(
BT_HDR *response,
bool *ble_offload_features_supported) {

uint8_t *stream = read_command_complete_header(response, NO_OPCODE_CHECKING, 0 /* bytes after */);
if(stream) {
*ble_offload_features_supported = true;
} else {
*ble_offload_features_supported = false;
}

buffer_allocator->free(response);
}

static void parse_read_bd_addr_response(BT_HDR* response,
RawAddress* address_ptr) {
uint8_t* stream = read_command_complete_header(
@@ -281,7 +295,8 @@ static const hci_packet_parser_t interface = {
parse_ble_read_maximum_data_length_response,
parse_ble_read_maximum_advertising_data_length,
parse_ble_read_number_of_supported_advertising_sets,
parse_read_local_supported_codecs_response};
parse_read_local_supported_codecs_response,
parse_ble_read_offload_features_response};

const hci_packet_parser_t* hci_packet_parser_get_interface() {
buffer_allocator = buffer_allocator_get_interface();

Loading…
Cancel
Save