The K32W lock example application provides a working demonstration of a connected door lock device, built using CHIP, and the NXP K32W061 SDK. The example supports remote access (e.g.: using CHIP Tool from a mobile phone) and control of a simulated door lock over a low-power, 802.15.4 Thread network. It is capable of being paired into an existing CHIP network along with other CHIP-enabled devices.
The example targets the NXP K32W061 DK6 development kit, but is readily adaptable to other K32W-based hardware.
The lock example is intended to serve both as a means to explore the workings of CHIP, as well as a template for creating real products based on the NXP platform.
The example application builds upon the CHIP. A top-level Makefile orchestrates the entire build process, including building CHIP, and select files from the NXP SDK. The resultant image file can be flashed directly onto the NXP dev kit hardware using MCUXpresso.
The example application provides a simple UI that depicts the state of the device and offers basic user control. This UI is implemented via the general-purpose LEDs and buttons built in to the OM15082 Expansion board attached to the DK6 board.
LED D2 shows the overall state of the device and its connectivity. Four states are depicted:
Button SW2 can be used to reset the device to a default state.
Pressing and holding Button SW2 for 6 seconds initiates a factory reset. After an initial period of 3 seconds, LED2 D2 and D3 will flash in unison to signal the pending reset. Holding the button past 6 seconds will cause the device to reset its persistent configuration and initiate a reboot. The reset action can be cancelled by releasing the button at any point before the 6 second limit.
LED D3 shows the state of the simulated lock bolt. When the LED is lit the bolt is extended (i.e. door locked); when not lit, the bolt is retracted (door unlocked). The LED will flash whenever the simulated bolt is in motion from one position to another.
Button SW3 can be used to change the state of the simulated bolt. This can be used to mimick a user manually operating the lock. The button behaves as a toggle, swapping the state every time it is pressed.
Button SW4 can be used for joining a Thread network advertised by a Border Router. At this moment, Thread commissioning parameters are hard-coded but a future PR will add support for transmiting them over BLE.
The remaining two LEDs(D1/D2) and button (SW1) are unused.
In order to build Project CHIP, we recommend using a Linux distribution (the demo-application was compiled on Ubuntu 20.04).
Download SDK 2.6.1 MR1 for Project CHIP. You need to create an account before being able to download an SDK. Once the account is created, login and follow the steps for downloading SDK_2.6.1_K32W061DK6. The UI is very intuitive and the correct selection should be similiar with the one from the image below.
Download the suitable ARM GCC toolchain for your Linux distribution
Set two Linux environmental variables based on the above downloaded packages:
user@ubuntu:~/Desktop/git/connectedhomeip$ export K32W061_SDK_ROOT=/home/user/Desktop/git/SDK_2.6.1_K32W061DK6 user@ubuntu:~/Desktop/git/connectedhomeip$ export GNU_INSTALL_ROOT=/home/user/Desktop/git/gcc-arm-none-eabi-7-2018-q2-update/bin/
user@ubuntu:~/Desktop/git/connectedhomeip$ cd examples/lock-app/k32w/ user@ubuntu:~/Desktop/git/connectedhomeip/examples/lock-app/k32w$ make
In case OpenThread fails to compile due to some signing errors just follow the compilation logs and install the recommanded packages (python version > 3, pip3, pycrypto, pycryptodome):
user@ubuntu:~$ python3 --version Python 3.8.2 user@ubuntu:~$ pip3 --version pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8) user@ubuntu:~$ pip3 list | grep -i pycrypto pycrypto 2.6.1 pycryptodome 3.9.8
The resulting elf file can be found in the build directory and it's named chip-k32w061-lock-example.elf.
In order to flash the application we recommend using MCUXpresso IDE (version >= 11.0.0).