Loading system/vendor_libs/test_vendor_lib/include/bredr_controller.h +261 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,8 @@ class BREDRController { // Resets the controller. For now, this just generates and sends a command // complete event back to the HCI. // OGF: 0x0003 // OCF: 0x0003 // Command parameters: none. // Command response: // Status (1 octet) Loading @@ -64,6 +66,257 @@ class BREDRController { // 0x01-0xFF: Failed. Check error codes. void HciReset(const std::vector<std::uint8_t>& args); // Reads the max size of the payload for ACL/SCO data packets sent from the // host to the controller. Also reads the number of ACL/SCO data packets // that can be stored in the controller's data buffer. // OGF: 0x0004 // OGF: 0x0005 // Command parameters: none. void HciReadBufferSize(const std::vector<std::uint8_t>& args); // Notifies the controller about the max payload size for ACL/SCO data // packets sent from the controller to the host. Also notifies the controller // about the number of ACL/SCO data packets that can be stored in the host's // data buffers. // OGF: 0x0003 // OCF: 0x0033 // Command parameters: none. void HciHostBufferSize(const std::vector<std::uint8_t>& args); // Gives the host the controller's version information. // OGF: 0x0004 // OCF: 0x0001 // Command parameters: none. void HciReadLocalVersionInformation(const std::vector<std::uint8_t>& args); // Gives the host the controller's address. See the Bluetooth Core // Specification, Version 4.2, Volume 2, Part B (page 58) for more details // about how the address is used. // OGF: 0x0004 // OCF: 0x0009 // Command parameters: none. void HciReadBdAddr(const std::vector<std::uint8_t>& args); // Reads the list of HCI commands the controller supports. // OGF: 0x0004 // OCF: 0x0002 // Command parameters: none. void HciReadLocalSupportedCommands(const std::vector<std::uint8_t>& args); // Returns the requested page of extended LMP features. // OGF: 0x0004 // OCF: 0x0004 // Command parameters: // Page Number (1 octet) // 0x00: Requests the normal LMP features as returned // by HciReadLocalSupportedCommands(). // 0x01-0xFF: Returns the // corresponding page of features. void HciReadLocalExtendedFeatures(const std::vector<std::uint8_t>& args); // Toggles simple pairing mode. // OGF: 0x0003 // OCF: 0x0056 // Command parameters: // Simple Pairing Mode (1 octet) // 0x00: Disables simple pairing. // 0x01: Enables simple pairing. // 0x02-0xFF: Reserved. void HciWriteSimplePairingMode(const std::vector<std::uint8_t>& args); // Used to set the LE Supported and Simultaneous LE and BREDR to Same Device // Capable Link Manager Protocol feature bits. // OGF: 0x0003 // OCF: 0x006D // Command parameters: // LE supported host (1 octet) // 0x00: LE Supported disabled. // 0x01: LE Supported enabled. // 0x02-0xFF: Reserved. // Simultaneous LE Host (1 octet) // 0x00: Simultaneous LE and BREDR to Same Device Capable disabled. // 0x01-0xFF Reserved. void HciWriteLeHostSupport(const std::vector<std::uint8_t>& args); // Used to control which events are generated by the HCI for the host. // OGF: 0x0003 // OCF: 0x0001 // Command parameters: // Event Mask (8 octets) // See the Bluetooth Core Specification, Version 4.2, Volume 2, Section // 7.3.1 (page 642) for details about the event mask. void HciSetEventMask(const std::vector<std::uint8_t>& args); // Writes the inquiry mode configuration parameter of the local controller. // OGF: 0x0003 // OCF: 0x0045 // Command parameters: // Inquiry Mode (1 octet) // 0x00: Standard inquiry result event format. // 0x01: Inquiry result format with RSSI. // 0x02: Inquiry result with RSSI format or extended inquiry result // format. // 0x03-0xFF: Reserved. void HciWriteInquiryMode(const std::vector<std::uint8_t>& args); // Writes the Page Scan Type configuration parameter of the local controller. // OGF: 0x0003 // OCF: 0x0047 // Command parameters: // Page Scan Type (1 octet) // 0x00: Standard scan. // 0x01: Interlaced scan. // 0x02-0xFF: Reserved. void HciWritePageScanType(const std::vector<std::uint8_t>& args); // Writes the Inquiry Scan Type configuration parameter of the local // controller. // OGF: 0x0003 // OCF: 0x0043 // Command parameters: // Scan Type (1 octet) // 0x00: Standard scan. // 0x01: Interlaced scan. // 0x02-0xFF: Reserved. void HciWriteInquiryScanType(const std::vector<std::uint8_t>& args); // Write the value for the class of device parameter. // OGF: 0x0003 // OCF: 0x0024 // Command parameters: // Class of Device (3 octets) void HciWriteClassOfDevice(const std::vector<std::uint8_t>& args); // Writes the value that defines the maximum time the local link manager shall // wait for a baseband page response from the remote device at a locally // initiated connection attempt. // OGF: 0x0003 // OCF: 0x0018 // Command parameters: // Page Timeout (2 octets) // 0: Illegal page timeout, must be larger than 0. // 0xXXXX: Page timeout measured in number of baseband slots. void HciWritePageTimeout(const std::vector<std::uint8_t>& args); // Writes the default link policy configuration value which determines the // initial value of the link policy settings for all new BR/EDR connections. // OGF: 0x0002 // OCF: 0x000F // Command parameters: // Default Link Policy Settings (2 octets) // 0x0000: Disable all LM modes default. // 0x0001: Enable role switch. // 0x0002: Enable hold mode. // 0x0004: Enable sniff mode. // 0x0008: Enable park state. // 0x0010-0x8000: Reserved. void HciWriteDefaultLinkPolicySettings(const std::vector<std::uint8_t>& args); // Reads the stored user-friendly name for the controller. // OGF: 0x0003 // OCF: 0x0014 // Command parameters: none. void HciReadLocalName(const std::vector<std::uint8_t>& args); // Reads the stored user-friendly name for the controller. // OGF: 0x0003 // OCF: 0x0013 // Command parameters: // Local Name (248 octets) void HciWriteLocalName(const std::vector<std::uint8_t>& args); // Writes the extended inquiry response to be sent during the extended inquiry // ersponse procedure. // OGF: 0x0003 // OCF: 0x0052 // Command parameters: // FEC Required (1 octet) // 0x00: FEC is not required. // 0x01: FEC is required. // 0x02-0xFF: Reserved. void HciWriteExtendedInquiryResponse(const std::vector<std::uint8_t>& args); // Writes the values for the voice setting configuration paramter. // OGF: 0x0003 // OCF: 0x0026 // Command parameters: // Voice setting (2 octets, 10 bits meaningful) // See Section 6.12 (page 482). void HciWriteVoiceSetting(const std::vector<std::uint8_t>& args); // Writes the LAP(s) used to create the Inquiry Access Codes that the local // controller is simultaneously scanning for during Inquiry Scans. // OGF: 0x0003 // OCF: 0x003A // Command parameters: // Num Current IAC (1 octet) // 0xXX: Specifies the number of IACs which are currently in use. // IAC LAP (3 octets * Num Current IAC) // 0xXXXXXX: LAP(s) used to create IAC. Ranges from 0x9E8B00-0x9E8B3F. void HciWriteCurrentIacLap(const std::vector<std::uint8_t>& args); // Writes the values for the inquiry scan interval and inquiry scan window // configuration parameters. // OGF: 0x0003 // OCF: 0x001E // Command parameters: // Inquiry Scan Interval (2 octets) // See Section 6.2 (page 478). // Inquiry Scan Window (2 octets) // See Section 6.2 (page 479). void HciWriteInquiryScanActivity(const std::vector<std::uint8_t>& args); // Writes the value for the scan enable configuration parameter. // OGF: 0x0003 // OCF: 0x001A // Command parameters: // Scan Enable (1 octet) // 0x00: No scans enabled (default). // 0x01: Inquiry scan enabled. Page scan disabled. // 0x02: Inquiry scan disable. Page scan enabled. // 0x03: Inquiry scan enabled. Page scan enabled. // 0x04-0xFF: Reserved. void HciWriteScanEnable(const std::vector<std::uint8_t>& args); // Used by the host to specify different event filters. // OGF: 0x0003 // OCF: 0x0005 // Command parameters: // Filter Type (1 octet) // 0x00: Clear all filters. // 0x01: Inquiry result. // 0x02: Connection setup. // 0x03-0xFF: Reserved. // Filter Condition Type (1 octet) // 0x00: Return responses from all devices during the inquiry response. // 0x01: A device with a specific class of device responded to the inquiry // process. // 0x02: A device with a specific BD Address responded to the inquiry // process. // 0x03-0xFF: Reserved. // Condition (1 octet) // 0x00: Allow connections from all devices. // 0x01: Allow connections from a device with a specific class of device. // 0x02: Allow connections from a device with a specific BD Address. // 0x03-0xFF: Reserved. void HciSetEventFilter(const std::vector<std::uint8_t>& args); // Causes the BREDR Controller to enter inquiry mode where other nearby // controllers can be discovered. // OGF: 0x0001 // OCF: 0x0001 // Command parameters: // LAP (3 octets) // 0x9E8B00-0x9E8B3F: LAP from which the inquiry access code should be // derived when the inquiry procedure is made. // Inquiry Length (1 octet) // 0xXX: Maximum amount of time specified before the inquiry is halted. // Num Responses (1 octet) // 0x00: Unlimited number of responses. // 0xXX: Maximum number of responses from the inquiry before the inquiry // is halted. void HciInquiry(const std::vector<std::uint8_t>& args); private: // There will only be a single global instance of this class. BREDRController(); Loading @@ -81,6 +334,14 @@ class BREDRController { // Disallow any copies of the singleton to be made. DISALLOW_COPY_AND_ASSIGN(BREDRController); // Specifies the format of Inquiry Result events to be returned during the // Inquiry command. // 0x00: Standard Inquiry Result event format (default). // 0x01: Inquiry Result format with RSSI. // 0x02 Inquiry Result with RSSI format or Extended Inquiry Result format. // 0x03-0xFF: Reserved. std::uint8_t inquiry_mode_; }; } // namespace test_vendor_lib system/vendor_libs/test_vendor_lib/include/event_packet.h +94 −8 Original line number Diff line number Diff line Loading @@ -49,18 +49,104 @@ class EventPacket : public Packet { // Creates and returns a command complete event packet. See the Bluetooth // Core Specification Version 4.2, Volume 2, Part E, Section 7.7.14 (page 861) // for more information about the command complete event. // |num_hci_command_packets| indicates the number of HCI command packets the // host can send to the controller. If |num_hci_command_packets| is 0, the // controller would like to stop receiving commands from the host (to indicate // Event Parameters: // |num_hci_command_packets| // Indicates the number of HCI command packets the host can send to the // controller. If |num_hci_command_packets| is 0, the controller would // like to stop receiving commands from the host (to indicate // readiness again, the controller sends a command complete event with // |command_opcode| to 0x0000 (no op) and |num_hci_command_packets| > 1). // |command_opcode| is the opcode of the command that caused this event. // |return_parameters| will contain any event specific parameters that should // |command_opcode| // The opcode of the command that caused this event. // |return_parameters| // Contains any event specific parameters that should // be sent to the host. static std::unique_ptr<EventPacket> CreateCommandCompleteEvent( std::uint8_t num_hci_command_packets, std::uint16_t command_opcode, const std::vector<std::uint8_t>& event_return_parameters); // Creates and returns a command complete event packet. See the Bluetooth // Core Specification Version 4.2, Volume 2, Part E, Section 7.7.15 (page 862) // for more information about the command complete event. // Event Parameters: // Status // 0x00: Command currently in pending. // 0x01-0xFF: Command failed. // |num_hci_command_packets| // Indicates the number of HCI command packets the host can send to the // controller. If |num_hci_command_packets| is 0, the controller would // like to stop receiving commands from the host (to indicate // readiness again, the controller sends a command complete event with // |command_opcode| to 0x0000 (no op) and |num_hci_command_packets| > 1). // |command_opcode| // The opcode of the command that caused this event. static std::unique_ptr<EventPacket> CreateCommandStatusEvent( std::uint8_t num_hci_command_packets, std::uint16_t command_opcode); // Creates and returns an inquiry result event packet. See the Bluetooth // Core Specification Version 4.2, Volume 2, Part E, Section 7.7.2 (page 844) // for more information about the command complete event. // Event Parameters: // Num Responses (1 octet) // 0xXX: Number of responses from the inquiry. // Bd Addresses (6 octets * Num Responses) // 0xXXXXXXXXXXX: Bd Address for each device which responded. // Page Scan Repetition Mode (1 octet * Num Responses) // 0x00: R0 // 0x01: R1 // 0x02: R2 // 0x03-0xFF: Reserved. // Reserved 1 (1 octet * Num Responses) // Originally Page Scan Period Mode parameter. No longer in use. // Reserved 2 (1 octet * Num Responses) // Originally Page Scan Mode parameter. No longer in use. // Class of Device (3 octet * Num Responses) // 0xXXXXXX: Class of device. // Clock Offset (2 octet * Num Responses) // Bits 14-0: Bits 16-2 of CLKNslave-CLK. // Bits 15: Reserved. static std::unique_ptr<EventPacket> CreateInquiryResultEvent( std::uint8_t num_responses, const std::vector<std::uint8_t>& bd_addresses, const std::vector<std::uint8_t>& page_scan_repetition_mode, const std::vector<std::uint8_t>& page_scan_period_mode, const std::vector<std::uint8_t>& page_scan_mode, const std::vector<std::uint8_t>& class_of_device, const std::vector<std::uint8_t>& clock_offset); // Creates and returns an inquiry result event packet. See the Bluetooth // Core Specification Version 4.2, Volume 2, Part E, Section 7.7.38 (page 896) // for more information about the command complete event. // Event Parameters: // Num Responses (1 octet) // 0x01: Always contains a single response. // Bd Addresses (6 octets * Num Responses) // 0xXXXXXXXXXXX: Bd Address for each device which responded. // Page Scan Repetition Mode (1 octet * Num Responses) // 0x00: R0 // 0x01: R1 // 0x02: R2 // 0x03-0xFF: Reserved. // Reserved 1 (1 octet * Num Responses) // Originally Page Scan Period Mode parameter. No longer in use. // Class of Device (3 octet * Num Responses) // 0xXXXXXX: Class of device. // Clock Offset (2 octet * Num Responses) // Bits 14-0: Bits 16-2 of CLKNslave-CLK. // Bits 15: Reserved. // RSSI (1 octet) // 0xXX: Ranges from -127 to +20. Units are dBm. // Extended Inquiry Response (240 octets) // Defined in Volumne 2, Part C, Section 8. Also see the Supplement to the // Bluetooth Core Specificiation for data type definitions and formats. static std::unique_ptr<EventPacket> CreateExtendedInquiryResultEvent( const std::vector<std::uint8_t>& bd_address, const std::vector<std::uint8_t>& page_scan_repetition_mode, const std::vector<std::uint8_t>& page_scan_period_mode, const std::vector<std::uint8_t>& class_of_device, const std::vector<std::uint8_t>& clock_offset, const std::vector<std::uint8_t>& rssi, const std::vector<std::uint8_t>& extended_inquiry_response); // Size in octets of a data packet header, which consists of a 1 octet // event code and a 1 octet payload size. static const size_t kEventHeaderSize = 2; Loading system/vendor_libs/test_vendor_lib/include/hci_transport.h +2 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,8 @@ // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. Loading system/vendor_libs/test_vendor_lib/src/bredr_controller.cc +308 −1 File changed.Preview size limit exceeded, changes collapsed. Show changes system/vendor_libs/test_vendor_lib/src/event_packet.cc +75 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ #define LOG_TAG "event_packet" #define VECTOR_COPY_TO_END(source, destination) \ std::copy(source.begin(), source.end(), std::back_inserter(destination)); #include "vendor_libs/test_vendor_lib/include/event_packet.h" extern "C" { Loading Loading @@ -49,11 +52,81 @@ std::unique_ptr<EventPacket> EventPacket::CreateCommandCompleteEvent( payload.push_back(num_hci_command_packets); payload.push_back(command_opcode); payload.push_back(command_opcode >> 8); std::copy(event_return_parameters.begin(), event_return_parameters.end(), std::back_inserter(payload)); VECTOR_COPY_TO_END(event_return_parameters, payload); return std::unique_ptr<EventPacket>( new EventPacket(HCI_COMMAND_COMPLETE_EVT, payload)); } // static std::unique_ptr<EventPacket> EventPacket::CreateCommandStatusEvent( std::uint8_t num_hci_command_packets, std::uint16_t command_opcode) { size_t payload_size = sizeof(num_hci_command_packets) + sizeof(command_opcode); std::vector<uint8_t> payload; payload.reserve(payload_size); payload.push_back(num_hci_command_packets); payload.push_back(command_opcode); payload.push_back(command_opcode >> 8); return std::unique_ptr<EventPacket>( new EventPacket(HCI_COMMAND_STATUS_EVT, payload)); } //static std::unique_ptr<EventPacket> EventPacket::CreateInquiryResultEvent( std::uint8_t num_responses, const std::vector<std::uint8_t>& bd_addresses, const std::vector<std::uint8_t>& page_scan_repetition_mode, const std::vector<std::uint8_t>& page_scan_period_mode, const std::vector<std::uint8_t>& page_scan_mode, const std::vector<std::uint8_t>& class_of_device, const std::vector<std::uint8_t>& clock_offset) { size_t payload_size = sizeof(num_responses) + bd_addresses.size() + page_scan_repetition_mode.size() + page_scan_period_mode.size() + page_scan_mode.size() + class_of_device.size() + clock_offset.size(); std::vector<uint8_t> payload; payload.reserve(payload_size); payload.push_back(num_responses); VECTOR_COPY_TO_END(bd_addresses, payload); VECTOR_COPY_TO_END(page_scan_repetition_mode, payload); VECTOR_COPY_TO_END(page_scan_mode, payload); VECTOR_COPY_TO_END(class_of_device, payload); VECTOR_COPY_TO_END(clock_offset, payload); return std::unique_ptr<EventPacket>( new EventPacket(HCI_INQUIRY_RESULT_EVT, payload)); } //static std::unique_ptr<EventPacket> EventPacket::CreateExtendedInquiryResultEvent( const std::vector<std::uint8_t>& bd_address, const std::vector<std::uint8_t>& page_scan_repetition_mode, const std::vector<std::uint8_t>& page_scan_period_mode, const std::vector<std::uint8_t>& class_of_device, const std::vector<std::uint8_t>& clock_offset, const std::vector<std::uint8_t>& rssi, const std::vector<std::uint8_t>& extended_inquiry_response) { size_t payload_size = 1 + bd_address.size() + page_scan_repetition_mode.size() + page_scan_period_mode.size() + class_of_device.size() + clock_offset.size() + rssi.size() + extended_inquiry_response.size(); std::vector<uint8_t> payload; payload.reserve(payload_size); payload.push_back(1); // Each extended inquiry result contains one device. VECTOR_COPY_TO_END(bd_address, payload); VECTOR_COPY_TO_END(page_scan_repetition_mode, payload); VECTOR_COPY_TO_END(page_scan_period_mode, payload); VECTOR_COPY_TO_END(class_of_device, payload); VECTOR_COPY_TO_END(clock_offset, payload); VECTOR_COPY_TO_END(rssi, payload); VECTOR_COPY_TO_END(extended_inquiry_response, payload); return std::unique_ptr<EventPacket>( new EventPacket(HCI_EXTENDED_INQUIRY_RESULT_EVT, payload)); } } // namespace test_vendor_lib Loading
system/vendor_libs/test_vendor_lib/include/bredr_controller.h +261 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,8 @@ class BREDRController { // Resets the controller. For now, this just generates and sends a command // complete event back to the HCI. // OGF: 0x0003 // OCF: 0x0003 // Command parameters: none. // Command response: // Status (1 octet) Loading @@ -64,6 +66,257 @@ class BREDRController { // 0x01-0xFF: Failed. Check error codes. void HciReset(const std::vector<std::uint8_t>& args); // Reads the max size of the payload for ACL/SCO data packets sent from the // host to the controller. Also reads the number of ACL/SCO data packets // that can be stored in the controller's data buffer. // OGF: 0x0004 // OGF: 0x0005 // Command parameters: none. void HciReadBufferSize(const std::vector<std::uint8_t>& args); // Notifies the controller about the max payload size for ACL/SCO data // packets sent from the controller to the host. Also notifies the controller // about the number of ACL/SCO data packets that can be stored in the host's // data buffers. // OGF: 0x0003 // OCF: 0x0033 // Command parameters: none. void HciHostBufferSize(const std::vector<std::uint8_t>& args); // Gives the host the controller's version information. // OGF: 0x0004 // OCF: 0x0001 // Command parameters: none. void HciReadLocalVersionInformation(const std::vector<std::uint8_t>& args); // Gives the host the controller's address. See the Bluetooth Core // Specification, Version 4.2, Volume 2, Part B (page 58) for more details // about how the address is used. // OGF: 0x0004 // OCF: 0x0009 // Command parameters: none. void HciReadBdAddr(const std::vector<std::uint8_t>& args); // Reads the list of HCI commands the controller supports. // OGF: 0x0004 // OCF: 0x0002 // Command parameters: none. void HciReadLocalSupportedCommands(const std::vector<std::uint8_t>& args); // Returns the requested page of extended LMP features. // OGF: 0x0004 // OCF: 0x0004 // Command parameters: // Page Number (1 octet) // 0x00: Requests the normal LMP features as returned // by HciReadLocalSupportedCommands(). // 0x01-0xFF: Returns the // corresponding page of features. void HciReadLocalExtendedFeatures(const std::vector<std::uint8_t>& args); // Toggles simple pairing mode. // OGF: 0x0003 // OCF: 0x0056 // Command parameters: // Simple Pairing Mode (1 octet) // 0x00: Disables simple pairing. // 0x01: Enables simple pairing. // 0x02-0xFF: Reserved. void HciWriteSimplePairingMode(const std::vector<std::uint8_t>& args); // Used to set the LE Supported and Simultaneous LE and BREDR to Same Device // Capable Link Manager Protocol feature bits. // OGF: 0x0003 // OCF: 0x006D // Command parameters: // LE supported host (1 octet) // 0x00: LE Supported disabled. // 0x01: LE Supported enabled. // 0x02-0xFF: Reserved. // Simultaneous LE Host (1 octet) // 0x00: Simultaneous LE and BREDR to Same Device Capable disabled. // 0x01-0xFF Reserved. void HciWriteLeHostSupport(const std::vector<std::uint8_t>& args); // Used to control which events are generated by the HCI for the host. // OGF: 0x0003 // OCF: 0x0001 // Command parameters: // Event Mask (8 octets) // See the Bluetooth Core Specification, Version 4.2, Volume 2, Section // 7.3.1 (page 642) for details about the event mask. void HciSetEventMask(const std::vector<std::uint8_t>& args); // Writes the inquiry mode configuration parameter of the local controller. // OGF: 0x0003 // OCF: 0x0045 // Command parameters: // Inquiry Mode (1 octet) // 0x00: Standard inquiry result event format. // 0x01: Inquiry result format with RSSI. // 0x02: Inquiry result with RSSI format or extended inquiry result // format. // 0x03-0xFF: Reserved. void HciWriteInquiryMode(const std::vector<std::uint8_t>& args); // Writes the Page Scan Type configuration parameter of the local controller. // OGF: 0x0003 // OCF: 0x0047 // Command parameters: // Page Scan Type (1 octet) // 0x00: Standard scan. // 0x01: Interlaced scan. // 0x02-0xFF: Reserved. void HciWritePageScanType(const std::vector<std::uint8_t>& args); // Writes the Inquiry Scan Type configuration parameter of the local // controller. // OGF: 0x0003 // OCF: 0x0043 // Command parameters: // Scan Type (1 octet) // 0x00: Standard scan. // 0x01: Interlaced scan. // 0x02-0xFF: Reserved. void HciWriteInquiryScanType(const std::vector<std::uint8_t>& args); // Write the value for the class of device parameter. // OGF: 0x0003 // OCF: 0x0024 // Command parameters: // Class of Device (3 octets) void HciWriteClassOfDevice(const std::vector<std::uint8_t>& args); // Writes the value that defines the maximum time the local link manager shall // wait for a baseband page response from the remote device at a locally // initiated connection attempt. // OGF: 0x0003 // OCF: 0x0018 // Command parameters: // Page Timeout (2 octets) // 0: Illegal page timeout, must be larger than 0. // 0xXXXX: Page timeout measured in number of baseband slots. void HciWritePageTimeout(const std::vector<std::uint8_t>& args); // Writes the default link policy configuration value which determines the // initial value of the link policy settings for all new BR/EDR connections. // OGF: 0x0002 // OCF: 0x000F // Command parameters: // Default Link Policy Settings (2 octets) // 0x0000: Disable all LM modes default. // 0x0001: Enable role switch. // 0x0002: Enable hold mode. // 0x0004: Enable sniff mode. // 0x0008: Enable park state. // 0x0010-0x8000: Reserved. void HciWriteDefaultLinkPolicySettings(const std::vector<std::uint8_t>& args); // Reads the stored user-friendly name for the controller. // OGF: 0x0003 // OCF: 0x0014 // Command parameters: none. void HciReadLocalName(const std::vector<std::uint8_t>& args); // Reads the stored user-friendly name for the controller. // OGF: 0x0003 // OCF: 0x0013 // Command parameters: // Local Name (248 octets) void HciWriteLocalName(const std::vector<std::uint8_t>& args); // Writes the extended inquiry response to be sent during the extended inquiry // ersponse procedure. // OGF: 0x0003 // OCF: 0x0052 // Command parameters: // FEC Required (1 octet) // 0x00: FEC is not required. // 0x01: FEC is required. // 0x02-0xFF: Reserved. void HciWriteExtendedInquiryResponse(const std::vector<std::uint8_t>& args); // Writes the values for the voice setting configuration paramter. // OGF: 0x0003 // OCF: 0x0026 // Command parameters: // Voice setting (2 octets, 10 bits meaningful) // See Section 6.12 (page 482). void HciWriteVoiceSetting(const std::vector<std::uint8_t>& args); // Writes the LAP(s) used to create the Inquiry Access Codes that the local // controller is simultaneously scanning for during Inquiry Scans. // OGF: 0x0003 // OCF: 0x003A // Command parameters: // Num Current IAC (1 octet) // 0xXX: Specifies the number of IACs which are currently in use. // IAC LAP (3 octets * Num Current IAC) // 0xXXXXXX: LAP(s) used to create IAC. Ranges from 0x9E8B00-0x9E8B3F. void HciWriteCurrentIacLap(const std::vector<std::uint8_t>& args); // Writes the values for the inquiry scan interval and inquiry scan window // configuration parameters. // OGF: 0x0003 // OCF: 0x001E // Command parameters: // Inquiry Scan Interval (2 octets) // See Section 6.2 (page 478). // Inquiry Scan Window (2 octets) // See Section 6.2 (page 479). void HciWriteInquiryScanActivity(const std::vector<std::uint8_t>& args); // Writes the value for the scan enable configuration parameter. // OGF: 0x0003 // OCF: 0x001A // Command parameters: // Scan Enable (1 octet) // 0x00: No scans enabled (default). // 0x01: Inquiry scan enabled. Page scan disabled. // 0x02: Inquiry scan disable. Page scan enabled. // 0x03: Inquiry scan enabled. Page scan enabled. // 0x04-0xFF: Reserved. void HciWriteScanEnable(const std::vector<std::uint8_t>& args); // Used by the host to specify different event filters. // OGF: 0x0003 // OCF: 0x0005 // Command parameters: // Filter Type (1 octet) // 0x00: Clear all filters. // 0x01: Inquiry result. // 0x02: Connection setup. // 0x03-0xFF: Reserved. // Filter Condition Type (1 octet) // 0x00: Return responses from all devices during the inquiry response. // 0x01: A device with a specific class of device responded to the inquiry // process. // 0x02: A device with a specific BD Address responded to the inquiry // process. // 0x03-0xFF: Reserved. // Condition (1 octet) // 0x00: Allow connections from all devices. // 0x01: Allow connections from a device with a specific class of device. // 0x02: Allow connections from a device with a specific BD Address. // 0x03-0xFF: Reserved. void HciSetEventFilter(const std::vector<std::uint8_t>& args); // Causes the BREDR Controller to enter inquiry mode where other nearby // controllers can be discovered. // OGF: 0x0001 // OCF: 0x0001 // Command parameters: // LAP (3 octets) // 0x9E8B00-0x9E8B3F: LAP from which the inquiry access code should be // derived when the inquiry procedure is made. // Inquiry Length (1 octet) // 0xXX: Maximum amount of time specified before the inquiry is halted. // Num Responses (1 octet) // 0x00: Unlimited number of responses. // 0xXX: Maximum number of responses from the inquiry before the inquiry // is halted. void HciInquiry(const std::vector<std::uint8_t>& args); private: // There will only be a single global instance of this class. BREDRController(); Loading @@ -81,6 +334,14 @@ class BREDRController { // Disallow any copies of the singleton to be made. DISALLOW_COPY_AND_ASSIGN(BREDRController); // Specifies the format of Inquiry Result events to be returned during the // Inquiry command. // 0x00: Standard Inquiry Result event format (default). // 0x01: Inquiry Result format with RSSI. // 0x02 Inquiry Result with RSSI format or Extended Inquiry Result format. // 0x03-0xFF: Reserved. std::uint8_t inquiry_mode_; }; } // namespace test_vendor_lib
system/vendor_libs/test_vendor_lib/include/event_packet.h +94 −8 Original line number Diff line number Diff line Loading @@ -49,18 +49,104 @@ class EventPacket : public Packet { // Creates and returns a command complete event packet. See the Bluetooth // Core Specification Version 4.2, Volume 2, Part E, Section 7.7.14 (page 861) // for more information about the command complete event. // |num_hci_command_packets| indicates the number of HCI command packets the // host can send to the controller. If |num_hci_command_packets| is 0, the // controller would like to stop receiving commands from the host (to indicate // Event Parameters: // |num_hci_command_packets| // Indicates the number of HCI command packets the host can send to the // controller. If |num_hci_command_packets| is 0, the controller would // like to stop receiving commands from the host (to indicate // readiness again, the controller sends a command complete event with // |command_opcode| to 0x0000 (no op) and |num_hci_command_packets| > 1). // |command_opcode| is the opcode of the command that caused this event. // |return_parameters| will contain any event specific parameters that should // |command_opcode| // The opcode of the command that caused this event. // |return_parameters| // Contains any event specific parameters that should // be sent to the host. static std::unique_ptr<EventPacket> CreateCommandCompleteEvent( std::uint8_t num_hci_command_packets, std::uint16_t command_opcode, const std::vector<std::uint8_t>& event_return_parameters); // Creates and returns a command complete event packet. See the Bluetooth // Core Specification Version 4.2, Volume 2, Part E, Section 7.7.15 (page 862) // for more information about the command complete event. // Event Parameters: // Status // 0x00: Command currently in pending. // 0x01-0xFF: Command failed. // |num_hci_command_packets| // Indicates the number of HCI command packets the host can send to the // controller. If |num_hci_command_packets| is 0, the controller would // like to stop receiving commands from the host (to indicate // readiness again, the controller sends a command complete event with // |command_opcode| to 0x0000 (no op) and |num_hci_command_packets| > 1). // |command_opcode| // The opcode of the command that caused this event. static std::unique_ptr<EventPacket> CreateCommandStatusEvent( std::uint8_t num_hci_command_packets, std::uint16_t command_opcode); // Creates and returns an inquiry result event packet. See the Bluetooth // Core Specification Version 4.2, Volume 2, Part E, Section 7.7.2 (page 844) // for more information about the command complete event. // Event Parameters: // Num Responses (1 octet) // 0xXX: Number of responses from the inquiry. // Bd Addresses (6 octets * Num Responses) // 0xXXXXXXXXXXX: Bd Address for each device which responded. // Page Scan Repetition Mode (1 octet * Num Responses) // 0x00: R0 // 0x01: R1 // 0x02: R2 // 0x03-0xFF: Reserved. // Reserved 1 (1 octet * Num Responses) // Originally Page Scan Period Mode parameter. No longer in use. // Reserved 2 (1 octet * Num Responses) // Originally Page Scan Mode parameter. No longer in use. // Class of Device (3 octet * Num Responses) // 0xXXXXXX: Class of device. // Clock Offset (2 octet * Num Responses) // Bits 14-0: Bits 16-2 of CLKNslave-CLK. // Bits 15: Reserved. static std::unique_ptr<EventPacket> CreateInquiryResultEvent( std::uint8_t num_responses, const std::vector<std::uint8_t>& bd_addresses, const std::vector<std::uint8_t>& page_scan_repetition_mode, const std::vector<std::uint8_t>& page_scan_period_mode, const std::vector<std::uint8_t>& page_scan_mode, const std::vector<std::uint8_t>& class_of_device, const std::vector<std::uint8_t>& clock_offset); // Creates and returns an inquiry result event packet. See the Bluetooth // Core Specification Version 4.2, Volume 2, Part E, Section 7.7.38 (page 896) // for more information about the command complete event. // Event Parameters: // Num Responses (1 octet) // 0x01: Always contains a single response. // Bd Addresses (6 octets * Num Responses) // 0xXXXXXXXXXXX: Bd Address for each device which responded. // Page Scan Repetition Mode (1 octet * Num Responses) // 0x00: R0 // 0x01: R1 // 0x02: R2 // 0x03-0xFF: Reserved. // Reserved 1 (1 octet * Num Responses) // Originally Page Scan Period Mode parameter. No longer in use. // Class of Device (3 octet * Num Responses) // 0xXXXXXX: Class of device. // Clock Offset (2 octet * Num Responses) // Bits 14-0: Bits 16-2 of CLKNslave-CLK. // Bits 15: Reserved. // RSSI (1 octet) // 0xXX: Ranges from -127 to +20. Units are dBm. // Extended Inquiry Response (240 octets) // Defined in Volumne 2, Part C, Section 8. Also see the Supplement to the // Bluetooth Core Specificiation for data type definitions and formats. static std::unique_ptr<EventPacket> CreateExtendedInquiryResultEvent( const std::vector<std::uint8_t>& bd_address, const std::vector<std::uint8_t>& page_scan_repetition_mode, const std::vector<std::uint8_t>& page_scan_period_mode, const std::vector<std::uint8_t>& class_of_device, const std::vector<std::uint8_t>& clock_offset, const std::vector<std::uint8_t>& rssi, const std::vector<std::uint8_t>& extended_inquiry_response); // Size in octets of a data packet header, which consists of a 1 octet // event code and a 1 octet payload size. static const size_t kEventHeaderSize = 2; Loading
system/vendor_libs/test_vendor_lib/include/hci_transport.h +2 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,8 @@ // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. Loading
system/vendor_libs/test_vendor_lib/src/bredr_controller.cc +308 −1 File changed.Preview size limit exceeded, changes collapsed. Show changes
system/vendor_libs/test_vendor_lib/src/event_packet.cc +75 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ #define LOG_TAG "event_packet" #define VECTOR_COPY_TO_END(source, destination) \ std::copy(source.begin(), source.end(), std::back_inserter(destination)); #include "vendor_libs/test_vendor_lib/include/event_packet.h" extern "C" { Loading Loading @@ -49,11 +52,81 @@ std::unique_ptr<EventPacket> EventPacket::CreateCommandCompleteEvent( payload.push_back(num_hci_command_packets); payload.push_back(command_opcode); payload.push_back(command_opcode >> 8); std::copy(event_return_parameters.begin(), event_return_parameters.end(), std::back_inserter(payload)); VECTOR_COPY_TO_END(event_return_parameters, payload); return std::unique_ptr<EventPacket>( new EventPacket(HCI_COMMAND_COMPLETE_EVT, payload)); } // static std::unique_ptr<EventPacket> EventPacket::CreateCommandStatusEvent( std::uint8_t num_hci_command_packets, std::uint16_t command_opcode) { size_t payload_size = sizeof(num_hci_command_packets) + sizeof(command_opcode); std::vector<uint8_t> payload; payload.reserve(payload_size); payload.push_back(num_hci_command_packets); payload.push_back(command_opcode); payload.push_back(command_opcode >> 8); return std::unique_ptr<EventPacket>( new EventPacket(HCI_COMMAND_STATUS_EVT, payload)); } //static std::unique_ptr<EventPacket> EventPacket::CreateInquiryResultEvent( std::uint8_t num_responses, const std::vector<std::uint8_t>& bd_addresses, const std::vector<std::uint8_t>& page_scan_repetition_mode, const std::vector<std::uint8_t>& page_scan_period_mode, const std::vector<std::uint8_t>& page_scan_mode, const std::vector<std::uint8_t>& class_of_device, const std::vector<std::uint8_t>& clock_offset) { size_t payload_size = sizeof(num_responses) + bd_addresses.size() + page_scan_repetition_mode.size() + page_scan_period_mode.size() + page_scan_mode.size() + class_of_device.size() + clock_offset.size(); std::vector<uint8_t> payload; payload.reserve(payload_size); payload.push_back(num_responses); VECTOR_COPY_TO_END(bd_addresses, payload); VECTOR_COPY_TO_END(page_scan_repetition_mode, payload); VECTOR_COPY_TO_END(page_scan_mode, payload); VECTOR_COPY_TO_END(class_of_device, payload); VECTOR_COPY_TO_END(clock_offset, payload); return std::unique_ptr<EventPacket>( new EventPacket(HCI_INQUIRY_RESULT_EVT, payload)); } //static std::unique_ptr<EventPacket> EventPacket::CreateExtendedInquiryResultEvent( const std::vector<std::uint8_t>& bd_address, const std::vector<std::uint8_t>& page_scan_repetition_mode, const std::vector<std::uint8_t>& page_scan_period_mode, const std::vector<std::uint8_t>& class_of_device, const std::vector<std::uint8_t>& clock_offset, const std::vector<std::uint8_t>& rssi, const std::vector<std::uint8_t>& extended_inquiry_response) { size_t payload_size = 1 + bd_address.size() + page_scan_repetition_mode.size() + page_scan_period_mode.size() + class_of_device.size() + clock_offset.size() + rssi.size() + extended_inquiry_response.size(); std::vector<uint8_t> payload; payload.reserve(payload_size); payload.push_back(1); // Each extended inquiry result contains one device. VECTOR_COPY_TO_END(bd_address, payload); VECTOR_COPY_TO_END(page_scan_repetition_mode, payload); VECTOR_COPY_TO_END(page_scan_period_mode, payload); VECTOR_COPY_TO_END(class_of_device, payload); VECTOR_COPY_TO_END(clock_offset, payload); VECTOR_COPY_TO_END(rssi, payload); VECTOR_COPY_TO_END(extended_inquiry_response, payload); return std::unique_ptr<EventPacket>( new EventPacket(HCI_EXTENDED_INQUIRY_RESULT_EVT, payload)); } } // namespace test_vendor_lib