diff --git a/README.md b/README.md index 3d7e6a2dd9..847ec6034b 100644 --- a/README.md +++ b/README.md @@ -1,186 +1,487 @@ -# Introduction -This repository add the support of Matter on Microchip [PIC32MZW1 (WFI32) Wi-Fi MCU module](https://www.microchip.com/en-us/product/WFI32E01PC). -**To quickly get start the PIC32MZW1 Matter example, you can go to the [PIC32MZW1 lighting-app](examples/lighting-app/mchp/pic32mzw1/README.md) page** +![https://www.microchip.com/](assets/microchip.png) -# Matter + -[![Builds](https://github.com/project-chip/connectedhomeip/workflows/Builds/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/build.yaml) +# Matter (*formerly* CHIP) PIC32MZW1 Lighting Example -[![Examples - EFR32](https://github.com/project-chip/connectedhomeip/workflows/Build%20example%20-%20EFR32/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/examples-efr32.yaml) -[![Examples - ESP32](https://github.com/project-chip/connectedhomeip/workflows/Build%20example%20-%20ESP32/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/examples-esp32.yaml) -[![Examples - i.MX Linux](https://github.com/project-chip/connectedhomeip/workflows/Build%20example%20-%20i.MX%20Linux/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/examples-linux-imx.yaml) -[![Examples - K32W with SE051](https://github.com/project-chip/connectedhomeip/workflows/Build%20example%20-%20K32W%20with%20SE051/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/examples-k32w.yaml) -[![Examples - Linux Standalone](https://github.com/project-chip/connectedhomeip/workflows/Build%20example%20-%20Linux%20Standalone/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/examples-linux-standalone.yaml) -[![Examples - nRF Connect SDK](https://github.com/project-chip/connectedhomeip/workflows/Build%20example%20-%20nRF%20Connect%20SDK/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/examples-nrfconnect.yaml) -[![Examples - QPG](https://github.com/project-chip/connectedhomeip/workflows/Build%20example%20-%20QPG/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/examples-qpg.yaml) -[![Examples - TI CC26X2X7](https://github.com/project-chip/connectedhomeip/workflows/Build%20example%20-%20TI%20CC26X2X7/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/examples-cc13x2x7_26x2x7.yaml) +This MPLAB example demonstrates the use of Matter protocol (also known as Project CHIP - Connected Home over IP) over Microchip PIC32MZW1 based [WFI32-IoT board](https://ww1.microchip.com/downloads/aemDocuments/documents/WSG/ProductDocuments/UserGuides/EV36W50A-WFI32-IoT-Board-Users-Guide-DS50003262.pdf) -[![Android](https://github.com/project-chip/connectedhomeip/workflows/Android/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/android.yaml) +
-[![Unit / Interation Tests](https://github.com/project-chip/connectedhomeip/workflows/Unit%20/%20Interation%20Tests/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/unit_integration_test.yaml) -[![Cirque](https://github.com/project-chip/connectedhomeip/workflows/Cirque/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/cirque.yaml) -[![QEMU](https://github.com/project-chip/connectedhomeip/workflows/QEMU/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/qemu.yaml) +- [CHIP PIC32MZW1 Lighting Example](#chip-pic32mzw1-lighting-example) -[![ZAP Templates](https://github.com/project-chip/connectedhomeip/workflows/ZAP/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/zap_templates.yaml) + - [Introduction](#introduction) + - [Hardware Requirements](#hardware-requirements) + - [Setup CHIP Environment - Install Prerequisites](#setup-chip-environment---install-prerequisites) + - [Software Requirements](#software-requirements) + - [Demo Setup](#demo-setup) + - [Features](#features) + - [Checking out Matter Repository](#checking-out-matter-repository) + - [Wi-Fi Network Provisioning](#wi-fi-network-provisioning) + - [Build and Flash the example](#build-and-flash-the-example) + - [Commissioning and Controlling Matter device](#commissioning-and-controlling-matter-device) + - [OTA Firmware Upgrade](#ota-firmware-upgrade) + - [Memory Consumption](#memory-consumption) + - [Limitations](#example-limitations) + - [Add or modify Harmony 3 components and re-generate the code using MPLAB X IDE](#add-or-modify-harmony-3-components-and-regenerate-code-using-mplab-x-ide) + - [Add or modify clusters](#add-or-modify-clusters) + - [Reference](#reference) + -# What is Matter? + -Matter (formerly Project Connected Home over IP, or Project CHIP) is a new -Working Group within the Connectivity Standards Alliance (CSA, formerly Zigbee -Alliance). This Working Group plans to develop and promote the adoption of a -new, royalty-free connectivity standard to increase compatibility among smart -home products, with security as a fundamental design tenet. +## Introduction -The goal of the Matter project is to simplify development for manufacturers and -increase compatibility for consumers. The project is built around a shared -belief that smart home devices should be secure, reliable, and seamless to use. -By building upon Internet Protocol (IP), the project aims to enable -communication across smart home devices, mobile apps, and cloud services and to -define a specific set of IP-based networking technologies for device -certification. +This example is a starting point for Matter protocol demonstration over Microchip's PIC32MZW1 platform and gives an idea to control the Yellow LED on WFI32-IoT board using Android CHIPTool app (Matter Controller). During the initial release (Phase-1) of this example, we use the example certificates provided in the matter's repo for device attestation and embedded the certifcates in the project code. To launch products in the market, certificates approved by [CSA](https://csa-iot.org/) are need to be used. -The CSA officially opened the Matter Working Group on January 17, 2020 and is in -the process of drafting the specification. +- Note: This example was developed and tested using MPLAB X IDE v6.00+, MPLAB XC32 compiler v4.20 on Ubuntu 20.04 LTS and 22.04 LTS and on Microsoft Windows 10 Pro. -Visit [buildwithmatter.com](https://buildwithmatter.com) to learn more and read -the latest news and updates about the project. + -# Project Overview +## Hardware Requirements -## Development Goals +- [WFI32-IoT board](https://www.microchip.com/en-us/development-tool/EV36W50A) +- An Android Phone with ["CHIPTool" app](assets/matterMicrochip.apk) installed +- Router/AP (Needs no internet connectivity) -Matter is developed with the following goals and principles in mind: + -**Unifying:** Matter will produce a new specification, building with and on top -of market-tested, existing technologies. +## Setup CHIP Environment - Install Prerequisites -**Interoperable:** The specification permits communication between any -Matter-certified device, subject to users’ permission. +The project can support GN build system and MPLAB X IDE build. If you build with MPLAB X IDE, you can run on Windows or Linux environment. If you build with GN build system, you can run on Linux Environment. +Below is the OS environment that you can use. +- Microsoft Windows OR +- [Linux](https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/BUILDING.md#installing-prerequisites-on-linux) (Ubuntu release version 20.04 LTS, 22.04 LTS is preferred) -**Secure:** The specification leverages modern security practices and protocols. + -**User Control:** The end user is in control of authorization for interaction -with devices. +## Software Requirements -**Federated:** No single entity serves as a throttle or a -single-point-of-failure for root of trust. +- [MPLAB X IDE v6.00+](https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-x-ide) and [follow the instructions to install IDE](https://microchipdeveloper.com/mplabx:installation). Also, select "MPLAB IPE" option during IDE installation. +- Check if the DFP v1.6.220 is installed. In MPLAB X IDE, from Menu bar -> Tools -> Packs -> locate "PIC32MZ-W_DFP" as below -**Robust:** The set of protocols specify a complete lifecycle of a device — -starting with the seamless out-of-box experience, through operational protocols, -to device and system management specifications required for proper function in -the presence of change. +

+

+

-**Low Overhead:** The protocols are practically implementable on low -compute-resource devices, such as MCUs. +- [MPLAB XC32 Compiler v4.20](https://www.microchip.com/en-us/tools-resources/develop/mplab-xc-compilers/downloads-documentation#XC32) and [follow the instructions to install XC32 compiler](https://microchipdeveloper.com/xc32:installation). + Use XC32 professional compiler license. Please refer tab 'Internal Microchip Licenses' from [Compilers Latest Builds Page](https://compilers.microchip.com/latest_builds.php) for more details about Internal Microchip Employee License Generator. -**Pervasive:** The protocols are broadly deployable and accessible, thanks to -leveraging IP and being implementable on low-capability devices. +- [Open JDK v8](https://docs.datastax.com/en/jdk-install/doc/jdk-install/installOpenJdkDeb.html) for GN build system. Please note that, this is a strict requirement to use Open JDK v8 -**Ecosystem-Flexible:** The protocol must be flexible enough to accommodate -deployment in ecosystems with differing policies. + - Note: + - For Ubuntu, add PATHs for MPLAB X IDE and XC32 Compiler's installation directories at the end of '~/.profile' OR '~/.bashrc' file: -**Easy to Use:** The protocol should aim to provide smooth, cohesive, integrated -provisioning and out-of-box experience. + ``` + PATH=$PATH:"/opt/microchip/xc32/v4.20/bin" + PATH=$PATH:"/opt/microchip/mplabx/v6.00/mplab_platform/mplab_ipe" + ``` -**Open:** The Project’s design and technical processes should be open and -transparent to the general public, including to non-members wherever possible. + - To continue using the same terminal, run `source ~/.profile` or `source ~/.bashrc` -## Architecture Overview + -![Matter Architecture Overview](docs/images/CHIP_IP_pyramid.png) +## Demo setup -The Project, as illustrated above, defines the application layer that will be -deployed on devices and controllers as well as the supported IPv6-based networks -to help achieve our interoperability architectural goal. Matter will initially -support Wi-Fi and Thread for core, operational communications and Bluetooth Low -Energy (BLE) to simplify device commissioning and setup. +The demo setup for Matter Lighting example includes an Android phone running CHIPTool app, WFI32-IoT board and Router/AP (Needs no internet connectivity). The following diagram shows the demo setup for WFI32-IoT board. -The Application Layer can be further broken down into seven main components: +

+

+

-![Matter Stack Architecture](docs/images/CHIP_Arch_Pyramid.png) + -1. **Application:** High order business logic of a device. For example, an - application that is focused on lighting might contain logic to handle turning - on/off the bulb as well as its color characteristics. +## Features -2. **Data Model:** Data primitives that help describe the various - functionalities of the devices. The Application operates on these data - structures when there is intent to interact with the device. +- This example supports OTA (Over-the-air) firmware upgrade feature +- MPLAB X IDE can be used on Microsoft Windows to build and flash the example +- Enables ON/OFF lighting cluster +- Supports device discovery and Commission +- Status LED (Blue color D403) + - Blinking at 500ms ON/OFF : Attempting to connect to AP + - Blinking at 200ms ON/OFF : Set as Soft-AP mode for network provisioning + - Turned ON (SOLID ON) : Success to connect to AP +- Switch 1 (SW1) + - Short Press : Enables Soft-AP mode + - Long Press for 5 seconds : Factory Reset (Device can be re-commissioned to same AP) +- Switch 2 (SW2) + - Short Press : Turns ON/OFF the Yellow LED, status is to sync to the cluster -3. **Interaction Model:** Represents a set of actions that can be performed on - the devices to interact with it. For example, reading or writing attributes - on a device would correspond to interactions with the devices. These actions - operate on the structures defined by the data model. + -4. **Action Framing:** Once an action is constructed using the Interaction - Model, it is framed into a prescriptive packed binary format to enable being - well represented on the “wire”. +## Checking out Matter Repository -5. **Security:** An encoded action frame is then sent down to the Security Layer - to encrypt and sign the payload to ensure that data is secured and - authenticated by both sender and receiver of a packet. +- To check out the Matter repository: -6. **Message Framing & Routing:** With an interaction encrypted and signed, the - Message Layer constructs the payload format with required and optional header - fields; which specify properties of the message as well as some routing - information. +``` +git clone https://github.com/MicrochipTech/PIC32MZW1_Matter_Project.git +``` -7. **IP Framing & Transport Management:** After the final payload has been - constructed, it is sent to the underlying transport protocol for IP - management of the data. +- Switch to branch "pic32mzw1_support_v1": -# Current Status of Matter +``` +cd PIC32MZW1_Matter_Project/ +git checkout pic32mzw1_support_v1 +``` -Matter’s design and technical processes are intended to be open and transparent -to the general public, including to Work Group non-members wherever possible. -The availability of this GitHub repository and its source code under an Apache -v2 license is an important and demonstrable step to achieving this commitment. +- Update submodules: -Matter endeavors to bring together the best aspects of market-tested -technologies and to redeploy them as a unified and cohesive whole-system -solution. The overall goal of this approach is to bring the benefits of Matter -to consumers and manufacturers as quickly as possible. As a result, what you -observe in this repository is an implementation-first approach to the technical -specification, vetting integrations in practice. +``` +git submodule update --progress --init --recursive -- "third_party/zap/repo" +git submodule update --progress --init --recursive -- "third_party/nlassert/repo" +git submodule update --progress --init --recursive -- "third_party/nlio/repo" +git submodule update --progress --init --recursive -- "third_party/mbedtls/repo" +git submodule update --progress --init --recursive -- "examples/common/QRCode/repo" +``` -The Matter repository is growing and evolving to implement the overall -architecture. The repository currently contains the security foundations, -message framing and dispatch, an implementation of the interaction model and -data model. The code examples show simple interactions, and are supported on -multiple transports -- Wi-Fi and Thread -- starting with resource-constrained -(i.e., memory, processing) silicon platforms to help ensure Matter’s -scalability. + -# How to Contribute +## Build and Flash the example -We welcome your contributions to Matter. Read our contribution guidelines -[here](./CONTRIBUTING.md). +Update default Wi-Fi Access Point (AP) credentials in "/PIC32MZW1_Matter_Project/src/platform/wfi32/CHIPDevicePlatformConfig.h" file as below: -# Building and Developing in Matter +``` +#define CHIP_DEVICE_CONFIG_DEFAULT_STA_SSID "DEMO_AP" +#define CHIP_DEVICE_CONFIG_DEFAULT_STA_PASSWORD "password" +``` + ### For GN buid system (Linux environment) + To build the example using GN build system on Ubuntu, execute following commands: -Instructions about how to build Matter can be found [here](./docs/README.md). + ``` + cd PIC32MZW1_Matter_Project/ + ./scripts/examples/gn_wfi32_example.sh examples/lighting-app/mchp/pic32mzw1/ out/wfi32/ + ``` -# Directory Structure + To flash the example to WFI32-IoT board using CLI, run the following command: -The Matter repository is structured as follows: + ``` + cd PIC32MZW1_Matter_Project/ + ipecmd.sh -TPPKOB4 -P32MZ1025W104132 -M -Fout/wfi32/chip-wfi32-lighting-example.hex -OL + ``` +

+

+

-| File / Folder | Contents | -| -------------------------------------- | ---------------------------------------------------------------------------------- | -| `build/` | Build system support content and build output directories | -| [BUILDING.md](docs/guides/BUILDING.md) | More detailed information on configuring and building Matter for different targets | -| `CODE_OF_CONDUCT.md` | Code of Conduct for Matter, and contributions to it | -| [CONTRIBUTING.md](./CONTRIBUTING.md) | Guidelines for contributing to Matter | -| `docs/` | Documentation, including [guides](./docs/guides) | -| `examples/` | Example firmware applications that demonstrate use of the Matter technology | -| `integrations/` | Third party integrations related to this project | -| `integrations/docker/` | Docker scripts and Dockerfiles | -| `LICENSE` | Matter [License file](./LICENSE) (Apache 2.0) | -| `BUILD.gn` | Top level GN build file | -| `README.md` | This file | -| `src/` | Implementation of Matter | -| `third_party/` | Third-party code used by Matter | -| `scripts/` | Scripts needed to work with the Matter repository | + ### For MPLAB X IDE (Windows environment/ Linux environment) + To build and flash the example using MPLAB X IDE on Microsoft Windows/ Ubuntu, execute following commands: -# License + ``` + $ cd PIC32MZW1_Matter_Project\third_party\wfi32 + $ Run the batch script - "mem_def_workaround.bat" + $ Use MPLAB X IDE to open the project "matter_lighting_app_pic32mz_w1.X", available at PIC32MZW1_Matter_Project\third_party\wfi32\firmware + $ Compile the project in MPLAB X IDE and program the flash + ``` + The debug session can be started by referring to the steps mentioned [here.](https://microchipdeveloper.com/mplabx:start-a-debug-session) -Matter is released under the [Apache 2.0 license](./LICENSE). + + +## Wi-Fi Network Provisioning + +If you want to connect the WFI32-IoT board to the target AP other than the default settings, you can perform below steps: + + #### Step 1: + Short press the Switch 1 (SW1), the WFI32-IoT board will reboot and start in softAP mode. + + The Blue LED on-board will blink at 200ms ON/OFF. +

+

+

+ + #### Step 2: + Connect your smartphone to WFI32-IoT board softAP, SSID is "INF-FFF1-8001" in OPEN security. + + #### Step 3: + Launch the "Microchip WiFi Provisioning" [iOS](https://apps.apple.com/us/app/wi-fi-provisioning/id1553255731?platform=iphone) or [Android](https://play.google.com/store/apps/details?id=com.microchip.wifiapplication) APP on your iPhone or Android phone. + + Click "Connect" button +

+

+

+ + #### Step 4: + - Input the target AP SSID and password: + Select the desired AP name from the app's scan result list and click "Send" button + + #### Step 5: + WFI32-IoT Board receives the target AP credentials and connects to the target AP. The Blue LED on-board turns ON when connected to Wi-Fi. The Blue LED blinks at 500ms ON/OF,F if it fails to make the Wi-Fi connection. +

+

+

+ +- Note: The "Microchip Wi-Fi Provisioning" APP shown above is actually using a TCP client in the backend. The TCP client connects to WFI32-IoT TCP server and sends properly fomratted AP credentials. +User can use any other socket client app beside the smartphone APP. + + For example, user can use a PC to connect the WFI32-IoT softAP (SSID is "INF-FFF1-8001") and run below Python 2.7 based TCP client scripts. The WFI32-IoT board will reboot after it receive the AP credentials. + +```python +import socket +sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +# WFI32-IoT board runs an AP interface with IP address 192.168.1.1 and a TCP server on port 80 +server_address = ('192.168.5.1', 80) +# Connect to the TCP socket +sock.connect(server_address) +# Send AP credentials over the connected socket to the WFI32-IoT board +# Replace 'ssid' with your AP SSID and 'password' with your AP password +# Replace 'security' with proper value relevant to your AP security mode: +#0:Open | 1: WAP/WPA2 | 2:WEP | 3:WPA3 | 4:Enterprise +sock.sendall('apply,ssid,security,password,NULL') +# Send a 'finish' string over the socket to inform WFI32-IoT board to apply the passed credentials +sock.sendall('finish') +``` + + + +## Commissioning and Controlling Matter device + +Once the WFI32-IoT board is programmed with this example, use [Android CHIPTool app](assets/matterMicrochip.apk) to perform next steps in verifying the lighting example with Android device. + +More information about building and installing Android CHIPTool application can be found [here](https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/android_building.md#building-android) + +Alternatively, [follow the instructions to install](https://www.javatpoint.com/how-to-install-apk-on-android) Android CHIPTool app with generated Android debug package (.apk file) from your computer. + +- Note: The device running Android CHIPTool app, should be connected to the same AP ***(configured [here](#building-the-example))*** + + #### Step 1: + + Use "PROVISION CHIP DEVICE WITH WI-FI" -> "INPUT DEVICE ADDRESS" tabs to start commissioning WFI32-IoT board with IP address. + + +

+

+

+ + #### Step 2: + + To find Matter devices connected to the same AP ***(configured [here](#building-the-example))***, with "Discriminator - 3840" and "Pincode - 20202021" use "DISCOVER" tab. For a single Matter device discovered on the network, "Device address" will be auto populated and when multiple Matter devices are discovered, select an entry from the list to populate the "Device address". To proceed with commissioning of the discovered Matter device, use "COMMISSION" tab. + +

+

+

+ + #### Step 3: + + CHIPTool app notifies successful commissioning of Matter device with message "Commissioning completed with result: 0". To proceed with controlling device, use "LIGHT ON/OFF & LEVEL CLUSTER" tab. + +

+

+

+ + #### Step 4: + + The Yellow LED on-board can be controlled - turned ON, OFF, toggled using respective tabs. The "READ" tab returns the On/Off command value. + + User can also press SW2 on-board to control ON, OFF the Yellow LED locally. The "READ" tab on the APP returns the On/Off command value. + + - Note: "Fabric ID" and "Device ID" fields will be auto populated. + +

+

+

+

+

+ + - Note: If you need to re-commission the device, you can long press Switch 1 (SW1) for 5 sec to factory reset the device. + + + +## OTA Firmware Upgrade + + ### Build Process + - The MPLAB X IDE based Example includes OTA and Bootloader features by default. + + - For GN system based example, follow the steps: + - Navigate to "/PIC32MZW1_Matter_Project/" directory + + ``` + Build the Bootloader: + + $ /opt/microchip/mplabx/*/mplab_platform/bin/prjMakefilesGenerator.sh -v third_party/wfi32/bootloader/firmware/pic32mz_w1_curiosity.X@pic32mz_w1_curiosity + + $ /opt/microchip/mplabx/*/mplab_platform/bin/make -j32 -C third_party/wfi32/bootloader/firmware/pic32mz_w1_curiosity.X + ``` + + ``` + Build the Application example: + + $ ./scripts/examples/gn_wfi32_example.sh examples/lighting-app/mchp/pic32mzw1/ out/wfi32 linker_file=\"app_mz.ld\" enable_ota="true" + ``` + + ``` + Generate OTA image: + + $ /opt/microchip/xc32//bin/xc32-objcopy -I ihex -O binary out/wfi32/chip-wfi32-lighting-example.hex out/wfi32/chip-wfi32-lighting-example.bin + + Note: is the compiler version installed/used, e.g. “v4.20” + ``` + + ``` + Generate the unified image that includes both the bootloader and example images: + + $ /opt/microchip/mplabx/*/mplab_platform/bin/hexmate --edf="/opt/microchip/mplabx//mplab_platform/dat/en_msgs.txt" out/wfi32/chip-wfi32-lighting-example.hex third_party/wfi32/bootloader/firmware/pic32mz_w1_curiosity.X/dist/pic32mz_w1_curiosity/production/pic32mz_w1_curiosity.X.production.hex -oout/wfi32/chip-wfi32-lighting-example_unified.hex + + Note: is the MPLAB version installed/used, e.g. “v6.05” + ``` + + ### OTA Test Setup + + - Generate the OTA image + - The OTA image is generated at \PIC32MZW1_Matter_Project\third_party\wfi32\firmware\matter_lighting_app_pic32mz_w1.X\dist\pic32mz_w1_curiosity\production\matter_lighting_app_pic32mz_w1.X.production.bin + + - Run below command to generate Matter OTA image that includes Matter specific header + + 1. MPLAB X based build: + + ``` + $ python ./src/app/ota_image_tool.py create -v 0xDEAD -p 0xBEEF -vn 2 -vs "2.0" -da sha256 ./third_party/wfi32/firmware/matter_lighting_app_pic32mz_w1.X/dist/pic32mz_w1_curiosity/production/matter_lighting_app_pic32mz_w1.X.production.bin matter_lighting_app_pic32mz_w1.X.production.ota + ``` + 2. GN build: + + ``` + $ python ./src/app/ota_image_tool.py create -v 0xDEAD -p 0xBEEF -vn 2 -vs "2.0" -da sha256 out/wfi32/chip-wfi32-lighting-example.bin out/wfi32/chip-wfi32-lighting-example.ota + ``` + + - Set up OTA provider: + - To perform OTA firmware upgrade, PIC32MZW1 device acts as OTA requestor and retrieves the OTA image from the OTA provider. Raspberry Pi can be used as OTA provider. + - Note: Guide to prepare Raspberry Pi as Matter device can be found [here](https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/BUILDING.md) + + - Following two applications need to be run on Raspberry Pi, to verify working of Matter Lighting Example: + - ota-provider-app + [Build the application on Raspberry Pi](https://github.com/project-chip/connectedhomeip/tree/master/examples/ota-provider-app/linux) + + - chip-tool + [Build the application on Raspberry Pi](https://github.com/project-chip/connectedhomeip/tree/master/examples/chip-tool) + + - Run the OTA tests on Raspberry Pi + + ``` + On Raspberry Pi (Terminal 1) + $ ./chip-ota-provider-app -f matter_lighting_app_pic32mz_w1.X.production.ota + + On Raspberry Pi (Terminal 2) + $ ./chip-tool pairing onnetwork 1 20202021 + + $ ./chip-tool accesscontrol write acl '[{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [112233], "targets": null}, {"fabricIndex": 1, "privilege": 3, "authMode": 2, "subjects": null, "targets": null}]' 1 0 + + $ ./chip-tool pairing onnetwork 2 20202021 + + $ ./chip-tool otasoftwareupdaterequestor announce-ota-provider 1 0 0 0 2 0 + ``` + + + +## Memory Consumption + +As per latest memory usage analysis, this example consumes 892KB Program Memory and 238KB Data Memory. + + + +## Example Limitations +- Debug mode cannot be used with MPLAB X IDE on Microsoft Windows +- It takes long loading time to start debug mode with MPLAB X IDE +- Requires MPLAB XC32 compiler's PRO license +- Example certificates provided in the matter's repo are used for device attestation, certificates are embedded in the program code. +- Not support with Google Home APP/ Google Assistant + + + +## Add or modify Harmony 3 components and re-generate the code using MPLAB X IDE +- If you need to customize the project, H3 services/libraries can be added or removed and peripherals or components such as GPIO, UART, SPI etc. can be configured through project graph option in MHC (MPLAB Harmony 3 Configurator). The source code can be re-generated to include necessary changes. + + - MHC Project Configuration for PIC32MZW1 Lighting Example: +

+

+

+ + - To re-generate the code using MHC, select "USER_RECENT" as Merge Strategy: +

+

+

+ + - Do not merge following code, if the prompt messages are shown: +

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+ + + +## Add or modify clusters + +To customize the proejct, user can configure/enable/disable different clusters using ZAP GUI tool for cluster configuration. More information is available [here.](https://github.com/project-chip/connectedhomeip/tree/master/src/app/zap-templates) +Application codes under directory PIC32MZW1_Matter_Project/examples/lighting-app/mchp/pic32mzw1/ need to be modified after the clusters configurations are changed. + + ### Pre-requisite for Linux + - [Install node version 16.x for ZAP GUI tool](https://joshtronic.com/2021/05/09/how-to-install-nodejs-16-on-ubuntu-2004-lts/) + + #### Launch GUI and Configure Clusters + - Execute the following commands: + +``` +$ cd PIC32MZW1_Matter_Project/ +$ ./scripts/tools/zap/run_zaptool.sh +For example: +$ ./scripts/tools/zap/run_zaptool.sh examples/lighting-app/lighting-common/lighting-app.zap + +$ ./scripts/tools/zap/generated.py -o +For example: +$ ./scripts/tools/zap/generated.py examples/lighting-app/lighting-common/lighting-app.zap -o zzz_generated/lighting-app/zap-generated +``` + + ### Pre-requisite for Windows + - [Download node](https://nodejs.org/download/release/v16.18.0/) and move the node folder to C:\Program Files. Add "path-to-node.exe" to the environment PATH variable. + - In command prompt, type: cd \PIC32MZW1_Matter_Project\third_party\zap\repo + - Type: npm install installed-check + + #### Launch GUI and Configure Clusters + - Execute the following command: + + ``` + $ node src-script/zap-start.js --logToStdout --gen /PIC32MZW1_Matter_Project/src/app/zap-templates/app-templates.json --zcl /PIC32MZW1_Matter_Project/src/app/zap-templates/zcl/zcl.json -I + + For example: + $ node src-script/zap-start.js --logToStdout --gen /PIC32MZW1_Matter_Project/src/app/zap-templates/app-templates.json --zcl /PIC32MZW1_Matter_Project/src/app/zap-templates/zcl/zcl.json -i /PIC32MZW1_Matter_Project/examples/lighting-app/lighting-common/lighting-app.zap + + $ npm install installed-check + ``` + + #### Generate the template code + - Using command prompt, go to /PIC32MZW1_Matter_Project directory + +

+

+

+ + - Execute the following command: + + ``` + $ python + + For example: + $ python scripts/tools/zap/generate.py examples\lighting-app\lighting-common\lighting-app.zap -o zzz_generated\lighting-app\zap-generated + ``` + - Note: Template codes are generated at + + + +## Reference +- The official Matter (project CHIP) github repo can be found [here.](https://github.com/project-chip/connectedhomeip) +- The official specification document can be downloaded by [submitting this request form](https://csa-iot.org/developer-resource/specifications-download-request/) diff --git a/README_MATTER.md b/README_MATTER.md new file mode 100644 index 0000000000..3d7e6a2dd9 --- /dev/null +++ b/README_MATTER.md @@ -0,0 +1,186 @@ +# Introduction +This repository add the support of Matter on Microchip [PIC32MZW1 (WFI32) Wi-Fi MCU module](https://www.microchip.com/en-us/product/WFI32E01PC). +**To quickly get start the PIC32MZW1 Matter example, you can go to the [PIC32MZW1 lighting-app](examples/lighting-app/mchp/pic32mzw1/README.md) page** + +# Matter + +[![Builds](https://github.com/project-chip/connectedhomeip/workflows/Builds/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/build.yaml) + +[![Examples - EFR32](https://github.com/project-chip/connectedhomeip/workflows/Build%20example%20-%20EFR32/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/examples-efr32.yaml) +[![Examples - ESP32](https://github.com/project-chip/connectedhomeip/workflows/Build%20example%20-%20ESP32/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/examples-esp32.yaml) +[![Examples - i.MX Linux](https://github.com/project-chip/connectedhomeip/workflows/Build%20example%20-%20i.MX%20Linux/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/examples-linux-imx.yaml) +[![Examples - K32W with SE051](https://github.com/project-chip/connectedhomeip/workflows/Build%20example%20-%20K32W%20with%20SE051/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/examples-k32w.yaml) +[![Examples - Linux Standalone](https://github.com/project-chip/connectedhomeip/workflows/Build%20example%20-%20Linux%20Standalone/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/examples-linux-standalone.yaml) +[![Examples - nRF Connect SDK](https://github.com/project-chip/connectedhomeip/workflows/Build%20example%20-%20nRF%20Connect%20SDK/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/examples-nrfconnect.yaml) +[![Examples - QPG](https://github.com/project-chip/connectedhomeip/workflows/Build%20example%20-%20QPG/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/examples-qpg.yaml) +[![Examples - TI CC26X2X7](https://github.com/project-chip/connectedhomeip/workflows/Build%20example%20-%20TI%20CC26X2X7/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/examples-cc13x2x7_26x2x7.yaml) + +[![Android](https://github.com/project-chip/connectedhomeip/workflows/Android/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/android.yaml) + +[![Unit / Interation Tests](https://github.com/project-chip/connectedhomeip/workflows/Unit%20/%20Interation%20Tests/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/unit_integration_test.yaml) +[![Cirque](https://github.com/project-chip/connectedhomeip/workflows/Cirque/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/cirque.yaml) +[![QEMU](https://github.com/project-chip/connectedhomeip/workflows/QEMU/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/qemu.yaml) + +[![ZAP Templates](https://github.com/project-chip/connectedhomeip/workflows/ZAP/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/zap_templates.yaml) + +# What is Matter? + +Matter (formerly Project Connected Home over IP, or Project CHIP) is a new +Working Group within the Connectivity Standards Alliance (CSA, formerly Zigbee +Alliance). This Working Group plans to develop and promote the adoption of a +new, royalty-free connectivity standard to increase compatibility among smart +home products, with security as a fundamental design tenet. + +The goal of the Matter project is to simplify development for manufacturers and +increase compatibility for consumers. The project is built around a shared +belief that smart home devices should be secure, reliable, and seamless to use. +By building upon Internet Protocol (IP), the project aims to enable +communication across smart home devices, mobile apps, and cloud services and to +define a specific set of IP-based networking technologies for device +certification. + +The CSA officially opened the Matter Working Group on January 17, 2020 and is in +the process of drafting the specification. + +Visit [buildwithmatter.com](https://buildwithmatter.com) to learn more and read +the latest news and updates about the project. + +# Project Overview + +## Development Goals + +Matter is developed with the following goals and principles in mind: + +**Unifying:** Matter will produce a new specification, building with and on top +of market-tested, existing technologies. + +**Interoperable:** The specification permits communication between any +Matter-certified device, subject to users’ permission. + +**Secure:** The specification leverages modern security practices and protocols. + +**User Control:** The end user is in control of authorization for interaction +with devices. + +**Federated:** No single entity serves as a throttle or a +single-point-of-failure for root of trust. + +**Robust:** The set of protocols specify a complete lifecycle of a device — +starting with the seamless out-of-box experience, through operational protocols, +to device and system management specifications required for proper function in +the presence of change. + +**Low Overhead:** The protocols are practically implementable on low +compute-resource devices, such as MCUs. + +**Pervasive:** The protocols are broadly deployable and accessible, thanks to +leveraging IP and being implementable on low-capability devices. + +**Ecosystem-Flexible:** The protocol must be flexible enough to accommodate +deployment in ecosystems with differing policies. + +**Easy to Use:** The protocol should aim to provide smooth, cohesive, integrated +provisioning and out-of-box experience. + +**Open:** The Project’s design and technical processes should be open and +transparent to the general public, including to non-members wherever possible. + +## Architecture Overview + +![Matter Architecture Overview](docs/images/CHIP_IP_pyramid.png) + +The Project, as illustrated above, defines the application layer that will be +deployed on devices and controllers as well as the supported IPv6-based networks +to help achieve our interoperability architectural goal. Matter will initially +support Wi-Fi and Thread for core, operational communications and Bluetooth Low +Energy (BLE) to simplify device commissioning and setup. + +The Application Layer can be further broken down into seven main components: + +![Matter Stack Architecture](docs/images/CHIP_Arch_Pyramid.png) + +1. **Application:** High order business logic of a device. For example, an + application that is focused on lighting might contain logic to handle turning + on/off the bulb as well as its color characteristics. + +2. **Data Model:** Data primitives that help describe the various + functionalities of the devices. The Application operates on these data + structures when there is intent to interact with the device. + +3. **Interaction Model:** Represents a set of actions that can be performed on + the devices to interact with it. For example, reading or writing attributes + on a device would correspond to interactions with the devices. These actions + operate on the structures defined by the data model. + +4. **Action Framing:** Once an action is constructed using the Interaction + Model, it is framed into a prescriptive packed binary format to enable being + well represented on the “wire”. + +5. **Security:** An encoded action frame is then sent down to the Security Layer + to encrypt and sign the payload to ensure that data is secured and + authenticated by both sender and receiver of a packet. + +6. **Message Framing & Routing:** With an interaction encrypted and signed, the + Message Layer constructs the payload format with required and optional header + fields; which specify properties of the message as well as some routing + information. + +7. **IP Framing & Transport Management:** After the final payload has been + constructed, it is sent to the underlying transport protocol for IP + management of the data. + +# Current Status of Matter + +Matter’s design and technical processes are intended to be open and transparent +to the general public, including to Work Group non-members wherever possible. +The availability of this GitHub repository and its source code under an Apache +v2 license is an important and demonstrable step to achieving this commitment. + +Matter endeavors to bring together the best aspects of market-tested +technologies and to redeploy them as a unified and cohesive whole-system +solution. The overall goal of this approach is to bring the benefits of Matter +to consumers and manufacturers as quickly as possible. As a result, what you +observe in this repository is an implementation-first approach to the technical +specification, vetting integrations in practice. + +The Matter repository is growing and evolving to implement the overall +architecture. The repository currently contains the security foundations, +message framing and dispatch, an implementation of the interaction model and +data model. The code examples show simple interactions, and are supported on +multiple transports -- Wi-Fi and Thread -- starting with resource-constrained +(i.e., memory, processing) silicon platforms to help ensure Matter’s +scalability. + +# How to Contribute + +We welcome your contributions to Matter. Read our contribution guidelines +[here](./CONTRIBUTING.md). + +# Building and Developing in Matter + +Instructions about how to build Matter can be found [here](./docs/README.md). + +# Directory Structure + +The Matter repository is structured as follows: + +| File / Folder | Contents | +| -------------------------------------- | ---------------------------------------------------------------------------------- | +| `build/` | Build system support content and build output directories | +| [BUILDING.md](docs/guides/BUILDING.md) | More detailed information on configuring and building Matter for different targets | +| `CODE_OF_CONDUCT.md` | Code of Conduct for Matter, and contributions to it | +| [CONTRIBUTING.md](./CONTRIBUTING.md) | Guidelines for contributing to Matter | +| `docs/` | Documentation, including [guides](./docs/guides) | +| `examples/` | Example firmware applications that demonstrate use of the Matter technology | +| `integrations/` | Third party integrations related to this project | +| `integrations/docker/` | Docker scripts and Dockerfiles | +| `LICENSE` | Matter [License file](./LICENSE) (Apache 2.0) | +| `BUILD.gn` | Top level GN build file | +| `README.md` | This file | +| `src/` | Implementation of Matter | +| `third_party/` | Third-party code used by Matter | +| `scripts/` | Scripts needed to work with the Matter repository | + +# License + +Matter is released under the [Apache 2.0 license](./LICENSE). diff --git a/assets/CommissionedControlMenu.png b/assets/CommissionedControlMenu.png new file mode 100644 index 0000000000..cc78e67e75 Binary files /dev/null and b/assets/CommissionedControlMenu.png differ diff --git a/assets/DFPver.png b/assets/DFPver.png new file mode 100644 index 0000000000..fae10c95f9 Binary files /dev/null and b/assets/DFPver.png differ diff --git a/assets/commissioningDevice.png b/assets/commissioningDevice.png new file mode 100644 index 0000000000..32dffddd4d Binary files /dev/null and b/assets/commissioningDevice.png differ diff --git a/assets/controlYellowLED.png b/assets/controlYellowLED.png new file mode 100644 index 0000000000..f68501857e Binary files /dev/null and b/assets/controlYellowLED.png differ diff --git a/assets/controllingDevice.png b/assets/controllingDevice.png new file mode 100644 index 0000000000..0843979bc3 Binary files /dev/null and b/assets/controllingDevice.png differ diff --git a/assets/dnm1.png b/assets/dnm1.png new file mode 100644 index 0000000000..cc9c2185a9 Binary files /dev/null and b/assets/dnm1.png differ diff --git a/assets/dnm10.png b/assets/dnm10.png new file mode 100644 index 0000000000..7552d6f801 Binary files /dev/null and b/assets/dnm10.png differ diff --git a/assets/dnm11.png b/assets/dnm11.png new file mode 100644 index 0000000000..59f0635081 Binary files /dev/null and b/assets/dnm11.png differ diff --git a/assets/dnm2.png b/assets/dnm2.png new file mode 100644 index 0000000000..96168b3d74 Binary files /dev/null and b/assets/dnm2.png differ diff --git a/assets/dnm3.png b/assets/dnm3.png new file mode 100644 index 0000000000..99792fcd65 Binary files /dev/null and b/assets/dnm3.png differ diff --git a/assets/dnm4.png b/assets/dnm4.png new file mode 100644 index 0000000000..a3489b3a10 Binary files /dev/null and b/assets/dnm4.png differ diff --git a/assets/dnm5.png b/assets/dnm5.png new file mode 100644 index 0000000000..f34659f1b8 Binary files /dev/null and b/assets/dnm5.png differ diff --git a/assets/dnm6.png b/assets/dnm6.png new file mode 100644 index 0000000000..42353a578c Binary files /dev/null and b/assets/dnm6.png differ diff --git a/assets/dnm7.png b/assets/dnm7.png new file mode 100644 index 0000000000..81a554fc30 Binary files /dev/null and b/assets/dnm7.png differ diff --git a/assets/dnm8.png b/assets/dnm8.png new file mode 100644 index 0000000000..dbac528f31 Binary files /dev/null and b/assets/dnm8.png differ diff --git a/assets/dnm9.png b/assets/dnm9.png new file mode 100644 index 0000000000..0d05548c32 Binary files /dev/null and b/assets/dnm9.png differ diff --git a/assets/flashOutput.png b/assets/flashOutput.png new file mode 100644 index 0000000000..d88f4c76c7 Binary files /dev/null and b/assets/flashOutput.png differ diff --git a/assets/iosWifiProvisioningApp.png b/assets/iosWifiProvisioningApp.png new file mode 100644 index 0000000000..a239987827 Binary files /dev/null and b/assets/iosWifiProvisioningApp.png differ diff --git a/assets/matterMicrochip.apk b/assets/matterMicrochip.apk new file mode 100644 index 0000000000..7851b589e0 Binary files /dev/null and b/assets/matterMicrochip.apk differ diff --git a/assets/matterSetup.png b/assets/matterSetup.png new file mode 100644 index 0000000000..ea1ce33799 Binary files /dev/null and b/assets/matterSetup.png differ diff --git a/assets/mergeStrategy.png b/assets/mergeStrategy.png new file mode 100644 index 0000000000..1b39f2e656 Binary files /dev/null and b/assets/mergeStrategy.png differ diff --git a/assets/microchip.png b/assets/microchip.png new file mode 100644 index 0000000000..9bdf56cd09 Binary files /dev/null and b/assets/microchip.png differ diff --git a/assets/mobile-icon.png b/assets/mobile-icon.png new file mode 100644 index 0000000000..63f0ba6bfe Binary files /dev/null and b/assets/mobile-icon.png differ diff --git a/assets/networkConnectBlueLED.png b/assets/networkConnectBlueLED.png new file mode 100644 index 0000000000..2b56f9a02c Binary files /dev/null and b/assets/networkConnectBlueLED.png differ diff --git a/assets/projectGraph.png b/assets/projectGraph.png new file mode 100644 index 0000000000..0b74f805fa Binary files /dev/null and b/assets/projectGraph.png differ diff --git a/assets/provisionMenuSelect.png b/assets/provisionMenuSelect.png new file mode 100644 index 0000000000..0c060456a8 Binary files /dev/null and b/assets/provisionMenuSelect.png differ diff --git a/assets/softAPButton.png b/assets/softAPButton.png new file mode 100644 index 0000000000..880e653c0b Binary files /dev/null and b/assets/softAPButton.png differ diff --git a/assets/templcode.png b/assets/templcode.png new file mode 100644 index 0000000000..e56df39af2 Binary files /dev/null and b/assets/templcode.png differ diff --git a/examples/lighting-app/mchp/pic32mzw1/README.md b/examples/lighting-app/mchp/pic32mzw1/README.md index b919d74ba5..f87a3015a7 100644 --- a/examples/lighting-app/mchp/pic32mzw1/README.md +++ b/examples/lighting-app/mchp/pic32mzw1/README.md @@ -177,7 +177,7 @@ Update default Wi-Fi Access Point (AP) credentials in "/PIC32MZW1_Matter_Project ## Wi-Fi Network Provisioning -To connect the WFI32-IoT board to the target AP: +If you want to connect the WFI32-IoT board to the target AP other than the default settings, you can perform below steps: #### Step 1: Short press the Switch 1 (SW1), the WFI32-IoT board will reboot and start in softAP mode. @@ -377,9 +377,10 @@ As per latest memory usage analysis, this example consumes 892KB Program Memory ## Example Limitations - Debug mode cannot be used with MPLAB X IDE on Microsoft Windows -- It takes long loading time to start debug mode with MPLAB X IDE on Ubuntu -- Wi-Fi provisioning details are hard-coaded for the phase-1 released version +- It takes long loading time to start debug mode with MPLAB X IDE - Requires MPLAB XC32 compiler's PRO license +- Example certificates provided in the matter's repo are used for device attestation, certificates are embedded in the program code. +- Not support with Google Home APP/ Google Assistant diff --git a/third_party/wfi32/firmware/matter_lighting_app_pic32mz_w1.X/.main-meta/main.json b/third_party/wfi32/firmware/matter_lighting_app_pic32mz_w1.X/.main-meta/main.json new file mode 100644 index 0000000000..ee7f380e6f --- /dev/null +++ b/third_party/wfi32/firmware/matter_lighting_app_pic32mz_w1.X/.main-meta/main.json @@ -0,0 +1,67 @@ +{ + "metaDataVersion": "1.0.0", + "category": "com.microchip.ide.project", + "content": { + "metaDataVersion": "1.3.0", + "name": "com.microchip.mcu32.mplabx.project.PIC32MZW1_Matter_Project", + "version": "3.6.1", + "displayName": "PIC32MZW1 with Matter protocol", + "projectName": "PIC32MZW1_Matter_Project", + "shortDescription": "This project include a Matter Lighting Example, which can be paired and controlled by Matter Commissioner devices ", + "ide": { + "name": "MPLABX", + "semverRange": ">=6.00" + }, + "compiler": [ + { + "name": "XC32", + "semverRange": ">=4.2.0" + } + ], + "dfp": { + "name": "PIC32MZ-W_DFP", + "semverRange": "^1.5.203" + }, + "configurator": { + "name": "MHC", + "semverRange": ">=3.8.2" + }, + "device": { + "metaDataVersion": "1.0.0", + "category": "com.microchip.portal.contentRef", + "content": { + "metaDataVersion": "1.0.0", + "category": "com.microchip.device", + "name": "PIC32MZ1025W104132", + "versionRange": "*" + } + }, + "author": "Microchip", + "peripherals": [ + "Wi-Fi" + ], + "keywords": [ + "MHC", + "Harmony", + "PIC32MZ1025W104132", + "WFI32", + "WFI32E01", + "PIC32MZ W1 Family", + "wireless", + "matter", + "iot" + + ], + "additionalData": { + "longDescription": { + "metaDataVersion": "1.0.0", + "category": "com.microchip.portal.fileRef", + "content": { + "metaDataVersion": "1.0.0", + "fileName": "./../../../../README.md", + "mimeType": "text/markdown" + } + } + } + } +} \ No newline at end of file