37 const uint8_t uuid[16],
const void *buf,
size_t size)
39 const uint8_t *data =
static_cast<const uint8_t*
>(buf);
40 std::basic_string<uint8_t> result(uuid, uuid + 16);
41 result.append(data, size);
51 const uint8_t *data =
static_cast<const uint8_t*
>(buf);
52 std::basic_string<uint8_t> *d;
70 size_t space = std::min((size + 2), (max - d->size()));
71 if (space < (size + 2) && clip ==
false)
76 d->insert(0, 1, space - 1);
77 d->insert(1, 1,
static_cast<uint8_t
>(type));
78 d->insert(2, data, space - 2);
88 const uint8_t *data =
static_cast<const uint8_t*
>(buf);
89 std::basic_string<uint8_t> *d;
107 size_t space = std::min((size + 2), (max - d->size()));
108 if (space < (size + 2) && clip ==
false)
113 d->push_back(space - 1);
114 d->push_back(
static_cast<uint8_t
>(type));
115 d->append(data, space - 2);
123 size_t size,
unsigned instance,
bool exact_size,
126 const uint8_t *data =
static_cast<const uint8_t*
>(buf);
127 std::basic_string<uint8_t> *d;
152 if (exact_size && len != size)
157 size_t space = std::min((size + 2), (max - d->size()) + (len + 2));
158 if (space < size && clip ==
false)
163 d->at(pos) = space - 1;
164 d->replace(pos + 2, len, data, space - 2);
int update(Field field, Defs::AdvType type, const void *buf, size_t size, unsigned instance=1, bool exact_size=true, bool clip=false)
Update existing advertisement.
int append(Field field, Defs::AdvType type, const void *buf, size_t size, bool clip=false)
Add to the end of the advertisement.
static constexpr size_t MAX_SCAN_DATA_PAYLOAD_SIZE
Maximum payload size of scan data.
Field
Data fields that make up an advertisement.
bool extended_
true extended advertisement, else false
static constexpr size_t MAX_DATA_PAYLOAD_SIZE
Maximum payload size of data.
static constexpr size_t MAX_EXT_DATA_PAYLOAD_SIZE
Maximum payload size of extended data.
std::basic_string< uint8_t > data_
advertising data, also used for extended advertising
std::basic_string< uint8_t > concat_service_data_128(const uint8_t uuid[16], const void *buf, size_t size)
Concatenate a 128-bit (16-byte) UUID with provided data.
int prepend(Field field, Defs::AdvType type, const void *buf, size_t size, bool clip=false)
Add to the beginning of the advertisement.
AdvType
Advertising types.
static ssize_t adv_find_data(std::basic_string< uint8_t > &adv, AdvType type, uint8_t *size, unsigned instance=1)
Find an advertisment data within an advertisement set.
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.