Loading system/gd/hci/hci_packets.pdl +30 −7 Original line number Diff line number Diff line Loading @@ -9,7 +9,8 @@ enum Enable : 8 { } // https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile enum GapDataTypes : 8 { enum GapDataType : 8 { INVALID = 0x00, FLAGS = 0x01, INCOMPLETE_LIST_16_BIT_UUIDS = 0x02, COMPLETE_LIST_16_BIT_UUIDS = 0x03, Loading @@ -23,6 +24,12 @@ enum GapDataTypes : 8 { CLASS_OF_DEVICE = 0x0D, } struct GapData { _size_(data) : 8, // Including one byte for data_type data_type : GapDataType, data : 8[+1*8], } // HCI ACL Packets enum PacketBoundaryFlag : 2 { Loading Loading @@ -1771,12 +1778,14 @@ packet ReadExtendedInquiryResponse : CommandPacket (op_code = READ_EXTENDED_INQU packet ReadExtendedInquiryResponseComplete : CommandComplete (command_op_code = READ_EXTENDED_INQUIRY_RESPONSE) { status : ErrorCode, fec_required : FecRequired, _payload_, extended_inquiry_response : GapData[], } packet WriteExtendedInquiryResponse : CommandPacket (op_code = WRITE_EXTENDED_INQUIRY_RESPONSE) { fec_required : FecRequired, _payload_, extended_inquiry_response : GapData[], //_payload_, // Zero padding to be 240 octets // Should it be GapData[240] ? } packet WriteExtendedInquiryResponseComplete : CommandComplete (command_op_code = WRITE_EXTENDED_INQUIRY_RESPONSE) { Loading Loading @@ -2229,7 +2238,9 @@ packet LeReadAdvertisingChannelTxPowerComplete : CommandComplete (command_op_cod } packet LeSetAdvertisingData : LeAdvertisingCommand (op_code = LE_SET_ADVERTISING_DATA) { _payload_, _size_(advertising_data) : 8, advertising_data : GapData[], _payload_, // Zero padding to 31 bytes of advertising_data } packet LeSetAdvertisingDataComplete : CommandComplete (command_op_code = LE_SET_ADVERTISING_DATA) { Loading @@ -2237,7 +2248,9 @@ packet LeSetAdvertisingDataComplete : CommandComplete (command_op_code = LE_SET_ } packet LeSetScanResponseData : LeAdvertisingCommand (op_code = LE_SET_SCAN_RESPONSE_DATA) { _payload_, _size_(advertising_data) : 8, advertising_data : GapData[], _payload_, // Zero padding to 31 bytes of advertising_data } packet LeSetScanResponseDataComplete : CommandComplete (command_op_code = LE_SET_SCAN_RESPONSE_DATA) { Loading Loading @@ -2996,7 +3009,7 @@ packet ExtendedInquiryResult : EventPacket (event_code = EXTENDED_INQUIRY_RESULT clock_offset : 15, _reserved_ : 1, rssi : 8, _payload_, extended_inquiry_response : GapData[], } packet EncryptionKeyRefreshComplete : EventPacket (event_code = ENCRYPTION_KEY_REFRESH_COMPLETE){ Loading Loading @@ -3097,8 +3110,18 @@ packet LeConnectionComplete : LeMetaEvent (subevent_code = CONNECTION_COMPLETE) master_clock_accuracy : MasterClockAccuracy, } struct LeAdvertisingReport { event_type : AdvertisingEventType, address_type : AddressType, address : Address, _size_(advertising_data) : 8, advertising_data : GapData[], rssi : 8, } packet LeAdvertisingReport : LeMetaEvent (subevent_code = ADVERTISING_REPORT) { _payload_, _count_(le_advertising_reports) : 8, le_advertising_reports : LeAdvertisingReport[], } packet LeConnectionUpdateComplete : LeMetaEvent (subevent_code = CONNECTION_UPDATE_COMPLETE) { Loading system/gd/hci/hci_packets_test.cc +55 −0 Original line number Diff line number Diff line Loading @@ -127,5 +127,60 @@ DEFINE_AND_INSTANTIATE_LeReadBufferSizeReflectionTest(le_read_buffer_size); std::vector<uint8_t> le_read_buffer_size_complete = {0x0e, 0x07, 0x01, 0x02, 0x20, 0x00, 0xfb, 0x00, 0x10}; DEFINE_AND_INSTANTIATE_LeReadBufferSizeCompleteReflectionTest(le_read_buffer_size_complete); std::vector<uint8_t> pixel_3_xl_write_extended_inquiry_response{ 0x52, 0x0c, 0xf1, 0x01, 0x0b, 0x09, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x20, 0x33, 0x20, 0x58, 0x4c, 0x19, 0x03, 0x05, 0x11, 0x0a, 0x11, 0x0c, 0x11, 0x0e, 0x11, 0x12, 0x11, 0x15, 0x11, 0x16, 0x11, 0x1f, 0x11, 0x2d, 0x11, 0x2f, 0x11, 0x00, 0x12, 0x32, 0x11, 0x01, 0x05, 0x81, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; std::vector<uint8_t> pixel_3_xl_write_extended_inquiry_response_no_uuids{ 0x52, 0x0c, 0xf1, 0x01, 0x0b, 0x09, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x20, 0x33, 0x20, 0x58, 0x4c, 0x01, 0x03, 0x01, 0x05, 0x81, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; std::vector<uint8_t> pixel_3_xl_write_extended_inquiry_response_no_uuids_just_eir{ pixel_3_xl_write_extended_inquiry_response_no_uuids.begin() + 4, // skip command, size, and fec_required pixel_3_xl_write_extended_inquiry_response_no_uuids.end()}; TEST(HciPacketsTest, testWriteExtendedInquiryResponse) { std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>(pixel_3_xl_write_extended_inquiry_response); PacketView<kLittleEndian> packet_bytes_view(packet_bytes); auto view = WriteExtendedInquiryResponseView::Create(CommandPacketView::Create(packet_bytes_view)); ASSERT_TRUE(view.IsValid()); auto gap_data = view.GetExtendedInquiryResponse(); ASSERT_EQ(gap_data[0].data_type_, GapDataType::COMPLETE_LOCAL_NAME); ASSERT_EQ(gap_data[0].data_.size(), 10); ASSERT_EQ(gap_data[1].data_type_, GapDataType::COMPLETE_LIST_16_BIT_UUIDS); ASSERT_EQ(gap_data[1].data_.size(), 24); ASSERT_EQ(gap_data[2].data_type_, GapDataType::COMPLETE_LIST_32_BIT_UUIDS); ASSERT_EQ(gap_data[2].data_.size(), 0); ASSERT_EQ(gap_data[3].data_type_, GapDataType::COMPLETE_LIST_128_BIT_UUIDS); ASSERT_EQ(gap_data[3].data_.size(), 128); } // TODO: Revisit reflection tests for EIR // DEFINE_AND_INSTANTIATE_WriteExtendedInquiryResponseReflectionTest(pixel_3_xl_write_extended_inquiry_response, // pixel_3_xl_write_extended_inquiry_response_no_uuids); } // namespace hci } // namespace bluetooth Loading
system/gd/hci/hci_packets.pdl +30 −7 Original line number Diff line number Diff line Loading @@ -9,7 +9,8 @@ enum Enable : 8 { } // https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile enum GapDataTypes : 8 { enum GapDataType : 8 { INVALID = 0x00, FLAGS = 0x01, INCOMPLETE_LIST_16_BIT_UUIDS = 0x02, COMPLETE_LIST_16_BIT_UUIDS = 0x03, Loading @@ -23,6 +24,12 @@ enum GapDataTypes : 8 { CLASS_OF_DEVICE = 0x0D, } struct GapData { _size_(data) : 8, // Including one byte for data_type data_type : GapDataType, data : 8[+1*8], } // HCI ACL Packets enum PacketBoundaryFlag : 2 { Loading Loading @@ -1771,12 +1778,14 @@ packet ReadExtendedInquiryResponse : CommandPacket (op_code = READ_EXTENDED_INQU packet ReadExtendedInquiryResponseComplete : CommandComplete (command_op_code = READ_EXTENDED_INQUIRY_RESPONSE) { status : ErrorCode, fec_required : FecRequired, _payload_, extended_inquiry_response : GapData[], } packet WriteExtendedInquiryResponse : CommandPacket (op_code = WRITE_EXTENDED_INQUIRY_RESPONSE) { fec_required : FecRequired, _payload_, extended_inquiry_response : GapData[], //_payload_, // Zero padding to be 240 octets // Should it be GapData[240] ? } packet WriteExtendedInquiryResponseComplete : CommandComplete (command_op_code = WRITE_EXTENDED_INQUIRY_RESPONSE) { Loading Loading @@ -2229,7 +2238,9 @@ packet LeReadAdvertisingChannelTxPowerComplete : CommandComplete (command_op_cod } packet LeSetAdvertisingData : LeAdvertisingCommand (op_code = LE_SET_ADVERTISING_DATA) { _payload_, _size_(advertising_data) : 8, advertising_data : GapData[], _payload_, // Zero padding to 31 bytes of advertising_data } packet LeSetAdvertisingDataComplete : CommandComplete (command_op_code = LE_SET_ADVERTISING_DATA) { Loading @@ -2237,7 +2248,9 @@ packet LeSetAdvertisingDataComplete : CommandComplete (command_op_code = LE_SET_ } packet LeSetScanResponseData : LeAdvertisingCommand (op_code = LE_SET_SCAN_RESPONSE_DATA) { _payload_, _size_(advertising_data) : 8, advertising_data : GapData[], _payload_, // Zero padding to 31 bytes of advertising_data } packet LeSetScanResponseDataComplete : CommandComplete (command_op_code = LE_SET_SCAN_RESPONSE_DATA) { Loading Loading @@ -2996,7 +3009,7 @@ packet ExtendedInquiryResult : EventPacket (event_code = EXTENDED_INQUIRY_RESULT clock_offset : 15, _reserved_ : 1, rssi : 8, _payload_, extended_inquiry_response : GapData[], } packet EncryptionKeyRefreshComplete : EventPacket (event_code = ENCRYPTION_KEY_REFRESH_COMPLETE){ Loading Loading @@ -3097,8 +3110,18 @@ packet LeConnectionComplete : LeMetaEvent (subevent_code = CONNECTION_COMPLETE) master_clock_accuracy : MasterClockAccuracy, } struct LeAdvertisingReport { event_type : AdvertisingEventType, address_type : AddressType, address : Address, _size_(advertising_data) : 8, advertising_data : GapData[], rssi : 8, } packet LeAdvertisingReport : LeMetaEvent (subevent_code = ADVERTISING_REPORT) { _payload_, _count_(le_advertising_reports) : 8, le_advertising_reports : LeAdvertisingReport[], } packet LeConnectionUpdateComplete : LeMetaEvent (subevent_code = CONNECTION_UPDATE_COMPLETE) { Loading
system/gd/hci/hci_packets_test.cc +55 −0 Original line number Diff line number Diff line Loading @@ -127,5 +127,60 @@ DEFINE_AND_INSTANTIATE_LeReadBufferSizeReflectionTest(le_read_buffer_size); std::vector<uint8_t> le_read_buffer_size_complete = {0x0e, 0x07, 0x01, 0x02, 0x20, 0x00, 0xfb, 0x00, 0x10}; DEFINE_AND_INSTANTIATE_LeReadBufferSizeCompleteReflectionTest(le_read_buffer_size_complete); std::vector<uint8_t> pixel_3_xl_write_extended_inquiry_response{ 0x52, 0x0c, 0xf1, 0x01, 0x0b, 0x09, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x20, 0x33, 0x20, 0x58, 0x4c, 0x19, 0x03, 0x05, 0x11, 0x0a, 0x11, 0x0c, 0x11, 0x0e, 0x11, 0x12, 0x11, 0x15, 0x11, 0x16, 0x11, 0x1f, 0x11, 0x2d, 0x11, 0x2f, 0x11, 0x00, 0x12, 0x32, 0x11, 0x01, 0x05, 0x81, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; std::vector<uint8_t> pixel_3_xl_write_extended_inquiry_response_no_uuids{ 0x52, 0x0c, 0xf1, 0x01, 0x0b, 0x09, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x20, 0x33, 0x20, 0x58, 0x4c, 0x01, 0x03, 0x01, 0x05, 0x81, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; std::vector<uint8_t> pixel_3_xl_write_extended_inquiry_response_no_uuids_just_eir{ pixel_3_xl_write_extended_inquiry_response_no_uuids.begin() + 4, // skip command, size, and fec_required pixel_3_xl_write_extended_inquiry_response_no_uuids.end()}; TEST(HciPacketsTest, testWriteExtendedInquiryResponse) { std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>(pixel_3_xl_write_extended_inquiry_response); PacketView<kLittleEndian> packet_bytes_view(packet_bytes); auto view = WriteExtendedInquiryResponseView::Create(CommandPacketView::Create(packet_bytes_view)); ASSERT_TRUE(view.IsValid()); auto gap_data = view.GetExtendedInquiryResponse(); ASSERT_EQ(gap_data[0].data_type_, GapDataType::COMPLETE_LOCAL_NAME); ASSERT_EQ(gap_data[0].data_.size(), 10); ASSERT_EQ(gap_data[1].data_type_, GapDataType::COMPLETE_LIST_16_BIT_UUIDS); ASSERT_EQ(gap_data[1].data_.size(), 24); ASSERT_EQ(gap_data[2].data_type_, GapDataType::COMPLETE_LIST_32_BIT_UUIDS); ASSERT_EQ(gap_data[2].data_.size(), 0); ASSERT_EQ(gap_data[3].data_type_, GapDataType::COMPLETE_LIST_128_BIT_UUIDS); ASSERT_EQ(gap_data[3].data_.size(), 128); } // TODO: Revisit reflection tests for EIR // DEFINE_AND_INSTANTIATE_WriteExtendedInquiryResponseReflectionTest(pixel_3_xl_write_extended_inquiry_response, // pixel_3_xl_write_extended_inquiry_response_no_uuids); } // namespace hci } // namespace bluetooth