Compare commits
2 Commits
00d0bbd544
...
dd71e3e11a
Author | SHA1 | Date |
---|---|---|
Julio Contreras Fuica | dd71e3e11a | |
h2zero | b2dba08649 |
|
@ -203,6 +203,24 @@ std::string NimBLEAdvertisedDevice::getURI() {
|
|||
return "";
|
||||
} // getURI
|
||||
|
||||
/**
|
||||
* @brief Get the data from any type available in the advertisement
|
||||
* @param [in] type The advertised data type BLE_HS_ADV_TYPE
|
||||
* @return The data available under the type `type`
|
||||
*/
|
||||
std::string NimBLEAdvertisedDevice::getPayloadByType(uint16_t type) {
|
||||
size_t data_loc = 0;
|
||||
|
||||
if(findAdvField(type, 0, &data_loc) > 0) {
|
||||
ble_hs_adv_field *field = (ble_hs_adv_field *)&m_payload[data_loc];
|
||||
if(field->length > 1) {
|
||||
return std::string((char*)field->value, field->length - 1);
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
} // getPayloadByType
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the advertised name.
|
||||
|
@ -556,6 +574,14 @@ bool NimBLEAdvertisedDevice::haveURI() {
|
|||
return findAdvField(BLE_HS_ADV_TYPE_URI) > 0;
|
||||
} // haveURI
|
||||
|
||||
/**
|
||||
* @brief Does this advertisement have a adv type `type`?
|
||||
* @return True if there is a `type` present.
|
||||
*/
|
||||
bool NimBLEAdvertisedDevice::haveType(uint16_t type) {
|
||||
return findAdvField(type) > 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Does the advertisement contain a target address?
|
||||
|
|
|
@ -53,6 +53,7 @@ public:
|
|||
uint8_t getManufacturerDataCount();
|
||||
std::string getManufacturerData(uint8_t index = 0);
|
||||
std::string getURI();
|
||||
std::string getPayloadByType(uint16_t type);
|
||||
|
||||
/**
|
||||
* @brief A template to convert the service data to <type\>.
|
||||
|
@ -134,6 +135,7 @@ public:
|
|||
bool haveAdvInterval();
|
||||
bool haveTargetAddress();
|
||||
bool haveURI();
|
||||
bool haveType(uint16_t type);
|
||||
std::string toString();
|
||||
bool isConnectable();
|
||||
bool isLegacyAdvertisement();
|
||||
|
|
|
@ -23,7 +23,9 @@
|
|||
# include "esp_bt.h"
|
||||
# include "nvs_flash.h"
|
||||
# if defined(CONFIG_NIMBLE_CPP_IDF)
|
||||
# include "esp_nimble_hci.h"
|
||||
# if (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) || CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE)
|
||||
# include "esp_nimble_hci.h"
|
||||
# endif
|
||||
# include "nimble/nimble_port.h"
|
||||
# include "nimble/nimble_port_freertos.h"
|
||||
# include "host/ble_hs.h"
|
||||
|
|
|
@ -25,6 +25,18 @@
|
|||
#define CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE
|
||||
#define CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE 0
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BTDM_SCAN_DUPL_TYPE_DATA
|
||||
#define CONFIG_BTDM_SCAN_DUPL_TYPE_DATA 1
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE
|
||||
#define CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE 2
|
||||
#endif
|
||||
|
||||
/* Enables the use of Arduino String class for attribute values */
|
||||
#if defined __has_include
|
||||
# if __has_include (<Arduino.h>)
|
||||
|
|
|
@ -59,3 +59,11 @@
|
|||
#if defined(CONFIG_NIMBLE_MAX_CONNECTIONS ) && !defined(CONFIG_BT_NIMBLE_MAX_CONNECTIONS)
|
||||
#define CONFIG_BT_NIMBLE_MAX_CONNECTIONS CONFIG_NIMBLE_MAX_CONNECTIONS
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_BTDM_SCAN_DUPL_CACHE_SIZE) && defined(CONFIG_BT_LE_SCAN_DUPL_CACHE_SIZE)
|
||||
#define CONFIG_BTDM_SCAN_DUPL_CACHE_SIZE CONFIG_BT_LE_SCAN_DUPL_CACHE_SIZE
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_BTDM_SCAN_DUPL_TYPE) && defined(CONFIG_BT_LE_SCAN_DUPL_TYPE)
|
||||
#define CONFIG_BTDM_SCAN_DUPL_TYPE CONFIG_BT_LE_SCAN_DUPL_TYPE
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue