Loading system/btif/include/btif_common.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -212,7 +212,8 @@ void invoke_ssp_request_cb(RawAddress bd_addr, bt_bdname_t bd_name, uint32_t cod, bt_ssp_variant_t pairing_variant, uint32_t cod, bt_ssp_variant_t pairing_variant, uint32_t pass_key); uint32_t pass_key); void invoke_oob_data_request_cb(tBT_TRANSPORT t, bool valid, Octet16 c, void invoke_oob_data_request_cb(tBT_TRANSPORT t, bool valid, Octet16 c, Octet16 r, RawAddress raw_address); Octet16 r, RawAddress raw_address, uint8_t address_type); void invoke_bond_state_changed_cb(bt_status_t status, RawAddress bd_addr, void invoke_bond_state_changed_cb(bt_status_t status, RawAddress bd_addr, bt_bond_state_t state); bt_bond_state_t state); void invoke_acl_state_changed_cb(bt_status_t status, RawAddress bd_addr, void invoke_acl_state_changed_cb(bt_status_t status, RawAddress bd_addr, Loading system/btif/include/btif_gatt.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -27,6 +27,8 @@ #ifndef BTIF_GATT_H #ifndef BTIF_GATT_H #define BTIF_GATT_H #define BTIF_GATT_H #include "include/hardware/bt_gatt.h" extern const btgatt_client_interface_t btgattClientInterface; extern const btgatt_client_interface_t btgattClientInterface; extern const btgatt_server_interface_t btgattServerInterface; extern const btgatt_server_interface_t btgattServerInterface; Loading system/btif/src/bluetooth.cc +3 −3 Original line number Original line Diff line number Diff line Loading @@ -738,7 +738,8 @@ void invoke_ssp_request_cb(RawAddress bd_addr, bt_bdname_t bd_name, } } void invoke_oob_data_request_cb(tBT_TRANSPORT t, bool valid, Octet16 c, void invoke_oob_data_request_cb(tBT_TRANSPORT t, bool valid, Octet16 c, Octet16 r, RawAddress raw_address) { Octet16 r, RawAddress raw_address, uint8_t address_type) { LOG_INFO("%s", __func__); LOG_INFO("%s", __func__); bt_oob_data_t oob_data = {}; bt_oob_data_t oob_data = {}; Loading @@ -748,8 +749,7 @@ void invoke_oob_data_request_cb(tBT_TRANSPORT t, bool valid, Octet16 c, oob_data.address[i] = raw_address.address[j]; oob_data.address[i] = raw_address.address[j]; j--; j--; } } // Set type always public oob_data.address[6] = address_type; oob_data.address[6] = 0; // Each value (for C and R) is 16 octets in length // Each value (for C and R) is 16 octets in length bool c_empty = true; bool c_empty = true; Loading system/btif/src/btif_dm.cc +87 −8 Original line number Original line Diff line number Diff line Loading @@ -54,6 +54,7 @@ #include "btif_bqr.h" #include "btif_bqr.h" #include "btif_config.h" #include "btif_config.h" #include "btif_dm.h" #include "btif_dm.h" #include "btif_gatt.h" #include "btif_hd.h" #include "btif_hd.h" #include "btif_hf.h" #include "btif_hf.h" #include "btif_hh.h" #include "btif_hh.h" Loading Loading @@ -1338,16 +1339,16 @@ static void btif_dm_search_services_evt(tBTA_DM_SEARCH_EVT event, p_data->disc_res.num_uuids == 0) { p_data->disc_res.num_uuids == 0) { LOG_INFO("SDP failed, send empty UUID to unblock bonding %s", LOG_INFO("SDP failed, send empty UUID to unblock bonding %s", bd_addr.ToString().c_str()); bd_addr.ToString().c_str()); bt_property_t prop; bt_property_t prop_uuids; Uuid uuid = {}; Uuid uuid = {}; prop.type = BT_PROPERTY_UUIDS; prop_uuids.type = BT_PROPERTY_UUIDS; prop.val = &uuid; prop_uuids.val = &uuid; prop.len = Uuid::kNumBytes128; prop_uuids.len = Uuid::kNumBytes128; /* Send the event to the BTIF */ /* Send the event to the BTIF */ invoke_remote_device_properties_cb(BT_STATUS_SUCCESS, bd_addr, 1, invoke_remote_device_properties_cb(BT_STATUS_SUCCESS, bd_addr, 1, &prop); &prop_uuids); break; break; } } } } Loading Loading @@ -2378,14 +2379,92 @@ void btif_dm_generate_local_oob_data(tBT_TRANSPORT transport) { if (transport == BT_TRANSPORT_BR_EDR) { if (transport == BT_TRANSPORT_BR_EDR) { BTM_ReadLocalOobData(); BTM_ReadLocalOobData(); } else if (transport == BT_TRANSPORT_LE) { } else if (transport == BT_TRANSPORT_LE) { SMP_CrLocScOobData(base::BindOnce(&btif_dm_proc_loc_oob)); // Call create data first, so we don't have to hold on to the address for // the state machine lifecycle. Rather, lets create the data, then start // advertising then request the address. SMP_CrLocScOobData(); } } // Step Four: CallBack from Step Three static void get_address_callback(tBT_TRANSPORT transport, bool is_valid, const Octet16& c, const Octet16& r, uint8_t address_type, RawAddress address) { invoke_oob_data_request_cb(transport, is_valid, c, r, address, address_type); } // Step Three: CallBack from Step Two, advertise and get address static void start_advertising_callback(uint8_t id, tBT_TRANSPORT transport, bool is_valid, const Octet16& c, const Octet16& r, uint8_t status) { if (status != 0) { LOG_INFO("OOB get advertiser ID failed with status %hhd", status); invoke_oob_data_request_cb(transport, false, c, r, RawAddress{}, 0x00); SMP_ClearLocScOobData(); return; } } LOG_DEBUG("OOB advertiser with id %hhd", id); auto advertiser = get_ble_advertiser_instance(); advertiser->GetOwnAddress( id, base::Bind(&get_address_callback, transport, is_valid, c, r)); } static void timeout_cb(uint8_t id, uint8_t status) { LOG_INFO("OOB advertiser with id %hhd timed out with status %hhd", id, status); auto advertiser = get_ble_advertiser_instance(); advertiser->Unregister(id); SMP_ClearLocScOobData(); } // Step Two: CallBack from Step One, advertise and get address static void id_status_callback(tBT_TRANSPORT transport, bool is_valid, const Octet16& c, const Octet16& r, uint8_t id, uint8_t status) { if (status != 0) { LOG_INFO("OOB get advertiser ID failed with status %hhd", status); invoke_oob_data_request_cb(transport, false, c, r, RawAddress{}, 0x00); SMP_ClearLocScOobData(); return; } auto advertiser = get_ble_advertiser_instance(); AdvertiseParameters parameters; parameters.advertising_event_properties = 0x0041 /* connectable, tx power */; parameters.min_interval = 0xa0; // 100 ms parameters.max_interval = 0x500; // 800 ms parameters.channel_map = 0x7; // Use all the channels parameters.tx_power = 0; // 0 dBm parameters.primary_advertising_phy = 1; parameters.secondary_advertising_phy = 2; parameters.scan_request_notification_enable = 0; std::vector<uint8_t> advertisement{0x02, 0x01 /* Flags */, 0x02 /* Connectable */}; std::vector<uint8_t> scan_data{}; advertiser->StartAdvertising( id, base::Bind(&start_advertising_callback, id, transport, is_valid, c, r), parameters, advertisement, scan_data, 3600 /* timeout_s */, base::Bind(&timeout_cb, id)); } // Step One: Start the advertiser static void start_oob_advertiser(tBT_TRANSPORT transport, bool is_valid, const Octet16& c, const Octet16& r) { auto advertiser = get_ble_advertiser_instance(); advertiser->RegisterAdvertiser( base::Bind(&id_status_callback, transport, is_valid, c, r)); } } void btif_dm_proc_loc_oob(tBT_TRANSPORT transport, bool is_valid, void btif_dm_proc_loc_oob(tBT_TRANSPORT transport, bool is_valid, const Octet16& c, const Octet16& r) { const Octet16& c, const Octet16& r) { invoke_oob_data_request_cb(transport, is_valid, c, r, // is_valid is important for deciding which OobDataCallback function to use *controller_get_interface()->get_address()); if (!is_valid) invoke_oob_data_request_cb(transport, false, c, r, RawAddress{}, 0x00); // Now that we have the data, lets start advertising and get the address. start_oob_advertiser(transport, is_valid, c, r); } } /******************************************************************************* /******************************************************************************* Loading system/stack/include/smp_api.h +9 −6 Original line number Original line Diff line number Diff line Loading @@ -182,14 +182,17 @@ extern void SMP_SecureConnectionOobDataReply(uint8_t* p_data); * Description This function is called to generate a public key to be * Description This function is called to generate a public key to be * passed to a remote device via an Out of Band transport * passed to a remote device via an Out of Band transport * * * Parameters: callback - receive the data ******************************************************************************/ extern void SMP_CrLocScOobData(); /******************************************************************************* * * Function SMP_ClearLocScOobData * * Description This function is called to clear out the OOB stored locally. * * ******************************************************************************/ ******************************************************************************/ extern void SMP_CrLocScOobData( extern void SMP_ClearLocScOobData(); base::OnceCallback<void(tBT_TRANSPORT, bool, const std::array<unsigned char, 16>&, const std::array<unsigned char, 16>&)> callback); // Called when LTK request is received from controller. // Called when LTK request is received from controller. extern bool smp_proc_ltk_request(const RawAddress& bda); extern bool smp_proc_ltk_request(const RawAddress& bda); Loading Loading
system/btif/include/btif_common.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -212,7 +212,8 @@ void invoke_ssp_request_cb(RawAddress bd_addr, bt_bdname_t bd_name, uint32_t cod, bt_ssp_variant_t pairing_variant, uint32_t cod, bt_ssp_variant_t pairing_variant, uint32_t pass_key); uint32_t pass_key); void invoke_oob_data_request_cb(tBT_TRANSPORT t, bool valid, Octet16 c, void invoke_oob_data_request_cb(tBT_TRANSPORT t, bool valid, Octet16 c, Octet16 r, RawAddress raw_address); Octet16 r, RawAddress raw_address, uint8_t address_type); void invoke_bond_state_changed_cb(bt_status_t status, RawAddress bd_addr, void invoke_bond_state_changed_cb(bt_status_t status, RawAddress bd_addr, bt_bond_state_t state); bt_bond_state_t state); void invoke_acl_state_changed_cb(bt_status_t status, RawAddress bd_addr, void invoke_acl_state_changed_cb(bt_status_t status, RawAddress bd_addr, Loading
system/btif/include/btif_gatt.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -27,6 +27,8 @@ #ifndef BTIF_GATT_H #ifndef BTIF_GATT_H #define BTIF_GATT_H #define BTIF_GATT_H #include "include/hardware/bt_gatt.h" extern const btgatt_client_interface_t btgattClientInterface; extern const btgatt_client_interface_t btgattClientInterface; extern const btgatt_server_interface_t btgattServerInterface; extern const btgatt_server_interface_t btgattServerInterface; Loading
system/btif/src/bluetooth.cc +3 −3 Original line number Original line Diff line number Diff line Loading @@ -738,7 +738,8 @@ void invoke_ssp_request_cb(RawAddress bd_addr, bt_bdname_t bd_name, } } void invoke_oob_data_request_cb(tBT_TRANSPORT t, bool valid, Octet16 c, void invoke_oob_data_request_cb(tBT_TRANSPORT t, bool valid, Octet16 c, Octet16 r, RawAddress raw_address) { Octet16 r, RawAddress raw_address, uint8_t address_type) { LOG_INFO("%s", __func__); LOG_INFO("%s", __func__); bt_oob_data_t oob_data = {}; bt_oob_data_t oob_data = {}; Loading @@ -748,8 +749,7 @@ void invoke_oob_data_request_cb(tBT_TRANSPORT t, bool valid, Octet16 c, oob_data.address[i] = raw_address.address[j]; oob_data.address[i] = raw_address.address[j]; j--; j--; } } // Set type always public oob_data.address[6] = address_type; oob_data.address[6] = 0; // Each value (for C and R) is 16 octets in length // Each value (for C and R) is 16 octets in length bool c_empty = true; bool c_empty = true; Loading
system/btif/src/btif_dm.cc +87 −8 Original line number Original line Diff line number Diff line Loading @@ -54,6 +54,7 @@ #include "btif_bqr.h" #include "btif_bqr.h" #include "btif_config.h" #include "btif_config.h" #include "btif_dm.h" #include "btif_dm.h" #include "btif_gatt.h" #include "btif_hd.h" #include "btif_hd.h" #include "btif_hf.h" #include "btif_hf.h" #include "btif_hh.h" #include "btif_hh.h" Loading Loading @@ -1338,16 +1339,16 @@ static void btif_dm_search_services_evt(tBTA_DM_SEARCH_EVT event, p_data->disc_res.num_uuids == 0) { p_data->disc_res.num_uuids == 0) { LOG_INFO("SDP failed, send empty UUID to unblock bonding %s", LOG_INFO("SDP failed, send empty UUID to unblock bonding %s", bd_addr.ToString().c_str()); bd_addr.ToString().c_str()); bt_property_t prop; bt_property_t prop_uuids; Uuid uuid = {}; Uuid uuid = {}; prop.type = BT_PROPERTY_UUIDS; prop_uuids.type = BT_PROPERTY_UUIDS; prop.val = &uuid; prop_uuids.val = &uuid; prop.len = Uuid::kNumBytes128; prop_uuids.len = Uuid::kNumBytes128; /* Send the event to the BTIF */ /* Send the event to the BTIF */ invoke_remote_device_properties_cb(BT_STATUS_SUCCESS, bd_addr, 1, invoke_remote_device_properties_cb(BT_STATUS_SUCCESS, bd_addr, 1, &prop); &prop_uuids); break; break; } } } } Loading Loading @@ -2378,14 +2379,92 @@ void btif_dm_generate_local_oob_data(tBT_TRANSPORT transport) { if (transport == BT_TRANSPORT_BR_EDR) { if (transport == BT_TRANSPORT_BR_EDR) { BTM_ReadLocalOobData(); BTM_ReadLocalOobData(); } else if (transport == BT_TRANSPORT_LE) { } else if (transport == BT_TRANSPORT_LE) { SMP_CrLocScOobData(base::BindOnce(&btif_dm_proc_loc_oob)); // Call create data first, so we don't have to hold on to the address for // the state machine lifecycle. Rather, lets create the data, then start // advertising then request the address. SMP_CrLocScOobData(); } } // Step Four: CallBack from Step Three static void get_address_callback(tBT_TRANSPORT transport, bool is_valid, const Octet16& c, const Octet16& r, uint8_t address_type, RawAddress address) { invoke_oob_data_request_cb(transport, is_valid, c, r, address, address_type); } // Step Three: CallBack from Step Two, advertise and get address static void start_advertising_callback(uint8_t id, tBT_TRANSPORT transport, bool is_valid, const Octet16& c, const Octet16& r, uint8_t status) { if (status != 0) { LOG_INFO("OOB get advertiser ID failed with status %hhd", status); invoke_oob_data_request_cb(transport, false, c, r, RawAddress{}, 0x00); SMP_ClearLocScOobData(); return; } } LOG_DEBUG("OOB advertiser with id %hhd", id); auto advertiser = get_ble_advertiser_instance(); advertiser->GetOwnAddress( id, base::Bind(&get_address_callback, transport, is_valid, c, r)); } static void timeout_cb(uint8_t id, uint8_t status) { LOG_INFO("OOB advertiser with id %hhd timed out with status %hhd", id, status); auto advertiser = get_ble_advertiser_instance(); advertiser->Unregister(id); SMP_ClearLocScOobData(); } // Step Two: CallBack from Step One, advertise and get address static void id_status_callback(tBT_TRANSPORT transport, bool is_valid, const Octet16& c, const Octet16& r, uint8_t id, uint8_t status) { if (status != 0) { LOG_INFO("OOB get advertiser ID failed with status %hhd", status); invoke_oob_data_request_cb(transport, false, c, r, RawAddress{}, 0x00); SMP_ClearLocScOobData(); return; } auto advertiser = get_ble_advertiser_instance(); AdvertiseParameters parameters; parameters.advertising_event_properties = 0x0041 /* connectable, tx power */; parameters.min_interval = 0xa0; // 100 ms parameters.max_interval = 0x500; // 800 ms parameters.channel_map = 0x7; // Use all the channels parameters.tx_power = 0; // 0 dBm parameters.primary_advertising_phy = 1; parameters.secondary_advertising_phy = 2; parameters.scan_request_notification_enable = 0; std::vector<uint8_t> advertisement{0x02, 0x01 /* Flags */, 0x02 /* Connectable */}; std::vector<uint8_t> scan_data{}; advertiser->StartAdvertising( id, base::Bind(&start_advertising_callback, id, transport, is_valid, c, r), parameters, advertisement, scan_data, 3600 /* timeout_s */, base::Bind(&timeout_cb, id)); } // Step One: Start the advertiser static void start_oob_advertiser(tBT_TRANSPORT transport, bool is_valid, const Octet16& c, const Octet16& r) { auto advertiser = get_ble_advertiser_instance(); advertiser->RegisterAdvertiser( base::Bind(&id_status_callback, transport, is_valid, c, r)); } } void btif_dm_proc_loc_oob(tBT_TRANSPORT transport, bool is_valid, void btif_dm_proc_loc_oob(tBT_TRANSPORT transport, bool is_valid, const Octet16& c, const Octet16& r) { const Octet16& c, const Octet16& r) { invoke_oob_data_request_cb(transport, is_valid, c, r, // is_valid is important for deciding which OobDataCallback function to use *controller_get_interface()->get_address()); if (!is_valid) invoke_oob_data_request_cb(transport, false, c, r, RawAddress{}, 0x00); // Now that we have the data, lets start advertising and get the address. start_oob_advertiser(transport, is_valid, c, r); } } /******************************************************************************* /******************************************************************************* Loading
system/stack/include/smp_api.h +9 −6 Original line number Original line Diff line number Diff line Loading @@ -182,14 +182,17 @@ extern void SMP_SecureConnectionOobDataReply(uint8_t* p_data); * Description This function is called to generate a public key to be * Description This function is called to generate a public key to be * passed to a remote device via an Out of Band transport * passed to a remote device via an Out of Band transport * * * Parameters: callback - receive the data ******************************************************************************/ extern void SMP_CrLocScOobData(); /******************************************************************************* * * Function SMP_ClearLocScOobData * * Description This function is called to clear out the OOB stored locally. * * ******************************************************************************/ ******************************************************************************/ extern void SMP_CrLocScOobData( extern void SMP_ClearLocScOobData(); base::OnceCallback<void(tBT_TRANSPORT, bool, const std::array<unsigned char, 16>&, const std::array<unsigned char, 16>&)> callback); // Called when LTK request is received from controller. // Called when LTK request is received from controller. extern bool smp_proc_ltk_request(const RawAddress& bda); extern bool smp_proc_ltk_request(const RawAddress& bda); Loading