tree: 279b2ab84a3791c773528c8c085f7351f9d95ff6 [path history] [tgz]
  1. include/
  2. src/
  3. third_party/
  4. .gn
  5. args.gni
  6. BUILD.gn
  7. README.md
examples/lock-app/p6/README.md

Matter P6 Lock Example

An example showing the use of Matter on the Infineon CY8CKIT-062S2-43012 board.

Introduction

The P6 lock example provides a demonstration of a door lock control device, built using Matter and the Infineon Modustoolbox SDK. It can be controlled by a Matter controller over Wi-Fi network.

The P6 device can be commissioned over Bluetooth Low Energy where the device and the Matter controller will exchange security information with the Rendezvous procedure. Wi-Fi Network credentials are then provided to the P6 device which will then join the network.

Building

  • Modustoolbox Software

    Refer to integrations/docker/images/chip-build-infineon/Dockerfile or scripts/examples/gn_p6_example.sh for downloading the Software and related tools.

  • Install some additional tools (likely already present for Matter developers): $ sudo apt install gcc g++ clang ninja-build python python3-venv libssl-dev libavahi-client-dev libglib2.0-dev git cmake python3-pip

  • Supported hardware: CY8CKIT-062S2-43012

  • Build the example application:

      $ cd ~/connectedhomeip
      $ ./gn_build.sh enable_p6_builds=true
    

    Or Using P6 build script

      $ ./scripts/examples/gn_p6_example.sh examples/lock-app/p6 out/lock_app_p6
    
  • To delete generated executable, libraries and object files use:

      $ cd ~/connectedhomeip
      $ rm -rf out/
    

Flashing the Application

  • Put CY8CKIT-062S2-43012 board on KitProg3 CMSIS-DAP Mode by pressing the MODE SELECT button. KITPROG3 STATUS LED is ON confirms board is in proper mode.

  • On the command line:

      $ cd ~/connectedhomeip
      $ python3 out/debug/p6_lock_app/chip-p6-lock-example.flash.py
    

    Or when using P6 Build script

      $ cd ~/connectedhomeip
      $ python3 out/lock_app_p6/chip-p6-lock-example.flash.py
    

Commissioning and cluster control

Commissioning can be carried out using BLE.

Setting up Python Controller

Once P6 is up and running, we need to set up a device controller on Raspberry Pi 4 to perform commissioning and cluster control.

  • Set up python controller.

       $ cd {path-to-connectedhomeip}
       $ ./scripts/build_python.sh -m platform
    
  • Execute the controller.

       $ source ./out/python_env/bin/activate
       $ chip-device-ctrl
    

Commissioning over BLE

  • Establish the secure session over BLE.

     - chip-device-ctrl > ble-scan
     - chip-device-ctrl > connect -ble 3840 20202021 1234
    
     Parameters:
     1. Discriminator: 3840
     2. Setup-pin-code: 20202021
     3. Node ID: Optional.
        If not passed in this command, then it is auto-generated by the controller and
        displayed in the output of connect.
        The same value should be used in the next commands.
        We have chosen a random node ID which is 1234.
    
  • Add credentials of the Wi-Fi network you want the P6 to connect to, using the AddWiFiNetwork command and then enable the P6 to connect to it using EnableWiFiNetwork command. In this example, we have used WIFI_SSID and WIFI_PASSWORD as the SSID and passphrase respectively.

     - chip-device-ctrl > zcl NetworkCommissioning AddWiFiNetwork 1234 0 0 ssid=str:WIFI_SSID credentials=str:WIFI_PASSWORD breadcrumb=0 timeoutMs=1000
    
     - chip-device-ctrl > zcl NetworkCommissioning EnableNetwork 1234 0 0 networkID=str:WIFI_SSID breadcrumb=0 timeoutMs=1000
    
  • Close the BLE connection to P6, as it is not required hereafter.

     - chip-device-ctrl > close-ble
    
  • Resolve DNS-SD name and update address of the node in the device controller.

     - chip-device-ctrl > resolve 0 1234
    

Notes

Raspberry Pi 4 BLE connection issues can be avoided by running the following commands. These power cycle the BlueTooth hardware and disable BR/EDR mode.

      $ sudo btmgmt -i hci0 power off
      $ sudo btmgmt -i hci0 bredr off
      $ sudo btmgmt -i hci0 power on

Cluster control

  • After successful commissioning, use the OnOff cluster command to toggle device between On or Off states.

    chip-device-ctrl > zcl OnOff Off 1234 1 0

    chip-device-ctrl > zcl OnOff On 1234 1 0

  • Cluster OnOff can also be done using the USER_BTN1 button on the board. This button is configured with APP_LOCK_BUTTON in include/AppConfig.h. Press USER_BTN1 on the board to toggle between lock and unlock states. The Lock/Unlock status of door can be observed with ‘LED9’ on the board. This LED is configured with LOCK_STATE_LED in include/AppConfig.h.