Skip to content

Commit

Permalink
Expose advertisement flags in NimBLEAdvertisedDevice
Browse files Browse the repository at this point in the history
  • Loading branch information
lultimouomo committed Feb 20, 2023
1 parent 0d9f039 commit d5b1779
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/NimBLEAdvertisedDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
1 change: 1 addition & 0 deletions src/NimBLEAdvertisedDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class NimBLEAdvertisedDevice {

NimBLEAddress getAddress();
uint8_t getAdvType();
uint8_t getAdvFlags();
uint16_t getAppearance();
uint16_t getAdvInterval();
uint16_t getMinInterval();
Expand Down

0 comments on commit d5b1779

Please sign in to comment.