void OnConnectionPacketTypeChanged(uint16_t packet_type) override {
SAVE_OR_CALL(OnConnectionPacketTypeChanged, packet_type)
}
- void OnAuthenticationComplete() override {
- SAVE_OR_CALL(OnAuthenticationComplete)
+ void OnAuthenticationComplete(hci::ErrorCode hci_status) override {
+ SAVE_OR_CALL(OnAuthenticationComplete, hci_status)
}
void OnEncryptionChange(EncryptionEnabled enabled) override {
SAVE_OR_CALL(OnEncryptionChange, enabled)
SAVE_OR_CALL(OnModeChange, status, current_mode, interval)
}
void OnSniffSubrating(
+ hci::ErrorCode hci_status,
uint16_t maximum_transmit_latency,
uint16_t maximum_receive_latency,
uint16_t minimum_remote_timeout,
uint16_t minimum_local_timeout) override {
SAVE_OR_CALL(
OnSniffSubrating,
+ hci_status,
maximum_transmit_latency,
maximum_receive_latency,
minimum_remote_timeout,
void OnCentralLinkKeyComplete(KeyFlag key_flag) override {
SAVE_OR_CALL(OnCentralLinkKeyComplete, key_flag)
}
- void OnRoleChange(Role new_role) override {
- SAVE_OR_CALL(OnRoleChange, new_role)
+ void OnRoleChange(hci::ErrorCode hci_status, Role new_role) override {
+ SAVE_OR_CALL(OnRoleChange, hci_status, new_role)
}
void OnReadRemoteVersionInformationComplete(
- uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) override {
- SAVE_OR_CALL(OnReadRemoteVersionInformationComplete, lmp_version, manufacturer_name, sub_version);
+ hci::ErrorCode hci_status, uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) override {
+ SAVE_OR_CALL(OnReadRemoteVersionInformationComplete, hci_status, lmp_version, manufacturer_name, sub_version);
}
void OnReadRemoteExtendedFeaturesComplete(uint8_t page_number, uint8_t max_page_number, uint64_t features) override {
SAVE_OR_CALL(OnReadRemoteExtendedFeaturesComplete, page_number, max_page_number, features);
connection->locally_initiated_ = locally_initiated;
auto& connection_proxy = conn_pair.first->second;
connection_proxy.connection_management_callbacks_ = connection->GetEventCallbacks();
- connection_proxy.connection_management_callbacks_->OnRoleChange(current_role);
+ connection_proxy.connection_management_callbacks_->OnRoleChange(hci::ErrorCode::SUCCESS, current_role);
client_handler_->Post(common::BindOnce(&ConnectionCallbacks::OnConnectSuccess,
common::Unretained(client_callbacks_), std::move(connection)));
while (!pending_outgoing_connections_.empty()) {
if (!authentication_complete.IsValid()) {
LOG_ERROR("Received on_authentication_complete with invalid packet");
return;
- } else if (authentication_complete.GetStatus() != ErrorCode::SUCCESS) {
- auto status = authentication_complete.GetStatus();
- std::string error_code = ErrorCodeText(status);
- LOG_ERROR("Received on_authentication_complete with error code %s", error_code.c_str());
- return;
}
uint16_t handle = authentication_complete.GetConnectionHandle();
auto callbacks = get_callbacks(handle);
ASSERT(!crash_on_unknown_handle_);
return;
}
- callbacks->OnAuthenticationComplete();
+ callbacks->OnAuthenticationComplete(authentication_complete.GetStatus());
}
void cancel_connect(Address address) {
LOG_ERROR("Received on_mode_change with invalid packet");
return;
}
- auto status = mode_change_view.GetStatus();
uint16_t handle = mode_change_view.GetConnectionHandle();
- if (status != ErrorCode::SUCCESS) {
- std::string error_code = ErrorCodeText(status);
- LOG_ERROR("Received on_mode_change on handle 0x0%04hx with error code %s", handle, error_code.c_str());
- }
auto callbacks = get_callbacks(handle);
if (callbacks == nullptr) {
LOG_WARN("Unknown connection handle 0x%04hx", handle);
ASSERT(!crash_on_unknown_handle_);
return;
}
- Mode current_mode = mode_change_view.GetCurrentMode();
- uint16_t interval = mode_change_view.GetInterval();
- callbacks->OnModeChange(status, current_mode, interval);
+ callbacks->OnModeChange(
+ mode_change_view.GetStatus(), mode_change_view.GetCurrentMode(), mode_change_view.GetInterval());
}
void on_sniff_subrating(EventView packet) {
if (!sniff_subrating_view.IsValid()) {
LOG_ERROR("Received on_sniff_subrating with invalid packet");
return;
- } else if (sniff_subrating_view.GetStatus() != ErrorCode::SUCCESS) {
- auto status = sniff_subrating_view.GetStatus();
- std::string error_code = ErrorCodeText(status);
- LOG_ERROR("Received on_sniff_subrating with error code %s", error_code.c_str());
- return;
}
uint16_t handle = sniff_subrating_view.GetConnectionHandle();
auto callbacks = get_callbacks(handle);
ASSERT(!crash_on_unknown_handle_);
return;
}
- uint16_t max_tx_lat = sniff_subrating_view.GetMaximumTransmitLatency();
- uint16_t max_rx_lat = sniff_subrating_view.GetMaximumReceiveLatency();
- uint16_t min_remote_timeout = sniff_subrating_view.GetMinimumRemoteTimeout();
- uint16_t min_local_timeout = sniff_subrating_view.GetMinimumLocalTimeout();
- callbacks->OnSniffSubrating(max_tx_lat, max_rx_lat, min_remote_timeout, min_local_timeout);
+ callbacks->OnSniffSubrating(
+ sniff_subrating_view.GetStatus(),
+ sniff_subrating_view.GetMaximumTransmitLatency(),
+ sniff_subrating_view.GetMaximumReceiveLatency(),
+ sniff_subrating_view.GetMinimumRemoteTimeout(),
+ sniff_subrating_view.GetMinimumLocalTimeout());
}
void on_qos_setup_complete(EventView packet) {
if (!role_change_view.IsValid()) {
LOG_ERROR("Received on_role_change with invalid packet");
return;
- } else if (role_change_view.GetStatus() != ErrorCode::SUCCESS) {
- auto status = role_change_view.GetStatus();
- std::string error_code = ErrorCodeText(status);
- LOG_ERROR("Received on_role_change with error code %s", error_code.c_str());
- return;
}
+ auto hci_status = role_change_view.GetStatus();
Address bd_addr = role_change_view.GetBdAddr();
Role new_role = role_change_view.GetNewRole();
for (auto& connection_pair : acl_connections_) {
if (connection_pair.second.address_with_type_.GetAddress() == bd_addr) {
- connection_pair.second.connection_management_callbacks_->OnRoleChange(new_role);
+ connection_pair.second.connection_management_callbacks_->OnRoleChange(hci_status, new_role);
}
}
}
}
void on_read_remote_version_information(
- uint16_t handle, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version) {
+ hci::ErrorCode hci_status, uint16_t handle, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version) {
auto callbacks = get_callbacks(handle);
if (callbacks == nullptr) {
LOG_WARN("Unknown connection handle 0x%04hx", handle);
ASSERT(!crash_on_unknown_handle_);
return;
}
- callbacks->OnReadRemoteVersionInformationComplete(version, manufacturer_name, sub_version);
+ callbacks->OnReadRemoteVersionInformationComplete(hci_status, version, manufacturer_name, sub_version);
}
void on_read_remote_supported_features_complete(EventView packet) {
// Invoked when controller sends Connection Packet Type Changed event with Success error code
virtual void OnConnectionPacketTypeChanged(uint16_t packet_type) = 0;
// Invoked when controller sends Authentication Complete event with Success error code
- virtual void OnAuthenticationComplete() = 0;
+ virtual void OnAuthenticationComplete(hci::ErrorCode hci_status) = 0;
// Invoked when controller sends Encryption Change event with Success error code
virtual void OnEncryptionChange(EncryptionEnabled enabled) = 0;
// Invoked when controller sends Change Connection Link Key Complete event with Success error code
virtual void OnModeChange(ErrorCode status, Mode current_mode, uint16_t interval) = 0;
// Invoked when controller sends Sniff Subrating event with Success error code
virtual void OnSniffSubrating(
+ hci::ErrorCode hci_status,
uint16_t maximum_transmit_latency,
uint16_t maximum_receive_latency,
uint16_t minimum_remote_timeout,
// Invoked when controller sends Central Link Key Complete event
virtual void OnCentralLinkKeyComplete(KeyFlag key_flag) = 0;
// Invoked when controller sends Role Change event
- virtual void OnRoleChange(Role new_role) = 0;
+ virtual void OnRoleChange(hci::ErrorCode hci_status, Role new_role) = 0;
// Invoked when controller sends DisconnectComplete
virtual void OnDisconnection(ErrorCode reason) = 0;
// Invoked when controller sends Read Remote Version Information Complete
virtual void OnReadRemoteVersionInformationComplete(
- uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) = 0;
+ hci::ErrorCode hci_status, uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) = 0;
// Invoked when controller sends Read Remote Extended Features Complete
virtual void OnReadRemoteExtendedFeaturesComplete(
uint8_t page_number, uint8_t max_page_number, uint64_t features) = 0;
common::BindOnce(&LeConnectionManagementCallbacks::f, common::Unretained(client_callbacks_), __VA_ARGS__)); \
}
- void OnConnectionUpdate(uint16_t conn_interval, uint16_t conn_latency, uint16_t supervision_timeout) override {
- SAVE_OR_CALL(OnConnectionUpdate, conn_interval, conn_latency, supervision_timeout)
+ void OnConnectionUpdate(
+ hci::ErrorCode hci_status, uint16_t conn_interval, uint16_t conn_latency, uint16_t supervision_timeout) override {
+ SAVE_OR_CALL(OnConnectionUpdate, hci_status, conn_interval, conn_latency, supervision_timeout)
}
void OnDataLengthChange(uint16_t tx_octets, uint16_t tx_time, uint16_t rx_octets, uint16_t rx_time) override {
SAVE_OR_CALL(OnDataLengthChange, tx_octets, tx_time, rx_octets, rx_time)
}
- void OnReadRemoteVersionInformationComplete(uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) {
- SAVE_OR_CALL(OnReadRemoteVersionInformationComplete, lmp_version, manufacturer_name, sub_version);
+ void OnReadRemoteVersionInformationComplete(
+ hci::ErrorCode hci_status, uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) {
+ SAVE_OR_CALL(OnReadRemoteVersionInformationComplete, hci_status, lmp_version, manufacturer_name, sub_version);
}
- void OnPhyUpdate(uint8_t tx_phy, uint8_t rx_phy) override {
- SAVE_OR_CALL(OnPhyUpdate, tx_phy, rx_phy);
+ void OnPhyUpdate(hci::ErrorCode hci_status, uint8_t tx_phy, uint8_t rx_phy) override {
+ SAVE_OR_CALL(OnPhyUpdate, hci_status, tx_phy, rx_phy);
}
void OnLocalAddressUpdate(AddressWithType address_with_type) override {
SAVE_OR_CALL(OnLocalAddressUpdate, address_with_type);
class LeConnectionManagementCallbacks {
public:
virtual ~LeConnectionManagementCallbacks() = default;
- virtual void OnConnectionUpdate(uint16_t connection_interval, uint16_t connection_latency,
- uint16_t supervision_timeout) = 0;
+ virtual void OnConnectionUpdate(
+ hci::ErrorCode hci_status,
+ uint16_t connection_interval,
+ uint16_t connection_latency,
+ uint16_t supervision_timeout) = 0;
virtual void OnDataLengthChange(uint16_t tx_octets, uint16_t tx_time, uint16_t rx_octets, uint16_t rx_time) = 0;
virtual void OnDisconnection(ErrorCode reason) = 0;
virtual void OnReadRemoteVersionInformationComplete(
- uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) = 0;
- virtual void OnPhyUpdate(uint8_t tx_phy, uint8_t rx_phy) = 0;
+ hci::ErrorCode hci_status, uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) = 0;
+ virtual void OnPhyUpdate(hci::ErrorCode hci_status, uint8_t tx_phy, uint8_t rx_phy) = 0;
virtual void OnLocalAddressUpdate(AddressWithType address_with_type) = 0;
};
if (!complete_view.IsValid()) {
LOG_ERROR("Received on_le_connection_update_complete with invalid packet");
return;
- } else if (complete_view.GetStatus() != ErrorCode::SUCCESS) {
- auto status = complete_view.GetStatus();
- std::string error_code = ErrorCodeText(status);
- LOG_ERROR("Received on_le_connection_update_complete with error code %s", error_code.c_str());
- return;
}
auto handle = complete_view.GetConnectionHandle();
auto callbacks = get_callbacks(handle);
return;
}
callbacks->OnConnectionUpdate(
- complete_view.GetConnInterval(), complete_view.GetConnLatency(), complete_view.GetSupervisionTimeout());
+ complete_view.GetStatus(),
+ complete_view.GetConnInterval(),
+ complete_view.GetConnLatency(),
+ complete_view.GetSupervisionTimeout());
}
void on_le_phy_update_complete(LeMetaEventView view) {
if (!complete_view.IsValid()) {
LOG_ERROR("Received on_le_phy_update_complete with invalid packet");
return;
- } else if (complete_view.GetStatus() != ErrorCode::SUCCESS) {
- auto status = complete_view.GetStatus();
- std::string error_code = ErrorCodeText(status);
- LOG_ERROR("Received on_le_connection_update_complete with error code %s", error_code.c_str());
- return;
}
auto handle = complete_view.GetConnectionHandle();
auto callbacks = get_callbacks(handle);
ASSERT(!crash_on_unknown_handle_);
return;
}
- callbacks->OnPhyUpdate(complete_view.GetTxPhy(), complete_view.GetRxPhy());
+ callbacks->OnPhyUpdate(complete_view.GetStatus(), complete_view.GetTxPhy(), complete_view.GetRxPhy());
}
void on_le_read_remote_version_information(
- uint16_t handle, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version) {
+ hci::ErrorCode hci_status, uint16_t handle, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version) {
auto callbacks = get_callbacks(handle);
if (callbacks == nullptr) {
LOG_WARN("Can't find connection 0x%hx", handle);
ASSERT(!crash_on_unknown_handle_);
return;
}
- callbacks->OnReadRemoteVersionInformationComplete(version, manufacturer_name, sub_version);
+ callbacks->OnReadRemoteVersionInformationComplete(hci_status, version, manufacturer_name, sub_version);
}
void enqueue_command(std::unique_ptr<CommandBuilder> command_packet) {
class MockConnectionManagementCallbacks : public ConnectionManagementCallbacks {
public:
MOCK_METHOD1(OnConnectionPacketTypeChanged, void(uint16_t packet_type));
- MOCK_METHOD0(OnAuthenticationComplete, void());
+ MOCK_METHOD1(OnAuthenticationComplete, void(hci::ErrorCode hci_status));
MOCK_METHOD1(OnEncryptionChange, void(EncryptionEnabled enabled));
MOCK_METHOD0(OnChangeConnectionLinkKeyComplete, void());
MOCK_METHOD1(OnReadClockOffsetComplete, void(uint16_t clock_offse));
MOCK_METHOD3(OnModeChange, void(ErrorCode status, Mode current_mode, uint16_t interval));
- MOCK_METHOD4(
+ MOCK_METHOD5(
OnSniffSubrating,
void(
+ ErrorCode status,
uint16_t maximum_transmit_latency,
uint16_t maximum_receive_latency,
uint16_t minimum_remote_timeout,
MOCK_METHOD1(OnReadRssiComplete, void(uint8_t rssi));
MOCK_METHOD2(OnReadClockComplete, void(uint32_t clock, uint16_t accuracy));
MOCK_METHOD1(OnCentralLinkKeyComplete, void(KeyFlag flag));
- MOCK_METHOD1(OnRoleChange, void(Role new_role));
+ MOCK_METHOD2(OnRoleChange, void(ErrorCode hci_status, Role new_role));
MOCK_METHOD1(OnDisconnection, void(ErrorCode reason));
- MOCK_METHOD3(
+ MOCK_METHOD4(
OnReadRemoteVersionInformationComplete,
- void(uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version));
+ void(hci::ErrorCode hci_status, uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version));
MOCK_METHOD3(
OnReadRemoteExtendedFeaturesComplete, void(uint8_t page_number, uint8_t max_page_number, uint64_t features));
} mock_connection_management_callbacks_;
class MockLeConnectionManagementCallbacks : public LeConnectionManagementCallbacks {
public:
MOCK_METHOD1(OnDisconnection, void(ErrorCode reason));
- MOCK_METHOD3(
+ MOCK_METHOD4(
OnConnectionUpdate,
- void(uint16_t connection_interval, uint16_t connection_latency, uint16_t supervision_timeout));
+ void(
+ hci::ErrorCode hci_status,
+ uint16_t connection_interval,
+ uint16_t connection_latency,
+ uint16_t supervision_timeout));
MOCK_METHOD4(OnDataLengthChange, void(uint16_t tx_octets, uint16_t tx_time, uint16_t rx_octets, uint16_t rx_time));
- MOCK_METHOD3(
+ MOCK_METHOD4(
OnReadRemoteVersionInformationComplete,
- void(uint8_t version, uint16_t manufacturer_name, uint16_t sub_version));
- MOCK_METHOD2(OnPhyUpdate, void(uint8_t tx_phy, uint8_t rx_phy));
+ void(hci::ErrorCode hci_status, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version));
+ MOCK_METHOD3(OnPhyUpdate, void(hci::ErrorCode hci_status, uint8_t tx_phy, uint8_t rx_phy));
MOCK_METHOD1(OnLocalAddressUpdate, void(AddressWithType address_with_type));
} mock_le_connection_management_callbacks_;
};
connection_->RegisterCallbacks(&mock_le_connection_management_callbacks_, client_handler_);
std::promise<ErrorCode> promise;
+ ErrorCode hci_status = hci::ErrorCode::SUCCESS;
uint16_t connection_interval_min = 0x0012;
uint16_t connection_interval_max = 0x0080;
uint16_t connection_interval = (connection_interval_max + connection_interval_min) / 2;
LeConnectionUpdateView::Create(LeConnectionManagementCommandView::Create(AclCommandView::Create(update_packet)));
ASSERT_TRUE(update_view.IsValid());
EXPECT_EQ(update_view.GetConnectionHandle(), handle_);
- EXPECT_CALL(mock_le_connection_management_callbacks_,
- OnConnectionUpdate(connection_interval, connection_latency, supervision_timeout));
+ EXPECT_CALL(
+ mock_le_connection_management_callbacks_,
+ OnConnectionUpdate(hci_status, connection_interval, connection_latency, supervision_timeout));
test_hci_layer_->IncomingLeMetaEvent(LeConnectionUpdateCompleteBuilder::Create(
ErrorCode::SUCCESS, handle_, connection_interval, connection_latency, supervision_timeout));
}
ASSERT_EQ(command_view.GetBdAddr(), connection_->GetAddress());
ASSERT_EQ(command_view.GetRole(), Role::PERIPHERAL);
- EXPECT_CALL(mock_connection_management_callbacks_, OnRoleChange(Role::PERIPHERAL));
+ EXPECT_CALL(mock_connection_management_callbacks_, OnRoleChange(hci::ErrorCode::SUCCESS, Role::PERIPHERAL));
test_hci_layer_->IncomingEvent(
RoleChangeBuilder::Create(ErrorCode::SUCCESS, connection_->GetAddress(), Role::PERIPHERAL));
}
LOG_INFO("key_flag:%s", KeyFlagText(key_flag).c_str());
}
- void OnRoleChange(Role new_role) override {
+ void OnRoleChange(hci::ErrorCode hci_status, Role new_role) override {
LOG_INFO("new_role:%d", (uint8_t)new_role);
}
LOG_INFO("OnConnectionPacketTypeChanged packet_type:%d", packet_type);
}
- void OnAuthenticationComplete() override {
+ void OnAuthenticationComplete(hci::ErrorCode hci_status) override {
LOG_INFO("OnAuthenticationComplete");
}
};
void OnSniffSubrating(
+ hci::ErrorCode hci_status,
uint16_t maximum_transmit_latency,
uint16_t maximum_receive_latency,
uint16_t minimum_remote_timeout,
event_stream_->OnIncomingEvent(disconnection);
}
void OnReadRemoteVersionInformationComplete(
- uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) override {
+ hci::ErrorCode error_status, uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) override {
LOG_INFO(
"OnReadRemoteVersionInformationComplete lmp_version:%hhu manufacturer_name:%hu sub_version:%hu",
lmp_version,
std::shared_ptr<::bluetooth::grpc::GrpcEventQueue<LeConnectionEvent>> event_stream)
: handle_(handle), connection_(std::move(connection)), event_stream_(std::move(event_stream)) {}
void OnConnectionUpdate(
- uint16_t connection_interval, uint16_t connection_latency, uint16_t supervision_timeout) override {
+ hci::ErrorCode hci_status,
+ uint16_t connection_interval,
+ uint16_t connection_latency,
+ uint16_t supervision_timeout) override {
LOG_INFO(
"interval: 0x%hx, latency: 0x%hx, timeout 0x%hx",
connection_interval,
"tx_octets: 0x%hx, tx_time: 0x%hx, rx_octets 0x%hx, rx_time 0x%hx", tx_octets, tx_time, rx_octets, rx_time);
}
- void OnPhyUpdate(uint8_t tx_phy, uint8_t rx_phy) override {}
+ void OnPhyUpdate(hci::ErrorCode hci_status, uint8_t tx_phy, uint8_t rx_phy) override {}
void OnLocalAddressUpdate(AddressWithType address_with_type) override {}
void OnDisconnection(ErrorCode reason) override {
std::unique_ptr<BasePacketBuilder> builder =
}
void OnReadRemoteVersionInformationComplete(
- uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) override {}
+ hci::ErrorCode hci_status, uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) override {}
LeConnectionManagementCallbacks* GetCallbacks() {
return this;
hci::AclConnectionInterface* FuzzHciLayer::GetAclConnectionInterface(
ContextualCallback<void(hci::EventView)> event_handler,
ContextualCallback<void(uint16_t, hci::ErrorCode)> on_disconnect,
- ContextualCallback<void(uint16_t, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version)>
+ ContextualCallback<
+ void(hci::ErrorCode, uint16_t, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version)>
on_read_remote_version) {
return &acl_connection_interface_;
}
hci::LeAclConnectionInterface* FuzzHciLayer::GetLeAclConnectionInterface(
ContextualCallback<void(hci::LeMetaEventView)> event_handler,
ContextualCallback<void(uint16_t, hci::ErrorCode)> on_disconnect,
- ContextualCallback<void(uint16_t, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version)>
+ ContextualCallback<
+ void(hci::ErrorCode, uint16_t, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version)>
on_read_remote_version) {
return &le_acl_connection_interface_;
}
hci::AclConnectionInterface* GetAclConnectionInterface(
common::ContextualCallback<void(hci::EventView)> event_handler,
common::ContextualCallback<void(uint16_t, hci::ErrorCode)> on_disconnect,
- common::ContextualCallback<void(uint16_t, uint8_t, uint16_t, uint16_t)> on_read_remote_version) override;
+ common::ContextualCallback<void(hci::ErrorCode hci_status, uint16_t, uint8_t, uint16_t, uint16_t)>
+ on_read_remote_version) override;
hci::LeAclConnectionInterface* GetLeAclConnectionInterface(
common::ContextualCallback<void(hci::LeMetaEventView)> event_handler,
common::ContextualCallback<void(uint16_t, hci::ErrorCode)> on_disconnect,
- common::ContextualCallback<void(uint16_t, uint8_t, uint16_t, uint16_t)> on_read_remote_version) override;
+ common::ContextualCallback<void(hci::ErrorCode hci_status, uint16_t, uint8_t, uint16_t, uint16_t)>
+ on_read_remote_version) override;
hci::LeAdvertisingInterface* GetLeAdvertisingInterface(
common::ContextualCallback<void(hci::LeMetaEventView)> event_handler) override;
acl_connection_interface_ = hci_->GetAclConnectionInterface(
GetHandler()->Bind([](EventView) {}),
GetHandler()->Bind([](uint16_t, hci::ErrorCode) {}),
- GetHandler()->Bind([](uint16_t, uint8_t, uint16_t, uint16_t) {}));
+ GetHandler()->Bind([](hci::ErrorCode, uint16_t, uint8_t, uint16_t, uint16_t) {}));
le_acl_connection_interface_ = hci_->GetLeAclConnectionInterface(
GetHandler()->Bind([](LeMetaEventView) {}),
GetHandler()->Bind([](uint16_t, hci::ErrorCode) {}),
- GetHandler()->Bind([](uint16_t, uint8_t, uint16_t, uint16_t) {}));
+ GetHandler()->Bind([](hci::ErrorCode, uint16_t, uint8_t, uint16_t, uint16_t) {}));
le_advertising_interface_ = hci_->GetLeAdvertisingInterface(GetHandler()->Bind([](LeMetaEventView) {}));
le_scanning_interface_ = hci_->GetLeScanningInterface(GetHandler()->Bind([](LeMetaEventView) {}));
}
void HciLayer::on_read_remote_version_complete(EventView event_view) {
auto view = ReadRemoteVersionInformationCompleteView::Create(event_view);
ASSERT_LOG(view.IsValid(), "Read remote version information packet invalid");
- if (view.GetStatus() != ErrorCode::SUCCESS) {
- auto status = view.GetStatus();
- std::string error_code = ErrorCodeText(status);
- LOG_ERROR("Received with error code %s", error_code.c_str());
- return;
- }
- uint16_t handle = view.GetConnectionHandle();
- ReadRemoteVersion(handle, view.GetVersion(), view.GetManufacturerName(), view.GetSubVersion());
+ ReadRemoteVersion(
+ view.GetStatus(),
+ view.GetConnectionHandle(),
+ view.GetVersion(),
+ view.GetManufacturerName(),
+ view.GetSubVersion());
}
-void HciLayer::ReadRemoteVersion(uint16_t handle, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version) {
+void HciLayer::ReadRemoteVersion(
+ hci::ErrorCode hci_status, uint16_t handle, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version) {
for (auto callback : read_remote_version_handlers_) {
- callback.Invoke(handle, version, manufacturer_name, sub_version);
+ callback.Invoke(hci_status, handle, version, manufacturer_name, sub_version);
}
}
AclConnectionInterface* HciLayer::GetAclConnectionInterface(
ContextualCallback<void(EventView)> event_handler,
ContextualCallback<void(uint16_t, ErrorCode)> on_disconnect,
- ContextualCallback<void(uint16_t, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version)>
+ ContextualCallback<
+ void(hci::ErrorCode hci_status, uint16_t, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version)>
on_read_remote_version) {
for (const auto event : AclConnectionEvents) {
RegisterEventHandler(event, event_handler);
LeAclConnectionInterface* HciLayer::GetLeAclConnectionInterface(
ContextualCallback<void(LeMetaEventView)> event_handler,
ContextualCallback<void(uint16_t, ErrorCode)> on_disconnect,
- ContextualCallback<void(uint16_t, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version)>
+ ContextualCallback<
+ void(hci::ErrorCode hci_status, uint16_t, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version)>
on_read_remote_version) {
for (const auto event : LeConnectionManagementEvents) {
RegisterLeEventHandler(event, event_handler);
virtual AclConnectionInterface* GetAclConnectionInterface(
common::ContextualCallback<void(EventView)> event_handler,
common::ContextualCallback<void(uint16_t, hci::ErrorCode)> on_disconnect,
- common::ContextualCallback<void(uint16_t, uint8_t, uint16_t, uint16_t)> on_read_remote_version_complete);
+ common::ContextualCallback<void(hci::ErrorCode, uint16_t, uint8_t, uint16_t, uint16_t)>
+ on_read_remote_version_complete);
virtual LeAclConnectionInterface* GetLeAclConnectionInterface(
common::ContextualCallback<void(LeMetaEventView)> event_handler,
common::ContextualCallback<void(uint16_t, hci::ErrorCode)> on_disconnect,
- common::ContextualCallback<void(uint16_t, uint8_t, uint16_t, uint16_t)> on_read_remote_version_complete);
+ common::ContextualCallback<void(hci::ErrorCode, uint16_t, uint8_t, uint16_t, uint16_t)>
+ on_read_remote_version_complete);
virtual LeAdvertisingInterface* GetLeAdvertisingInterface(
common::ContextualCallback<void(LeMetaEventView)> event_handler);
void Stop() override;
virtual void Disconnect(uint16_t handle, ErrorCode reason);
- virtual void ReadRemoteVersion(uint16_t handle, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version);
+ virtual void ReadRemoteVersion(
+ hci::ErrorCode hci_status, uint16_t handle, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version);
virtual void RegisterLeMetaEventHandler(common::ContextualCallback<void(EventView)> event_handler);
private:
};
std::list<common::ContextualCallback<void(uint16_t, ErrorCode)>> disconnect_handlers_;
- std::list<common::ContextualCallback<void(uint16_t, uint8_t, uint16_t, uint16_t)>> read_remote_version_handlers_;
+ std::list<common::ContextualCallback<void(hci::ErrorCode, uint16_t, uint8_t, uint16_t, uint16_t)>>
+ read_remote_version_handlers_;
void on_disconnection_complete(EventView event_view);
void on_read_remote_version_complete(EventView event_view);
return ::grpc::Status::OK;
}
- void SecurityConnectionEventOccurred(hci::Address remote, LinkSecurityInterfaceCallbackEventType event_type) {
+ void SecurityConnectionEventOccurred(
+ hci::ErrorCode hci_status, hci::Address remote, LinkSecurityInterfaceCallbackEventType event_type) {
LinkSecurityInterfaceCallbackEvent msg;
msg.mutable_address()->set_address(remote.ToString());
msg.set_event_type(event_type);
outgoing_pairing_remote_devices_.erase(remote);
}
security_link_map_.emplace(remote, std::move(link));
- SecurityConnectionEventOccurred(remote, LinkSecurityInterfaceCallbackEventType::ON_CONNECTED);
+ SecurityConnectionEventOccurred(
+ hci::ErrorCode::SUCCESS, remote, LinkSecurityInterfaceCallbackEventType::ON_CONNECTED);
}
void OnLinkDisconnected(hci::Address remote) override {
}
entry->second.reset();
security_link_map_.erase(entry);
- SecurityConnectionEventOccurred(remote, LinkSecurityInterfaceCallbackEventType::ON_DISCONNECTED);
+ SecurityConnectionEventOccurred(
+ hci::ErrorCode::SUCCESS, remote, LinkSecurityInterfaceCallbackEventType::ON_DISCONNECTED);
}
- void OnAuthenticationComplete(hci::Address remote) override {
+ void OnAuthenticationComplete(hci::ErrorCode hci_status, hci::Address remote) override {
auto entry = security_link_map_.find(remote);
if (entry != security_link_map_.end()) {
entry->second->EnsureEncrypted();
return;
}
- SecurityConnectionEventOccurred(remote, LinkSecurityInterfaceCallbackEventType::ON_AUTHENTICATION_COMPLETE);
+ SecurityConnectionEventOccurred(
+ hci_status, remote, LinkSecurityInterfaceCallbackEventType::ON_AUTHENTICATION_COMPLETE);
}
void OnEncryptionChange(hci::Address remote, bool encrypted) override {
- SecurityConnectionEventOccurred(remote, LinkSecurityInterfaceCallbackEventType::ON_ENCRYPTION_CHANGE);
+ SecurityConnectionEventOccurred(
+ hci::ErrorCode::SUCCESS, remote, LinkSecurityInterfaceCallbackEventType::ON_ENCRYPTION_CHANGE);
}
class L2capDynamicChannelHelper {
LOG_INFO("UNIMPLEMENTED %s packet_type:%x", __func__, packet_type);
}
-void Link::OnAuthenticationComplete() {
- link_manager_->OnAuthenticationComplete(GetDevice().GetAddress());
+void Link::OnAuthenticationComplete(hci::ErrorCode hci_status) {
+ link_manager_->OnAuthenticationComplete(hci_status, GetDevice().GetAddress());
}
void Link::OnEncryptionChange(hci::EncryptionEnabled enabled) {
}
void Link::OnModeChange(hci::ErrorCode status, hci::Mode current_mode, uint16_t interval) {
- link_manager_->OnModeChange(GetDevice().GetAddress(), current_mode, interval);
+ link_manager_->OnModeChange(status, GetDevice().GetAddress(), current_mode, interval);
}
void Link::OnSniffSubrating(
+ hci::ErrorCode hci_status,
uint16_t maximum_transmit_latency,
uint16_t maximum_receive_latency,
uint16_t minimum_remote_timeout,
uint16_t minimum_local_timeout) {
link_manager_->OnSniffSubrating(
+ hci_status,
GetDevice().GetAddress(),
maximum_transmit_latency,
maximum_receive_latency,
void Link::OnCentralLinkKeyComplete(hci::KeyFlag key_flag) {
LOG_INFO("UNIMPLEMENTED key_flag:%s", hci::KeyFlagText(key_flag).c_str());
}
-void Link::OnRoleChange(hci::Role new_role) {
+void Link::OnRoleChange(hci::ErrorCode hci_status, hci::Role new_role) {
role_ = new_role;
- link_manager_->OnRoleChange(GetDevice().GetAddress(), new_role);
+ link_manager_->OnRoleChange(hci_status, GetDevice().GetAddress(), new_role);
}
void Link::OnDisconnection(hci::ErrorCode reason) {
OnAclDisconnected(reason);
link_manager_->OnDisconnect(GetDevice().GetAddress(), reason);
}
void Link::OnReadRemoteVersionInformationComplete(
- uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) {
+ hci::ErrorCode hci_status, uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) {
LOG_INFO(
- "UNIMPLEMENTED lmp_version:%hhu manufacturer_name:%hu sub_version:%hu",
+ "UNIMPLEMENTED hci_status:%s lmp_version:%hhu manufacturer_name:%hu sub_version:%hu",
+ ErrorCodeText(hci_status).c_str(),
lmp_version,
manufacturer_name,
sub_version);
- link_manager_->OnReadRemoteVersionInformation(GetDevice().GetAddress(), lmp_version, manufacturer_name, sub_version);
+ link_manager_->OnReadRemoteVersionInformation(
+ hci_status, GetDevice().GetAddress(), lmp_version, manufacturer_name, sub_version);
}
void Link::OnReadRemoteExtendedFeaturesComplete(uint8_t page_number, uint8_t max_page_number, uint64_t features) {
LOG_INFO(
// ConnectionManagementCallbacks
void OnConnectionPacketTypeChanged(uint16_t packet_type) override;
- void OnAuthenticationComplete() override;
+ void OnAuthenticationComplete(hci::ErrorCode hci_status) override;
void OnEncryptionChange(hci::EncryptionEnabled enabled) override;
void OnChangeConnectionLinkKeyComplete() override;
void OnReadClockOffsetComplete(uint16_t clock_offset) override;
void OnModeChange(hci::ErrorCode status, hci::Mode current_mode, uint16_t interval) override;
void OnSniffSubrating(
+ hci::ErrorCode hci_status,
uint16_t maximum_transmit_latency,
uint16_t maximum_receive_latency,
uint16_t minimum_remote_timeout,
void OnReadRssiComplete(uint8_t rssi) override;
void OnReadClockComplete(uint32_t clock, uint16_t accuracy) override;
void OnCentralLinkKeyComplete(hci::KeyFlag key_flag) override;
- void OnRoleChange(hci::Role new_role) override;
+ void OnRoleChange(hci::ErrorCode hci_status, hci::Role new_role) override;
void OnDisconnection(hci::ErrorCode reason) override;
- void OnReadRemoteVersionInformationComplete(uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version);
+ void OnReadRemoteVersionInformationComplete(
+ hci::ErrorCode hci_status, uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version);
void OnReadRemoteExtendedFeaturesComplete(uint8_t page_number, uint8_t max_page_number, uint64_t features);
struct EncryptionChangeListener {
links_.erase(device);
}
-void LinkManager::OnAuthenticationComplete(hci::Address device) {
+void LinkManager::OnAuthenticationComplete(hci::ErrorCode hci_status, hci::Address device) {
if (link_security_interface_listener_handler_ != nullptr) {
link_security_interface_listener_handler_->CallOn(
- link_security_interface_listener_, &LinkSecurityInterfaceListener::OnAuthenticationComplete, device);
+ link_security_interface_listener_,
+ &LinkSecurityInterfaceListener::OnAuthenticationComplete,
+ hci_status,
+ device);
}
}
}
void LinkManager::OnReadRemoteVersionInformation(
- hci::Address device, uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) {
+ hci::ErrorCode hci_status,
+ hci::Address device,
+ uint8_t lmp_version,
+ uint16_t manufacturer_name,
+ uint16_t sub_version) {
if (link_property_callback_handler_ != nullptr) {
link_property_callback_handler_->CallOn(
link_property_listener_,
&LinkPropertyListener::OnReadRemoteVersionInformation,
+ hci_status,
device,
lmp_version,
manufacturer_name,
}
}
-void LinkManager::OnRoleChange(hci::Address remote, hci::Role role) {
+void LinkManager::OnRoleChange(hci::ErrorCode hci_status, hci::Address remote, hci::Role role) {
if (link_property_callback_handler_ != nullptr) {
- link_property_callback_handler_->CallOn(link_property_listener_, &LinkPropertyListener::OnRoleChange, remote, role);
+ link_property_callback_handler_->CallOn(
+ link_property_listener_, &LinkPropertyListener::OnRoleChange, hci_status, remote, role);
}
}
}
}
-void LinkManager::OnModeChange(hci::Address remote, hci::Mode mode, uint16_t interval) {
+void LinkManager::OnModeChange(hci::ErrorCode hci_status, hci::Address remote, hci::Mode mode, uint16_t interval) {
if (link_property_callback_handler_ != nullptr) {
link_property_callback_handler_->CallOn(
- link_property_listener_, &LinkPropertyListener::OnModeChange, remote, mode, interval);
+ link_property_listener_, &LinkPropertyListener::OnModeChange, hci_status, remote, mode, interval);
}
}
void LinkManager::OnSniffSubrating(
+ hci::ErrorCode hci_status,
hci::Address remote,
uint16_t max_tx_lat,
uint16_t max_rx_lat,
link_property_callback_handler_->CallOn(
link_property_listener_,
&LinkPropertyListener::OnSniffSubrating,
+ hci_status,
remote,
max_tx_lat,
max_rx_lat,
void OnConnectSuccess(std::unique_ptr<hci::acl_manager::ClassicAclConnection> acl_connection) override;
void OnConnectFail(hci::Address device, hci::ErrorCode reason) override;
virtual void OnDisconnect(hci::Address device, hci::ErrorCode status);
- void OnAuthenticationComplete(hci::Address device);
+ void OnAuthenticationComplete(hci::ErrorCode hci_status, hci::Address device);
void OnEncryptionChange(hci::Address device, hci::EncryptionEnabled enabled);
void OnReadRemoteVersionInformation(
- hci::Address device, uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version);
+ hci::ErrorCode hci_status,
+ hci::Address device,
+ uint8_t lmp_version,
+ uint16_t manufacturer_name,
+ uint16_t sub_version);
void OnReadRemoteExtendedFeatures(
hci::Address device, uint8_t page_number, uint8_t max_page_number, uint64_t features);
- void OnRoleChange(hci::Address remote, hci::Role role);
+ void OnRoleChange(hci::ErrorCode hci_status, hci::Address remote, hci::Role role);
void OnReadClockOffset(hci::Address remote, uint16_t clock_offset);
- void OnModeChange(hci::Address remote, hci::Mode mode, uint16_t interval);
+ void OnModeChange(hci::ErrorCode hci_status, hci::Address remote, hci::Mode mode, uint16_t interval);
void OnSniffSubrating(
+ hci::ErrorCode hci_status,
hci::Address remote,
uint16_t max_tx_lat,
uint16_t max_rx_lat,
* Invoked when received remote version information for a given link
*/
virtual void OnReadRemoteVersionInformation(
- hci::Address remote, uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) {}
+ hci::ErrorCode hci_status,
+ hci::Address remote,
+ uint8_t lmp_version,
+ uint16_t manufacturer_name,
+ uint16_t sub_version) {}
/**
* Invoked when received remote features and remote extended features for a given link
/**
* Invoked when received role change
*/
- virtual void OnRoleChange(hci::Address remote, hci::Role role) {}
+ virtual void OnRoleChange(hci::ErrorCode hci_status, hci::Address remote, hci::Role role) {}
/**
* Invoked when received clock offset
/**
* Invoked when received mode change
*/
- virtual void OnModeChange(hci::Address remote, hci::Mode mode, uint16_t interval) {}
+ virtual void OnModeChange(hci::ErrorCode hci_status, hci::Address remote, hci::Mode mode, uint16_t interval) {}
/**
* Invoked when received sniff subrating
*/
virtual void OnSniffSubrating(
+ hci::ErrorCode hci_status,
hci::Address remote,
uint16_t max_tx_lat,
uint16_t max_rx_lat,
/**
* Invoked when AuthenticationComplete event is received for a given link
*/
- virtual void OnAuthenticationComplete(hci::Address remote) {}
+ virtual void OnAuthenticationComplete(hci::ErrorCode hci_status, hci::Address remote) {}
/**
* Invoked when EncryptionChange event is received for a given link
link_manager_->OnDisconnect(GetAclConnection()->GetRemoteAddress());
}
-void Link::OnConnectionUpdate(uint16_t connection_interval, uint16_t connection_latency, uint16_t supervision_timeout) {
+void Link::OnConnectionUpdate(
+ hci::ErrorCode hci_status,
+ uint16_t connection_interval,
+ uint16_t connection_latency,
+ uint16_t supervision_timeout) {
LOG_INFO(
"interval %hx latency %hx supervision_timeout %hx", connection_interval, connection_latency, supervision_timeout);
if (update_request_signal_id_ != kInvalidSignalId) {
}
void Link::OnReadRemoteVersionInformationComplete(
- uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) {
+ hci::ErrorCode hci_status, uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) {
LOG_INFO("lmp_version:%hhu manufacturer_name:%hu sub_version:%hu", lmp_version, manufacturer_name, sub_version);
- link_manager_->OnReadRemoteVersionInformationComplete(GetDevice(), lmp_version, manufacturer_name, sub_version);
+ link_manager_->OnReadRemoteVersionInformationComplete(
+ hci_status, GetDevice(), lmp_version, manufacturer_name, sub_version);
}
-void Link::OnPhyUpdate(uint8_t tx_phy, uint8_t rx_phy) {}
+void Link::OnPhyUpdate(hci::ErrorCode hci_status, uint8_t tx_phy, uint8_t rx_phy) {}
void Link::OnLocalAddressUpdate(hci::AddressWithType address_with_type) {
acl_connection_->UpdateLocalAddress(address_with_type);
void OnDisconnection(hci::ErrorCode reason) override;
- void OnConnectionUpdate(uint16_t connection_interval, uint16_t connection_latency,
- uint16_t supervision_timeout) override;
+ void OnConnectionUpdate(
+ hci::ErrorCode hci_status,
+ uint16_t connection_interval,
+ uint16_t connection_latency,
+ uint16_t supervision_timeout) override;
void OnDataLengthChange(uint16_t tx_octets, uint16_t tx_time, uint16_t rx_octets, uint16_t rx_time) override;
void OnReadRemoteVersionInformationComplete(
- uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) override;
- void OnPhyUpdate(uint8_t tx_phy, uint8_t rx_phy) override;
+ hci::ErrorCode hci_status, uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) override;
+ void OnPhyUpdate(hci::ErrorCode hci_status, uint8_t tx_phy, uint8_t rx_phy) override;
void OnLocalAddressUpdate(hci::AddressWithType address_with_type) override;
}
void LinkManager::OnReadRemoteVersionInformationComplete(
- hci::AddressWithType address_with_type, uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) {
+ hci::ErrorCode hci_status,
+ hci::AddressWithType address_with_type,
+ uint8_t lmp_version,
+ uint16_t manufacturer_name,
+ uint16_t sub_version) {
if (link_property_callback_handler_ != nullptr) {
link_property_callback_handler_->CallOn(
link_property_listener_,
&LinkPropertyListener::OnReadRemoteVersionInformation,
+ hci_status,
address_with_type,
lmp_version,
manufacturer_name,
void RegisterLinkPropertyListener(os::Handler* handler, LinkPropertyListener* listener);
void OnReadRemoteVersionInformationComplete(
- hci::AddressWithType address_with_type, uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version);
+ hci::ErrorCode hci_status,
+ hci::AddressWithType address_with_type,
+ uint8_t lmp_version,
+ uint16_t manufacturer_name,
+ uint16_t sub_version);
private:
// Dependencies
* Invoked when received remote version information for a given link
*/
virtual void OnReadRemoteVersionInformation(
- hci::AddressWithType remote, uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) {}
+ hci::ErrorCode hci_status,
+ hci::AddressWithType remote,
+ uint8_t lmp_version,
+ uint16_t manufacturer_name,
+ uint16_t sub_version) {}
/**
* Invoked when received connection update for a given link
listener_->OnConnectionClosed(address);
}
-void SecurityManagerChannel::OnAuthenticationComplete(hci::Address remote) {
+void SecurityManagerChannel::OnAuthenticationComplete(hci::ErrorCode hci_status, hci::Address remote) {
ASSERT_LOG(l2cap_security_interface_ != nullptr, "L2cap Security Interface is null!");
auto entry = link_map_.find(remote);
if (entry != link_map_.end()) {
// Interface overrides
void OnLinkConnected(std::unique_ptr<l2cap::classic::LinkSecurityInterface> link) override;
void OnLinkDisconnected(hci::Address address) override;
- void OnAuthenticationComplete(hci::Address remote) override;
+ void OnAuthenticationComplete(hci::ErrorCode hci_status, hci::Address remote) override;
void OnEncryptionChange(hci::Address, bool encrypted) override;
private:
on_link_disconnected_called = true;
}
- void OnAuthenticationComplete(hci::Address remote) override {}
+ void OnAuthenticationComplete(hci::ErrorCode hci_status, hci::Address remote) override {}
void OnEncryptionChange(hci::Address address, bool encrypted) override {}
};
LOG_ERROR("CALLED");
}
- void OnAuthenticationComplete(hci::Address remote) override {
+ void OnAuthenticationComplete(hci::ErrorCode hci_status, hci::Address remote) override {
LOG_ERROR("CALLED");
}
};
TRY_POSTING_ON_MAIN(interface_.on_packet_type_changed, packet_type);
}
- void OnAuthenticationComplete() override {
+ void OnAuthenticationComplete(hci::ErrorCode hci_status) override {
TRY_POSTING_ON_MAIN(interface_.on_authentication_complete, handle_,
- ToLegacyHciErrorCode(hci::ErrorCode::SUCCESS));
+ ToLegacyHciErrorCode(hci_status));
}
void OnEncryptionChange(hci::EncryptionEnabled enabled) override {
handle_, ToLegacyHciMode(current_mode), interval);
}
- void OnSniffSubrating(uint16_t maximum_transmit_latency,
+ void OnSniffSubrating(hci::ErrorCode hci_status,
+ uint16_t maximum_transmit_latency,
uint16_t maximum_receive_latency,
uint16_t minimum_remote_timeout,
uint16_t minimum_local_timeout) {
TRY_POSTING_ON_MAIN(interface_.on_sniff_subrating,
- ToLegacyHciErrorCode(hci::ErrorCode::SUCCESS), handle_,
+ ToLegacyHciErrorCode(hci_status), handle_,
maximum_transmit_latency, maximum_receive_latency,
minimum_remote_timeout, minimum_local_timeout);
}
LOG_INFO("%s UNIMPLEMENTED", __func__);
}
- void OnRoleChange(hci::Role new_role) override {
- TRY_POSTING_ON_MAIN(interface_.on_role_change,
- ToLegacyHciErrorCode(hci::ErrorCode::SUCCESS),
- ToRawAddress(connection_->GetAddress()),
- ToLegacyRole(new_role));
+ void OnRoleChange(hci::ErrorCode hci_status, hci::Role new_role) override {
+ TRY_POSTING_ON_MAIN(
+ interface_.on_role_change, ToLegacyHciErrorCode(hci_status),
+ ToRawAddress(connection_->GetAddress()), ToLegacyRole(new_role));
BTM_LogHistory(kBtmLogTag, ToRawAddress(connection_->GetAddress()),
"Role change",
- base::StringPrintf("classic new_role:%s",
+ base::StringPrintf("classic status:%s new_role:%s",
+ hci::ErrorCodeText(hci_status).c_str(),
hci::RoleText(new_role).c_str()));
}
on_disconnect_(handle_, reason);
}
- void OnReadRemoteVersionInformationComplete(uint8_t lmp_version,
+ void OnReadRemoteVersionInformationComplete(hci::ErrorCode hci_status,
+ uint8_t lmp_version,
uint16_t manufacturer_name,
uint16_t sub_version) override {
TRY_POSTING_ON_MAIN(interface_.on_read_remote_version_information_complete,
- ToLegacyHciErrorCode(hci::ErrorCode::SUCCESS), handle_,
- lmp_version, manufacturer_name, sub_version);
+ ToLegacyHciErrorCode(hci_status), handle_, lmp_version,
+ manufacturer_name, sub_version);
}
void OnReadRemoteExtendedFeaturesComplete(uint8_t page_number,
// TODO Issue LeReadRemoteFeatures Command
}
- void OnConnectionUpdate(uint16_t connection_interval,
+ void OnConnectionUpdate(hci::ErrorCode hci_status,
+ uint16_t connection_interval,
uint16_t connection_latency,
uint16_t supervision_timeout) {
- TRY_POSTING_ON_MAIN(interface_.on_connection_update,
- ToLegacyHciErrorCode(hci::ErrorCode::SUCCESS), handle_,
- connection_interval, connection_latency,
- supervision_timeout);
+ TRY_POSTING_ON_MAIN(
+ interface_.on_connection_update, ToLegacyHciErrorCode(hci_status),
+ handle_, connection_interval, connection_latency, supervision_timeout);
}
void OnDataLengthChange(uint16_t tx_octets, uint16_t tx_time,
uint16_t rx_octets, uint16_t rx_time) {
rx_octets, rx_time);
}
- void OnReadRemoteVersionInformationComplete(uint8_t lmp_version,
+ void OnReadRemoteVersionInformationComplete(hci::ErrorCode hci_status,
+ uint8_t lmp_version,
uint16_t manufacturer_name,
uint16_t sub_version) override {
TRY_POSTING_ON_MAIN(interface_.on_read_remote_version_information_complete,
- ToLegacyHciErrorCode(hci::ErrorCode::SUCCESS), handle_,
- lmp_version, manufacturer_name, sub_version);
+ ToLegacyHciErrorCode(hci_status), handle_, lmp_version,
+ manufacturer_name, sub_version);
}
- void OnPhyUpdate(uint8_t tx_phy, uint8_t rx_phy) override {
+ void OnPhyUpdate(hci::ErrorCode hci_status, uint8_t tx_phy,
+ uint8_t rx_phy) override {
TRY_POSTING_ON_MAIN(interface_.on_phy_update,
- ToLegacyHciErrorCode(hci::ErrorCode::SUCCESS), handle_,
- tx_phy, rx_phy);
+ ToLegacyHciErrorCode(hci_status), handle_, tx_phy,
+ rx_phy);
}
void OnLocalAddressUpdate(hci::AddressWithType address_with_type) override {}
address_to_handle_.erase(remote);
}
- void OnReadRemoteVersionInformation(hci::Address remote, uint8_t lmp_version,
+ void OnReadRemoteVersionInformation(hci::ErrorCode error_code,
+ hci::Address remote, uint8_t lmp_version,
uint16_t manufacturer_name,
uint16_t sub_version) override {
auto bda = bluetooth::ToRawAddress(remote);
}
}
- void OnRoleChange(hci::Address remote, hci::Role role) override {
- btm_rejectlist_role_change_device(ToRawAddress(remote), HCI_SUCCESS);
- btm_acl_role_changed(HCI_SUCCESS, ToRawAddress(remote),
- static_cast<uint8_t>(role));
+ void OnRoleChange(hci::ErrorCode error_code, hci::Address remote,
+ hci::Role role) override {
+ btm_rejectlist_role_change_device(ToRawAddress(remote),
+ ToLegacyHciErrorCode(error_code));
+ btm_acl_role_changed(ToLegacyHciErrorCode(error_code), ToRawAddress(remote),
+ ToLegacyRole(role));
}
void OnReadClockOffset(hci::Address remote, uint16_t clock_offset) override {
btm_sec_update_clock_offset(address_to_handle_[remote], clock_offset);
}
- void OnModeChange(hci::Address remote, hci::Mode mode,
- uint16_t interval) override {
- btm_sco_chk_pend_unpark(HCI_SUCCESS, address_to_handle_[remote]);
- btm_pm_proc_mode_change(HCI_SUCCESS, address_to_handle_[remote],
- static_cast<tHCI_MODE>(mode), interval);
+ void OnModeChange(hci::ErrorCode error_code, hci::Address remote,
+ hci::Mode mode, uint16_t interval) override {
+ btm_sco_chk_pend_unpark(ToLegacyHciErrorCode(error_code),
+ address_to_handle_[remote]);
+ btm_pm_proc_mode_change(ToLegacyHciErrorCode(error_code),
+ address_to_handle_[remote], ToLegacyHciMode(mode),
+ interval);
}
- void OnSniffSubrating(hci::Address remote, uint16_t max_tx_lat,
- uint16_t max_rx_lat, uint16_t min_remote_timeout,
+ void OnSniffSubrating(hci::ErrorCode error_code, hci::Address remote,
+ uint16_t max_tx_lat, uint16_t max_rx_lat,
+ uint16_t min_remote_timeout,
uint16_t min_local_timeout) override {
- process_ssr_event(HCI_SUCCESS, address_to_handle_[remote], max_tx_lat,
- max_rx_lat);
+ process_ssr_event(ToLegacyHciErrorCode(error_code),
+ address_to_handle_[remote], max_tx_lat, max_rx_lat);
}
} link_property_listener_shim_;
address_to_interface_[bda] = std::move(interface);
}
- void OnAuthenticationComplete(bluetooth::hci::Address remote) override {
+ void OnAuthenticationComplete(hci::ErrorCode hci_status,
+ bluetooth::hci::Address remote) override {
// Note: if gd security is not enabled, we should use btu_hcif.cc path
auto bda = bluetooth::ToRawAddress(remote);
uint16_t handle = address_to_handle_[bda];
- btm_sec_auth_complete(handle, HCI_SUCCESS);
+ btm_sec_auth_complete(handle, ToLegacyHciErrorCode(hci_status));
}
void OnLinkDisconnected(bluetooth::hci::Address remote) override {
info_.erase(remote.GetAddress());
}
- void OnReadRemoteVersionInformation(hci::AddressWithType remote,
+ void OnReadRemoteVersionInformation(hci::ErrorCode hci_status,
+ hci::AddressWithType remote,
uint8_t lmp_version,
uint16_t manufacturer_name,
uint16_t sub_version) override {