Files
esp-matter/examples/generic_switch
Shubham Patil 6dd7a44272 Fix building examples if placed outside the repo
Fixes https://github.com/espressif/esp-matter/issues/916

Build path using ESP_MATTER_PATH variable and not with
CMAKE_CURRENT_LIST_DIR.

If example is moved out from their current place then the compilation
breaks, becuase it tries to find the file wrt to current project
directory.
2024-05-06 11:57:56 +05:30
..

Generic Switch

This example creates a Generic Switch device using the ESP Matter data model. This example demonstrates the use of few optional data model elements like :

  • Fixed Label Cluster : provides a feature for the device to tag an endpoint with zero or more read only labels (demonstrated through nvs).
  • User Label Cluster : This cluster provides a feature to tag an endpoint with zero or more labels.
  • Taglist Feature of Descriptor Cluster : used to disambiguate sibling endpoints where two or more sibling endpoints have an overlap in the supported device types with each such endpoint having a unique TagList.

Note: In order to retrieve the label-list from the fixed-label cluster the two options: CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER and CONFIG_ENABLE_ESP32_DEVICE_INFO_PROVIDER have been set through sdkconfig.defaults.

See the docs for more information about building and flashing the firmware.

1. Additional Environment Setup

The steps below should be followed in order to access the fixed-labels.

  • If monitoring the device using idf.py monitor,press Ctrl + ] to stop the process.
  • The following command must be executed to flash the mfg partition:
esptool.py -p [port-name] write_flash 0x10000 mfg_binaries/20202020_3841.bin
  • Execute the command idf.py monitor

  • Commission the device with discriminator: 3841and passcode: 20202020

    chip-tool pairing ble-wifi 0x7283 [ssid] [password] 20202020 3841
    
  • Alternatively, below QR Code or Manual pairing code can be used for commissioning

    • Manualcode : 34970012334
    • QRCode :
    • QRCode
  • To read the fixed-labels, use chip-tool.

    chip-tool fixedlabel read label-list 0x7283 1
    

The example command given below should be executed to write to the label-list of User Label Cluster.

chip-tool userlabel write label-list '[{"label":"room", "value":"bedroom 1"}, {"label":"orientation", "value":"east"}]' 0x7283 1

To read label-list of User Label Cluster execute the command given below.

chip-tool userlabel read label-list 0x7283 1

Using the TagList Feature

To read the taglist of the Descriptor cluster execute the command given below.

chip-tool descriptor read tag-list 0x7283 0

2. Post Commissioning Setup

This should be followed by: Commission the generic switch device

  • Turn on chip-tool interactive mode. ./chip-tool interactive start
  • By default latching switch is enabled so subscribe to switch-latched event via chip-tool. switch subscribe-event switch-latched <min-interval> <max-interval> <destination-id> <endpoint-id>
  • Double press the boot button on device so that client will receive event after max-interval.

2.1 Latching switch

Following are latching switch events mapped with boot button on device.

  • Double Press -----------> switch-latched

2.2 Momentary switch

Following are momentary switch events mapped with boot button on device.

  • Button Press Down -----------> initial-pressed
  • Button Press Up ( Release ) -----------> short-release
  • Button Long Press ( 5 sec ) -----------> long-pressed
  • Button Press Up ( Long Release ) -----------> long-release
  • Button Press Repeat -----------> multipress-ongoing
  • Button Press Repeat Done -----------> multipress-completed

3. Device Performance

3.1 Memory usage

The following is the Memory and Flash Usage.

  • Bootup == Device just finished booting up. Device is not commissionined or connected to wifi yet.
  • After Commissioning == Device is conneted to wifi and is also commissioned and is rebooted.
  • device used: esp32c3_devkit_m
  • tested on: 4881109 (2022-12-15)
Bootup After Commissioning
Free Internal Memory 94KB 110KB

Flash Usage: Firmware binary size: 1.24MB

This should give you a good idea about the amount of free memory that is available for you to run your application's code.