28#ifndef _BLE_ADVERTISEMENT_HXX_
29#define _BLE_ADVERTISEMENT_HXX_
91 data_.reserve(data_reserve);
92 scanData_.reserve(scan_data_reserve);
104 if (data_reserve > max)
108 data_.reserve(data_reserve);
117 const uint8_t uuid[16],
const void *buf,
size_t size);
124 const uint8_t uuid[16], std::basic_string<uint8_t> &buf)
146 std::basic_string<uint8_t> &buf,
bool clip =
false)
148 return prepend(field, type, buf.data(), buf.size(), clip);
187 return append(field, type, buf.data(), buf.size(), clip);
217 unsigned instance = 1,
bool exact_size =
true,
230 unsigned instance = 1,
bool exact_size =
true,
234 field, type, buf.data(), buf.size(), instance, exact_size, clip);
248 return (uint8_t*)
data_.data();
263 return (uint8_t*)scanData_.data();
274 std::basic_string<uint8_t> &test_get_data()
279 std::basic_string<uint8_t> &test_get_scan_data()
290 std::basic_string<uint8_t> scanData_;
Object helper to define an advertisement.
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.
uint8_t * get_data()
Get the advertisement data.
std::basic_string< uint8_t > concat_service_data_128(const uint8_t uuid[16], std::basic_string< uint8_t > &buf)
Concatenate a 128-bit (16-byte) UUID with provided data.
size_t get_data_size()
Get the advertisement data size in bytes.
int prepend_name(Field field, std::string &name)
Add name to the beginning of the advertisement.
@ LE_ONLY_LIMITED_DISC_MODE
BLE only limited discovery mode.
@ LE_BR_EDR_HOST
BLE + BR/EDR Host.
@ LE_GENERAL_DISC_MODE
BLE general discovery mode.
@ LE_BR_EDR_CONTROLLER
BLE + BR/EDR controller.
@ LE_LIMITED_DISC_MODE
BLE limited discovery mode.
@ BR_EDR_NOT_SUPPORTED
BR/EDR (classic) not supported.
@ LE_ONLY_GENERAL_DISC_MODE
BEE only general discovery mode.
uint8_t * get_scan_data()
Get the advertisement data.
bool is_extended()
Test if extended advertisement or not.
int append(Field field, Defs::AdvType type, const void *buf, size_t size, bool clip=false)
Add to the end of the advertisement.
Advertisement(size_t data_reserve, size_t scan_data_reserve)
Constructor which reserves data and scan data space.
Advertisement(size_t data_reserve, size_t dummy, bool extended)
Constructor which reserves data space.
static constexpr size_t MAX_SCAN_DATA_PAYLOAD_SIZE
Maximum payload size of scan data.
int append(Field field, Defs::AdvType type, std::basic_string< uint8_t > &buf, bool clip=false)
Add to the end of the advertisement.
Field
Data fields that make up an advertisement.
Advertisement(bool extended=false)
Constructor.
int append_name(Field field, std::string &name)
Add name to the end of the advertisement.
bool extended_
true extended advertisement, else false
static constexpr size_t MAX_DATA_PAYLOAD_SIZE
Maximum payload size of data.
int update(Field field, Defs::AdvType type, std::basic_string< uint8_t > &buf, unsigned instance=1, bool exact_size=true, bool clip=false)
Update existing advertisement.
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
int prepend(Field field, Defs::AdvType type, std::basic_string< uint8_t > &buf, bool clip=false)
Add to the beginning of the advertisement.
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.
size_t get_scan_data_size()
Get the advertisement data size in bytes.
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.
@ NAME_COMPLETE
complete local name
@ NAME_SHORT
shortened local name
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.