Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bea7bd1

Browse filesBrowse files
WhyKickAmooCowme-no-dev
authored andcommitted
Implemented ability to change BLE address (espressif#2690)
Implemented the ability to change the ESP32s BLE device address as according the the BLE specification. This address is used when advertising the ESP32 over BLE.
1 parent 7dd537f commit bea7bd1
Copy full SHA for bea7bd1

File tree

2 files changed

+22
-0
lines changed
Filter options

2 files changed

+22
-0
lines changed

‎libraries/BLE/src/BLEAdvertising.cpp

Copy file name to clipboardExpand all lines: libraries/BLE/src/BLEAdvertising.cpp
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,27 @@ void BLEAdvertising::stop() {
253253
log_v("<< stop");
254254
} // stop
255255

256+
/**
257+
* @brief Set BLE address.
258+
* @param [in] Bluetooth address.
259+
* @param [in] Bluetooth address type.
260+
* Set BLE address.
261+
*/
262+
263+
void BLEAdvertising::setDeviceAddress(esp_bd_addr_t addr, esp_ble_addr_type_t type)
264+
{
265+
log_v(">> setPrivateAddress")
266+
267+
m_advParams.own_addr_type = type;
268+
esp_err_t errRc = esp_ble_gap_set_rand_addr((uint8_t*)addr);
269+
if (errRc != ESP_OK)
270+
{
271+
log_e("esp_ble_gap_set_rand_addr: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
272+
return;
273+
}
274+
log_v("<< setPrivateAddress")
275+
} // setPrivateAddress
276+
256277
/**
257278
* @brief Add data to the payload to be advertised.
258279
* @param [in] data The data to be added to the payload.

‎libraries/BLE/src/BLEAdvertising.h

Copy file name to clipboardExpand all lines: libraries/BLE/src/BLEAdvertising.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class BLEAdvertising {
5858
void setScanFilter(bool scanRequertWhitelistOnly, bool connectWhitelistOnly);
5959
void setScanResponseData(BLEAdvertisementData& advertisementData);
6060
void setPrivateAddress(esp_ble_addr_type_t type = BLE_ADDR_TYPE_RANDOM);
61+
void setDeviceAddress(esp_bd_addr_t addr, esp_ble_addr_type_t type = BLE_ADDR_TYPE_RANDOM);
6162

6263
void handleGAPEvent(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t* param);
6364
void setMinPreferred(uint16_t);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.