Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions examples/NimBLE_Client/NimBLE_Client.ino
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,6 @@ void setup (){
NimBLEDevice::setPower(9); /** +9db */
#endif

/** Optional: set any devices you don't want to get advertisments from */
// NimBLEDevice::addIgnored(NimBLEAddress ("aa:bb:cc:dd:ee:ff"));

/** create new scan */
NimBLEScan* pScan = NimBLEDevice::getScan();

Expand Down
6 changes: 0 additions & 6 deletions src/NimBLEClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -946,8 +946,6 @@ int NimBLEClient::handleGapEvent(struct ble_gap_event* event, void* arg) {
NIMBLE_LOGD(LOG_TAG, "disconnect; reason=%d, %s", rc, NimBLEUtils::returnCodeToString(rc));

pClient->m_terminateFailCount = 0;
NimBLEDevice::removeIgnored(pClient->m_peerAddress);

// Don't call the disconnect callback if we are waiting for a connection to complete and it fails
if (rc != (BLE_HS_ERR_HCI_BASE + BLE_ERR_CONN_ESTABLISHMENT) || pClient->m_config.asyncConnect) {
pClient->m_pClientCallbacks->onDisconnect(pClient, rc);
Expand Down Expand Up @@ -985,10 +983,6 @@ int NimBLEClient::handleGapEvent(struct ble_gap_event* event, void* arg) {
break;
}
}

// In the case of a multi-connecting device we ignore this device when
// scanning since we are already connected to it
NimBLEDevice::addIgnored(pClient->m_peerAddress);
} else {
pClient->m_connHandle = BLE_HS_CONN_HANDLE_NONE;
if (!pClient->m_config.asyncConnect) {
Expand Down
44 changes: 0 additions & 44 deletions src/NimBLEDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ bool NimBLEDevice::m_initialized{false};
uint32_t NimBLEDevice::m_passkey{123456};
bool NimBLEDevice::m_synced{false};
ble_gap_event_listener NimBLEDevice::m_listener{};
std::vector<NimBLEAddress> NimBLEDevice::m_ignoreList{};
std::vector<NimBLEAddress> NimBLEDevice::m_whiteList{};
uint8_t NimBLEDevice::m_ownAddrType{BLE_OWN_ADDR_PUBLIC};

Expand Down Expand Up @@ -928,7 +927,6 @@ bool NimBLEDevice::deinit(bool clearAll) {
deleteClient(clt);
}
# endif
m_ignoreList.clear();
}

return rc == 0;
Expand Down Expand Up @@ -1149,48 +1147,6 @@ bool NimBLEDevice::injectConfirmPasskey(const NimBLEConnInfo& peerInfo, bool acc
return rc == 0;
}

/* -------------------------------------------------------------------------- */
/* IGNORE LIST */
/* -------------------------------------------------------------------------- */

/**
* @brief Check if the device address is on our ignore list.
* @param [in] address The address to look for.
* @return True if ignoring.
*/
bool NimBLEDevice::isIgnored(const NimBLEAddress& address) {
for (const auto& addr : m_ignoreList) {
if (addr == address) {
return true;
}
}

return false;
}

/**
* @brief Add a device to the ignore list.
* @param [in] address The address of the device we want to ignore.
*/
void NimBLEDevice::addIgnored(const NimBLEAddress& address) {
if (!isIgnored(address)) {
m_ignoreList.push_back(address);
}
}

/**
* @brief Remove a device from the ignore list.
* @param [in] address The address of the device we want to remove from the list.
*/
void NimBLEDevice::removeIgnored(const NimBLEAddress& address) {
for (auto it = m_ignoreList.begin(); it < m_ignoreList.end(); ++it) {
if (*it == address) {
m_ignoreList.erase(it);
std::vector<NimBLEAddress>(m_ignoreList).swap(m_ignoreList);
}
}
}

/* -------------------------------------------------------------------------- */
/* UTILITIES */
/* -------------------------------------------------------------------------- */
Expand Down
4 changes: 0 additions & 4 deletions src/NimBLEDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ class NimBLEDevice {
static bool startSecurity(uint16_t connHandle);
static bool setMTU(uint16_t mtu);
static uint16_t getMTU();
static bool isIgnored(const NimBLEAddress& address);
static void addIgnored(const NimBLEAddress& address);
static void removeIgnored(const NimBLEAddress& address);
static void onReset(int reason);
static void onSync(void);
static void host_task(void* param);
Expand Down Expand Up @@ -189,7 +186,6 @@ class NimBLEDevice {
private:
static bool m_synced;
static bool m_initialized;
static std::vector<NimBLEAddress> m_ignoreList;
static uint32_t m_passkey;
static ble_gap_event_listener m_listener;
static uint8_t m_ownAddrType;
Expand Down
10 changes: 6 additions & 4 deletions src/NimBLEScan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,14 @@ int NimBLEScan::handleGapEvent(ble_gap_event* event, void* arg) {
# endif
NimBLEAddress advertisedAddress(disc.addr);

// stop processing if we don't want to see it or are already connected
if (NimBLEDevice::isIgnored(advertisedAddress)) {
NIMBLE_LOGI(LOG_TAG, "Ignoring device: address: %s", advertisedAddress.toString().c_str());
# ifdef CONFIG_BT_NIMBLE_ROLE_CENTRAL
// stop processing if already connected
NimBLEClient* pClient = NimBLEDevice::getClientByPeerAddress(advertisedAddress);
if (pClient != nullptr && pClient->isConnected()) {
NIMBLE_LOGI(LOG_TAG, "Ignoring device: address: %s, already connected", advertisedAddress.toString().c_str());
return 0;
}

# endif
NimBLEAdvertisedDevice* advertisedDevice = nullptr;

// If we've seen this device before get a pointer to it from the vector
Expand Down
Loading