From 348671b223b3436e93560b606f5d634f77b0a11d Mon Sep 17 00:00:00 2001 From: Anders Bang Poulsen Date: Thu, 14 Oct 2021 09:05:32 +0200 Subject: [PATCH 01/23] Update pump-app and documentation removing old lock-app code. Added dummy get functions for pressure and flow. Added the possibility to factory reset the device with a longpress on one of the buttons. Updated the .sysconfig file so it can be opened with sysconfig. --- examples/pump-app/cc13x2x7_26x2x7/README.md | 81 ++-- examples/pump-app/cc13x2x7_26x2x7/chip.syscfg | 349 +++++++++--------- .../pump-app/cc13x2x7_26x2x7/main/AppTask.cpp | 210 ++++++++--- .../cc13x2x7_26x2x7/main/PumpManager.cpp | 230 +++++++++--- .../cc13x2x7_26x2x7/main/ZclCallbacks.cpp | 23 +- .../cc13x2x7_26x2x7/main/include/AppEvent.h | 3 +- .../cc13x2x7_26x2x7/main/include/AppTask.h | 4 +- .../main/include/PumpManager.h | 52 ++- .../pump-app/cc13x2x7_26x2x7/main/main.cpp | 6 +- third_party/zap/repo | 2 +- 10 files changed, 615 insertions(+), 345 deletions(-) diff --git a/examples/pump-app/cc13x2x7_26x2x7/README.md b/examples/pump-app/cc13x2x7_26x2x7/README.md index 5b15bef626e2a8..66cc366c337ea3 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/README.md +++ b/examples/pump-app/cc13x2x7_26x2x7/README.md @@ -1,11 +1,11 @@ -# CHIP CC1352 CC2652 Lock Example Application +# Matter CC1352 CC2652 Pump Example Application -An example application showing the use [CHIP][chip] on the Texas Instruments -CC13X2_26X2 family of Wireless MCUs. +An example application showing the use of [Matter][matter] on the Texas +Instruments CC13X2_26X2 family of Wireless MCUs. --- -- [CHIP CC1352 CC2652 Lock Example Application](#chip-cc1352-cc2652-lock-example-application) +- [Matter CC1352 CC2652 Pump Example Application](#matter-cc1352-cc2652-pump-example-application) - [Introduction](#introduction) - [Device UI](#device-ui) - [Building](#building) @@ -19,7 +19,7 @@ CC13X2_26X2 family of Wireless MCUs. - [Provisioning](#provisioning) - [Bluetooth LE Advertising](#bluetooth-le-advertising) - [Bluetooth LE Rendezvous](#bluetooth-le-rendezvous) - - [CHIP Remote Commands](#chip-remote-commands) + - [Matter Remote Commands](#matter-remote-commands) - [TI Support](#ti-support) --- @@ -28,34 +28,35 @@ CC13X2_26X2 family of Wireless MCUs. ![CC1352R1_LAUNCHXL](doc/images/cc1352r1_launchxl.jpg) -The CC13X2_26X2 lock example application provides a working demonstration of a -connected door lock device. This uses the open-source CHIP implementation and -the Texas Instruments SimpleLinkā„¢ CC13x2 and CC26x2 software development kit. +The CC13X2_26X2 pump example application provides a working demonstration of a +connected pump device. This uses the open-source Matter implementation and the +Texas Instruments SimpleLinkā„¢ CC13x2 and CC26x2 software development kit. This example is enabled to build for CC2652R7 devices. This upcoming devices are currently not yet in full production. For more information on device -availability or early access to an engineering build of our CHIP-enabled SDK, -please reach out [here][ti_cc13x2_26x2_r7_chip_request]. +availability or early access to an engineering build of our Matter-enabled SDK, +please reach out [here][ti_cc13x2_26x2_r7_matter_request]. -The lock example is intended to serve both as a means to explore the workings of -CHIP, as well as a template for creating real products based on the Texas +The pump example is intended to serve both as a means to explore the workings of +Matter, as well as a template for creating real products based on the Texas Instruments devices. ## Device UI This example application has a simple User Interface to depict the state of the -door lock and to control the state. The user LEDs on the LaunchPad are set on -when the lock is locked, and are set off when unlocked. The LEDs will flash when -in the transition state between locked and unlocked. +pump and to control the state. The user LEDs on the LaunchPad are set on when +the pump is started, and are set off when stopped. The LEDs will flash when in +the transition state between started and stopped. -Short presses (less than 1000ms) of the user buttons are used for requesting -lock and unlock of the door lock. The left button (`BTN-1`) is used to request -locking. The right button (`BTN-2`) is used to request unlocking. +Short presses (less than 1000ms) of the left user button (`BTN-1`) are used for +toggeling the pump state. -Long presses (greater than 1000ms) of the user buttons are used for controlling -BLE advertisements. The left button (`BTN-1`) is used to disable advertisements -if they are enabled. The Right button (`BTN-2`) is used to enable -advertisements. +Short presses (less than 1000ms) of the right user button (`BTN-2`) are used for +toggeling Matter BLE advertisements. + +Long presses (greater than 5000ms) of the right user button (`BTN-2`) will +initiate a factory reset of the device clearing all stored provisioning +information to allow for a new network setup. ## Building @@ -65,7 +66,7 @@ Some initial setup is necessary for preparing the build environment. This section will need to be done when migrating to new versions of the SDK. - An engineering SDK from TI is required. Please request access for it - [here][ti_cc13x2_26x2_r7_chip_request]. + [here][ti_cc13x2_26x2_r7_matter_request]. - Follow the default installation instructions when executing the installer. @@ -124,7 +125,7 @@ Ninja to build the executable. `C:\ti` ``` - $ cd ~/connectedhomeip/examples/lock-app/cc13x2_26x2 + $ cd ~/connectedhomeip/examples/pump-app/cc13x2_26x2 $ export TI_SIMPLELINK_SDK_ROOT= $ export TI_SYSCONFIG_ROOT= $ gn gen out/debug --args="ti_simplelink_sdk_root=\"${TI_SIMPLELINK_SDK_ROOT}\" ti_sysconfig_root=\"${TI_SYSCONFIG_ROOT}\"" @@ -168,27 +169,27 @@ Router][ot_border_router_setup]. ### Provisioning -The first step to bring the CHIP device onto the network is to provision it. Our -example accomplishes this with Bluetooth Low Energy (BLE) and the +The first step to bring the Matter device onto the network is to provision it. +Our example accomplishes this with Bluetooth Low Energy (BLE) and the [CHIPTool](../../../src/android/CHIPTool/README.md) mobile app. #### Bluetooth LE Advertising To provision this example onto a Thread network, the device must be discoverable -over Bluetooth LE. BLE advertising is started by long pressing the right button -(greater than 1000ms), labeled `BTN-2` on the silkscreen. Once the device is -fully provisioned, BLE advertising will stop. +over Bluetooth LE. BLE advertising is started by pressing the right button (less +than 1000ms), labeled `BTN-2` on the silkscreen. Once the device is fully +provisioned, BLE advertising will stop. #### Bluetooth LE Rendezvous In this example, the provisioning procedure (called Rendezvous) is done over -Bluetooth LE between a CHIP device (lock-app) and the CHIP controller +Bluetooth LE between a Matter device (pump-app) and the Matter controller (CHIPTool), where the controller has the commissioner role. To start the rendezvous, the controller must get the commissioning information -from the CHIP device. +from the Matter device. -This is done by scanning a QR code. A URL will be displayed on the lock-app's +This is done by scanning a QR code. A URL will be displayed on the pump-app's log ([UART terminal](#viewing-logging-output)). It will look like the following: ``` @@ -202,21 +203,21 @@ pre-loaded). Alternatively, you can navigate to [the QR code generator][qr_code_generator] and enter in the payload shown in `SetupQRCode` (in this case `MT:.81TM -00 0C9SS0`). -### CHIP Remote Commands +### Matter Remote Commands -Once the CHIP device is provisioned and operating on the network, CHIPTool can -be used to control the device. During the provisioning process, the CHIP device -would have sent one of its newly assigned IPv6 addresses to the CHIPTool. +Once the Matter device is provisioned and operating on the network, CHIPTool can +be used to control the device. During the provisioning process, the Matter +device would have sent one of its newly assigned IPv6 addresses to the CHIPTool. -In the app, you should see an On/Off cluster; this corresponds to the lock-app. -You can now control the lock-app CHIP device from the smartphone! +In the app, you should see an On/Off cluster; this corresponds to the pump-app. +You can now control the pump-app Matter device from the smartphone! ## TI Support For technical support, please consider creating a post on TI's [E2E forum][e2e]. Additionally, we welcome any feedback. -[chip]: https://github.com/project-chip/connectedhomeip +[matter]: https://github.com/project-chip/connectedhomeip [cc1352r1_launchxl]: https://www.ti.com/tool/LAUNCHXL-CC1352R1 [e2e]: https://e2e.ti.com/support/wireless-connectivity/zigbee-and-thread [simplelink_sdk]: https://www.ti.com/tool/SIMPLELINK-CC13X2-26X2-SDK @@ -227,7 +228,7 @@ Additionally, we welcome any feedback. http://software-dl.ti.com/ccs/esd/sysconfig/sysconfig-1.5.0_1397-setup.run [ti_thread_dnd]: https://www.ti.com/wireless-connectivity/thread/design-development.html -[ti_cc13x2_26x2_r7_chip_request]: https://ti.com/chip_sdk +[ti_cc13x2_26x2_r7_matter_request]: https://ti.com/chip_sdk [ot_border_router_setup]: https://openthread.io/guides/border-router/beaglebone-black [qr_code_generator]: https://dhrishi.github.io/connectedhomeip/qrcode.html diff --git a/examples/pump-app/cc13x2x7_26x2x7/chip.syscfg b/examples/pump-app/cc13x2x7_26x2x7/chip.syscfg index c93e60f4846aaa..38a53e57d500fd 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/chip.syscfg +++ b/examples/pump-app/cc13x2x7_26x2x7/chip.syscfg @@ -17,198 +17,191 @@ * limitations under the License. */ -/* Modules */ -var AESCCM = scripting.addModule("/ti/drivers/AESCCM"); -var AESECB = scripting.addModule("/ti/drivers/AESECB"); -var Button = scripting.addModule("/ti/drivers/apps/Button"); -var ECJPAKE = scripting.addModule("/ti/drivers/ECJPAKE"); -var LED = scripting.addModule("/ti/drivers/apps/LED"); -var NVS = scripting.addModule("/ti/drivers/NVS"); -var RF = scripting.addModule("/ti/drivers/RF"); -var RFDesign = scripting.addModule("ti/devices/radioconfig/rfdesign"); -var RTOS = scripting.addModule("/ti/drivers/RTOS"); -var TRNG = scripting.addModule("/ti/drivers/TRNG"); -var Thread = scripting.addModule("/ti/thread/thread"); -var SHA2 = scripting.addModule("/ti/drivers/SHA2"); -var UART = scripting.addModule("/ti/drivers/UART"); -var ble = scripting.addModule("/ti/ble5stack/ble"); -var dmm = scripting.addModule("/ti/dmm/dmm"); -var AESCTRDRBG = scripting.addModule("/ti/drivers/AESCTRDRBG"); -var ECDH = scripting.addModule("/ti/drivers/ECDH"); - -/* Instances */ -var AESCCM1 = AESCCM.addInstance(); -var AESCCM2 = AESCCM.addInstance(); -var AESECB1 = AESECB.addInstance(); -var AESECB2 = AESECB.addInstance(); -var Button1 = Button.addInstance(); -var Button2 = Button.addInstance(); -var ECJPAKE = ECJPAKE.addInstance(); -var NVS1 = NVS.addInstance(); -var SHA21 = SHA2.addInstance(); -var LED1 = LED.addInstance(); -var LED2 = LED.addInstance(); -var TRNG1 = TRNG.addInstance(); -var TRNG2 = TRNG.addInstance(); -var TRNG3 = TRNG.addInstance(); -var UART1 = UART.addInstance(); -var UART2 = UART.addInstance(); -var AESCTRDRBG1 = AESCTRDRBG.addInstance(); -var ECDH1 = ECDH.addInstance(); -var ECDH2 = ECDH.addInstance(); +/** + * These arguments were used when this file was generated. They will be automatically applied on subsequent loads + * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. + * @cliArgs --board "/ti/boards/CC26X2R1_LAUNCHXL" --product "simplelink_cc13x2_26x2_sdk@4.40.05.02_eng" + * @versions {"tool":"1.9.0+2015","templates":null} + */ -AESCTRDRBG1.$name = "CONFIG_AESCTRDRBG_0"; -AESCTRDRBG1.aesctrObject.$name = "CONFIG_AESCTR_0"; +/** + * Import the modules used in this configuration. + */ +const ble = scripting.addModule("/ti/ble5stack/ble"); +const CCFG = scripting.addModule("/ti/devices/CCFG"); +const rfdesign = scripting.addModule("/ti/devices/radioconfig/rfdesign"); +const dmm = scripting.addModule("/ti/dmm/dmm"); +const AESCCM = scripting.addModule("/ti/drivers/AESCCM"); +const AESCCM1 = AESCCM.addInstance(); +const AESCCM2 = AESCCM.addInstance(); +const AESCTRDRBG = scripting.addModule("/ti/drivers/AESCTRDRBG"); +const AESCTRDRBG1 = AESCTRDRBG.addInstance(); +const AESECB = scripting.addModule("/ti/drivers/AESECB"); +const AESECB1 = AESECB.addInstance(); +const AESECB2 = AESECB.addInstance(); +const ECDH = scripting.addModule("/ti/drivers/ECDH"); +const ECDH1 = ECDH.addInstance(); +const ECDH2 = ECDH.addInstance(); +const ECJPAKE = scripting.addModule("/ti/drivers/ECJPAKE"); +const ECJPAKE1 = ECJPAKE.addInstance(); +const NVS = scripting.addModule("/ti/drivers/NVS"); +const NVS1 = NVS.addInstance(); +const RF = scripting.addModule("/ti/drivers/RF"); +const RTOS = scripting.addModule("/ti/drivers/RTOS"); +const SHA2 = scripting.addModule("/ti/drivers/SHA2"); +const SHA21 = SHA2.addInstance(); +const TRNG = scripting.addModule("/ti/drivers/TRNG"); +const TRNG1 = TRNG.addInstance(); +const TRNG2 = TRNG.addInstance(); +const TRNG3 = TRNG.addInstance(); +const UART = scripting.addModule("/ti/drivers/UART"); +const UART1 = UART.addInstance(); +const UART2 = UART.addInstance(); +const Button = scripting.addModule("/ti/drivers/apps/Button"); +const Button1 = Button.addInstance(); +const Button2 = Button.addInstance(); +const LED = scripting.addModule("/ti/drivers/apps/LED"); +const LED1 = LED.addInstance(); +const LED2 = LED.addInstance(); +const thread = scripting.addModule("/ti/thread/thread"); + +/** + * Write custom configuration values to the imported modules. + */ +ble.maxConnNum = 1; +ble.numOfAdvSets = 1; +ble.lockProject = true; +ble.maxPDUSize = 255; +ble.radioConfig.codeExportConfig.$name = "ti_devices_radioconfig_code_export_param1"; +ble.connUpdateParamsPeripheral.$name = "ti_ble5stack_general_ble_conn_update_params0"; +ble.connUpdateParamsPeripheral.reqMinConnInt = 30; +ble.connUpdateParamsPeripheral.reqMaxConnInt = 50; +ble.advSet1.$name = "ti_ble5stack_broadcaster_advertisement_set0"; +ble.advSet1.advParam1.$name = "ti_ble5stack_broadcaster_advertisement_params0"; +ble.advSet1.advParam1.primIntMax = 200; +ble.advSet1.advData1.$name = "ti_ble5stack_broadcaster_advertisement_data0"; +ble.advSet1.scanRes1.$name = "ti_ble5stack_broadcaster_advertisement_data1"; + +CCFG.enableBootloader = true; +CCFG.enableBootloaderBackdoor = true; +CCFG.dioBootloaderBackdoor = 13; +CCFG.levelBootloaderBackdoor = "Active low"; +CCFG.srcClkLF = "Derived from HF XOSC"; +CCFG.ccfgTemplate.$name = "ti_devices_CCFGTemplate0"; + +dmm.project = "ti_thread_thermostat_remote_display"; +dmm.stackRoles = ["blePeripheral","threadFTD"]; +dmm.lockStackRoles = true; +dmm.numApplicationStates = 10; +dmm.applicationState0 = "ANY"; +dmm.applicationState1 = "DMMPOLICY_BLE_IDLE"; +dmm.applicationState2 = "DMMPOLICY_BLE_ADV"; +dmm.applicationState3 = "DMMPOLICY_BLE_CONNECTING"; +dmm.applicationState4 = "DMMPOLICY_BLE_HIGH_BANDWIDTH"; +dmm.applicationState5 = "DMMPOLICY_BLE_CONNECTED"; +dmm.applicationState6 = "DMMPOLICY_BLE_OAD"; +dmm.applicationState7 = "DMMPOLICY_THREAD_IDLE"; +dmm.applicationState8 = "DMMPOLICY_THREAD_LINK_EST"; +dmm.applicationState9 = "DMMPOLICY_THREAD_DATA"; +dmm.policyArray.create(4); +dmm.policyArray[0].$name = "ti_dmm_policy_dmm_policy0"; +dmm.policyArray[0].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble0"; +dmm.policyArray[0].blePeripheral.applicationStates = ["applicationState6"]; +dmm.policyArray[0].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread0"; +dmm.policyArray[0].threadFTD.pause = "DMMPOLICY_PAUSED"; +dmm.policyArray[1].$name = "ti_dmm_policy_dmm_policy1"; +dmm.policyArray[1].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble1"; +dmm.policyArray[1].blePeripheral.applicationStates = ["applicationState3","applicationState4"]; +dmm.policyArray[1].blePeripheral.weight = 25; +dmm.policyArray[1].blePeripheral.appliedActivity = ["DMMPOLICY_APPLIED_ACTIVITY_BLE_CONNECTION"]; +dmm.policyArray[1].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread1"; +dmm.policyArray[2].$name = "ti_dmm_policy_dmm_policy2"; +dmm.policyArray[2].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble2"; +dmm.policyArray[2].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread2"; +dmm.policyArray[2].threadFTD.weight = 30; +dmm.policyArray[2].threadFTD.applicationStates = ["applicationState8"]; +dmm.policyArray[2].threadFTD.appliedActivity = ["DMMPOLICY_APPLIED_ACTIVITY_ALL"]; +dmm.policyArray[3].$name = "ti_dmm_policy_dmm_policy3"; +dmm.policyArray[3].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble3"; +dmm.policyArray[3].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread3"; +dmm.policyArray[3].threadFTD.weight = 1; AESCCM1.$name = "CONFIG_AESCCM0"; + AESCCM2.$name = "CONFIG_AESCCM_1"; +AESCTRDRBG1.$name = "CONFIG_AESCTRDRBG_0"; +AESCTRDRBG1.aesctrObject.$name = "CONFIG_AESCTR_0"; + AESECB1.$name = "CONFIG_AESECB0"; + AESECB2.$name = "CONFIG_AESECB_1"; ECDH1.$name = "CONFIG_ECDH0"; + ECDH2.$name = "CONFIG_ECDH_1"; -/* RTOS */ -RTOS.name = "FreeRTOS"; +ECJPAKE1.$name = "CONFIG_ECJPAKE_0"; -/* Left Button */ -Button1.$name = "CONFIG_BTN_LEFT"; -Button1.$hardware = system.deviceData.board.components["BTN-1"]; -Button1.gpioPin.$name = "CONFIG_GPIO_BTN1"; -Button1.gpioPin.pull = "Pull Up"; -Button1.gpioPin.interruptTrigger = "Falling Edge"; -Button1.gpioPin.pinInstance.$name = "CONFIG_PIN_BTN1"; - -/* Left Button */ -Button2.$name = "CONFIG_BTN_RIGHT"; -Button2.$hardware = system.deviceData.board.components["BTN-2"]; -Button2.gpioPin.$name = "CONFIG_GPIO_BTN2"; -Button2.gpioPin.pull = "Pull Up"; -Button2.gpioPin.interruptTrigger = "Falling Edge"; -Button2.gpioPin.pinInstance.$name = "CONFIG_PIN_BTN2"; - -/* ======== CCFG ======== */ -var CCFG = scripting.addModule("/ti/devices/CCFG"); -const deviceName = system.getScript("/ti/ti154stack/ti154stack_common.js").getLaunchPadFromDevice(); -const ccfgSettings = system.getScript("/ti/common/lprf_ccfg_settings.js").ccfgSettings; -for(var setting in ccfgSettings) -{ - CCFG[setting] = ccfgSettings[setting]; -} - -// Update LF Clock Source for CC2652RB devices -if(deviceName.includes("RB")) -{ - CCFG.srcClkLF = "Derived from HF XOSC"; -} -/* NVS */ -NVS1.$name = "CONFIG_NVSINTERNAL"; +NVS1.$name = "CONFIG_NVSINTERNAL"; +NVS1.internalFlash.$name = "ti_drivers_nvs_NVSCC26XX0"; NVS1.internalFlash.regionBase = 0x78000; NVS1.internalFlash.regionSize = 0x4000; -/* RF */ -RF.$name = "CONFIG_RF0"; -/* if an antenna component exists, assign it to the rf instance */ -if (system.deviceData.board && system.deviceData.board.components.RF) { - RF.$hardware = system.deviceData.board.components.RF; -} - -const rfDesignSettings = system.getScript("/ti/common/lprf_rf_design_settings.js").rfDesignSettings; -for(var setting in rfDesignSettings) -{ - RFDesign[setting] = rfDesignSettings[setting]; -} - -/* Red LED */ -LED1.$name = "CONFIG_LED_RED"; -LED1.$hardware = system.deviceData.board.components.LED_RED; -LED1.gpioPin.$name = "CONFIG_GPIO_RLED"; -LED1.gpioPin.mode = "Output"; -LED1.gpioPin.callbackFunction = ""; -LED1.gpioPin.pinInstance.$name = "CONFIG_PIN_RLED"; - -/* Green LED */ -LED2.$name = "CONFIG_LED_GREEN"; -LED2.$hardware = system.deviceData.board.components.LED_GREEN; -LED2.gpioPin.$name = "CONFIG_GPIO_GLED"; -LED2.gpioPin.mode = "Output"; -LED2.gpioPin.callbackFunction = ""; -LED2.gpioPin.pinInstance.$name = "CONFIG_PIN_GLED"; - -/* Debug UART */ -UART1.$hardware = system.deviceData.board.components.XDS110UART; -UART1.$name = "CONFIG_UART_DEBUG"; - -/* Display UART */ -UART2.$name = "CONFIG_DISPLAY_UART"; -UART2.uart.txPin.$suggestSolution = "boosterpack.32"; -UART2.uart.rxPin.$suggestSolution = "boosterpack.18"; - -/* TRNG */ -TRNG1.$name = "CONFIG_TRNG_0"; -TRNG2.$name = "CONFIG_TRNG_1"; -TRNG3.$name = "CONFIG_TRNG_APP"; - -/* Thread */ -Thread.deviceType = "ftd"; -Thread.deviceTypeReadOnly = true; -/* Thread SysConfig generated sources are not used until the upstream modules - * can be updated to enable CHIP. - */ RTOS.name = "FreeRTOS"; -/* BLE */ -ble.addressMode = "ADDRMODE_RP_WITH_PUBLIC_ID"; -ble.maxConnNum = 1; -ble.numOfAdvSets = 1; -ble.lockProject = true; -ble.oneLibSizeOpt = true; -ble.maxPDUSize = 255; -ble.radioConfig.codeExportConfig.$name = "ti_devices_radioconfig_code_export_param1"; -ble.connUpdateParamsPeripheral.$name = "ti_ble5stack_general_ble_conn_update_params0"; -ble.connUpdateParamsPeripheral.reqMinConnInt = 30; -ble.connUpdateParamsPeripheral.reqMaxConnInt = 50; - -ble.advSet1.$name = "ti_ble5stack_broadcaster_advertisement_set0"; -ble.advSet1.advParam1.$name = "ti_ble5stack_broadcaster_advertisement_params0"; -ble.advSet1.advParam1.primIntMin = 100; -ble.advSet1.advParam1.primIntMax = 200; - -/* DMM */ -dmm.project = "ti_thread_thermostat_remote_display"; -dmm.stackRoles = ["blePeripheral","threadFTD"]; -dmm.lockStackRoles = true; -dmm.numApplicationStates = 10; -dmm.applicationState0 = "ANY"; -dmm.applicationState1 = "DMMPOLICY_BLE_IDLE"; -dmm.applicationState2 = "DMMPOLICY_BLE_ADV"; -dmm.applicationState3 = "DMMPOLICY_BLE_CONNECTING"; -dmm.applicationState4 = "DMMPOLICY_BLE_HIGH_BANDWIDTH"; -dmm.applicationState5 = "DMMPOLICY_BLE_CONNECTED"; -dmm.applicationState6 = "DMMPOLICY_BLE_OAD"; -dmm.applicationState7 = "DMMPOLICY_THREAD_IDLE"; -dmm.applicationState8 = "DMMPOLICY_THREAD_LINK_EST"; -dmm.applicationState9 = "DMMPOLICY_THREAD_DATA"; -dmm.policyArray.create(4); -dmm.policyArray[0].$name = "ti_dmm_policy_dmm_policy0"; -dmm.policyArray[0].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble0"; -dmm.policyArray[0].blePeripheral.applicationStates = ["applicationState6"]; -dmm.policyArray[0].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread0"; -dmm.policyArray[0].threadFTD.pause = "DMMPOLICY_PAUSED"; -dmm.policyArray[1].$name = "ti_dmm_policy_dmm_policy1"; -dmm.policyArray[1].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble1"; -dmm.policyArray[1].blePeripheral.applicationStates = ["applicationState3","applicationState4"]; -dmm.policyArray[1].blePeripheral.weight = 25; -dmm.policyArray[1].blePeripheral.appliedActivity = ["DMMPOLICY_APPLIED_ACTIVITY_BLE_CONNECTION"]; -dmm.policyArray[1].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread1"; -dmm.policyArray[2].$name = "ti_dmm_policy_dmm_policy2"; -dmm.policyArray[2].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble2"; -dmm.policyArray[2].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread2"; -dmm.policyArray[2].threadFTD.weight = 30; -dmm.policyArray[2].threadFTD.applicationStates = ["applicationState8"]; -dmm.policyArray[2].threadFTD.appliedActivity = ["DMMPOLICY_APPLIED_ACTIVITY_ALL"]; -dmm.policyArray[3].$name = "ti_dmm_policy_dmm_policy3"; -dmm.policyArray[3].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble3"; -dmm.policyArray[3].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread3"; -dmm.policyArray[3].threadFTD.weight = 1; +SHA21.$name = "CONFIG_SHA2_0"; + +TRNG1.$name = "CONFIG_TRNG_0"; + +TRNG2.$name = "CONFIG_TRNG_1"; + +TRNG3.$name = "CONFIG_TRNG_APP"; + +UART1.$name = "CONFIG_UART_DEBUG"; +UART1.uart.$assign = "UART1"; +UART1.uart.txPin.$assign = "boosterpack.4"; +UART1.uart.rxPin.$assign = "boosterpack.3"; +UART1.txPinInstance.$name = "CONFIG_PIN_4"; +UART1.rxPinInstance.$name = "CONFIG_PIN_5"; + +UART2.$name = "CONFIG_DISPLAY_UART"; +UART2.txPinInstance.$name = "CONFIG_PIN_6"; +UART2.rxPinInstance.$name = "CONFIG_PIN_7"; + +Button1.$name = "CONFIG_BTN_LEFT"; +Button1.gpioPin.$name = "CONFIG_GPIO_BTN1"; +Button1.gpioPin.gpioPin.$assign = "boosterpack.32"; +Button1.gpioPin.pinInstance.$name = "CONFIG_PIN_BTN1"; + +Button2.$name = "CONFIG_BTN_RIGHT"; +Button2.gpioPin.$name = "CONFIG_GPIO_BTN2"; +Button2.gpioPin.gpioPin.$assign = "boosterpack.13"; +Button2.gpioPin.pinInstance.$name = "CONFIG_PIN_BTN2"; + +LED1.$name = "CONFIG_LED_RED"; +LED1.gpioPin.$name = "CONFIG_GPIO_RLED"; +LED1.gpioPin.gpioPin.$assign = "boosterpack.10"; +LED1.gpioPin.pinInstance.$name = "CONFIG_PIN_RLED"; + +LED2.$name = "CONFIG_LED_GREEN"; +LED2.gpioPin.$name = "CONFIG_GPIO_GLED"; +LED2.gpioPin.gpioPin.$assign = "boosterpack.39"; +LED2.gpioPin.pinInstance.$name = "CONFIG_PIN_GLED"; + +thread.deviceTypeReadOnly = true; +thread.pm.$name = "ti_thread_pm_thread_pm0"; +thread.rf.$name = "ti_thread_rf_thread_rf0"; +thread.rf.radioConfig.$name = "ti_devices_radioconfig_settings_ieee_15_40"; +thread.rf.radioConfig.codeExportConfig.$name = "ti_devices_radioconfig_code_export_param0"; +thread.network.$name = "ti_thread_network_thread_network0"; +thread.security.$name = "ti_thread_security_thread_security0"; + +/** + * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future + * version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to + * re-solve from scratch. + */ +UART2.uart.$suggestSolution = "UART0"; +UART2.uart.txPin.$suggestSolution = "boosterpack.30"; +UART2.uart.rxPin.$suggestSolution = "boosterpack.29"; diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp index 50a0d017ecfc80..508990b6c9f282 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -22,10 +22,16 @@ #include "AppEvent.h" #include +#include +#include +#include + +#include "FreeRTOS.h" #include #include -#include "FreeRTOS.h" +#include +#include #include #include @@ -33,8 +39,6 @@ #include -//#include - #include #include @@ -84,7 +88,7 @@ int AppTask::StartAppTask() int AppTask::Init() { LED_Params ledParams; - Button_Params buttionParams; + Button_Params buttonParams; ConnectivityManager::ThreadPollingConfig pollingConfig; cc13x2_26x2LogInit(); @@ -167,18 +171,18 @@ int AppTask::Init() PLAT_LOG("Initialize buttons"); Button_init(); - Button_Params_init(&buttionParams); - buttionParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED; - buttionParams.longPressDuration = 1000U; // ms - sAppLeftHandle = Button_open(CONFIG_BTN_LEFT, ButtonLeftEventHandler, &buttionParams); + Button_Params_init(&buttonParams); + buttonParams.buttonEventMask = Button_EV_CLICKED; + buttonParams.longPressDuration = 1000U; // ms + sAppLeftHandle = Button_open(CONFIG_BTN_LEFT, ButtonLeftEventHandler, &buttonParams); - Button_Params_init(&buttionParams); - buttionParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED; - buttionParams.longPressDuration = 1000U; // ms - sAppRightHandle = Button_open(CONFIG_BTN_RIGHT, ButtonRightEventHandler, &buttionParams); + Button_Params_init(&buttonParams); + buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGPRESSED; + buttonParams.longPressDuration = 5000U; // ms + sAppRightHandle = Button_open(CONFIG_BTN_RIGHT, ButtonRightEventHandler, &buttonParams); - // Initialize BoltLock module - PLAT_LOG("Initialize BoltLock"); + // Initialize Pump module + PLAT_LOG("Initialize Pump"); PumpMgr().Init(); PumpMgr().SetCallbacks(ActionInitiated, ActionCompleted); @@ -224,10 +228,7 @@ void AppTask::ButtonLeftEventHandler(Button_Handle handle, Button_EventMask even { event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; } - else if (events & Button_EV_LONGCLICKED) - { - event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked; - } + // button callbacks are in ISR context if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) { @@ -244,9 +245,9 @@ void AppTask::ButtonRightEventHandler(Button_Handle handle, Button_EventMask eve { event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; } - else if (events & Button_EV_LONGCLICKED) + else if (events & Button_EV_LONGPRESSED) { - event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked; + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongPressed; } // button callbacks are in ISR context if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) @@ -257,16 +258,16 @@ void AppTask::ButtonRightEventHandler(Button_Handle handle, Button_EventMask eve void AppTask::ActionInitiated(PumpManager::Action_t aAction, int32_t aActor) { - // If the action has been initiated by the lock, update the bolt lock trait + // If the action has been initiated by the pump, update the pump trait // and start flashing the LEDs rapidly to indicate action initiation. - if (aAction == PumpManager::LOCK_ACTION) + if (aAction == PumpManager::START_ACTION) { - PLAT_LOG("Lock initiated"); + PLAT_LOG("Pump start initiated"); ; // TODO } - else if (aAction == PumpManager::UNLOCK_ACTION) + else if (aAction == PumpManager::STOP_ACTION) { - PLAT_LOG("Unlock initiated"); + PLAT_LOG("Stop initiated"); ; // TODO } @@ -278,20 +279,20 @@ void AppTask::ActionInitiated(PumpManager::Action_t aAction, int32_t aActor) void AppTask::ActionCompleted(PumpManager::Action_t aAction) { - // if the action has been completed by the lock, update the bolt lock trait. - // Turn on the lock LED if in a LOCKED state OR - // Turn off the lock LED if in an UNLOCKED state. - if (aAction == PumpManager::LOCK_ACTION) + // if the action has been completed by the pump, update the pump trait. + // Turn on the pump state LED if in a STARTED state OR + // Turn off the pump state LED if in an STOPPED state. + if (aAction == PumpManager::START_ACTION) { - PLAT_LOG("Lock completed"); + PLAT_LOG("Pump start completed"); LED_stopBlinking(sAppGreenHandle); LED_setOn(sAppGreenHandle, LED_BRIGHTNESS_MAX); LED_stopBlinking(sAppRedHandle); LED_setOn(sAppRedHandle, LED_BRIGHTNESS_MAX); } - else if (aAction == PumpManager::UNLOCK_ACTION) + else if (aAction == PumpManager::STOP_ACTION) { - PLAT_LOG("Unlock completed"); + PLAT_LOG("Pump stop completed"); LED_stopBlinking(sAppGreenHandle); LED_setOff(sAppGreenHandle); LED_stopBlinking(sAppRedHandle); @@ -306,18 +307,14 @@ void AppTask::DispatchEvent(AppEvent * aEvent) case AppEvent::kEventType_ButtonLeft: if (AppEvent::kAppEventButtonType_Clicked == aEvent->ButtonEvent.Type) { - if (!PumpMgr().IsUnlocked()) + // Toggle Pump state + if (!PumpMgr().IsStopped()) { - PumpMgr().InitiateAction(0, PumpManager::UNLOCK_ACTION); + PumpMgr().InitiateAction(0, PumpManager::STOP_ACTION); } - } - else if (AppEvent::kAppEventButtonType_LongClicked == aEvent->ButtonEvent.Type) - { - // Disable BLE advertisements - if (ConnectivityMgr().IsBLEAdvertisingEnabled()) + else { - ConnectivityMgr().SetBLEAdvertisingEnabled(false); - PLAT_LOG("Disabled BLE Advertisements"); + PumpMgr().InitiateAction(0, PumpManager::START_ACTION); } } break; @@ -325,14 +322,7 @@ void AppTask::DispatchEvent(AppEvent * aEvent) case AppEvent::kEventType_ButtonRight: if (AppEvent::kAppEventButtonType_Clicked == aEvent->ButtonEvent.Type) { - if (PumpMgr().IsUnlocked()) - { - PumpMgr().InitiateAction(0, PumpManager::LOCK_ACTION); - } - } - else if (AppEvent::kAppEventButtonType_LongClicked == aEvent->ButtonEvent.Type) - { - // Enable BLE advertisements + // Toggle BLE advertisements if (!ConnectivityMgr().IsBLEAdvertisingEnabled()) { if (chip::Server::GetInstance().GetCommissioningWindowManager().OpenBasicCommissioningWindow() == CHIP_NO_ERROR) @@ -344,6 +334,16 @@ void AppTask::DispatchEvent(AppEvent * aEvent) PLAT_LOG("OpenBasicCommissioningWindow() failed"); } } + else + { + // Disable BLE advertisements + ConnectivityMgr().SetBLEAdvertisingEnabled(false); + PLAT_LOG("Disabled BLE Advertisements"); + } + } + else if (AppEvent::kAppEventButtonType_LongPressed == aEvent->ButtonEvent.Type) + { + ConfigurationMgr().InitiateFactoryReset(); } break; @@ -359,3 +359,115 @@ void AppTask::DispatchEvent(AppEvent * aEvent) break; } } + +void AppTask::UpdateClusterState() +{ + EmberStatus status; + + ChipLogProgress(NotSpecified, "UpdateClusterState"); + + // write the new values + int16_t maxPressure = PumpMgr().GetMaxPressure(); + status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MAX_PRESSURE_ATTRIBUTE_ID, + (uint8_t *) &maxPressure, ZCL_INT16S_ATTRIBUTE_TYPE); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxPressure %" PRIx8, status); + } + + uint16_t maxSpeed = PumpMgr().GetMaxSpeed(); + status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MAX_SPEED_ATTRIBUTE_ID, (uint8_t *) &maxSpeed, + ZCL_INT16U_ATTRIBUTE_TYPE); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxSpeed %" PRIx8, status); + } + + uint16_t maxFlow = PumpMgr().GetMaxFlow(); + status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MAX_FLOW_ATTRIBUTE_ID, (uint8_t *) &maxFlow, + ZCL_INT16U_ATTRIBUTE_TYPE); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxFlow %" PRIx8, status); + } + + int16_t minConstPress = PumpMgr().GetMinConstPressure(); + status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MIN_CONST_PRESSURE_ATTRIBUTE_ID, + (uint8_t *) &minConstPress, ZCL_INT16S_ATTRIBUTE_TYPE); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MinConstPressure %" PRIx8, status); + } + + int16_t maxConstPress = PumpMgr().GetMaxConstPressure(); + status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MAX_CONST_PRESSURE_ATTRIBUTE_ID, + (uint8_t *) &maxConstPress, ZCL_INT16S_ATTRIBUTE_TYPE); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxConstPressure %" PRIx8, status); + } + + int16_t minCompPress = PumpMgr().GetMinCompPressure(); + status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MIN_COMP_PRESSURE_ATTRIBUTE_ID, + (uint8_t *) &minCompPress, ZCL_INT16S_ATTRIBUTE_TYPE); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MinCompPressure %" PRIx8, status); + } + + int16_t maxCompPress = PumpMgr().GetMaxCompPressure(); + status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MAX_COMP_PRESSURE_ATTRIBUTE_ID, + (uint8_t *) &maxCompPress, ZCL_INT16S_ATTRIBUTE_TYPE); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxCompPressure %" PRIx8, status); + } + + uint16_t minConstSpeed = PumpMgr().GetMinConstSpeed(); + status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MIN_CONST_SPEED_ATTRIBUTE_ID, + (uint8_t *) &minConstSpeed, ZCL_INT16U_ATTRIBUTE_TYPE); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MinConstSpeed %" PRIx8, status); + } + + uint16_t maxConstSpeed = PumpMgr().GetMaxConstSpeed(); + status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MAX_CONST_SPEED_ATTRIBUTE_ID, + (uint8_t *) &maxConstSpeed, ZCL_INT16U_ATTRIBUTE_TYPE); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxConstSpeed %" PRIx8, status); + } + + uint16_t minConstFlow = PumpMgr().GetMinConstFlow(); + status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MIN_CONST_FLOW_ATTRIBUTE_ID, + (uint8_t *) &minConstFlow, ZCL_INT16U_ATTRIBUTE_TYPE); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MinConstFlow %" PRIx8, status); + } + + uint16_t maxConstFlow = PumpMgr().GetMaxConstFlow(); + status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MAX_CONST_FLOW_ATTRIBUTE_ID, + (uint8_t *) &maxConstFlow, ZCL_INT16U_ATTRIBUTE_TYPE); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxConstFlow %" PRIx8, status); + } + + int16_t minConstTemp = PumpMgr().GetMinConstTemp(); + status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MIN_CONST_TEMP_ATTRIBUTE_ID, + (uint8_t *) &minConstTemp, ZCL_INT16S_ATTRIBUTE_TYPE); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MinConstTemp %" PRIx8, status); + } + + int16_t maxConstTemp = PumpMgr().GetMaxConstTemp(); + status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MAX_CONST_TEMP_ATTRIBUTE_ID, + (uint8_t *) &maxConstTemp, ZCL_INT16S_ATTRIBUTE_TYPE); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxConstTemp %" PRIx8, status); + } +} diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/PumpManager.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/PumpManager.cpp index 7869171d77f1f0..73e638fcceb348 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/PumpManager.cpp +++ b/examples/pump-app/cc13x2x7_26x2x7/main/PumpManager.cpp @@ -25,7 +25,7 @@ #define ACTUATOR_MOVEMENT_PERIOS_MS 500 -PumpManager PumpManager::sLock; +PumpManager PumpManager::sPump; int PumpManager::Init() { @@ -34,15 +34,15 @@ int PumpManager::Init() mTimerHandle = xTimerCreate("BLT_TIMER", pdMS_TO_TICKS(ACTUATOR_MOVEMENT_PERIOS_MS), pdFALSE, this, TimerEventHandler); if (NULL == mTimerHandle) { - PLAT_LOG("failed to create bolt lock timer"); + PLAT_LOG("failed to create pump timer"); while (1) ; } - mState = kState_LockingCompleted; - mAutoLockTimerArmed = false; - mAutoRelock = false; - mAutoLockDuration = 0; + mState = kState_StopCompleted; + mAutoStartTimerArmed = false; + mAutoRestart = false; + mAutoStartDuration = 0; return ret; } @@ -55,22 +55,22 @@ void PumpManager::SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callba bool PumpManager::IsActionInProgress() { - return (mState == kState_LockingInitiated || mState == kState_UnlockingInitiated); + return (mState == kState_StartInitiated || mState == kState_StopInitiated); } -bool PumpManager::IsUnlocked() +bool PumpManager::IsStopped() { - return (mState == kState_UnlockingCompleted); + return (mState == kState_StopCompleted); } -void PumpManager::EnableAutoRelock(bool aOn) +void PumpManager::EnableAutoRestart(bool aOn) { - mAutoRelock = aOn; + mAutoRestart = aOn; } -void PumpManager::SetAutoLockDuration(uint32_t aDurationInSecs) +void PumpManager::SetAutoStartDuration(uint32_t aDurationInSecs) { - mAutoLockDuration = aDurationInSecs; + mAutoStartDuration = aDurationInSecs; } bool PumpManager::InitiateAction(int32_t aActor, Action_t aAction) @@ -78,32 +78,32 @@ bool PumpManager::InitiateAction(int32_t aActor, Action_t aAction) bool action_initiated = false; State_t new_state; - // Initiate Lock/Unlock Action only when the previous one is complete. - if (mState == kState_LockingCompleted && aAction == UNLOCK_ACTION) + // Initiate Start/Stop Action only when the previous one is complete. + if (mState == kState_StartCompleted && aAction == STOP_ACTION) { action_initiated = true; - new_state = kState_UnlockingInitiated; + new_state = kState_StopInitiated; } - else if (mState == kState_UnlockingCompleted && aAction == LOCK_ACTION) + else if (mState == kState_StopCompleted && aAction == START_ACTION) { action_initiated = true; - new_state = kState_LockingInitiated; + new_state = kState_StartInitiated; } if (action_initiated) { - if (mAutoLockTimerArmed && new_state == kState_LockingInitiated) + if (mAutoStartTimerArmed && new_state == kState_StartInitiated) { - // If auto lock timer has been armed and someone initiates locking, + // If auto start timer has been armed and someone initiates start, // cancel the timer and continue as normal. - mAutoLockTimerArmed = false; + mAutoStartTimerArmed = false; CancelTimer(); } - StartTimer(ACTUATOR_MOVEMENT_PERIOS_MS); + PumpTimer(ACTUATOR_MOVEMENT_PERIOS_MS); // Since the timer started successfully, update the state and trigger callback mState = new_state; @@ -117,7 +117,7 @@ bool PumpManager::InitiateAction(int32_t aActor, Action_t aAction) return action_initiated; } -void PumpManager::StartTimer(uint32_t aTimeoutMs) +void PumpManager::PumpTimer(uint32_t aTimeoutMs) { xTimerChangePeriod(mTimerHandle, pdMS_TO_TICKS(aTimeoutMs), 100); xTimerStart(mTimerHandle, 100); @@ -130,17 +130,17 @@ void PumpManager::CancelTimer(void) void PumpManager::TimerEventHandler(TimerHandle_t aTimer) { - PumpManager * lock = static_cast(pvTimerGetTimerID(aTimer)); + PumpManager * pump = static_cast(pvTimerGetTimerID(aTimer)); // The timer event handler will be called in the context of the timer task - // once sLockTimer expires. Post an event to apptask queue with the actual handler + // once sPumpTimer expires. Post an event to apptask queue with the actual handler // so that the event can be handled in the context of the apptask. AppEvent event; - event.Type = AppEvent::kEventType_AppEvent; - event.BoltLockEvent.Context = static_cast(lock); - if (lock->mAutoLockTimerArmed) + event.Type = AppEvent::kEventType_AppEvent; + event.PumpStateEvent.Context = static_cast(pump); + if (pump->mAutoStartTimerArmed) { - event.Handler = AutoReLockTimerEventHandler; + event.Handler = AutoRestartTimerEventHandler; } else { @@ -149,56 +149,186 @@ void PumpManager::TimerEventHandler(TimerHandle_t aTimer) GetAppTask().PostEvent(&event); } -void PumpManager::AutoReLockTimerEventHandler(AppEvent * aEvent) +void PumpManager::AutoRestartTimerEventHandler(AppEvent * aEvent) { - PumpManager * lock = static_cast(aEvent->BoltLockEvent.Context); + PumpManager * pump = static_cast(aEvent->PumpStateEvent.Context); int32_t actor = 0; - // Make sure auto lock timer is still armed. - if (!lock->mAutoLockTimerArmed) + // Make sure auto start timer is still armed. + if (!pump->mAutoStartTimerArmed) { return; } - lock->mAutoLockTimerArmed = false; + pump->mAutoStartTimerArmed = false; - PLAT_LOG("Auto Re-Lock has been triggered!"); + PLAT_LOG("Auto Re-Start has been triggered!"); - lock->InitiateAction(actor, LOCK_ACTION); + pump->InitiateAction(actor, START_ACTION); } void PumpManager::ActuatorMovementTimerEventHandler(AppEvent * aEvent) { Action_t actionCompleted = INVALID_ACTION; - PumpManager * lock = static_cast(aEvent->BoltLockEvent.Context); + PumpManager * pump = static_cast(aEvent->PumpStateEvent.Context); - if (lock->mState == kState_LockingInitiated) + if (pump->mState == kState_StartInitiated) { - lock->mState = kState_LockingCompleted; - actionCompleted = LOCK_ACTION; + pump->mState = kState_StartCompleted; + actionCompleted = START_ACTION; } - else if (lock->mState == kState_UnlockingInitiated) + else if (pump->mState == kState_StopInitiated) { - lock->mState = kState_UnlockingCompleted; - actionCompleted = UNLOCK_ACTION; + pump->mState = kState_StopCompleted; + actionCompleted = STOP_ACTION; } if (actionCompleted != INVALID_ACTION) { - if (lock->mActionCompleted_CB) + if (pump->mActionCompleted_CB) { - lock->mActionCompleted_CB(actionCompleted); + pump->mActionCompleted_CB(actionCompleted); } - if (lock->mAutoRelock && actionCompleted == UNLOCK_ACTION) + if (pump->mAutoRestart && actionCompleted == STOP_ACTION) { - // Start the timer for auto relock - lock->StartTimer(lock->mAutoLockDuration * 1000); + // Start the timer for auto restart + pump->PumpTimer(pump->mAutoStartDuration * 1000); - lock->mAutoLockTimerArmed = true; + pump->mAutoStartTimerArmed = true; - PLAT_LOG("Auto Re-lock enabled. Will be triggered in %u seconds", lock->mAutoLockDuration); + PLAT_LOG("Auto Re-start enabled. Will be triggered in %u seconds", pump->mAutoStartDuration); } } } + +int16_t PumpManager::GetMaxPressure() +{ + // 1.6.1. MaxPressure Attribute + // Range -3276.7 kPa to 3276.7 kPa (steps of 0.1 kPa) + // -3276.8 is invalid value - perhaps 'null' + + // Return 2000.0 kPa as Max Pressure + return 20000; +} + +uint16_t PumpManager::GetMaxSpeed() +{ + // 1.6.2. MaxSpeed Attribute + // Range 0 RPM to 65534 RPM (steps of 1 RPM) + // 65535 is invalid value - perhaps 'null' + + // Return 1000 RPM as MaxSpeed + return 1000; +} + +uint16_t PumpManager::GetMaxFlow() +{ + // 1.6.3. MaxFlow Attribute + // Range 0 m3/h to 6553.4 m3/h (steps of 0.1 m3/h) + // 6553.5 m3/h is invalid value - perhaps 'null' + + // Return 200.0 m3/h as MaxFlow + return 2000; +} + +int16_t PumpManager::GetMinConstPressure() +{ + // 1.6.4. MinConstPressure Attribute + // Range -3276.7 kPa to 3276.7 kPa (steps of 0.1 kPa) + // -3276.8 is invalid value - perhaps 'null' + + // Return -100.0 kPa as MinConstPressure + return -1000; +} + +int16_t PumpManager::GetMaxConstPressure() +{ + // 1.6.5. MaxConstPressure Attribute + // Range -3276.7 kPa to 3276.7 kPa (steps of 0.1 kPa) + // -3276.8 is invalid value - perhaps 'null' + + // Return 100.0 kPa as MaxConstPressure + return 1000; +} + +int16_t PumpManager::GetMinCompPressure() +{ + // 1.6.6. MinCompPressure Attribute + // Range -3276.7 kPa to 3276.7 kPa (steps of 0.1 kPa) + // -3276.8 is invalid value - perhaps 'null' + + // Return -20.0 kPa as MinCompPressure + return -200; +} + +int16_t PumpManager::GetMaxCompPressure() +{ + // 1.6.7. MaxCompPressure Attribute + // Range -3276.7 kPa to 3276.7 kPa (steps of 0.1 kPa) + // -3276.8 is invalid value - perhaps 'null' + + // Return 20.0 kPa as MaxCompPressure + return 200; +} + +uint16_t PumpManager::GetMinConstSpeed() +{ + // 1.6.8. MinConstSpeed Attribute + // Range 0 to 65534 RPM (steps of 1 RPM) + // 65535 RPM is invalid valud - perhaps 'null' + + // Return 200 RPM as MinConstSpeed + return 200; +} + +uint16_t PumpManager::GetMaxConstSpeed() +{ + // 1.6.9. MaxConstSpeed Attribute + // Range 0 to 65534 RPM (steps of 1 RPM) + // 65535 RPM is invalid valud - perhaps 'null' + + // Return 2000 RPM as MaxConstSpeed + return 2000; +} + +uint16_t PumpManager::GetMinConstFlow() +{ + // 1.6.10. MinConstFlow Attribute + // Range 0 m3/h to 6553.4 m3/h (steps of 0.1 m3/h) + // 6553.5 m3/h is invalid value - perhaps 'null' + + // Return 12.5 m3/h as MinConstFlow + return 125; +} + +uint16_t PumpManager::GetMaxConstFlow() +{ + // 1.6.11. MaxConstFlow Attribute + // Range 0 m3/h to 6553.4 m3/h (steps of 0.1 m3/h) + // 6553.5 m3/h is invalid value - perhaps 'null' + + // Return 655.7 m3/h as MaxConstFlow + return 6557; +} + +int16_t PumpManager::GetMinConstTemp() +{ + // 1.6.12. MinConstTemp Attribute + // Range -273.15 C to 327.67 C (steps of 0.01 C) + // All other values are invalid values - perhaps 'null' + + // Return 30.00 C as MinConstTemp + return 3000; +} + +int16_t PumpManager::GetMaxConstTemp() +{ + // 1.6.13. MaxConstTemp Attribute + // Range -273.15 C to 327.67 C (steps of 0.01 C) + // All other values are invalid values - perhaps 'null' + + // Return 56.00 C as MaxConstTemp + return 5600; +} diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp index 8d4abc4858c4a1..902ddf83b96758 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp +++ b/examples/pump-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp @@ -15,7 +15,10 @@ * limitations under the License. */ +#include + #include "AppConfig.h" +#include "AppTask.h" #include "PumpManager.h" #include @@ -31,7 +34,17 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & { if (attributePath.mClusterId == OnOff::Id && attributePath.mAttributeId == OnOff::Attributes::OnOff::Id) { - PumpMgr().InitiateAction(0, *value ? PumpManager::LOCK_ACTION : PumpManager::UNLOCK_ACTION); + PumpMgr().InitiateAction(0, *value ? PumpManager::START_ACTION : PumpManager::STOP_ACTION); + } + else if (attributePath.mClusterId == LevelControl::Id && + attributePath.mAttributeId == LevelControl::Attributes::CurrentLevel::Id) + { + ChipLogProgress(Zcl, "[pump-app] Cluster LevelControl: attribute CurrentLevel set to %" PRIu8, *value); + } + else + { + ChipLogProgress(Zcl, "Unknown attribute ID: " ChipLogFormatMEI, ChipLogValueMEI(attributePath.mAttributeId)); + return; } } @@ -52,5 +65,11 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & */ void emberAfOnOffClusterInitCallback(EndpointId endpoint) { - // TODO: implement any additional Cluster Server init actions + GetAppTask().UpdateClusterState(); } + +void emberAfPumpConfigurationAndControlClusterInitCallback(chip::EndpointId endpoint) +{ + // TODO: Setup the default values in the cluster for this specific application + GetAppTask().UpdateClusterState(); +} \ No newline at end of file diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/include/AppEvent.h b/examples/pump-app/cc13x2x7_26x2x7/main/include/AppEvent.h index ad9e93ee3ad1a5..14c9f045231e2a 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/include/AppEvent.h +++ b/examples/pump-app/cc13x2x7_26x2x7/main/include/AppEvent.h @@ -37,6 +37,7 @@ struct AppEvent kAppEventButtonType_None = 0, kAppEventButtonType_Clicked, kAppEventButtonType_LongClicked, + kAppEventButtonType_LongPressed, }; enum AppEventType Type; @@ -51,7 +52,7 @@ struct AppEvent struct { void * Context; - } BoltLockEvent; + } PumpStateEvent; }; EventHandler Handler; diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h b/examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h index 7c6345e1bd9c26..65fb71df49adc9 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h +++ b/examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h @@ -37,15 +37,15 @@ class AppTask int StartAppTask(); static void AppTaskMain(void * pvParameter); - void PostLockActionRequest(int32_t aActor, PumpManager::Action_t aAction); + void PostStartActionRequest(int32_t aActor, PumpManager::Action_t aAction); void PostEvent(const AppEvent * event); + void UpdateClusterState(); private: friend AppTask & GetAppTask(void); int Init(); - // should this be done by BoltLock Manager? I don't want to unravel this spaghetti quite yet static void ActionInitiated(PumpManager::Action_t aAction, int32_t aActor); static void ActionCompleted(PumpManager::Action_t aAction); diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/include/PumpManager.h b/examples/pump-app/cc13x2x7_26x2x7/main/include/PumpManager.h index ec83d508f91c1e..62988216fec1fb 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/include/PumpManager.h +++ b/examples/pump-app/cc13x2x7_26x2x7/main/include/PumpManager.h @@ -16,8 +16,8 @@ * limitations under the License. */ -#ifndef LOCK_MANAGER_H -#define LOCK_MANAGER_H +#ifndef PUMP_MANAGER_H +#define PUMP_MANAGER_H #include #include @@ -32,27 +32,41 @@ class PumpManager public: enum Action_t { - LOCK_ACTION = 0, - UNLOCK_ACTION, + START_ACTION = 0, + STOP_ACTION, INVALID_ACTION } Action; enum State_t { - kState_LockingInitiated = 0, - kState_LockingCompleted, - kState_UnlockingInitiated, - kState_UnlockingCompleted, + kState_StartInitiated = 0, + kState_StartCompleted, + kState_StopInitiated, + kState_StopCompleted, } State; int Init(); - bool IsUnlocked(); - void EnableAutoRelock(bool aOn); - void SetAutoLockDuration(uint32_t aDurationInSecs); + bool IsStopped(); + void EnableAutoRestart(bool aOn); + void SetAutoStartDuration(uint32_t aDurationInSecs); bool IsActionInProgress(); bool InitiateAction(int32_t aActor, Action_t aAction); + int16_t GetMaxPressure(); + uint16_t GetMaxSpeed(); + uint16_t GetMaxFlow(); + int16_t GetMinConstPressure(); + int16_t GetMaxConstPressure(); + int16_t GetMinCompPressure(); + int16_t GetMaxCompPressure(); + uint16_t GetMinConstSpeed(); + uint16_t GetMaxConstSpeed(); + uint16_t GetMinConstFlow(); + uint16_t GetMaxConstFlow(); + int16_t GetMinConstTemp(); + int16_t GetMaxConstTemp(); + typedef void (*Callback_fn_initiated)(Action_t, int32_t aActor); typedef void (*Callback_fn_completed)(Action_t); void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); @@ -64,24 +78,24 @@ class PumpManager Callback_fn_initiated mActionInitiated_CB; Callback_fn_completed mActionCompleted_CB; - bool mAutoRelock; - uint32_t mAutoLockDuration; - bool mAutoLockTimerArmed; + bool mAutoRestart; + uint32_t mAutoStartDuration; + bool mAutoStartTimerArmed; TimerHandle_t mTimerHandle; void CancelTimer(void); - void StartTimer(uint32_t aTimeoutMs); + void PumpTimer(uint32_t aTimeoutMs); static void TimerEventHandler(TimerHandle_t aTimer); - static void AutoReLockTimerEventHandler(AppEvent * aEvent); + static void AutoRestartTimerEventHandler(AppEvent * aEvent); static void ActuatorMovementTimerEventHandler(AppEvent * aEvent); - static PumpManager sLock; + static PumpManager sPump; }; inline PumpManager & PumpMgr(void) { - return PumpManager::sLock; + return PumpManager::sPump; } -#endif // LOCK_MANAGER_H +#endif // PUMP_MANAGER_H diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/main.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/main.cpp index 1ed5409a721cce..3cda02fd8b05b0 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/main.cpp +++ b/examples/pump-app/cc13x2x7_26x2x7/main/main.cpp @@ -37,7 +37,7 @@ #include #include -#define TOTAL_ICALL_HEAP_SIZE (0xf000) +#define TOTAL_ICALL_HEAP_SIZE (0xE000) using namespace ::chip; using namespace ::chip::Inet; @@ -77,8 +77,8 @@ int main(void) SHA2_init(); - CHIP_ERROR ret = GetAppTask().StartAppTask(); - if (ret != CHIP_NO_ERROR) + int ret = GetAppTask().StartAppTask(); + if (ret != 0) { // can't log until the kernel is started // PLAT_LOG("GetAppTask().StartAppTask() failed"); diff --git a/third_party/zap/repo b/third_party/zap/repo index 085c08cd1f8ce0..85d174c67697c6 160000 --- a/third_party/zap/repo +++ b/third_party/zap/repo @@ -1 +1 @@ -Subproject commit 085c08cd1f8ce016318c3ec5972756b9d264a553 +Subproject commit 85d174c67697c6e45a632669d2f846030aad9237 From cf7e3dbe51aa3d6191273434899c807e2733643a Mon Sep 17 00:00:00 2001 From: Anders Bang Poulsen Date: Thu, 14 Oct 2021 09:16:18 +0200 Subject: [PATCH 02/23] Restyled --- .../pump-app/cc13x2x7_26x2x7/main/AppTask.cpp | 22 +++++++++---------- third_party/wifi-ism43362/repo | 1 + 2 files changed, 12 insertions(+), 11 deletions(-) create mode 160000 third_party/wifi-ism43362/repo diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp index 508990b6c9f282..ba4323c79195f5 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -369,7 +369,7 @@ void AppTask::UpdateClusterState() // write the new values int16_t maxPressure = PumpMgr().GetMaxPressure(); status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MAX_PRESSURE_ATTRIBUTE_ID, - (uint8_t *) &maxPressure, ZCL_INT16S_ATTRIBUTE_TYPE); + (uint8_t *) &maxPressure, ZCL_INT16S_ATTRIBUTE_TYPE); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxPressure %" PRIx8, status); @@ -393,7 +393,7 @@ void AppTask::UpdateClusterState() int16_t minConstPress = PumpMgr().GetMinConstPressure(); status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MIN_CONST_PRESSURE_ATTRIBUTE_ID, - (uint8_t *) &minConstPress, ZCL_INT16S_ATTRIBUTE_TYPE); + (uint8_t *) &minConstPress, ZCL_INT16S_ATTRIBUTE_TYPE); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MinConstPressure %" PRIx8, status); @@ -401,7 +401,7 @@ void AppTask::UpdateClusterState() int16_t maxConstPress = PumpMgr().GetMaxConstPressure(); status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MAX_CONST_PRESSURE_ATTRIBUTE_ID, - (uint8_t *) &maxConstPress, ZCL_INT16S_ATTRIBUTE_TYPE); + (uint8_t *) &maxConstPress, ZCL_INT16S_ATTRIBUTE_TYPE); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxConstPressure %" PRIx8, status); @@ -409,7 +409,7 @@ void AppTask::UpdateClusterState() int16_t minCompPress = PumpMgr().GetMinCompPressure(); status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MIN_COMP_PRESSURE_ATTRIBUTE_ID, - (uint8_t *) &minCompPress, ZCL_INT16S_ATTRIBUTE_TYPE); + (uint8_t *) &minCompPress, ZCL_INT16S_ATTRIBUTE_TYPE); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MinCompPressure %" PRIx8, status); @@ -417,7 +417,7 @@ void AppTask::UpdateClusterState() int16_t maxCompPress = PumpMgr().GetMaxCompPressure(); status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MAX_COMP_PRESSURE_ATTRIBUTE_ID, - (uint8_t *) &maxCompPress, ZCL_INT16S_ATTRIBUTE_TYPE); + (uint8_t *) &maxCompPress, ZCL_INT16S_ATTRIBUTE_TYPE); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxCompPressure %" PRIx8, status); @@ -425,7 +425,7 @@ void AppTask::UpdateClusterState() uint16_t minConstSpeed = PumpMgr().GetMinConstSpeed(); status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MIN_CONST_SPEED_ATTRIBUTE_ID, - (uint8_t *) &minConstSpeed, ZCL_INT16U_ATTRIBUTE_TYPE); + (uint8_t *) &minConstSpeed, ZCL_INT16U_ATTRIBUTE_TYPE); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MinConstSpeed %" PRIx8, status); @@ -433,7 +433,7 @@ void AppTask::UpdateClusterState() uint16_t maxConstSpeed = PumpMgr().GetMaxConstSpeed(); status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MAX_CONST_SPEED_ATTRIBUTE_ID, - (uint8_t *) &maxConstSpeed, ZCL_INT16U_ATTRIBUTE_TYPE); + (uint8_t *) &maxConstSpeed, ZCL_INT16U_ATTRIBUTE_TYPE); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxConstSpeed %" PRIx8, status); @@ -441,7 +441,7 @@ void AppTask::UpdateClusterState() uint16_t minConstFlow = PumpMgr().GetMinConstFlow(); status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MIN_CONST_FLOW_ATTRIBUTE_ID, - (uint8_t *) &minConstFlow, ZCL_INT16U_ATTRIBUTE_TYPE); + (uint8_t *) &minConstFlow, ZCL_INT16U_ATTRIBUTE_TYPE); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MinConstFlow %" PRIx8, status); @@ -449,7 +449,7 @@ void AppTask::UpdateClusterState() uint16_t maxConstFlow = PumpMgr().GetMaxConstFlow(); status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MAX_CONST_FLOW_ATTRIBUTE_ID, - (uint8_t *) &maxConstFlow, ZCL_INT16U_ATTRIBUTE_TYPE); + (uint8_t *) &maxConstFlow, ZCL_INT16U_ATTRIBUTE_TYPE); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxConstFlow %" PRIx8, status); @@ -457,7 +457,7 @@ void AppTask::UpdateClusterState() int16_t minConstTemp = PumpMgr().GetMinConstTemp(); status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MIN_CONST_TEMP_ATTRIBUTE_ID, - (uint8_t *) &minConstTemp, ZCL_INT16S_ATTRIBUTE_TYPE); + (uint8_t *) &minConstTemp, ZCL_INT16S_ATTRIBUTE_TYPE); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MinConstTemp %" PRIx8, status); @@ -465,7 +465,7 @@ void AppTask::UpdateClusterState() int16_t maxConstTemp = PumpMgr().GetMaxConstTemp(); status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MAX_CONST_TEMP_ATTRIBUTE_ID, - (uint8_t *) &maxConstTemp, ZCL_INT16S_ATTRIBUTE_TYPE); + (uint8_t *) &maxConstTemp, ZCL_INT16S_ATTRIBUTE_TYPE); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxConstTemp %" PRIx8, status); diff --git a/third_party/wifi-ism43362/repo b/third_party/wifi-ism43362/repo new file mode 160000 index 00000000000000..a75d553bdc6232 --- /dev/null +++ b/third_party/wifi-ism43362/repo @@ -0,0 +1 @@ +Subproject commit a75d553bdc62322ec98634a29c2b697681dff8ec From 060880b5c70ef7945c8f50facbdfeb2249670dc9 Mon Sep 17 00:00:00 2001 From: Anders Bang Poulsen Date: Thu, 14 Oct 2021 09:43:42 +0200 Subject: [PATCH 03/23] Update pump-controller-app and documentation removing old lock-app references. Added reset feature in the app. Reduced target heap size to allow the project to build again. Updated .sysconfig file so it loads correctly in SysConfig. --- .../main/include/BoltLockManager.h | 87 ----- .../cc13x2x7_26x2x7/README.md | 70 ++-- .../cc13x2x7_26x2x7/chip.syscfg | 349 +++++++++--------- .../cc13x2x7_26x2x7/main/AppTask.cpp | 106 +++--- .../cc13x2x7_26x2x7/main/PumpManager.cpp | 100 ++--- .../cc13x2x7_26x2x7/main/ZclCallbacks.cpp | 17 +- .../cc13x2x7_26x2x7/main/include/AppEvent.h | 3 +- .../cc13x2x7_26x2x7/main/include/AppTask.h | 4 +- .../main/include/BoltLockManager.h | 87 ----- .../main/include/PumpManager.h | 52 ++- .../cc13x2x7_26x2x7/main/main.cpp | 6 +- 11 files changed, 366 insertions(+), 515 deletions(-) delete mode 100644 examples/pump-app/cc13x2x7_26x2x7/main/include/BoltLockManager.h delete mode 100644 examples/pump-controller-app/cc13x2x7_26x2x7/main/include/BoltLockManager.h diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/include/BoltLockManager.h b/examples/pump-app/cc13x2x7_26x2x7/main/include/BoltLockManager.h deleted file mode 100644 index 40fc4ffb338a67..00000000000000 --- a/examples/pump-app/cc13x2x7_26x2x7/main/include/BoltLockManager.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * 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. - */ - -#ifndef LOCK_MANAGER_H -#define LOCK_MANAGER_H - -#include -#include - -#include "AppEvent.h" - -#include -#include - -class BoltLockManager -{ -public: - enum Action_t - { - LOCK_ACTION = 0, - UNLOCK_ACTION, - - INVALID_ACTION - } Action; - - enum State_t - { - kState_LockingInitiated = 0, - kState_LockingCompleted, - kState_UnlockingInitiated, - kState_UnlockingCompleted, - } State; - - int Init(); - bool IsUnlocked(); - void EnableAutoRelock(bool aOn); - void SetAutoLockDuration(uint32_t aDurationInSecs); - bool IsActionInProgress(); - bool InitiateAction(int32_t aActor, Action_t aAction); - - typedef void (*Callback_fn_initiated)(Action_t, int32_t aActor); - typedef void (*Callback_fn_completed)(Action_t); - void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); - -private: - friend BoltLockManager & BoltLockMgr(void); - State_t mState; - - Callback_fn_initiated mActionInitiated_CB; - Callback_fn_completed mActionCompleted_CB; - - bool mAutoRelock; - uint32_t mAutoLockDuration; - bool mAutoLockTimerArmed; - TimerHandle_t mTimerHandle; - - void CancelTimer(void); - void StartTimer(uint32_t aTimeoutMs); - - static void TimerEventHandler(TimerHandle_t aTimer); - static void AutoReLockTimerEventHandler(AppEvent * aEvent); - static void ActuatorMovementTimerEventHandler(AppEvent * aEvent); - - static BoltLockManager sLock; -}; - -inline BoltLockManager & BoltLockMgr(void) -{ - return BoltLockManager::sLock; -} - -#endif // LOCK_MANAGER_H diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/README.md b/examples/pump-controller-app/cc13x2x7_26x2x7/README.md index 5b15bef626e2a8..573ea74ca7d007 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/README.md +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/README.md @@ -1,11 +1,11 @@ -# CHIP CC1352 CC2652 Lock Example Application +# Matter CC1352 CC2652 Pump Controller Example Application -An example application showing the use [CHIP][chip] on the Texas Instruments +An example application showing the use of [Matter][matter] on the Texas Instruments CC13X2_26X2 family of Wireless MCUs. --- -- [CHIP CC1352 CC2652 Lock Example Application](#chip-cc1352-cc2652-lock-example-application) +- [Matter CC1352 CC2652 Pump Controller Example Application](#matter-cc1352-cc2652-pump-controller-example-application) - [Introduction](#introduction) - [Device UI](#device-ui) - [Building](#building) @@ -19,7 +19,7 @@ CC13X2_26X2 family of Wireless MCUs. - [Provisioning](#provisioning) - [Bluetooth LE Advertising](#bluetooth-le-advertising) - [Bluetooth LE Rendezvous](#bluetooth-le-rendezvous) - - [CHIP Remote Commands](#chip-remote-commands) + - [Matter Remote Commands](#matter-remote-commands) - [TI Support](#ti-support) --- @@ -28,35 +28,35 @@ CC13X2_26X2 family of Wireless MCUs. ![CC1352R1_LAUNCHXL](doc/images/cc1352r1_launchxl.jpg) -The CC13X2_26X2 lock example application provides a working demonstration of a -connected door lock device. This uses the open-source CHIP implementation and +The CC13X2_26X2 pump controller example application provides a working demonstration of a +connected pump controller device. This uses the open-source Matter implementation and the Texas Instruments SimpleLinkā„¢ CC13x2 and CC26x2 software development kit. This example is enabled to build for CC2652R7 devices. This upcoming devices are currently not yet in full production. For more information on device -availability or early access to an engineering build of our CHIP-enabled SDK, -please reach out [here][ti_cc13x2_26x2_r7_chip_request]. +availability or early access to an engineering build of our Matter-enabled SDK, +please reach out [here][ti_cc13x2_26x2_r7_matter_request]. -The lock example is intended to serve both as a means to explore the workings of -CHIP, as well as a template for creating real products based on the Texas +The pump example is intended to serve both as a means to explore the workings of +Matter, as well as a template for creating real products based on the Texas Instruments devices. ## Device UI This example application has a simple User Interface to depict the state of the -door lock and to control the state. The user LEDs on the LaunchPad are set on -when the lock is locked, and are set off when unlocked. The LEDs will flash when -in the transition state between locked and unlocked. +pump and to control the state. The user LEDs on the LaunchPad are set on +when the pump is started, and are set off when stopped. The LEDs will flash when +in the transition state between started and stopped. -Short presses (less than 1000ms) of the user buttons are used for requesting -lock and unlock of the door lock. The left button (`BTN-1`) is used to request -locking. The right button (`BTN-2`) is used to request unlocking. +Short presses (less than 1000ms) of the left user button (`BTN-1`) are used for +toggeling the pump state. -Long presses (greater than 1000ms) of the user buttons are used for controlling -BLE advertisements. The left button (`BTN-1`) is used to disable advertisements -if they are enabled. The Right button (`BTN-2`) is used to enable -advertisements. +Short presses (less than 1000ms) of the right user button (`BTN-2`) are used for +toggeling Matter BLE advertisements. +Long presses (greater than 5000ms) of the right user button (`BTN-2`) will +initiate a factory reset of the device clearing all stored provisioning information +to allow for a new network setup. ## Building ### Preparation @@ -65,7 +65,7 @@ Some initial setup is necessary for preparing the build environment. This section will need to be done when migrating to new versions of the SDK. - An engineering SDK from TI is required. Please request access for it - [here][ti_cc13x2_26x2_r7_chip_request]. + [here][ti_cc13x2_26x2_r7_matter_request]. - Follow the default installation instructions when executing the installer. @@ -124,7 +124,7 @@ Ninja to build the executable. `C:\ti` ``` - $ cd ~/connectedhomeip/examples/lock-app/cc13x2_26x2 + $ cd ~/connectedhomeip/examples/pump-controller-app/cc13x2_26x2 $ export TI_SIMPLELINK_SDK_ROOT= $ export TI_SYSCONFIG_ROOT= $ gn gen out/debug --args="ti_simplelink_sdk_root=\"${TI_SIMPLELINK_SDK_ROOT}\" ti_sysconfig_root=\"${TI_SYSCONFIG_ROOT}\"" @@ -168,27 +168,27 @@ Router][ot_border_router_setup]. ### Provisioning -The first step to bring the CHIP device onto the network is to provision it. Our +The first step to bring the Matter device onto the network is to provision it. Our example accomplishes this with Bluetooth Low Energy (BLE) and the [CHIPTool](../../../src/android/CHIPTool/README.md) mobile app. #### Bluetooth LE Advertising To provision this example onto a Thread network, the device must be discoverable -over Bluetooth LE. BLE advertising is started by long pressing the right button -(greater than 1000ms), labeled `BTN-2` on the silkscreen. Once the device is +over Bluetooth LE. BLE advertising is started by pressing the right button +(less than 1000ms), labeled `BTN-2` on the silkscreen. Once the device is fully provisioned, BLE advertising will stop. #### Bluetooth LE Rendezvous In this example, the provisioning procedure (called Rendezvous) is done over -Bluetooth LE between a CHIP device (lock-app) and the CHIP controller +Bluetooth LE between a Matter device (pump-controller-app) and the Matter controller (CHIPTool), where the controller has the commissioner role. To start the rendezvous, the controller must get the commissioning information -from the CHIP device. +from the Matter device. -This is done by scanning a QR code. A URL will be displayed on the lock-app's +This is done by scanning a QR code. A URL will be displayed on the pump-app's log ([UART terminal](#viewing-logging-output)). It will look like the following: ``` @@ -202,21 +202,21 @@ pre-loaded). Alternatively, you can navigate to [the QR code generator][qr_code_generator] and enter in the payload shown in `SetupQRCode` (in this case `MT:.81TM -00 0C9SS0`). -### CHIP Remote Commands +### Matter Remote Commands -Once the CHIP device is provisioned and operating on the network, CHIPTool can -be used to control the device. During the provisioning process, the CHIP device +Once the Matter device is provisioned and operating on the network, CHIPTool can +be used to control the device. During the provisioning process, the Matter device would have sent one of its newly assigned IPv6 addresses to the CHIPTool. -In the app, you should see an On/Off cluster; this corresponds to the lock-app. -You can now control the lock-app CHIP device from the smartphone! +In the app, you should see an On/Off cluster; this corresponds to the pump-app. +You can now control the pump-controller-app Matter device from the smartphone! ## TI Support For technical support, please consider creating a post on TI's [E2E forum][e2e]. Additionally, we welcome any feedback. -[chip]: https://github.com/project-chip/connectedhomeip +[matter]: https://github.com/project-chip/connectedhomeip [cc1352r1_launchxl]: https://www.ti.com/tool/LAUNCHXL-CC1352R1 [e2e]: https://e2e.ti.com/support/wireless-connectivity/zigbee-and-thread [simplelink_sdk]: https://www.ti.com/tool/SIMPLELINK-CC13X2-26X2-SDK @@ -227,7 +227,7 @@ Additionally, we welcome any feedback. http://software-dl.ti.com/ccs/esd/sysconfig/sysconfig-1.5.0_1397-setup.run [ti_thread_dnd]: https://www.ti.com/wireless-connectivity/thread/design-development.html -[ti_cc13x2_26x2_r7_chip_request]: https://ti.com/chip_sdk +[ti_cc13x2_26x2_r7_matter_request]: https://ti.com/chip_sdk [ot_border_router_setup]: https://openthread.io/guides/border-router/beaglebone-black [qr_code_generator]: https://dhrishi.github.io/connectedhomeip/qrcode.html diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/chip.syscfg b/examples/pump-controller-app/cc13x2x7_26x2x7/chip.syscfg index c93e60f4846aaa..38a53e57d500fd 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/chip.syscfg +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/chip.syscfg @@ -17,198 +17,191 @@ * limitations under the License. */ -/* Modules */ -var AESCCM = scripting.addModule("/ti/drivers/AESCCM"); -var AESECB = scripting.addModule("/ti/drivers/AESECB"); -var Button = scripting.addModule("/ti/drivers/apps/Button"); -var ECJPAKE = scripting.addModule("/ti/drivers/ECJPAKE"); -var LED = scripting.addModule("/ti/drivers/apps/LED"); -var NVS = scripting.addModule("/ti/drivers/NVS"); -var RF = scripting.addModule("/ti/drivers/RF"); -var RFDesign = scripting.addModule("ti/devices/radioconfig/rfdesign"); -var RTOS = scripting.addModule("/ti/drivers/RTOS"); -var TRNG = scripting.addModule("/ti/drivers/TRNG"); -var Thread = scripting.addModule("/ti/thread/thread"); -var SHA2 = scripting.addModule("/ti/drivers/SHA2"); -var UART = scripting.addModule("/ti/drivers/UART"); -var ble = scripting.addModule("/ti/ble5stack/ble"); -var dmm = scripting.addModule("/ti/dmm/dmm"); -var AESCTRDRBG = scripting.addModule("/ti/drivers/AESCTRDRBG"); -var ECDH = scripting.addModule("/ti/drivers/ECDH"); - -/* Instances */ -var AESCCM1 = AESCCM.addInstance(); -var AESCCM2 = AESCCM.addInstance(); -var AESECB1 = AESECB.addInstance(); -var AESECB2 = AESECB.addInstance(); -var Button1 = Button.addInstance(); -var Button2 = Button.addInstance(); -var ECJPAKE = ECJPAKE.addInstance(); -var NVS1 = NVS.addInstance(); -var SHA21 = SHA2.addInstance(); -var LED1 = LED.addInstance(); -var LED2 = LED.addInstance(); -var TRNG1 = TRNG.addInstance(); -var TRNG2 = TRNG.addInstance(); -var TRNG3 = TRNG.addInstance(); -var UART1 = UART.addInstance(); -var UART2 = UART.addInstance(); -var AESCTRDRBG1 = AESCTRDRBG.addInstance(); -var ECDH1 = ECDH.addInstance(); -var ECDH2 = ECDH.addInstance(); +/** + * These arguments were used when this file was generated. They will be automatically applied on subsequent loads + * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments. + * @cliArgs --board "/ti/boards/CC26X2R1_LAUNCHXL" --product "simplelink_cc13x2_26x2_sdk@4.40.05.02_eng" + * @versions {"tool":"1.9.0+2015","templates":null} + */ -AESCTRDRBG1.$name = "CONFIG_AESCTRDRBG_0"; -AESCTRDRBG1.aesctrObject.$name = "CONFIG_AESCTR_0"; +/** + * Import the modules used in this configuration. + */ +const ble = scripting.addModule("/ti/ble5stack/ble"); +const CCFG = scripting.addModule("/ti/devices/CCFG"); +const rfdesign = scripting.addModule("/ti/devices/radioconfig/rfdesign"); +const dmm = scripting.addModule("/ti/dmm/dmm"); +const AESCCM = scripting.addModule("/ti/drivers/AESCCM"); +const AESCCM1 = AESCCM.addInstance(); +const AESCCM2 = AESCCM.addInstance(); +const AESCTRDRBG = scripting.addModule("/ti/drivers/AESCTRDRBG"); +const AESCTRDRBG1 = AESCTRDRBG.addInstance(); +const AESECB = scripting.addModule("/ti/drivers/AESECB"); +const AESECB1 = AESECB.addInstance(); +const AESECB2 = AESECB.addInstance(); +const ECDH = scripting.addModule("/ti/drivers/ECDH"); +const ECDH1 = ECDH.addInstance(); +const ECDH2 = ECDH.addInstance(); +const ECJPAKE = scripting.addModule("/ti/drivers/ECJPAKE"); +const ECJPAKE1 = ECJPAKE.addInstance(); +const NVS = scripting.addModule("/ti/drivers/NVS"); +const NVS1 = NVS.addInstance(); +const RF = scripting.addModule("/ti/drivers/RF"); +const RTOS = scripting.addModule("/ti/drivers/RTOS"); +const SHA2 = scripting.addModule("/ti/drivers/SHA2"); +const SHA21 = SHA2.addInstance(); +const TRNG = scripting.addModule("/ti/drivers/TRNG"); +const TRNG1 = TRNG.addInstance(); +const TRNG2 = TRNG.addInstance(); +const TRNG3 = TRNG.addInstance(); +const UART = scripting.addModule("/ti/drivers/UART"); +const UART1 = UART.addInstance(); +const UART2 = UART.addInstance(); +const Button = scripting.addModule("/ti/drivers/apps/Button"); +const Button1 = Button.addInstance(); +const Button2 = Button.addInstance(); +const LED = scripting.addModule("/ti/drivers/apps/LED"); +const LED1 = LED.addInstance(); +const LED2 = LED.addInstance(); +const thread = scripting.addModule("/ti/thread/thread"); + +/** + * Write custom configuration values to the imported modules. + */ +ble.maxConnNum = 1; +ble.numOfAdvSets = 1; +ble.lockProject = true; +ble.maxPDUSize = 255; +ble.radioConfig.codeExportConfig.$name = "ti_devices_radioconfig_code_export_param1"; +ble.connUpdateParamsPeripheral.$name = "ti_ble5stack_general_ble_conn_update_params0"; +ble.connUpdateParamsPeripheral.reqMinConnInt = 30; +ble.connUpdateParamsPeripheral.reqMaxConnInt = 50; +ble.advSet1.$name = "ti_ble5stack_broadcaster_advertisement_set0"; +ble.advSet1.advParam1.$name = "ti_ble5stack_broadcaster_advertisement_params0"; +ble.advSet1.advParam1.primIntMax = 200; +ble.advSet1.advData1.$name = "ti_ble5stack_broadcaster_advertisement_data0"; +ble.advSet1.scanRes1.$name = "ti_ble5stack_broadcaster_advertisement_data1"; + +CCFG.enableBootloader = true; +CCFG.enableBootloaderBackdoor = true; +CCFG.dioBootloaderBackdoor = 13; +CCFG.levelBootloaderBackdoor = "Active low"; +CCFG.srcClkLF = "Derived from HF XOSC"; +CCFG.ccfgTemplate.$name = "ti_devices_CCFGTemplate0"; + +dmm.project = "ti_thread_thermostat_remote_display"; +dmm.stackRoles = ["blePeripheral","threadFTD"]; +dmm.lockStackRoles = true; +dmm.numApplicationStates = 10; +dmm.applicationState0 = "ANY"; +dmm.applicationState1 = "DMMPOLICY_BLE_IDLE"; +dmm.applicationState2 = "DMMPOLICY_BLE_ADV"; +dmm.applicationState3 = "DMMPOLICY_BLE_CONNECTING"; +dmm.applicationState4 = "DMMPOLICY_BLE_HIGH_BANDWIDTH"; +dmm.applicationState5 = "DMMPOLICY_BLE_CONNECTED"; +dmm.applicationState6 = "DMMPOLICY_BLE_OAD"; +dmm.applicationState7 = "DMMPOLICY_THREAD_IDLE"; +dmm.applicationState8 = "DMMPOLICY_THREAD_LINK_EST"; +dmm.applicationState9 = "DMMPOLICY_THREAD_DATA"; +dmm.policyArray.create(4); +dmm.policyArray[0].$name = "ti_dmm_policy_dmm_policy0"; +dmm.policyArray[0].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble0"; +dmm.policyArray[0].blePeripheral.applicationStates = ["applicationState6"]; +dmm.policyArray[0].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread0"; +dmm.policyArray[0].threadFTD.pause = "DMMPOLICY_PAUSED"; +dmm.policyArray[1].$name = "ti_dmm_policy_dmm_policy1"; +dmm.policyArray[1].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble1"; +dmm.policyArray[1].blePeripheral.applicationStates = ["applicationState3","applicationState4"]; +dmm.policyArray[1].blePeripheral.weight = 25; +dmm.policyArray[1].blePeripheral.appliedActivity = ["DMMPOLICY_APPLIED_ACTIVITY_BLE_CONNECTION"]; +dmm.policyArray[1].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread1"; +dmm.policyArray[2].$name = "ti_dmm_policy_dmm_policy2"; +dmm.policyArray[2].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble2"; +dmm.policyArray[2].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread2"; +dmm.policyArray[2].threadFTD.weight = 30; +dmm.policyArray[2].threadFTD.applicationStates = ["applicationState8"]; +dmm.policyArray[2].threadFTD.appliedActivity = ["DMMPOLICY_APPLIED_ACTIVITY_ALL"]; +dmm.policyArray[3].$name = "ti_dmm_policy_dmm_policy3"; +dmm.policyArray[3].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble3"; +dmm.policyArray[3].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread3"; +dmm.policyArray[3].threadFTD.weight = 1; AESCCM1.$name = "CONFIG_AESCCM0"; + AESCCM2.$name = "CONFIG_AESCCM_1"; +AESCTRDRBG1.$name = "CONFIG_AESCTRDRBG_0"; +AESCTRDRBG1.aesctrObject.$name = "CONFIG_AESCTR_0"; + AESECB1.$name = "CONFIG_AESECB0"; + AESECB2.$name = "CONFIG_AESECB_1"; ECDH1.$name = "CONFIG_ECDH0"; + ECDH2.$name = "CONFIG_ECDH_1"; -/* RTOS */ -RTOS.name = "FreeRTOS"; +ECJPAKE1.$name = "CONFIG_ECJPAKE_0"; -/* Left Button */ -Button1.$name = "CONFIG_BTN_LEFT"; -Button1.$hardware = system.deviceData.board.components["BTN-1"]; -Button1.gpioPin.$name = "CONFIG_GPIO_BTN1"; -Button1.gpioPin.pull = "Pull Up"; -Button1.gpioPin.interruptTrigger = "Falling Edge"; -Button1.gpioPin.pinInstance.$name = "CONFIG_PIN_BTN1"; - -/* Left Button */ -Button2.$name = "CONFIG_BTN_RIGHT"; -Button2.$hardware = system.deviceData.board.components["BTN-2"]; -Button2.gpioPin.$name = "CONFIG_GPIO_BTN2"; -Button2.gpioPin.pull = "Pull Up"; -Button2.gpioPin.interruptTrigger = "Falling Edge"; -Button2.gpioPin.pinInstance.$name = "CONFIG_PIN_BTN2"; - -/* ======== CCFG ======== */ -var CCFG = scripting.addModule("/ti/devices/CCFG"); -const deviceName = system.getScript("/ti/ti154stack/ti154stack_common.js").getLaunchPadFromDevice(); -const ccfgSettings = system.getScript("/ti/common/lprf_ccfg_settings.js").ccfgSettings; -for(var setting in ccfgSettings) -{ - CCFG[setting] = ccfgSettings[setting]; -} - -// Update LF Clock Source for CC2652RB devices -if(deviceName.includes("RB")) -{ - CCFG.srcClkLF = "Derived from HF XOSC"; -} -/* NVS */ -NVS1.$name = "CONFIG_NVSINTERNAL"; +NVS1.$name = "CONFIG_NVSINTERNAL"; +NVS1.internalFlash.$name = "ti_drivers_nvs_NVSCC26XX0"; NVS1.internalFlash.regionBase = 0x78000; NVS1.internalFlash.regionSize = 0x4000; -/* RF */ -RF.$name = "CONFIG_RF0"; -/* if an antenna component exists, assign it to the rf instance */ -if (system.deviceData.board && system.deviceData.board.components.RF) { - RF.$hardware = system.deviceData.board.components.RF; -} - -const rfDesignSettings = system.getScript("/ti/common/lprf_rf_design_settings.js").rfDesignSettings; -for(var setting in rfDesignSettings) -{ - RFDesign[setting] = rfDesignSettings[setting]; -} - -/* Red LED */ -LED1.$name = "CONFIG_LED_RED"; -LED1.$hardware = system.deviceData.board.components.LED_RED; -LED1.gpioPin.$name = "CONFIG_GPIO_RLED"; -LED1.gpioPin.mode = "Output"; -LED1.gpioPin.callbackFunction = ""; -LED1.gpioPin.pinInstance.$name = "CONFIG_PIN_RLED"; - -/* Green LED */ -LED2.$name = "CONFIG_LED_GREEN"; -LED2.$hardware = system.deviceData.board.components.LED_GREEN; -LED2.gpioPin.$name = "CONFIG_GPIO_GLED"; -LED2.gpioPin.mode = "Output"; -LED2.gpioPin.callbackFunction = ""; -LED2.gpioPin.pinInstance.$name = "CONFIG_PIN_GLED"; - -/* Debug UART */ -UART1.$hardware = system.deviceData.board.components.XDS110UART; -UART1.$name = "CONFIG_UART_DEBUG"; - -/* Display UART */ -UART2.$name = "CONFIG_DISPLAY_UART"; -UART2.uart.txPin.$suggestSolution = "boosterpack.32"; -UART2.uart.rxPin.$suggestSolution = "boosterpack.18"; - -/* TRNG */ -TRNG1.$name = "CONFIG_TRNG_0"; -TRNG2.$name = "CONFIG_TRNG_1"; -TRNG3.$name = "CONFIG_TRNG_APP"; - -/* Thread */ -Thread.deviceType = "ftd"; -Thread.deviceTypeReadOnly = true; -/* Thread SysConfig generated sources are not used until the upstream modules - * can be updated to enable CHIP. - */ RTOS.name = "FreeRTOS"; -/* BLE */ -ble.addressMode = "ADDRMODE_RP_WITH_PUBLIC_ID"; -ble.maxConnNum = 1; -ble.numOfAdvSets = 1; -ble.lockProject = true; -ble.oneLibSizeOpt = true; -ble.maxPDUSize = 255; -ble.radioConfig.codeExportConfig.$name = "ti_devices_radioconfig_code_export_param1"; -ble.connUpdateParamsPeripheral.$name = "ti_ble5stack_general_ble_conn_update_params0"; -ble.connUpdateParamsPeripheral.reqMinConnInt = 30; -ble.connUpdateParamsPeripheral.reqMaxConnInt = 50; - -ble.advSet1.$name = "ti_ble5stack_broadcaster_advertisement_set0"; -ble.advSet1.advParam1.$name = "ti_ble5stack_broadcaster_advertisement_params0"; -ble.advSet1.advParam1.primIntMin = 100; -ble.advSet1.advParam1.primIntMax = 200; - -/* DMM */ -dmm.project = "ti_thread_thermostat_remote_display"; -dmm.stackRoles = ["blePeripheral","threadFTD"]; -dmm.lockStackRoles = true; -dmm.numApplicationStates = 10; -dmm.applicationState0 = "ANY"; -dmm.applicationState1 = "DMMPOLICY_BLE_IDLE"; -dmm.applicationState2 = "DMMPOLICY_BLE_ADV"; -dmm.applicationState3 = "DMMPOLICY_BLE_CONNECTING"; -dmm.applicationState4 = "DMMPOLICY_BLE_HIGH_BANDWIDTH"; -dmm.applicationState5 = "DMMPOLICY_BLE_CONNECTED"; -dmm.applicationState6 = "DMMPOLICY_BLE_OAD"; -dmm.applicationState7 = "DMMPOLICY_THREAD_IDLE"; -dmm.applicationState8 = "DMMPOLICY_THREAD_LINK_EST"; -dmm.applicationState9 = "DMMPOLICY_THREAD_DATA"; -dmm.policyArray.create(4); -dmm.policyArray[0].$name = "ti_dmm_policy_dmm_policy0"; -dmm.policyArray[0].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble0"; -dmm.policyArray[0].blePeripheral.applicationStates = ["applicationState6"]; -dmm.policyArray[0].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread0"; -dmm.policyArray[0].threadFTD.pause = "DMMPOLICY_PAUSED"; -dmm.policyArray[1].$name = "ti_dmm_policy_dmm_policy1"; -dmm.policyArray[1].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble1"; -dmm.policyArray[1].blePeripheral.applicationStates = ["applicationState3","applicationState4"]; -dmm.policyArray[1].blePeripheral.weight = 25; -dmm.policyArray[1].blePeripheral.appliedActivity = ["DMMPOLICY_APPLIED_ACTIVITY_BLE_CONNECTION"]; -dmm.policyArray[1].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread1"; -dmm.policyArray[2].$name = "ti_dmm_policy_dmm_policy2"; -dmm.policyArray[2].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble2"; -dmm.policyArray[2].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread2"; -dmm.policyArray[2].threadFTD.weight = 30; -dmm.policyArray[2].threadFTD.applicationStates = ["applicationState8"]; -dmm.policyArray[2].threadFTD.appliedActivity = ["DMMPOLICY_APPLIED_ACTIVITY_ALL"]; -dmm.policyArray[3].$name = "ti_dmm_policy_dmm_policy3"; -dmm.policyArray[3].blePeripheral.$name = "ti_dmm_policy_stack_dmm_stack_ble3"; -dmm.policyArray[3].threadFTD.$name = "ti_dmm_policy_stack_dmm_stack_thread3"; -dmm.policyArray[3].threadFTD.weight = 1; +SHA21.$name = "CONFIG_SHA2_0"; + +TRNG1.$name = "CONFIG_TRNG_0"; + +TRNG2.$name = "CONFIG_TRNG_1"; + +TRNG3.$name = "CONFIG_TRNG_APP"; + +UART1.$name = "CONFIG_UART_DEBUG"; +UART1.uart.$assign = "UART1"; +UART1.uart.txPin.$assign = "boosterpack.4"; +UART1.uart.rxPin.$assign = "boosterpack.3"; +UART1.txPinInstance.$name = "CONFIG_PIN_4"; +UART1.rxPinInstance.$name = "CONFIG_PIN_5"; + +UART2.$name = "CONFIG_DISPLAY_UART"; +UART2.txPinInstance.$name = "CONFIG_PIN_6"; +UART2.rxPinInstance.$name = "CONFIG_PIN_7"; + +Button1.$name = "CONFIG_BTN_LEFT"; +Button1.gpioPin.$name = "CONFIG_GPIO_BTN1"; +Button1.gpioPin.gpioPin.$assign = "boosterpack.32"; +Button1.gpioPin.pinInstance.$name = "CONFIG_PIN_BTN1"; + +Button2.$name = "CONFIG_BTN_RIGHT"; +Button2.gpioPin.$name = "CONFIG_GPIO_BTN2"; +Button2.gpioPin.gpioPin.$assign = "boosterpack.13"; +Button2.gpioPin.pinInstance.$name = "CONFIG_PIN_BTN2"; + +LED1.$name = "CONFIG_LED_RED"; +LED1.gpioPin.$name = "CONFIG_GPIO_RLED"; +LED1.gpioPin.gpioPin.$assign = "boosterpack.10"; +LED1.gpioPin.pinInstance.$name = "CONFIG_PIN_RLED"; + +LED2.$name = "CONFIG_LED_GREEN"; +LED2.gpioPin.$name = "CONFIG_GPIO_GLED"; +LED2.gpioPin.gpioPin.$assign = "boosterpack.39"; +LED2.gpioPin.pinInstance.$name = "CONFIG_PIN_GLED"; + +thread.deviceTypeReadOnly = true; +thread.pm.$name = "ti_thread_pm_thread_pm0"; +thread.rf.$name = "ti_thread_rf_thread_rf0"; +thread.rf.radioConfig.$name = "ti_devices_radioconfig_settings_ieee_15_40"; +thread.rf.radioConfig.codeExportConfig.$name = "ti_devices_radioconfig_code_export_param0"; +thread.network.$name = "ti_thread_network_thread_network0"; +thread.security.$name = "ti_thread_security_thread_security0"; + +/** + * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future + * version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to + * re-solve from scratch. + */ +UART2.uart.$suggestSolution = "UART0"; +UART2.uart.txPin.$suggestSolution = "boosterpack.30"; +UART2.uart.rxPin.$suggestSolution = "boosterpack.29"; diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp index dd2d3d63200f7f..c9697d5bcc7d09 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -22,7 +22,16 @@ #include "AppEvent.h" #include +#include +#include +#include + #include "FreeRTOS.h" +#include +#include + +#include +#include #include #include @@ -30,11 +39,6 @@ #include -#include -#include - -//#include - #include #include @@ -84,7 +88,7 @@ int AppTask::StartAppTask() int AppTask::Init() { LED_Params ledParams; - Button_Params buttionParams; + Button_Params buttonParams; ConnectivityManager::ThreadPollingConfig pollingConfig; cc13x2_26x2LogInit(); @@ -167,18 +171,18 @@ int AppTask::Init() PLAT_LOG("Initialize buttons"); Button_init(); - Button_Params_init(&buttionParams); - buttionParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED; - buttionParams.longPressDuration = 1000U; // ms - sAppLeftHandle = Button_open(CONFIG_BTN_LEFT, ButtonLeftEventHandler, &buttionParams); + Button_Params_init(&buttonParams); + buttonParams.buttonEventMask = Button_EV_CLICKED; + buttonParams.longPressDuration = 1000U; // ms + sAppLeftHandle = Button_open(CONFIG_BTN_LEFT, ButtonLeftEventHandler, &buttonParams); - Button_Params_init(&buttionParams); - buttionParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED; - buttionParams.longPressDuration = 1000U; // ms - sAppRightHandle = Button_open(CONFIG_BTN_RIGHT, ButtonRightEventHandler, &buttionParams); + Button_Params_init(&buttonParams); + buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGPRESSED; + buttonParams.longPressDuration = 5000U; // ms + sAppRightHandle = Button_open(CONFIG_BTN_RIGHT, ButtonRightEventHandler, &buttonParams); - // Initialize BoltLock module - PLAT_LOG("Initialize BoltLock"); + // Initialize Pump module + PLAT_LOG("Initialize Pump"); PumpMgr().Init(); PumpMgr().SetCallbacks(ActionInitiated, ActionCompleted); @@ -224,10 +228,7 @@ void AppTask::ButtonLeftEventHandler(Button_Handle handle, Button_EventMask even { event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; } - else if (events & Button_EV_LONGCLICKED) - { - event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked; - } + // button callbacks are in ISR context if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) { @@ -244,9 +245,9 @@ void AppTask::ButtonRightEventHandler(Button_Handle handle, Button_EventMask eve { event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; } - else if (events & Button_EV_LONGCLICKED) + else if (events & Button_EV_LONGPRESSED) { - event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked; + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongPressed; } // button callbacks are in ISR context if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) @@ -257,16 +258,16 @@ void AppTask::ButtonRightEventHandler(Button_Handle handle, Button_EventMask eve void AppTask::ActionInitiated(PumpManager::Action_t aAction, int32_t aActor) { - // If the action has been initiated by the lock, update the bolt lock trait + // If the action has been initiated by the pump, update the pump trait // and start flashing the LEDs rapidly to indicate action initiation. - if (aAction == PumpManager::LOCK_ACTION) + if (aAction == PumpManager::START_ACTION) { - PLAT_LOG("Lock initiated"); + PLAT_LOG("Pump start initiated"); ; // TODO } - else if (aAction == PumpManager::UNLOCK_ACTION) + else if (aAction == PumpManager::STOP_ACTION) { - PLAT_LOG("Unlock initiated"); + PLAT_LOG("Stop initiated"); ; // TODO } @@ -278,20 +279,20 @@ void AppTask::ActionInitiated(PumpManager::Action_t aAction, int32_t aActor) void AppTask::ActionCompleted(PumpManager::Action_t aAction) { - // if the action has been completed by the lock, update the bolt lock trait. - // Turn on the lock LED if in a LOCKED state OR - // Turn off the lock LED if in an UNLOCKED state. - if (aAction == PumpManager::LOCK_ACTION) + // if the action has been completed by the pump, update the pump trait. + // Turn on the pump state LED if in a STARTED state OR + // Turn off the pump state LED if in an STOPPED state. + if (aAction == PumpManager::START_ACTION) { - PLAT_LOG("Lock completed"); + PLAT_LOG("Pump start completed"); LED_stopBlinking(sAppGreenHandle); LED_setOn(sAppGreenHandle, LED_BRIGHTNESS_MAX); LED_stopBlinking(sAppRedHandle); LED_setOn(sAppRedHandle, LED_BRIGHTNESS_MAX); } - else if (aAction == PumpManager::UNLOCK_ACTION) + else if (aAction == PumpManager::STOP_ACTION) { - PLAT_LOG("Unlock completed"); + PLAT_LOG("Pump stop completed"); LED_stopBlinking(sAppGreenHandle); LED_setOff(sAppGreenHandle); LED_stopBlinking(sAppRedHandle); @@ -306,18 +307,14 @@ void AppTask::DispatchEvent(AppEvent * aEvent) case AppEvent::kEventType_ButtonLeft: if (AppEvent::kAppEventButtonType_Clicked == aEvent->ButtonEvent.Type) { - if (!PumpMgr().IsUnlocked()) + // Toggle Pump state + if (!PumpMgr().IsStopped()) { - PumpMgr().InitiateAction(0, PumpManager::UNLOCK_ACTION); + PumpMgr().InitiateAction(0, PumpManager::STOP_ACTION); } - } - else if (AppEvent::kAppEventButtonType_LongClicked == aEvent->ButtonEvent.Type) - { - // Disable BLE advertisements - if (ConnectivityMgr().IsBLEAdvertisingEnabled()) + else { - ConnectivityMgr().SetBLEAdvertisingEnabled(false); - PLAT_LOG("Disabled BLE Advertisements"); + PumpMgr().InitiateAction(0, PumpManager::START_ACTION); } } break; @@ -325,14 +322,7 @@ void AppTask::DispatchEvent(AppEvent * aEvent) case AppEvent::kEventType_ButtonRight: if (AppEvent::kAppEventButtonType_Clicked == aEvent->ButtonEvent.Type) { - if (PumpMgr().IsUnlocked()) - { - PumpMgr().InitiateAction(0, PumpManager::LOCK_ACTION); - } - } - else if (AppEvent::kAppEventButtonType_LongClicked == aEvent->ButtonEvent.Type) - { - // Enable BLE advertisements + // Toggle BLE advertisements if (!ConnectivityMgr().IsBLEAdvertisingEnabled()) { if (chip::Server::GetInstance().GetCommissioningWindowManager().OpenBasicCommissioningWindow() == CHIP_NO_ERROR) @@ -344,6 +334,16 @@ void AppTask::DispatchEvent(AppEvent * aEvent) PLAT_LOG("OpenBasicCommissioningWindow() failed"); } } + else + { + // Disable BLE advertisements + ConnectivityMgr().SetBLEAdvertisingEnabled(false); + PLAT_LOG("Disabled BLE Advertisements"); + } + } + else if (AppEvent::kAppEventButtonType_LongPressed == aEvent->ButtonEvent.Type) + { + ConfigurationMgr().InitiateFactoryReset(); } break; @@ -359,3 +359,7 @@ void AppTask::DispatchEvent(AppEvent * aEvent) break; } } + +void AppTask::UpdateClusterState() +{ +} diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/PumpManager.cpp b/examples/pump-controller-app/cc13x2x7_26x2x7/main/PumpManager.cpp index 7869171d77f1f0..6d5020f3e89f10 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/PumpManager.cpp +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/PumpManager.cpp @@ -25,7 +25,7 @@ #define ACTUATOR_MOVEMENT_PERIOS_MS 500 -PumpManager PumpManager::sLock; +PumpManager PumpManager::sPump; int PumpManager::Init() { @@ -34,15 +34,15 @@ int PumpManager::Init() mTimerHandle = xTimerCreate("BLT_TIMER", pdMS_TO_TICKS(ACTUATOR_MOVEMENT_PERIOS_MS), pdFALSE, this, TimerEventHandler); if (NULL == mTimerHandle) { - PLAT_LOG("failed to create bolt lock timer"); + PLAT_LOG("failed to create pump timer"); while (1) ; } - mState = kState_LockingCompleted; - mAutoLockTimerArmed = false; - mAutoRelock = false; - mAutoLockDuration = 0; + mState = kState_StopCompleted; + mAutoStartTimerArmed = false; + mAutoRestart = false; + mAutoStartDuration = 0; return ret; } @@ -55,22 +55,22 @@ void PumpManager::SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callba bool PumpManager::IsActionInProgress() { - return (mState == kState_LockingInitiated || mState == kState_UnlockingInitiated); + return (mState == kState_StartInitiated || mState == kState_StopInitiated); } -bool PumpManager::IsUnlocked() +bool PumpManager::IsStopped() { - return (mState == kState_UnlockingCompleted); + return (mState == kState_StopCompleted); } -void PumpManager::EnableAutoRelock(bool aOn) +void PumpManager::EnableAutoRestart(bool aOn) { - mAutoRelock = aOn; + mAutoRestart = aOn; } -void PumpManager::SetAutoLockDuration(uint32_t aDurationInSecs) +void PumpManager::SetAutoStartDuration(uint32_t aDurationInSecs) { - mAutoLockDuration = aDurationInSecs; + mAutoStartDuration = aDurationInSecs; } bool PumpManager::InitiateAction(int32_t aActor, Action_t aAction) @@ -78,32 +78,32 @@ bool PumpManager::InitiateAction(int32_t aActor, Action_t aAction) bool action_initiated = false; State_t new_state; - // Initiate Lock/Unlock Action only when the previous one is complete. - if (mState == kState_LockingCompleted && aAction == UNLOCK_ACTION) + // Initiate Start/Stop Action only when the previous one is complete. + if (mState == kState_StartCompleted && aAction == STOP_ACTION) { action_initiated = true; - new_state = kState_UnlockingInitiated; + new_state = kState_StopInitiated; } - else if (mState == kState_UnlockingCompleted && aAction == LOCK_ACTION) + else if (mState == kState_StopCompleted && aAction == START_ACTION) { action_initiated = true; - new_state = kState_LockingInitiated; + new_state = kState_StartInitiated; } if (action_initiated) { - if (mAutoLockTimerArmed && new_state == kState_LockingInitiated) + if (mAutoStartTimerArmed && new_state == kState_StartInitiated) { - // If auto lock timer has been armed and someone initiates locking, + // If auto start timer has been armed and someone initiates start, // cancel the timer and continue as normal. - mAutoLockTimerArmed = false; + mAutoStartTimerArmed = false; CancelTimer(); } - StartTimer(ACTUATOR_MOVEMENT_PERIOS_MS); + PumpTimer(ACTUATOR_MOVEMENT_PERIOS_MS); // Since the timer started successfully, update the state and trigger callback mState = new_state; @@ -117,7 +117,7 @@ bool PumpManager::InitiateAction(int32_t aActor, Action_t aAction) return action_initiated; } -void PumpManager::StartTimer(uint32_t aTimeoutMs) +void PumpManager::PumpTimer(uint32_t aTimeoutMs) { xTimerChangePeriod(mTimerHandle, pdMS_TO_TICKS(aTimeoutMs), 100); xTimerStart(mTimerHandle, 100); @@ -130,17 +130,17 @@ void PumpManager::CancelTimer(void) void PumpManager::TimerEventHandler(TimerHandle_t aTimer) { - PumpManager * lock = static_cast(pvTimerGetTimerID(aTimer)); + PumpManager * pump = static_cast(pvTimerGetTimerID(aTimer)); // The timer event handler will be called in the context of the timer task - // once sLockTimer expires. Post an event to apptask queue with the actual handler + // once sPumpTimer expires. Post an event to apptask queue with the actual handler // so that the event can be handled in the context of the apptask. AppEvent event; - event.Type = AppEvent::kEventType_AppEvent; - event.BoltLockEvent.Context = static_cast(lock); - if (lock->mAutoLockTimerArmed) + event.Type = AppEvent::kEventType_AppEvent; + event.PumpStateEvent.Context = static_cast(pump); + if (pump->mAutoStartTimerArmed) { - event.Handler = AutoReLockTimerEventHandler; + event.Handler = AutoRestartTimerEventHandler; } else { @@ -149,56 +149,56 @@ void PumpManager::TimerEventHandler(TimerHandle_t aTimer) GetAppTask().PostEvent(&event); } -void PumpManager::AutoReLockTimerEventHandler(AppEvent * aEvent) +void PumpManager::AutoRestartTimerEventHandler(AppEvent * aEvent) { - PumpManager * lock = static_cast(aEvent->BoltLockEvent.Context); + PumpManager * pump = static_cast(aEvent->PumpStateEvent.Context); int32_t actor = 0; - // Make sure auto lock timer is still armed. - if (!lock->mAutoLockTimerArmed) + // Make sure auto start timer is still armed. + if (!pump->mAutoStartTimerArmed) { return; } - lock->mAutoLockTimerArmed = false; + pump->mAutoStartTimerArmed = false; - PLAT_LOG("Auto Re-Lock has been triggered!"); + PLAT_LOG("Auto Re-Start has been triggered!"); - lock->InitiateAction(actor, LOCK_ACTION); + pump->InitiateAction(actor, START_ACTION); } void PumpManager::ActuatorMovementTimerEventHandler(AppEvent * aEvent) { Action_t actionCompleted = INVALID_ACTION; - PumpManager * lock = static_cast(aEvent->BoltLockEvent.Context); + PumpManager * pump = static_cast(aEvent->PumpStateEvent.Context); - if (lock->mState == kState_LockingInitiated) + if (pump->mState == kState_StartInitiated) { - lock->mState = kState_LockingCompleted; - actionCompleted = LOCK_ACTION; + pump->mState = kState_StartCompleted; + actionCompleted = START_ACTION; } - else if (lock->mState == kState_UnlockingInitiated) + else if (pump->mState == kState_StopInitiated) { - lock->mState = kState_UnlockingCompleted; - actionCompleted = UNLOCK_ACTION; + pump->mState = kState_StopCompleted; + actionCompleted = STOP_ACTION; } if (actionCompleted != INVALID_ACTION) { - if (lock->mActionCompleted_CB) + if (pump->mActionCompleted_CB) { - lock->mActionCompleted_CB(actionCompleted); + pump->mActionCompleted_CB(actionCompleted); } - if (lock->mAutoRelock && actionCompleted == UNLOCK_ACTION) + if (pump->mAutoRestart && actionCompleted == STOP_ACTION) { - // Start the timer for auto relock - lock->StartTimer(lock->mAutoLockDuration * 1000); + // Start the timer for auto restart + pump->PumpTimer(pump->mAutoStartDuration * 1000); - lock->mAutoLockTimerArmed = true; + pump->mAutoStartTimerArmed = true; - PLAT_LOG("Auto Re-lock enabled. Will be triggered in %u seconds", lock->mAutoLockDuration); + PLAT_LOG("Auto Re-start enabled. Will be triggered in %u seconds", pump->mAutoStartDuration); } } } diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp b/examples/pump-controller-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp index 8d4abc4858c4a1..2ca101ae79ece6 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp @@ -15,7 +15,10 @@ * limitations under the License. */ +#include + #include "AppConfig.h" +#include "AppTask.h" #include "PumpManager.h" #include @@ -31,7 +34,17 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & { if (attributePath.mClusterId == OnOff::Id && attributePath.mAttributeId == OnOff::Attributes::OnOff::Id) { - PumpMgr().InitiateAction(0, *value ? PumpManager::LOCK_ACTION : PumpManager::UNLOCK_ACTION); + PumpMgr().InitiateAction(0, *value ? PumpManager::START_ACTION : PumpManager::STOP_ACTION); + } + else if (attributePath.mClusterId == LevelControl::Id && + attributePath.mAttributeId == LevelControl::Attributes::CurrentLevel::Id) + { + ChipLogProgress(Zcl, "[pump-app] Cluster LevelControl: attribute CurrentLevel set to %" PRIu8, *value); + } + else + { + ChipLogProgress(Zcl, "Unknown attribute ID: " ChipLogFormatMEI, ChipLogValueMEI(attributePath.mAttributeId)); + return; } } @@ -52,5 +65,5 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & */ void emberAfOnOffClusterInitCallback(EndpointId endpoint) { - // TODO: implement any additional Cluster Server init actions + GetAppTask().UpdateClusterState(); } diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppEvent.h b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppEvent.h index ad9e93ee3ad1a5..14c9f045231e2a 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppEvent.h +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppEvent.h @@ -37,6 +37,7 @@ struct AppEvent kAppEventButtonType_None = 0, kAppEventButtonType_Clicked, kAppEventButtonType_LongClicked, + kAppEventButtonType_LongPressed, }; enum AppEventType Type; @@ -51,7 +52,7 @@ struct AppEvent struct { void * Context; - } BoltLockEvent; + } PumpStateEvent; }; EventHandler Handler; diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppTask.h b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppTask.h index 7c6345e1bd9c26..65fb71df49adc9 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppTask.h +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppTask.h @@ -37,15 +37,15 @@ class AppTask int StartAppTask(); static void AppTaskMain(void * pvParameter); - void PostLockActionRequest(int32_t aActor, PumpManager::Action_t aAction); + void PostStartActionRequest(int32_t aActor, PumpManager::Action_t aAction); void PostEvent(const AppEvent * event); + void UpdateClusterState(); private: friend AppTask & GetAppTask(void); int Init(); - // should this be done by BoltLock Manager? I don't want to unravel this spaghetti quite yet static void ActionInitiated(PumpManager::Action_t aAction, int32_t aActor); static void ActionCompleted(PumpManager::Action_t aAction); diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/BoltLockManager.h b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/BoltLockManager.h deleted file mode 100644 index 40fc4ffb338a67..00000000000000 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/BoltLockManager.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * 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. - */ - -#ifndef LOCK_MANAGER_H -#define LOCK_MANAGER_H - -#include -#include - -#include "AppEvent.h" - -#include -#include - -class BoltLockManager -{ -public: - enum Action_t - { - LOCK_ACTION = 0, - UNLOCK_ACTION, - - INVALID_ACTION - } Action; - - enum State_t - { - kState_LockingInitiated = 0, - kState_LockingCompleted, - kState_UnlockingInitiated, - kState_UnlockingCompleted, - } State; - - int Init(); - bool IsUnlocked(); - void EnableAutoRelock(bool aOn); - void SetAutoLockDuration(uint32_t aDurationInSecs); - bool IsActionInProgress(); - bool InitiateAction(int32_t aActor, Action_t aAction); - - typedef void (*Callback_fn_initiated)(Action_t, int32_t aActor); - typedef void (*Callback_fn_completed)(Action_t); - void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); - -private: - friend BoltLockManager & BoltLockMgr(void); - State_t mState; - - Callback_fn_initiated mActionInitiated_CB; - Callback_fn_completed mActionCompleted_CB; - - bool mAutoRelock; - uint32_t mAutoLockDuration; - bool mAutoLockTimerArmed; - TimerHandle_t mTimerHandle; - - void CancelTimer(void); - void StartTimer(uint32_t aTimeoutMs); - - static void TimerEventHandler(TimerHandle_t aTimer); - static void AutoReLockTimerEventHandler(AppEvent * aEvent); - static void ActuatorMovementTimerEventHandler(AppEvent * aEvent); - - static BoltLockManager sLock; -}; - -inline BoltLockManager & BoltLockMgr(void) -{ - return BoltLockManager::sLock; -} - -#endif // LOCK_MANAGER_H diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/PumpManager.h b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/PumpManager.h index ec83d508f91c1e..62988216fec1fb 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/PumpManager.h +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/PumpManager.h @@ -16,8 +16,8 @@ * limitations under the License. */ -#ifndef LOCK_MANAGER_H -#define LOCK_MANAGER_H +#ifndef PUMP_MANAGER_H +#define PUMP_MANAGER_H #include #include @@ -32,27 +32,41 @@ class PumpManager public: enum Action_t { - LOCK_ACTION = 0, - UNLOCK_ACTION, + START_ACTION = 0, + STOP_ACTION, INVALID_ACTION } Action; enum State_t { - kState_LockingInitiated = 0, - kState_LockingCompleted, - kState_UnlockingInitiated, - kState_UnlockingCompleted, + kState_StartInitiated = 0, + kState_StartCompleted, + kState_StopInitiated, + kState_StopCompleted, } State; int Init(); - bool IsUnlocked(); - void EnableAutoRelock(bool aOn); - void SetAutoLockDuration(uint32_t aDurationInSecs); + bool IsStopped(); + void EnableAutoRestart(bool aOn); + void SetAutoStartDuration(uint32_t aDurationInSecs); bool IsActionInProgress(); bool InitiateAction(int32_t aActor, Action_t aAction); + int16_t GetMaxPressure(); + uint16_t GetMaxSpeed(); + uint16_t GetMaxFlow(); + int16_t GetMinConstPressure(); + int16_t GetMaxConstPressure(); + int16_t GetMinCompPressure(); + int16_t GetMaxCompPressure(); + uint16_t GetMinConstSpeed(); + uint16_t GetMaxConstSpeed(); + uint16_t GetMinConstFlow(); + uint16_t GetMaxConstFlow(); + int16_t GetMinConstTemp(); + int16_t GetMaxConstTemp(); + typedef void (*Callback_fn_initiated)(Action_t, int32_t aActor); typedef void (*Callback_fn_completed)(Action_t); void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); @@ -64,24 +78,24 @@ class PumpManager Callback_fn_initiated mActionInitiated_CB; Callback_fn_completed mActionCompleted_CB; - bool mAutoRelock; - uint32_t mAutoLockDuration; - bool mAutoLockTimerArmed; + bool mAutoRestart; + uint32_t mAutoStartDuration; + bool mAutoStartTimerArmed; TimerHandle_t mTimerHandle; void CancelTimer(void); - void StartTimer(uint32_t aTimeoutMs); + void PumpTimer(uint32_t aTimeoutMs); static void TimerEventHandler(TimerHandle_t aTimer); - static void AutoReLockTimerEventHandler(AppEvent * aEvent); + static void AutoRestartTimerEventHandler(AppEvent * aEvent); static void ActuatorMovementTimerEventHandler(AppEvent * aEvent); - static PumpManager sLock; + static PumpManager sPump; }; inline PumpManager & PumpMgr(void) { - return PumpManager::sLock; + return PumpManager::sPump; } -#endif // LOCK_MANAGER_H +#endif // PUMP_MANAGER_H diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/main.cpp b/examples/pump-controller-app/cc13x2x7_26x2x7/main/main.cpp index 1ed5409a721cce..3cda02fd8b05b0 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/main.cpp +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/main.cpp @@ -37,7 +37,7 @@ #include #include -#define TOTAL_ICALL_HEAP_SIZE (0xf000) +#define TOTAL_ICALL_HEAP_SIZE (0xE000) using namespace ::chip; using namespace ::chip::Inet; @@ -77,8 +77,8 @@ int main(void) SHA2_init(); - CHIP_ERROR ret = GetAppTask().StartAppTask(); - if (ret != CHIP_NO_ERROR) + int ret = GetAppTask().StartAppTask(); + if (ret != 0) { // can't log until the kernel is started // PLAT_LOG("GetAppTask().StartAppTask() failed"); From e7d9be41ce0c9ef87ed8e13510e704b888839d30 Mon Sep 17 00:00:00 2001 From: Anders Bang Poulsen Date: Thu, 14 Oct 2021 09:47:14 +0200 Subject: [PATCH 04/23] Restyle changed files --- .../cc13x2x7_26x2x7/README.md | 44 ++++++++++--------- .../cc13x2x7_26x2x7/main/AppTask.cpp | 4 +- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/README.md b/examples/pump-controller-app/cc13x2x7_26x2x7/README.md index 573ea74ca7d007..e0c656e51b5dce 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/README.md +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/README.md @@ -1,7 +1,7 @@ # Matter CC1352 CC2652 Pump Controller Example Application -An example application showing the use of [Matter][matter] on the Texas Instruments -CC13X2_26X2 family of Wireless MCUs. +An example application showing the use of [Matter][matter] on the Texas +Instruments CC13X2_26X2 family of Wireless MCUs. --- @@ -28,9 +28,10 @@ CC13X2_26X2 family of Wireless MCUs. ![CC1352R1_LAUNCHXL](doc/images/cc1352r1_launchxl.jpg) -The CC13X2_26X2 pump controller example application provides a working demonstration of a -connected pump controller device. This uses the open-source Matter implementation and -the Texas Instruments SimpleLinkā„¢ CC13x2 and CC26x2 software development kit. +The CC13X2_26X2 pump controller example application provides a working +demonstration of a connected pump controller device. This uses the open-source +Matter implementation and the Texas Instruments SimpleLinkā„¢ CC13x2 and CC26x2 +software development kit. This example is enabled to build for CC2652R7 devices. This upcoming devices are currently not yet in full production. For more information on device @@ -44,19 +45,20 @@ Instruments devices. ## Device UI This example application has a simple User Interface to depict the state of the -pump and to control the state. The user LEDs on the LaunchPad are set on -when the pump is started, and are set off when stopped. The LEDs will flash when -in the transition state between started and stopped. +pump and to control the state. The user LEDs on the LaunchPad are set on when +the pump is started, and are set off when stopped. The LEDs will flash when in +the transition state between started and stopped. -Short presses (less than 1000ms) of the left user button (`BTN-1`) are used for +Short presses (less than 1000ms) of the left user button (`BTN-1`) are used for toggeling the pump state. -Short presses (less than 1000ms) of the right user button (`BTN-2`) are used for +Short presses (less than 1000ms) of the right user button (`BTN-2`) are used for toggeling Matter BLE advertisements. Long presses (greater than 5000ms) of the right user button (`BTN-2`) will -initiate a factory reset of the device clearing all stored provisioning information -to allow for a new network setup. +initiate a factory reset of the device clearing all stored provisioning +information to allow for a new network setup. + ## Building ### Preparation @@ -168,22 +170,22 @@ Router][ot_border_router_setup]. ### Provisioning -The first step to bring the Matter device onto the network is to provision it. Our -example accomplishes this with Bluetooth Low Energy (BLE) and the +The first step to bring the Matter device onto the network is to provision it. +Our example accomplishes this with Bluetooth Low Energy (BLE) and the [CHIPTool](../../../src/android/CHIPTool/README.md) mobile app. #### Bluetooth LE Advertising To provision this example onto a Thread network, the device must be discoverable -over Bluetooth LE. BLE advertising is started by pressing the right button -(less than 1000ms), labeled `BTN-2` on the silkscreen. Once the device is -fully provisioned, BLE advertising will stop. +over Bluetooth LE. BLE advertising is started by pressing the right button (less +than 1000ms), labeled `BTN-2` on the silkscreen. Once the device is fully +provisioned, BLE advertising will stop. #### Bluetooth LE Rendezvous In this example, the provisioning procedure (called Rendezvous) is done over -Bluetooth LE between a Matter device (pump-controller-app) and the Matter controller -(CHIPTool), where the controller has the commissioner role. +Bluetooth LE between a Matter device (pump-controller-app) and the Matter +controller (CHIPTool), where the controller has the commissioner role. To start the rendezvous, the controller must get the commissioning information from the Matter device. @@ -205,8 +207,8 @@ generator][qr_code_generator] and enter in the payload shown in `SetupQRCode` ### Matter Remote Commands Once the Matter device is provisioned and operating on the network, CHIPTool can -be used to control the device. During the provisioning process, the Matter device -would have sent one of its newly assigned IPv6 addresses to the CHIPTool. +be used to control the device. During the provisioning process, the Matter +device would have sent one of its newly assigned IPv6 addresses to the CHIPTool. In the app, you should see an On/Off cluster; this corresponds to the pump-app. You can now control the pump-controller-app Matter device from the smartphone! diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp index c9697d5bcc7d09..fe0fcf339a695f 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -360,6 +360,4 @@ void AppTask::DispatchEvent(AppEvent * aEvent) } } -void AppTask::UpdateClusterState() -{ -} +void AppTask::UpdateClusterState() {} From 3d4d803d23482c61772acf2ee8ff86d224fb333d Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 14 Oct 2021 08:15:05 +0000 Subject: [PATCH 05/23] Restyled by whitespace --- examples/pump-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp index 902ddf83b96758..4d97751ad0a190 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp +++ b/examples/pump-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp @@ -72,4 +72,4 @@ void emberAfPumpConfigurationAndControlClusterInitCallback(chip::EndpointId endp { // TODO: Setup the default values in the cluster for this specific application GetAppTask().UpdateClusterState(); -} \ No newline at end of file +} From 8a9135bf8032b9306450b5c8c086cb908812f3fd Mon Sep 17 00:00:00 2001 From: Anders Bang Poulsen Date: Thu, 14 Oct 2021 10:34:13 +0200 Subject: [PATCH 06/23] Removed submodule added from bad merge. --- third_party/wifi-ism43362/repo | 1 - 1 file changed, 1 deletion(-) delete mode 160000 third_party/wifi-ism43362/repo diff --git a/third_party/wifi-ism43362/repo b/third_party/wifi-ism43362/repo deleted file mode 160000 index a75d553bdc6232..00000000000000 --- a/third_party/wifi-ism43362/repo +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a75d553bdc62322ec98634a29c2b697681dff8ec From d1ec9216d016b3a68e15803011ada9940ba84c0c Mon Sep 17 00:00:00 2001 From: Anders Bang Poulsen Date: Thu, 14 Oct 2021 10:41:44 +0200 Subject: [PATCH 07/23] Reverted zap repo to correct version --- third_party/zap/repo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/zap/repo b/third_party/zap/repo index 85d174c67697c6..085c08cd1f8ce0 160000 --- a/third_party/zap/repo +++ b/third_party/zap/repo @@ -1 +1 @@ -Subproject commit 85d174c67697c6e45a632669d2f846030aad9237 +Subproject commit 085c08cd1f8ce016318c3ec5972756b9d264a553 From 8194357449c65919b1ec2b03ad605b3ab74f22f7 Mon Sep 17 00:00:00 2001 From: Anders Bang Poulsen Date: Thu, 14 Oct 2021 10:46:08 +0200 Subject: [PATCH 08/23] Corrected spelling --- examples/pump-app/cc13x2x7_26x2x7/README.md | 4 ++-- examples/pump-controller-app/cc13x2x7_26x2x7/README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/pump-app/cc13x2x7_26x2x7/README.md b/examples/pump-app/cc13x2x7_26x2x7/README.md index 66cc366c337ea3..b8e270f63d9e4d 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/README.md +++ b/examples/pump-app/cc13x2x7_26x2x7/README.md @@ -49,10 +49,10 @@ the pump is started, and are set off when stopped. The LEDs will flash when in the transition state between started and stopped. Short presses (less than 1000ms) of the left user button (`BTN-1`) are used for -toggeling the pump state. +toggling the pump state. Short presses (less than 1000ms) of the right user button (`BTN-2`) are used for -toggeling Matter BLE advertisements. +toggling Matter BLE advertisements. Long presses (greater than 5000ms) of the right user button (`BTN-2`) will initiate a factory reset of the device clearing all stored provisioning diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/README.md b/examples/pump-controller-app/cc13x2x7_26x2x7/README.md index e0c656e51b5dce..b252a2fce7d6a1 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/README.md +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/README.md @@ -50,10 +50,10 @@ the pump is started, and are set off when stopped. The LEDs will flash when in the transition state between started and stopped. Short presses (less than 1000ms) of the left user button (`BTN-1`) are used for -toggeling the pump state. +toggling the pump state. Short presses (less than 1000ms) of the right user button (`BTN-2`) are used for -toggeling Matter BLE advertisements. +toggling Matter BLE advertisements. Long presses (greater than 5000ms) of the right user button (`BTN-2`) will initiate a factory reset of the device clearing all stored provisioning From fe1288d1e5eadc50d649cd5f885620c4161a0e78 Mon Sep 17 00:00:00 2001 From: Anders Bang Poulsen Date: Thu, 14 Oct 2021 14:39:25 +0200 Subject: [PATCH 09/23] Enabled extended discovery to support multiadmin on TI platform --- src/platform/cc13x2_26x2/CHIPDevicePlatformConfig.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/platform/cc13x2_26x2/CHIPDevicePlatformConfig.h b/src/platform/cc13x2_26x2/CHIPDevicePlatformConfig.h index 965bde2f9db848..e003125ca4a247 100644 --- a/src/platform/cc13x2_26x2/CHIPDevicePlatformConfig.h +++ b/src/platform/cc13x2_26x2/CHIPDevicePlatformConfig.h @@ -50,3 +50,8 @@ // disabled for Locks and Barrier Access Devices. #define CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART 0 #define CHIP_DEVICE_CONFIG_ENABLE_PAIRING_AUTOSTART 0 + +#define CHIP_DEVICE_CONFIG_ENABLE_DNSSD 1 +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT 1 +#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1 +#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DISCOVERY 1 \ No newline at end of file From e19a91078f6f64df8d2b0a81cbf8b68c69933bbb Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 14 Oct 2021 12:41:24 +0000 Subject: [PATCH 10/23] Restyled by whitespace --- src/platform/cc13x2_26x2/CHIPDevicePlatformConfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/cc13x2_26x2/CHIPDevicePlatformConfig.h b/src/platform/cc13x2_26x2/CHIPDevicePlatformConfig.h index e003125ca4a247..bddae508acea2b 100644 --- a/src/platform/cc13x2_26x2/CHIPDevicePlatformConfig.h +++ b/src/platform/cc13x2_26x2/CHIPDevicePlatformConfig.h @@ -54,4 +54,4 @@ #define CHIP_DEVICE_CONFIG_ENABLE_DNSSD 1 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT 1 #define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1 -#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DISCOVERY 1 \ No newline at end of file +#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DISCOVERY 1 From 2d319bcd6251958e2d2d15a6c4963c98ff87f6e0 Mon Sep 17 00:00:00 2001 From: Anders Bang Poulsen Date: Fri, 15 Oct 2021 10:20:41 +0200 Subject: [PATCH 11/23] pump-app: Replaced use of emberAfWriteServerAttribute calls with correct accessor methods --- .../pump-app/cc13x2x7_26x2x7/main/AppTask.cpp | 50 +++++++++---------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp index ba4323c79195f5..204c7b19ef47f3 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include "FreeRTOS.h" @@ -51,6 +52,7 @@ using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; +using namespace ::chip::app::Clusters; static TaskHandle_t sAppTaskHandle; static QueueHandle_t sAppEventQueue; @@ -367,105 +369,101 @@ void AppTask::UpdateClusterState() ChipLogProgress(NotSpecified, "UpdateClusterState"); // write the new values + + bool onOffState = !PumpMgr().IsStopped(); + + status = OnOff::Attributes::OnOff::Set(1, onOffState); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxPressure %" PRIx8, status); + } + int16_t maxPressure = PumpMgr().GetMaxPressure(); - status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MAX_PRESSURE_ATTRIBUTE_ID, - (uint8_t *) &maxPressure, ZCL_INT16S_ATTRIBUTE_TYPE); + status = PumpConfigurationAndControl::Attributes::MaxPressure::Set(1, maxPressure); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxPressure %" PRIx8, status); } uint16_t maxSpeed = PumpMgr().GetMaxSpeed(); - status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MAX_SPEED_ATTRIBUTE_ID, (uint8_t *) &maxSpeed, - ZCL_INT16U_ATTRIBUTE_TYPE); + status = PumpConfigurationAndControl::Attributes::MaxSpeed::Set(1, maxSpeed); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxSpeed %" PRIx8, status); } uint16_t maxFlow = PumpMgr().GetMaxFlow(); - status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MAX_FLOW_ATTRIBUTE_ID, (uint8_t *) &maxFlow, - ZCL_INT16U_ATTRIBUTE_TYPE); + status = PumpConfigurationAndControl::Attributes::MaxFlow::Set(1, maxFlow); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxFlow %" PRIx8, status); } int16_t minConstPress = PumpMgr().GetMinConstPressure(); - status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MIN_CONST_PRESSURE_ATTRIBUTE_ID, - (uint8_t *) &minConstPress, ZCL_INT16S_ATTRIBUTE_TYPE); + status = PumpConfigurationAndControl::Attributes::MinConstPressure::Set(1, minConstPress); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MinConstPressure %" PRIx8, status); } int16_t maxConstPress = PumpMgr().GetMaxConstPressure(); - status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MAX_CONST_PRESSURE_ATTRIBUTE_ID, - (uint8_t *) &maxConstPress, ZCL_INT16S_ATTRIBUTE_TYPE); + status = PumpConfigurationAndControl::Attributes::MaxConstPressure::Set(1, maxConstPress); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxConstPressure %" PRIx8, status); } int16_t minCompPress = PumpMgr().GetMinCompPressure(); - status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MIN_COMP_PRESSURE_ATTRIBUTE_ID, - (uint8_t *) &minCompPress, ZCL_INT16S_ATTRIBUTE_TYPE); + status = PumpConfigurationAndControl::Attributes::MinCompPressure::Set(1, minCompPress); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MinCompPressure %" PRIx8, status); } int16_t maxCompPress = PumpMgr().GetMaxCompPressure(); - status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MAX_COMP_PRESSURE_ATTRIBUTE_ID, - (uint8_t *) &maxCompPress, ZCL_INT16S_ATTRIBUTE_TYPE); + status = PumpConfigurationAndControl::Attributes::MaxCompPressure::Set(1, maxCompPress); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxCompPressure %" PRIx8, status); } uint16_t minConstSpeed = PumpMgr().GetMinConstSpeed(); - status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MIN_CONST_SPEED_ATTRIBUTE_ID, - (uint8_t *) &minConstSpeed, ZCL_INT16U_ATTRIBUTE_TYPE); + status = PumpConfigurationAndControl::Attributes::MinConstSpeed::Set(1, minConstSpeed); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MinConstSpeed %" PRIx8, status); } uint16_t maxConstSpeed = PumpMgr().GetMaxConstSpeed(); - status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MAX_CONST_SPEED_ATTRIBUTE_ID, - (uint8_t *) &maxConstSpeed, ZCL_INT16U_ATTRIBUTE_TYPE); + status = PumpConfigurationAndControl::Attributes::MaxConstSpeed::Set(1, maxConstSpeed); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxConstSpeed %" PRIx8, status); } uint16_t minConstFlow = PumpMgr().GetMinConstFlow(); - status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MIN_CONST_FLOW_ATTRIBUTE_ID, - (uint8_t *) &minConstFlow, ZCL_INT16U_ATTRIBUTE_TYPE); + status = PumpConfigurationAndControl::Attributes::MinConstFlow::Set(1, minConstFlow); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MinConstFlow %" PRIx8, status); } uint16_t maxConstFlow = PumpMgr().GetMaxConstFlow(); - status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MAX_CONST_FLOW_ATTRIBUTE_ID, - (uint8_t *) &maxConstFlow, ZCL_INT16U_ATTRIBUTE_TYPE); + status = PumpConfigurationAndControl::Attributes::MaxConstFlow::Set(1, maxConstFlow); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxConstFlow %" PRIx8, status); } int16_t minConstTemp = PumpMgr().GetMinConstTemp(); - status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MIN_CONST_TEMP_ATTRIBUTE_ID, - (uint8_t *) &minConstTemp, ZCL_INT16S_ATTRIBUTE_TYPE); + status = PumpConfigurationAndControl::Attributes::MinConstTemp::Set(1, minConstTemp); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MinConstTemp %" PRIx8, status); } int16_t maxConstTemp = PumpMgr().GetMaxConstTemp(); - status = emberAfWriteServerAttribute(1, ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID, ZCL_MAX_CONST_TEMP_ATTRIBUTE_ID, - (uint8_t *) &maxConstTemp, ZCL_INT16S_ATTRIBUTE_TYPE); + status = PumpConfigurationAndControl::Attributes::MaxConstTemp::Set(1, maxConstTemp); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxConstTemp %" PRIx8, status); From 16d223f76bf3c516d37af55dde18f1a464b8b6bc Mon Sep 17 00:00:00 2001 From: Anders Bang Poulsen Date: Fri, 15 Oct 2021 13:10:26 +0200 Subject: [PATCH 12/23] Fixed a typo in the log output for UpdateClusterState --- examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp index 204c7b19ef47f3..4776cc0b773fab 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -375,7 +375,7 @@ void AppTask::UpdateClusterState() status = OnOff::Attributes::OnOff::Set(1, onOffState); if (status != EMBER_ZCL_STATUS_SUCCESS) { - ChipLogError(NotSpecified, "ERR: Updating MaxPressure %" PRIx8, status); + ChipLogError(NotSpecified, "ERR: Updating On/Off state %" PRIx8, status); } int16_t maxPressure = PumpMgr().GetMaxPressure(); From 89c6e3b7983764f27b358efe52040467d2085e4a Mon Sep 17 00:00:00 2001 From: Anders Bang Poulsen Date: Fri, 15 Oct 2021 13:48:32 +0200 Subject: [PATCH 13/23] Replaced usage of emberAf call's with correct accessors for nrfconnect pump examples. Added update of on/off cluster when button is pressed in TI pump examples so they match the nrfconnect example behavior. --- .../pump-app/cc13x2x7_26x2x7/main/AppTask.cpp | 117 +++++++++++++++++- .../cc13x2x7_26x2x7/main/PumpManager.cpp | 10 +- .../cc13x2x7_26x2x7/main/include/AppTask.h | 2 +- .../main/include/CHIPProjectConfig.h | 4 +- .../main/include/PumpManager.h | 3 +- examples/pump-app/nrfconnect/main/AppTask.cpp | 110 +++++++++++++++- .../cc13x2x7_26x2x7/main/AppTask.cpp | 25 +++- .../cc13x2x7_26x2x7/main/PumpManager.cpp | 6 +- .../cc13x2x7_26x2x7/main/include/AppTask.h | 2 +- .../main/include/PumpManager.h | 3 +- .../nrfconnect/main/AppTask.cpp | 16 ++- 11 files changed, 271 insertions(+), 27 deletions(-) diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp index 50a0d017ecfc80..04bb7b8b9b4935 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -45,6 +45,9 @@ #define APP_TASK_PRIORITY 4 #define APP_EVENT_QUEUE_SIZE 10 +#define PCC_CLUSTER_ENDPOINT 1 +#define ONOFF_CLUSTER_ENDPOINT 1 + using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; @@ -276,7 +279,7 @@ void AppTask::ActionInitiated(PumpManager::Action_t aAction, int32_t aActor) LED_startBlinking(sAppRedHandle, 110 /* ms */, LED_BLINK_FOREVER); } -void AppTask::ActionCompleted(PumpManager::Action_t aAction) +void AppTask::ActionCompleted(PumpManager::Action_t aAction, int32_t aActor) { // if the action has been completed by the lock, update the bolt lock trait. // Turn on the lock LED if in a LOCKED state OR @@ -297,6 +300,10 @@ void AppTask::ActionCompleted(PumpManager::Action_t aAction) LED_stopBlinking(sAppRedHandle); LED_setOff(sAppRedHandle); } + if (aActor == AppEvent::kEventType_ButtonLeft) + { + sAppTask.UpdateClusterState(); + } } void AppTask::DispatchEvent(AppEvent * aEvent) @@ -359,3 +366,111 @@ void AppTask::DispatchEvent(AppEvent * aEvent) break; } } + +void AppTask::UpdateClusterState() +{ + EmberStatus status; + + ChipLogProgress(NotSpecified, "UpdateClusterState"); + + // Write the new values + + bool onOffState = !PumpMgr().IsStopped(); + + status = OnOff::Attributes::OnOff::Set(ONOFF_CLUSTER_ENDPOINT, onOffState); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating On/Off state %" PRIx8, status); + } + + int16_t maxPressure = PumpMgr().GetMaxPressure(); + status = PumpConfigurationAndControl::Attributes::MaxPressure::Set(PCC_CLUSTER_ENDPOINT, maxPressure); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxPressure %" PRIx8, status); + } + + uint16_t maxSpeed = PumpMgr().GetMaxSpeed(); + status = PumpConfigurationAndControl::Attributes::MaxSpeed::Set(PCC_CLUSTER_ENDPOINT, maxSpeed); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxSpeed %" PRIx8, status); + } + + uint16_t maxFlow = PumpMgr().GetMaxFlow(); + status = PumpConfigurationAndControl::Attributes::MaxFlow::Set(PCC_CLUSTER_ENDPOINT, maxFlow); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxFlow %" PRIx8, status); + } + + int16_t minConstPress = PumpMgr().GetMinConstPressure(); + status = PumpConfigurationAndControl::Attributes::MinConstPressure::Set(PCC_CLUSTER_ENDPOINT, minConstPress); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MinConstPressure %" PRIx8, status); + } + + int16_t maxConstPress = PumpMgr().GetMaxConstPressure(); + status = PumpConfigurationAndControl::Attributes::MaxConstPressure::Set(PCC_CLUSTER_ENDPOINT, maxConstPress); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxConstPressure %" PRIx8, status); + } + + int16_t minCompPress = PumpMgr().GetMinCompPressure(); + status = PumpConfigurationAndControl::Attributes::MinCompPressure::Set(PCC_CLUSTER_ENDPOINT, minCompPress); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MinCompPressure %" PRIx8, status); + } + + int16_t maxCompPress = PumpMgr().GetMaxCompPressure(); + status = PumpConfigurationAndControl::Attributes::MaxCompPressure::Set(PCC_CLUSTER_ENDPOINT, maxCompPress); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxCompPressure %" PRIx8, status); + } + + uint16_t minConstSpeed = PumpMgr().GetMinConstSpeed(); + status = PumpConfigurationAndControl::Attributes::MinConstSpeed::Set(PCC_CLUSTER_ENDPOINT, minConstSpeed); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MinConstSpeed %" PRIx8, status); + } + + uint16_t maxConstSpeed = PumpMgr().GetMaxConstSpeed(); + status = PumpConfigurationAndControl::Attributes::MaxConstSpeed::Set(PCC_CLUSTER_ENDPOINT, maxConstSpeed); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxConstSpeed %" PRIx8, status); + } + + uint16_t minConstFlow = PumpMgr().GetMinConstFlow(); + status = PumpConfigurationAndControl::Attributes::MinConstFlow::Set(PCC_CLUSTER_ENDPOINT, minConstFlow); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MinConstFlow %" PRIx8, status); + } + + uint16_t maxConstFlow = PumpMgr().GetMaxConstFlow(); + status = PumpConfigurationAndControl::Attributes::MaxConstFlow::Set(PCC_CLUSTER_ENDPOINT, maxConstFlow); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxConstFlow %" PRIx8, status); + } + + int16_t minConstTemp = PumpMgr().GetMinConstTemp(); + status = PumpConfigurationAndControl::Attributes::MinConstTemp::Set(PCC_CLUSTER_ENDPOINT, minConstTemp); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MinConstTemp %" PRIx8, status); + } + + int16_t maxConstTemp = PumpMgr().GetMaxConstTemp(); + status = PumpConfigurationAndControl::Attributes::MaxConstTemp::Set(PCC_CLUSTER_ENDPOINT, maxConstTemp); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxConstTemp %" PRIx8, status); + } +} diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/PumpManager.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/PumpManager.cpp index 7869171d77f1f0..d6b6539e24e02c 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/PumpManager.cpp +++ b/examples/pump-app/cc13x2x7_26x2x7/main/PumpManager.cpp @@ -82,14 +82,14 @@ bool PumpManager::InitiateAction(int32_t aActor, Action_t aAction) if (mState == kState_LockingCompleted && aAction == UNLOCK_ACTION) { action_initiated = true; - - new_state = kState_UnlockingInitiated; + mCurrentActor = aActor; + new_state = kState_StopInitiated; } else if (mState == kState_UnlockingCompleted && aAction == LOCK_ACTION) { action_initiated = true; - - new_state = kState_LockingInitiated; + mCurrentActor = aActor; + new_state = kState_StartInitiated; } if (action_initiated) @@ -188,7 +188,7 @@ void PumpManager::ActuatorMovementTimerEventHandler(AppEvent * aEvent) { if (lock->mActionCompleted_CB) { - lock->mActionCompleted_CB(actionCompleted); + pump->mActionCompleted_CB(actionCompleted, pump->mCurrentActor); } if (lock->mAutoRelock && actionCompleted == UNLOCK_ACTION) diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h b/examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h index 7c6345e1bd9c26..09db37ae75d90a 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h +++ b/examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h @@ -47,7 +47,7 @@ class AppTask // should this be done by BoltLock Manager? I don't want to unravel this spaghetti quite yet static void ActionInitiated(PumpManager::Action_t aAction, int32_t aActor); - static void ActionCompleted(PumpManager::Action_t aAction); + static void ActionCompleted(PumpManager::Action_t aAction, int32_t aActor); void DispatchEvent(AppEvent * event); diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h b/examples/pump-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h index c0330d33d649df..eb7d5dc45d90dd 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h +++ b/examples/pump-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h @@ -41,8 +41,8 @@ // authentication in various protocols. // WARNING: These options make it possible to circumvent basic CHIP security functionality, // including message encryption. Because of this they MUST NEVER BE ENABLED IN PRODUCTION BUILDS. -#define CHIP_CONFIG_SECURITY_TEST_MODE 1 -#define CHIP_CONFIG_REQUIRE_AUTH 0 +#define CHIP_CONFIG_SECURITY_TEST_MODE 0 +#define CHIP_CONFIG_REQUIRE_AUTH 1 /** * CHIP_DEVICE_CONFIG_ENABLE_TEST_DEVICE_IDENTITY diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/include/PumpManager.h b/examples/pump-app/cc13x2x7_26x2x7/main/include/PumpManager.h index ec83d508f91c1e..4c5161ecf0e8f3 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/include/PumpManager.h +++ b/examples/pump-app/cc13x2x7_26x2x7/main/include/PumpManager.h @@ -54,7 +54,7 @@ class PumpManager bool InitiateAction(int32_t aActor, Action_t aAction); typedef void (*Callback_fn_initiated)(Action_t, int32_t aActor); - typedef void (*Callback_fn_completed)(Action_t); + typedef void (*Callback_fn_completed)(Action_t, int32_t aActor); void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); private: @@ -68,6 +68,7 @@ class PumpManager uint32_t mAutoLockDuration; bool mAutoLockTimerArmed; TimerHandle_t mTimerHandle; + int32_t mCurrentActor; void CancelTimer(void); void StartTimer(uint32_t aTimeoutMs); diff --git a/examples/pump-app/nrfconnect/main/AppTask.cpp b/examples/pump-app/nrfconnect/main/AppTask.cpp index 0a61538f227f5c..c9d5d02b5aed5b 100644 --- a/examples/pump-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-app/nrfconnect/main/AppTask.cpp @@ -44,6 +44,9 @@ #define BUTTON_PUSH_EVENT 1 #define BUTTON_RELEASE_EVENT 0 +#define PCC_CLUSTER_ENDPOINT 1 +#define ONOFF_CLUSTER_ENDPOINT 1 + LOG_MODULE_DECLARE(app); K_MSGQ_DEFINE(sAppEventQueue, sizeof(AppEvent), APP_EVENT_QUEUE_SIZE, alignof(AppEvent)); @@ -500,13 +503,108 @@ void AppTask::DispatchEvent(AppEvent * aEvent) void AppTask::UpdateClusterState() { - uint8_t newValue = !PumpMgr().IsStopped(); + EmberStatus status; + + ChipLogProgress(NotSpecified, "UpdateClusterState"); + + // Write the new values + + bool onOffState = !PumpMgr().IsStopped(); - // write the new on/off value - EmberAfStatus status = emberAfWriteAttribute(1, ZCL_ON_OFF_CLUSTER_ID, ZCL_ON_OFF_ATTRIBUTE_ID, CLUSTER_MASK_SERVER, &newValue, - ZCL_BOOLEAN_ATTRIBUTE_TYPE); + status = OnOff::Attributes::OnOff::Set(ONOFF_CLUSTER_ENDPOINT, onOffState); if (status != EMBER_ZCL_STATUS_SUCCESS) { - LOG_ERR("Updating on/off %x", status); + ChipLogError(NotSpecified, "ERR: Updating On/Off state %" PRIx8, status); } -} + + int16_t maxPressure = PumpMgr().GetMaxPressure(); + status = PumpConfigurationAndControl::Attributes::MaxPressure::Set(PCC_CLUSTER_ENDPOINT, maxPressure); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxPressure %" PRIx8, status); + } + + uint16_t maxSpeed = PumpMgr().GetMaxSpeed(); + status = PumpConfigurationAndControl::Attributes::MaxSpeed::Set(PCC_CLUSTER_ENDPOINT, maxSpeed); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxSpeed %" PRIx8, status); + } + + uint16_t maxFlow = PumpMgr().GetMaxFlow(); + status = PumpConfigurationAndControl::Attributes::MaxFlow::Set(PCC_CLUSTER_ENDPOINT, maxFlow); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxFlow %" PRIx8, status); + } + + int16_t minConstPress = PumpMgr().GetMinConstPressure(); + status = PumpConfigurationAndControl::Attributes::MinConstPressure::Set(PCC_CLUSTER_ENDPOINT, minConstPress); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MinConstPressure %" PRIx8, status); + } + + int16_t maxConstPress = PumpMgr().GetMaxConstPressure(); + status = PumpConfigurationAndControl::Attributes::MaxConstPressure::Set(PCC_CLUSTER_ENDPOINT, maxConstPress); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxConstPressure %" PRIx8, status); + } + + int16_t minCompPress = PumpMgr().GetMinCompPressure(); + status = PumpConfigurationAndControl::Attributes::MinCompPressure::Set(PCC_CLUSTER_ENDPOINT, minCompPress); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MinCompPressure %" PRIx8, status); + } + + int16_t maxCompPress = PumpMgr().GetMaxCompPressure(); + status = PumpConfigurationAndControl::Attributes::MaxCompPressure::Set(PCC_CLUSTER_ENDPOINT, maxCompPress); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxCompPressure %" PRIx8, status); + } + + uint16_t minConstSpeed = PumpMgr().GetMinConstSpeed(); + status = PumpConfigurationAndControl::Attributes::MinConstSpeed::Set(PCC_CLUSTER_ENDPOINT, minConstSpeed); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MinConstSpeed %" PRIx8, status); + } + + uint16_t maxConstSpeed = PumpMgr().GetMaxConstSpeed(); + status = PumpConfigurationAndControl::Attributes::MaxConstSpeed::Set(PCC_CLUSTER_ENDPOINT, maxConstSpeed); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxConstSpeed %" PRIx8, status); + } + + uint16_t minConstFlow = PumpMgr().GetMinConstFlow(); + status = PumpConfigurationAndControl::Attributes::MinConstFlow::Set(PCC_CLUSTER_ENDPOINT, minConstFlow); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MinConstFlow %" PRIx8, status); + } + + uint16_t maxConstFlow = PumpMgr().GetMaxConstFlow(); + status = PumpConfigurationAndControl::Attributes::MaxConstFlow::Set(PCC_CLUSTER_ENDPOINT, maxConstFlow); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxConstFlow %" PRIx8, status); + } + + int16_t minConstTemp = PumpMgr().GetMinConstTemp(); + status = PumpConfigurationAndControl::Attributes::MinConstTemp::Set(PCC_CLUSTER_ENDPOINT, minConstTemp); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MinConstTemp %" PRIx8, status); + } + + int16_t maxConstTemp = PumpMgr().GetMaxConstTemp(); + status = PumpConfigurationAndControl::Attributes::MaxConstTemp::Set(PCC_CLUSTER_ENDPOINT, maxConstTemp); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxConstTemp %" PRIx8, status); + } +} \ No newline at end of file diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp index dd2d3d63200f7f..5fb19ee90526bd 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -45,6 +45,8 @@ #define APP_TASK_PRIORITY 4 #define APP_EVENT_QUEUE_SIZE 10 +#define ONOFF_CLUSTER_ENDPOINT 1 + using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; @@ -276,7 +278,7 @@ void AppTask::ActionInitiated(PumpManager::Action_t aAction, int32_t aActor) LED_startBlinking(sAppRedHandle, 110 /* ms */, LED_BLINK_FOREVER); } -void AppTask::ActionCompleted(PumpManager::Action_t aAction) +void AppTask::ActionCompleted(PumpManager::Action_t aAction, int32_t aActor) { // if the action has been completed by the lock, update the bolt lock trait. // Turn on the lock LED if in a LOCKED state OR @@ -297,6 +299,10 @@ void AppTask::ActionCompleted(PumpManager::Action_t aAction) LED_stopBlinking(sAppRedHandle); LED_setOff(sAppRedHandle); } + if (aActor == AppEvent::kEventType_ButtonLeft) + { + sAppTask.UpdateClusterState(); + } } void AppTask::DispatchEvent(AppEvent * aEvent) @@ -359,3 +365,20 @@ void AppTask::DispatchEvent(AppEvent * aEvent) break; } } + +void AppTask::UpdateClusterState() +{ + EmberStatus status; + + ChipLogProgress(NotSpecified, "UpdateClusterState"); + + // Write the new values + + bool onOffState = !PumpMgr().IsStopped(); + + status = OnOff::Attributes::OnOff::Set(ONOFF_CLUSTER_ENDPOINT, onOffState); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating On/Off state %" PRIx8, status); + } +} \ No newline at end of file diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/PumpManager.cpp b/examples/pump-controller-app/cc13x2x7_26x2x7/main/PumpManager.cpp index 7869171d77f1f0..82b4925202967a 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/PumpManager.cpp +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/PumpManager.cpp @@ -82,13 +82,13 @@ bool PumpManager::InitiateAction(int32_t aActor, Action_t aAction) if (mState == kState_LockingCompleted && aAction == UNLOCK_ACTION) { action_initiated = true; - + mCurrentActor = aActor; new_state = kState_UnlockingInitiated; } else if (mState == kState_UnlockingCompleted && aAction == LOCK_ACTION) { action_initiated = true; - + mCurrentActor = aActor; new_state = kState_LockingInitiated; } @@ -188,7 +188,7 @@ void PumpManager::ActuatorMovementTimerEventHandler(AppEvent * aEvent) { if (lock->mActionCompleted_CB) { - lock->mActionCompleted_CB(actionCompleted); + pump->mActionCompleted_CB(actionCompleted, pump->mCurrentActor); } if (lock->mAutoRelock && actionCompleted == UNLOCK_ACTION) diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppTask.h b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppTask.h index 7c6345e1bd9c26..09db37ae75d90a 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppTask.h +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppTask.h @@ -47,7 +47,7 @@ class AppTask // should this be done by BoltLock Manager? I don't want to unravel this spaghetti quite yet static void ActionInitiated(PumpManager::Action_t aAction, int32_t aActor); - static void ActionCompleted(PumpManager::Action_t aAction); + static void ActionCompleted(PumpManager::Action_t aAction, int32_t aActor); void DispatchEvent(AppEvent * event); diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/PumpManager.h b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/PumpManager.h index ec83d508f91c1e..4c5161ecf0e8f3 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/PumpManager.h +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/PumpManager.h @@ -54,7 +54,7 @@ class PumpManager bool InitiateAction(int32_t aActor, Action_t aAction); typedef void (*Callback_fn_initiated)(Action_t, int32_t aActor); - typedef void (*Callback_fn_completed)(Action_t); + typedef void (*Callback_fn_completed)(Action_t, int32_t aActor); void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); private: @@ -68,6 +68,7 @@ class PumpManager uint32_t mAutoLockDuration; bool mAutoLockTimerArmed; TimerHandle_t mTimerHandle; + int32_t mCurrentActor; void CancelTimer(void); void StartTimer(uint32_t aTimeoutMs); diff --git a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp index 0a61538f227f5c..fcdb02c0e06e70 100644 --- a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp @@ -44,6 +44,8 @@ #define BUTTON_PUSH_EVENT 1 #define BUTTON_RELEASE_EVENT 0 +#define ONOFF_CLUSTER_ENDPOINT 1 + LOG_MODULE_DECLARE(app); K_MSGQ_DEFINE(sAppEventQueue, sizeof(AppEvent), APP_EVENT_QUEUE_SIZE, alignof(AppEvent)); @@ -500,13 +502,17 @@ void AppTask::DispatchEvent(AppEvent * aEvent) void AppTask::UpdateClusterState() { - uint8_t newValue = !PumpMgr().IsStopped(); + EmberStatus status; + + ChipLogProgress(NotSpecified, "UpdateClusterState"); + + // Write the new values + + bool onOffState = !PumpMgr().IsStopped(); - // write the new on/off value - EmberAfStatus status = emberAfWriteAttribute(1, ZCL_ON_OFF_CLUSTER_ID, ZCL_ON_OFF_ATTRIBUTE_ID, CLUSTER_MASK_SERVER, &newValue, - ZCL_BOOLEAN_ATTRIBUTE_TYPE); + status = OnOff::Attributes::OnOff::Set(ONOFF_CLUSTER_ENDPOINT, onOffState); if (status != EMBER_ZCL_STATUS_SUCCESS) { - LOG_ERR("Updating on/off %x", status); + ChipLogError(NotSpecified, "ERR: Updating On/Off state %" PRIx8, status); } } From 2dd4a6c158e328920532fab714deede04a01227b Mon Sep 17 00:00:00 2001 From: Anders Bang Poulsen Date: Fri, 15 Oct 2021 14:17:15 +0200 Subject: [PATCH 14/23] Minor merge fixes. Built all pump examples (nrf + TI) --- .../pump-app/cc13x2x7_26x2x7/main/AppTask.cpp | 7 +- examples/pump-app/nrfconnect/main/AppTask.cpp | 2 + .../pump-app/nrfconnect/main/PumpManager.cpp | 130 ++++++++++++++++++ .../nrfconnect/main/include/PumpManager.h | 14 ++ .../cc13x2x7_26x2x7/main/AppTask.cpp | 2 + .../nrfconnect/main/AppTask.cpp | 2 + .../nrfconnect/main/include/PumpManager.h | 14 ++ 7 files changed, 170 insertions(+), 1 deletion(-) diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp index 5f2d61fca5c873..59bcee93e4b00b 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -390,7 +390,12 @@ void AppTask::UpdateClusterState() if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxPressure %" PRIx8, status); - status = PumpConfigurationAndControl::Attributes::MaxSpeed::Set(1, maxSpeed); + } + + int16_t maxSpeed = PumpMgr().GetMaxSpeed(); + status = PumpConfigurationAndControl::Attributes::MaxSpeed::Set(PCC_CLUSTER_ENDPOINT, maxSpeed); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { ChipLogError(NotSpecified, "ERR: Updating MaxSpeed %" PRIx8, status); } diff --git a/examples/pump-app/nrfconnect/main/AppTask.cpp b/examples/pump-app/nrfconnect/main/AppTask.cpp index c9d5d02b5aed5b..7f30e073a0ada4 100644 --- a/examples/pump-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-app/nrfconnect/main/AppTask.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -63,6 +64,7 @@ static k_timer sFunctionTimer; using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; +using namespace ::chip::app::Clusters; AppTask AppTask::sAppTask; diff --git a/examples/pump-app/nrfconnect/main/PumpManager.cpp b/examples/pump-app/nrfconnect/main/PumpManager.cpp index 7e0c9482305df9..274ef8ff812886 100644 --- a/examples/pump-app/nrfconnect/main/PumpManager.cpp +++ b/examples/pump-app/nrfconnect/main/PumpManager.cpp @@ -187,3 +187,133 @@ void PumpManager::PumpStartTimerEventHandler(AppEvent * aEvent) } } } + +int16_t PumpManager::GetMaxPressure() +{ + // 1.6.1. MaxPressure Attribute + // Range -3276.7 kPa to 3276.7 kPa (steps of 0.1 kPa) + // -3276.8 is invalid value - perhaps 'null' + + // Return 2000.0 kPa as Max Pressure + return 20000; +} + +uint16_t PumpManager::GetMaxSpeed() +{ + // 1.6.2. MaxSpeed Attribute + // Range 0 RPM to 65534 RPM (steps of 1 RPM) + // 65535 is invalid value - perhaps 'null' + + // Return 1000 RPM as MaxSpeed + return 1000; +} + +uint16_t PumpManager::GetMaxFlow() +{ + // 1.6.3. MaxFlow Attribute + // Range 0 m3/h to 6553.4 m3/h (steps of 0.1 m3/h) + // 6553.5 m3/h is invalid value - perhaps 'null' + + // Return 200.0 m3/h as MaxFlow + return 2000; +} + +int16_t PumpManager::GetMinConstPressure() +{ + // 1.6.4. MinConstPressure Attribute + // Range -3276.7 kPa to 3276.7 kPa (steps of 0.1 kPa) + // -3276.8 is invalid value - perhaps 'null' + + // Return -100.0 kPa as MinConstPressure + return -1000; +} + +int16_t PumpManager::GetMaxConstPressure() +{ + // 1.6.5. MaxConstPressure Attribute + // Range -3276.7 kPa to 3276.7 kPa (steps of 0.1 kPa) + // -3276.8 is invalid value - perhaps 'null' + + // Return 100.0 kPa as MaxConstPressure + return 1000; +} + +int16_t PumpManager::GetMinCompPressure() +{ + // 1.6.6. MinCompPressure Attribute + // Range -3276.7 kPa to 3276.7 kPa (steps of 0.1 kPa) + // -3276.8 is invalid value - perhaps 'null' + + // Return -20.0 kPa as MinCompPressure + return -200; +} + +int16_t PumpManager::GetMaxCompPressure() +{ + // 1.6.7. MaxCompPressure Attribute + // Range -3276.7 kPa to 3276.7 kPa (steps of 0.1 kPa) + // -3276.8 is invalid value - perhaps 'null' + + // Return 20.0 kPa as MaxCompPressure + return 200; +} + +uint16_t PumpManager::GetMinConstSpeed() +{ + // 1.6.8. MinConstSpeed Attribute + // Range 0 to 65534 RPM (steps of 1 RPM) + // 65535 RPM is invalid valud - perhaps 'null' + + // Return 200 RPM as MinConstSpeed + return 200; +} + +uint16_t PumpManager::GetMaxConstSpeed() +{ + // 1.6.9. MaxConstSpeed Attribute + // Range 0 to 65534 RPM (steps of 1 RPM) + // 65535 RPM is invalid valud - perhaps 'null' + + // Return 2000 RPM as MaxConstSpeed + return 2000; +} + +uint16_t PumpManager::GetMinConstFlow() +{ + // 1.6.10. MinConstFlow Attribute + // Range 0 m3/h to 6553.4 m3/h (steps of 0.1 m3/h) + // 6553.5 m3/h is invalid value - perhaps 'null' + + // Return 12.5 m3/h as MinConstFlow + return 125; +} + +uint16_t PumpManager::GetMaxConstFlow() +{ + // 1.6.11. MaxConstFlow Attribute + // Range 0 m3/h to 6553.4 m3/h (steps of 0.1 m3/h) + // 6553.5 m3/h is invalid value - perhaps 'null' + + // Return 655.7 m3/h as MaxConstFlow + return 6557; +} + +int16_t PumpManager::GetMinConstTemp() +{ + // 1.6.12. MinConstTemp Attribute + // Range -273.15 C to 327.67 C (steps of 0.01 C) + // All other values are invalid values - perhaps 'null' + + // Return 30.00 C as MinConstTemp + return 3000; +} + +int16_t PumpManager::GetMaxConstTemp() +{ + // 1.6.13. MaxConstTemp Attribute + // Range -273.15 C to 327.67 C (steps of 0.01 C) + // All other values are invalid values - perhaps 'null' + + // Return 56.00 C as MaxConstTemp + return 5600; +} diff --git a/examples/pump-app/nrfconnect/main/include/PumpManager.h b/examples/pump-app/nrfconnect/main/include/PumpManager.h index afc1b571e40acd..eb2f0868e1242a 100644 --- a/examples/pump-app/nrfconnect/main/include/PumpManager.h +++ b/examples/pump-app/nrfconnect/main/include/PumpManager.h @@ -51,6 +51,20 @@ class PumpManager bool IsActionInProgress(); bool InitiateAction(int32_t aActor, Action_t aAction); + int16_t GetMaxPressure(); + uint16_t GetMaxSpeed(); + uint16_t GetMaxFlow(); + int16_t GetMinConstPressure(); + int16_t GetMaxConstPressure(); + int16_t GetMinCompPressure(); + int16_t GetMaxCompPressure(); + uint16_t GetMinConstSpeed(); + uint16_t GetMaxConstSpeed(); + uint16_t GetMinConstFlow(); + uint16_t GetMaxConstFlow(); + int16_t GetMinConstTemp(); + int16_t GetMaxConstTemp(); + typedef void (*Callback_fn_initiated)(Action_t, int32_t aActor); typedef void (*Callback_fn_completed)(Action_t, int32_t aActor); void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp index 71c5cf568ac420..ab4d1f2e59f410 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include "FreeRTOS.h" @@ -53,6 +54,7 @@ using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; +using namespace ::chip::app::Clusters; static TaskHandle_t sAppTaskHandle; static QueueHandle_t sAppEventQueue; diff --git a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp index fcdb02c0e06e70..5aa8121f0ac0c5 100644 --- a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -62,6 +63,7 @@ static k_timer sFunctionTimer; using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; +using namespace ::chip::app::Clusters; AppTask AppTask::sAppTask; diff --git a/examples/pump-controller-app/nrfconnect/main/include/PumpManager.h b/examples/pump-controller-app/nrfconnect/main/include/PumpManager.h index afc1b571e40acd..eb2f0868e1242a 100644 --- a/examples/pump-controller-app/nrfconnect/main/include/PumpManager.h +++ b/examples/pump-controller-app/nrfconnect/main/include/PumpManager.h @@ -51,6 +51,20 @@ class PumpManager bool IsActionInProgress(); bool InitiateAction(int32_t aActor, Action_t aAction); + int16_t GetMaxPressure(); + uint16_t GetMaxSpeed(); + uint16_t GetMaxFlow(); + int16_t GetMinConstPressure(); + int16_t GetMaxConstPressure(); + int16_t GetMinCompPressure(); + int16_t GetMaxCompPressure(); + uint16_t GetMinConstSpeed(); + uint16_t GetMaxConstSpeed(); + uint16_t GetMinConstFlow(); + uint16_t GetMaxConstFlow(); + int16_t GetMinConstTemp(); + int16_t GetMaxConstTemp(); + typedef void (*Callback_fn_initiated)(Action_t, int32_t aActor); typedef void (*Callback_fn_completed)(Action_t, int32_t aActor); void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); From 68572d37af1fad08d10941f8f3e4197e8f567a0c Mon Sep 17 00:00:00 2001 From: Anders Bang Poulsen Date: Thu, 28 Oct 2021 10:25:37 +0200 Subject: [PATCH 15/23] Fixed bad merge of AppTask.cpp for TI Pump-app --- examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp index 396f75c9dc766e..59bcee93e4b00b 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -394,6 +394,10 @@ void AppTask::UpdateClusterState() int16_t maxSpeed = PumpMgr().GetMaxSpeed(); status = PumpConfigurationAndControl::Attributes::MaxSpeed::Set(PCC_CLUSTER_ENDPOINT, maxSpeed); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxSpeed %" PRIx8, status); + } uint16_t maxFlow = PumpMgr().GetMaxFlow(); status = PumpConfigurationAndControl::Attributes::MaxFlow::Set(PCC_CLUSTER_ENDPOINT, maxFlow); From b517a50dae05febcb80c71b16b45ba3e0f5eb29d Mon Sep 17 00:00:00 2001 From: Anders Bang Poulsen Date: Thu, 28 Oct 2021 10:31:53 +0200 Subject: [PATCH 16/23] Fix bad merge of pump-manager for TI Pump App --- .../pump-app/cc13x2x7_26x2x7/main/PumpManager.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/PumpManager.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/PumpManager.cpp index 7701d96f8df2ac..1d4b5bb3daafdc 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/PumpManager.cpp +++ b/examples/pump-app/cc13x2x7_26x2x7/main/PumpManager.cpp @@ -91,12 +91,17 @@ bool PumpManager::InitiateAction(int32_t aActor, Action_t aAction) mCurrentActor = aActor; new_state = kState_StartInitiated; } + + if (action_initiated) { - // If auto start timer has been armed and someone initiates start, - // cancel the timer and continue as normal. - mAutoStartTimerArmed = false; + if (mAutoStartTimerArmed && new_state == kState_StartInitiated) + { + // If auto start timer has been armed and someone initiates start, + // cancel the timer and continue as normal. + mAutoStartTimerArmed = false; - CancelTimer(); + CancelTimer(); + } } PumpTimer(ACTUATOR_MOVEMENT_PERIOS_MS); From a233b7deb88df7bf525681a8f676073c0f1af4d4 Mon Sep 17 00:00:00 2001 From: Anders Bang Poulsen Date: Thu, 28 Oct 2021 10:34:41 +0200 Subject: [PATCH 17/23] One more attempt to fix bad merge. --- .../cc13x2x7_26x2x7/main/PumpManager.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/PumpManager.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/PumpManager.cpp index 1d4b5bb3daafdc..28af445b25caa9 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/PumpManager.cpp +++ b/examples/pump-app/cc13x2x7_26x2x7/main/PumpManager.cpp @@ -102,20 +102,18 @@ bool PumpManager::InitiateAction(int32_t aActor, Action_t aAction) CancelTimer(); } - } - PumpTimer(ACTUATOR_MOVEMENT_PERIOS_MS); + PumpTimer(ACTUATOR_MOVEMENT_PERIOS_MS); - // Since the timer started successfully, update the state and trigger callback - mState = new_state; + // Since the timer started successfully, update the state and trigger callback + mState = new_state; - if (mActionInitiated_CB) - { - mActionInitiated_CB(aAction, aActor); + if (mActionInitiated_CB) + { + mActionInitiated_CB(aAction, aActor); + } } -} - -return action_initiated; + return action_initiated; } void PumpManager::PumpTimer(uint32_t aTimeoutMs) From 710de2214f2b9f1e21095b1ef0b962329f13f9e5 Mon Sep 17 00:00:00 2001 From: Anders Bang Poulsen Date: Thu, 28 Oct 2021 11:29:27 +0200 Subject: [PATCH 18/23] Corrected type on maxSpeed attribute for pump-app --- examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp index 59bcee93e4b00b..25e449a0166555 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -392,8 +392,8 @@ void AppTask::UpdateClusterState() ChipLogError(NotSpecified, "ERR: Updating MaxPressure %" PRIx8, status); } - int16_t maxSpeed = PumpMgr().GetMaxSpeed(); - status = PumpConfigurationAndControl::Attributes::MaxSpeed::Set(PCC_CLUSTER_ENDPOINT, maxSpeed); + uint16_t maxSpeed = PumpMgr().GetMaxSpeed(); + status = PumpConfigurationAndControl::Attributes::MaxSpeed::Set(PCC_CLUSTER_ENDPOINT, maxSpeed); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxSpeed %" PRIx8, status); From 98fb78a630232bf1ccc9babd36c36fd08aae3f86 Mon Sep 17 00:00:00 2001 From: Anders Bang Poulsen Date: Thu, 28 Oct 2021 12:44:42 +0200 Subject: [PATCH 19/23] Removed On/Off cluster update from pump-controller-apps as the attribute is no longer enabled --- .../cc13x2x7_26x2x7/main/AppTask.cpp | 20 +------------------ .../nrfconnect/main/AppTask.cpp | 20 +------------------ third_party/pigweed/repo | 2 +- 3 files changed, 3 insertions(+), 39 deletions(-) diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp index 3e3a4373163d68..b728e1109508d3 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -49,11 +49,8 @@ #define APP_TASK_PRIORITY 4 #define APP_EVENT_QUEUE_SIZE 10 -#define ONOFF_CLUSTER_ENDPOINT 1 - using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; -using namespace ::chip::app::Clusters; static TaskHandle_t sAppTaskHandle; static QueueHandle_t sAppEventQueue; @@ -367,19 +364,4 @@ void AppTask::DispatchEvent(AppEvent * aEvent) } } -void AppTask::UpdateClusterState() -{ - EmberStatus status; - - ChipLogProgress(NotSpecified, "UpdateClusterState"); - - // Write the new values - - bool onOffState = !PumpMgr().IsStopped(); - - status = OnOff::Attributes::OnOff::Set(ONOFF_CLUSTER_ENDPOINT, onOffState); - if (status != EMBER_ZCL_STATUS_SUCCESS) - { - ChipLogError(NotSpecified, "ERR: Updating On/Off state %" PRIx8, status); - } -} +void AppTask::UpdateClusterState() {} diff --git a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp index 4b3cb7461f95ac..dd4cd3d88a6b38 100644 --- a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp @@ -45,8 +45,6 @@ #define BUTTON_PUSH_EVENT 1 #define BUTTON_RELEASE_EVENT 0 -#define ONOFF_CLUSTER_ENDPOINT 1 - LOG_MODULE_DECLARE(app); K_MSGQ_DEFINE(sAppEventQueue, sizeof(AppEvent), APP_EVENT_QUEUE_SIZE, alignof(AppEvent)); @@ -63,7 +61,6 @@ static k_timer sFunctionTimer; using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; -using namespace ::chip::app::Clusters; AppTask AppTask::sAppTask; @@ -507,19 +504,4 @@ void AppTask::DispatchEvent(AppEvent * aEvent) } } -void AppTask::UpdateClusterState() -{ - EmberStatus status; - - ChipLogProgress(NotSpecified, "UpdateClusterState"); - - // Write the new values - - bool onOffState = !PumpMgr().IsStopped(); - - status = OnOff::Attributes::OnOff::Set(ONOFF_CLUSTER_ENDPOINT, onOffState); - if (status != EMBER_ZCL_STATUS_SUCCESS) - { - ChipLogError(NotSpecified, "ERR: Updating On/Off state %" PRIx8, status); - } -} +void AppTask::UpdateClusterState() {} diff --git a/third_party/pigweed/repo b/third_party/pigweed/repo index f0e9205b4185fd..3aab7f6ce38c7e 160000 --- a/third_party/pigweed/repo +++ b/third_party/pigweed/repo @@ -1 +1 @@ -Subproject commit f0e9205b4185fdd1409444e5636a8f955a441971 +Subproject commit 3aab7f6ce38c7e861968f5aec158faa1a0d2584a From d443f600b5aa9619b09ad84337935aa0c2356d30 Mon Sep 17 00:00:00 2001 From: Anders Bang Poulsen Date: Thu, 28 Oct 2021 12:47:44 +0200 Subject: [PATCH 20/23] revert submodule --- third_party/pigweed/repo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/pigweed/repo b/third_party/pigweed/repo index 3aab7f6ce38c7e..f0e9205b4185fd 160000 --- a/third_party/pigweed/repo +++ b/third_party/pigweed/repo @@ -1 +1 @@ -Subproject commit 3aab7f6ce38c7e861968f5aec158faa1a0d2584a +Subproject commit f0e9205b4185fdd1409444e5636a8f955a441971 From 7eab093f371729a1a2bffde8dedeab2b00cdd631 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 28 Oct 2021 10:52:49 +0000 Subject: [PATCH 21/23] Restyled by whitespace --- examples/pump-app/nrfconnect/main/AppTask.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/pump-app/nrfconnect/main/AppTask.cpp b/examples/pump-app/nrfconnect/main/AppTask.cpp index 9528e49e0c8c4e..c6e3e48f992cee 100644 --- a/examples/pump-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-app/nrfconnect/main/AppTask.cpp @@ -614,4 +614,4 @@ void AppTask::UpdateClusterState() { ChipLogError(NotSpecified, "ERR: Updating MaxConstTemp %" PRIx8, status); } -} \ No newline at end of file +} From 8a9f18654118db731d23a7fc6c58eb1ce7bf1de2 Mon Sep 17 00:00:00 2001 From: Anders Bang Poulsen Date: Fri, 29 Oct 2021 08:13:27 +0200 Subject: [PATCH 22/23] Removed unused declarations from pump manager in pump-controller-app --- .../cc13x2x7_26x2x7/main/include/PumpManager.h | 14 -------------- .../nrfconnect/main/include/PumpManager.h | 14 -------------- 2 files changed, 28 deletions(-) diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/PumpManager.h b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/PumpManager.h index ea742c22acb765..40a3961dd09161 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/PumpManager.h +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/PumpManager.h @@ -53,20 +53,6 @@ class PumpManager bool IsActionInProgress(); bool InitiateAction(int32_t aActor, Action_t aAction); - int16_t GetMaxPressure(); - uint16_t GetMaxSpeed(); - uint16_t GetMaxFlow(); - int16_t GetMinConstPressure(); - int16_t GetMaxConstPressure(); - int16_t GetMinCompPressure(); - int16_t GetMaxCompPressure(); - uint16_t GetMinConstSpeed(); - uint16_t GetMaxConstSpeed(); - uint16_t GetMinConstFlow(); - uint16_t GetMaxConstFlow(); - int16_t GetMinConstTemp(); - int16_t GetMaxConstTemp(); - typedef void (*Callback_fn_initiated)(Action_t, int32_t aActor); typedef void (*Callback_fn_completed)(Action_t, int32_t aActor); void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); diff --git a/examples/pump-controller-app/nrfconnect/main/include/PumpManager.h b/examples/pump-controller-app/nrfconnect/main/include/PumpManager.h index eb2f0868e1242a..afc1b571e40acd 100644 --- a/examples/pump-controller-app/nrfconnect/main/include/PumpManager.h +++ b/examples/pump-controller-app/nrfconnect/main/include/PumpManager.h @@ -51,20 +51,6 @@ class PumpManager bool IsActionInProgress(); bool InitiateAction(int32_t aActor, Action_t aAction); - int16_t GetMaxPressure(); - uint16_t GetMaxSpeed(); - uint16_t GetMaxFlow(); - int16_t GetMinConstPressure(); - int16_t GetMaxConstPressure(); - int16_t GetMinCompPressure(); - int16_t GetMaxCompPressure(); - uint16_t GetMinConstSpeed(); - uint16_t GetMaxConstSpeed(); - uint16_t GetMinConstFlow(); - uint16_t GetMaxConstFlow(); - int16_t GetMinConstTemp(); - int16_t GetMaxConstTemp(); - typedef void (*Callback_fn_initiated)(Action_t, int32_t aActor); typedef void (*Callback_fn_completed)(Action_t, int32_t aActor); void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); From 79651e4512037b82f962d8bc98b078697ade3d5f Mon Sep 17 00:00:00 2001 From: Anders Bang Poulsen Date: Sat, 30 Oct 2021 10:26:15 +0200 Subject: [PATCH 23/23] Regen ZAP --- .../zap-generated/chip/devicecontroller/ClusterInfoMapping.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java b/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java index 73ba96d648c921..fe366bbf9678f8 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java @@ -5332,7 +5332,6 @@ public Map getClusterMap() { Map modeSelectClusterCommandInfoMap = new LinkedHashMap<>(); Map modeSelectchangeToModeCommandParams = new LinkedHashMap(); - // PLEASE UPDATE LATER: fill out parameter types CommandParameterInfo modeSelectchangeToModeCommandParameterInfo = new CommandParameterInfo("ModeSelect", ChipClusters.DefaultClusterCallback.class); CommandParameterInfo modeSelectchangeToModenewModeCommandParameterInfo =