Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9b9ae133 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Allow command complete and command status with opcode 0x0 anytime"

parents 4024c5ee f309f110
Loading
Loading
Loading
Loading
+20 −4
Original line number Original line Diff line number Diff line
@@ -329,10 +329,26 @@ struct HciLayer::impl {
    ASSERT(event.IsValid());
    ASSERT(event.IsValid());
    if (command_queue_.empty()) {
    if (command_queue_.empty()) {
      auto event_code = event.GetEventCode();
      auto event_code = event.GetEventCode();
      ASSERT_LOG(
      // BT Core spec 5.2 (Volume 4, Part E section 4.4) allows anytime
          event_code != EventCode::COMMAND_COMPLETE && event_code != EventCode::COMMAND_STATUS,
      // COMMAND_COMPLETE and COMMAND_STATUS with opcode 0x0 for flow control
          "Received %s without a waiting command (is the HAL sending commands, but not handling the events?)",
      if (event_code == EventCode::COMMAND_COMPLETE) {
          EventCodeText(event_code).c_str());
          auto view = CommandCompleteView::Create(event);
          ASSERT(view.IsValid());
          auto op_code = view.GetCommandOpCode();
          ASSERT_LOG(op_code == OpCode::NONE,
            "Received %s event with OpCode 0x%02hx (%s) without a waiting command"
            "(is the HAL sending commands, but not handling the events?)",
            EventCodeText(event_code).c_str(), op_code, OpCodeText(op_code).c_str());
      }
      if (event_code == EventCode::COMMAND_STATUS) {
          auto view = CommandStatusView::Create(event);
          ASSERT(view.IsValid());
          auto op_code = view.GetCommandOpCode();
          ASSERT_LOG(op_code == OpCode::NONE,
            "Received %s event with OpCode 0x%02hx (%s) without a waiting command"
            "(is the HAL sending commands, but not handling the events?)",
            EventCodeText(event_code).c_str(), op_code, OpCodeText(op_code).c_str());
      }
      std::unique_ptr<CommandView> no_waiting_command{nullptr};
      std::unique_ptr<CommandView> no_waiting_command{nullptr};
      log_hci_event(no_waiting_command, event, module_.GetDependency<storage::StorageModule>());
      log_hci_event(no_waiting_command, event, module_.GetDependency<storage::StorageModule>());
    } else {
    } else {