At first, we want to pair our laptop with the chip-tool (the Commissioner) with our ESP32 (the Commissionee) and provide the Wi-Fi credentials, the following command will do this for us. The Node ID (here “12344321”) can be chosen freely.
# ./chip-tool pairing ble-wifi node-id ssid password setup-pin-code discriminator
./chip-tool pairing ble-wifi 12344321 "IoT Testing" NotTheRealPassword 20202021 3840
This will perform the complete commissioning discussed in Part 1. In the GIF below, you can see both the monitoring of the device (bottom) and the commissioning with the chip-tool (top).

Let’s have a look at the logs of the chip-tool for the commissioning process and match the output to what we learned in Part 1.
The location where the Fabric credentials are stored. You need to back up these files if you want to keep access to your matter devices, as they will be removed after reboot, when the /tmp folder is cleared.

The log output with comments to explain each section and a summary after the listing.

In summary, the chip-tool does the following:
1.) Discover device via BLE using the discriminator
2.) Setup secure communication (PASE)
3.) Communicate basic information
4.) Perform device attestation
5.) Configure operational credentials on the device
6.) Enable Wi-Fi access on the device
7.) Test connection to the device (CASE)
8.) Close and cleanup all sessions.
Now you can easily turn the light on and off by sending the following command.
# ./chip-tool onoff toggle destination-id endpoint-id
./chip-tool onoff toggle 12344321 1
The following GIF will demonstrate toggling the light.

A brief look at the chip-tool output to explain what is happening.

In summary, the chip-tool does the following:
1.) Setup credentials for Fabric 1
2.) Find Node 12344321 (0xbc5c01) and establish a session using CASE
3.) Send the toggle command (0x2) to the OnOff cluster (0x6) and endpoint 1. (OnOff cluster definitions here)
4.) Receive a response from the node if the command was successful.
We now can see a bright light and controlled our first hand made Matter device. We used many of the concepts explained in Part 1 and the Part 3 of this series we will take a look at binding a light switch to the light bulb to have a more complete setup and get rid of the chip-tool to control the light.
Further reading:
If you are interested in working with us on your Matter product or would like our help, please contact us via our Contact Form or send us an email via matter@grandcentrix.net.