Expose advertisement flags in NimBLEAdvertisedDevice

This commit is contained in:
Luca Niccoli 2023-04-06 20:11:50 +02:00 committed by h2zero
parent 0d38a3f43e
commit bc09c74ba6
2 changed files with 20 additions and 0 deletions

View file

@ -62,6 +62,25 @@ uint8_t NimBLEAdvertisedDevice::getAdvType() {
} // getAdvType
/**
* @brief Get the advertisement flags.
* @return The advertisement flags, a bitmask of:
* BLE_HS_ADV_F_DISC_LTD (0x01) - limited discoverability
* BLE_HS_ADV_F_DISC_GEN (0x02) - general discoverability
* BLE_HS_ADV_F_BREDR_UNSUP - BR/EDR not supported
*/
uint8_t NimBLEAdvertisedDevice::getAdvFlags() {
size_t data_loc = 0;
if(findAdvField(BLE_HS_ADV_TYPE_FLAGS, 0, &data_loc) > 0) {
ble_hs_adv_field *field = (ble_hs_adv_field *)&m_payload[data_loc];
if(field->length == BLE_HS_ADV_FLAGS_LEN + 1) {
return *field->value;
}
}
return 0;
} // getAdvFlags
/**
* @brief Get the appearance.
*

View file

@ -45,6 +45,7 @@ public:
NimBLEAddress getAddress();
uint8_t getAdvType();
uint8_t getAdvFlags();
uint16_t getAppearance();
uint16_t getAdvInterval();
uint16_t getMinInterval();