Loading tools/rootcanal/model/hci/h4_parser.cc +5 −0 Original line number Diff line number Diff line Loading @@ -131,6 +131,7 @@ bool H4Parser::Consume(const uint8_t* buffer, int32_t bytes_read) { packet_type_ = *buffer; packet_.clear(); break; case HCI_RECOVERY: { // Skip all received bytes until the HCI Reset command is received. // The parser can end up in a bad state when the host is restarted. Loading @@ -150,12 +151,16 @@ bool H4Parser::Consume(const uint8_t* buffer, int32_t bytes_read) { } } // Received full reset command. if (packet_.size() == reset_command.size()) { LOG_INFO("Received HCI Reset command, exiting recovery state"); // Pop the Idc from the received packet. packet_.erase(packet_.begin()); bytes_wanted_ = 0; } break; } case HCI_PREAMBLE: case HCI_PAYLOAD: packet_.insert(packet_.end(), buffer, buffer + bytes_read); Loading tools/rootcanal/test/h4_parser_unittest.cc +3 −3 Original line number Diff line number Diff line Loading @@ -176,9 +176,9 @@ TEST_F(H4ParserTest, Recovery) { // Validate that the HCI Reset command was correctly received. ASSERT_EQ(type_, PacketType::COMMAND); ASSERT_EQ(packet_.size(), reset_command.size()); for (size_t i = 0; i < packet_.size(); i++) { ASSERT_EQ(packet_[i], reset_command[i]); ASSERT_EQ(packet_.size(), reset_command.size() - 1); for (size_t i = 1; i < packet_.size(); i++) { ASSERT_EQ(packet_[i - 1], reset_command[i]); } } Loading Loading
tools/rootcanal/model/hci/h4_parser.cc +5 −0 Original line number Diff line number Diff line Loading @@ -131,6 +131,7 @@ bool H4Parser::Consume(const uint8_t* buffer, int32_t bytes_read) { packet_type_ = *buffer; packet_.clear(); break; case HCI_RECOVERY: { // Skip all received bytes until the HCI Reset command is received. // The parser can end up in a bad state when the host is restarted. Loading @@ -150,12 +151,16 @@ bool H4Parser::Consume(const uint8_t* buffer, int32_t bytes_read) { } } // Received full reset command. if (packet_.size() == reset_command.size()) { LOG_INFO("Received HCI Reset command, exiting recovery state"); // Pop the Idc from the received packet. packet_.erase(packet_.begin()); bytes_wanted_ = 0; } break; } case HCI_PREAMBLE: case HCI_PAYLOAD: packet_.insert(packet_.end(), buffer, buffer + bytes_read); Loading
tools/rootcanal/test/h4_parser_unittest.cc +3 −3 Original line number Diff line number Diff line Loading @@ -176,9 +176,9 @@ TEST_F(H4ParserTest, Recovery) { // Validate that the HCI Reset command was correctly received. ASSERT_EQ(type_, PacketType::COMMAND); ASSERT_EQ(packet_.size(), reset_command.size()); for (size_t i = 0; i < packet_.size(); i++) { ASSERT_EQ(packet_[i], reset_command[i]); ASSERT_EQ(packet_.size(), reset_command.size() - 1); for (size_t i = 1; i < packet_.size(); i++) { ASSERT_EQ(packet_[i - 1], reset_command[i]); } } Loading