so I am currently working on a NUKI - Hybrid mobile application integration over a hybrid mobile application dev framework Ionic. With the help of a Ionic BluetoothLE plugin (BluetoothLE | Bluetooth LE Plugin for iOS and Android API Methods) I managed to connect to my NUKI Smart Lock device from within my custom mobile application but I am struggling with reading the characteristics as well as writing to them.
Initial idea behind of an implementation is to be able to unlock/lock NUKI Smart Lock from the mobile application. I have called the .discover method of a above mentioned Ionic Bluetooth plugin to retrieve a full list of all services and theirs characteristics.
However as I mentioned above, I have problems implementing write and read functionality of values from a specific service characteristics because of:
firstly I do not even know which service stores Lock/Unlock status of a NUKI Smart Lock inside of a characteristics
List of services and characteristics of a NUKI Smart Lock are not even documented or I’ve not seen the appropriate documentation so far
I would really love to get slightly more information regarding the above described idea of a functionality and several pointed out obscurities.
Looks like you have not fully understood how the BLE API works. The available characteristics are pure input/output pipes. i.e. you send a data stream there and get a response back.
There is no characteristic from which you can read the state. You need to send a “get state” command to the lock and will get a response back. Because everything that is sent is encrypted you first need to pair and create an authentication which allows you to send encrypted commands. There are detailed examples at the end of the BLE API specification for pairing and sending commands.
The documentation is actually very good, and thanks to NUKI to make all of this information public, this is rarely seen for a proprietary device. As suggested, have a look at Jeroens library, it’s all in there. You might just want to use the library instead of writing your own code, he did all the hard work already, and the code is tested and working.
Yeah, I am sorry for my quick run on “badly formatted docs” at the first place as I did not understand the whole princip of communication as @Juergen mentioned.
I managed to get it work by noble npm library for Node.js env, but I am stuck on the 4th step (‘4. SL sends its public key via multiple indications on GDIO’) of the authorisation step. I do get a response back from the NUKI Smart Lock 3.0 device by sending ‘1. CL sends 0100030027A7’ command, getting me in the 4.a) sub-step (‘CL receives 03002FE57DA347CD62431528DAAC5FBB290730FF’) but I am not able to retrieve response from 4.b).
I do have an ‘read’ event listener on the pairing general data IO characteristics (tried as well with the ‘data’ on event listener) but I do not retrieve a second indication which is meant to be retrieved inside of the 4.b) sub-step.
I do please for any further advice or solution. I would very much appreciate it.
Newer phones support larger MTU sizes (up to 250 bytes/message) which could lead to longer responses returned. i.e. 4b could not be necessary anymore if your retrieved already everything in a longer 4a response.