Loading system/gd/hci/hci_layer.cc +6 −7 Original line number Diff line number Diff line Loading @@ -58,16 +58,10 @@ using common::BidiQueueEnd; using os::Handler; struct HciLayer::impl : public hal::HciHalCallbacks { impl(HciLayer& module) : hal_(nullptr), module_(module) { RegisterEventHandler(EventCode::COMMAND_COMPLETE, [this](EventPacketView event) { CommandCompleteCallback(event); }, module_.GetHandler()); RegisterEventHandler(EventCode::COMMAND_STATUS, [this](EventPacketView event) { CommandStatusCallback(event); }, module_.GetHandler()); } impl(HciLayer& module) : hal_(nullptr), module_(module) {} void Start(hal::HciHal* hal) { hal_ = hal; hal_->registerIncomingPacketCallback(this); send_acl_ = [this](std::unique_ptr<hci::BasePacketBuilder> packet) { std::vector<uint8_t> bytes; Loading @@ -84,6 +78,11 @@ struct HciLayer::impl : public hal::HciHalCallbacks { auto queue_end = acl_queue_.GetDownEnd(); Handler* handler = module_.GetHandler(); queue_end->RegisterDequeue(handler, [queue_end, this]() { send_acl_(queue_end->TryDequeue()); }); RegisterEventHandler(EventCode::COMMAND_COMPLETE, [this](EventPacketView event) { CommandCompleteCallback(event); }, handler); RegisterEventHandler(EventCode::COMMAND_STATUS, [this](EventPacketView event) { CommandStatusCallback(event); }, handler); hal_->registerIncomingPacketCallback(this); } void Stop() { Loading system/gd/hci/hci_layer_test.cc +8 −1 Original line number Diff line number Diff line Loading @@ -231,11 +231,18 @@ TEST_F(HciTest, createConnectionTest) { uint16_t handle = 0x123; LinkType link_type = LinkType::ACL; Enable encryption_enabled = Enable::DISABLED; hal->callbacks->hciEventReceived(GetPacketBytes(CreateConnectionStatusBuilder::Create(ErrorCode::SUCCESS, 1))); // Verify the event auto event = upper->GetReceivedEvent(); ASSERT_TRUE(event.IsValid()); ASSERT_EQ(EventCode::COMMAND_STATUS, event.GetEventCode()); hal->callbacks->hciEventReceived( GetPacketBytes(ConnectionCompleteBuilder::Create(status, handle, bd_addr, link_type, encryption_enabled))); // Verify the event auto event = upper->GetReceivedEvent(); event = upper->GetReceivedEvent(); ASSERT_TRUE(event.IsValid()); ASSERT_EQ(EventCode::CONNECTION_COMPLETE, event.GetEventCode()); ConnectionCompleteView connection_complete_view = ConnectionCompleteView::Create(event); Loading system/gd/module.cc +1 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ ModuleFactory::ModuleFactory(std::function<Module*()> ctor) : ctor_(ctor) { } Handler* Module::GetHandler() { ASSERT_LOG(handler_ != nullptr, "Can't get handler when it's not started"); return handler_; } Loading system/gd/module.h +1 −1 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ class Module { private: Module* GetDependency(const ModuleFactory* module) const; ::bluetooth::os::Handler* handler_; ::bluetooth::os::Handler* handler_ = nullptr; ModuleList dependencies_; ModuleRegistry* registry_; }; Loading Loading
system/gd/hci/hci_layer.cc +6 −7 Original line number Diff line number Diff line Loading @@ -58,16 +58,10 @@ using common::BidiQueueEnd; using os::Handler; struct HciLayer::impl : public hal::HciHalCallbacks { impl(HciLayer& module) : hal_(nullptr), module_(module) { RegisterEventHandler(EventCode::COMMAND_COMPLETE, [this](EventPacketView event) { CommandCompleteCallback(event); }, module_.GetHandler()); RegisterEventHandler(EventCode::COMMAND_STATUS, [this](EventPacketView event) { CommandStatusCallback(event); }, module_.GetHandler()); } impl(HciLayer& module) : hal_(nullptr), module_(module) {} void Start(hal::HciHal* hal) { hal_ = hal; hal_->registerIncomingPacketCallback(this); send_acl_ = [this](std::unique_ptr<hci::BasePacketBuilder> packet) { std::vector<uint8_t> bytes; Loading @@ -84,6 +78,11 @@ struct HciLayer::impl : public hal::HciHalCallbacks { auto queue_end = acl_queue_.GetDownEnd(); Handler* handler = module_.GetHandler(); queue_end->RegisterDequeue(handler, [queue_end, this]() { send_acl_(queue_end->TryDequeue()); }); RegisterEventHandler(EventCode::COMMAND_COMPLETE, [this](EventPacketView event) { CommandCompleteCallback(event); }, handler); RegisterEventHandler(EventCode::COMMAND_STATUS, [this](EventPacketView event) { CommandStatusCallback(event); }, handler); hal_->registerIncomingPacketCallback(this); } void Stop() { Loading
system/gd/hci/hci_layer_test.cc +8 −1 Original line number Diff line number Diff line Loading @@ -231,11 +231,18 @@ TEST_F(HciTest, createConnectionTest) { uint16_t handle = 0x123; LinkType link_type = LinkType::ACL; Enable encryption_enabled = Enable::DISABLED; hal->callbacks->hciEventReceived(GetPacketBytes(CreateConnectionStatusBuilder::Create(ErrorCode::SUCCESS, 1))); // Verify the event auto event = upper->GetReceivedEvent(); ASSERT_TRUE(event.IsValid()); ASSERT_EQ(EventCode::COMMAND_STATUS, event.GetEventCode()); hal->callbacks->hciEventReceived( GetPacketBytes(ConnectionCompleteBuilder::Create(status, handle, bd_addr, link_type, encryption_enabled))); // Verify the event auto event = upper->GetReceivedEvent(); event = upper->GetReceivedEvent(); ASSERT_TRUE(event.IsValid()); ASSERT_EQ(EventCode::CONNECTION_COMPLETE, event.GetEventCode()); ConnectionCompleteView connection_complete_view = ConnectionCompleteView::Create(event); Loading
system/gd/module.cc +1 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ ModuleFactory::ModuleFactory(std::function<Module*()> ctor) : ctor_(ctor) { } Handler* Module::GetHandler() { ASSERT_LOG(handler_ != nullptr, "Can't get handler when it's not started"); return handler_; } Loading
system/gd/module.h +1 −1 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ class Module { private: Module* GetDependency(const ModuleFactory* module) const; ::bluetooth::os::Handler* handler_; ::bluetooth::os::Handler* handler_ = nullptr; ModuleList dependencies_; ModuleRegistry* registry_; }; Loading