Skip to content
Snippets Groups Projects
Commit 83a2df89 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Do not set random address when public address is in use

Test: compilation
Change-Id: Ie9832b258aa85a9a4086c1608a32aa6f4049853b
parent 29498f57
No related branches found
No related tags found
No related merge requests found
......@@ -422,6 +422,12 @@ class BleAdvertisingManagerImpl
c->self->adv_inst[c->inst_id].tx_power = tx_power;
if (c->self->adv_inst[c->inst_id].own_address_type == BLE_ADDR_PUBLIC) {
c->self->StartAdvertisingSetAfterAddressPart(std::move(c));
return;
}
//own_address_type == BLE_ADDR_RANDOM
const RawAddress& rpa = c->self->adv_inst[c->inst_id].own_address;
c->self->GetHciInterface()->SetRandomAddress(c->inst_id, rpa, Bind(
[](c_type c, uint8_t status) {
......@@ -432,37 +438,41 @@ class BleAdvertisingManagerImpl
return;
}
c->self->SetData(c->inst_id, false, std::move(c->advertise_data), Bind(
[](c_type c, uint8_t status) {
if (status != 0) {
c->self->Unregister(c->inst_id);
LOG(ERROR) << "setting advertise data failed, status: " << +status;
c->cb.Run(0, 0, status);
return;
}
c->self->SetData(c->inst_id, true, std::move(c->scan_response_data), Bind(
[](c_type c, uint8_t status) {
if (status != 0) {
c->self->Unregister(c->inst_id);
LOG(ERROR) << "setting scan response data failed, status: " << +status;
c->cb.Run(0, 0, status);
return;
}
if (c->periodic_params.enable) {
c->self->StartAdvertisingSetPeriodicPart(std::move(c));
} else {
c->self->StartAdvertisingSetFinish(std::move(c));
}
}, base::Passed(&c)));
}, base::Passed(&c)));
}, base::Passed(&c)));
c->self->StartAdvertisingSetAfterAddressPart(std::move(c));
}, base::Passed(&c)));
}, base::Passed(&c)));
}, base::Passed(&c)));
// clang-format on
}
void StartAdvertisingSetAfterAddressPart(c_type c) {
c->self->SetData(c->inst_id, false, std::move(c->advertise_data), Bind(
[](c_type c, uint8_t status) {
if (status != 0) {
c->self->Unregister(c->inst_id);
LOG(ERROR) << "setting advertise data failed, status: " << +status;
c->cb.Run(0, 0, status);
return;
}
c->self->SetData(c->inst_id, true, std::move(c->scan_response_data), Bind(
[](c_type c, uint8_t status) {
if (status != 0) {
c->self->Unregister(c->inst_id);
LOG(ERROR) << "setting scan response data failed, status: " << +status;
c->cb.Run(0, 0, status);
return;
}
if (c->periodic_params.enable) {
c->self->StartAdvertisingSetPeriodicPart(std::move(c));
} else {
c->self->StartAdvertisingSetFinish(std::move(c));
}
}, base::Passed(&c)));
}, base::Passed(&c)));
}
void StartAdvertisingSetPeriodicPart(c_type c) {
// this code is intentionally left formatted this way to highlight the
// asynchronous flow
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment