Loading system/vendor_libs/test_vendor_lib/include/command_packet.h +6 −4 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <cstdint> #include <vector> using std::vector; #include "base/macros.h" #include "vendor_libs/test_vendor_lib/include/packet.h" Loading @@ -42,7 +43,9 @@ namespace test_vendor_lib { // in size. class CommandPacket : public Packet { public: CommandPacket(); CommandPacket(vector<uint8_t> header); CommandPacket(uint16_t opcode); CommandPacket(vector<uint8_t> header, vector<uint8_t> payload); virtual ~CommandPacket() override = default; Loading @@ -68,9 +71,8 @@ class CommandPacket : public Packet { // within an opcode group field. The upper 6 bits will be zero filled. uint16_t GetOCF() const; // Size in octets of a command packet header, which consists of a 2 octet // opcode and a 1 octet payload size. static const size_t kCommandHeaderSize = 3; // Size of a command packet header, which consists of a 2 octet opcode static const size_t kCommandHeaderSize = 2; private: // Disallow any copies of the singleton to be made. Loading system/vendor_libs/test_vendor_lib/include/dual_mode_controller.h +147 −115 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <string> #include <unordered_map> #include <vector> using std::vector; #include "base/json/json_value_converter.h" #include "base/time/time.h" Loading @@ -36,7 +37,7 @@ namespace test_vendor_lib { // commands sent by the HCI. These methods will be registered as callbacks from // a controller instance with the HciHandler. To implement a new Bluetooth // command, simply add the method declaration below, with return type void and a // single const std::vector<uint8_t>& argument. After implementing the // single const vector<uint8_t>& argument. After implementing the // method, simply register it with the HciHandler using the SET_HANDLER macro in // the controller's default constructor. Be sure to name your method after the // corresponding Bluetooth command in the Core Specification with the prefix Loading @@ -45,62 +46,88 @@ class DualModeController { public: class Properties { public: // TODO(dennischeng): Add default initialization and use that to instantiate // a default configured controller if the config file is invalid or not // provided. Properties(const std::string& file_name); // Aggregates and returns the result for the Read Local Extended Features // command. This result contains the |maximum_page_number_| property (among // other things not in the Properties object). See the Bluetooth Core // Specification Version 4.2, Volume 2, Part E, Section 7.4.4 (page 792). const std::vector<uint8_t> GetBdAddress(); // Aggregates and returns the result for the Read Buffer Size command. This // result consists of the |acl_data_packet_size_|, |sco_data_packet_size_|, // |num_acl_data_packets_|, and |num_sco_data_packets_| properties. See the // Bluetooth Core Specification Version 4.2, Volume 2, Part E, Section 7.4.5 // (page 794). const std::vector<uint8_t> GetBufferSize(); // Returns the result for the Read BD_ADDR command. This result is the // |bd_address_| property. See the Bluetooth Core Specification Version // 4.2, Volume 2, Part E, Section 7.4.6 (page 796). const std::vector<uint8_t> GetLocalExtendedFeatures(uint8_t page_number); // Returns the result for the Read Local Name command. See the Bluetooth // Core Specification Version 4.2, Volume 2, Part E, Section 7.3.12 // (page 664). const std::vector<uint8_t> GetLocalName(); // Returns the result for the Read Local Supported Commands command. See the // Bluetooth Core Specification Version 4.2, Volume 2, Part E, Section 7.4.2 // (page 790). const std::vector<uint8_t> GetLocalSupportedCommands(); // Aggregates and returns the Read Local Version Information result. This // consists of the |version_|, |revision_|, |lmp_pal_version_|, // |manufacturer_name_|, and |lmp_pal_subversion_|. See the Bluetooth Core // Specification Version 4.2, Volume 2, Part E, Section 7.4.1 (page 788). const std::vector<uint8_t> GetLocalVersionInformation(); // Access private configuration data // Specification Version 4.2, Volume 2, Part E, Section 7.4.1 const vector<uint8_t>& GetLocalVersionInformation() const; // Specification Version 4.2, Volume 2, Part E, Section 7.4.2 const vector<uint8_t>& GetLocalSupportedCommands() const { return local_supported_commands_; } // Specification Version 4.2, Volume 2, Part E, Section 7.4.3 uint64_t GetLocalSupportedFeatures() const { return local_extended_features_[0]; }; // Specification Version 4.2, Volume 2, Part E, Section 7.4.4 uint8_t GetLocalExtendedFeaturesMaximumPageNumber() const { return local_extended_features_.size() - 1; }; uint64_t GetLocalExtendedFeatures(uint8_t page_number) const { CHECK(page_number < local_extended_features_.size()); return local_extended_features_[page_number]; }; // Specification Version 4.2, Volume 2, Part E, Section 7.4.5 uint16_t GetAclDataPacketSize() const { return acl_data_packet_size_; } uint8_t GetSynchronousDataPacketSize() const { return sco_data_packet_size_; } uint16_t GetTotalNumAclDataPackets() const { return num_acl_data_packets_; } uint16_t GetTotalNumSynchronousDataPackets() const { return num_sco_data_packets_; } // Specification Version 4.2, Volume 2, Part E, Section 7.4.6 const vector<uint8_t>& GetBdAddress() const { return bd_address_; } // Specification Version 4.2, Volume 2, Part E, Section 7.4.8 const vector<uint8_t>& GetSupportedCodecs() const { return supported_codecs_; } const vector<uint32_t>& GetVendorSpecificCodecs() const { return vendor_specific_codecs_; } const std::string& GetLocalName() const { return local_name_; } uint8_t GetVersion() const { return version_; } uint16_t GetRevision() const { return revision_; } uint8_t GetLmpPalVersion() const { return lmp_pal_version_; } uint16_t GetLmpPalSubversion() const { return lmp_pal_subversion_; } uint16_t GetManufacturerName() const { return manufacturer_name_; } // Specification Version 4.2, Volume 2, Part E, Section 7.8.2 const std::vector<uint8_t> GetLeBufferSize(); uint16_t GetLeDataPacketLength() const { return le_data_packet_length_; } uint8_t GetTotalNumLeDataPackets() const { return num_le_data_packets_; } // Specification Version 4.2, Volume 2, Part E, Section 7.8.3 const std::vector<uint8_t> GetLeLocalSupportedFeatures(); uint64_t GetLeLocalSupportedFeatures() const { return le_supported_features_; } // Specification Version 4.2, Volume 2, Part E, Section 7.8.14 const std::vector<uint8_t> GetLeWhiteListSize(); // Specification Version 4.2, Volume 2, Part E, Section 7.8.23 const std::vector<uint8_t> GetLeRand(); uint8_t GetLeWhiteListSize() const { return le_white_list_size_; } // Specification Version 4.2, Volume 2, Part E, Section 7.8.27 const std::vector<uint8_t> GetLeSupportedStates(); uint64_t GetLeSupportedStates() const { return le_supported_states_; } // Vendor-specific commands (see hcidefs.h) const std::vector<uint8_t> GetLeVendorCap(); const vector<uint8_t>& GetLeVendorCap() const { return le_vendor_cap_; } static void RegisterJSONConverter( base::JSONValueConverter<Properties>* converter); Loading @@ -115,12 +142,19 @@ class DualModeController { uint8_t lmp_pal_version_; uint16_t manufacturer_name_; uint16_t lmp_pal_subversion_; uint8_t local_supported_commands_size_; uint8_t local_name_size_; uint16_t le_acl_data_packet_length_; uint8_t num_le_acl_data_packets_; vector<uint8_t> supported_codecs_; vector<uint32_t> vendor_specific_codecs_; vector<uint8_t> local_supported_commands_; std::string local_name_; vector<uint64_t> local_extended_features_; vector<uint8_t> bd_address_; uint16_t le_data_packet_length_; uint8_t num_le_data_packets_; uint8_t le_white_list_size_; std::vector<uint8_t> bd_address_; uint64_t le_supported_features_; uint64_t le_supported_states_; vector<uint8_t> le_vendor_cap_; }; // Sets all of the methods to be used as callbacks in the HciHandler. Loading @@ -136,7 +170,7 @@ class DualModeController { // Dispatches the test channel action corresponding to the command specified // by |name|. void HandleTestChannelCommand(const std::string& name, const std::vector<std::string>& args); const vector<std::string>& args); // Sets the controller Handle* methods as callbacks for the transport to call // when data is received. Loading @@ -163,241 +197,241 @@ class DualModeController { // OGF: 0x0003 // OCF: 0x0003 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.2 void HciReset(const std::vector<uint8_t>& args); void HciReset(const vector<uint8_t>& args); // OGF: 0x0004 // OGF: 0x0005 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.4.5 void HciReadBufferSize(const std::vector<uint8_t>& args); void HciReadBufferSize(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0033 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.39 void HciHostBufferSize(const std::vector<uint8_t>& args); void HciHostBufferSize(const vector<uint8_t>& args); // OGF: 0x0004 // OCF: 0x0001 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.4.1 void HciReadLocalVersionInformation(const std::vector<uint8_t>& args); void HciReadLocalVersionInformation(const vector<uint8_t>& args); // OGF: 0x0004 // OCF: 0x0009 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.4.6 void HciReadBdAddr(const std::vector<uint8_t>& args); void HciReadBdAddr(const vector<uint8_t>& args); // OGF: 0x0004 // OCF: 0x0002 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.4.2 void HciReadLocalSupportedCommands(const std::vector<uint8_t>& args); void HciReadLocalSupportedCommands(const vector<uint8_t>& args); // OGF: 0x0004 // OCF: 0x0004 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.4.4 void HciReadLocalExtendedFeatures(const std::vector<uint8_t>& args); void HciReadLocalExtendedFeatures(const vector<uint8_t>& args); // OGF: 0x0004 // OCF: 0x000B // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.4.8 void HciReadLocalSupportedCodecs(const std::vector<uint8_t>& args); void HciReadLocalSupportedCodecs(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0056 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.59 void HciWriteSimplePairingMode(const std::vector<uint8_t>& args); void HciWriteSimplePairingMode(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x006D // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.79 void HciWriteLeHostSupport(const std::vector<uint8_t>& args); void HciWriteLeHostSupport(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0001 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.1 void HciSetEventMask(const std::vector<uint8_t>& args); void HciSetEventMask(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0045 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.50 void HciWriteInquiryMode(const std::vector<uint8_t>& args); void HciWriteInquiryMode(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0047 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.52 void HciWritePageScanType(const std::vector<uint8_t>& args); void HciWritePageScanType(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0043 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.48 void HciWriteInquiryScanType(const std::vector<uint8_t>& args); void HciWriteInquiryScanType(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0024 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.26 void HciWriteClassOfDevice(const std::vector<uint8_t>& args); void HciWriteClassOfDevice(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0018 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.16 void HciWritePageTimeout(const std::vector<uint8_t>& args); void HciWritePageTimeout(const vector<uint8_t>& args); // OGF: 0x0002 // OCF: 0x000F // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.2.12 void HciWriteDefaultLinkPolicySettings(const std::vector<uint8_t>& args); void HciWriteDefaultLinkPolicySettings(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0014 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.12 void HciReadLocalName(const std::vector<uint8_t>& args); void HciReadLocalName(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0013 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.11 void HciWriteLocalName(const std::vector<uint8_t>& args); void HciWriteLocalName(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0052 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.56 void HciWriteExtendedInquiryResponse(const std::vector<uint8_t>& args); void HciWriteExtendedInquiryResponse(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0026 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.28 void HciWriteVoiceSetting(const std::vector<uint8_t>& args); void HciWriteVoiceSetting(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x003A // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.45 void HciWriteCurrentIacLap(const std::vector<uint8_t>& args); void HciWriteCurrentIacLap(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x001E // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.22 void HciWriteInquiryScanActivity(const std::vector<uint8_t>& args); void HciWriteInquiryScanActivity(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x001A // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.18 void HciWriteScanEnable(const std::vector<uint8_t>& args); void HciWriteScanEnable(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0005 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.3 void HciSetEventFilter(const std::vector<uint8_t>& args); void HciSetEventFilter(const vector<uint8_t>& args); // OGF: 0x0001 // OCF: 0x0001 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.1.1 void HciInquiry(const std::vector<uint8_t>& args); void HciInquiry(const vector<uint8_t>& args); // OGF: 0x0001 // OCF: 0x0002 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.1.2 void HciInquiryCancel(const std::vector<uint8_t>& args); void HciInquiryCancel(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0012 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.10 void HciDeleteStoredLinkKey(const std::vector<uint8_t>& args); void HciDeleteStoredLinkKey(const vector<uint8_t>& args); // OGF: 0x0001 // OCF: 0x0019 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.1.19 void HciRemoteNameRequest(const std::vector<uint8_t>& args); void HciRemoteNameRequest(const vector<uint8_t>& args); // LE Controller Commands // OGF: 0x0008 // OCF: 0x0001 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.8.1 void HciLeSetEventMask(const std::vector<uint8_t>& args); void HciLeSetEventMask(const vector<uint8_t>& args); // OGF: 0x0008 // OCF: 0x0002 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.8.2 void HciLeReadBufferSize(const std::vector<uint8_t>& args); void HciLeReadBufferSize(const vector<uint8_t>& args); // OGF: 0x0008 // OCF: 0x0003 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.8.3 void HciLeReadLocalSupportedFeatures(const std::vector<uint8_t>& args); void HciLeReadLocalSupportedFeatures(const vector<uint8_t>& args); // OGF: 0x0008 // OCF: 0x0005 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.8.4 void HciLeSetRandomAddress(const std::vector<uint8_t>& args); void HciLeSetRandomAddress(const vector<uint8_t>& args); // OGF: 0x0008 // OCF: 0x000B // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.8.10 void HciLeSetScanParameters(const std::vector<uint8_t>& args); void HciLeSetScanParameters(const vector<uint8_t>& args); // OGF: 0x0008 // OCF: 0x000C // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.8.11 void HciLeSetScanEnable(const std::vector<uint8_t>& args); void HciLeSetScanEnable(const vector<uint8_t>& args); // OGF: 0x0008 // OCF: 0x000F // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.8.14 void HciLeReadWhiteListSize(const std::vector<uint8_t>& args); void HciLeReadWhiteListSize(const vector<uint8_t>& args); // OGF: 0x0008 // OCF: 0x0018 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.8.23 void HciLeRand(const std::vector<uint8_t>& args); void HciLeRand(const vector<uint8_t>& args); // OGF: 0x0008 // OCF: 0x001C // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.8.27 void HciLeReadSupportedStates(const std::vector<uint8_t>& args); void HciLeReadSupportedStates(const vector<uint8_t>& args); // Vendor-specific commands (see hcidefs.h) // OGF: 0x00FC // OCF: 0x0027 void HciBleVendorSleepMode(const std::vector<uint8_t>& args); void HciBleVendorSleepMode(const vector<uint8_t>& args); // OGF: 0x00FC // OCF: 0x0153 void HciBleVendorCap(const std::vector<uint8_t>& args); void HciBleVendorCap(const vector<uint8_t>& args); // OGF: 0x00FC // OCF: 0x0154 void HciBleVendorMultiAdv(const std::vector<uint8_t>& args); void HciBleVendorMultiAdv(const vector<uint8_t>& args); // OGF: 0x00FC // OCF: 0x0155 void HciBleVendor155(const std::vector<uint8_t>& args); void HciBleVendor155(const vector<uint8_t>& args); // OGF: 0x00FC // OCF: 0x0157 void HciBleVendor157(const std::vector<uint8_t>& args); void HciBleVendor157(const vector<uint8_t>& args); // OGF: 0x00FC // OCF: 0x0159 void HciBleEnergyInfo(const std::vector<uint8_t>& args); void HciBleEnergyInfo(const vector<uint8_t>& args); // OGF: 0x00FC // OCF: 0x015A void HciBleExtendedScanParams(const std::vector<uint8_t>& args); void HciBleExtendedScanParams(const vector<uint8_t>& args); // Test Channel commands: // Clears all test channel modifications. void TestChannelClear(const std::vector<std::string>& args); void TestChannelClear(const vector<std::string>& args); // Sets the response delay for events to 0. void TestChannelClearEventDelay(const std::vector<std::string>& args); void TestChannelClearEventDelay(const vector<std::string>& args); // Discovers a fake device. void TestChannelDiscover(const std::vector<std::string>& args); void TestChannelDiscover(const vector<std::string>& args); // Causes events to be sent after a delay. void TestChannelSetEventDelay(const std::vector<std::string>& args); void TestChannelSetEventDelay(const vector<std::string>& args); // Causes all future HCI commands to timeout. void TestChannelTimeoutAll(const std::vector<std::string>& args); void TestChannelTimeoutAll(const vector<std::string>& args); private: // Current link layer state of the controller. Loading @@ -413,12 +447,17 @@ class DualModeController { }; // Creates a command complete event and sends it back to the HCI. void SendCommandComplete(uint16_t command_opcode, const std::vector<uint8_t>& return_parameters) const; void SendCommandComplete(const uint16_t command_opcode, const vector<uint8_t>& return_parameters) const; // Sends a command complete event with no return parameters. This event is // typically sent for commands that can be completed immediately. void SendCommandCompleteSuccess(uint16_t command_opcode) const; void SendCommandCompleteSuccess(const uint16_t command_opcode) const; // Sends a command complete event with no return parameters. This event is // typically sent for commands that can be completed immediately. void SendCommandCompleteOnlyStatus(const uint16_t command_opcode, const uint8_t status) const; // Creates a command status event and sends it back to the HCI. void SendCommandStatus(uint8_t status, uint16_t command_opcode) const; Loading @@ -426,13 +465,6 @@ class DualModeController { // Sends a command status event with default event parameters. void SendCommandStatusSuccess(uint16_t command_opcode) const; // Sends an inquiry response for a fake device. void SendInquiryResult() const; // Sends an extended inquiry response for a fake device. void SendExtendedInquiryResult(const std::string& name, const std::string& address) const; void SetEventDelay(int64_t delay); // Callback provided to send events from the controller back to the HCI. Loading @@ -444,11 +476,11 @@ class DualModeController { // Maintains the commands to be registered and used in the HciHandler object. // Keys are command opcodes and values are the callbacks to handle each // command. std::unordered_map<uint16_t, std::function<void(const std::vector<uint8_t>&)>> std::unordered_map<uint16_t, std::function<void(const vector<uint8_t>&)>> active_hci_commands_; std::unordered_map<std::string, std::function<void(const std::vector<std::string>&)>> std::function<void(const vector<std::string>&)>> active_test_channel_commands_; // Specifies the format of Inquiry Result events to be returned during the Loading @@ -459,9 +491,9 @@ class DualModeController { // 0x03-0xFF: Reserved. uint8_t inquiry_mode_; std::vector<uint8_t> le_event_mask_; vector<uint8_t> le_event_mask_; std::vector<uint8_t> le_random_address_; vector<uint8_t> le_random_address_; uint8_t le_scan_type_; uint16_t le_scan_interval_; Loading Loading
system/vendor_libs/test_vendor_lib/include/command_packet.h +6 −4 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <cstdint> #include <vector> using std::vector; #include "base/macros.h" #include "vendor_libs/test_vendor_lib/include/packet.h" Loading @@ -42,7 +43,9 @@ namespace test_vendor_lib { // in size. class CommandPacket : public Packet { public: CommandPacket(); CommandPacket(vector<uint8_t> header); CommandPacket(uint16_t opcode); CommandPacket(vector<uint8_t> header, vector<uint8_t> payload); virtual ~CommandPacket() override = default; Loading @@ -68,9 +71,8 @@ class CommandPacket : public Packet { // within an opcode group field. The upper 6 bits will be zero filled. uint16_t GetOCF() const; // Size in octets of a command packet header, which consists of a 2 octet // opcode and a 1 octet payload size. static const size_t kCommandHeaderSize = 3; // Size of a command packet header, which consists of a 2 octet opcode static const size_t kCommandHeaderSize = 2; private: // Disallow any copies of the singleton to be made. Loading
system/vendor_libs/test_vendor_lib/include/dual_mode_controller.h +147 −115 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <string> #include <unordered_map> #include <vector> using std::vector; #include "base/json/json_value_converter.h" #include "base/time/time.h" Loading @@ -36,7 +37,7 @@ namespace test_vendor_lib { // commands sent by the HCI. These methods will be registered as callbacks from // a controller instance with the HciHandler. To implement a new Bluetooth // command, simply add the method declaration below, with return type void and a // single const std::vector<uint8_t>& argument. After implementing the // single const vector<uint8_t>& argument. After implementing the // method, simply register it with the HciHandler using the SET_HANDLER macro in // the controller's default constructor. Be sure to name your method after the // corresponding Bluetooth command in the Core Specification with the prefix Loading @@ -45,62 +46,88 @@ class DualModeController { public: class Properties { public: // TODO(dennischeng): Add default initialization and use that to instantiate // a default configured controller if the config file is invalid or not // provided. Properties(const std::string& file_name); // Aggregates and returns the result for the Read Local Extended Features // command. This result contains the |maximum_page_number_| property (among // other things not in the Properties object). See the Bluetooth Core // Specification Version 4.2, Volume 2, Part E, Section 7.4.4 (page 792). const std::vector<uint8_t> GetBdAddress(); // Aggregates and returns the result for the Read Buffer Size command. This // result consists of the |acl_data_packet_size_|, |sco_data_packet_size_|, // |num_acl_data_packets_|, and |num_sco_data_packets_| properties. See the // Bluetooth Core Specification Version 4.2, Volume 2, Part E, Section 7.4.5 // (page 794). const std::vector<uint8_t> GetBufferSize(); // Returns the result for the Read BD_ADDR command. This result is the // |bd_address_| property. See the Bluetooth Core Specification Version // 4.2, Volume 2, Part E, Section 7.4.6 (page 796). const std::vector<uint8_t> GetLocalExtendedFeatures(uint8_t page_number); // Returns the result for the Read Local Name command. See the Bluetooth // Core Specification Version 4.2, Volume 2, Part E, Section 7.3.12 // (page 664). const std::vector<uint8_t> GetLocalName(); // Returns the result for the Read Local Supported Commands command. See the // Bluetooth Core Specification Version 4.2, Volume 2, Part E, Section 7.4.2 // (page 790). const std::vector<uint8_t> GetLocalSupportedCommands(); // Aggregates and returns the Read Local Version Information result. This // consists of the |version_|, |revision_|, |lmp_pal_version_|, // |manufacturer_name_|, and |lmp_pal_subversion_|. See the Bluetooth Core // Specification Version 4.2, Volume 2, Part E, Section 7.4.1 (page 788). const std::vector<uint8_t> GetLocalVersionInformation(); // Access private configuration data // Specification Version 4.2, Volume 2, Part E, Section 7.4.1 const vector<uint8_t>& GetLocalVersionInformation() const; // Specification Version 4.2, Volume 2, Part E, Section 7.4.2 const vector<uint8_t>& GetLocalSupportedCommands() const { return local_supported_commands_; } // Specification Version 4.2, Volume 2, Part E, Section 7.4.3 uint64_t GetLocalSupportedFeatures() const { return local_extended_features_[0]; }; // Specification Version 4.2, Volume 2, Part E, Section 7.4.4 uint8_t GetLocalExtendedFeaturesMaximumPageNumber() const { return local_extended_features_.size() - 1; }; uint64_t GetLocalExtendedFeatures(uint8_t page_number) const { CHECK(page_number < local_extended_features_.size()); return local_extended_features_[page_number]; }; // Specification Version 4.2, Volume 2, Part E, Section 7.4.5 uint16_t GetAclDataPacketSize() const { return acl_data_packet_size_; } uint8_t GetSynchronousDataPacketSize() const { return sco_data_packet_size_; } uint16_t GetTotalNumAclDataPackets() const { return num_acl_data_packets_; } uint16_t GetTotalNumSynchronousDataPackets() const { return num_sco_data_packets_; } // Specification Version 4.2, Volume 2, Part E, Section 7.4.6 const vector<uint8_t>& GetBdAddress() const { return bd_address_; } // Specification Version 4.2, Volume 2, Part E, Section 7.4.8 const vector<uint8_t>& GetSupportedCodecs() const { return supported_codecs_; } const vector<uint32_t>& GetVendorSpecificCodecs() const { return vendor_specific_codecs_; } const std::string& GetLocalName() const { return local_name_; } uint8_t GetVersion() const { return version_; } uint16_t GetRevision() const { return revision_; } uint8_t GetLmpPalVersion() const { return lmp_pal_version_; } uint16_t GetLmpPalSubversion() const { return lmp_pal_subversion_; } uint16_t GetManufacturerName() const { return manufacturer_name_; } // Specification Version 4.2, Volume 2, Part E, Section 7.8.2 const std::vector<uint8_t> GetLeBufferSize(); uint16_t GetLeDataPacketLength() const { return le_data_packet_length_; } uint8_t GetTotalNumLeDataPackets() const { return num_le_data_packets_; } // Specification Version 4.2, Volume 2, Part E, Section 7.8.3 const std::vector<uint8_t> GetLeLocalSupportedFeatures(); uint64_t GetLeLocalSupportedFeatures() const { return le_supported_features_; } // Specification Version 4.2, Volume 2, Part E, Section 7.8.14 const std::vector<uint8_t> GetLeWhiteListSize(); // Specification Version 4.2, Volume 2, Part E, Section 7.8.23 const std::vector<uint8_t> GetLeRand(); uint8_t GetLeWhiteListSize() const { return le_white_list_size_; } // Specification Version 4.2, Volume 2, Part E, Section 7.8.27 const std::vector<uint8_t> GetLeSupportedStates(); uint64_t GetLeSupportedStates() const { return le_supported_states_; } // Vendor-specific commands (see hcidefs.h) const std::vector<uint8_t> GetLeVendorCap(); const vector<uint8_t>& GetLeVendorCap() const { return le_vendor_cap_; } static void RegisterJSONConverter( base::JSONValueConverter<Properties>* converter); Loading @@ -115,12 +142,19 @@ class DualModeController { uint8_t lmp_pal_version_; uint16_t manufacturer_name_; uint16_t lmp_pal_subversion_; uint8_t local_supported_commands_size_; uint8_t local_name_size_; uint16_t le_acl_data_packet_length_; uint8_t num_le_acl_data_packets_; vector<uint8_t> supported_codecs_; vector<uint32_t> vendor_specific_codecs_; vector<uint8_t> local_supported_commands_; std::string local_name_; vector<uint64_t> local_extended_features_; vector<uint8_t> bd_address_; uint16_t le_data_packet_length_; uint8_t num_le_data_packets_; uint8_t le_white_list_size_; std::vector<uint8_t> bd_address_; uint64_t le_supported_features_; uint64_t le_supported_states_; vector<uint8_t> le_vendor_cap_; }; // Sets all of the methods to be used as callbacks in the HciHandler. Loading @@ -136,7 +170,7 @@ class DualModeController { // Dispatches the test channel action corresponding to the command specified // by |name|. void HandleTestChannelCommand(const std::string& name, const std::vector<std::string>& args); const vector<std::string>& args); // Sets the controller Handle* methods as callbacks for the transport to call // when data is received. Loading @@ -163,241 +197,241 @@ class DualModeController { // OGF: 0x0003 // OCF: 0x0003 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.2 void HciReset(const std::vector<uint8_t>& args); void HciReset(const vector<uint8_t>& args); // OGF: 0x0004 // OGF: 0x0005 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.4.5 void HciReadBufferSize(const std::vector<uint8_t>& args); void HciReadBufferSize(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0033 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.39 void HciHostBufferSize(const std::vector<uint8_t>& args); void HciHostBufferSize(const vector<uint8_t>& args); // OGF: 0x0004 // OCF: 0x0001 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.4.1 void HciReadLocalVersionInformation(const std::vector<uint8_t>& args); void HciReadLocalVersionInformation(const vector<uint8_t>& args); // OGF: 0x0004 // OCF: 0x0009 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.4.6 void HciReadBdAddr(const std::vector<uint8_t>& args); void HciReadBdAddr(const vector<uint8_t>& args); // OGF: 0x0004 // OCF: 0x0002 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.4.2 void HciReadLocalSupportedCommands(const std::vector<uint8_t>& args); void HciReadLocalSupportedCommands(const vector<uint8_t>& args); // OGF: 0x0004 // OCF: 0x0004 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.4.4 void HciReadLocalExtendedFeatures(const std::vector<uint8_t>& args); void HciReadLocalExtendedFeatures(const vector<uint8_t>& args); // OGF: 0x0004 // OCF: 0x000B // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.4.8 void HciReadLocalSupportedCodecs(const std::vector<uint8_t>& args); void HciReadLocalSupportedCodecs(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0056 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.59 void HciWriteSimplePairingMode(const std::vector<uint8_t>& args); void HciWriteSimplePairingMode(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x006D // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.79 void HciWriteLeHostSupport(const std::vector<uint8_t>& args); void HciWriteLeHostSupport(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0001 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.1 void HciSetEventMask(const std::vector<uint8_t>& args); void HciSetEventMask(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0045 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.50 void HciWriteInquiryMode(const std::vector<uint8_t>& args); void HciWriteInquiryMode(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0047 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.52 void HciWritePageScanType(const std::vector<uint8_t>& args); void HciWritePageScanType(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0043 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.48 void HciWriteInquiryScanType(const std::vector<uint8_t>& args); void HciWriteInquiryScanType(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0024 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.26 void HciWriteClassOfDevice(const std::vector<uint8_t>& args); void HciWriteClassOfDevice(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0018 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.16 void HciWritePageTimeout(const std::vector<uint8_t>& args); void HciWritePageTimeout(const vector<uint8_t>& args); // OGF: 0x0002 // OCF: 0x000F // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.2.12 void HciWriteDefaultLinkPolicySettings(const std::vector<uint8_t>& args); void HciWriteDefaultLinkPolicySettings(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0014 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.12 void HciReadLocalName(const std::vector<uint8_t>& args); void HciReadLocalName(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0013 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.11 void HciWriteLocalName(const std::vector<uint8_t>& args); void HciWriteLocalName(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0052 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.56 void HciWriteExtendedInquiryResponse(const std::vector<uint8_t>& args); void HciWriteExtendedInquiryResponse(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0026 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.28 void HciWriteVoiceSetting(const std::vector<uint8_t>& args); void HciWriteVoiceSetting(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x003A // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.45 void HciWriteCurrentIacLap(const std::vector<uint8_t>& args); void HciWriteCurrentIacLap(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x001E // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.22 void HciWriteInquiryScanActivity(const std::vector<uint8_t>& args); void HciWriteInquiryScanActivity(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x001A // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.18 void HciWriteScanEnable(const std::vector<uint8_t>& args); void HciWriteScanEnable(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0005 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.3 void HciSetEventFilter(const std::vector<uint8_t>& args); void HciSetEventFilter(const vector<uint8_t>& args); // OGF: 0x0001 // OCF: 0x0001 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.1.1 void HciInquiry(const std::vector<uint8_t>& args); void HciInquiry(const vector<uint8_t>& args); // OGF: 0x0001 // OCF: 0x0002 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.1.2 void HciInquiryCancel(const std::vector<uint8_t>& args); void HciInquiryCancel(const vector<uint8_t>& args); // OGF: 0x0003 // OCF: 0x0012 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3.10 void HciDeleteStoredLinkKey(const std::vector<uint8_t>& args); void HciDeleteStoredLinkKey(const vector<uint8_t>& args); // OGF: 0x0001 // OCF: 0x0019 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.1.19 void HciRemoteNameRequest(const std::vector<uint8_t>& args); void HciRemoteNameRequest(const vector<uint8_t>& args); // LE Controller Commands // OGF: 0x0008 // OCF: 0x0001 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.8.1 void HciLeSetEventMask(const std::vector<uint8_t>& args); void HciLeSetEventMask(const vector<uint8_t>& args); // OGF: 0x0008 // OCF: 0x0002 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.8.2 void HciLeReadBufferSize(const std::vector<uint8_t>& args); void HciLeReadBufferSize(const vector<uint8_t>& args); // OGF: 0x0008 // OCF: 0x0003 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.8.3 void HciLeReadLocalSupportedFeatures(const std::vector<uint8_t>& args); void HciLeReadLocalSupportedFeatures(const vector<uint8_t>& args); // OGF: 0x0008 // OCF: 0x0005 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.8.4 void HciLeSetRandomAddress(const std::vector<uint8_t>& args); void HciLeSetRandomAddress(const vector<uint8_t>& args); // OGF: 0x0008 // OCF: 0x000B // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.8.10 void HciLeSetScanParameters(const std::vector<uint8_t>& args); void HciLeSetScanParameters(const vector<uint8_t>& args); // OGF: 0x0008 // OCF: 0x000C // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.8.11 void HciLeSetScanEnable(const std::vector<uint8_t>& args); void HciLeSetScanEnable(const vector<uint8_t>& args); // OGF: 0x0008 // OCF: 0x000F // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.8.14 void HciLeReadWhiteListSize(const std::vector<uint8_t>& args); void HciLeReadWhiteListSize(const vector<uint8_t>& args); // OGF: 0x0008 // OCF: 0x0018 // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.8.23 void HciLeRand(const std::vector<uint8_t>& args); void HciLeRand(const vector<uint8_t>& args); // OGF: 0x0008 // OCF: 0x001C // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.8.27 void HciLeReadSupportedStates(const std::vector<uint8_t>& args); void HciLeReadSupportedStates(const vector<uint8_t>& args); // Vendor-specific commands (see hcidefs.h) // OGF: 0x00FC // OCF: 0x0027 void HciBleVendorSleepMode(const std::vector<uint8_t>& args); void HciBleVendorSleepMode(const vector<uint8_t>& args); // OGF: 0x00FC // OCF: 0x0153 void HciBleVendorCap(const std::vector<uint8_t>& args); void HciBleVendorCap(const vector<uint8_t>& args); // OGF: 0x00FC // OCF: 0x0154 void HciBleVendorMultiAdv(const std::vector<uint8_t>& args); void HciBleVendorMultiAdv(const vector<uint8_t>& args); // OGF: 0x00FC // OCF: 0x0155 void HciBleVendor155(const std::vector<uint8_t>& args); void HciBleVendor155(const vector<uint8_t>& args); // OGF: 0x00FC // OCF: 0x0157 void HciBleVendor157(const std::vector<uint8_t>& args); void HciBleVendor157(const vector<uint8_t>& args); // OGF: 0x00FC // OCF: 0x0159 void HciBleEnergyInfo(const std::vector<uint8_t>& args); void HciBleEnergyInfo(const vector<uint8_t>& args); // OGF: 0x00FC // OCF: 0x015A void HciBleExtendedScanParams(const std::vector<uint8_t>& args); void HciBleExtendedScanParams(const vector<uint8_t>& args); // Test Channel commands: // Clears all test channel modifications. void TestChannelClear(const std::vector<std::string>& args); void TestChannelClear(const vector<std::string>& args); // Sets the response delay for events to 0. void TestChannelClearEventDelay(const std::vector<std::string>& args); void TestChannelClearEventDelay(const vector<std::string>& args); // Discovers a fake device. void TestChannelDiscover(const std::vector<std::string>& args); void TestChannelDiscover(const vector<std::string>& args); // Causes events to be sent after a delay. void TestChannelSetEventDelay(const std::vector<std::string>& args); void TestChannelSetEventDelay(const vector<std::string>& args); // Causes all future HCI commands to timeout. void TestChannelTimeoutAll(const std::vector<std::string>& args); void TestChannelTimeoutAll(const vector<std::string>& args); private: // Current link layer state of the controller. Loading @@ -413,12 +447,17 @@ class DualModeController { }; // Creates a command complete event and sends it back to the HCI. void SendCommandComplete(uint16_t command_opcode, const std::vector<uint8_t>& return_parameters) const; void SendCommandComplete(const uint16_t command_opcode, const vector<uint8_t>& return_parameters) const; // Sends a command complete event with no return parameters. This event is // typically sent for commands that can be completed immediately. void SendCommandCompleteSuccess(uint16_t command_opcode) const; void SendCommandCompleteSuccess(const uint16_t command_opcode) const; // Sends a command complete event with no return parameters. This event is // typically sent for commands that can be completed immediately. void SendCommandCompleteOnlyStatus(const uint16_t command_opcode, const uint8_t status) const; // Creates a command status event and sends it back to the HCI. void SendCommandStatus(uint8_t status, uint16_t command_opcode) const; Loading @@ -426,13 +465,6 @@ class DualModeController { // Sends a command status event with default event parameters. void SendCommandStatusSuccess(uint16_t command_opcode) const; // Sends an inquiry response for a fake device. void SendInquiryResult() const; // Sends an extended inquiry response for a fake device. void SendExtendedInquiryResult(const std::string& name, const std::string& address) const; void SetEventDelay(int64_t delay); // Callback provided to send events from the controller back to the HCI. Loading @@ -444,11 +476,11 @@ class DualModeController { // Maintains the commands to be registered and used in the HciHandler object. // Keys are command opcodes and values are the callbacks to handle each // command. std::unordered_map<uint16_t, std::function<void(const std::vector<uint8_t>&)>> std::unordered_map<uint16_t, std::function<void(const vector<uint8_t>&)>> active_hci_commands_; std::unordered_map<std::string, std::function<void(const std::vector<std::string>&)>> std::function<void(const vector<std::string>&)>> active_test_channel_commands_; // Specifies the format of Inquiry Result events to be returned during the Loading @@ -459,9 +491,9 @@ class DualModeController { // 0x03-0xFF: Reserved. uint8_t inquiry_mode_; std::vector<uint8_t> le_event_mask_; vector<uint8_t> le_event_mask_; std::vector<uint8_t> le_random_address_; vector<uint8_t> le_random_address_; uint8_t le_scan_type_; uint16_t le_scan_interval_; Loading