I have a sample example that runs on esp32 microcontroller which connects successfully to Nuki 2.0 smart lock, creates a user (pair) and locks the smart lock successfully without any issues.
but the same code fails to create a user when it connects to Nuki 1.0 smart lock.
The code belongs to my employer so unfortunately, I can’t share snippets of it. But the logic is straight forward.
Scan for the pairing service and connect to the first device that advertise such service.
Register for notify and enable indications
Write request data command with the public key and follow the logic explained in the api description
for nuki 2.0 it goes on without any issues.
for nuki 1.0 (fw version 1.8.1) i receive the shared key from the smart lock then the corresponding indication
One difference between the two Smart Lock generations that might affect you is the allowed MTU size.
Smart Lock 1.0 is using a maximum MTU size of 23. Therefore any message longer than 20 bytes needs to be sent via a “Write Long” request instead of a regular “Write” request.
As your first message (shorter than 20 bytes) is correctly handled and the second one (longer than 20 bytes) fails, this might be the reason.
Please make also sure, that the ESP32 is also using the MTU size of 23.
Otherwise the ESP32 will still send one “Write Long” request containing the full payload instead of chunks of 20.
To test if the MTU size really is the problem, please try the Smart Lock beta 1.9.1 that has been released on Thursday.
This beta allows a bigger MTU size of 247 (same as Smart Lock 2.0).
If it still is not working with that beta, the reason must be something else.
Just send me your Smart Lock ID via DM and I’ll unlock the beta for it.
ESP32 sends chuked messages (20 + 16 = 36 bytes ) of “ 03 00 8d a4 d1 dd f1 66 d8 64 c1 93 24 9f 55 c7 3a af f4 6e ” and "5a ed 42 89 2f 2c cf ee bd 34 94 4b a3 05 e4 d1 " as the public key payload.
You’re not creating the chunks (splitting the outgoing message) yourself are you?
So it is the smaller MTU size that is causing the issue.
If you want to support Smart Locks with older firmware versions as well you would need to find out how to handle that on the ESP32 correctly.
Do you have the possibility to dump the low level BLE communication of the ESP32?
Supporting old firmwares ( aka MTU of 23 ) is also on my plans but not at the moment honestly, i will come back to you with updates on the actual state once i work on it. it might be a bug in the esp32 framework as well.
Speaking of which … Do you have expected release date for firmware 1.9.1 ?