20TEST_CASE(
"AD EIR PDU Test 01",
"[datatype][AD][EIR]" ) {
21 const std::vector<uint8_t> msd_data = { 0x01, 0x02 };
27 std::shared_ptr<const jau::uuid_t>
const p1 = std::make_shared<jau::uuid16_t>( uuid_01 );
28 std::shared_ptr<const jau::uuid_t>
const p2 = uuid_02.
clone();
29 std::cout <<
"uuid_01: " << uuid_01.
toString() <<
", [" << p1->toString() <<
"]" << std::endl;
30 std::cout <<
"uuid_02: " << uuid_02.
toString() <<
", [" << p2->toString() <<
"]" << std::endl;
34 eir0.
setFlags(GAPFlags::LE_Gen_Disc);
35 eir0.setName(
"TestTempDev01");
36 eir0.setManufactureSpecificData(msd);
40 std::cout <<
"eir0.0: " << eir0.
toString(
true) << std::endl;
42 std::vector<uint8_t> buffer;
46 buffer.resize(eir_sz);
47 std::cout <<
"eir0.0: bytes-out " << eir_sz <<
", " << buffer.size() << std::endl;
48 std::cout <<
"eir0.0: " <<
jau::bytesHexString(buffer.data(), 0, buffer.size(),
true ) << std::endl;
50 std::cout << std::endl;
53 const int eir_segments = eir1.
read_data(buffer.data(), buffer.size());
54 std::cout <<
"eir1.0: segments " << eir_segments << std::endl;
55 std::cout <<
"eir1.0: " << eir1.
toString(
true) << std::endl;
57 REQUIRE(eir0 == eir1);
63TEST_CASE(
"AD EIR PDU Test 02",
"[datatype][AD][EIR]" ) {
64 const std::vector<uint8_t> msd_data = { 0x01, 0x02, 0x03, 0x04, 0x05 };
70 const jau::uuid128_t uuid_21(
"00001234-5678-100a-8000-00805F9B34FB");
72 std::shared_ptr<const jau::uuid_t>
const p1 = uuid_21.
clone();
73 std::cout <<
"uuid_21: " << uuid_21.
toString() <<
", [" << p1->toString() <<
"]" << std::endl;
78 eir0a.
setFlags(GAPFlags::LE_Gen_Disc);
79 eir0a.setName(
"TestTempDev02");
80 eir0a.setManufactureSpecificData(msd);
87 const EIRDataType mask_0b = EIRDataType::FLAGS | EIRDataType::NAME | EIRDataType::MANUF_DATA;
89 eir0b.
setFlags(GAPFlags::LE_Gen_Disc);
90 eir0b.setName(
"TestTempDev02");
91 eir0b.setManufactureSpecificData(msd);
94 const EIRDataType mask_0c = EIRDataType::SERVICE_UUID;
101 std::cout <<
"eir0a: " << eir0a.
toString(
true) << std::endl;
102 std::cout <<
"eir0b: " << eir0b.
toString(
true) << std::endl;
103 std::cout <<
"eir0c: " << eir0c.
toString(
true) << std::endl;
107 std::vector<uint8_t> buffer;
110 buffer.resize(eir_sz);
111 std::cout <<
"eir0a.1: bytes-out " << eir_sz <<
", " << buffer.size() << std::endl;
112 std::cout <<
"eir0a.1: " <<
jau::bytesHexString(buffer.data(), 0, buffer.size(),
true ) << std::endl;
113 std::cout << std::endl;
116 const int eir_segments = eir1.
read_data(buffer.data(), buffer.size());
117 std::cout <<
"eir1.0: segments " << eir_segments << std::endl;
118 std::cout <<
"eir1.0: " << eir1.
toString(
true) << std::endl;
120 REQUIRE(eir0b == eir1);
125 std::vector<uint8_t> buffer;
128 buffer.resize(eir_sz);
129 std::cout <<
"eir0a.2: bytes-out " << eir_sz <<
", " << buffer.size() << std::endl;
130 std::cout <<
"eir0a.2: " <<
jau::bytesHexString(buffer.data(), 0, buffer.size(),
true ) << std::endl;
131 std::cout << std::endl;
134 const int eir_segments = eir1.
read_data(buffer.data(), buffer.size());
135 std::cout <<
"eir2.0: segments " << eir_segments << std::endl;
136 std::cout <<
"eir2.0: " << eir1.
toString(
true) << std::endl;
138 REQUIRE(eir0c == eir1);
143 std::vector<uint8_t> buffer1;
147 buffer1.resize(eir_sz1);
148 std::cout <<
"eir0a.3: bytes-out " << eir_sz1 <<
", " << buffer1.size() << std::endl;
149 std::cout <<
"eir0a.3: " <<
jau::bytesHexString(buffer1.data(), 0, buffer1.size(),
true ) << std::endl;
150 std::cout << std::endl;
152 std::vector<uint8_t> buffer2;
155 buffer2.resize(eir_sz2);
156 std::cout <<
"eir0a.4: bytes-out " << eir_sz2 <<
", " << buffer2.size() << std::endl;
157 std::cout <<
"eir0a.4: " <<
jau::bytesHexString(buffer2.data(), 0, buffer2.size(),
true ) << std::endl;
158 std::cout << std::endl;
161 const int eir_segments1 = eir1.
read_data(buffer1.data(), buffer1.size());
162 std::cout <<
"eir3.1: segments " << eir_segments1 << std::endl;
163 std::cout <<
"eir3.1: " << eir1.
toString(
true) << std::endl;
165 const int eir_segments2 = eir1.
read_data(buffer2.data(), buffer2.size());
166 std::cout <<
"eir3.2: segments " << eir_segments2 << std::endl;
167 std::cout <<
"eir3.2: " << eir1.
toString(
true) << std::endl;
169 REQUIRE(eir0a == eir1);
Collection of 'Extended Advertising Data' (EAD), 'Advertising Data' (AD) or 'Extended Inquiry Respons...
std::string toString(const bool includeServices=true) const noexcept
jau::nsize_t write_data(EIRDataType write_mask, uint8_t *data, jau::nsize_t const data_length) const noexcept
Writes the Extended Inquiry Response (EIR) or (Extended) Advertising Data (EAD or AD) segments of exi...
void setFlags(GAPFlags f) noexcept
bool addService(const std::shared_ptr< const jau::uuid_t > &uuid) noexcept
int read_data(uint8_t const *data, uint8_t const data_length) noexcept
Reads the Extended Inquiry Response (EIR) or (Extended) Advertising Data (EAD or AD) segments and ret...
std::string toString() const noexcept override
Returns the string representation in BE network order, i.e.
std::string toString() const noexcept override
Returns the string representation in BE network order, i.e.
std::unique_ptr< uuid_t > clone() const noexcept
EIRDataType
Bit mask of 'Extended Inquiry Response' (EIR) data fields, indicating a set of related data.
uint_fast32_t nsize_t
Natural 'size_t' alternative using uint_fast32_t as its natural sized type.
std::string bytesHexString(const void *data, const nsize_t offset, const nsize_t length, const bool lsbFirst, const bool lowerCase=true) noexcept
Produce a hexadecimal string representation of the given byte values.
TEST_CASE("AD EIR PDU Test 01", "[datatype][AD][EIR]")
EIR AD Test: Squeezing all-at-once .