diff --git a/.github/.wordlist.txt b/.github/.wordlist.txt index c811299aae330f..bef9dbb18a275f 100644 --- a/.github/.wordlist.txt +++ b/.github/.wordlist.txt @@ -27,6 +27,7 @@ adb AddOrUpdateThreadNetwork AddOrUpdateWiFiNetwork addr +AddThreadNetwork adk adoc AdvAutonomous @@ -252,6 +253,7 @@ customizations cvfJ cxx CY +CYW DAC DAP DataFrame @@ -357,6 +359,7 @@ elftools elock emberAfExternalAttributeReadCallback emberAfExternalAttributeWriteCallback +EnableNetwork EnableWiFiNetwork EndpointId endpointName @@ -416,6 +419,7 @@ fsl fstab fsync fullclean +gbl gcloud GDB GeneralCommissioning @@ -725,6 +729,7 @@ OTA OTADownloader OTAImageProcessorDriver OTAImageProcessorInterface +OTAProvider OTAProviderIpAddress OTAProviderNodeId OTAProviderSerialPort @@ -840,6 +845,7 @@ RendezVousTest repo req Requestor +Requestors responder retargeting reusability @@ -993,6 +999,7 @@ TLV tmp tngvndl TODO +tokenized toolchain toolchains topologies diff --git a/.github/workflows/examples-cyw30739.yaml b/.github/workflows/examples-cyw30739.yaml new file mode 100644 index 00000000000000..b9cc62b511f71a --- /dev/null +++ b/.github/workflows/examples-cyw30739.yaml @@ -0,0 +1,82 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Build example - Infineon CYW30739 + +on: + push: + pull_request: + +concurrency: + group: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }} + cancel-in-progress: true + +jobs: + cyw30739: + name: CYW30739 + timeout-minutes: 60 + + runs-on: ubuntu-latest + if: github.actor != 'restyled-io[bot]' + + container: + image: connectedhomeip/chip-build:latest + volumes: + - "/tmp/bloat_reports:/tmp/bloat_reports" + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: true + + - name: Set up environment for size reports + if: ${{ !env.ACT }} + env: + GH_CONTEXT: ${{ toJson(github) }} + run: scripts/tools/memory/gh_sizes_environment.py "${GH_CONTEXT}" + + - name: Bootstrap + timeout-minutes: 25 + run: scripts/build/gn_bootstrap.sh + - name: Uploading bootstrap logs + uses: actions/upload-artifact@v2 + if: ${{ always() }} && ${{ !env.ACT }} + with: + name: bootstrap-logs + path: | + .environment/gn_out/.ninja_log + .environment/pigweed-venv/*.log + - name: Build example CYW30739 Lighting App + timeout-minutes: 10 + run: | + ./scripts/run_in_build_env.sh \ + "./scripts/build/build_examples.py \ + --target cyw30739-cyw930739m2evb_01-light \ + build \ + --copy-artifacts-to out/artifacts \ + " + - name: Get light size stats + timeout-minutes: 5 + run: | + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + cyw30739 cyw930739m2evb_01 light \ + out/artifacts/cyw30739-cyw930739m2evb_01-light/chip-cyw30739-lighting-example.elf \ + /tmp/bloat_reports/ + - name: Uploading Size Reports + uses: actions/upload-artifact@v2 + if: ${{ !env.ACT }} + with: + name: Size,CYW30739-Examples,${{ env.GH_EVENT_PR }},${{ env.GH_EVENT_HASH }},${{ env.GH_EVENT_PARENT }},${{ github.event_name }} + path: | + /tmp/bloat_reports/ diff --git a/.gitmodules b/.gitmodules index b8f7b0832f3d99..6a548e76dcb3b4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -79,6 +79,10 @@ [submodule "third_party/openthread/ot-efr32"] path = third_party/openthread/ot-efr32 url = https://github.com/openthread/ot-efr32.git +[submodule "third_party/openthread/ot-ifx"] + path = third_party/openthread/ot-ifx + url = https://github.com/Infineon/ot-ifx-release.git + branch = cyw30739 [submodule "third_party/mbed-os/repo"] path = third_party/mbed-os/repo url = https://github.com/ARMmbed/mbed-os.git @@ -165,3 +169,15 @@ [submodule "third_party/jsoncpp/repo"] path = third_party/jsoncpp/repo url = https://github.com/open-source-parsers/jsoncpp.git +[submodule "cyw30739_sdk/30739A0"] + path = third_party/cyw30739_sdk/repos/30739A0 + url = https://github.com/Infineon/30739A0.git +[submodule "cyw30739_sdk/include"] + path = third_party/cyw30739_sdk/repos/btsdk-include + url = https://github.com/Infineon/btsdk-include.git +[submodule "cyw30739_sdk/target"] + path = third_party/cyw30739_sdk/repos/CYW930739M2EVB-01 + url = https://github.com/Infineon/TARGET_CYW930739M2EVB-01.git +[submodule "cyw30739_sdk/tools"] + path = third_party/cyw30739_sdk/repos/btsdk-tools + url = https://github.com/Infineon/btsdk-tools.git diff --git a/config/esp32/components/chip/component.mk b/config/esp32/components/chip/component.mk index 6b8714b1db620e..61ab9100fa78e7 100644 --- a/config/esp32/components/chip/component.mk +++ b/config/esp32/components/chip/component.mk @@ -136,6 +136,7 @@ ifeq ($(is_debug),false) endif if [[ "$(CONFIG_ENABLE_PW_RPC)" = "y" ]]; then \ echo "chip_build_pw_rpc_lib = true" >> $(OUTPUT_DIR)/args.gn ;\ + echo "chip_build_pw_trace_lib = true" >> $(OUTPUT_DIR)/args.gn ;\ echo "remove_default_configs = [\"//third_party/connectedhomeip/third_party/pigweed/repo/pw_build:cpp17\"]" >> $(OUTPUT_DIR)/args.gn ;\ echo "pw_log_BACKEND = \"//third_party/connectedhomeip/third_party/pigweed/repo/pw_log_basic\"" >> $(OUTPUT_DIR)/args.gn ;\ echo "pw_assert_BACKEND = \"//third_party/connectedhomeip/third_party/pigweed/repo/pw_assert_log\"" >> $(OUTPUT_DIR)/args.gn ;\ diff --git a/docs/guides/nrfconnect_examples_software_update.md b/docs/guides/nrfconnect_examples_software_update.md index 5b83ac0c9a4515..f15641670d20af 100644 --- a/docs/guides/nrfconnect_examples_software_update.md +++ b/docs/guides/nrfconnect_examples_software_update.md @@ -1,15 +1,86 @@ # Performing Device Firmware Upgrade in the nRF Connect examples Some examples for the development kits from Nordic Semiconductor support -over-the-air Device Firmware Upgrade. +over-the-air (OTA) Device Firmware Upgrade (DFU) using one of the following +protocols: -Currently, the Bluetooth LE is the only available transport for performing the -DFU operation and it uses nRF Connect SDK's -[Simple Management Protocol](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/device_mgmt/index.html#device-mgmt). -The upgrade can be done either using a smartphone application or a PC command -line tool. +- Matter-compliant OTA update protocol that uses the Matter operational + network for querying and downloading a new firmware image. +- [Simple Management Protocol](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/device_mgmt/index.html#device-mgmt) + over Bluetooth LE. In this case, the DFU can be done either using a + smartphone application or a PC command line tool. Note that this protocol is + not part of the Matter specification. -## Device Firmware Upgrade using smartphone +## Device Firmware Upgrade over Matter + +> **_NOTE:_** The procedure presented below requires that you have OpenThread +> Border Router (OTBR) set up either in Docker or on a Raspberry Pi. Read +> [Setup OpenThread Border Router on Raspberry Pi](openthread_border_router_pi.md) +> to learn how to install the OTBR on a Raspberry Pi. + +The DFU over Matter involves two kinds of nodes: OTA Provider and OTA Requestor. +An OTA Provider is a node that can respond to the OTA Requestors' queries about +available software updates and share the update packages with them. An OTA +Requestor is any node that needs to be updated and can communicate with the OTA +Provider to fetch applicable software updates. In the procedure described below, +the OTA Provider will be a Linux application and the example running on the +Nordic Semiconductor's board will work as the OTA Requestor. + +To test the DFU over Matter, you need to complete the following steps: + +1. Navigate to the CHIP root directory. +2. Build the OTA Provider application for Linux: + + $ scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/provider chip_config_network_layer_ble=false + +3. Build chip-tool for Linux: + + $ scripts/examples/gn_build_example.sh examples/chip-tool out/chiptool 'chip_mdns="platform"' + +4. Run OTA Provider application with _app_update.bin_ replaced with the path to + the new firmware image which you wish to provide to the Matter device: + + $ out/provider/chip-ota-provider-app -f app_update.bin + + Keep the application running and use another terminal for the remaining + steps. + +5. Commission the OTA Provider into the Matter network using Node Id 1: + + $ ./out/chiptool/chip-tool pairing onnetwork 1 20202021 + +6. Use the OTBR web interface to form a new Thread network using the default + network settings. +7. Commission the Matter device into the same Matter network using Node Id 2. + The parameter starting with the _hex:_ prefix is the Thread network's Active + Operational Dataset. It can be retrieved from the OTBR in case you have + changed the default network settings when forming the network. + + $ ./out/chiptool/chip-tool pairing ble-thread 2 hex:000300000f02081111111122222222051000112233445566778899aabbccddeeff01021234 20202021 3840 + +8. Initiate the DFU procedure in one of the following ways: + + - If you have built the device firmware with `-DCONFIG_CHIP_LIB_SHELL=y` + option, which enables Matter shell commands, run the following command + on the device shell. The numeric arguments are Fabric Index, Provider + Node Id and Provider Endpoint Id, respectively. + + $ matter ota query 1 1 0 + + - Otherwise, use chip-tool to send the Announce OTA Provider command to + the device. The numeric arguments are Provider Node Id, Provider Vendor + Id, Announcement Reason, Provider Endpoint Id, Requestor Node Id and + Requestor Endpoint Id, respectively. + + $ ./out/chiptool/chip-tool otasoftwareupdaterequestor announce-ota-provider 1 0 0 0 2 0 + + Once the device is made aware of the OTA Provider node, it automatically + queries the OTA Provider for a new firmware image. + +9. When the firmware image download is complete, reboot the device to apply the + update. + +## Device Firmware Upgrade over Bluetooth LE using smartphone To upgrade your device firmware over Bluetooth LE using smartphone, complete the following steps: @@ -30,7 +101,7 @@ following steps: [FOTA upgrades](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_nrf52.html#fota-upgrades) page in the nRF Connect SDK documentation. -## Device Firmware Upgrade using PC command line tool +## Device Firmware Upgrade over Bluetooth LE using PC command line tool To upgrade your device firmware over Bluetooth LE, you can use the PC command line tool provided by the [mcumgr](https://github.com/zephyrproject-rtos/mcumgr) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index 72d0a2fe9bc8c9..5260d539a4a5ed 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -2,8 +2,8 @@ // It is for view/code review purposes only. struct LabelStruct { - CHAR_STRING label = 0; - CHAR_STRING value = 1; + CHAR_STRING<16> label = 0; + CHAR_STRING<16> value = 1; } server cluster AccessControl = 31 { @@ -43,7 +43,7 @@ server cluster AccessControl = 31 { struct ExtensionEntry { fabric_idx fabricIndex = 0; - OCTET_STRING data = 1; + OCTET_STRING<254> data = 1; } info event AccessControlEntryChanged = 0 { @@ -115,12 +115,12 @@ server cluster ApplicationBasic = 1293 { kActiveVisibleNotFocus = 3; } - readonly attribute char_string vendorName = 0; + readonly attribute char_string<32> vendorName = 0; readonly attribute int16u vendorId = 1; - readonly attribute char_string applicationName = 2; + readonly attribute char_string<32> applicationName = 2; readonly attribute int16u productId = 3; readonly attribute ApplicationStatusEnum applicationStatus = 5; - readonly attribute char_string applicationVersion = 6; + readonly attribute char_string<32> applicationVersion = 6; readonly attribute vendor_id allowedVendorList[] = 7; readonly global attribute int16u clusterRevision = 65533; } @@ -154,7 +154,7 @@ server cluster AudioOutput = 1291 { struct OutputInfo { INT8U index = 0; OutputTypeEnum outputType = 1; - CHAR_STRING name = 2; + CHAR_STRING<32> name = 2; } readonly attribute OutputInfo audioOutputList[] = 0; @@ -193,24 +193,24 @@ server cluster Basic = 40 { } readonly attribute int16u interactionModelVersion = 0; - readonly attribute char_string vendorName = 1; + readonly attribute char_string<32> vendorName = 1; readonly attribute vendor_id vendorID = 2; - readonly attribute char_string productName = 3; + readonly attribute char_string<32> productName = 3; readonly attribute int16u productID = 4; - attribute char_string nodeLabel = 5; - attribute char_string location = 6; + attribute char_string<32> nodeLabel = 5; + attribute char_string<2> location = 6; readonly attribute int16u hardwareVersion = 7; - readonly attribute char_string hardwareVersionString = 8; + readonly attribute char_string<64> hardwareVersionString = 8; readonly attribute int32u softwareVersion = 9; - readonly attribute char_string softwareVersionString = 10; - readonly attribute char_string manufacturingDate = 11; - readonly attribute char_string partNumber = 12; - readonly attribute long_char_string productURL = 13; - readonly attribute char_string productLabel = 14; - readonly attribute char_string serialNumber = 15; + readonly attribute char_string<64> softwareVersionString = 10; + readonly attribute char_string<16> manufacturingDate = 11; + readonly attribute char_string<32> partNumber = 12; + readonly attribute long_char_string<256> productURL = 13; + readonly attribute char_string<64> productLabel = 14; + readonly attribute char_string<32> serialNumber = 15; attribute boolean localConfigDisabled = 16; readonly attribute boolean reachable = 17; - readonly attribute char_string uniqueID = 18; + readonly attribute char_string<32> uniqueID = 18; readonly global attribute int16u clusterRevision = 65533; command MfgSpecificPing(): DefaultSuccess = 0; @@ -284,7 +284,7 @@ server cluster BridgedActions = 37 { struct ActionStruct { INT16U actionID = 0; - CHAR_STRING name = 1; + CHAR_STRING<32> name = 1; ActionTypeEnum type = 2; INT16U endpointListID = 3; INT16U supportedCommands = 4; @@ -293,7 +293,7 @@ server cluster BridgedActions = 37 { struct EndpointListStruct { INT16U endpointListID = 0; - CHAR_STRING name = 1; + CHAR_STRING<32> name = 1; EndpointListTypeEnum type = 2; ENDPOINT_NO endpoints[] = 3; } @@ -313,7 +313,7 @@ server cluster BridgedActions = 37 { readonly attribute ActionStruct actionList[] = 0; readonly attribute EndpointListStruct endpointList[] = 1; - readonly attribute long_char_string setupUrl = 2; + readonly attribute long_char_string<512> setupUrl = 2; readonly global attribute int16u clusterRevision = 65533; } @@ -334,9 +334,9 @@ server cluster Channel = 1284 { struct ChannelInfo { INT16U majorNumber = 0; INT16U minorNumber = 1; - CHAR_STRING name = 2; - CHAR_STRING callSign = 3; - CHAR_STRING affiliateCallSign = 4; + CHAR_STRING<32> name = 2; + CHAR_STRING<32> callSign = 3; + CHAR_STRING<32> affiliateCallSign = 4; } readonly attribute ChannelInfo channelList[] = 0; @@ -396,7 +396,7 @@ server cluster ColorControl = 768 { readonly attribute int16u currentX = 3; readonly attribute int16u currentY = 4; readonly attribute enum8 driftCompensation = 5; - readonly attribute char_string compensationText = 6; + readonly attribute char_string<254> compensationText = 6; readonly attribute int16u colorTemperature = 7; readonly attribute enum8 colorMode = 8; attribute bitmap8 colorControlOptions = 15; @@ -976,7 +976,7 @@ server cluster DoorLock = 257 { readonly attribute int8u maxPINCodeLength = 23; readonly attribute int8u minPINCodeLength = 24; readonly attribute bitmap8 credentialRulesSupport = 27; - attribute char_string language = 33; + attribute char_string<3> language = 33; attribute int32u autoRelockTime = 35; attribute int8u soundVolume = 36; attribute DlOperatingMode operatingMode = 37; @@ -1233,11 +1233,11 @@ server cluster GeneralDiagnostics = 51 { } struct NetworkInterfaceType { - CHAR_STRING name = 0; + CHAR_STRING<32> name = 0; BOOLEAN fabricConnected = 1; BOOLEAN offPremiseServicesReachableIPv4 = 2; BOOLEAN offPremiseServicesReachableIPv6 = 3; - OCTET_STRING hardwareAddress = 4; + OCTET_STRING<8> hardwareAddress = 4; InterfaceType type = 5; } @@ -1287,17 +1287,17 @@ server cluster GroupKeyManagement = 63 { INT16U fabricIndex = 0; INT16U groupId = 1; INT16U endpoints[] = 2; - CHAR_STRING groupName = 3; + CHAR_STRING<16> groupName = 3; } struct GroupKeySet { INT16U groupKeySetID = 0; GroupKeySecurityPolicy securityPolicy = 1; - OCTET_STRING epochKey0 = 2; + OCTET_STRING<16> epochKey0 = 2; INT64U epochStartTime0 = 3; - OCTET_STRING epochKey1 = 4; + OCTET_STRING<16> epochKey1 = 4; INT64U epochStartTime1 = 5; - OCTET_STRING epochKey2 = 6; + OCTET_STRING<16> epochKey2 = 6; INT64U epochStartTime2 = 7; } @@ -1687,7 +1687,7 @@ server cluster LevelControl = 8 { } server cluster LocalizationConfiguration = 43 { - attribute char_string activeLocale = 1; + attribute char_string<35> activeLocale = 1; readonly attribute CHAR_STRING supportedLocales[] = 2; } @@ -1716,8 +1716,8 @@ server cluster MediaInput = 1287 { struct InputInfo { INT8U index = 0; InputTypeEnum inputType = 1; - CHAR_STRING name = 2; - CHAR_STRING description = 3; + CHAR_STRING<32> name = 2; + CHAR_STRING<32> description = 3; } readonly attribute InputInfo mediaInputList[] = 0; @@ -1753,7 +1753,7 @@ server cluster MediaPlayback = 1286 { server cluster ModeSelect = 80 { struct ModeOptionStruct { - CHAR_STRING label = 0; + CHAR_STRING<32> label = 0; INT8U mode = 1; INT32U semanticTag = 2; } @@ -1762,7 +1762,7 @@ server cluster ModeSelect = 80 { readonly attribute ModeOptionStruct supportedModes[] = 1; attribute int8u onMode = 2; readonly attribute int8u startUpMode = 3; - readonly attribute char_string description = 4; + readonly attribute char_string<32> description = 4; readonly global attribute int16u clusterRevision = 65533; request struct ChangeToModeRequest { @@ -1828,7 +1828,7 @@ server cluster NetworkCommissioning = 49 { readonly attribute int8u connectMaxTimeSeconds = 3; attribute boolean interfaceEnabled = 4; readonly attribute NetworkCommissioningStatus lastNetworkingStatus = 5; - readonly attribute octet_string lastNetworkID = 6; + readonly attribute octet_string<32> lastNetworkID = 6; readonly attribute int32u lastConnectErrorValue = 7; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; @@ -2092,11 +2092,11 @@ server cluster OperationalCredentials = 62 { struct FabricDescriptor { fabric_idx fabricIndex = 0; - OCTET_STRING rootPublicKey = 1; + OCTET_STRING<65> rootPublicKey = 1; INT16U vendorId = 2; FABRIC_ID fabricId = 3; NODE_ID nodeId = 4; - CHAR_STRING label = 5; + CHAR_STRING<32> label = 5; } readonly attribute NOCStruct NOCs[] = 0; @@ -2182,7 +2182,7 @@ server cluster OperationalCredentials = 62 { server cluster PowerSource = 47 { readonly attribute enum8 status = 0; readonly attribute int8u order = 1; - readonly attribute char_string description = 2; + readonly attribute char_string<60> description = 2; readonly attribute int32u batteryVoltage = 11; readonly attribute int8u batteryPercentRemaining = 12; readonly attribute int32u batteryTimeRemaining = 13; @@ -2412,7 +2412,7 @@ server cluster Scenes = 5 { server cluster SoftwareDiagnostics = 52 { struct ThreadMetrics { INT64U id = 0; - CHAR_STRING name = 1; + CHAR_STRING<8> name = 1; INT32U stackFreeCurrent = 2; INT32U stackFreeMinimum = 3; INT32U stackSize = 4; @@ -2479,7 +2479,7 @@ server cluster TargetNavigator = 1285 { struct TargetInfo { INT8U identifier = 0; - CHAR_STRING name = 1; + CHAR_STRING<32> name = 1; } readonly attribute TargetInfo targetNavigatorList[] = 0; @@ -2505,7 +2505,7 @@ server cluster TestCluster = 1295 { struct TestListStructOctet { INT64U fabricIndex = 0; - OCTET_STRING operationalCert = 1; + OCTET_STRING<32> operationalCert = 1; } struct NullablesAndOptionalsStruct { @@ -2584,13 +2584,13 @@ server cluster TestCluster = 1295 { attribute enum16 enum16 = 22; attribute single floatSingle = 23; attribute double floatDouble = 24; - attribute octet_string octetString = 25; + attribute octet_string<10> octetString = 25; attribute INT8U listInt8u[] = 26; attribute OCTET_STRING listOctetString[] = 27; attribute TestListStructOctet listStructOctetString[] = 28; - attribute long_octet_string longOctetString = 29; - attribute char_string charString = 30; - attribute long_char_string longCharString = 31; + attribute long_octet_string<1000> longOctetString = 29; + attribute char_string<10> charString = 30; + attribute long_char_string<1000> longCharString = 31; attribute epoch_us epochUs = 32; attribute epoch_s epochS = 33; attribute vendor_id vendorId = 34; @@ -2628,8 +2628,8 @@ server cluster TestCluster = 1295 { attribute enum16 nullableEnum16 = 32790; attribute single nullableFloatSingle = 32791; attribute double nullableFloatDouble = 32792; - attribute octet_string nullableOctetString = 32793; - attribute char_string nullableCharString = 32798; + attribute octet_string<10> nullableOctetString = 32793; + attribute char_string<10> nullableCharString = 32798; attribute SimpleEnum nullableEnumAttr = 32804; attribute SimpleStruct nullableStruct = 32805; attribute int8u nullableRangeRestrictedInt8u = 32806; @@ -2859,10 +2859,10 @@ server cluster ThreadNetworkDiagnostics = 53 { readonly attribute int16u channel = 0; readonly attribute enum8 routingRole = 1; - readonly attribute octet_string networkName = 2; + readonly attribute octet_string<16> networkName = 2; readonly attribute int16u panId = 3; readonly attribute int64u extendedPanId = 4; - readonly attribute octet_string meshLocalPrefix = 5; + readonly attribute octet_string<17> meshLocalPrefix = 5; readonly attribute int64u overrunCount = 6; readonly attribute NeighborTable neighborTableList[] = 7; readonly attribute RouteTable routeTableList[] = 8; @@ -2917,7 +2917,7 @@ server cluster ThreadNetworkDiagnostics = 53 { readonly attribute int64u pendingTimestamp = 57; readonly attribute int32u delay = 58; readonly attribute SecurityPolicy securityPolicy[] = 59; - readonly attribute octet_string channelMask = 60; + readonly attribute octet_string<4> channelMask = 60; readonly attribute OperationalDatasetComponents operationalDatasetComponents[] = 61; readonly attribute NetworkFault activeNetworkFaultsList[] = 62; readonly global attribute bitmap32 featureMap = 65532; @@ -2926,13 +2926,40 @@ server cluster ThreadNetworkDiagnostics = 53 { command ResetCounts(): DefaultSuccess = 0; } +server cluster TimeFormatLocalization = 44 { + enum CalendarType : ENUM8 { + kBuddhist = 0; + kChinese = 1; + kCoptic = 2; + kEthiopian = 3; + kGregorian = 4; + kHebrew = 5; + kIndian = 6; + kIslamic = 7; + kJapanese = 8; + kKorean = 9; + kPersian = 10; + kTaiwanese = 11; + } + + enum HourFormat : ENUM8 { + k12hr = 0; + k24hr = 1; + } + + attribute HourFormat hourFormat = 0; + attribute CalendarType activeCalendarType = 1; + readonly attribute CalendarType supportedCalendarTypes[] = 2; + readonly global attribute int16u clusterRevision = 65533; +} + server cluster UserLabel = 65 { attribute LabelStruct labelList[] = 0; readonly global attribute int16u clusterRevision = 65533; } server cluster WakeOnLan = 1283 { - readonly attribute char_string wakeOnLanMacAddress = 0; + readonly attribute char_string<32> wakeOnLanMacAddress = 0; readonly global attribute int16u clusterRevision = 65533; } @@ -2980,7 +3007,7 @@ server cluster WiFiNetworkDiagnostics = 54 { WiFiConnectionStatus connectionStatus = 0; } - readonly attribute octet_string bssid = 0; + readonly attribute octet_string<6> bssid = 0; readonly attribute enum8 securityType = 1; readonly attribute enum8 wiFiVersion = 2; readonly attribute int16u channelNumber = 3; @@ -3050,6 +3077,7 @@ endpoint 0 { server cluster RelativeHumidityMeasurement; server cluster SoftwareDiagnostics; server cluster ThreadNetworkDiagnostics; + server cluster TimeFormatLocalization; server cluster UserLabel; server cluster WiFiNetworkDiagnostics; } diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index 90ddac7d87f30d..fd43f52d3ae7bc 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -1677,6 +1677,87 @@ } ] }, + { + "name": "Time Format Localization", + "code": 44, + "mfgCode": null, + "define": "TIME_FORMAT_LOCALIZATION_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [] + }, + { + "name": "Time Format Localization", + "code": 44, + "mfgCode": null, + "define": "TIME_FORMAT_LOCALIZATION_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "HourFormat", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CalendarType", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SupportedCalendarTypes", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "Power Source Configuration", "code": 46, diff --git a/examples/all-clusters-app/esp32/README.md b/examples/all-clusters-app/esp32/README.md index 1f4ca1ca5a630e..cfb88c5606f70d 100644 --- a/examples/all-clusters-app/esp32/README.md +++ b/examples/all-clusters-app/esp32/README.md @@ -15,6 +15,7 @@ control. - [Flashing app using script](#flashing-app-using-script) - [Note](#note) - [Using the RPC console](#using-the-rpc-console) + - [Device Tracing](#device-tracing) --- @@ -295,3 +296,16 @@ From within the console you can then invoke rpcs: rpcs.chip.rpc.Lighting.Get() rpcs.chip.rpc.Lighting.Set(on=True, level=128, color=protos.chip.rpc.LightingColor(hue=5, saturation=5)) + +## Device Tracing + +Device tracing is available to analyze the device performance. To turn on +tracing, build with RPC enabled. See +[Using the RPC console](#using-the-rpc-console). + +Obtain tracing json file. + +``` + $ ./{PIGWEED_REPO}/pw_trace_tokenized/py/pw_trace_tokenized/get_trace.py -d {PORT} -o {OUTPUT_FILE} \ + -t {ELF_FILE} {PIGWEED_REPO}/pw_trace_tokenized/pw_trace_protos/trace_rpc.proto +``` diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt index ae22ec44a75888..c0dbe295703c12 100644 --- a/examples/all-clusters-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt @@ -78,6 +78,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ias-zone-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ethernet-network-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/localization-configuration-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/time-format-localization-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/wifi-network-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/wake-on-lan-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/pump-configuration-and-control-server" diff --git a/examples/all-clusters-app/mbed/CMakeLists.txt b/examples/all-clusters-app/mbed/CMakeLists.txt index bbb871d89943ad..84788b823e143f 100644 --- a/examples/all-clusters-app/mbed/CMakeLists.txt +++ b/examples/all-clusters-app/mbed/CMakeLists.txt @@ -109,6 +109,7 @@ target_sources(${APP_TARGET} PRIVATE ${APP_CLUSTERS}/level-control/level-control.cpp ${APP_CLUSTERS}/low-power-server/low-power-server.cpp ${APP_CLUSTERS}/localization-configuration-server/localization-configuration-server.cpp + ${APP_CLUSTERS}/time-format-localization-server/time-format-localization-server.cpp ${APP_CLUSTERS}/media-input-server/media-input-server.cpp ${APP_CLUSTERS}/media-playback-server/media-playback-server.cpp ${APP_CLUSTERS}/mode-select-server/mode-select-server.cpp diff --git a/examples/bridge-app/bridge-common/bridge-app.matter b/examples/bridge-app/bridge-common/bridge-app.matter index f8504f25addfa8..49b12c8ffb070a 100644 --- a/examples/bridge-app/bridge-common/bridge-app.matter +++ b/examples/bridge-app/bridge-common/bridge-app.matter @@ -2,8 +2,8 @@ // It is for view/code review purposes only. struct LabelStruct { - CHAR_STRING label = 0; - CHAR_STRING value = 1; + CHAR_STRING<16> label = 0; + CHAR_STRING<16> value = 1; } server cluster AdministratorCommissioning = 60 { @@ -58,16 +58,16 @@ server cluster Basic = 40 { } readonly attribute int16u interactionModelVersion = 0; - readonly attribute char_string vendorName = 1; + readonly attribute char_string<32> vendorName = 1; readonly attribute vendor_id vendorID = 2; - readonly attribute char_string productName = 3; + readonly attribute char_string<32> productName = 3; readonly attribute int16u productID = 4; - attribute char_string nodeLabel = 5; - attribute char_string location = 6; + attribute char_string<32> nodeLabel = 5; + attribute char_string<2> location = 6; readonly attribute int16u hardwareVersion = 7; - readonly attribute char_string hardwareVersionString = 8; + readonly attribute char_string<64> hardwareVersionString = 8; readonly attribute int32u softwareVersion = 9; - readonly attribute char_string softwareVersionString = 10; + readonly attribute char_string<64> softwareVersionString = 10; readonly global attribute int16u clusterRevision = 65533; } @@ -255,11 +255,11 @@ server cluster GeneralDiagnostics = 51 { } struct NetworkInterfaceType { - CHAR_STRING name = 0; + CHAR_STRING<32> name = 0; BOOLEAN fabricConnected = 1; BOOLEAN offPremiseServicesReachableIPv4 = 2; BOOLEAN offPremiseServicesReachableIPv6 = 3; - OCTET_STRING hardwareAddress = 4; + OCTET_STRING<8> hardwareAddress = 4; InterfaceType type = 5; } @@ -375,7 +375,7 @@ server cluster LevelControl = 8 { } server cluster LocalizationConfiguration = 43 { - attribute char_string activeLocale = 1; + attribute char_string<35> activeLocale = 1; readonly attribute CHAR_STRING supportedLocales[] = 2; } @@ -435,7 +435,7 @@ server cluster NetworkCommissioning = 49 { readonly attribute int8u connectMaxTimeSeconds = 3; attribute boolean interfaceEnabled = 4; readonly attribute NetworkCommissioningStatus lastNetworkingStatus = 5; - readonly attribute octet_string lastNetworkID = 6; + readonly attribute octet_string<32> lastNetworkID = 6; readonly attribute int32u lastConnectErrorValue = 7; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; @@ -544,11 +544,11 @@ server cluster OperationalCredentials = 62 { struct FabricDescriptor { fabric_idx fabricIndex = 0; - OCTET_STRING rootPublicKey = 1; + OCTET_STRING<65> rootPublicKey = 1; INT16U vendorId = 2; FABRIC_ID fabricId = 3; NODE_ID nodeId = 4; - CHAR_STRING label = 5; + CHAR_STRING<32> label = 5; } readonly attribute NOCStruct NOCs[] = 0; @@ -634,7 +634,7 @@ server cluster OperationalCredentials = 62 { server cluster SoftwareDiagnostics = 52 { struct ThreadMetrics { INT64U id = 0; - CHAR_STRING name = 1; + CHAR_STRING<8> name = 1; INT32U stackFreeCurrent = 2; INT32U stackFreeMinimum = 3; INT32U stackSize = 4; @@ -769,10 +769,10 @@ server cluster ThreadNetworkDiagnostics = 53 { readonly attribute int16u channel = 0; readonly attribute enum8 routingRole = 1; - readonly attribute octet_string networkName = 2; + readonly attribute octet_string<16> networkName = 2; readonly attribute int16u panId = 3; readonly attribute int64u extendedPanId = 4; - readonly attribute octet_string meshLocalPrefix = 5; + readonly attribute octet_string<17> meshLocalPrefix = 5; readonly attribute int64u overrunCount = 6; readonly attribute NeighborTable neighborTableList[] = 7; readonly attribute RouteTable routeTableList[] = 8; @@ -827,13 +827,40 @@ server cluster ThreadNetworkDiagnostics = 53 { readonly attribute int64u pendingTimestamp = 57; readonly attribute int32u delay = 58; readonly attribute SecurityPolicy securityPolicy[] = 59; - readonly attribute octet_string channelMask = 60; + readonly attribute octet_string<4> channelMask = 60; readonly attribute OperationalDatasetComponents operationalDatasetComponents[] = 61; readonly attribute NetworkFault activeNetworkFaultsList[] = 62; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; } +server cluster TimeFormatLocalization = 44 { + enum CalendarType : ENUM8 { + kBuddhist = 0; + kChinese = 1; + kCoptic = 2; + kEthiopian = 3; + kGregorian = 4; + kHebrew = 5; + kIndian = 6; + kIslamic = 7; + kJapanese = 8; + kKorean = 9; + kPersian = 10; + kTaiwanese = 11; + } + + enum HourFormat : ENUM8 { + k12hr = 0; + k24hr = 1; + } + + attribute HourFormat hourFormat = 0; + attribute CalendarType activeCalendarType = 1; + readonly attribute CalendarType supportedCalendarTypes[] = 2; + readonly global attribute int16u clusterRevision = 65533; +} + server cluster UserLabel = 65 { attribute LabelStruct labelList[] = 0; readonly global attribute int16u clusterRevision = 65533; @@ -883,7 +910,7 @@ server cluster WiFiNetworkDiagnostics = 54 { WiFiConnectionStatus connectionStatus = 0; } - readonly attribute octet_string bssid = 0; + readonly attribute octet_string<6> bssid = 0; readonly attribute enum8 securityType = 1; readonly attribute enum8 wiFiVersion = 2; readonly attribute int16u channelNumber = 3; @@ -915,6 +942,7 @@ endpoint 0 { server cluster OperationalCredentials; server cluster SoftwareDiagnostics; server cluster ThreadNetworkDiagnostics; + server cluster TimeFormatLocalization; server cluster UserLabel; server cluster WiFiNetworkDiagnostics; } diff --git a/examples/bridge-app/bridge-common/bridge-app.zap b/examples/bridge-app/bridge-common/bridge-app.zap index ceab47a82bb9be..cf1316d0f120c9 100644 --- a/examples/bridge-app/bridge-common/bridge-app.zap +++ b/examples/bridge-app/bridge-common/bridge-app.zap @@ -416,6 +416,87 @@ } ] }, + { + "name": "Time Format Localization", + "code": 44, + "mfgCode": null, + "define": "TIME_FORMAT_LOCALIZATION_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [] + }, + { + "name": "Time Format Localization", + "code": 44, + "mfgCode": null, + "define": "TIME_FORMAT_LOCALIZATION_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "HourFormat", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CalendarType", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SupportedCalendarTypes", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "General Commissioning", "code": 48, diff --git a/examples/bridge-app/esp32/main/CMakeLists.txt b/examples/bridge-app/esp32/main/CMakeLists.txt index 697feecf78abb7..d90f98cbed9614 100644 --- a/examples/bridge-app/esp32/main/CMakeLists.txt +++ b/examples/bridge-app/esp32/main/CMakeLists.txt @@ -30,7 +30,8 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/level-control" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/diagnostic-logs-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ethernet-network-diagnostics-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/localization-configuration-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/localization-configuration-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/time-format-localization-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/fixed-label-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/user-label-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread-network-diagnostics-server" diff --git a/examples/build_overrides/cyw30739_sdk.gni b/examples/build_overrides/cyw30739_sdk.gni new file mode 100644 index 00000000000000..d2c81de46ba614 --- /dev/null +++ b/examples/build_overrides/cyw30739_sdk.gni @@ -0,0 +1,19 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Root directory for CYW30739 SDK. + cyw30739_sdk_build_root = + "//third_party/connectedhomeip/third_party/cyw30739_sdk" +} diff --git a/examples/door-lock-app/door-lock-common/door-lock-app.matter b/examples/door-lock-app/door-lock-common/door-lock-app.matter index 2dbd6bc86aa468..d362df558d298e 100644 --- a/examples/door-lock-app/door-lock-common/door-lock-app.matter +++ b/examples/door-lock-app/door-lock-common/door-lock-app.matter @@ -2,8 +2,8 @@ // It is for view/code review purposes only. struct LabelStruct { - CHAR_STRING label = 0; - CHAR_STRING value = 1; + CHAR_STRING<16> label = 0; + CHAR_STRING<16> value = 1; } server cluster AdministratorCommissioning = 60 { @@ -58,16 +58,16 @@ server cluster Basic = 40 { } readonly attribute int16u interactionModelVersion = 0; - readonly attribute char_string vendorName = 1; + readonly attribute char_string<32> vendorName = 1; readonly attribute vendor_id vendorID = 2; - readonly attribute char_string productName = 3; + readonly attribute char_string<32> productName = 3; readonly attribute int16u productID = 4; - attribute char_string nodeLabel = 5; - attribute char_string location = 6; + attribute char_string<32> nodeLabel = 5; + attribute char_string<2> location = 6; readonly attribute int16u hardwareVersion = 7; - readonly attribute char_string hardwareVersionString = 8; + readonly attribute char_string<64> hardwareVersionString = 8; readonly attribute int32u softwareVersion = 9; - readonly attribute char_string softwareVersionString = 10; + readonly attribute char_string<64> softwareVersionString = 10; readonly global attribute int16u clusterRevision = 65533; } @@ -359,7 +359,7 @@ server cluster DoorLock = 257 { readonly attribute int8u maxPINCodeLength = 23; readonly attribute int8u minPINCodeLength = 24; readonly attribute bitmap8 credentialRulesSupport = 27; - attribute char_string language = 33; + attribute char_string<3> language = 33; attribute int32u autoRelockTime = 35; attribute int8u soundVolume = 36; attribute DlOperatingMode operatingMode = 37; @@ -588,11 +588,11 @@ server cluster GeneralDiagnostics = 51 { } struct NetworkInterfaceType { - CHAR_STRING name = 0; + CHAR_STRING<32> name = 0; BOOLEAN fabricConnected = 1; BOOLEAN offPremiseServicesReachableIPv4 = 2; BOOLEAN offPremiseServicesReachableIPv6 = 3; - OCTET_STRING hardwareAddress = 4; + OCTET_STRING<8> hardwareAddress = 4; InterfaceType type = 5; } @@ -627,7 +627,7 @@ server cluster GeneralDiagnostics = 51 { } server cluster LocalizationConfiguration = 43 { - attribute char_string activeLocale = 1; + attribute char_string<35> activeLocale = 1; readonly attribute CHAR_STRING supportedLocales[] = 2; } @@ -687,7 +687,7 @@ server cluster NetworkCommissioning = 49 { readonly attribute int8u connectMaxTimeSeconds = 3; attribute boolean interfaceEnabled = 4; readonly attribute NetworkCommissioningStatus lastNetworkingStatus = 5; - readonly attribute octet_string lastNetworkID = 6; + readonly attribute octet_string<32> lastNetworkID = 6; readonly attribute int32u lastConnectErrorValue = 7; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; @@ -772,11 +772,11 @@ server cluster OperationalCredentials = 62 { struct FabricDescriptor { fabric_idx fabricIndex = 0; - OCTET_STRING rootPublicKey = 1; + OCTET_STRING<65> rootPublicKey = 1; INT16U vendorId = 2; FABRIC_ID fabricId = 3; NODE_ID nodeId = 4; - CHAR_STRING label = 5; + CHAR_STRING<32> label = 5; } readonly attribute NOCStruct NOCs[] = 0; @@ -862,12 +862,12 @@ server cluster OperationalCredentials = 62 { server cluster PowerSource = 47 { readonly attribute enum8 status = 0; readonly attribute int8u order = 1; - readonly attribute char_string description = 2; + readonly attribute char_string<60> description = 2; readonly attribute int32u wiredAssessedCurrent = 6; readonly attribute enum8 batteryChargeLevel = 14; readonly attribute boolean batteryReplacementNeeded = 15; readonly attribute enum8 batteryReplaceability = 16; - readonly attribute char_string batteryReplacementDescription = 19; + readonly attribute char_string<60> batteryReplacementDescription = 19; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; } @@ -880,7 +880,7 @@ server cluster PowerSourceConfiguration = 46 { server cluster SoftwareDiagnostics = 52 { struct ThreadMetrics { INT64U id = 0; - CHAR_STRING name = 1; + CHAR_STRING<8> name = 1; INT32U stackFreeCurrent = 2; INT32U stackFreeMinimum = 3; INT32U stackSize = 4; @@ -977,10 +977,10 @@ server cluster ThreadNetworkDiagnostics = 53 { readonly attribute int16u channel = 0; readonly attribute enum8 routingRole = 1; - readonly attribute octet_string networkName = 2; + readonly attribute octet_string<16> networkName = 2; readonly attribute int16u panId = 3; readonly attribute int64u extendedPanId = 4; - readonly attribute octet_string meshLocalPrefix = 5; + readonly attribute octet_string<17> meshLocalPrefix = 5; readonly attribute int64u overrunCount = 6; readonly attribute NeighborTable neighborTableList[] = 7; readonly attribute RouteTable routeTableList[] = 8; @@ -1035,13 +1035,40 @@ server cluster ThreadNetworkDiagnostics = 53 { readonly attribute int64u pendingTimestamp = 57; readonly attribute int32u delay = 58; readonly attribute SecurityPolicy securityPolicy[] = 59; - readonly attribute octet_string channelMask = 60; + readonly attribute octet_string<4> channelMask = 60; readonly attribute OperationalDatasetComponents operationalDatasetComponents[] = 61; readonly attribute NetworkFault activeNetworkFaultsList[] = 62; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; } +server cluster TimeFormatLocalization = 44 { + enum CalendarType : ENUM8 { + kBuddhist = 0; + kChinese = 1; + kCoptic = 2; + kEthiopian = 3; + kGregorian = 4; + kHebrew = 5; + kIndian = 6; + kIslamic = 7; + kJapanese = 8; + kKorean = 9; + kPersian = 10; + kTaiwanese = 11; + } + + enum HourFormat : ENUM8 { + k12hr = 0; + k24hr = 1; + } + + attribute HourFormat hourFormat = 0; + attribute CalendarType activeCalendarType = 1; + readonly attribute CalendarType supportedCalendarTypes[] = 2; + readonly global attribute int16u clusterRevision = 65533; +} + server cluster UserLabel = 65 { attribute LabelStruct labelList[] = 0; readonly global attribute int16u clusterRevision = 65533; @@ -1091,7 +1118,7 @@ server cluster WiFiNetworkDiagnostics = 54 { WiFiConnectionStatus connectionStatus = 0; } - readonly attribute octet_string bssid = 0; + readonly attribute octet_string<6> bssid = 0; readonly attribute enum8 securityType = 1; readonly attribute enum8 wiFiVersion = 2; readonly attribute int16u channelNumber = 3; @@ -1125,6 +1152,7 @@ endpoint 0 { server cluster PowerSourceConfiguration; server cluster SoftwareDiagnostics; server cluster ThreadNetworkDiagnostics; + server cluster TimeFormatLocalization; server cluster UserLabel; server cluster WiFiNetworkDiagnostics; } diff --git a/examples/door-lock-app/door-lock-common/door-lock-app.zap b/examples/door-lock-app/door-lock-common/door-lock-app.zap index 1a7e40362e00b4..3338d0eb73acbe 100644 --- a/examples/door-lock-app/door-lock-common/door-lock-app.zap +++ b/examples/door-lock-app/door-lock-common/door-lock-app.zap @@ -1210,6 +1210,87 @@ } ] }, + { + "name": "Time Format Localization", + "code": 44, + "mfgCode": null, + "define": "TIME_FORMAT_LOCALIZATION_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [] + }, + { + "name": "Time Format Localization", + "code": 44, + "mfgCode": null, + "define": "TIME_FORMAT_LOCALIZATION_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "HourFormat", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CalendarType", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SupportedCalendarTypes", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "Power Source Configuration", "code": 46, diff --git a/examples/lighting-app/cyw30739/.gn b/examples/lighting-app/cyw30739/.gn new file mode 100644 index 00000000000000..90115e4209947e --- /dev/null +++ b/examples/lighting-app/cyw30739/.gn @@ -0,0 +1,28 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/build.gni") + +# The location of the build configuration file. +buildconfig = "${build_root}/config/BUILDCONFIG.gn" + +# CHIP uses angle bracket includes. +check_system_includes = true + +default_args = { + target_cpu = "arm" + target_os = "cyw30739" + + import("//args.gni") +} diff --git a/examples/lighting-app/cyw30739/BUILD.gn b/examples/lighting-app/cyw30739/BUILD.gn new file mode 100644 index 00000000000000..8912b0594c2c76 --- /dev/null +++ b/examples/lighting-app/cyw30739/BUILD.gn @@ -0,0 +1,68 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/build.gni") +import("//build_overrides/chip.gni") +import("//build_overrides/cyw30739_sdk.gni") + +import("${cyw30739_sdk_build_root}/cyw30739_executable.gni") +import("${cyw30739_sdk_build_root}/cyw30739_sdk.gni") + +cyw30739_project_dir = "${chip_root}/examples/lighting-app/cyw30739" + +declare_args() { + setupPinCode = 0 + setupDiscriminator = 0 +} + +cyw30739_sdk("sdk") { + sources = [ "${cyw30739_project_dir}/include/CHIPProjectConfig.h" ] + + include_dirs = [ "${cyw30739_project_dir}/include" ] + + defines = [ + "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}", + "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}", + ] +} + +cyw30739_executable("lighting_app") { + output_name = "chip-cyw30739-lighting-example.elf" + + sources = [ + "src/AppShellCommands.cpp", + "src/ButtonHandler.cpp", + "src/LightingManager.cpp", + "src/ZclCallbacks.cpp", + "src/main.cpp", + ] + + deps = [ + ":sdk", + "${chip_root}/examples/lighting-app/lighting-common", + "${chip_root}/examples/shell/shell_common:shell_common", + "${chip_root}/src/lib", + "${chip_root}/third_party/openthread/repo:libopenthread-ftd", + ] + + include_dirs = [ "include" ] +} + +group("cyw30739") { + deps = [ ":lighting_app" ] +} + +group("default") { + deps = [ ":cyw30739" ] +} diff --git a/examples/lighting-app/cyw30739/README.md b/examples/lighting-app/cyw30739/README.md new file mode 100644 index 00000000000000..3d333ee204a75c --- /dev/null +++ b/examples/lighting-app/cyw30739/README.md @@ -0,0 +1,104 @@ +# Matter CYW30739 Lighting Example + +An example showing the use of Matter on the Infineon CYW30739 platform. + +--- + +## Table of Contents + +- [CHIP CYW30739 Lighting Example](#matter-cyw30739-lighting-example) + - [Introduction](#introduction) + - [Building](#building) + - [Flashing the Application](#flashing-the-application) + - [Running the Complete Example](#running-the-complete-example) + +--- + +## Introduction + +The CYW30739 lighting example provides a baseline demonstration of a Light +control device, built using Matter and the Infineon Modustoolbox SDK. It can be +controlled by a Matter controller over Openthread network. + +The CYW30739 device can be commissioned over Bluetooth Low Energy where the +device and the Matter controller will exchange security information with the +Rendez-vous procedure. Thread Network credentials are then provided to the +CYW30739 device which will then join the network. + +## Building + +- Build the example application: + + ```bash + $ cd ~/connectedhomeip + $ git submodule update --init + $ ./scripts/examples/gn_build_example.sh examples/lighting-app/cyw30739 out/lighting-app + ``` + +- To delete generated executable, libraries and object files use: + + ```bash + $ cd ~/connectedhomeip + $ rm -rf ./out/ + ``` + +- OR use GN/Ninja directly + + ```bash + $ cd ~/connectedhomeip/examples/lighting-app/cyw30739 + $ git submodule update --init + $ source third_party/connectedhomeip/scripts/activate.sh + $ gn gen out/debug + $ ninja -C out/debug + ``` + +- To delete generated executable, libraries and object files use: + + ```bash + $ cd ~/connectedhomeip/examples/lighting-app/cyw30739 + $ rm -rf out/ + ``` + +## Flashing the Application + +### Enter Recovery Mode + +Put the CYW30739 in to the recovery mode before running the flash script. + +1. Press and hold the `RECOVERY` button on the board. +2. Press and hold the `RESET` button on the board. +3. Release the `RESET` button. +4. After one second, release the `RECOVERY` button. + +### Run Flash Script + +- On the command line: + + ```bash + $ cd ~/connectedhomeip/examples/lighting-app/cyw30739 + $ python3 out/debug/chip-cyw30739-lighting-example.flash.py + ``` + +## Running the Complete Example + +- It is assumed here that you already have an OpenThread border router + configured and running. If not see the following guide + [Openthread_border_router](https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/openthread_border_router_pi.md) + for more information on how to setup a border router on a raspberryPi. + +- You can provision and control the Chip device using the python controller, + Chip tool standalone, Android or iOS app + + [Python Controller](https://github.com/project-chip/connectedhomeip/blob/master/src/controller/python/README.md) + + Here is an example with the Python controller: + + ```bash + $ chip-device-ctrl + chip-device-ctrl > connect -ble 3840 20202021 1234 + chip-device-ctrl > zcl NetworkCommissioning AddThreadNetwork 1234 0 0 operationalDataset=hex:0e080000000000000000000300000b35060004001fffe00208dead00beef00cafe0708fddead00beef000005108e11d8ea8ffaa875713699f59e8807e0030a4f70656e5468726561640102c2980410edc641eb63b100b87e90a9980959befc0c0402a0fff8 breadcrumb=0 timeoutMs=1000 + chip-device-ctrl > zcl NetworkCommissioning EnableNetwork 1234 0 0 networkID=hex:dead00beef00cafe breadcrumb=0 timeoutMs=1000 + chip-device-ctrl > close-ble + chip-device-ctrl > resolve 1234 + chip-device-ctrl > zcl OnOff Toggle 1234 1 0 + ``` diff --git a/examples/lighting-app/cyw30739/args.gni b/examples/lighting-app/cyw30739/args.gni new file mode 100644 index 00000000000000..149f7d42b18b5f --- /dev/null +++ b/examples/lighting-app/cyw30739/args.gni @@ -0,0 +1,18 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") +import("${chip_root}/src/platform/CYW30739/args.gni") + +cyw30739_sdk_target = get_label_info(":sdk", "label_no_toolchain") diff --git a/examples/lighting-app/cyw30739/build_overrides b/examples/lighting-app/cyw30739/build_overrides new file mode 120000 index 00000000000000..e578e73312ebd1 --- /dev/null +++ b/examples/lighting-app/cyw30739/build_overrides @@ -0,0 +1 @@ +../../build_overrides \ No newline at end of file diff --git a/examples/lighting-app/cyw30739/include/AppShellCommands.h b/examples/lighting-app/cyw30739/include/AppShellCommands.h new file mode 100644 index 00000000000000..575d6c24a3e2d0 --- /dev/null +++ b/examples/lighting-app/cyw30739/include/AppShellCommands.h @@ -0,0 +1,22 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2019 Google LLC. + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +void RegisterAppShellCommands(); diff --git a/examples/lighting-app/cyw30739/include/ButtonHandler.h b/examples/lighting-app/cyw30739/include/ButtonHandler.h new file mode 100644 index 00000000000000..8fbe5ab214c68f --- /dev/null +++ b/examples/lighting-app/cyw30739/include/ButtonHandler.h @@ -0,0 +1,28 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2019 Google LLC. + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "wiced.h" + +typedef enum +{ + ON_OFF_BUTTON, + APP_MAX_BUTTON, +} application_button_t; +#define APP_MAX_BUTTON_DEF 1 // define for preprocessor + +wiced_result_t app_button_init(void); diff --git a/examples/lighting-app/cyw30739/include/CHIPProjectConfig.h b/examples/lighting-app/cyw30739/include/CHIPProjectConfig.h new file mode 100644 index 00000000000000..f9a91d3f03b70f --- /dev/null +++ b/examples/lighting-app/cyw30739/include/CHIPProjectConfig.h @@ -0,0 +1,61 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2019 Google LLC. + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * Example project configuration file for CHIP. + * + * This is a place to put application or project-specific overrides + * to the default configuration values for general CHIP features. + * + */ + +#pragma once + +// -------------------- Device Identification Configuration -------------------- + +/* The VendorName attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME "Infineon" + +/* The VendorID attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0x0009 + +/* The ProductName attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME "CYW30739 Lighting App" + +/* The ProductID attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x154c + +/* The HardwareVersionString attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING "30739" + +/* The HardwareVersion attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION 30739 + +/* The SoftwareVersionString attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "TE7.5" + +/* The SoftwareVersion attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0705 + +/* The SerialNumber attribute of the Basic cluster. */ +#define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER "TEST_SN" + +// -------------------- Test Configuration -------------------- +#define CHIP_DEVICE_CONFIG_ENABLE_TEST_DEVICE_IDENTITY 1 diff --git a/examples/lighting-app/cyw30739/include/LightingManager.h b/examples/lighting-app/cyw30739/include/LightingManager.h new file mode 100644 index 00000000000000..0ce5b5c4073bfa --- /dev/null +++ b/examples/lighting-app/cyw30739/include/LightingManager.h @@ -0,0 +1,75 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2019 Google LLC. + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +#include + +class LightingManager +{ +public: + enum Action_t + { + ON_ACTION = 0, + OFF_ACTION, + LEVEL_ACTION, + + INVALID_ACTION + } Action; + + enum State_t + { + kState_OffInitiated = 0, + kState_OffCompleted, + kState_OnInitiated, + kState_OnCompleted, + } State; + + enum Actor_t + { + ACTOR_ZCL_CMD = 0, + ACTOR_APP_CMD, + ACTOR_BUTTON, + } Actor; + + CHIP_ERROR Init(); + bool IsLightOn(); + bool IsActionInProgress(); + bool InitiateAction(Actor_t aActor, Action_t aAction, uint8_t vallue); + + typedef void (*Callback_fn_initiated)(Actor_t, Action_t, uint8_t); + typedef void (*Callback_fn_completed)(Action_t); + void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); + +private: + void WriteClusterState(uint8_t value); + void WriteClusterLevel(uint8_t value); + + friend LightingManager & LightMgr(void); + State_t mState; + + Callback_fn_initiated mActionInitiated_CB; + Callback_fn_completed mActionCompleted_CB; + + static LightingManager sLight; +}; + +inline LightingManager & LightMgr(void) +{ + return LightingManager::sLight; +} diff --git a/examples/lighting-app/cyw30739/src/AppShellCommands.cpp b/examples/lighting-app/cyw30739/src/AppShellCommands.cpp new file mode 100644 index 00000000000000..84f7b74adefc94 --- /dev/null +++ b/examples/lighting-app/cyw30739/src/AppShellCommands.cpp @@ -0,0 +1,103 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2019 Google LLC. + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "LightingManager.h" +#include +#include + +using namespace chip::Shell; + +static CHIP_ERROR AppCommandHelpHandler(int argc, char * argv[]); +static CHIP_ERROR AppCommandLightingHandler(int argc, char * argv[]); +static CHIP_ERROR AppCommandDispatch(int argc, char * argv[]); + +static chip::Shell::Engine sAppSubcommands; + +void RegisterAppShellCommands(void) +{ + static const shell_command_t sAppSubCommands[] = { + { + .cmd_func = AppCommandHelpHandler, + .cmd_name = "help", + .cmd_help = "Usage: app ", + }, + { + .cmd_func = AppCommandLightingHandler, + .cmd_name = "light", + .cmd_help = "Usage: app light [on|off|toggle]", + }, + }; + + static const shell_command_t sAppCommand = { + .cmd_func = AppCommandDispatch, + .cmd_name = "app", + .cmd_help = "App commands", + }; + + sAppSubcommands.RegisterCommands(sAppSubCommands, ArraySize(sAppSubCommands)); + + Engine::Root().RegisterCommands(&sAppCommand, 1); +} + +CHIP_ERROR AppCommandHelpHandler(int argc, char * argv[]) +{ + sAppSubcommands.ForEachCommand(PrintCommandHelp, nullptr); + return CHIP_NO_ERROR; +} + +CHIP_ERROR AppCommandLightingHandler(int argc, char * argv[]) +{ + if (argc == 0) + { + streamer_printf(streamer_get(), "The light is %s\n", LightMgr().IsLightOn() ? "on" : "off"); + } + else if (strcmp(argv[0], "on") == 0) + { + streamer_printf(streamer_get(), "Turning the light on ...\n"); + LightMgr().InitiateAction(LightingManager::ACTOR_APP_CMD, LightingManager::ON_ACTION, 0); + } + else if (strcmp(argv[0], "off") == 0) + { + streamer_printf(streamer_get(), "Turning the light off ...\n"); + LightMgr().InitiateAction(LightingManager::ACTOR_APP_CMD, LightingManager::OFF_ACTION, 0); + } + else if (strcmp(argv[0], "toggle") == 0) + { + streamer_printf(streamer_get(), "Toggling the light ...\n"); + if (LightMgr().IsLightOn()) + LightMgr().InitiateAction(LightingManager::ACTOR_APP_CMD, LightingManager::OFF_ACTION, 0); + else + LightMgr().InitiateAction(LightingManager::ACTOR_APP_CMD, LightingManager::ON_ACTION, 0); + } + else + { + return CHIP_ERROR_INVALID_ARGUMENT; + } + return CHIP_NO_ERROR; +} + +CHIP_ERROR AppCommandDispatch(int argc, char * argv[]) +{ + if (argc == 0) + { + AppCommandHelpHandler(argc, argv); + return CHIP_NO_ERROR; + } + return sAppSubcommands.ExecCommand(argc, argv); +} diff --git a/examples/lighting-app/cyw30739/src/ButtonHandler.cpp b/examples/lighting-app/cyw30739/src/ButtonHandler.cpp new file mode 100644 index 00000000000000..10c24a4b785440 --- /dev/null +++ b/examples/lighting-app/cyw30739/src/ButtonHandler.cpp @@ -0,0 +1,88 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2019 Google LLC. + * Copyright 2021, Cypress Semiconductor Corporation (an Infineon company) + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include + +/****************************************************** + * Macros + ******************************************************/ +void app_button_event_handler(const button_manager_button_t * button, button_manager_event_t event, + button_manager_button_state_t state); + +static wiced_button_manager_configuration_t app_button_manager_configuration = { + .short_hold_duration = 500, /*msec*/ + .medium_hold_duration = 700, + .long_hold_duration = 1500, + .very_long_hold_duration = 2500, + .debounce_duration = 150, /* typically a click takes around ~150-200 ms */ + .double_click_interval = 250, + .continuous_hold_detect = WICED_TRUE, + .event_handler = app_button_event_handler, +}; + +/* Static button configuration */ +static wiced_button_configuration_t app_button_configurations[APP_MAX_BUTTON_DEF]; +/* Button objects for the button manager */ +static button_manager_button_t app_buttons[APP_MAX_BUTTON_DEF]; +static button_manager_t app_button_manager; + +wiced_result_t app_button_init(void) +{ + wiced_result_t result = WICED_ERROR; + + memset(app_button_configurations, 0, (sizeof(wiced_button_configuration_t) * APP_MAX_BUTTON_DEF)); + memset(app_buttons, 0, (sizeof(button_manager_button_t) * APP_MAX_BUTTON_DEF)); + + app_button_configurations[ON_OFF_BUTTON].button = PLATFORM_BUTTON_1; + app_button_configurations[ON_OFF_BUTTON].button_event_mask = BUTTON_CLICK_EVENT; + app_buttons[ON_OFF_BUTTON].configuration = &app_button_configurations[ON_OFF_BUTTON]; + + result = wiced_button_manager_init(&app_button_manager, &app_button_manager_configuration, app_buttons, 1); + + if (result != WICED_SUCCESS) + { + printf("button_manager_init failed (%d)\n", result); + } + return result; +} + +void app_button_event_handler(const button_manager_button_t * button_mgr, button_manager_event_t event, + button_manager_button_state_t state) +{ + + if (button_mgr[0].configuration->button == PLATFORM_BUTTON_1 && event == BUTTON_CLICK_EVENT && state == BUTTON_STATE_RELEASED) + { + if (LightMgr().IsLightOn()) + { + printf("Button Toggle:ON -> OFF\n"); + LightMgr().InitiateAction(LightingManager::ACTOR_BUTTON, LightingManager::OFF_ACTION, 0); + } + else + { + printf("Button Toggle:OFF -> ON\n"); + LightMgr().InitiateAction(LightingManager::ACTOR_BUTTON, LightingManager::ON_ACTION, 0); + } + } +} diff --git a/examples/lighting-app/cyw30739/src/LightingManager.cpp b/examples/lighting-app/cyw30739/src/LightingManager.cpp new file mode 100644 index 00000000000000..dc11429fc65cd0 --- /dev/null +++ b/examples/lighting-app/cyw30739/src/LightingManager.cpp @@ -0,0 +1,121 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2019 Google LLC. + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "LightingManager.h" +#include +#include +#include +#include +#include +#include +#include + +using namespace chip; +using namespace chip::app; +using namespace chip::app::Clusters; + +LightingManager LightingManager::sLight; + +CHIP_ERROR LightingManager::Init() +{ + mState = kState_OffCompleted; + + return CHIP_NO_ERROR; +} + +void LightingManager::SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB) +{ + mActionInitiated_CB = aActionInitiated_CB; + mActionCompleted_CB = aActionCompleted_CB; +} + +bool LightingManager::IsActionInProgress() +{ + return (mState == kState_OffInitiated || mState == kState_OnInitiated); +} + +bool LightingManager::IsLightOn(void) +{ + bool on = true; + const EmberAfStatus status = OnOff::Attributes::OnOff::Get(1, &on); + + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + printf("Error ReadServerAttribute 0x%02x\n", status); + } + + return on != false; +} + +bool LightingManager::InitiateAction(Actor_t aActor, Action_t aAction, uint8_t value) +{ + if (mActionInitiated_CB) + { + mActionInitiated_CB(aActor, aAction, value); + } + + switch (aAction) + { + case ON_ACTION: + mState = kState_OnInitiated; + if (aActor != ACTOR_ZCL_CMD) + { + WriteClusterState(1); + } + mState = kState_OnCompleted; + break; + case OFF_ACTION: + mState = kState_OffInitiated; + if (aActor != ACTOR_ZCL_CMD) + { + WriteClusterState(0); + } + mState = kState_OffCompleted; + break; + default: + return false; + } + + if (mActionCompleted_CB) + { + mActionCompleted_CB(aAction); + } + + return true; +} + +void LightingManager::WriteClusterState(uint8_t value) +{ + const EmberAfStatus status = OnOff::Attributes::OnOff::Set(1, value); + + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + printf("Error WriteServerAttribute 0x%02x\n", status); + } +} + +void LightingManager::WriteClusterLevel(uint8_t value) +{ + const EmberAfStatus status = LevelControl::Attributes::CurrentLevel::Set(1, value); + + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + printf("Error WriteServerAttribute 0x%02x\n", status); + } +} diff --git a/examples/lighting-app/cyw30739/src/ZclCallbacks.cpp b/examples/lighting-app/cyw30739/src/ZclCallbacks.cpp new file mode 100644 index 00000000000000..ce4b51297cc321 --- /dev/null +++ b/examples/lighting-app/cyw30739/src/ZclCallbacks.cpp @@ -0,0 +1,71 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2019 Google LLC. + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "LightingManager.h" +#include +#include + +using namespace chip; +using namespace chip::app::Clusters; +using namespace chip::DeviceLayer; + +void emberAfBasicClusterInitCallback(EndpointId endpoint) +{ + uint16_t year; + uint8_t month; + uint8_t dayOfMonth; + char cString[16] = "00000000"; + + if (ConfigurationMgr().GetManufacturingDate(year, month, dayOfMonth) == CHIP_NO_ERROR) + { + snprintf(cString, sizeof(cString), "%04u%02u%02u", year, month, dayOfMonth); + } + Basic::Attributes::ManufacturingDate::Set(endpoint, CharSpan(cString)); +} + +void MatterPostAttributeChangeCallback(const app::ConcreteAttributePath & attributePath, uint8_t mask, uint8_t type, uint16_t size, + uint8_t * value) + +{ + switch (attributePath.mClusterId) + { + case OnOff::Id: + if (attributePath.mAttributeId == OnOff::Attributes::OnOff::Id) + { + printf("ZCL OnOff -> %u\n", *value); + LightMgr().InitiateAction(LightingManager::ACTOR_ZCL_CMD, + (*value == 0) ? LightingManager::OFF_ACTION : LightingManager::ON_ACTION, *value); + return; + } + break; + case LevelControl::Id: + if (attributePath.mAttributeId == LevelControl::Attributes::CurrentLevel::Id) + { + printf("ZCL CurrentLevel -> %u\n", *value); + LightMgr().InitiateAction(LightingManager::ACTOR_ZCL_CMD, LightingManager::LEVEL_ACTION, *value); + return; + } + break; + default: + printf("Unhandled cluster ID: 0x%04lx\n", attributePath.mClusterId); + return; + } + + printf("ERROR clusterId: 0x%04lx, unknown attribute ID: 0x%04lx\n", attributePath.mClusterId, attributePath.mAttributeId); +} diff --git a/examples/lighting-app/cyw30739/src/main.cpp b/examples/lighting-app/cyw30739/src/main.cpp new file mode 100644 index 00000000000000..3a99588bc7f4f6 --- /dev/null +++ b/examples/lighting-app/cyw30739/src/main.cpp @@ -0,0 +1,181 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2019 Google LLC. + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace ::chip::Credentials; +using namespace ::chip::DeviceLayer; +using namespace ::chip::Shell; + +static void EventHandler(const ChipDeviceEvent * event, intptr_t arg); +static void HandleThreadStateChangeEvent(const ChipDeviceEvent * event); +static void LightManagerCallback(LightingManager::Actor_t actor, LightingManager::Action_t action, uint8_t value); + +static wiced_led_config_t chip_lighting_led_config = { + .led = PLATFORM_LED_1, + .bright = 50, +}; + +APPLICATION_START() +{ + CHIP_ERROR err; + wiced_result_t result; + + printf("\nChipLighting App starting\n"); + + mbedtls_platform_set_calloc_free(CHIPPlatformMemoryCalloc, CHIPPlatformMemoryFree); + + err = chip::Platform::MemoryInit(); + if (err != CHIP_NO_ERROR) + { + printf("ERROR MemoryInit %ld\n", err.AsInteger()); + } + + result = app_button_init(); + if (result != WICED_SUCCESS) + { + printf("ERROR app_button_init %d\n", result); + } + + /* Init. LED Manager. */ + result = wiced_led_manager_init(&chip_lighting_led_config); + if (result != WICED_SUCCESS) + printf("wiced_led_manager_init fail (%d)\n", result); + + printf("Initializing CHIP\n"); + err = PlatformMgr().InitChipStack(); + if (err != CHIP_NO_ERROR) + { + printf("ERROR InitChipStack %ld\n", err.AsInteger()); + } + +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + printf("Initializing OpenThread stack\n"); + err = ThreadStackMgr().InitThreadStack(); + if (err != CHIP_NO_ERROR) + { + printf("ERROR InitThreadStack %ld\n", err.AsInteger()); + } +#endif + +#if CHIP_DEVICE_CONFIG_THREAD_FTD + err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router); +#else // !CHIP_DEVICE_CONFIG_THREAD_FTD + err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice); +#endif // CHIP_DEVICE_CONFIG_THREAD_FTD + if (err != CHIP_NO_ERROR) + { + printf("ERROR SetThreadDeviceType %ld\n", err.AsInteger()); + } + + printf("Starting event loop task\n"); + err = PlatformMgr().StartEventLoopTask(); + if (err != CHIP_NO_ERROR) + { + printf("ERROR StartEventLoopTask %ld\n", err.AsInteger()); + } + +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + printf("Starting thread task\n"); + err = ThreadStackMgr().StartThreadTask(); + if (err != CHIP_NO_ERROR) + { + printf("ERROR StartThreadTask %ld\n", err.AsInteger()); + } +#endif + + PlatformMgrImpl().AddEventHandler(EventHandler, 0); + + LightMgr().Init(); + LightMgr().SetCallbacks(LightManagerCallback, NULL); + + /* Start CHIP datamodel server */ + chip::Server::GetInstance().Init(); + + SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); + + ConfigurationMgr().LogDeviceConfig(); + + const int ret = Engine::Root().Init(); + if (!chip::ChipError::IsSuccess(ret)) + { + printf("ERROR Shell Init %d\n", ret); + } + cmd_ping_init(); + RegisterAppShellCommands(); + Engine::Root().RunMainLoop(); + + assert(!wiced_rtos_check_for_stack_overflow()); +} + +void EventHandler(const ChipDeviceEvent * event, intptr_t arg) +{ + switch (event->Type) + { + case DeviceEventType::kThreadStateChange: + HandleThreadStateChangeEvent(event); + break; + default: + break; + } +} + +void HandleThreadStateChangeEvent(const ChipDeviceEvent * event) +{ +#if CHIP_BYPASS_RENDEZVOUS + if (event->ThreadStateChange.NetDataChanged && !ConnectivityMgr().IsThreadProvisioned()) + { + ThreadStackMgr().JoinerStart(); + } +#endif /* CHIP_BYPASS_RENDEZVOUS */ +} + +void LightManagerCallback(LightingManager::Actor_t actor, LightingManager::Action_t action, uint8_t level) +{ + if (action == LightingManager::ON_ACTION) + { + printf("Turning light ON\n"); + wiced_led_manager_enable_led(PLATFORM_LED_1); + } + else if (action == LightingManager::OFF_ACTION) + { + printf("Turning light OFF\n"); + wiced_led_manager_disable_led(PLATFORM_LED_1); + } + else if (action == LightingManager::LEVEL_ACTION) + { + printf("Set light level = %d\n", level); + chip_lighting_led_config.bright = (uint16_t) level * 100 / 0xfe; + wiced_led_manager_reconfig_led(&chip_lighting_led_config); + } +} diff --git a/examples/lighting-app/cyw30739/static_config.txt b/examples/lighting-app/cyw30739/static_config.txt new file mode 100644 index 00000000000000..f256ac94aa5abf --- /dev/null +++ b/examples/lighting-app/cyw30739/static_config.txt @@ -0,0 +1,21 @@ +# The post-building script uses this file to generate specified static configurations. +# All '#' prefixed lines are ignored by the script. +# Each line defines a static configuration by 3 fields separated by commas. +# +# The 1st field is a 16-bit ID from 0x2000 to 0x3ffff. +# All IDs in this file have to be different. +# +# The 2nd field is a type to which the script interprets the value according. +# +# The 3rd field is a value of the static configuration. The value format depends on what the value type is: +# - hex: Multiple hexadecimal values separated by commas. +# - uint32/uint16/uint8/int16/int8: A integer. +# - eui64: random or btext. If the value is btext, the configuration will be generated from the BT address. +# +# ID, type, value +# EUI64 +0x2000, eui64, random +# Setup Pin Code +0x2105, uint32, 20202021 +# Setup Discriminator +0x2107, uint32, 3840 diff --git a/examples/lighting-app/cyw30739/third_party/connectedhomeip b/examples/lighting-app/cyw30739/third_party/connectedhomeip new file mode 120000 index 00000000000000..c866b86874994d --- /dev/null +++ b/examples/lighting-app/cyw30739/third_party/connectedhomeip @@ -0,0 +1 @@ +../../../.. \ No newline at end of file diff --git a/examples/lighting-app/esp32/README.md b/examples/lighting-app/esp32/README.md index 534e6ec3df0c16..51ca945b63140d 100644 --- a/examples/lighting-app/esp32/README.md +++ b/examples/lighting-app/esp32/README.md @@ -142,10 +142,10 @@ scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/debug c hello-world.bin can be obtained from compiling the hello-world ESP-IDF example. -- Provision the Linux OTA Provider using chip-tool +- Commission the Linux OTA Provider using chip-tool ``` -./out/debug/chip-tool pairing onnetwork 12345 20202021 +./out/debug/chip-tool pairing onnetwork 12346 20202021 ``` ## Query for an OTA Image @@ -154,10 +154,11 @@ After commissioning is successful, press Enter in requestor device console and type below query. ``` ->matter ota query 1 12345 0 +>matter ota query 1 12346 0 ``` ## Apply update -Once transfer is complete, reboot the device manually to boot from upgraded OTA -image. +Once the transfer is complete, OTA requestor sends ApplyUpdateRequest command to +OTA provider for applying the image. Device will restart on successful +application of OTA image. diff --git a/examples/lighting-app/esp32/main/CMakeLists.txt b/examples/lighting-app/esp32/main/CMakeLists.txt index 4413f141070491..0b2deeab79926a 100644 --- a/examples/lighting-app/esp32/main/CMakeLists.txt +++ b/examples/lighting-app/esp32/main/CMakeLists.txt @@ -43,6 +43,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/identify-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/localization-configuration-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/time-format-localization-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/level-control" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning-old" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/occupancy-sensor-server" diff --git a/examples/lighting-app/esp32/main/main.cpp b/examples/lighting-app/esp32/main/main.cpp index b26a2fa6afd2e6..c3114e04c2b363 100644 --- a/examples/lighting-app/esp32/main/main.cpp +++ b/examples/lighting-app/esp32/main/main.cpp @@ -57,12 +57,10 @@ static void InitOTARequestor(void) { #if CONFIG_ENABLE_OTA_REQUESTOR SetRequestorInstance(&gRequestorCore); - gRequestorCore.SetServerInstance(&Server::GetInstance()); - gRequestorCore.SetOtaRequestorDriver(&gRequestorUser); + gRequestorCore.Init(&Server::GetInstance(), &gRequestorUser, &gDownloader); gImageProcessor.SetOTADownloader(&gDownloader); gDownloader.SetImageProcessorDelegate(&gImageProcessor); gRequestorUser.Init(&gRequestorCore, &gImageProcessor); - gRequestorCore.SetBDXDownloader(&gDownloader); #endif } diff --git a/examples/lighting-app/lighting-common/lighting-app.matter b/examples/lighting-app/lighting-common/lighting-app.matter index b2e216e95e5504..ac2cfca6d84c82 100644 --- a/examples/lighting-app/lighting-common/lighting-app.matter +++ b/examples/lighting-app/lighting-common/lighting-app.matter @@ -2,8 +2,8 @@ // It is for view/code review purposes only. struct LabelStruct { - CHAR_STRING label = 0; - CHAR_STRING value = 1; + CHAR_STRING<16> label = 0; + CHAR_STRING<16> value = 1; } server cluster AdministratorCommissioning = 60 { @@ -58,24 +58,24 @@ server cluster Basic = 40 { } readonly attribute int16u interactionModelVersion = 0; - readonly attribute char_string vendorName = 1; + readonly attribute char_string<32> vendorName = 1; readonly attribute vendor_id vendorID = 2; - readonly attribute char_string productName = 3; + readonly attribute char_string<32> productName = 3; readonly attribute int16u productID = 4; - attribute char_string nodeLabel = 5; - attribute char_string location = 6; + attribute char_string<32> nodeLabel = 5; + attribute char_string<2> location = 6; readonly attribute int16u hardwareVersion = 7; - readonly attribute char_string hardwareVersionString = 8; + readonly attribute char_string<64> hardwareVersionString = 8; readonly attribute int32u softwareVersion = 9; - readonly attribute char_string softwareVersionString = 10; - readonly attribute char_string manufacturingDate = 11; - readonly attribute char_string partNumber = 12; - readonly attribute long_char_string productURL = 13; - readonly attribute char_string productLabel = 14; - readonly attribute char_string serialNumber = 15; + readonly attribute char_string<64> softwareVersionString = 10; + readonly attribute char_string<16> manufacturingDate = 11; + readonly attribute char_string<32> partNumber = 12; + readonly attribute long_char_string<256> productURL = 13; + readonly attribute char_string<64> productLabel = 14; + readonly attribute char_string<32> serialNumber = 15; attribute boolean localConfigDisabled = 16; readonly attribute boolean reachable = 17; - readonly attribute char_string uniqueID = 18; + readonly attribute char_string<32> uniqueID = 18; readonly global attribute int16u clusterRevision = 65533; } @@ -504,11 +504,11 @@ server cluster GeneralDiagnostics = 51 { } struct NetworkInterfaceType { - CHAR_STRING name = 0; + CHAR_STRING<32> name = 0; BOOLEAN fabricConnected = 1; BOOLEAN offPremiseServicesReachableIPv4 = 2; BOOLEAN offPremiseServicesReachableIPv6 = 3; - OCTET_STRING hardwareAddress = 4; + OCTET_STRING<8> hardwareAddress = 4; InterfaceType type = 5; } @@ -669,7 +669,7 @@ server cluster LevelControl = 8 { } server cluster LocalizationConfiguration = 43 { - attribute char_string activeLocale = 1; + attribute char_string<35> activeLocale = 1; readonly attribute CHAR_STRING supportedLocales[] = 2; } @@ -729,7 +729,7 @@ server cluster NetworkCommissioning = 49 { readonly attribute int8u connectMaxTimeSeconds = 3; attribute boolean interfaceEnabled = 4; readonly attribute NetworkCommissioningStatus lastNetworkingStatus = 5; - readonly attribute octet_string lastNetworkID = 6; + readonly attribute octet_string<32> lastNetworkID = 6; readonly attribute int32u lastConnectErrorValue = 7; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; @@ -1029,11 +1029,11 @@ server cluster OperationalCredentials = 62 { struct FabricDescriptor { fabric_idx fabricIndex = 0; - OCTET_STRING rootPublicKey = 1; + OCTET_STRING<65> rootPublicKey = 1; INT16U vendorId = 2; FABRIC_ID fabricId = 3; NODE_ID nodeId = 4; - CHAR_STRING label = 5; + CHAR_STRING<32> label = 5; } readonly attribute NOCStruct NOCs[] = 0; @@ -1119,7 +1119,7 @@ server cluster OperationalCredentials = 62 { server cluster SoftwareDiagnostics = 52 { struct ThreadMetrics { INT64U id = 0; - CHAR_STRING name = 1; + CHAR_STRING<8> name = 1; INT32U stackFreeCurrent = 2; INT32U stackFreeMinimum = 3; INT32U stackSize = 4; @@ -1251,10 +1251,10 @@ server cluster ThreadNetworkDiagnostics = 53 { readonly attribute int16u channel = 0; readonly attribute enum8 routingRole = 1; - readonly attribute octet_string networkName = 2; + readonly attribute octet_string<16> networkName = 2; readonly attribute int16u panId = 3; readonly attribute int64u extendedPanId = 4; - readonly attribute octet_string meshLocalPrefix = 5; + readonly attribute octet_string<17> meshLocalPrefix = 5; readonly attribute int64u overrunCount = 6; readonly attribute NeighborTable neighborTableList[] = 7; readonly attribute RouteTable routeTableList[] = 8; @@ -1309,7 +1309,7 @@ server cluster ThreadNetworkDiagnostics = 53 { readonly attribute int64u pendingTimestamp = 57; readonly attribute int32u delay = 58; readonly attribute SecurityPolicy securityPolicy[] = 59; - readonly attribute octet_string channelMask = 60; + readonly attribute octet_string<4> channelMask = 60; readonly attribute OperationalDatasetComponents operationalDatasetComponents[] = 61; readonly attribute NetworkFault activeNetworkFaultsList[] = 62; readonly global attribute bitmap32 featureMap = 65532; @@ -1318,6 +1318,33 @@ server cluster ThreadNetworkDiagnostics = 53 { command ResetCounts(): DefaultSuccess = 0; } +server cluster TimeFormatLocalization = 44 { + enum CalendarType : ENUM8 { + kBuddhist = 0; + kChinese = 1; + kCoptic = 2; + kEthiopian = 3; + kGregorian = 4; + kHebrew = 5; + kIndian = 6; + kIslamic = 7; + kJapanese = 8; + kKorean = 9; + kPersian = 10; + kTaiwanese = 11; + } + + enum HourFormat : ENUM8 { + k12hr = 0; + k24hr = 1; + } + + attribute HourFormat hourFormat = 0; + attribute CalendarType activeCalendarType = 1; + readonly attribute CalendarType supportedCalendarTypes[] = 2; + readonly global attribute int16u clusterRevision = 65533; +} + server cluster UserLabel = 65 { attribute LabelStruct labelList[] = 0; readonly global attribute int16u clusterRevision = 65533; @@ -1367,7 +1394,7 @@ server cluster WiFiNetworkDiagnostics = 54 { WiFiConnectionStatus connectionStatus = 0; } - readonly attribute octet_string bssid = 0; + readonly attribute octet_string<6> bssid = 0; readonly attribute enum8 securityType = 1; readonly attribute enum8 wiFiVersion = 2; readonly attribute int16u channelNumber = 3; @@ -1404,6 +1431,7 @@ endpoint 0 { server cluster SoftwareDiagnostics; server cluster Switch; server cluster ThreadNetworkDiagnostics; + server cluster TimeFormatLocalization; server cluster UserLabel; server cluster WiFiNetworkDiagnostics; } diff --git a/examples/lighting-app/lighting-common/lighting-app.zap b/examples/lighting-app/lighting-common/lighting-app.zap index fb1e68cb44bec1..631118b4b76b67 100644 --- a/examples/lighting-app/lighting-common/lighting-app.zap +++ b/examples/lighting-app/lighting-common/lighting-app.zap @@ -1592,6 +1592,87 @@ } ] }, + { + "name": "Time Format Localization", + "code": 44, + "mfgCode": null, + "define": "TIME_FORMAT_LOCALIZATION_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [] + }, + { + "name": "Time Format Localization", + "code": 44, + "mfgCode": null, + "define": "TIME_FORMAT_LOCALIZATION_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "HourFormat", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CalendarType", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SupportedCalendarTypes", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "General Commissioning", "code": 48, diff --git a/examples/lighting-app/mbed/CMakeLists.txt b/examples/lighting-app/mbed/CMakeLists.txt index bfad30ece1b85f..38505dfc0c93b4 100644 --- a/examples/lighting-app/mbed/CMakeLists.txt +++ b/examples/lighting-app/mbed/CMakeLists.txt @@ -80,7 +80,8 @@ target_sources(${APP_TARGET} PRIVATE ${CHIP_ROOT}/src/app/clusters/identify-server/identify-server.cpp ${CHIP_ROOT}/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp ${CHIP_ROOT}/src/app/clusters/ethernet-network-diagnostics-server/ethernet-network-diagnostics-server.cpp - ${CHIP_ROOT}/src/app/clusters/localization-configuration-server/localization-configuration-server.cpp + ${CHIP_ROOT}/src/app/clusters/localization-configuration-server/localization-configuration-server.cpp + ${CHIP_ROOT}/src/app/clusters/time-format-localization-server/time-format-localization-server.cpp ${CHIP_ROOT}/src/app/clusters/fixed-label-server/fixed-label-server.cpp ${CHIP_ROOT}/src/app/clusters/user-label-server/user-label-server.cpp ${CHIP_ROOT}/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-server.cpp diff --git a/examples/lighting-app/telink/CMakeLists.txt b/examples/lighting-app/telink/CMakeLists.txt index f6bb6443f127ba..b27eb35fff3680 100644 --- a/examples/lighting-app/telink/CMakeLists.txt +++ b/examples/lighting-app/telink/CMakeLists.txt @@ -80,6 +80,7 @@ target_sources(app PRIVATE ${CHIP_ROOT}/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp ${CHIP_ROOT}/src/app/clusters/ethernet-network-diagnostics-server/ethernet-network-diagnostics-server.cpp ${CHIP_ROOT}/src/app/clusters/localization-configuration-server/localization-configuration-server.cpp + ${CHIP_ROOT}/src/app/clusters/time-format-localization-server/time-format-localization-server.cpp ${CHIP_ROOT}/src/app/clusters/fixed-label-server/fixed-label-server.cpp ${CHIP_ROOT}/src/app/clusters/user-label-server/user-label-server.cpp ${CHIP_ROOT}/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-server.cpp diff --git a/examples/lock-app/esp32/main/CMakeLists.txt b/examples/lock-app/esp32/main/CMakeLists.txt index 353812d4dc7ed2..b9679637ee75ba 100644 --- a/examples/lock-app/esp32/main/CMakeLists.txt +++ b/examples/lock-app/esp32/main/CMakeLists.txt @@ -138,7 +138,8 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/descriptor" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/diagnostic-logs-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ethernet-network-diagnostics-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/localization-configuration-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/localization-configuration-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/time-format-localization-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/fixed-label-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread-network-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/wifi-network-diagnostics-server" diff --git a/examples/lock-app/lock-common/lock-app.matter b/examples/lock-app/lock-common/lock-app.matter index fe6fecc6a9dd26..121f94d37f9803 100644 --- a/examples/lock-app/lock-common/lock-app.matter +++ b/examples/lock-app/lock-common/lock-app.matter @@ -2,8 +2,8 @@ // It is for view/code review purposes only. struct LabelStruct { - CHAR_STRING label = 0; - CHAR_STRING value = 1; + CHAR_STRING<16> label = 0; + CHAR_STRING<16> value = 1; } server cluster AdministratorCommissioning = 60 { @@ -58,16 +58,16 @@ server cluster Basic = 40 { } readonly attribute int16u interactionModelVersion = 0; - readonly attribute char_string vendorName = 1; + readonly attribute char_string<32> vendorName = 1; readonly attribute vendor_id vendorID = 2; - readonly attribute char_string productName = 3; + readonly attribute char_string<32> productName = 3; readonly attribute int16u productID = 4; - attribute char_string nodeLabel = 5; - attribute char_string location = 6; + attribute char_string<32> nodeLabel = 5; + attribute char_string<2> location = 6; readonly attribute int16u hardwareVersion = 7; - readonly attribute char_string hardwareVersionString = 8; + readonly attribute char_string<64> hardwareVersionString = 8; readonly attribute int32u softwareVersion = 9; - readonly attribute char_string softwareVersionString = 10; + readonly attribute char_string<64> softwareVersionString = 10; readonly global attribute int16u clusterRevision = 65533; } @@ -255,11 +255,11 @@ server cluster GeneralDiagnostics = 51 { } struct NetworkInterfaceType { - CHAR_STRING name = 0; + CHAR_STRING<32> name = 0; BOOLEAN fabricConnected = 1; BOOLEAN offPremiseServicesReachableIPv4 = 2; BOOLEAN offPremiseServicesReachableIPv6 = 3; - OCTET_STRING hardwareAddress = 4; + OCTET_STRING<8> hardwareAddress = 4; InterfaceType type = 5; } @@ -294,7 +294,7 @@ server cluster GeneralDiagnostics = 51 { } server cluster LocalizationConfiguration = 43 { - attribute char_string activeLocale = 1; + attribute char_string<35> activeLocale = 1; readonly attribute CHAR_STRING supportedLocales[] = 2; } @@ -354,7 +354,7 @@ server cluster NetworkCommissioning = 49 { readonly attribute int8u connectMaxTimeSeconds = 3; attribute boolean interfaceEnabled = 4; readonly attribute NetworkCommissioningStatus lastNetworkingStatus = 5; - readonly attribute octet_string lastNetworkID = 6; + readonly attribute octet_string<32> lastNetworkID = 6; readonly attribute int32u lastConnectErrorValue = 7; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; @@ -468,11 +468,11 @@ server cluster OperationalCredentials = 62 { struct FabricDescriptor { fabric_idx fabricIndex = 0; - OCTET_STRING rootPublicKey = 1; + OCTET_STRING<65> rootPublicKey = 1; INT16U vendorId = 2; FABRIC_ID fabricId = 3; NODE_ID nodeId = 4; - CHAR_STRING label = 5; + CHAR_STRING<32> label = 5; } readonly attribute NOCStruct NOCs[] = 0; @@ -558,12 +558,12 @@ server cluster OperationalCredentials = 62 { server cluster PowerSource = 47 { readonly attribute enum8 status = 0; readonly attribute int8u order = 1; - readonly attribute char_string description = 2; + readonly attribute char_string<60> description = 2; readonly attribute int32u wiredAssessedCurrent = 6; readonly attribute enum8 batteryChargeLevel = 14; readonly attribute boolean batteryReplacementNeeded = 15; readonly attribute enum8 batteryReplaceability = 16; - readonly attribute char_string batteryReplacementDescription = 19; + readonly attribute char_string<60> batteryReplacementDescription = 19; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; } @@ -576,7 +576,7 @@ server cluster PowerSourceConfiguration = 46 { server cluster SoftwareDiagnostics = 52 { struct ThreadMetrics { INT64U id = 0; - CHAR_STRING name = 1; + CHAR_STRING<8> name = 1; INT32U stackFreeCurrent = 2; INT32U stackFreeMinimum = 3; INT32U stackSize = 4; @@ -673,10 +673,10 @@ server cluster ThreadNetworkDiagnostics = 53 { readonly attribute int16u channel = 0; readonly attribute enum8 routingRole = 1; - readonly attribute octet_string networkName = 2; + readonly attribute octet_string<16> networkName = 2; readonly attribute int16u panId = 3; readonly attribute int64u extendedPanId = 4; - readonly attribute octet_string meshLocalPrefix = 5; + readonly attribute octet_string<17> meshLocalPrefix = 5; readonly attribute int64u overrunCount = 6; readonly attribute NeighborTable neighborTableList[] = 7; readonly attribute RouteTable routeTableList[] = 8; @@ -731,13 +731,40 @@ server cluster ThreadNetworkDiagnostics = 53 { readonly attribute int64u pendingTimestamp = 57; readonly attribute int32u delay = 58; readonly attribute SecurityPolicy securityPolicy[] = 59; - readonly attribute octet_string channelMask = 60; + readonly attribute octet_string<4> channelMask = 60; readonly attribute OperationalDatasetComponents operationalDatasetComponents[] = 61; readonly attribute NetworkFault activeNetworkFaultsList[] = 62; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; } +server cluster TimeFormatLocalization = 44 { + enum CalendarType : ENUM8 { + kBuddhist = 0; + kChinese = 1; + kCoptic = 2; + kEthiopian = 3; + kGregorian = 4; + kHebrew = 5; + kIndian = 6; + kIslamic = 7; + kJapanese = 8; + kKorean = 9; + kPersian = 10; + kTaiwanese = 11; + } + + enum HourFormat : ENUM8 { + k12hr = 0; + k24hr = 1; + } + + attribute HourFormat hourFormat = 0; + attribute CalendarType activeCalendarType = 1; + readonly attribute CalendarType supportedCalendarTypes[] = 2; + readonly global attribute int16u clusterRevision = 65533; +} + server cluster UserLabel = 65 { attribute LabelStruct labelList[] = 0; readonly global attribute int16u clusterRevision = 65533; @@ -787,7 +814,7 @@ server cluster WiFiNetworkDiagnostics = 54 { WiFiConnectionStatus connectionStatus = 0; } - readonly attribute octet_string bssid = 0; + readonly attribute octet_string<6> bssid = 0; readonly attribute enum8 securityType = 1; readonly attribute enum8 wiFiVersion = 2; readonly attribute int16u channelNumber = 3; @@ -821,6 +848,7 @@ endpoint 0 { server cluster PowerSourceConfiguration; server cluster SoftwareDiagnostics; server cluster ThreadNetworkDiagnostics; + server cluster TimeFormatLocalization; server cluster UserLabel; server cluster WiFiNetworkDiagnostics; } diff --git a/examples/lock-app/lock-common/lock-app.zap b/examples/lock-app/lock-common/lock-app.zap index 08b8f6614b3cbb..13f08d2ee738a2 100644 --- a/examples/lock-app/lock-common/lock-app.zap +++ b/examples/lock-app/lock-common/lock-app.zap @@ -1210,6 +1210,87 @@ } ] }, + { + "name": "Time Format Localization", + "code": 44, + "mfgCode": null, + "define": "TIME_FORMAT_LOCALIZATION_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [] + }, + { + "name": "Time Format Localization", + "code": 44, + "mfgCode": null, + "define": "TIME_FORMAT_LOCALIZATION_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "HourFormat", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CalendarType", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SupportedCalendarTypes", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "Power Source Configuration", "code": 46, diff --git a/examples/lock-app/mbed/CMakeLists.txt b/examples/lock-app/mbed/CMakeLists.txt index f7326fa9822375..59fc5d3670964b 100644 --- a/examples/lock-app/mbed/CMakeLists.txt +++ b/examples/lock-app/mbed/CMakeLists.txt @@ -78,6 +78,7 @@ target_sources(${APP_TARGET} PRIVATE ${CHIP_ROOT}/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp ${CHIP_ROOT}/src/app/clusters/ethernet-network-diagnostics-server/ethernet-network-diagnostics-server.cpp ${CHIP_ROOT}/src/app/clusters/localization-configuration-server/localization-configuration-server.cpp + ${CHIP_ROOT}/src/app/clusters/time-format-localization-server/time-format-localization-server.cpp ${CHIP_ROOT}/src/app/clusters/fixed-label-server/fixed-label-server.cpp ${CHIP_ROOT}/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-server.cpp ${CHIP_ROOT}/src/app/clusters/wifi-network-diagnostics-server/wifi-network-diagnostics-server.cpp diff --git a/examples/log-source-app/log-source-common/log-source-app.matter b/examples/log-source-app/log-source-common/log-source-app.matter index e30623a820f786..1280aec975ace0 100644 --- a/examples/log-source-app/log-source-common/log-source-app.matter +++ b/examples/log-source-app/log-source-common/log-source-app.matter @@ -236,11 +236,11 @@ server cluster OperationalCredentials = 62 { struct FabricDescriptor { fabric_idx fabricIndex = 0; - OCTET_STRING rootPublicKey = 1; + OCTET_STRING<65> rootPublicKey = 1; INT16U vendorId = 2; FABRIC_ID fabricId = 3; NODE_ID nodeId = 4; - CHAR_STRING label = 5; + CHAR_STRING<32> label = 5; } readonly attribute FabricDescriptor fabricsList[] = 1; diff --git a/examples/ota-provider-app/esp32/README.md b/examples/ota-provider-app/esp32/README.md index c849db6afd95d6..af830a81c95c45 100644 --- a/examples/ota-provider-app/esp32/README.md +++ b/examples/ota-provider-app/esp32/README.md @@ -41,6 +41,15 @@ idf.py -p flash ./out/debug/chip-tool pairing ble-wifi 12345 20202021 3841 ``` +## Set delayed action time (Optional) + +- Set delayed action time in the Query Image Response and Apply Update + Response, default is zero. + +``` +> matter OTAProvider delay +``` + --- Once OTA provider is commissioned then head over to diff --git a/examples/ota-provider-app/esp32/main/CMakeLists.txt b/examples/ota-provider-app/esp32/main/CMakeLists.txt index 2d673860ea9668..f4da8691893de6 100644 --- a/examples/ota-provider-app/esp32/main/CMakeLists.txt +++ b/examples/ota-provider-app/esp32/main/CMakeLists.txt @@ -34,7 +34,8 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/descriptor" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/diagnostic-logs-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ethernet-network-diagnostics-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/localization-configuration-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/localization-configuration-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/time-format-localization-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/fixed-label-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/user-label-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread-network-diagnostics-server" @@ -48,6 +49,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/operational-credentials-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ota-provider" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/ota-provider-app/ota-provider-common" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/shell_extension" EXCLUDE_SRCS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/ota-provider-app/ota-provider-common/BdxOtaSender.cpp" PRIV_REQUIRES chip QRCode bt console spiffs) diff --git a/examples/ota-provider-app/esp32/main/OTAProviderCommands.cpp b/examples/ota-provider-app/esp32/main/OTAProviderCommands.cpp new file mode 100644 index 00000000000000..58bf1ee1320f16 --- /dev/null +++ b/examples/ota-provider-app/esp32/main/OTAProviderCommands.cpp @@ -0,0 +1,87 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +namespace chip { +namespace Shell { +namespace { + +OTAProviderExample * exampleOTAProvider = nullptr; +Shell::Engine sSubShell; + +CHIP_ERROR DelayedActionTimeHandler(int argc, char ** argv) +{ + VerifyOrReturnError(argc == 1, CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(exampleOTAProvider != nullptr, CHIP_ERROR_INCORRECT_STATE); + + const uint32_t delay = strtoul(argv[0], nullptr, 10); + exampleOTAProvider->SetDelayedActionTimeSec(delay); + return CHIP_NO_ERROR; +} + +CHIP_ERROR OTAProviderHandler(int argc, char ** argv) +{ + if (argc == 0) + { + sSubShell.ForEachCommand(PrintCommandHelp, nullptr); + return CHIP_NO_ERROR; + } + + CHIP_ERROR error = sSubShell.ExecCommand(argc, argv); + + if (error != CHIP_NO_ERROR) + { + streamer_printf(streamer_get(), "Error: %" CHIP_ERROR_FORMAT "\r\n", error.Format()); + } + + return error; +} +} // namespace + +void OTAProviderCommands::Register() +{ + // These commands can be moved to src/lib/shell/commands/Ota.cpp along with the other OTA commands. + // But as of now only Linux and ESP32 platforms supports OTA provider + + // Register subcommands of the `OTAProvider` commands. + static const shell_command_t subCommands[] = { + { &DelayedActionTimeHandler, "delay", + "Set delayed action time for QueryImageResponse and ApplyUpdateResponse\n" + "Usage: OTAProvider delay " }, + }; + + sSubShell.RegisterCommands(subCommands, ArraySize(subCommands)); + + // Register the root `OTA Provider` command in the top-level shell. + static const shell_command_t otaProviderCommand = { &OTAProviderHandler, "OTAProvider", "OTA Provider commands" }; + + Engine::Root().RegisterCommands(&otaProviderCommand, 1); +} + +// Set Example OTA provider +void OTAProviderCommands::SetExampleOTAProvider(OTAProviderExample * otaProvider) +{ + exampleOTAProvider = otaProvider; +} + +} // namespace Shell +} // namespace chip diff --git a/examples/ota-provider-app/esp32/main/include/OTAProviderCommands.h b/examples/ota-provider-app/esp32/main/include/OTAProviderCommands.h new file mode 100644 index 00000000000000..25eaa0cea6262e --- /dev/null +++ b/examples/ota-provider-app/esp32/main/include/OTAProviderCommands.h @@ -0,0 +1,51 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once +#include + +namespace chip { +namespace Shell { + +class OTAProviderCommands +{ +public: + // delete the copy constructor + OTAProviderCommands(const OTAProviderCommands &) = delete; + // delete the move constructor + OTAProviderCommands(OTAProviderCommands &&) = delete; + // delete the assignment operator + OTAProviderCommands & operator=(const OTAProviderCommands &) = delete; + + static OTAProviderCommands & GetInstance() + { + static OTAProviderCommands instance; + return instance; + } + + // Register the OTA provider commands + void Register(); + + // Set Example OTA provider + void SetExampleOTAProvider(OTAProviderExample * otaProvider); + +private: + OTAProviderCommands() {} +}; + +} // namespace Shell +} // namespace chip diff --git a/examples/ota-provider-app/esp32/main/main.cpp b/examples/ota-provider-app/esp32/main/main.cpp index bd64837a3eb710..7c5ea0aa337e93 100644 --- a/examples/ota-provider-app/esp32/main/main.cpp +++ b/examples/ota-provider-app/esp32/main/main.cpp @@ -17,36 +17,25 @@ #include "CHIPDeviceManager.h" #include "DeviceCallbacks.h" -#include "esp_heap_caps_init.h" #include "esp_log.h" -#include "esp_netif.h" #include "esp_spi_flash.h" #include "esp_spiffs.h" -#include "esp_system.h" -#include "esp_wifi.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" #include "nvs_flash.h" -#include #include -#include - -#include -#include -#include -#include - #include #include - #include +#include +#include #include #include #include +#include using chip::Callback::Callback; using namespace ::chip; +using namespace ::chip::Shell; using namespace ::chip::System; using namespace ::chip::Credentials; using namespace ::chip::DeviceManager; @@ -130,17 +119,6 @@ extern "C" void app_main() { ESP_LOGI(TAG, "OTA Provider!"); - /* Print chip information */ - esp_chip_info_t chip_info; - esp_chip_info(&chip_info); - ESP_LOGI(TAG, "This is ESP32 chip with %d CPU cores, WiFi%s%s, ", chip_info.cores, - (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "", (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : ""); - - ESP_LOGI(TAG, "silicon revision %d, ", chip_info.revision); - - ESP_LOGI(TAG, "%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024), - (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external"); - // Initialize the ESP NVS layer. esp_err_t err = nvs_flash_init(); if (err != ESP_OK) @@ -216,4 +194,10 @@ extern "C" void app_main() } chip::app::Clusters::OTAProvider::SetDelegate(kOtaProviderEndpoint, &otaProvider); + + // Launch a chip shell and register OTA Provider Commands + chip::LaunchShell(); + OTAProviderCommands & otaProviderCommands = OTAProviderCommands::GetInstance(); + otaProviderCommands.SetExampleOTAProvider(&otaProvider); + otaProviderCommands.Register(); } diff --git a/examples/ota-provider-app/esp32/sdkconfig.defaults b/examples/ota-provider-app/esp32/sdkconfig.defaults index aaae13fbb5c092..89258be810acd8 100644 --- a/examples/ota-provider-app/esp32/sdkconfig.defaults +++ b/examples/ota-provider-app/esp32/sdkconfig.defaults @@ -55,3 +55,6 @@ CONFIG_ESPTOOLPY_FLASHSIZE="4MB" # discriminator CONFIG_USE_TEST_SETUP_DISCRIMINATOR=0xF01 + +# Enable chip shell +CONFIG_ENABLE_CHIP_SHELL=y diff --git a/examples/ota-provider-app/linux/main.cpp b/examples/ota-provider-app/linux/main.cpp index 9242ab780e41ce..733d40f35b1283 100644 --- a/examples/ota-provider-app/linux/main.cpp +++ b/examples/ota-provider-app/linux/main.cpp @@ -124,7 +124,8 @@ OptionSet cmdLineOptions = { HandleOptions, cmdLineOptionsDef, "PROGRAM OPTIONS" " -q/--QueryImageBehavior \n" " Status value in the Query Image Response\n" " -d/--DelayedActionTimeSec