Closed aenniw closed 2 years ago
Hard for me to say what is happening in this situation with any certainty but I can speculate a couple things.
Security in NimBLE and Bluedroid work differently, where Bluedroid will request a secure connection immediately upon a client connection, NimBLE will only request it when a characteristic is read that has encryption requirements. This may have something to do with the errors. To workaround this a call to NimBLEDevice::startSecurity()
can be used in the NimBLEServerCallbacks::onConnect()
handler to mimic the Bluedroid action.
This line: advertising->setMinPreferred(0x0);
may be causing connection timing issues in NimBLE, depending on how the client uses it, I suggest removing it for both code bases and testing the effect.
removing advertising->setMinPreferred(0x0)
and adding
void onConnect(NimBLEServer *s, ble_gap_conn_desc *desc) override {
NimBLEDevice::startAdvertising();
NimBLEDevice::startSecurity(desc->conn_handle);
}
sadly didn't resolve the notification
issue, any other idea where to look for?
Could you clarify the issue, is this occurring when sending notifications or when the client is subscribing? The logs don't show the disconnect so I'm not able to see what is happening when.
I can say though that the timeout error occurs because no communication between the devices occurred within the supervision timeout, this is set by the client device. The server (peripheral) can request different parameters after the client connects. Requesting that change with a longer timeout setting may resolve that error.
If you could provide more logs, preferably with the nimble core logs enabled I may be able to diagnose this further.
re-tested with:
-DCONFIG_BT_NIMBLE_DEBUG
-DCONFIG_NIMBLE_CPP_DEBUG_LEVEL=5
-DCONFIG_NIMBLE_CPP_ENABLE_RETURN_CODE_TEXT
-DCONFIG_NIMBLE_CPP_ENABLE_GAP_EVENT_CODE_TEXT
-DCONFIG_NIMBLE_CPP_ENABLE_ADVERTISMENT_TYPE_TEXT
and it seems that after these entries the notification seems to misbehave
19:07:09.126 > error persisting cccd; too many entries (8)
19:07:09.126 > looking up our sec;
19:07:09.126 > looking up our sec;
increasing the CONFIG_BT_NIMBLE_MAX_CCCDS
solves the issue :laughing:
thanks!
Oh, right! Thanks for the update, I completely forgot about that setting.
Subscribing to multiple characteristics (tested with
24
) that haveREAD_ENC
orREAD_AUTH
enabled fails. Tested againstAndroid
againstnRF Connect
that failed with eithertimetout error
orerror 6 (0x6) gatt req not supported
and againstreact-native-ble-plx
. Testing the samesketch
withvanilla
BLE works without any issue. If the characteristics have onlyREAD
/NOTIF
everything seems to work fine also... Reducing the number total available characteristics seems to affect the number failed subscriptions...Tested with
arduino-esp32 @ 2.0.2
andplatformio
withespressif32 @ 3.5.0
both usingh2zero/NimBLE-Arduino @ 1.3.7
nimble.log