std::unique_ptr<hci::acl_manager::LeAclConnection> acl_connection) {
// Same link should not be connected twice
hci::AddressWithType connected_address_with_type = acl_connection->GetRemoteAddress();
+ uint16_t handle = acl_connection->GetHandle();
ASSERT_LOG(GetLink(connected_address_with_type) == nullptr, "%s is connected twice without disconnection",
acl_connection->GetRemoteAddress().ToString().c_str());
links_.try_emplace(connected_address_with_type, l2cap_handler_, std::move(acl_connection), parameter_provider_,
dynamic_channel_service_manager_, fixed_channel_service_manager_, this);
auto* link = GetLink(connected_address_with_type);
+
+ if (link_property_callback_handler_ != nullptr) {
+ link_property_callback_handler_->CallOn(
+ link_property_listener_,
+ &LinkPropertyListener::OnLinkConnected,
+ connected_address_with_type,
+ handle,
+ link->GetRole());
+ }
+
// Allocate and distribute channels for all registered fixed channel services
auto fixed_channel_services = fixed_channel_service_manager_->GetRegisteredServices();
for (auto& fixed_channel_service : fixed_channel_services) {
void LinkManager::OnLeConnectFail(hci::AddressWithType address_with_type, hci::ErrorCode reason) {
// Notify all pending links for this device
auto pending_link = pending_links_.find(address_with_type);
- if (pending_link == pending_links_.end()) {
- // There is no pending link, exit
+ if (pending_link == pending_links_.end() && reason != hci::ErrorCode::UNKNOWN_CONNECTION) {
+ // There is no pending link, exit; UNKNOWN_CONNECTION means we cancelled
LOG_INFO("Connection to %s failed without a pending link", address_with_type.ToString().c_str());
return;
}
ASSERT_LOG(link != nullptr, "Device %s is disconnected but not in local database",
address_with_type.ToString().c_str());
links_.erase(address_with_type);
+
+ if (link_property_callback_handler_ != nullptr) {
+ link_property_callback_handler_->CallOn(
+ link_property_listener_, &LinkPropertyListener::OnLinkDisconnected, address_with_type);
+ }
}
void LinkManager::RegisterLinkPropertyListener(os::Handler* handler, LinkPropertyListener* listener) {