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

Commit 9f97bb50 authored by Joseph Hwang's avatar Joseph Hwang
Browse files

PDL: MsftReadSupportedFeaturesCommandComplete

Add event fields to MsftReadSupportedFeaturesCommandComplete to
derive prefix_length and prefix.

Add a new test testMsftReadSupportedFeaturesComplete for the event.

Bug: 246398494
Tag: #floss
Test: ./build.py --target test
Test: atest packages/modules/Bluetooth/system/gd/hci/hci_packets_test.cc
        x86_64 bluetooth_test_gd_unit: Passed: 26, Failed: 0,
                                       Ignored: 0, Assumption Failed: 0
Test: Manual test with next patch --
      "gd/hci: get MSFT opcode and read supported features"

Change-Id: Ic578d41ae80ec6a254a42759081dcd115cf59109
parent 167163a6
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -6301,6 +6301,13 @@ packet MsftCommandComplete : CommandComplete {

packet MsftReadSupportedFeaturesCommandComplete : MsftCommandComplete (subcommand_opcode = MSFT_READ_SUPPORTED_FEATURES) {
  supported_features: 64,
  _size_(prefix) : 8,
  prefix: 8[],
}

test MsftReadSupportedFeaturesCommandComplete {
  "\x0e\x10\x01\x1e\xfc\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x02\x87\x80", // Msft opcode by Intel
  "\x0e\x12\x01\x70\xfd\x00\x00\x1f\x00\x00\x00\x00\x00\x00\x00\x04\x4d\x53\x46\x54", // Msft opcode by Qualcomm
}

packet MsftLeMonitorAdvCommandComplete : MsftCommandComplete (subcommand_opcode = MSFT_LE_MONITOR_ADV) {
+37 −0
Original line number Diff line number Diff line
@@ -588,5 +588,42 @@ TEST(HciPacketsTest, testMsftLeMonitorAdvPatterns) {
  ASSERT_EQ(expected_bytes, *packet_bytes);
}

std::vector<uint8_t> msft_read_supported_features_complete{
    0x0e,  // command complete event code
    0x10,  // event size
    0x01,  // num_hci_command_packets
    0x1e,
    0xfc,  // vendor specific MSFT opcode assigned by Intel
    0x00,  // status
    0x00,  // MSFT subcommand opcode
    0x7f,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,  // supported features
    0x02,  // MSFT event prefix length
    0x87,
    0x80,  // prefix: MSFT event prefix provided by Intel
};
TEST(HciPacketsTest, testMsftReadSupportedFeaturesComplete) {
  PacketView<kLittleEndian> packet_bytes_view(
      std::make_shared<std::vector<uint8_t>>(msft_read_supported_features_complete));
  auto view = MsftReadSupportedFeaturesCommandCompleteView::Create(
      MsftCommandCompleteView::Create(CommandCompleteView::Create(EventView::Create(packet_bytes_view))));

  ASSERT_TRUE(view.IsValid());
  ASSERT_EQ(ErrorCode::SUCCESS, view.GetStatus());
  ASSERT_EQ((uint8_t)0x00, (uint8_t)view.GetSubcommandOpcode());
  ASSERT_EQ((uint64_t)0x000000000000007f, view.GetSupportedFeatures());
  ASSERT_EQ(2ul, view.GetPrefix().size());

  uint16_t prefix = 0;
  for (auto p : view.GetPrefix()) prefix = (prefix << 8) + p;
  ASSERT_EQ((uint16_t)0x8780, prefix);
}

}  // namespace hci
}  // namespace bluetooth