|
Nuki BLE ESP32
|
Note that generated documentation can be found here: https://i-connect.github.io/NukiBleEsp32/
This lib is made for communicating directly to a Nuki smart lock or a Nuki opener via BLE without the need of a Nuki Bridge. Implementation is according to Nuki Smart Lock BLE API (kudo's to the Nuki developers for providing such an accurate and well made documentation!)
From v0.0.5 onwards Implementation is based on Espressif platform version 4.x.x
This library makes use of BLE scanner to receive the Ble advertisements sent by Nuki devices and other Ble devices (https://github.com/I-Connect/BleScanner.git).
When running main.cpp which includes the example NukiSmartLockTest.h (with #define DEBUG_NUKI_CONNECT) there will initially be some logging "No nuki in pairing mode found", if you then press and hold the button on the Nuki lock for 10 secs (until the led ring lights up) the ESP should automatically find the lock in pairing mode and pair with it. Credentials will be saved in a persistent Preference store with store name equal to the devicename specified on construction of the NukiBle object. No pairing needs to be done the next time the ESP starts.
There are some example methods in NukiSmartLockTest.h to get/write data and execute actions on the lock.
Be aware that if you have set a pincode on the lock you will have to store this in the esp using nukiLock.savePincode() otherwise the methods that need a pincode (most methods that write settings) will fail. This only needs to be done once as the pincode will be stored in the preferences.
Logging can be enabled by setting the following defines (these are also available in platformio.ini):
Nuki::NukiLock nukiLock{deviceName, deviceId};
BleScanner::Scanner scanner;
Handler handler;
void setup() {
scanner.initialize();
nukiLock.registerBleScanner(&scanner);
nukiLock.initialize();
nukiLock.setEventHandler(&handler);
}
void loop() {
scanner.update();
delay(10);
// Terminate stale Bluetooth connections
updateConnectionState();
}
The setup for the opener is very much the same as for the lock, except you create a NukiOpener object instead of a NukiLock object. Most functionality is shared between lock and opener, except for device-specific functionality.
For example: