Skip to content

Commit d39b353

Browse files
committed
[BREAKING] Refactor NimBLEServer
* General code cleanup * `NimBLEServerCallbacks::onMTUChanged` renamed to `NimBLEServerCallbacks::onMTUChange` to be consistent with the client callback. * `NimBLEServer::getPeerIDInfo` renamed to `NimBLEServer::getPeerInfoByHandle` to better describe it's use. * Use a std::array to store client connection handles instead of std::vector to reduce memory allocation. * `NimBLEServer::disconnect` now returns `bool`, true = success, instead of `int` to be consistent with the rest of the library.
1 parent c4c9f79 commit d39b353

File tree

5 files changed

+451
-513
lines changed

5 files changed

+451
-513
lines changed

src/NimBLEAdvertising.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,7 @@ bool NimBLEAdvertising::start(uint32_t duration, const NimBLEAddress* dirAddr) {
199199
# if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
200200
NimBLEServer* pServer = NimBLEDevice::getServer();
201201
if (pServer != nullptr) {
202-
if (!pServer->m_gattsStarted) {
203-
pServer->start();
204-
} else if (pServer->getConnectedCount() >= NIMBLE_MAX_CONNECTIONS) {
205-
NIMBLE_LOGE(LOG_TAG, "Unable to advertise; Max connections reached");
206-
return false;
207-
}
202+
pServer->start(); // make sure the GATT server is ready before advertising
208203
}
209204
# endif
210205

src/NimBLEExtAdvertising.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ bool NimBLEExtAdvertising::setInstanceData(uint8_t instId, NimBLEExtAdvertisemen
6262
# if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
6363
NimBLEServer* pServer = NimBLEDevice::getServer();
6464
if (pServer != nullptr) {
65-
if (!pServer->m_gattsStarted) {
66-
pServer->start();
67-
}
65+
pServer->start(); // make sure the GATT server is ready before advertising
6866
}
6967

7068
int rc = ble_gap_ext_adv_configure(

0 commit comments

Comments
 (0)