From dd20b54e1ed4b2d13fcfe2f9e2dc5fc8e6e933e4 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 25 Sep 2024 16:41:04 -0400 Subject: [PATCH] Drop Z-Wave --- ...a-lr2_zwave_ncp_serial_api_controller.yaml | 14 - ...1a-lr_zwave_ncp_serial_api_controller.yaml | 14 - ...b001a_zwave_ncp_serial_api_controller.yaml | 14 - src/zwave_ncp_serial_api_controller/.cproject | 2550 ------------ src/zwave_ncp_serial_api_controller/README.md | 59 - src/zwave_ncp_serial_api_controller/app.c | 1290 ------ src/zwave_ncp_serial_api_controller/app.h | 663 --- .../app_node_info.c | 26 - .../app_node_info.h | 15 - .../cmd_get_capabilities.c | 49 - .../cmd_handlers.c | 3635 ----------------- .../cmd_handlers.h | 70 - .../cmd_handlers_invoker.c | 47 - .../cmds_dcdc.c | 72 - .../cmds_management.c | 585 --- .../cmds_management.h | 180 - .../cmds_power_management.c | 63 - src/zwave_ncp_serial_api_controller/cmds_rf.c | 32 - src/zwave_ncp_serial_api_controller/cmds_rf.h | 22 - .../cmds_security.c | 136 - .../cmds_security.h | 16 - .../comm_interface.c | 519 --- .../comm_interface.h | 81 - .../config/FreeRTOSConfig.h | 271 -- .../config/app_properties_config.h | 65 - .../config/btl_interface_cfg.h | 48 - .../config/emlib_core_debug_config.h | 45 - .../config/extension_board_8029a_efr32xg13.h | 48 - .../extension_board_8029a_efr32xg13_button.h | 133 - .../extension_board_8029a_efr32xg13_led.h | 107 - .../extension_board_8029a_efr32xg13_slider.h | 50 - .../config/nvm3_default_config.h | 45 - .../config/pin_config.h | 159 - .../config/serial_api_config.h | 48 - .../config/sl_board_control_config.h | 84 - .../config/sl_debug_swo_config.h | 109 - .../config/sl_device_init_dcdc_config.h | 58 - .../config/sl_device_init_emu_config.h | 68 - .../config/sl_device_init_hfxo_config.h | 72 - .../config/sl_fem_util_config.h | 95 - .../config/sl_memory_config.h | 28 - .../config/sl_power_manager_config.h | 64 - .../config/sl_rail_util_pa_config.h | 80 - .../sl_rail_util_power_manager_init_config.h | 44 - .../config/sl_rail_util_sequencer_config.h | 48 - .../config/sl_sleeptimer_config.h | 82 - .../config/zaf_appname_config.h | 30 - .../config/zaf_config.h | 400 -- .../zaf_event_distributor_core_config.h | 30 - .../config/zpal_zwave_nvm_instance_config.h | 58 - .../config/zw_build_no.h | 17 - .../config/zw_config_rf.h | 46 - .../config/zw_region_config.h | 43 - .../config/zw_version_config.h | 60 - .../controller_supported_func.h | 211 - .../gbl_metadata.yaml | 6 - src/zwave_ncp_serial_api_controller/main.c | 29 - .../nvm_backup_restore.c | 292 -- .../nvm_backup_restore.h | 23 - .../postbuild.sh | 174 - .../serialapi_file.c | 795 ---- .../serialapi_file.h | 136 - .../slave_supported_func.h | 181 - src/zwave_ncp_serial_api_controller/utils.c | 286 -- src/zwave_ncp_serial_api_controller/utils.h | 38 - .../virtual_slave_node_info.c | 25 - .../virtual_slave_node_info.h | 26 - .../zaf_config_security.h | 37 - .../zwave_ncp_serial_api_controller.pintool | 39 - .../zwave_ncp_serial_api_controller.slcp | 147 - .../zwave_ncp_serial_api_controller.slps | 17 - 71 files changed, 15149 deletions(-) delete mode 100644 manifests/nabucasa/slusb001a-lr2_zwave_ncp_serial_api_controller.yaml delete mode 100644 manifests/nabucasa/slusb001a-lr_zwave_ncp_serial_api_controller.yaml delete mode 100644 manifests/nabucasa/slusb001a_zwave_ncp_serial_api_controller.yaml delete mode 100644 src/zwave_ncp_serial_api_controller/.cproject delete mode 100644 src/zwave_ncp_serial_api_controller/README.md delete mode 100644 src/zwave_ncp_serial_api_controller/app.c delete mode 100644 src/zwave_ncp_serial_api_controller/app.h delete mode 100644 src/zwave_ncp_serial_api_controller/app_node_info.c delete mode 100644 src/zwave_ncp_serial_api_controller/app_node_info.h delete mode 100644 src/zwave_ncp_serial_api_controller/cmd_get_capabilities.c delete mode 100644 src/zwave_ncp_serial_api_controller/cmd_handlers.c delete mode 100644 src/zwave_ncp_serial_api_controller/cmd_handlers.h delete mode 100644 src/zwave_ncp_serial_api_controller/cmd_handlers_invoker.c delete mode 100644 src/zwave_ncp_serial_api_controller/cmds_dcdc.c delete mode 100644 src/zwave_ncp_serial_api_controller/cmds_management.c delete mode 100644 src/zwave_ncp_serial_api_controller/cmds_management.h delete mode 100644 src/zwave_ncp_serial_api_controller/cmds_power_management.c delete mode 100644 src/zwave_ncp_serial_api_controller/cmds_rf.c delete mode 100644 src/zwave_ncp_serial_api_controller/cmds_rf.h delete mode 100644 src/zwave_ncp_serial_api_controller/cmds_security.c delete mode 100644 src/zwave_ncp_serial_api_controller/cmds_security.h delete mode 100644 src/zwave_ncp_serial_api_controller/comm_interface.c delete mode 100644 src/zwave_ncp_serial_api_controller/comm_interface.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/FreeRTOSConfig.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/app_properties_config.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/btl_interface_cfg.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/emlib_core_debug_config.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13_button.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13_led.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13_slider.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/nvm3_default_config.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/pin_config.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/serial_api_config.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/sl_board_control_config.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/sl_debug_swo_config.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/sl_device_init_dcdc_config.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/sl_device_init_emu_config.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/sl_device_init_hfxo_config.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/sl_fem_util_config.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/sl_memory_config.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/sl_power_manager_config.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/sl_rail_util_pa_config.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/sl_rail_util_power_manager_init_config.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/sl_rail_util_sequencer_config.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/sl_sleeptimer_config.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/zaf_appname_config.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/zaf_config.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/zaf_event_distributor_core_config.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/zpal_zwave_nvm_instance_config.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/zw_build_no.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/zw_config_rf.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/zw_region_config.h delete mode 100644 src/zwave_ncp_serial_api_controller/config/zw_version_config.h delete mode 100644 src/zwave_ncp_serial_api_controller/controller_supported_func.h delete mode 100644 src/zwave_ncp_serial_api_controller/gbl_metadata.yaml delete mode 100644 src/zwave_ncp_serial_api_controller/main.c delete mode 100644 src/zwave_ncp_serial_api_controller/nvm_backup_restore.c delete mode 100644 src/zwave_ncp_serial_api_controller/nvm_backup_restore.h delete mode 100644 src/zwave_ncp_serial_api_controller/postbuild.sh delete mode 100644 src/zwave_ncp_serial_api_controller/serialapi_file.c delete mode 100644 src/zwave_ncp_serial_api_controller/serialapi_file.h delete mode 100644 src/zwave_ncp_serial_api_controller/slave_supported_func.h delete mode 100644 src/zwave_ncp_serial_api_controller/utils.c delete mode 100644 src/zwave_ncp_serial_api_controller/utils.h delete mode 100644 src/zwave_ncp_serial_api_controller/virtual_slave_node_info.c delete mode 100644 src/zwave_ncp_serial_api_controller/virtual_slave_node_info.h delete mode 100644 src/zwave_ncp_serial_api_controller/zaf_config_security.h delete mode 100644 src/zwave_ncp_serial_api_controller/zwave_ncp_serial_api_controller.pintool delete mode 100644 src/zwave_ncp_serial_api_controller/zwave_ncp_serial_api_controller.slcp delete mode 100644 src/zwave_ncp_serial_api_controller/zwave_ncp_serial_api_controller.slps diff --git a/manifests/nabucasa/slusb001a-lr2_zwave_ncp_serial_api_controller.yaml b/manifests/nabucasa/slusb001a-lr2_zwave_ncp_serial_api_controller.yaml deleted file mode 100644 index cfcd0fbb..00000000 --- a/manifests/nabucasa/slusb001a-lr2_zwave_ncp_serial_api_controller.yaml +++ /dev/null @@ -1,14 +0,0 @@ -name: ??? -device: ZGM130S037HGN -base_project: src/zwave_ncp_serial_api_controller - -gbl: - fw_type: z-wave - dynamic: ["zwave_version"] - baudrate: 115200 - compression: lz4 - sign_key: "{SDK_DIR}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_sign.key" - encrypt_key: "{SDK_DIR}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_encrypt.key" - -add_components: -- id: brd4207a diff --git a/manifests/nabucasa/slusb001a-lr_zwave_ncp_serial_api_controller.yaml b/manifests/nabucasa/slusb001a-lr_zwave_ncp_serial_api_controller.yaml deleted file mode 100644 index 4f7c243a..00000000 --- a/manifests/nabucasa/slusb001a-lr_zwave_ncp_serial_api_controller.yaml +++ /dev/null @@ -1,14 +0,0 @@ -name: Silicon Labs UZB-7 (SLUSB001A), +14 dBm, Z-Wave Long Range -device: EFR32ZG14P231F256GM32 -base_project: src/zwave_ncp_serial_api_controller - -gbl: - fw_type: z-wave - dynamic: ["zwave_version"] - baudrate: 115200 - compression: lz4 - sign_key: "{SDK_DIR}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_sign.key" - encrypt_key: "{SDK_DIR}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_encrypt.key" - -add_components: -- id: brd4206a diff --git a/manifests/nabucasa/slusb001a_zwave_ncp_serial_api_controller.yaml b/manifests/nabucasa/slusb001a_zwave_ncp_serial_api_controller.yaml deleted file mode 100644 index fae99012..00000000 --- a/manifests/nabucasa/slusb001a_zwave_ncp_serial_api_controller.yaml +++ /dev/null @@ -1,14 +0,0 @@ -name: Silicon Labs UZB-7 (SLUSB001A), +14 dBm, with SAW filters -device: EFR32ZG14P231F256GM32 -base_project: src/zwave_ncp_serial_api_controller - -gbl: - fw_type: z-wave - dynamic: ["zwave_version"] - baudrate: 115200 - compression: lz4 - sign_key: "{SDK_DIR}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_sign.key" - encrypt_key: "{SDK_DIR}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_encrypt.key" - -add_components: -- id: brd4201a diff --git a/src/zwave_ncp_serial_api_controller/.cproject b/src/zwave_ncp_serial_api_controller/.cproject deleted file mode 100644 index 816928e0..00000000 --- a/src/zwave_ncp_serial_api_controller/.cproject +++ /dev/null @@ -1,2550 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/README.md b/src/zwave_ncp_serial_api_controller/README.md deleted file mode 100644 index 860340a6..00000000 --- a/src/zwave_ncp_serial_api_controller/README.md +++ /dev/null @@ -1,59 +0,0 @@ -# Serial API - -The Serial Applications Programming Interface (Serial API) allows a host to communicate with a Z-Wave -chip. The host may be PC or a less powerful embedded host CPU, e.g., in a remote control or in a -gateway device. Depending on the chip family, the Serial API may be accessed via RS-232 or USB -physical interfaces. - -There are 2 available versions of SerialAPI: - - - SerialAPI Controller - - SerialAPI End Device - -The following host-based sample applications are available in the SDK: - -- Z/IP Gateway – Gateway application using Serial API features of the bridge controller API -- PC Controller – Demonstrates Serial API features of the bridge controller API - -The host-based sample applications are described in the respective SDK overview documents. - -The Serial API leverages the Z-Wave Protocol API. The Serial API introduces additional messages related -to inter-host communications. - -## Known Issues - -### OTW Update - -The following update paths for Serial API Controller are not possible using the -pre-built binaries because the defines `ZAF_CONFIG_GENERIC_TYPE` and -`ZAF_CONFIG_SPECIFIC_TYPE` differ across these versions: - -- 7.19 or lower to 7.20 -- 7.20 to 7.21 or higher - -However, it is possible to create a custom firmware that is compatible with -earlier versions of the application by building the application manually after -editing `application_properties_config.h`. - -If you want to update a device running the pre-built 7.19 or lower version -firmware to 7.20, -change both `PRODUCT_ID_GENERIC_TYPE` and `PRODUCT_ID_SPECIFIC_TYPE` to -`0`. - -If you want to update a device running the pre-built 7.20 version firmware -to 7.21 or higher, -remove the following conditional block from the file: - -``` -#if (ZAF_CONFIG_GENERIC_TYPE == GENERIC_TYPE_STATIC_CONTROLLER && \ - ZAF_CONFIG_SPECIFIC_TYPE == SPECIFIC_TYPE_PC_CONTROLLER) -(...) -#endif -``` - -Changing these values will only affect the Product ID, stored in the struct -`sl_app_properties`. -The application will still report the values specified in the defines -`ZAF_CONFIG_GENERIC_TYPE` and `ZAF_CONFIG_SPECIFIC_TYPE` in its -Node Information Frame.\ -Note that these values can be changed on the fly using the Serial API command `SERIAL_API_APPL_NODE_INFORMATION`. diff --git a/src/zwave_ncp_serial_api_controller/app.c b/src/zwave_ncp_serial_api_controller/app.c deleted file mode 100644 index 460d7469..00000000 --- a/src/zwave_ncp_serial_api_controller/app.c +++ /dev/null @@ -1,1290 +0,0 @@ -/** - * @file - * Serial API implementation for Enhanced Z-Wave module - * - * @copyright 2019 Silicon Laboratories Inc. - */ - -#include -#include -#include "Assert.h" -#include "SyncEvent.h" -#ifdef ZW_CONTROLLER -#include "ZW_controller_api.h" -#endif /* ZW_CONTROLLER */ -#include "AppTimer.h" -#include "ZW_system_startup_api.h" -#include "zpal_retention_register.h" -/* Include app header file - containing version and */ -/* SerialAPI functionality support definitions */ -#ifdef ZW_SECURITY_PROTOCOL -#include "ZW_security_api.h" -#include "ZW_TransportSecProtocol.h" -#endif -#include "DebugPrintConfig.h" -// SerialAPI uses SWO for debug output. -// For example SWO Terminal in Studio commander can be used to get the output. -//#define DEBUGPRINT -#include "DebugPrint.h" -#include "app_node_info.h" -#include "virtual_slave_node_info.h" -#include "serialapi_file.h" -#include "cmd_handlers.h" -#include "cmds_management.h" -#include "ZAF_Common_interface.h" -#include "utils.h" -#include "zpal_watchdog.h" -#include "app_hw.h" -#include "SerialAPI_hw.h" -#include "board_indicator.h" -#include "zaf_event_distributor_ncp.h" -#include "zpal_misc.h" -#include "zw_build_no.h" -#include "zaf_protocol_config.h" -#ifdef DEBUGPRINT -#include "ZAF_PrintAppInfo.h" -#endif -#include "ZAF_AppName.h" - -#include - -/* Basic level definitions */ -#define BASIC_ON 0xFF -#define BASIC_OFF 0x00 - -#define TX_POWER_LR_20_DBM 200 -#define TX_POWER_LR_14_DBM 140 - -#ifdef JP_DK -/* Define RSSI threshold so JP can be tested in DK */ -#define JP_DK_RSSI_THRESHOLD 52 -#endif - -#ifdef ZW_SECURITY_PROTOCOL -#define REQUESTED_SECURITY_KEYS ( SECURITY_KEY_S0_BIT | SECURITY_KEY_S2_UNAUTHENTICATED_BIT | SECURITY_KEY_S2_AUTHENTICATED_BIT | SECURITY_KEY_S2_ACCESS_BIT) -#else -#define REQUESTED_SECURITY_KEYS 0 -#endif /* ZW_SECURITY_PROTOCOL */ - -/* Accept all incoming command classes, regardless of NIF contents. */ -#define ACCEPT_ALL_CMD_CLASSES - -/** - * - */ -typedef struct _S_TRANSPORT_REQUESTED_SECURITY_SETTINGS_ -{ - uint8_t requestedSecurityKeysBits; -} S_TRANSPORT_REQUESTED_SECURITY_SETTINGS; - -static TaskHandle_t g_AppTaskHandle; - -extern SSyncEvent SetDefaultCB; -extern SSyncEventArg1 LearnModeStatusCb; - -/* State vars for ApplicationPoll */ -static uint8_t state = 0xff; -static uint8_t retry = 0; - -static uint8_t lastRetVal = 0; /* Used to store retVal for retransmissions */ -uint8_t compl_workbuf[BUF_SIZE_TX]; /* Used for frames send to remote side. */ - -/* Queue for frames transmitted to PC - callback, ApplicationCommandHandler, ApplicationControllerUpdate... */ -#if !defined(MAX_CALLBACK_QUEUE) -#define MAX_CALLBACK_QUEUE 8 -#endif /* !defined(MAX_CALLBACK_QUEUE) */ - -#if !defined(MAX_UNSOLICITED_QUEUE) -#define MAX_UNSOLICITED_QUEUE 8 -#endif /* !defined(MAX_UNSOLICITED_QUEUE) */ - -typedef struct _callback_element_ -{ - uint8_t wCmd; - uint8_t wLen; - uint8_t wBuf[BUF_SIZE_TX]; -} CALLBACK_ELEMENT; - -typedef struct _request_queue_ -{ - uint8_t requestOut; - uint8_t requestIn; - uint8_t requestCnt; - CALLBACK_ELEMENT requestQueue[MAX_CALLBACK_QUEUE]; -} REQUEST_QUEUE; - -REQUEST_QUEUE callbackQueue = {0}; - -typedef struct _request_unsolicited_queue_ -{ - uint8_t requestOut; - uint8_t requestIn; - uint8_t requestCnt; - CALLBACK_ELEMENT requestQueue[MAX_UNSOLICITED_QUEUE]; -} REQUEST_UNSOLICITED_QUEUE; - -REQUEST_UNSOLICITED_QUEUE commandQueue = {0}; - -eSerialAPISetupNodeIdBaseType nodeIdBaseType = SERIAL_API_SETUP_NODEID_BASE_TYPE_DEFAULT; - -#if SUPPORT_ZW_WATCHDOG_START | SUPPORT_ZW_WATCHDOG_STOP -extern uint8_t bWatchdogStarted; -#endif - -/* Last system wakeup reason - is set in ApplicationInit */ -EResetReason_t g_eApplResetReason; - -#ifdef APPL_PROD_TEST -#define PRODTEST_NR_1 1 -#define PRODTEST_NR_2 2 -#define PRODTEST_NR_3 3 -#define PRODTEST_NR_4 4 -#define PRODTEST_NR_5 5 -#define PRODTEST_NR_6 6 -#define PRODTEST_NR_7 7 - -#define POWERON_MAGIC_VALUE 0x4242 -extern uint8_t bProdtestState; -/* Production test pin definition */ -static uint8_t testRun; -#define SET_PRODUCTIONTEST_PIN PIN_IN(P21, 1) -#define IN_PRODUCTIONTEST (!PIN_GET(P21)) -#endif /* APPL_PROD_TEST */ - -zpal_pm_handle_t radio_power_lock; -zpal_pm_handle_t io_power_lock; -SSwTimer mWakeupTimer; -bool bTxStatusReportEnabled; - -static void ApplicationInitSW(void); -static void ApplicationTask(SApplicationHandles *pAppHandles); - -#ifdef ZW_CONTROLLER_BRIDGE -static void ApplicationCommandHandler_Bridge(SReceiveMulti *pReciveMulti); -#else -void ApplicationCommandHandler(void *pSubscriberContext, SZwaveReceivePackage* pRxPackage); -#endif - -void ApplicationNodeUpdate(uint8_t bStatus, uint16_t nodeID, uint8_t *pCmd, uint8_t bLen); - -#if SUPPORT_ZW_SET_PROMISCUOUS_MODE -static void SetPromiscuousMode(uint8_t mode); -#endif - -#if SUPPORT_ZW_REMOVE_FAILED_NODE_ID -extern void ZCB_ComplHandler_ZW_RemoveFailedNodeID(uint8_t bStatus); -#endif - -#if SUPPORT_ZW_REPLACE_FAILED_NODE -extern void ZCB_ComplHandler_ZW_ReplaceFailedNode(uint8_t bStatus); -#endif - -#if SUPPORT_ZW_SET_SLAVE_LEARN_MODE -extern void ZCB_ComplHandler_ZW_SetSlaveLearnMode(uint8_t bStatus, uint8_t orgID, uint8_t newID); -#endif - -#if SUPPORT_ZW_SET_RF_RECEIVE_MODE -extern uint8_t SetRFReceiveMode(uint8_t mode); -#endif - -#ifdef UZB - -#if 1 // 0 - test UZB on ZDP03A, 1 - normal mode (UZB on UZB :) -#define LEDxPort P0 -#define LEDxSHADOW P0Shadow -#define LEDxSHADOWDIR P0ShadowDIR -#define LEDxDIR P0DIR -#define LEDxDIR_PAGE P0DIR_PAGE -#define LEDx 4 -#else // 0 - test UZB on ZDP03A, 1 - normal mode (UZB on UZB :) -#define LEDxPort P0 -#define LEDxSHADOW P0Shadow -#define LEDxSHADOWDIR P0ShadowDIR -#define LEDxDIR P0DIR -#define LEDxDIR_PAGE P0DIR_PAGE -#define LEDx 7 -#endif // 0 - test UZB on ZDP03A, 1 - normal mode (UZB on UZB :) - -void /*RET Nothing */ -set_state_and_notify(uint8_t st) -{ - - if (state != st) - { - xTaskNotify(g_AppTaskHandle, - 1< (uint8_t)BUF_SIZE_TX) - { - ASSERT((uint8_t)BUF_SIZE_TX >= len); - len = (uint8_t)BUF_SIZE_TX; - } - callbackQueue.requestQueue[callbackQueue.requestIn].wLen = len; - memcpy(&callbackQueue.requestQueue[callbackQueue.requestIn].wBuf[0], pData, len); - if (++callbackQueue.requestIn >= MAX_CALLBACK_QUEUE) - { - callbackQueue.requestIn = 0; - } - xTaskNotify(g_AppTaskHandle, - 1< (uint8_t)BUF_SIZE_TX) - { - ASSERT((uint8_t)BUF_SIZE_TX >= len); - len = (uint8_t)BUF_SIZE_TX; - } - commandQueue.requestQueue[commandQueue.requestIn].wLen = len; - memcpy(&commandQueue.requestQueue[commandQueue.requestIn].wBuf[0], pData, len); - if (++commandQueue.requestIn >= MAX_UNSOLICITED_QUEUE) - { - commandQueue.requestIn = 0; - } - taskEXIT_CRITICAL(); - xTaskNotify(g_AppTaskHandle, - 1<cmd, &lastRetVal, 1); -} - -void -DoRespond_workbuf( - uint8_t cnt -) -{ - Respond(serial_frame->cmd, compl_workbuf, cnt); -} - -void zaf_event_distributor_app_zw_rx(SZwaveReceivePackage *RxPackage) -{ - switch (RxPackage->eReceiveType) { - case EZWAVERECEIVETYPE_SINGLE: -#ifndef ZW_CONTROLLER_BRIDGE - ApplicationCommandHandler(NULL, RxPackage); -#endif - break; - -#ifdef ZW_CONTROLLER_BRIDGE - case EZWAVERECEIVETYPE_MULTI: - ApplicationCommandHandler_Bridge(&RxPackage->uReceiveParams.RxMulti); - break; -#endif // #ifdef ZW_CONTROLLER_BRIDGE - - case EZWAVERECEIVETYPE_NODE_UPDATE: - ApplicationNodeUpdate( - RxPackage->uReceiveParams.RxNodeUpdate.Status, - RxPackage->uReceiveParams.RxNodeUpdate.NodeId, - RxPackage->uReceiveParams.RxNodeUpdate.aPayload, - RxPackage->uReceiveParams.RxNodeUpdate.iLength); - break; - default: - break; - } -} - - -/** -* @brief Triggered when protocol puts a message on the ZwCommandStatusQueue. -*/ -void zaf_event_distributor_app_zw_command_status(SZwaveCommandStatusPackage *Status) -{ - DPRINTF("Incoming Status msg %x\r\n", Status->eStatusType); - - switch (Status->eStatusType) { - case EZWAVECOMMANDSTATUS_LEARN_MODE_STATUS: - SyncEventArg1Invoke(&LearnModeStatusCb, Status->Content.LearnModeStatus.Status); - break; - - case EZWAVECOMMANDSTATUS_SET_DEFAULT: - // Received when protocol is started (not implemented yet), and when SetDefault command is completed - SyncEventInvoke(&SetDefaultCB); - break; - -#ifdef ZW_CONTROLLER - case EZWAVECOMMANDSTATUS_REPLACE_FAILED_NODE_ID: - ZCB_ComplHandler_ZW_ReplaceFailedNode(Status->Content.FailedNodeIDStatus.result); - break; - case EZWAVECOMMANDSTATUS_REMOVE_FAILED_NODE_ID: - ZCB_ComplHandler_ZW_RemoveFailedNodeID(Status->Content.FailedNodeIDStatus.result); - break; - case EZWAVECOMMANDSTATUS_NETWORK_MANAGEMENT: - { - LEARN_INFO_T mLearnInfo; - mLearnInfo.bStatus = Status->Content.NetworkManagementStatus.statusInfo[0]; - mLearnInfo.bSource = (uint16_t)(((uint16_t)Status->Content.NetworkManagementStatus.statusInfo[1] << 8) // nodeID MSB - | (uint16_t)Status->Content.NetworkManagementStatus.statusInfo[2]); // nodeID LSB - mLearnInfo.bLen = Status->Content.NetworkManagementStatus.statusInfo[3]; - mLearnInfo.pCmd = &Status->Content.NetworkManagementStatus.statusInfo[4]; - ZCB_ComplHandler_ZW_NodeManagement(&mLearnInfo); - break; - } -#if SUPPORT_ZW_SET_SLAVE_LEARN_MODE - case EZWAVECOMMANDSTATUS_SET_SLAVE_LEARN_MODE: - { - uint8_t bStatus; - uint16_t orgID; - uint16_t newID; - bStatus = Status->Content.NetworkManagementStatus.statusInfo[0]; - orgID = (uint16_t)((uint16_t)(Status->Content.NetworkManagementStatus.statusInfo[1] << 8) // org nodeID MSB - | Status->Content.NetworkManagementStatus.statusInfo[2]); // org nodeID LSB - newID = (uint16_t)((uint16_t)(Status->Content.NetworkManagementStatus.statusInfo[3] << 8) // new nodeID MSB - | Status->Content.NetworkManagementStatus.statusInfo[4]); // new nodeID LSB - ZCB_ComplHandler_ZW_SetSlaveLearnMode(bStatus, (uint8_t)orgID, (uint8_t)newID); // orgID and newID are always (8-bit) IDs - break; - } -#endif -#endif - default: - break; - } -} - -static void -appFileSystemInit(void) -{ - SAppNodeInfo_t *AppNodeInfo; - SRadioConfig_t *RadioConfig; - - AppNodeInfo = zaf_get_app_node_info(); - RadioConfig = zaf_get_radio_config(); - - // enable the watchdog at init of application - zpal_enable_watchdog(true); - - /* - * Handle file system init inside Application Task - * This reduces the default stack needed during initialization - */ - if (SerialApiFileInit()) - { - ReadApplicationSettings(&AppNodeInfo->DeviceOptionsMask, &AppNodeInfo->NodeType.generic, &AppNodeInfo->NodeType.specific); - ReadApplicationCCInfo(&CommandClasses.UnSecureIncludedCC.iListLength, - (uint8_t*)CommandClasses.UnSecureIncludedCC.pCommandClasses, - &CommandClasses.SecureIncludedUnSecureCC.iListLength, - (uint8_t*)CommandClasses.SecureIncludedUnSecureCC.pCommandClasses, - &CommandClasses.SecureIncludedSecureCC.iListLength, - (uint8_t*)CommandClasses.SecureIncludedSecureCC.pCommandClasses); - ReadApplicationRfRegion(&RadioConfig->eRegion); - ReadApplicationTxPowerlevel(&RadioConfig->iTxPowerLevelMax, &RadioConfig->iTxPowerLevelAdjust); - ReadApplicationMaxLRTxPwr(&RadioConfig->iTxPowerLevelMaxLR); - ReadApplicationEnablePTI(&RadioConfig->radio_debug_enable); - ReadApplicationNodeIdBaseType(&nodeIdBaseType); - } - else - { - /* - * We end up here on the first boot after initializing the flash file system - */ - - zpal_radio_region_t mfgRegionConfig; - // Check for a valid RF Region value in the manufacturing user data configuration - ZW_GetMfgTokenDataCountryFreq(&mfgRegionConfig); - if ( (mfgRegionConfig <= REGION_US_LR) || (mfgRegionConfig == REGION_JP) || (mfgRegionConfig == REGION_KR) ) - { - // Valid RF Region configuration found. Use instead of the app default setting - RadioConfig->eRegion = mfgRegionConfig; - } - - // Save the setting to flash - SaveApplicationRfRegion(RadioConfig->eRegion); - // Save the default Tx powerlevel - SaveApplicationTxPowerlevel(RadioConfig->iTxPowerLevelMax, RadioConfig->iTxPowerLevelAdjust); - // write defualt values - SaveApplicationSettings(AppNodeInfo->DeviceOptionsMask, AppNodeInfo->NodeType.generic, AppNodeInfo->NodeType.specific); - // change the 20dBm tx power setting according to the application configuration - SaveApplicationMaxLRTxPwr(RadioConfig->iTxPowerLevelMaxLR); - - SaveApplicationEnablePTI(RadioConfig->radio_debug_enable); - SaveApplicationNodeIdBaseType(SERIAL_API_SETUP_NODEID_BASE_TYPE_DEFAULT); - } - - ZAF_AppName_Write(); -} -/* - * The below function must be implemented as hardware specific function in a separate source - * file if required. - */ -ZW_WEAK void SerialAPI_hw_psu_init(void) -{ - // Do nothing -} - -/*=============================== ApplicationPoll ======================= -** Application poll function, handling the receiving and transmitting -** communication with the PC. -** -**--------------------------------------------------------------------------*/ -static void /*RET Nothing */ -ApplicationTask(SApplicationHandles* pAppHandles) -{ - - SerialAPI_hw_psu_init(); // Must be invoked after the file system is initialized. - - // Init - g_AppTaskHandle = xTaskGetCurrentTaskHandle(); - - SetTaskHandle(g_AppTaskHandle); - ZAF_setAppHandle(pAppHandles); - ZW_system_startup_SetCCSet(&CommandClasses); - - AppTimerInit(EAPPLICATIONEVENT_TIMER, (void *) g_AppTaskHandle); - radio_power_lock = zpal_pm_register(ZPAL_PM_TYPE_USE_RADIO); - zpal_pm_stay_awake(radio_power_lock, 0); - io_power_lock = zpal_pm_register(ZPAL_PM_TYPE_DEEP_SLEEP); - zpal_pm_stay_awake(io_power_lock, 0); - - zaf_event_distributor_init(); - - set_state_and_notify(stateStartup); - // Wait for and process events - DPRINT("SerialApi Event processor Started\r\n"); - for (;;) - { - if (!zaf_event_distributor_distribute()) - { - return; - } - } -} - -static void SerialAPICommandHandler(void) -{ - const bool handler_invoked = invoke_cmd_handler(serial_frame); - if (!handler_invoked) - { - /* TODO - send a "Not Supported" respond frame */ - /* UNKNOWN - just drop it */ - set_state_and_notify(stateIdle); - } -} - - -static void SerialAPIStateHandler(void) -{ - comm_interface_parse_result_t conVal; - - /* ApplicationPoll is controlled by a statemachine with the four states: - stateIdle, stateFrameParse, stateTxSerial, stateCbTxSerial. - - stateIdle: If there is anything to transmit do so. -> stateCbTxSerial - If not, check if anything is received. -> stateFrameParse - If neither, stay in the state - Note: frames received while we are transmitting are lost - and must be retransmitted by PC - - stateFrameParse: Parse received frame. - If the request has no response -> stateIdle - If there is an immediate response send it. -> stateTxSerial - - stateTxSerial: Waits for ack on responses send in stateFrameParse. - Retransmit frame as needed. - -> stateIdle - - stateCbTxSerial: Waits for ack on requests send in stateIdle - (callback, ApplicationCommandHandler etc). - Retransmit frame as needed and remove from callbackqueue when done. - -> stateIdle - - stateAppSuspend: Added for the uzb suspend function. The resume is through the suspend signal goes high in UZB stick - The wakeup from deep sleep suspend causes system reboot - - */ - - { - switch (state) - { - case stateStartup: - { - ApplicationInitSW(); - SetRFReceiveMode(1); - set_state_and_notify(stateIdle); - } - break; - - case stateIdle: - { -#if SUPPORT_SERIAL_API_READY - /* Only empty callback queue for HOST if SERIAL LINK has been established */ - if (callbackQueue.requestCnt && (SERIAL_LINK_DETACHED != serialLinkState)) -#else - /* Check if there is anything to transmit. If so do it */ - if (callbackQueue.requestCnt) -#endif - { - comm_interface_transmit_frame( - callbackQueue.requestQueue[callbackQueue.requestOut].wCmd, - REQUEST, - (uint8_t *)callbackQueue.requestQueue[callbackQueue.requestOut].wBuf, - callbackQueue.requestQueue[callbackQueue.requestOut].wLen, - NULL - ); - set_state_and_notify(stateCallbackTxSerial); - /* callbackCnt decremented when frame is acknowledged from PC - or timed out after retries */ - } - else - { -#if SUPPORT_SERIAL_API_READY - /* Only empty command queue for HOST if SERIAL LINK has been established */ - if (commandQueue.requestCnt && (SERIAL_LINK_DETACHED != serialLinkState)) -#else - /* Check if there is anything to transmit. If so do it */ - if (commandQueue.requestCnt) -#endif - { - comm_interface_transmit_frame( - commandQueue.requestQueue[commandQueue.requestOut].wCmd, - REQUEST, - (uint8_t *)commandQueue.requestQueue[commandQueue.requestOut].wBuf, - commandQueue.requestQueue[commandQueue.requestOut].wLen, - NULL - ); - set_state_and_notify(stateCommandTxSerial); - /* commandCnt decremented when frame is acknowledged from PC - or timed out after retries */ - } - else - { - /* Nothing to transmit. Check if we received anything */ - if (comm_interface_parse_data(true) == PARSE_FRAME_RECEIVED) - { -#if SUPPORT_SERIAL_API_READY - /* We have received a frame from HOST so we must assume we are connected */ - serialLinkState = SERIAL_LINK_CONNECTED; -#endif - /* We got a frame... */ - set_state_and_notify(stateFrameParse); - } - } - } - } - break; - - case stateFrameParse: - { - SerialAPICommandHandler(); - } - break; - - case stateTxSerial: - { - /* Wait for ACK on send respond. Retransmit as needed */ - if ((conVal = comm_interface_parse_data(false)) == PARSE_FRAME_SENT) - { - /* One more RES transmitted succesfully */ - retry = 0; - set_state_and_notify(stateIdle); - } - else if (conVal == PARSE_TX_TIMEOUT) - { - /* Either a NAK has been received or we timed out waiting for ACK */ - if (retry++ < MAX_SERIAL_RETRY) - { - comm_interface_transmit_frame(0, REQUEST, NULL, 0, NULL); /* Retry... */ - } - else - { - /* Drop RES as HOST could not be reached */ - retry = 0; - set_state_and_notify(stateIdle); - } - } - /* All other states are ignored, as for now the only thing we are looking for is ACK/NAK! */ - } - break; - - case stateCallbackTxSerial: - { - /* Wait for ack on unsolicited event (callback etc.) */ - /* Retransmit as needed. Remove frame from callbackQueue when done */ - if ((conVal = comm_interface_parse_data(false)) == PARSE_FRAME_SENT) - { - /* One more REQ transmitted succesfully */ - PopCallBackQueue(); - } - else if (conVal == PARSE_TX_TIMEOUT) - { - /* Either a NAK has been received or we timed out waiting for ACK */ - if (retry++ < MAX_SERIAL_RETRY) - { - comm_interface_transmit_frame(0, REQUEST, NULL, 0, NULL); /* Retry... */ - } - else - { - /* Drop REQ as HOST could not be reached */ - PopCallBackQueue(); - } - } - /* All other states are ignored, as for now the only thing we are looking for is ACK/NAK! */ - } - break; - - case stateCommandTxSerial: - { - /* Wait for ack on unsolicited ApplicationCommandHandler event */ - /* Retransmit as needed. Remove frame from comamndQueue when done */ - if ((conVal = comm_interface_parse_data(false)) == PARSE_FRAME_SENT) - { - /* One more REQ transmitted succesfully */ - PopCommandQueue(); - } - else if (conVal == PARSE_TX_TIMEOUT) - { - /* Either a NAK has been received or we timed out waiting for ACK */ - if (retry++ < MAX_SERIAL_RETRY) - { - comm_interface_transmit_frame(0, REQUEST, NULL, 0, NULL); /* Retry... */ - } - else - { - /* Drop REQ as HOST could not be reached */ - PopCommandQueue(); - } - } - /* All other states are ignored, as for now the only thing we are looking for is ACK/NAK! */ - } - break; - #ifdef USB_SUSPEND_SUPPORT - case stateAppSuspend: - SerialAPI_hw_usb_suspend_handler(); - break; -#endif - default: - set_state_and_notify(stateIdle); - break; - } - - } // For loop - task loop -} - - -void -zaf_event_distributor_app_state_change(void) -{ - SerialAPIStateHandler(); -} - -void -zaf_event_distributor_app_serial_data_rx(void) -{ - SerialAPIStateHandler(); -} - -void -zaf_event_distributor_app_serial_timeout(void) -{ - SerialAPIStateHandler(); -} - -void -PopCallBackQueue(void) -{ - if (callbackQueue.requestCnt) - { - callbackQueue.requestCnt--; - if (++callbackQueue.requestOut >= MAX_CALLBACK_QUEUE) - { - callbackQueue.requestOut = 0; - } - } - else - { - callbackQueue.requestOut = callbackQueue.requestIn; - } - retry = 0; - set_state_and_notify(stateIdle); -} - - -void -PopCommandQueue(void) -{ - if (commandQueue.requestCnt) - { - commandQueue.requestCnt--; - if (++commandQueue.requestOut >= MAX_UNSOLICITED_QUEUE) - { - commandQueue.requestOut = 0; - } - } - else - { - commandQueue.requestOut = commandQueue.requestIn; - } - retry = 0; - set_state_and_notify(stateIdle); -} - -/** - * @brief wakeup after sleep timeout event - * - * @param pTimer Timer connected to this method - */ -void -ZCB_WakeupTimeout(__attribute__((unused)) SSwTimer *pTimer) -{ - DPRINT("ZCB_WakeupTimeout\n"); -} - -/*============================== ApplicationInitSW ====================== -** Initialization of the Application Software -** -**--------------------------------------------------------------------------*/ -void -ApplicationInitSW(void) -{ - SAppNodeInfo_t *AppNodeInfo; - SRadioConfig_t *RadioConfig; - - AppNodeInfo = zaf_get_app_node_info(); - RadioConfig = zaf_get_radio_config(); - - comm_interface_init(); - - // FIXME load any saved node configuration and prepare to feed it to protocol -/* Do we together with the bTxStatus uint8_t also transmit a sTxStatusReport struct on ZW_SendData callback to HOST */ -#if SUPPORT_SEND_DATA_TIMING - bTxStatusReportEnabled = true; -#else - bTxStatusReportEnabled = false; -#endif - -#if SUPPORT_SERIAL_API_STARTUP_NOTIFICATION - /* ZW->HOST: bWakeupReason | bWatchdogStarted | deviceOptionMask | */ - /* nodeType_generic | nodeType_specific | cmdClassLength | cmdClass[] */ - - // FIXME send startup notification via serial port if we are supposed to - SCommandClassList_t *const apCCLists[3] = - { - &CommandClasses.UnSecureIncludedCC, - &CommandClasses.SecureIncludedUnSecureCC, - &CommandClasses.SecureIncludedSecureCC - }; - - compl_workbuf[0] = g_eApplResetReason; -#if SUPPORT_ZW_WATCHDOG_START || SUPPORT_ZW_WATCHDOG_STOP - compl_workbuf[1] = bWatchdogStarted; -#else - compl_workbuf[1] = false; -#endif - compl_workbuf[2] = AppNodeInfo->DeviceOptionsMask; - compl_workbuf[3] = AppNodeInfo->NodeType.generic; - compl_workbuf[4] = AppNodeInfo->NodeType.specific; - compl_workbuf[5] = apCCLists[0]->iListLength; - uint8_t i = 0; - if (0 < apCCLists[0]->iListLength) - { - for (i = 0; i < apCCLists[0]->iListLength; i++) - { - compl_workbuf[6 + i] = apCCLists[0]->pCommandClasses[i]; - } - } - eSerialAPIStartedCapabilities capabilities = (RadioConfig->eRegion == REGION_US_LR) ? SERIAL_API_STARTED_CAPABILITIES_L0NG_RANGE : 0; - compl_workbuf[6 + i] = capabilities; - - uint32_t zpal_reset_info = 0; - if (ZPAL_STATUS_OK != zpal_retention_register_read(ZPAL_RETENTION_REGISTER_RESET_INFO, &zpal_reset_info)) - { - DPRINT("ERROR while reading the reset information\n"); - Request(FUNC_ID_SERIAL_API_STARTED, compl_workbuf, 7 + i); - } - else - { - compl_workbuf[7 + i] = (uint8_t)(zpal_reset_info >> 24); - compl_workbuf[8 + i] = (uint8_t)(zpal_reset_info >> 16); - compl_workbuf[9 + i] = (uint8_t)(zpal_reset_info >> 8); - compl_workbuf[10 + i] = (uint8_t)zpal_reset_info; - DPRINTF("zpal_reset_reason: %u\n", zpal_reset_info); - Request(FUNC_ID_SERIAL_API_STARTED, compl_workbuf, 11 + i); - } - -#endif /* #if SUPPORT_STARTUP_NOTIFICATION */ - AppTimerDeepSleepPersistentRegister(&mWakeupTimer, false, ZCB_WakeupTimeout); // register for event jobs timeout event -} - -#ifdef USB_SUSPEND_SUPPORT -void UsbSuspendCallback(void) -{ - set_state(stateAppSuspend); -} -#endif - -/*============================== ApplicationInit ====================== -** Init UART and setup port pins for LEDs -** -**--------------------------------------------------------------------------*/ -ZW_APPLICATION_STATUS -ApplicationInit( - EResetReason_t eResetReason) -{ - // Serial API can control hardware with information - // set in the file system therefore it should be the first - // step in the Initialization - appFileSystemInit(); - - app_hw_init(); - -#ifdef USB_SUSPEND_SUPPORT - SerialAPI_set_usb_supend_callback(UsbSuspendCallback); -#endif - -#if SUPPORT_SERIAL_API_READY - if (ERESETREASON_SLEEP == eResetReason) - { - /* We have been waken from sleep by timer or external pin event - we must assume we are connected. */ - serialLinkState = SERIAL_LINK_CONNECTED; - } - else - { - /* We have been waken either by ERESETREASON_POWER_ON or ERESETREASON_PIN or similar. Initially we are DETACHED */ - serialLinkState = SERIAL_LINK_CONNECTED; - } -#endif - /* g_eApplResetReason now contains lastest System Reset reason */ - g_eApplResetReason = eResetReason; - -#ifdef DEBUGPRINT - static uint8_t m_aDebugPrintBuffer[96]; - zpal_debug_init(); - DebugPrintConfig(m_aDebugPrintBuffer, sizeof(m_aDebugPrintBuffer), zpal_debug_output); - DebugPrintf("ApplicationInit eResetReason = %d\n", eResetReason); - ZAF_PrintAppInfo(); -#endif - - /************************************************************************************* - * CREATE USER TASKS - ZW_ApplicationRegisterTask() and ZW_UserTask_CreateTask() - ************************************************************************************* - * Register the main APP task function. - * - * ATTENTION: This function is the only task that can call ZAF API functions!!! - * Failure to follow guidelines will result in undefined behavior. - * - * Furthermore, this function is the only way to register Event Notification - * Bit Numbers for associating to given event handlers. - * - * ZW_UserTask_CreateTask() can be used to create additional tasks. - * @see zwave_soc_sensor_pir example for more info. - *************************************************************************************/ - bool bWasTaskCreated = ZW_ApplicationRegisterTask( - ApplicationTask, - EAPPLICATIONEVENT_ZWRX, - EAPPLICATIONEVENT_ZWCOMMANDSTATUS, - zaf_get_protocol_config() - ); - ASSERT(bWasTaskCreated); - - return (APPLICATION_RUNNING); /*Return false to enter production test mode*/ -} - - -#ifndef ZW_CONTROLLER_BRIDGE -/*========================== ApplicationCommandHandler ================== -** Handling of received application commands and requests -** -**--------------------------------------------------------------------------*/ -void /*RET Nothing */ -ApplicationCommandHandler(__attribute__((unused)) void *pSubscriberContext, SZwaveReceivePackage* pRxPackage) -{ - ZW_APPLICATION_TX_BUFFER *pCmd = (ZW_APPLICATION_TX_BUFFER *)&pRxPackage->uReceiveParams.Rx.Payload; - uint8_t cmdLength = pRxPackage->uReceiveParams.Rx.iLength; - RECEIVE_OPTIONS_TYPE *rxOpt = &pRxPackage->uReceiveParams.Rx.RxOptions; - /* ZW->PC: REQ | 0x04 | rxStatus | sourceNode | cmdLength | pCmd[] | rssiVal | securityKey */ - uint8_t offset = 0; - BYTE_IN_AR(compl_workbuf, 0) = rxOpt->rxStatus; - if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) - { - BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)(rxOpt->sourceNode >> 8); // MSB - BYTE_IN_AR(compl_workbuf, 2) = (uint8_t)(rxOpt->sourceNode & 0xFF); // LSB - offset++; // 16 bit nodeID means the command fields that follow are offset by one byte - } - else - { - BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)(rxOpt->sourceNode & 0xFF); // Legacy 8 bit nodeID - } -#if defined(ZW_CONTROLLER) && !defined(ZW_CONTROLLER_STATIC) - if (cmdLength > (uint8_t)(BUF_SIZE_TX - (offset + (rxOpt->rxStatus & RECEIVE_STATUS_FOREIGN_FRAME ? 5 : 4)))) - { - cmdLength = (uint8_t)(BUF_SIZE_TX - (offset + (rxOpt->rxStatus & RECEIVE_STATUS_FOREIGN_FRAME ? 5 : 4))); - } -#else - if (cmdLength > (uint8_t)(BUF_SIZE_TX - (offset + 5))) - { - cmdLength = (uint8_t)(BUF_SIZE_TX - (offset + 5)); - } -#endif - BYTE_IN_AR(compl_workbuf, offset + 2) = cmdLength; - for (uint8_t i = 0; i < cmdLength; i++) - { - BYTE_IN_AR(compl_workbuf, offset + 3 + i) = *((uint8_t*)pCmd + i); - } - /* Syntax when a promiscuous frame is received (i.e. RECEIVE_STATUS_FOREIGN_FRAME is set): */ - /* ZW->PC: REQ | 0xD1 | rxStatus | sourceNode | cmdLength | pCmd[] | destNode | rssiVal - * | securityKey | bSourceTxPower | bSourceNoiseFloor */ -#if defined(ZW_CONTROLLER) && !defined(ZW_CONTROLLER_STATIC) - /* For libraries supporting promiscuous mode... */ - BYTE_IN_AR(compl_workbuf, offset + 3 + cmdLength) = (uint8_t)(rxOpt->destNode & 0xFF); - uint8_t index = (uint8_t)(offset + 3 + ((rxOpt->rxStatus & RECEIVE_STATUS_FOREIGN_FRAME) ? 1 : 0) + cmdLength); - BYTE_IN_AR(compl_workbuf, index++) = (uint8_t)rxOpt->rxRSSIVal; - BYTE_IN_AR(compl_workbuf, index++) = rxOpt->securityKey; - BYTE_IN_AR(compl_workbuf, index++) = (uint8_t)rxOpt->bSourceTxPower; - BYTE_IN_AR(compl_workbuf, index) = (uint8_t)rxOpt->bSourceNoiseFloor; - RequestUnsolicited((rxOpt->rxStatus & RECEIVE_STATUS_FOREIGN_FRAME ? - FUNC_ID_PROMISCUOUS_APPLICATION_COMMAND_HANDLER : FUNC_ID_APPLICATION_COMMAND_HANDLER), - compl_workbuf, - index); -#else - BYTE_IN_AR(compl_workbuf, offset + 3 + cmdLength) = (uint8_t)rxOpt->rxRSSIVal; - BYTE_IN_AR(compl_workbuf, offset + 4 + cmdLength) = rxOpt->securityKey; - BYTE_IN_AR(compl_workbuf, offset + 5 + cmdLength) = (uint8_t)rxOpt->bSourceTxPower; - BYTE_IN_AR(compl_workbuf, offset + 6 + cmdLength) = (uint8_t)rxOpt->bSourceNoiseFloor; - - /* Less code space-consuming version for libraries without promiscuous support */ - RequestUnsolicited(FUNC_ID_APPLICATION_COMMAND_HANDLER, compl_workbuf, (uint8_t)(offset + 7 + cmdLength)); -#endif -} -#endif - -#ifdef ZW_CONTROLLER_BRIDGE - -// Struct describing Multicast nodemask header for SerialAPI -typedef struct SMultiCastNodeMaskHeaderSerial -{ - uint8_t iNodemaskLength : 5; // Bits 0-4 is length. Length of Nodemask in bytes - Valid values [0-29] - uint8_t iNodeMaskOffset : 3; // Bits 5-7 is offset. Denotes which node the first bit in the nodemask describes - // First node in nodemask is (Value * 32) + 1 - e.g. 2 -> first node is 65 - // In reality - we always give a full nodemask -> length 29, offset 0. -} SMultiCastNodeMaskHeaderSerial; - -/*====================== ApplicationCommandHandler_Bridge ================ -** Handling of received application commands and requests -** -**--------------------------------------------------------------------------*/ -static void /*RET Nothing */ -ApplicationCommandHandler_Bridge(SReceiveMulti* pReceiveMulti) -{ -#if SUPPORT_APPLICATION_COMMAND_HANDLER_BRIDGE - /* ZW->HOST: REQ | 0xA8 | rxStatus | destNode | sourceNode | cmdLength - * | pCmd[] | multiDestsOffset_NodeMaskLen | multiDestsNodeMask[] | rssiVal - * | securityKey | bSourceTxPower | bSourceNoiseFloor */ - uint8_t offset = 0; - BYTE_IN_AR(compl_workbuf, 0) = pReceiveMulti->RxOptions.rxStatus; - if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) - { - BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)(pReceiveMulti->RxOptions.destNode >> 8); // MSB - BYTE_IN_AR(compl_workbuf, 2) = (uint8_t)(pReceiveMulti->RxOptions.destNode & 0xFF); // LSB - BYTE_IN_AR(compl_workbuf, 3) = (uint8_t)(pReceiveMulti->RxOptions.sourceNode >> 8); // MSB - BYTE_IN_AR(compl_workbuf, 4) = (uint8_t)(pReceiveMulti->RxOptions.sourceNode & 0xFF); // LSB - offset = 6; // 16 bit nodeIDs means the command fields that follow are offset by two bytes - } - else - { - // Legacy 8 bit nodeIDs - BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)pReceiveMulti->RxOptions.destNode; - BYTE_IN_AR(compl_workbuf, 2) = (uint8_t)pReceiveMulti->RxOptions.sourceNode; - offset = 4; - } - - uint32_t cmdLength = pReceiveMulti->iCommandLength; - uint8_t i; - - if (cmdLength > sizeof(pReceiveMulti->Payload)) - { - cmdLength = sizeof(pReceiveMulti->Payload); - } - if (cmdLength > (uint8_t)(BUF_SIZE_TX - offset) ) - { - cmdLength = (uint8_t)(BUF_SIZE_TX - offset) ; - } - BYTE_IN_AR(compl_workbuf, offset - 1 ) = (uint8_t)cmdLength; - - memcpy(compl_workbuf + offset, (uint8_t*)&pReceiveMulti->Payload, cmdLength); - - if (pReceiveMulti->RxOptions.rxStatus & RECEIVE_STATUS_TYPE_MULTI) - { - /* Its a Multicast frame */ - - // Create NodeMaskHeader to comply with SerialAPI - const SMultiCastNodeMaskHeaderSerial NodeMaskHeader = { - .iNodemaskLength = 29, // Always offset full nodemask. Hardwired to 29 (and not - // nodemask define) since SerialAPI is not supposed to change. - .iNodeMaskOffset = 0 // Always full nodemask -> No offset - }; - - i = NodeMaskHeader.iNodemaskLength + 1; // + 1 for node mask headers own size. - if (i > (uint8_t)(BUF_SIZE_TX - (offset + cmdLength))) - { - i = (uint8_t)(BUF_SIZE_TX - (offset + cmdLength + 1)); - } - if (i > 0) - { - *(compl_workbuf + offset + cmdLength) = i - 1; - memcpy(compl_workbuf + offset + 1 + cmdLength, (uint8_t*)pReceiveMulti->NodeMask, i - 1); // +- 1 as we already copied node mask header - i += (uint8_t)cmdLength; - } - } - else - { - if (cmdLength >= (uint8_t)(BUF_SIZE_TX - offset) ) - { - cmdLength = (uint8_t)(BUF_SIZE_TX - offset -1); - i = (uint8_t)cmdLength; - } - else - { - i = (uint8_t)(cmdLength + 1); - } - BYTE_IN_AR(compl_workbuf, (uint8_t)(offset + cmdLength)) = 0; - } - BYTE_IN_AR(compl_workbuf, offset + i) = (uint8_t)pReceiveMulti->RxOptions.rxRSSIVal; - if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) - { - BYTE_IN_AR(compl_workbuf, offset + ++i) = pReceiveMulti->RxOptions.securityKey; //inclusion fails without this - BYTE_IN_AR(compl_workbuf, offset + ++i) = (uint8_t)pReceiveMulti->RxOptions.bSourceTxPower; - BYTE_IN_AR(compl_workbuf, offset + ++i) = (uint8_t)pReceiveMulti->RxOptions.bSourceNoiseFloor; - } - /* Unified Application Command Handler for Bridge and Virtual nodes */ - RequestUnsolicited(FUNC_ID_APPLICATION_COMMAND_HANDLER_BRIDGE, compl_workbuf, (uint8_t)(offset + 1 + i)); -#else - /* Simulate old split Application Command Handlers */ - uint8_t offset = 0; - if (!IsNodeVirtual(destNode)) - { - /* ZW->PC: REQ | 0x04 | rxStatus | sourceNode | cmdLength | Payload */ - BYTE_IN_AR(compl_workbuf, 0) = pReceiveMulti->RxOptions.rxStatus; - if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) - { - BYTE_IN_AR(compl_workbuf, offset + 1) = (uint8_t)(pReceiveMulti->RxOptions.sourceNode >> 8); // MSB - BYTE_IN_AR(compl_workbuf, offset + 2) = (uint8_t)(pReceiveMulti->RxOptions.sourceNode & 0xFF); // LSB - offset = 4; // 16 bit nodeID means the command fields that follow are offset by one byte - } - else - { - BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)pReceiveMulti->RxOptions.sourceNode; // Legacy 8 bit - offset = 3; - } - if (cmdLength > (uint8_t)(BUF_SIZE_TX - offset) ) - { - cmdLength = (uint8_t)(BUF_SIZE_TX - offset) ; - } - BYTE_IN_AR(compl_workbuf, offset - 1 ) = (uint8_t)cmdLength; - for (i = 0; i < cmdLength; i++) - { - BYTE_IN_AR(compl_workbuf, offset + i) = *((uint8_t*)&pReceiveMulti->Payload + i); - } - RequestUnsolicited(FUNC_ID_APPLICATION_COMMAND_HANDLER, compl_workbuf, offset + cmdLength); - } - else - { - /* ZW->PC: REQ | 0xA1 | rxStatus | destNode | sourceNode | cmdLength | Payload */ - BYTE_IN_AR(compl_workbuf, 0) = pReceiveMulti->RxOptions.rxStatus; - if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) - { - BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)(pReceiveMulti->RxOptions.destNode >> 8); // MSB - BYTE_IN_AR(compl_workbuf, 2) = (uint8_t)(pReceiveMulti->RxOptions.destNode & 0xFF); // LSB - BYTE_IN_AR(compl_workbuf, 3) = (uint8_t)(pReceiveMulti->RxOptions.sourceNode >> 8); // MSB - BYTE_IN_AR(compl_workbuf, 4) = (uint8_t)(pReceiveMulti->RxOptions.sourceNode & 0xFF); // LSB - offset = 6; // 16 bit nodeIDs means the command fields that follow are offset by two bytes - } - else - { - // Legacy 8 bit nodeIDs - BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)pReceiveMulti->RxOptions.destNode; - BYTE_IN_AR(compl_workbuf, 2) = (uint8_t)pReceiveMulti->RxOptions.sourceNode; - offset = 4; - } - if (cmdLength > (uint8_t)(BUF_SIZE_TX - offset)) - { - cmdLength = (uint8_t)(BUF_SIZE_TX - offset) ; - } - BYTE_IN_AR(compl_workbuf, offset - 1) = cmdLength; - for (i = 0; i < cmdLength; i++) - { - BYTE_IN_AR(compl_workbuf, offset + i) = *((uint8_t*)&pReceiveMulti->Payload + i); - } - - RequestUnsolicited(FUNC_ID_APPLICATION_SLAVE_COMMAND_HANDLER, compl_workbuf, offset + cmdLength); - } -#endif -} -#endif - - -/*====================== ApplicationNodeUpdate ========================= -** Inform the static controller/slave of node information received -** -**--------------------------------------------------------------------------*/ -void /* RET Nothing */ -ApplicationNodeUpdate( - uint8_t bStatus, /* IN Status of learn mode */ - uint16_t nodeID, /* IN Node id of node sending nodeinfo*/ - uint8_t *pCmd, /* IN Pointer to appl. node info */ - uint8_t bLen /* IN Node info length */ -) -{ - uint8_t offset = 0; - BYTE_IN_AR(compl_workbuf, 0) = bStatus; - if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) - { - BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)(nodeID >> 8); // MSB - BYTE_IN_AR(compl_workbuf, 2) = (uint8_t)(nodeID & 0xFF); // LSB - offset++; // 16 bit nodeID means the command fields that follow are offset by one byte - } - else - { - BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)(nodeID & 0xFF); // Legacy 8 bit nodeID - } - - /* - Buffer boundary check */ - if (bLen > (uint8_t)(BUF_SIZE_TX - (offset + 3))) - { - bLen = (uint8_t)(BUF_SIZE_TX - (offset + 3)); - } - BYTE_IN_AR(compl_workbuf, offset + 2) = bLen; - for (uint8_t i = 0; i < bLen; i++) - { - BYTE_IN_AR(compl_workbuf, offset + 3 + i) = *(pCmd + i); - } - RequestUnsolicited(FUNC_ID_ZW_APPLICATION_UPDATE, compl_workbuf, (uint8_t)(offset + bLen + 3)); -} - -ZW_WEAK const void * SerialAPI_get_uart_config_ext(void) -{ - return NULL; -} - -#ifdef USB_SUSPEND_SUPPORT - -ZW_WEAK void SerialAPI_set_usb_supend_callback(__attribute__((unused)) SerialAPI_hw_usb_suspend_callback_t callback) -{ -} - -ZW_WEAK void SerialAPI_hw_usb_suspend_handler(void) -{ - -} - -#endif diff --git a/src/zwave_ncp_serial_api_controller/app.h b/src/zwave_ncp_serial_api_controller/app.h deleted file mode 100644 index 4ab412ef..00000000 --- a/src/zwave_ncp_serial_api_controller/app.h +++ /dev/null @@ -1,663 +0,0 @@ -/** - * @file - * Header file for Serial API implementation. - * - * Contains various application definitions and SerialAPI - * functionality support definitions. - * - * @copyright 2019 Silicon Laboratories Inc. - */ -#ifndef _SERIALAPPL_H_ -#define _SERIALAPPL_H_ -#include - -#ifndef UNIT_TEST -/* Z-Wave library functionality support definitions */ -#ifdef ZW_SLAVE -#include -#else -#include -#endif -#endif /*#ifndef UNIT_TEST*/ - -#include - -#include - -#ifdef ZW_SLAVE -#include -#endif -#ifdef ZW_SECURITY_PROTOCOL -#include -#endif - -#ifdef ZW_CONTROLLER -#include -#endif - -/* Serial API version */ -#define SERIAL_API_VER 10 - -/* Max number of times a frame will be transmitted to PC */ -#define MAX_SERIAL_RETRY 3 - -/* Number of bytes in a homeID */ -#define HOMEID_LENGTH 4 - -/* Max number of nodes in a multi cast (group) */ -#define MAX_GROUP_NODES 64 - -/* Macro for accessing the byte in byte_array at the index indx */ -#define BYTE_IN_AR(byte_array, indx) (*(byte_array + indx)) - -/* Macro for getting HIGH uint8_t in wVar uint16_t variable */ -#define BYTE_GET_HIGH_BYTE_IN_WORD(wVar) *((uint8_t*)&wVar) - -/* Macro for getting LOW uint8_t in wVar uint16_t variable */ -#define BYTE_GET_LOW_BYTE_IN_WORD(wVar) *((uint8_t*)&wVar + 1) - -/* Macro for setting HIGH uint8_t and LOW uint8_t in wVar uint16_t variable */ -#define WORD_SET_HIGH_LOW_BYTES(wVar, bHIGHByte, bLOWByte) BYTE_GET_HIGH_BYTE_IN_WORD(wVar) = bHIGHByte; \ - BYTE_GET_LOW_BYTE_IN_WORD(wVar) = bLOWByte - -/* States for ApplicationPoll function */ -enum -{ - stateStartup, - stateIdle, - stateTxSerial, - stateFrameParse, - stateCallbackTxSerial, - stateCommandTxSerial, - stateAppSuspend -}; - -/* States for FUNC_ID_NVM_BACKUP_RESTORE operation */ -typedef enum -{ - NVMBackupRestoreOperationOpen, - NVMBackupRestoreOperationRead, - NVMBackupRestoreOperationWrite, - NVMBackupRestoreOperationClose -} eNVMBackupRestoreOperation; - -/* Return values for FUNC_ID_NVM_BACKUP_RESTORE operation */ -typedef enum -{ - NVMBackupRestoreReturnValueOK = false, /* Everything is OK, so far */ - NVMBackupRestoreReturnValueError = true, /* Non specific error */ - NVMBackupRestoreReturnValueOperationMismatch, /* Error mixing read and write */ - NVMBackupRestoreReturnValueOperationDisturbed, /* Error read operation disturbed by other write */ - NVMBackupRestoreReturnValueEOF = EOF /* Not really an error. Just an indication of EndOfFile */ -} eNVMBackupRestoreReturnValue; - -#ifndef ZW_SECURITY_PROTOCOL -/* params used by ApplicationNodeInformation */ -#define APPL_NODEPARM_MAX 35 -#endif -#define APPL_SLAVENODEPARM_MAX APPL_NODEPARM_MAX - - -typedef enum _E_SERIALAPI_SET_LEARN_MODE_ -{ - SERIALPI_SET_LEARN_MODE_ZW_SET_LEARN_MODE_DISABLE = ZW_SET_LEARN_MODE_DISABLE, - SERIALPI_SET_LEARN_MODE_ZW_SET_LEARN_MODE_CLASSIC = ZW_SET_LEARN_MODE_CLASSIC, - SERIALPI_SET_LEARN_MODE_ZW_SET_LEARN_MODE_NWI = ZW_SET_LEARN_MODE_NWI, - SERIALPI_SET_LEARN_MODE_ZW_SET_LEARN_MODE_NWE = ZW_SET_LEARN_MODE_NWE, - SERIALPI_SET_LEARN_MODE_ZW_SET_LEARN_MODE_MAX = SERIALPI_SET_LEARN_MODE_ZW_SET_LEARN_MODE_NWE, - - /* slave_learn_plus/ctrl_learn extensions */ - SERIALPI_SET_LEARN_MODE_LEARN_PLUS_OFFSET = 0x80, - -} E_SERIALAPI_SET_LEARN_MODE; - -#ifdef ZW_SLAVE_ROUTING -/* SerialAPI only used state - used when ZW_RequestNodeInfo transmit fails */ -/* It is then assumed that the destination node did not receive the request. */ -#define UPDATE_STATE_NODE_INFO_REQ_FAILED 0x81 -#endif - -/* SerialAPI functionality support definitions */ -#define SUPPORT_SEND_DATA_TIMING 1 -/* Definitions for SerialAPI startup */ -typedef enum -{ - SERIALAPI_CONFIG_STARTUP_NOTIFICATION_ENABLED = 1, - SERIALAPI_CONFIG_UNDEFINED = 0xFE -} SERIALAPI_CONFIG_T; - -#if defined(NUNIT_TEST) && !defined(ZW_CONTROLLER_BRIDGE) -#define SUPPORT_ZW_NUNIT 1 -#else -#define SUPPORT_ZW_NUNIT 0 -#endif - -#ifdef PORT_STATUS -#define SUPPORT_ZW_PORT_STATUS 1 -#else -#define SUPPORT_ZW_PORT_STATUS 0 -#endif -#define SUPPORT_ZW_SET_SECURITY_S0_NETWORK_KEY 0 /*deprecated*/ -/* Enable support for SerialAPI Startup Notification */ -#define SUPPORT_SERIAL_API_STARTUP_NOTIFICATION 1 - -/* Security in Protocol SerialAPI functionality support definitions */ -#ifdef ZW_SECURITY_PROTOCOL -#define SUPPORT_APPLICATION_SECURITY_EVENT 0 -#define SUPPORT_SERIAL_API_APPL_NODE_INFORMATION_CMD_CLASSES 1 -#if (SUPPORT_ZW_GET_SECURITY_KEYS | \ - SUPPORT_ZW_SET_SECURITY_S0_NETWORK_KEY | \ - SUPPORT_ZW_GET_SECURITY_S2_PUBLIC_DSK | \ - SUPPORT_ZW_SET_SECURITY_S2_CRITICAL_NODE_ID) -#define SUPPORT_ZW_SECURITY_SETUP 1 -#else -#define SUPPORT_ZW_SECURITY_SETUP 0 -#endif -#else /*#ifdef ZW_SECURITY_PROTOCOL*/ -#define SUPPORT_SERIAL_API_APPL_NODE_INFORMATION_CMD_CLASSES 0 -#define SUPPORT_ZW_SECURITY_SETUP 0 -#define SUPPORT_APPLICATION_SECURITY_EVENT 0 -#endif - -/* Common SerialAPI functionality support definitions */ -#define SUPPORT_SERIAL_API_APPL_NODE_INFORMATION 1 - -#define SUPPORT_SERIAL_API_GET_CAPABILITIES 1 -#define SUPPORT_SERIAL_API_SOFT_RESET 1 - -#define SUPPORT_SERIAL_API_POWER_MANAGEMENT 0 -#define SUPPORT_SERIAL_API_READY 0 - -#define SUPPORT_SERIAL_API_EXT 1 -#ifdef ZW_SECURITY_PROTOCOL -/* Only libraries with SECURITY buildin should supports this (slave_enhanced_232) */ -#define SUPPORT_SERIAL_API_APPL_NODE_INFORMATION_CMD_CLASSES 1 -#else -#define SUPPORT_SERIAL_API_APPL_NODE_INFORMATION_CMD_CLASSES 0 -#endif - -#ifdef ZW_ENABLE_RTC -#define SUPPORT_CLOCK_SET 1 -#define SUPPORT_CLOCK_GET 1 -#define SUPPORT_CLOCK_CMP 1 -#define SUPPORT_RTC_TIMER_CREATE 1 -#define SUPPORT_RTC_TIMER_READ 1 -#define SUPPORT_RTC_TIMER_DELETE 1 -#define SUPPORT_RTC_TIMER_CALL 1 -#else -#define SUPPORT_CLOCK_SET 0 -#define SUPPORT_CLOCK_GET 0 -#define SUPPORT_CLOCK_CMP 0 -#define SUPPORT_RTC_TIMER_CREATE 0 -#define SUPPORT_RTC_TIMER_READ 0 -#define SUPPORT_RTC_TIMER_DELETE 0 -#define SUPPORT_RTC_TIMER_CALL 0 -#endif - -#define SUPPORT_ZW_AUTO_PROGRAMMING 1 - -#ifdef TIMER_SUPPORT -#define SUPPORT_TIMER_START 1 -#define SUPPORT_TIMER_RESTART 1 -#define SUPPORT_TIMER_CANCEL 1 -#define SUPPORT_TIMER_CALL 1 -#else -#define SUPPORT_TIMER_START 0 -#define SUPPORT_TIMER_RESTART 0 -#define SUPPORT_TIMER_CANCEL 0 -#define SUPPORT_TIMER_CALL 0 -#endif - -#if defined(NUNIT_TEST) && !defined(ZW_CONTROLLER_BRIDGE) -#define SUPPORT_ZW_NUNIT 1 -#else -#define SUPPORT_ZW_NUNIT 0 -#endif - -#ifdef PORT_STATUS -#define SUPPORT_ZW_PORT_STATUS 1 -#else -#define SUPPORT_ZW_PORT_STATUS 0 -#endif -/* ZW_EnableSUC() no longer exists in the library */ - -/* */ -#define SUPPORT_SERIAL_API_GET_APPL_HOST_MEMORY_OFFSET 0 - - -#define FID_BM_OFFS(FUNCID) ((FUNCID - 1) / 8) -#define FID_BM(FUNCID) (1 << ((FUNCID - 1) & 0x07)) -#define CAP_FID(OFFSET, FUNCID) (((FUNCID != 0) && (FID_BM_OFFS(FUNCID) == OFFSET)) ? FID_BM(FUNCID) : 0) -#ifdef ZW_CONTROLLER_SINGLE -#define CAP_BM(OFFSET) (CAP_FID(OFFSET, (SUPPORT_SERIAL_API_POWER_MANAGEMENT == 0) ? 0 : FUNC_ID_SERIAL_API_POWER_MANAGEMENT) | \ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_READY == 0) ? 0 : FUNC_ID_SERIAL_API_READY) | \ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_GET_INIT_DATA == 0) ? 0 : FUNC_ID_SERIAL_API_GET_INIT_DATA) | \ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_APPL_NODE_INFORMATION == 0) ? 0 : FUNC_ID_SERIAL_API_APPL_NODE_INFORMATION) | \ - CAP_FID(OFFSET, (SUPPORT_APPLICATION_COMMAND_HANDLER_BRIDGE == 0) ? 0 : FUNC_ID_APPLICATION_COMMAND_HANDLER_BRIDGE) | \ - CAP_FID(OFFSET, (SUPPORT_APPLICATION_COMMAND_HANDLER == 0) ? 0 : FUNC_ID_APPLICATION_COMMAND_HANDLER) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_CONTROLLER_CAPABILITIES == 0) ? 0 : FUNC_ID_ZW_GET_CONTROLLER_CAPABILITIES) | \ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_SET_TIMEOUTS == 0) ? 0 : FUNC_ID_SERIAL_API_SET_TIMEOUTS) | \ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_GET_CAPABILITIES == 0) ? 0 : FUNC_ID_SERIAL_API_GET_CAPABILITIES) | \ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_SOFT_RESET == 0) ? 0 : FUNC_ID_SERIAL_API_SOFT_RESET) | \ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_STARTUP_NOTIFICATION == 0) ? 0 : FUNC_ID_SERIAL_API_STARTED) | \ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_SETUP == 0) ? 0 : FUNC_ID_SERIAL_API_SETUP) | \ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_APPL_NODE_INFORMATION_CMD_CLASSES == 0) ? 0 : FUNC_ID_SERIAL_API_APPL_NODE_INFORMATION_CMD_CLASSES) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_PROTOCOL_VERSION == 0) ? 0 : FUNC_ID_ZW_GET_PROTOCOL_VERSION) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_RF_RECEIVE_MODE == 0) ? 0 : FUNC_ID_ZW_SET_RF_RECEIVE_MODE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_SLEEP_MODE == 0) ? 0 : FUNC_ID_ZW_SET_SLEEP_MODE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_NODE_INFORMATION == 0) ? 0 : FUNC_ID_ZW_SEND_NODE_INFORMATION) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA == 0) ? 0 : FUNC_ID_ZW_SEND_DATA) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_BRIDGE == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_BRIDGE)|\ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_EX == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_EX) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_META_BRIDGE == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_META_BRIDGE)|\ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_MULTI == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_MULTI) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_MULTI_BRIDGE == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_MULTI_BRIDGE)|\ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_MULTI_EX == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_MULTI_EX) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SECURITY_SETUP == 0) ? 0 : FUNC_ID_ZW_SECURITY_SETUP) | \ - CAP_FID(OFFSET, (SUPPORT_APPLICATION_SECURITY_EVENT == 0) ? 0 : FUNC_ID_APPLICATION_SECURITY_EVENT) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_VERSION == 0) ? 0 : FUNC_ID_ZW_GET_VERSION) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_ABORT == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_ABORT) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_RF_POWER_LEVEL_SET == 0) ? 0 : FUNC_ID_ZW_RF_POWER_LEVEL_SET) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_RF_POWER_LEVEL_GET == 0) ? 0 : FUNC_ID_ZW_RF_POWER_LEVEL_GET) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_TYPE_LIBRARY == 0) ? 0 : FUNC_ID_ZW_TYPE_LIBRARY) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_PROTOCOL_STATUS == 0) ? 0 : FUNC_ID_ZW_GET_PROTOCOL_STATUS) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_WATCHDOG_ENABLE == 0) ? 0 : FUNC_ID_ZW_WATCHDOG_ENABLE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_WATCHDOG_DISABLE == 0) ? 0 : FUNC_ID_ZW_WATCHDOG_DISABLE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_WATCHDOG_KICK == 0) ? 0 : FUNC_ID_ZW_WATCHDOG_KICK) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_WATCHDOG_START == 0) ? 0 : FUNC_ID_ZW_WATCHDOG_START)|\ - CAP_FID(OFFSET, (SUPPORT_ZW_WATCHDOG_STOP == 0) ? 0 : FUNC_ID_ZW_WATCHDOG_STOP)|\ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_WUT_TIMEOUT == 0) ? 0 : FUNC_ID_ZW_SET_WUT_TIMEOUT) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_IS_WUT_KICKED == 0) ? 0 : FUNC_ID_ZW_IS_WUT_KICKED) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_EXT_INT_LEVEL == 0) ? 0 : FUNC_ID_ZW_SET_EXT_INT_LEVEL) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_META == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_META) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_TEST_FRAME == 0) ? 0 : FUNC_ID_ZW_SEND_TEST_FRAME) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_RANDOM == 0) ? 0 : FUNC_ID_ZW_GET_RANDOM) | \ - CAP_FID(OFFSET, (SUPPORT_MEMORY_GET_ID == 0) ? 0 : FUNC_ID_MEMORY_GET_ID) | \ - CAP_FID(OFFSET, (SUPPORT_MEMORY_GET_BYTE == 0) ? 0 : FUNC_ID_MEMORY_GET_BYTE) | \ - CAP_FID(OFFSET, (SUPPORT_MEMORY_PUT_BYTE == 0) ? 0 : FUNC_ID_MEMORY_PUT_BYTE) | \ - CAP_FID(OFFSET, (SUPPORT_MEMORY_GET_BUFFER == 0) ? 0 : FUNC_ID_MEMORY_GET_BUFFER) | \ - CAP_FID(OFFSET, (SUPPORT_MEMORY_PUT_BUFFER == 0) ? 0 : FUNC_ID_MEMORY_PUT_BUFFER) | \ - CAP_FID(OFFSET, (SUPPORT_NVM_BACKUP_RESTORE == 0) ? 0 : FUNC_ID_NVM_BACKUP_RESTORE) | \ - CAP_FID(OFFSET, (SUPPORT_NVM_GET_ID == 0) ? 0 : FUNC_ID_NVM_GET_ID) | \ - CAP_FID(OFFSET, (SUPPORT_NVM_EXT_READ_LONG_BYTE == 0) ? 0 : FUNC_ID_NVM_EXT_READ_LONG_BYTE) | \ - CAP_FID(OFFSET, (SUPPORT_NVM_EXT_WRITE_LONG_BYTE == 0) ? 0 : FUNC_ID_NVM_EXT_WRITE_LONG_BYTE) | \ - CAP_FID(OFFSET, (SUPPORT_NVM_EXT_READ_LONG_BUFFER == 0) ? 0 : FUNC_ID_NVM_EXT_READ_LONG_BUFFER) | \ - CAP_FID(OFFSET, (SUPPORT_NVM_EXT_WRITE_LONG_BUFFER == 0) ? 0 : FUNC_ID_NVM_EXT_WRITE_LONG_BUFFER) | \ - CAP_FID(OFFSET, (SUPPORT_CLOCK_SET == 0) ? 0 : FUNC_ID_CLOCK_SET) | \ - CAP_FID(OFFSET, (SUPPORT_CLOCK_GET == 0) ? 0 : FUNC_ID_CLOCK_GET) | \ - CAP_FID(OFFSET, (SUPPORT_CLOCK_CMP == 0) ? 0 : FUNC_ID_CLOCK_CMP) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_NVR_GET_VALUE == 0) ? 0 : FUNC_ID_NVR_GET_VALUE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_AUTO_PROGRAMMING == 0) ? 0 : FUNC_ID_AUTO_PROGRAMMING) | \ - CAP_FID(OFFSET, (SUPPORT_PWR_SETSTOPMODE == 0) ? 0 : FUNC_ID_PWR_SETSTOPMODE) | \ - CAP_FID(OFFSET, (SUPPORT_PWR_CLK_PD == 0) ? 0 : FUNC_ID_PWR_CLK_PD) | \ - CAP_FID(OFFSET, (SUPPORT_PWR_CLK_PUP == 0) ? 0 : FUNC_ID_PWR_CLK_PUP) | \ - CAP_FID(OFFSET, (SUPPORT_PWR_SELECT_CLK == 0) ? 0 : FUNC_ID_PWR_SELECT_CLK) | \ - CAP_FID(OFFSET, (SUPPORT_RTC_TIMER_CREATE == 0) ? 0 : FUNC_ID_RTC_TIMER_CREATE) | \ - CAP_FID(OFFSET, (SUPPORT_RTC_TIMER_READ == 0) ? 0 : FUNC_ID_RTC_TIMER_READ) | \ - CAP_FID(OFFSET, (SUPPORT_RTC_TIMER_DELETE == 0) ? 0 : FUNC_ID_RTC_TIMER_DELETE) | \ - CAP_FID(OFFSET, (SUPPORT_RTC_TIMER_CALL == 0) ? 0 : FUNC_ID_RTC_TIMER_CALL) | \ - CAP_FID(OFFSET, (SUPPORT_FUNC_ID_CLEAR_TX_TIMERS == 0) ? 0 : FUNC_ID_CLEAR_TX_TIMERS) | \ - CAP_FID(OFFSET, (SUPPORT_FUNC_ID_GET_TX_TIMERS == 0) ? 0 : FUNC_ID_GET_TX_TIMERS) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_CLEAR_NETWORK_STATS == 0) ? 0 : FUNC_ID_ZW_CLEAR_NETWORK_STATS) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_NETWORK_STATS == 0) ? 0 : FUNC_ID_ZW_GET_NETWORK_STATS) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_BACKGROUND_RSSI == 0) ? 0 : FUNC_ID_ZW_GET_BACKGROUND_RSSI) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_REMOVE_NODE_ID_FROM_NETWORK == 0) ? 0 : FUNC_ID_ZW_REMOVE_NODE_ID_FROM_NETWORK) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_LEARN_NODE_STATE == 0) ? 0 : FUNC_ID_ZW_SET_LEARN_NODE_STATE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_NODE_PROTOCOL_INFO == 0) ? 0 : FUNC_ID_ZW_GET_NODE_PROTOCOL_INFO) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_DEFAULT == 0) ? 0 : FUNC_ID_ZW_SET_DEFAULT) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_NEW_CONTROLLER == 0) ? 0 : FUNC_ID_ZW_NEW_CONTROLLER) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_REPLICATION_COMMAND_COMPLETE == 0) ? 0 : FUNC_ID_ZW_REPLICATION_COMMAND_COMPLETE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_REPLICATION_SEND_DATA == 0) ? 0 : FUNC_ID_ZW_REPLICATION_SEND_DATA) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_ASSIGN_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_ASSIGN_RETURN_ROUTE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_DELETE_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_DELETE_RETURN_ROUTE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_REQUEST_NODE_NEIGHBOR_UPDATE == 0) ? 0 : FUNC_ID_ZW_REQUEST_NODE_NEIGHBOR_UPDATE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_NEIGHBOR_COUNT == 0) ? 0 : FUNC_ID_ZW_GET_NEIGHBOR_COUNT) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_ARE_NODES_NEIGHBOURS == 0) ? 0 : FUNC_ID_ZW_ARE_NODES_NEIGHBOURS) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_APPLICATION_CONTROLLER_UPDATE == 0) ? 0 : FUNC_ID_ZW_APPLICATION_UPDATE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_ADD_NODE_TO_NETWORK == 0) ? 0 : FUNC_ID_ZW_ADD_NODE_TO_NETWORK) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_REMOVE_NODE_FROM_NETWORK == 0) ? 0 : FUNC_ID_ZW_REMOVE_NODE_FROM_NETWORK) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_CREATE_NEW_PRIMARY == 0) ? 0 : FUNC_ID_ZW_CREATE_NEW_PRIMARY) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_CONTROLLER_CHANGE == 0) ? 0 : FUNC_ID_ZW_CONTROLLER_CHANGE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_REQUEST_NODE_INFO == 0) ? 0 : FUNC_ID_ZW_REQUEST_NODE_INFO) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_REMOVE_FAILED_NODE_ID == 0) ? 0 : FUNC_ID_ZW_REMOVE_FAILED_NODE_ID) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_IS_FAILED_NODE_ID == 0) ? 0 : FUNC_ID_ZW_IS_FAILED_NODE_ID) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_REPLACE_FAILED_NODE == 0) ? 0 : FUNC_ID_ZW_REPLACE_FAILED_NODE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_ROUTING_MAX == 0) ? 0 : FUNC_ID_ZW_GET_ROUTING_MAX) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_ROUTING_MAX == 0) ? 0 : FUNC_ID_ZW_SET_ROUTING_MAX) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_IS_PRIMARY_CTRL == 0) ? 0 : FUNC_ID_ZW_IS_PRIMARY_CTRL) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_AES_ECB == 0) ? 0 : FUNC_ID_ZW_AES_ECB) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_APPLICATION_UPDATE == 0) ? 0 : FUNC_ID_ZW_APPLICATION_UPDATE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_LEARN_MODE == 0) ? 0 : FUNC_ID_ZW_SET_LEARN_MODE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_EXPLORE_REQUEST_INCLUSION == 0) ? 0 : FUNC_ID_ZW_EXPLORE_REQUEST_INCLUSION) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_EXPLORE_REQUEST_EXCLUSION == 0) ? 0 : FUNC_ID_ZW_EXPLORE_REQUEST_EXCLUSION) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_ASSIGN_SUC_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_ASSIGN_SUC_RETURN_ROUTE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_ENABLE_SUC == 0) ? 0 : FUNC_ID_ZW_ENABLE_SUC) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_REQUEST_NETWORK_UPDATE == 0) ? 0 : FUNC_ID_ZW_REQUEST_NETWORK_UPDATE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_SUC_NODE_ID == 0) ? 0 : FUNC_ID_ZW_SET_SUC_NODE_ID) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_DELETE_SUC_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_DELETE_SUC_RETURN_ROUTE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_SUC_NODE_ID == 0) ? 0 : FUNC_ID_ZW_GET_SUC_NODE_ID) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_SUC_ID == 0) ? 0 : FUNC_ID_ZW_SEND_SUC_ID) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_ASSIGN_PRIORITY_SUC_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_ASSIGN_PRIORITY_SUC_RETURN_ROUTE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_ASSIGN_PRIORITY_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_ASSIGN_PRIORITY_RETURN_ROUTE) | \ - CAP_FID(OFFSET, (SUPPORT_TIMER_START == 0) ? 0 : FUNC_ID_TIMER_START) | \ - CAP_FID(OFFSET, (SUPPORT_TIMER_RESTART == 0) ? 0 : FUNC_ID_TIMER_RESTART) | \ - CAP_FID(OFFSET, (SUPPORT_TIMER_CANCEL == 0) ? 0 : FUNC_ID_TIMER_CANCEL) | \ - CAP_FID(OFFSET, (SUPPORT_TIMER_CALL == 0) ? 0 : FUNC_ID_TIMER_CALL) | \ - CAP_FID(OFFSET, (SUPPORT_GET_ROUTING_TABLE_LINE == 0) ? 0 : FUNC_ID_GET_ROUTING_TABLE_LINE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_ROUTING_INFO == 0) ? 0 : FUNC_ID_ZW_SET_ROUTING_INFO) | \ - CAP_FID(OFFSET, (SUPPORT_GET_TX_COUNTER == 0) ? 0 : FUNC_ID_GET_TX_COUNTER) | \ - CAP_FID(OFFSET, (SUPPORT_RESET_TX_COUNTER == 0) ? 0 : FUNC_ID_RESET_TX_COUNTER) | \ - CAP_FID(OFFSET, (SUPPORT_STORE_NODEINFO == 0) ? 0 : FUNC_ID_STORE_NODEINFO) | \ - CAP_FID(OFFSET, (SUPPORT_STORE_HOMEID == 0) ? 0 : FUNC_ID_STORE_HOMEID) | \ - CAP_FID(OFFSET, (SUPPORT_LOCK_ROUTE_RESPONSE == 0) ? 0 : FUNC_ID_LOCK_ROUTE_RESPONSE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_PRIORITY_ROUTE == 0) ? 0 : FUNC_ID_ZW_GET_PRIORITY_ROUTE)|\ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_PRIORITY_ROUTE == 0) ? 0 : FUNC_ID_ZW_SET_PRIORITY_ROUTE)|\ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_APPL_SLAVE_NODE_INFORMATION == 0) ? 0 : FUNC_ID_SERIAL_API_APPL_SLAVE_NODE_INFORMATION) | \ - CAP_FID(OFFSET, (SUPPORT_APPLICATION_SLAVE_COMMAND_HANDLER == 0) ? 0 : FUNC_ID_APPLICATION_SLAVE_COMMAND_HANDLER) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_SLAVE_NODE_INFORMATION == 0) ? 0 : FUNC_ID_ZW_SEND_SLAVE_NODE_INFORMATION) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_SLAVE_DATA == 0) ? 0 : FUNC_ID_ZW_SEND_SLAVE_DATA) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_SLAVE_LEARN_MODE == 0) ? 0 : FUNC_ID_ZW_SET_SLAVE_LEARN_MODE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_VIRTUAL_NODES == 0) ? 0 : FUNC_ID_ZW_GET_VIRTUAL_NODES) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_IS_VIRTUAL_NODE == 0) ? 0 : FUNC_ID_ZW_IS_VIRTUAL_NODE) | \ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_TEST == 0) ? 0 : FUNC_ID_SERIAL_API_TEST) | \ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_EXT == 0) ? 0 : FUNC_ID_SERIAL_API_EXT) | \ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_GET_APPL_HOST_MEMORY_OFFSET == 0) ? 0 : FUNC_ID_SERIAL_API_GET_APPL_HOST_MEMORY_OFFSET) |\ - CAP_FID(OFFSET, (SUPPORT_ZW_NUNIT == 0) ? 0 : FUNC_ID_ZW_NUNIT_CMD) |\ - CAP_FID(OFFSET, (SUPPORT_ZW_NUNIT == 0) ? 0 : FUNC_ID_ZW_NUNIT_INIT) |\ - CAP_FID(OFFSET, (SUPPORT_ZW_NUNIT == 0) ? 0 : FUNC_ID_ZW_NUNIT_LIST) |\ - CAP_FID(OFFSET, (SUPPORT_ZW_NUNIT == 0) ? 0 : FUNC_ID_ZW_NUNIT_RUN) |\ - CAP_FID(OFFSET, (SUPPORT_ZW_NUNIT == 0) ? 0 : FUNC_ID_ZW_NUNIT_END) |\ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_LISTEN_BEFORE_TALK_THRESHOLD == 0) ? 0 : FUNC_ID_ZW_SET_LISTEN_BEFORE_TALK_THRESHOLD)| \ - CAP_FID(OFFSET, (SUPPORT_ZW_NETWORK_MANAGEMENT_SET_MAX_INCLUSION_REQUEST_INTERVALS == 0) ? 0 : FUNC_ID_ZW_NETWORK_MANAGEMENT_SET_MAX_INCLUSION_REQUEST_INTERVALS) \ - ) -#else -#define CAP_BM(OFFSET) (CAP_FID(OFFSET, (SUPPORT_SERIAL_API_POWER_MANAGEMENT == 0) ? 0 : FUNC_ID_SERIAL_API_POWER_MANAGEMENT) | \ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_READY == 0) ? 0 : FUNC_ID_SERIAL_API_READY) | \ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_GET_INIT_DATA == 0) ? 0 : FUNC_ID_SERIAL_API_GET_INIT_DATA) | \ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_APPL_NODE_INFORMATION == 0) ? 0 : FUNC_ID_SERIAL_API_APPL_NODE_INFORMATION) | \ - CAP_FID(OFFSET, (SUPPORT_APPLICATION_COMMAND_HANDLER_BRIDGE == 0) ? 0 : FUNC_ID_APPLICATION_COMMAND_HANDLER_BRIDGE) | \ - CAP_FID(OFFSET, (SUPPORT_APPLICATION_COMMAND_HANDLER == 0) ? 0 : FUNC_ID_APPLICATION_COMMAND_HANDLER) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_CONTROLLER_CAPABILITIES == 0) ? 0 : FUNC_ID_ZW_GET_CONTROLLER_CAPABILITIES) | \ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_SET_TIMEOUTS == 0) ? 0 : FUNC_ID_SERIAL_API_SET_TIMEOUTS) | \ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_GET_CAPABILITIES == 0) ? 0 : FUNC_ID_SERIAL_API_GET_CAPABILITIES) | \ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_SOFT_RESET == 0) ? 0 : FUNC_ID_SERIAL_API_SOFT_RESET) | \ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_STARTUP_NOTIFICATION == 0) ? 0 : FUNC_ID_SERIAL_API_STARTED) | \ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_SETUP == 0) ? 0 : FUNC_ID_SERIAL_API_SETUP) | \ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_APPL_NODE_INFORMATION_CMD_CLASSES == 0) ? 0 : FUNC_ID_SERIAL_API_APPL_NODE_INFORMATION_CMD_CLASSES) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_PROTOCOL_VERSION == 0) ? 0 : FUNC_ID_ZW_GET_PROTOCOL_VERSION) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_RF_RECEIVE_MODE == 0) ? 0 : FUNC_ID_ZW_SET_RF_RECEIVE_MODE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_SLEEP_MODE == 0) ? 0 : FUNC_ID_ZW_SET_SLEEP_MODE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_NODE_INFORMATION == 0) ? 0 : FUNC_ID_ZW_SEND_NODE_INFORMATION) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA == 0) ? 0 : FUNC_ID_ZW_SEND_DATA) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_BRIDGE == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_BRIDGE)|\ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_EX == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_EX) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_META_BRIDGE == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_META_BRIDGE)|\ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_MULTI == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_MULTI) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_MULTI_BRIDGE == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_MULTI_BRIDGE)|\ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_MULTI_EX == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_MULTI_EX) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SECURITY_SETUP == 0) ? 0 : FUNC_ID_ZW_SECURITY_SETUP) | \ - CAP_FID(OFFSET, (SUPPORT_APPLICATION_SECURITY_EVENT == 0) ? 0 : FUNC_ID_APPLICATION_SECURITY_EVENT) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_VERSION == 0) ? 0 : FUNC_ID_ZW_GET_VERSION) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_ABORT == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_ABORT) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_RF_POWER_LEVEL_SET == 0) ? 0 : FUNC_ID_ZW_RF_POWER_LEVEL_SET) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_RF_POWER_LEVEL_GET == 0) ? 0 : FUNC_ID_ZW_RF_POWER_LEVEL_GET) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_TYPE_LIBRARY == 0) ? 0 : FUNC_ID_ZW_TYPE_LIBRARY) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_PROTOCOL_STATUS == 0) ? 0 : FUNC_ID_ZW_GET_PROTOCOL_STATUS) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_WATCHDOG_ENABLE == 0) ? 0 : FUNC_ID_ZW_WATCHDOG_ENABLE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_WATCHDOG_DISABLE == 0) ? 0 : FUNC_ID_ZW_WATCHDOG_DISABLE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_WATCHDOG_KICK == 0) ? 0 : FUNC_ID_ZW_WATCHDOG_KICK) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_WATCHDOG_START == 0) ? 0 : FUNC_ID_ZW_WATCHDOG_START)|\ - CAP_FID(OFFSET, (SUPPORT_ZW_WATCHDOG_STOP == 0) ? 0 : FUNC_ID_ZW_WATCHDOG_STOP)|\ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_WUT_TIMEOUT == 0) ? 0 : FUNC_ID_ZW_SET_WUT_TIMEOUT) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_IS_WUT_KICKED == 0) ? 0 : FUNC_ID_ZW_IS_WUT_KICKED) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_EXT_INT_LEVEL == 0) ? 0 : FUNC_ID_ZW_SET_EXT_INT_LEVEL) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_META == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_META) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_TEST_FRAME == 0) ? 0 : FUNC_ID_ZW_SEND_TEST_FRAME) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_RANDOM == 0) ? 0 : FUNC_ID_ZW_GET_RANDOM) | \ - CAP_FID(OFFSET, (SUPPORT_MEMORY_GET_ID == 0) ? 0 : FUNC_ID_MEMORY_GET_ID) | \ - CAP_FID(OFFSET, (SUPPORT_MEMORY_GET_BYTE == 0) ? 0 : FUNC_ID_MEMORY_GET_BYTE) | \ - CAP_FID(OFFSET, (SUPPORT_MEMORY_PUT_BYTE == 0) ? 0 : FUNC_ID_MEMORY_PUT_BYTE) | \ - CAP_FID(OFFSET, (SUPPORT_MEMORY_GET_BUFFER == 0) ? 0 : FUNC_ID_MEMORY_GET_BUFFER) | \ - CAP_FID(OFFSET, (SUPPORT_MEMORY_PUT_BUFFER == 0) ? 0 : FUNC_ID_MEMORY_PUT_BUFFER) | \ - CAP_FID(OFFSET, (SUPPORT_NVM_BACKUP_RESTORE == 0) ? 0 : FUNC_ID_NVM_BACKUP_RESTORE) | \ - CAP_FID(OFFSET, (SUPPORT_NVM_GET_ID == 0) ? 0 : FUNC_ID_NVM_GET_ID) | \ - CAP_FID(OFFSET, (SUPPORT_NVM_EXT_READ_LONG_BYTE == 0) ? 0 : FUNC_ID_NVM_EXT_READ_LONG_BYTE) | \ - CAP_FID(OFFSET, (SUPPORT_NVM_EXT_WRITE_LONG_BYTE == 0) ? 0 : FUNC_ID_NVM_EXT_WRITE_LONG_BYTE) | \ - CAP_FID(OFFSET, (SUPPORT_NVM_EXT_READ_LONG_BUFFER == 0) ? 0 : FUNC_ID_NVM_EXT_READ_LONG_BUFFER) | \ - CAP_FID(OFFSET, (SUPPORT_NVM_EXT_WRITE_LONG_BUFFER == 0) ? 0 : FUNC_ID_NVM_EXT_WRITE_LONG_BUFFER) | \ - CAP_FID(OFFSET, (SUPPORT_CLOCK_SET == 0) ? 0 : FUNC_ID_CLOCK_SET) | \ - CAP_FID(OFFSET, (SUPPORT_CLOCK_GET == 0) ? 0 : FUNC_ID_CLOCK_GET) | \ - CAP_FID(OFFSET, (SUPPORT_CLOCK_CMP == 0) ? 0 : FUNC_ID_CLOCK_CMP) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_NVR_GET_VALUE == 0) ? 0 : FUNC_ID_NVR_GET_VALUE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_AUTO_PROGRAMMING == 0) ? 0 : FUNC_ID_AUTO_PROGRAMMING) | \ - CAP_FID(OFFSET, (SUPPORT_PWR_SETSTOPMODE == 0) ? 0 : FUNC_ID_PWR_SETSTOPMODE) | \ - CAP_FID(OFFSET, (SUPPORT_PWR_CLK_PD == 0) ? 0 : FUNC_ID_PWR_CLK_PD) | \ - CAP_FID(OFFSET, (SUPPORT_PWR_CLK_PUP == 0) ? 0 : FUNC_ID_PWR_CLK_PUP) | \ - CAP_FID(OFFSET, (SUPPORT_PWR_SELECT_CLK == 0) ? 0 : FUNC_ID_PWR_SELECT_CLK) | \ - CAP_FID(OFFSET, (SUPPORT_RTC_TIMER_CREATE == 0) ? 0 : FUNC_ID_RTC_TIMER_CREATE) | \ - CAP_FID(OFFSET, (SUPPORT_RTC_TIMER_READ == 0) ? 0 : FUNC_ID_RTC_TIMER_READ) | \ - CAP_FID(OFFSET, (SUPPORT_RTC_TIMER_DELETE == 0) ? 0 : FUNC_ID_RTC_TIMER_DELETE) | \ - CAP_FID(OFFSET, (SUPPORT_RTC_TIMER_CALL == 0) ? 0 : FUNC_ID_RTC_TIMER_CALL) | \ - CAP_FID(OFFSET, (SUPPORT_FUNC_ID_CLEAR_TX_TIMERS == 0) ? 0 : FUNC_ID_CLEAR_TX_TIMERS) | \ - CAP_FID(OFFSET, (SUPPORT_FUNC_ID_GET_TX_TIMERS == 0) ? 0 : FUNC_ID_GET_TX_TIMERS) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_CLEAR_NETWORK_STATS == 0) ? 0 : FUNC_ID_ZW_CLEAR_NETWORK_STATS) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_NETWORK_STATS == 0) ? 0 : FUNC_ID_ZW_GET_NETWORK_STATS) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_BACKGROUND_RSSI == 0) ? 0 : FUNC_ID_ZW_GET_BACKGROUND_RSSI) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_REMOVE_NODE_ID_FROM_NETWORK == 0) ? 0 : FUNC_ID_ZW_REMOVE_NODE_ID_FROM_NETWORK) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_LEARN_NODE_STATE == 0) ? 0 : FUNC_ID_ZW_SET_LEARN_NODE_STATE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_NODE_PROTOCOL_INFO == 0) ? 0 : FUNC_ID_ZW_GET_NODE_PROTOCOL_INFO) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_DEFAULT == 0) ? 0 : FUNC_ID_ZW_SET_DEFAULT) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_NEW_CONTROLLER == 0) ? 0 : FUNC_ID_ZW_NEW_CONTROLLER) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_REPLICATION_COMMAND_COMPLETE == 0) ? 0 : FUNC_ID_ZW_REPLICATION_COMMAND_COMPLETE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_REPLICATION_SEND_DATA == 0) ? 0 : FUNC_ID_ZW_REPLICATION_SEND_DATA) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_ASSIGN_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_ASSIGN_RETURN_ROUTE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_DELETE_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_DELETE_RETURN_ROUTE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_REQUEST_NODE_NEIGHBOR_UPDATE == 0) ? 0 : FUNC_ID_ZW_REQUEST_NODE_NEIGHBOR_UPDATE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_APPLICATION_CONTROLLER_UPDATE == 0) ? 0 : FUNC_ID_ZW_APPLICATION_UPDATE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_ADD_NODE_TO_NETWORK == 0) ? 0 : FUNC_ID_ZW_ADD_NODE_TO_NETWORK) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_REMOVE_NODE_FROM_NETWORK == 0) ? 0 : FUNC_ID_ZW_REMOVE_NODE_FROM_NETWORK) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_CREATE_NEW_PRIMARY == 0) ? 0 : FUNC_ID_ZW_CREATE_NEW_PRIMARY) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_CONTROLLER_CHANGE == 0) ? 0 : FUNC_ID_ZW_CONTROLLER_CHANGE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_REQUEST_NODE_INFO == 0) ? 0 : FUNC_ID_ZW_REQUEST_NODE_INFO) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_REMOVE_FAILED_NODE_ID == 0) ? 0 : FUNC_ID_ZW_REMOVE_FAILED_NODE_ID) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_IS_FAILED_NODE_ID == 0) ? 0 : FUNC_ID_ZW_IS_FAILED_NODE_ID) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_REPLACE_FAILED_NODE == 0) ? 0 : FUNC_ID_ZW_REPLACE_FAILED_NODE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_ROUTING_MAX == 0) ? 0 : FUNC_ID_ZW_GET_ROUTING_MAX) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_ROUTING_MAX == 0) ? 0 : FUNC_ID_ZW_SET_ROUTING_MAX) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_IS_PRIMARY_CTRL == 0) ? 0 : FUNC_ID_ZW_IS_PRIMARY_CTRL) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_AES_ECB == 0) ? 0 : FUNC_ID_ZW_AES_ECB) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_APPLICATION_UPDATE == 0) ? 0 : FUNC_ID_ZW_APPLICATION_UPDATE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_LEARN_MODE == 0) ? 0 : FUNC_ID_ZW_SET_LEARN_MODE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_EXPLORE_REQUEST_INCLUSION == 0) ? 0 : FUNC_ID_ZW_EXPLORE_REQUEST_INCLUSION) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_EXPLORE_REQUEST_EXCLUSION == 0) ? 0 : FUNC_ID_ZW_EXPLORE_REQUEST_EXCLUSION) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_ASSIGN_SUC_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_ASSIGN_SUC_RETURN_ROUTE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_ENABLE_SUC == 0) ? 0 : FUNC_ID_ZW_ENABLE_SUC) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_REQUEST_NETWORK_UPDATE == 0) ? 0 : FUNC_ID_ZW_REQUEST_NETWORK_UPDATE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_SUC_NODE_ID == 0) ? 0 : FUNC_ID_ZW_SET_SUC_NODE_ID) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_DELETE_SUC_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_DELETE_SUC_RETURN_ROUTE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_SUC_NODE_ID == 0) ? 0 : FUNC_ID_ZW_GET_SUC_NODE_ID) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_SUC_ID == 0) ? 0 : FUNC_ID_ZW_SEND_SUC_ID) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_ASSIGN_PRIORITY_SUC_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_ASSIGN_PRIORITY_SUC_RETURN_ROUTE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_ASSIGN_PRIORITY_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_ASSIGN_PRIORITY_RETURN_ROUTE) | \ - CAP_FID(OFFSET, (SUPPORT_TIMER_START == 0) ? 0 : FUNC_ID_TIMER_START) | \ - CAP_FID(OFFSET, (SUPPORT_TIMER_RESTART == 0) ? 0 : FUNC_ID_TIMER_RESTART) | \ - CAP_FID(OFFSET, (SUPPORT_TIMER_CANCEL == 0) ? 0 : FUNC_ID_TIMER_CANCEL) | \ - CAP_FID(OFFSET, (SUPPORT_TIMER_CALL == 0) ? 0 : FUNC_ID_TIMER_CALL) | \ - CAP_FID(OFFSET, (SUPPORT_GET_ROUTING_TABLE_LINE == 0) ? 0 : FUNC_ID_GET_ROUTING_TABLE_LINE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_ROUTING_INFO == 0) ? 0 : FUNC_ID_ZW_SET_ROUTING_INFO) | \ - CAP_FID(OFFSET, (SUPPORT_GET_TX_COUNTER == 0) ? 0 : FUNC_ID_GET_TX_COUNTER) | \ - CAP_FID(OFFSET, (SUPPORT_RESET_TX_COUNTER == 0) ? 0 : FUNC_ID_RESET_TX_COUNTER) | \ - CAP_FID(OFFSET, (SUPPORT_STORE_NODEINFO == 0) ? 0 : FUNC_ID_STORE_NODEINFO) | \ - CAP_FID(OFFSET, (SUPPORT_STORE_HOMEID == 0) ? 0 : FUNC_ID_STORE_HOMEID) | \ - CAP_FID(OFFSET, (SUPPORT_LOCK_ROUTE_RESPONSE == 0) ? 0 : FUNC_ID_LOCK_ROUTE_RESPONSE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_PRIORITY_ROUTE == 0) ? 0 : FUNC_ID_ZW_GET_PRIORITY_ROUTE)|\ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_PRIORITY_ROUTE == 0) ? 0 : FUNC_ID_ZW_SET_PRIORITY_ROUTE)|\ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_APPL_SLAVE_NODE_INFORMATION == 0) ? 0 : FUNC_ID_SERIAL_API_APPL_SLAVE_NODE_INFORMATION) | \ - CAP_FID(OFFSET, (SUPPORT_APPLICATION_SLAVE_COMMAND_HANDLER == 0) ? 0 : FUNC_ID_APPLICATION_SLAVE_COMMAND_HANDLER) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_SLAVE_NODE_INFORMATION == 0) ? 0 : FUNC_ID_ZW_SEND_SLAVE_NODE_INFORMATION) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SEND_SLAVE_DATA == 0) ? 0 : FUNC_ID_ZW_SEND_SLAVE_DATA) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_SLAVE_LEARN_MODE == 0) ? 0 : FUNC_ID_ZW_SET_SLAVE_LEARN_MODE) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_GET_VIRTUAL_NODES == 0) ? 0 : FUNC_ID_ZW_GET_VIRTUAL_NODES) | \ - CAP_FID(OFFSET, (SUPPORT_ZW_IS_VIRTUAL_NODE == 0) ? 0 : FUNC_ID_ZW_IS_VIRTUAL_NODE) | \ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_EXT == 0) ? 0 : FUNC_ID_SERIAL_API_EXT) | \ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_GET_APPL_HOST_MEMORY_OFFSET == 0) ? 0 : FUNC_ID_SERIAL_API_GET_APPL_HOST_MEMORY_OFFSET) |\ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_PROMISCUOUS_MODE == 0) ? 0 : FUNC_ID_ZW_SET_PROMISCUOUS_MODE) |\ - CAP_FID(OFFSET, (SUPPORT_ZW_NUNIT == 0) ? 0 : FUNC_ID_ZW_NUNIT_CMD) |\ - CAP_FID(OFFSET, (SUPPORT_ZW_NUNIT == 0) ? 0 : FUNC_ID_ZW_NUNIT_INIT) |\ - CAP_FID(OFFSET, (SUPPORT_ZW_NUNIT == 0) ? 0 : FUNC_ID_ZW_NUNIT_LIST) |\ - CAP_FID(OFFSET, (SUPPORT_ZW_NUNIT == 0) ? 0 : FUNC_ID_ZW_NUNIT_RUN) |\ - CAP_FID(OFFSET, (SUPPORT_ZW_NUNIT == 0) ? 0 : FUNC_ID_ZW_NUNIT_END) |\ - CAP_FID(OFFSET, (SUPPORT_ZW_SET_LISTEN_BEFORE_TALK_THRESHOLD == 0) ? 0 : FUNC_ID_ZW_SET_LISTEN_BEFORE_TALK_THRESHOLD)| \ - CAP_FID(OFFSET, (SUPPORT_ZW_NETWORK_MANAGEMENT_SET_MAX_INCLUSION_REQUEST_INTERVALS == 0) ? 0 : FUNC_ID_ZW_NETWORK_MANAGEMENT_SET_MAX_INCLUSION_REQUEST_INTERVALS)| \ - CAP_FID(OFFSET, (SUPPORT_ZW_INITIATE_SHUTDOWN == 0) ? 0 : FUNC_ID_ZW_INITIATE_SHUTDOWN) |\ - CAP_FID(OFFSET, (SUPPORT_SERIAL_API_GET_LR_NODES == 0) ? 0 : FUNC_ID_SERIAL_API_GET_LR_NODES) |\ - CAP_FID(OFFSET, (SUPPORT_SERIAL_GET_LR_CHANNEL == 0) ? 0 : FUNC_ID_GET_LR_CHANNEL) |\ - CAP_FID(OFFSET, (SUPPORT_SERIAL_SET_LR_CHANNEL == 0) ? 0 : FUNC_ID_SET_LR_CHANNEL) |\ - CAP_FID(OFFSET, (SUPPORT_SERIAL_SET_LR_VIRTUAL_IDS == 0) ? 0 : FUNC_ID_ZW_SET_LR_VIRTUAL_IDS) |\ - CAP_FID(OFFSET, (SUPPORT_SERIAL_ENABLE_RADIO_PTI == 0) ? 0 : FUNC_ID_ENABLE_RADIO_PTI) |\ - CAP_FID(OFFSET, (SUPPORT_SERIAL_ENABLE_RADIO_PTI == 0) ? 0 : FUNC_ID_GET_RADIO_PTI) \ - ) -#endif /* ZW_CONTROLLER_SINGLE */ - - -#if SUPPORT_SERIAL_API_READY -enum -{ - /* SERIAL_LINK_IDLE = Ready for incomming Serial communication, but */ - /* do not transmit anything via the serial link even if application */ - /* frames is received on the RF, which normally should be transmitted */ - /* to the HOST. */ - SERIAL_LINK_DETACHED = 0, - /* SERIAL_LINK_CONNECTED = There exists a HOST so transmit on serial */ - /* link if needed. */ - SERIAL_LINK_CONNECTED = 1 -}; - -extern uint8_t serialLinkState; -#endif /* SUPPORT_SERIAL_API_READY */ - -extern void DoRespond_workbuf( - uint8_t cnt); - -extern void set_state_and_notify( - uint8_t st -); - -extern void set_state( - uint8_t st -); - -extern bool Request( - uint8_t cmd, /*IN Command */ - uint8_t *pData, /*IN pointer to data */ - uint8_t len /*IN Length of data */ -); - -extern bool RequestUnsolicited( - uint8_t cmd, /*IN Command */ - uint8_t *pData, /*IN pointer to data */ - uint8_t len /*IN Length of data */ -); - -extern void Respond( - uint8_t cmd, /*IN Command */ - uint8_t const * pData, /*IN pointer to data */ - uint8_t len /*IN Length of data */ -); -extern void DoRespond(uint8_t retVal); - -extern void PopCallBackQueue(void); - -extern void PopCommandQueue(void); - -extern uint8_t GetCallbackCnt(void); - -extern void ZW_GetMfgTokenDataCountryFreq(void *data); - -#ifdef ZW_CONTROLLER_SINGLE -#if SUPPORT_SERIAL_API_TEST - -extern void -SendTestReport( - uint8_t txStatus); - -extern void -TestStartRound(void); - -extern void -SendTestRoundReport( - uint8_t txStatus); - -extern void -ZCB_TestDelayNextSendTimeout(void); - -extern void -ZCB_TestDelayTimeout(void); - -extern bool -TestFindNextNode(void); - -extern void -ZCB_TestSendComplete( - uint8_t bStatus, - TX_STATUS_TYPE *txStatusReport); - -extern void -TestSend(void); - -#endif /* SUPPORT_SERIAL_API_TEST */ -#endif /* ZW_CONTROLLER_SINGLE */ - -#if SUPPORT_SERIAL_API_POWER_MANAGEMENT -extern void -ZCB_PowerManagementWakeUpOnExternalActive(void); - -extern void -ZCB_PowerManagementWakeUpOnTimerHandler(void); - -extern void -ZCB_powerManagementPoweredUpPinActive(void); - -extern void -PowerManagementSetPowerDown(void); - -extern void -PowerManagementSetPowerUp(void); - -extern void -PowerManagementCheck(void); - -extern void -PurgeCallbackQueue(void); - -extern void -PurgeCommandQueue(void); -#endif /* SUPPORT_SERIAL_API_POWER_MANAGEMENT */ - -// Prioritized events that can wakeup protocol thread. -typedef enum EApplicationEvent -{ - EAPPLICATIONEVENT_ZWRX = 0, - EAPPLICATIONEVENT_ZWCOMMANDSTATUS, - EAPPLICATIONEVENT_STATECHANGE, - EAPPLICATIONEVENT_SERIALDATARX, - EAPPLICATIONEVENT_SERIALTIMEOUT, - EAPPLICATIONEVENT_TIMER -} EApplicationEvent; - -/* FUNC_ID_SERIAL_API_STARTED Capabilities bit field definitions */ -typedef enum -{ - SERIAL_API_STARTED_CAPABILITIES_L0NG_RANGE = 1<<0 // Controller is Z-Wave Long Range capable - /* Can be extended with future capability bits here */ -} eSerialAPIStartedCapabilities; - -extern void ApplicationNodeUpdate(uint8_t bStatus, uint16_t nodeID, uint8_t *pCmd, uint8_t bLen); - -/* Should be enough */ -#define BUF_SIZE_RX 168 -#define BUF_SIZE_TX 168 - -extern uint8_t compl_workbuf[BUF_SIZE_TX]; - -#endif /* _SERIALAPPL_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/app_node_info.c b/src/zwave_ncp_serial_api_controller/app_node_info.c deleted file mode 100644 index c2da5788..00000000 --- a/src/zwave_ncp_serial_api_controller/app_node_info.c +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @file app_node_info.c - * @copyright 2022 Silicon Laboratories Inc. - */ - -#include "app_node_info.h" - -uint8_t aAppNodeInfoCCUnSecureIncluded[APPL_NODEPARM_MAX]; -uint8_t aAppNodeInfoCCSecureIncludedUnSecure[APPL_NODEPARM_MAX]; -uint8_t aAppNodeInfoCCSecureIncludedSecure[APPL_NODEPARM_MAX]; - -SCommandClassSet_t CommandClasses = { - .UnSecureIncludedCC.iListLength = 0, - .UnSecureIncludedCC.pCommandClasses = aAppNodeInfoCCUnSecureIncluded, - .SecureIncludedUnSecureCC.iListLength = 0, - .SecureIncludedUnSecureCC.pCommandClasses = aAppNodeInfoCCSecureIncludedUnSecure, - .SecureIncludedSecureCC.iListLength = 0, - .SecureIncludedSecureCC.pCommandClasses = aAppNodeInfoCCSecureIncludedSecure -}; - -const uint8_t CCListSizes[3] = -{ - sizeof(aAppNodeInfoCCUnSecureIncluded), - sizeof(aAppNodeInfoCCSecureIncludedUnSecure), - sizeof(aAppNodeInfoCCSecureIncludedSecure) -}; diff --git a/src/zwave_ncp_serial_api_controller/app_node_info.h b/src/zwave_ncp_serial_api_controller/app_node_info.h deleted file mode 100644 index b628e38e..00000000 --- a/src/zwave_ncp_serial_api_controller/app_node_info.h +++ /dev/null @@ -1,15 +0,0 @@ -/** - * @file - * @copyright 2022 Silicon Laboratories Inc. - */ - -#ifndef APP_NODE_INFO_H_ -#define APP_NODE_INFO_H_ - -#include "app.h" -#include - -extern SCommandClassSet_t CommandClasses; -extern const uint8_t CCListSizes[3]; - -#endif /* APP_NODE_INFO_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/cmd_get_capabilities.c b/src/zwave_ncp_serial_api_controller/cmd_get_capabilities.c deleted file mode 100644 index 4ce912c9..00000000 --- a/src/zwave_ncp_serial_api_controller/cmd_get_capabilities.c +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @file - * @copyright 2022 Silicon Laboratories Inc. - */ -#include -#include "cmd_handlers.h" -#include "app.h" -#include "zaf_config.h" -#include "zw_version_config.h" - -#define CAPABILITIES_SIZE (8 + 32) // Info + supported commands - -/* Serial API application manufacturer_id */ -#define SERIALAPI_MANUFACTURER_ID1 (uint8_t)((ZAF_CONFIG_MANUFACTURER_ID & 0xFF00) >> 8) /* MSB */ -#define SERIALAPI_MANUFACTURER_ID2 (uint8_t)( ZAF_CONFIG_MANUFACTURER_ID & 0x00FF) /* LSB */ -/* Serial API application manufacturer product type */ -#define SERIALAPI_MANUFACTURER_PRODUCT_TYPE1 (uint8_t)((ZAF_CONFIG_PRODUCT_TYPE_ID & 0xFF00) >> 8) /* MSB */ -#define SERIALAPI_MANUFACTURER_PRODUCT_TYPE2 (uint8_t) (ZAF_CONFIG_PRODUCT_TYPE_ID & 0x00FF) /* LSB */ -/* Serial API application manufacturer product id */ -#define SERIALAPI_MANUFACTURER_PRODUCT_ID1 (uint8_t)((ZAF_CONFIG_PRODUCT_ID & 0xFF00) >> 8) /* MSB */ -#define SERIALAPI_MANUFACTURER_PRODUCT_ID2 (uint8_t) (ZAF_CONFIG_PRODUCT_ID & 0x00FF) /* LSB */ - -static uint8_t SERIALAPI_CAPABILITIES[CAPABILITIES_SIZE] = { - APP_VERSION, - APP_REVISION, - SERIALAPI_MANUFACTURER_ID1, - SERIALAPI_MANUFACTURER_ID2, - SERIALAPI_MANUFACTURER_PRODUCT_TYPE1, - SERIALAPI_MANUFACTURER_PRODUCT_TYPE2, - SERIALAPI_MANUFACTURER_PRODUCT_ID1, - SERIALAPI_MANUFACTURER_PRODUCT_ID2 -}; - -static bool add_cmd_to_capabilities(cmd_handler_map_t const * const p_cmd_entry, cmd_context_t context) -{ - ZW_NodeMaskSetBit(context, p_cmd_entry->cmd); - return false; -} - -ZW_ADD_CMD(FUNC_ID_SERIAL_API_GET_CAPABILITIES) -{ - cmd_foreach(add_cmd_to_capabilities, &SERIALAPI_CAPABILITIES[8]); - /* HOST->ZW: no params defined */ - /* ZW->HOST: RES | 0x07 | */ - /* SERIAL_APPL_VERSION | SERIAL_APPL_REVISION | SERIALAPI_MANUFACTURER_ID1 | SERIALAPI_MANUFACTURER_ID2 | */ - /* SERIALAPI_MANUFACTURER_PRODUCT_TYPE1 | SERIALAPI_MANUFACTURER_PRODUCT_TYPE2 | */ - /* SERIALAPI_MANUFACTURER_PRODUCT_ID1 | SERIALAPI_MANUFACTURER_PRODUCT_ID2 | FUNCID_SUPPORTED_BITMASK[] */ - Respond(frame->cmd, SERIALAPI_CAPABILITIES, sizeof(SERIALAPI_CAPABILITIES)); -} diff --git a/src/zwave_ncp_serial_api_controller/cmd_handlers.c b/src/zwave_ncp_serial_api_controller/cmd_handlers.c deleted file mode 100644 index abd2ec50..00000000 --- a/src/zwave_ncp_serial_api_controller/cmd_handlers.c +++ /dev/null @@ -1,3635 +0,0 @@ -/** - * @file cmd_handlers.c - * @copyright 2022 Silicon Laboratories Inc. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#define DEBUGPRINT -#include - -#include "app_node_info.h" -#include "virtual_slave_node_info.h" -#include "cmd_handlers.h" -#include "cmds_management.h" -#include "cmds_security.h" -#include "cmds_rf.h" -#include "ZW_SerialAPI.h" -#include "app.h" -#include "serialapi_file.h" -#include "utils.h" -#include "nvm_backup_restore.h" -#include "zaf_protocol_config.h" - -#if SUPPORT_ZW_AES_ECB -#include -#endif - -extern bool bTxStatusReportEnabled; - -SSyncEventArg1 LearnModeStatusCb = {.uFunctor.pFunction = 0}; // Ensure function pointer is initialized -SSyncEvent SetDefaultCB = {.uFunctor.pFunction = 0}; // Ensure function pointer is initialized - -#ifdef ZW_CONTROLLER -static uint8_t addState = 0; -uint8_t funcID_ComplHandler_ZW_NodeManagement; -uint8_t nodeManagement_Func_ID; -#endif - - -#ifdef ZW_CONTROLLER -static void SetupNodeManagement(const comm_interface_frame_ptr frame, uint8_t funcID_offet) -{ - nodeManagement_Func_ID = frame->cmd; - funcID_ComplHandler_ZW_NodeManagement = *(frame->payload + funcID_offet); - set_state_and_notify(stateIdle); - addState = 0; -} -#endif - - -#if SUPPORT_ZW_INITIATE_SHUTDOWN -/* - This callback function called from protocol just before going into deep sleep (Deep Sleep) - The function itself sends a respond to the host notifying it that the device is ready to go into deep sleep. -*/ -static void Initiate_shutdown_cb(void) -{ - // 0x1 0x03 0x00 0xd9 - const uint8_t status = 0x01; - comm_interface_transmit_frame(FUNC_ID_ZW_INITIATE_SHUTDOWN, RESPONSE, &status, sizeof(status), NULL); - comm_interface_wait_transmit_done(); -} - -/* - HOST->ZW - ZW-HOST 0x01 -*/ -ZW_ADD_CMD(FUNC_ID_ZW_INITIATE_SHUTDOWN) -{ - AppTimerStopAll(); - if (InitiateShutdown(&Initiate_shutdown_cb)) - { - set_state_and_notify(stateIdle); - } - else - { - // somthing went wrong we failed to start the graceful shutdown - DoRespond(0); - } -} - -#endif - - -#if SUPPORT_FUNC_ID_CLEAR_TX_TIMERS -static void ClearTxTimers(void) -{ - SZwaveCommandPackage CommandPackage = { .eCommandType = EZWAVECOMMANDTYPE_CLEAR_TX_TIMERS }; - - // Put the package on queue (and DO wait for it, since there is no feedback to serial master) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&CommandPackage, 500); - - if (EQUEUENOTIFYING_STATUS_SUCCESS != QueueStatus) - { - DPRINT("Warning: Failed to clear Tx timers"); - } -} - -ZW_ADD_CMD(FUNC_ID_CLEAR_TX_TIMERS) -{ - /* HOST->ZW: */ - ClearTxTimers(); - set_state(stateIdle); -} -#endif /* SUPPORT_FUNC_ID_CLEAR_TX_TIMERS */ - - -#if SUPPORT_FUNC_ID_GET_TX_TIMERS -ZW_ADD_CMD(FUNC_ID_GET_TX_TIMERS) -{ - /* HOST->ZW: */ - /* ZW->HOST: channel0TxTimer_MSB | channel0TxTimer_Next_MSB | channel0TxTimer_Next_LSB | channel0TxTimerLSB | */ - /* channel1TxTimer_MSB | channel1TxTimer_Next_MSB | channel1TxTimer_Next_LSB | channel1TxTimerLSB | */ - /* channel2TxTimer_MSB | channel2TxTimer_Next_MSB | channel2TxTimer_Next_LSB | channel2TxTimerLSB | */ - /* channel3TxTimer_MSB | channel3TxTimer_Next_MSB | channel3TxTimer_Next_LSB | channel3TxTimerLSB | */ - /* channel4TxTimer_MSB | channel4TxTimer_Next_MSB | channel4TxTimer_Next_LSB | channel4TxTimerLSB */ - - // Copy current Network Statistic counters - const zpal_radio_network_stats_t *sRFStats = ZAF_getNetworkStatistics(); - - uint8_t i = 0; - // Copy with endian swap - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel[0] >> 24) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel[0] >> 16) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel[0] >> 8) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel[0] >> 0) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel[1] >> 24) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel[1] >> 16) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel[1] >> 8) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel[1] >> 0) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel[2] >> 24) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel[2] >> 16) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel[2] >> 8) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel[2] >> 0) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel[3] >> 24) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel[3] >> 16) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel[3] >> 8) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel[3] >> 0) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel[4] >> 24) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel[4] >> 16) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel[4] >> 8) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel[4] >> 0) & 0xff); - - DoRespond_workbuf(i); -} -#endif /* SUPPORT_FUNC_ID_GET_TX_TIMERS */ - - -#if SUPPORT_ZW_GET_BACKGROUND_RSSI -static void GetBackgroundRSSI(RSSI_LEVELS *noise_levels) -{ - SZwaveCommandPackage cmdPackage = {.eCommandType = EZWAVECOMMANDTYPE_GET_BACKGROUND_RSSI}; - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 0); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); - SZwaveCommandStatusPackage cmdStatus = { 0 }; - if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_GET_BACKGROUND_RSSI)) - { - memcpy((uint8_t *)noise_levels, cmdStatus.Content.GetBackgroundRssiStatus.rssi, sizeof(RSSI_LEVELS)); - return; - } - ASSERT(false); // FIXME We should have more intelligent error handling, we shouldnt assert here. -} - -ZW_ADD_CMD(FUNC_ID_ZW_GET_BACKGROUND_RSSI) -{ - /* HOST->ZW: (no arguments) */ - /* ZW->HOST: RES | RSSI Ch0 | RSSI Ch1 | RSSI Ch2 */ - GetBackgroundRSSI((RSSI_LEVELS*)&compl_workbuf[0]); - DoRespond_workbuf(sizeof(RSSI_LEVELS)); -} -#endif - - -#if SUPPORT_ZW_CLEAR_NETWORK_STATS -static void ClearNetworkStats(void) -{ - SZwaveCommandPackage CommandPackage = {.eCommandType = EZWAVECOMMANDTYPE_CLEAR_NETWORK_STATISTICS}; - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&CommandPackage, 0); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); -} - -ZW_ADD_CMD(FUNC_ID_ZW_CLEAR_NETWORK_STATS) -{ - /* HOST->ZW: */ - /* ZW->HOST: 0x01 */ - ClearNetworkStats(); - DoRespond(1); -} -#endif /* SUPPORT_ZW_CLEAR_NETWORK_STATS */ - - -#if SUPPORT_ZW_GET_NETWORK_STATS -ZW_ADD_CMD(FUNC_ID_ZW_GET_NETWORK_STATS) -{ - /* HOST->ZW: */ - /* ZW->HOST: wRFTxFrames_MSB | wRFTxFrames_LSB | */ - /* wRFTxLBTBackOffs_MSB | wRFTxLBTBackOffs_LSB | */ - /* wRFRxFrames_MSB | wRFRxFrames_LSB */ - /* wRFRxLRCErrors_MSB | wRFRxLRCErrors_LSB */ - /* wRFRxCRCErrors_MSB | wRFRxCRCErrors_LSB */ - /* wRFRxForeignHomeID_MSB | wRFRxForeignHomeID_LSB */ - - // Copy current Network Statistic counters - const zpal_radio_network_stats_t *sRFStats = ZAF_getNetworkStatistics(); - - int i = 0; - // Copy with endian swap - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_frames >> 8) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_frames >> 0) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_lbt_back_offs >> 8) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->tx_lbt_back_offs >> 0) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->rx_frames >> 8) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->rx_frames >> 0) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->rx_lrc_errors >> 8) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->rx_lrc_errors >> 0) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->rx_crc_errors >> 8) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->rx_crc_errors >> 0) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->rx_foreign_home_id >> 8) & 0xff); - compl_workbuf[i++] = (uint8_t)((sRFStats->rx_foreign_home_id >> 0) & 0xff); - - DoRespond_workbuf((uint8_t)i); -} -#endif /* SUPPORT_ZW_GET_NETWORK_STATS */ - - -#if SUPPORT_ZW_SET_RF_RECEIVE_MODE -uint8_t SetRFReceiveMode(uint8_t mode) -{ - SZwaveCommandPackage pCmdPackage = { - .eCommandType = EZWAVECOMMANDTYPE_SET_RF_RECEIVE_MODE, - .uCommandParams.SetRfReceiveMode.mode = mode}; - - // Put the Command on queue (and dont wait for it, queue must be empty) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&pCmdPackage, 0); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); - SZwaveCommandStatusPackage cmdStatus = { 0 }; - if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_SET_RF_RECEIVE_MODE)) - { - return cmdStatus.Content.SetRFReceiveModeStatus.result; - } - ASSERT(0); - return 0; -} - -ZW_ADD_CMD(FUNC_ID_ZW_SET_RF_RECEIVE_MODE) -{ - /* HOST->ZW: mode */ - /* ZW->HOST: retVal */ - const uint8_t retVal = SetRFReceiveMode(frame->payload[0]); - DoRespond(retVal); -} -#endif /* SUPPORT_ZW_SET_RF_RECEIVE_MODE */ - - -#if SUPPORT_ZW_SEND_NODE_INFORMATION -uint8_t funcID_ComplHandler_ZW_SendNodeInformation; - -static uint8_t SendNodeInformation(uint16_t destID, uint8_t txOptions, ZW_TX_Callback_t pCallBack) -{ - SZwaveTransmitPackage FramePackage = { - .uTransmitParams.NodeInfo.DestNodeId = destID, - .uTransmitParams.NodeInfo.TransmitOptions = txOptions, - .uTransmitParams.NodeInfo.Handle = (ZW_Void_Callback_t)pCallBack, - .eTransmitType = EZWAVETRANSMITTYPE_NODEINFORMATION - }; - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus; - QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); - return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; -} - -/*===================== ComplHandler_ZW_SendNodeInformation ============= -** Completion handler for ZW_SendNodeInformation -** -**--------------------------------------------------------------------------*/ -static void /* RET Nothing */ -ZCB_ComplHandler_ZW_SendNodeInformation( - uint8_t txStatus, /* IN Transmit completion status */ - __attribute__((unused)) TX_STATUS_TYPE *txStatusReport) -{ - BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_SendNodeInformation; - BYTE_IN_AR(compl_workbuf, 1) = txStatus; - Request(FUNC_ID_ZW_SEND_NODE_INFORMATION, compl_workbuf, 2); -} - -ZW_ADD_CMD(FUNC_ID_ZW_SEND_NODE_INFORMATION) -{ - /* HOST->ZW: destNode | txOptions | funcID */ - /* ZW->HOST: retVal */ - uint8_t offset = 0; - node_id_t destNode = (node_id_t)GET_NODEID(&frame->payload[0], offset); - funcID_ComplHandler_ZW_SendNodeInformation = frame->payload[offset + 2]; - const uint8_t retVal = SendNodeInformation(destNode, frame->payload[offset + 1], (frame->payload[offset + 2] != 0) ? &ZCB_ComplHandler_ZW_SendNodeInformation : NULL); - DoRespond(retVal); -} -#endif /* SUPPORT_ZW_SEND_NODE_INFORMATION */ - - -#if SUPPORT_ZW_SECURITY_SETUP -ZW_ADD_CMD(FUNC_ID_ZW_SECURITY_SETUP) -{ - uint8_t length; - func_id_zw_security_setup(frame_payload_len(frame), frame->payload, compl_workbuf, &length); - DoRespond_workbuf(length); -} -#endif - - -#if SUPPORT_ZW_SEND_DATA || SUPPORT_ZW_SEND_DATA_BRIDGE -uint8_t funcID_ComplHandler_ZW_SendData; -#endif - -#if SUPPORT_ZW_SEND_DATA || SUPPORT_ZW_SEND_DATA_EX || SUPPORT_ZW_SEND_DATA_BRIDGE -static void -GenerateTxStatusRequest( - uint8_t cmd, - uint8_t txStatusfuncID, - uint8_t txStatus, - TX_STATUS_TYPE *txStatusReport) /* IN Transmit completion status */ -{ - uint8_t bIdx = 0; - BYTE_IN_AR(compl_workbuf, bIdx++) = txStatusfuncID; - BYTE_IN_AR(compl_workbuf, bIdx++) = txStatus; - if (bTxStatusReportEnabled /* Do HOST want txStatusReport */ - && txStatusReport) /* Check if detailed info is available from protocol */ - { - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)((((txStatusReport->TransmitTicks / 10) & 0xFFFFFF) >> 8) & 0xFF); - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(((txStatusReport->TransmitTicks / 10) & 0xFFFFFF) & 0xFF); - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bRepeaters); - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->rssi_values.incoming[0]); - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->rssi_values.incoming[1]); - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->rssi_values.incoming[2]); - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->rssi_values.incoming[3]); - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->rssi_values.incoming[4]); - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bACKChannelNo); - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bLastTxChannelNo); - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bRouteSchemeState); - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->pLastUsedRoute[0]); - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->pLastUsedRoute[1]); - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->pLastUsedRoute[2]); - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->pLastUsedRoute[3]); - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->pLastUsedRoute[4]); - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bRouteTries); - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bLastFailedLink.from); - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bLastFailedLink.to); - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bUsedTxpower); - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bMeasuredNoiseFloor); - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bDestinationAckUsedTxPower); - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bDestinationAckMeasuredRSSI); - BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bDestinationAckMeasuredNoiseFloor); - } - Request(cmd, compl_workbuf, bIdx); -} -#endif - -#if SUPPORT_ZW_SEND_DATA -/*====================== ComplHandler_ZW_SendData ======================== -** Completion handler for ZW_SendData -** -**--------------------------------------------------------------------------*/ -static void /* RET Nothing */ -ZCB_ComplHandler_ZW_SendData( - uint8_t txStatus, - TX_STATUS_TYPE *txStatusReport) /* IN Transmit completion status */ -{ - GenerateTxStatusRequest(FUNC_ID_ZW_SEND_DATA, funcID_ComplHandler_ZW_SendData, txStatus, txStatusReport); -} - -static uint8_t SendData(uint16_t nodeID, const uint8_t *pData, uint8_t dataLength, uint8_t txOptions, ZW_TX_Callback_t pCallBack) -{ - SZwaveTransmitPackage FramePackage = { 0 }; - -#ifndef ZW_SECURITY_PROTOCOL - SSendData *pSendData = &FramePackage.uTransmitParams.SendData; - memset(&pSendData->FrameConfig.aFrame, 0, sizeof(pSendData->FrameConfig.aFrame)); - pSendData->DestNodeId = nodeID; - pSendData->FrameConfig.TransmitOptions = txOptions; - memcpy(&pSendData->FrameConfig.aFrame, pData, dataLength); - pSendData->FrameConfig.Handle = pCallBack; - FramePackage.eTransmitType = EZWAVETRANSMITTYPE_STD; - pSendData->FrameConfig.iFrameLength = dataLength; - -#else - { - SSendDataEx *pSendDataEx = &FramePackage.uTransmitParams.SendDataEx; - pSendDataEx->DestNodeId = nodeID; - pSendDataEx->FrameConfig.TransmitOptions = txOptions; - memcpy(&pSendDataEx->FrameConfig.aFrame, pData, dataLength); - pSendDataEx->FrameConfig.Handle = pCallBack; - FramePackage.eTransmitType = EZWAVETRANSMITTYPE_EX; - FramePackage.uTransmitParams.SendDataEx.FrameConfig.iFrameLength = dataLength; - } -#endif /* !ZW_SLAVE_ENHANCED_232 */ - - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); - return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_SEND_DATA) -{ - /* HOST->ZW: nodeID | dataLength | pData[] | txOptions | funcID */ - /* ZW->HOST: RetVal */ - /* If RetVal == false -> no callback */ - /* If RetVal == true then callback returns with */ - /* ZW->HOST: funcID | txStatus | wTransmitTicksMSB | wTransmitTicksLSB | bRepeaters | rssi_values.incoming[0] | - * rssi_values.incoming[1] | rssi_values.incoming[2] | rssi_values.incoming[3] | rssi_values.incoming[4] | - * bRouteSchemeState | repeater0 | repeater1 | repeater2 | repeater3 | routespeed | - * bRouteTries | bLastFailedLink.from | bLastFailedLink.to | - * bUsedTxpower | bMeasuredNoiseFloor | bAckDestinationUsedTxPower | bDestinationAckMeasuredRSSI | - * bDestinationckMeasuredNoiseFloor */ - uint8_t offset = 0; - node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); - uint8_t dataLength = frame->payload[offset + 1]; - ASSERT(dataLength <= BUF_SIZE_RX); - if (dataLength > BUF_SIZE_RX) - { - dataLength = BUF_SIZE_RX; - } - - const uint8_t * const pSerInData = frame->payload + offset + 2; - funcID_ComplHandler_ZW_SendData = frame->payload[offset + 3 + dataLength]; - - // Create transmit frame package - const uint8_t retVal = SendData(nodeId, pSerInData, dataLength, frame->payload[offset + 2 + dataLength], - (funcID_ComplHandler_ZW_SendData) ? &ZCB_ComplHandler_ZW_SendData : NULL); - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_SEND_DATA_EX -uint8_t funcID_ComplHandler_ZW_SendDataEx; - -/*====================== ComplHandler_ZW_SendDataEx ======================== -** Completion handler for ZW_SendDataEx -** -**--------------------------------------------------------------------------*/ -static void /* RET Nothing */ -ZCB_ComplHandler_ZW_SendDataEx( - uint8_t txStatus, - TX_STATUS_TYPE *txStatusReport) /* IN Transmit completion status */ -{ - GenerateTxStatusRequest(FUNC_ID_ZW_SEND_DATA_EX, funcID_ComplHandler_ZW_SendDataEx, txStatus, txStatusReport); -} - -static uint8_t SendDataEx(uint16_t nodeID, uint8_t *pData, uint8_t dataLength, - uint8_t txOptions, uint8_t txSecOptions, uint8_t txOptions2, uint8_t secKeyType, - ZW_TX_Callback_t pCallBack) -{ - // Create transmit frame package - SZwaveTransmitPackage FramePackage = { - .uTransmitParams.SendDataEx.DestNodeId = nodeID, - .uTransmitParams.SendDataEx.TransmitSecurityOptions = txSecOptions, - .uTransmitParams.SendDataEx.TransmitOptions2 = txOptions2, - .uTransmitParams.SendDataEx.eKeyType = secKeyType, - .uTransmitParams.SendDataEx.FrameConfig.TransmitOptions = txOptions, - .uTransmitParams.SendDataEx.FrameConfig.Handle = pCallBack, - .uTransmitParams.SendDataEx.FrameConfig.iFrameLength = dataLength, - .eTransmitType = EZWAVETRANSMITTYPE_EX - }; - memcpy(&FramePackage.uTransmitParams.SendDataEx.FrameConfig.aFrame, pData, dataLength); - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); - return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_SEND_DATA_EX) -{ - /* HOST->ZW: nodeID | dataLength | pData[] | txOptions | txSecOptions | securityKey | txOptions2 | funcID */ - /* ZW->HOST: RetVal */ - /* If "RetVal != 1" -> no callback */ - /* If "RetVal == 1" and "funcID != 0" then callback returns with */ - /* ZW->HOST: funcID | txStatus | wTransmitTicksMSB | wTransmitTicksLSB | bRepeaters | rssi_values.incoming[0] | */ - /* rssi_values.incoming[1] | rssi_values.incoming[2] | rssi_values.incoming[3] | rssi_values.incoming[4] | */ - /* bRouteSchemeState | repeater0 | repeater1 | repeater2 | repeater3 | routespeed | */ - /* bRouteTries | bLastFailedLink.from | bLastFailedLink.to */ - uint8_t offset = 0; - node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); - uint8_t dataLength; - - dataLength = frame->payload[offset + 1]; - ASSERT(dataLength <= BUF_SIZE_RX); - if (dataLength > BUF_SIZE_RX) - { - dataLength = BUF_SIZE_RX; - } - funcID_ComplHandler_ZW_SendDataEx = frame->payload[offset + 6 + dataLength]; - - const uint8_t retVal = SendDataEx(nodeId, &frame->payload[offset + 2], dataLength, frame->payload[offset + 2 + dataLength], - frame->payload[offset + 3 + dataLength], frame->payload[offset + 5 + dataLength], - frame->payload[offset + 4 + dataLength], (funcID_ComplHandler_ZW_SendDataEx != 0) ? ZCB_ComplHandler_ZW_SendDataEx : NULL); - - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_SEND_DATA_MULTI || SUPPORT_ZW_SEND_DATA_MULTI_BRIDGE -uint8_t funcID_ComplHandler_ZW_SendDataMulti; -#endif - -#if SUPPORT_ZW_SEND_DATA_MULTI -/*===================== ComplHandler_ZW_SendDataMulti ==================== -** Completion handler for ZW_SendDataMulti -** -**--------------------------------------------------------------------------*/ -static void /* RET Nothing */ -ZCB_ComplHandler_ZW_SendDataMulti( - uint8_t txStatus, - __attribute__((unused)) TX_STATUS_TYPE *txStatusType) /* IN Transmit completion status */ -{ - BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_SendDataMulti; - BYTE_IN_AR(compl_workbuf, 1) = txStatus; - Request(FUNC_ID_ZW_SEND_DATA_MULTI, compl_workbuf, 2); -} - -static uint8_t SendDataMulti(uint8_t numberOfNodes, const uint8_t *pNodeList, const uint8_t *pData, uint8_t dataLength, uint8_t txOptions, ZW_TX_Callback_t pCallBack) -{ - // Create transmit frame package - SZwaveTransmitPackage FramePackage; - SSendDataMulti *pSendDataMulti = &FramePackage.uTransmitParams.SendDataMulti; - memset(&pSendDataMulti->FrameConfig.aFrame, 0, sizeof(pSendDataMulti->FrameConfig.aFrame)); - /* clear the destination node mask */ - memset(&pSendDataMulti->NodeMask, 0, sizeof(pSendDataMulti->NodeMask)); - /* Set the destination node mask bits */ - for (uint8_t i = 0; i < numberOfNodes && i < MAX_GROUP_NODES; i++) - { - ZW_NodeMaskSetBit(pSendDataMulti->NodeMask, pNodeList[i]); - } - pSendDataMulti->FrameConfig.TransmitOptions = txOptions; - ASSERT(dataLength <= BUF_SIZE_RX); - if (dataLength > BUF_SIZE_RX) - { - dataLength = BUF_SIZE_RX; - } - memcpy(&pSendDataMulti->FrameConfig.aFrame, pData, dataLength); - pSendDataMulti->FrameConfig.Handle = pCallBack; - FramePackage.eTransmitType = EZWAVETRANSMITTYPE_MULTI; - FramePackage.uTransmitParams.SendDataMulti.FrameConfig.iFrameLength = dataLength; - - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); - return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_SEND_DATA_MULTI) -{ - /* numberNodes | pNodeIDList[] | dataLength | pData[] | txOptions | funcId */ - // Create transmit frame package - uint8_t numOfNodes = frame->payload[0]; - uint8_t tLength = frame->payload[1 + numOfNodes]; - uint8_t tOptions = frame->payload[2 + numOfNodes + tLength]; - funcID_ComplHandler_ZW_SendDataMulti = frame->payload[3 + numOfNodes + tLength]; - - const uint8_t retVal = SendDataMulti(numOfNodes, &frame->payload[1], &frame->payload[2 + numOfNodes], tLength, tOptions, - (funcID_ComplHandler_ZW_SendDataMulti != 0) ? &ZCB_ComplHandler_ZW_SendDataMulti : NULL); - - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_SEND_DATA_MULTI_EX -uint8_t funcID_ComplHandler_ZW_SendDataMultiEx; - -/*===================== ComplHandler_ZW_SendDataMulti ==================== -** Completion handler for ZW_SendDataMulti -** -**--------------------------------------------------------------------------*/ -static void -ZCB_ComplHandler_ZW_SendDataMultiEx( - uint8_t txStatus, /* IN Transmit completion status */ - __attribute__((unused)) TX_STATUS_TYPE* extendedTxStatus) -{ - BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_SendDataMultiEx; - BYTE_IN_AR(compl_workbuf, 1) = txStatus; - Request(FUNC_ID_ZW_SEND_DATA_MULTI_EX, compl_workbuf, 2); -} - -static uint8_t SendDataMultiEx(uint8_t dataLength, uint8_t *pData, uint8_t txOptions, uint8_t secKeyType, uint8_t groupID, ZW_TX_Callback_t pCallBack) -{ - ASSERT(dataLength <= BUF_SIZE_RX); - if (dataLength > BUF_SIZE_RX) - { - dataLength = BUF_SIZE_RX; - } - // Create transmit frame package - SZwaveTransmitPackage FramePackage = { - .uTransmitParams.SendDataMultiEx.FrameConfig.Handle = pCallBack, - .uTransmitParams.SendDataMultiEx.FrameConfig.TransmitOptions = txOptions, - .uTransmitParams.SendDataMultiEx.FrameConfig.iFrameLength = dataLength, - .uTransmitParams.SendDataMultiEx.GroupId = groupID, - .uTransmitParams.SendDataMultiEx.eKeyType = secKeyType, - .eTransmitType = EZWAVETRANSMITTYPE_MULTI_EX - }; - memcpy(&FramePackage.uTransmitParams.SendDataMultiEx.FrameConfig.aFrame, pData, dataLength); - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); - return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_SEND_DATA_MULTI_EX) -{ - /* dataLength | pData[] | txOptions | securityKey | groupId | funcId */ - uint8_t dataLength = frame->payload[0]; - funcID_ComplHandler_ZW_SendDataMultiEx = frame->payload[4 + dataLength]; - uint8_t tOptions = frame->payload[1 + dataLength]; - uint8_t tGID = frame->payload[3 + dataLength]; - uint8_t tKey = frame->payload[2 + dataLength]; - - const uint8_t retVal = SendDataMultiEx(dataLength, &frame->payload[1], tOptions, tKey, tGID, (funcID_ComplHandler_ZW_SendDataMultiEx != 0) ? ZCB_ComplHandler_ZW_SendDataMultiEx : NULL); - - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_SEND_DATA_ABORT -static void SendDataAbort(void) -{ - // FIXME - we need to change the implementation of abort - // What makes sense? aborting based on frame context? - // We cant peek into FreeRtos queue... - // We could also reset the queue on abort. and stop any ongoing frame. - SZwaveCommandPackage CommandPackage = { .eCommandType = EZWAVECOMMANDTYPE_SEND_DATA_ABORT }; - // Put the package on queue (and DO wait for it, since there is no feedback to serial master) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&CommandPackage, 500); - - if (EQUEUENOTIFYING_STATUS_SUCCESS != QueueStatus) - { - DPRINT("Warning: Failed to To call ZW_SendDataAbort"); - } -} - -ZW_ADD_CMD(FUNC_ID_ZW_SEND_DATA_ABORT) -{ - /* If we are in middle of transmitting an application frame then STOP the transmission as soon as possible. */ - SendDataAbort(); - set_state_and_notify(stateIdle); -} -#endif - - -#if SUPPORT_ZW_SEND_DATA_BRIDGE -/*================= ComplHandler_ZW_SendData_Bridge ====================== -** Completion handler for ZW_SendData_Bridge -** -**--------------------------------------------------------------------------*/ -static void /* RET Nothing */ -ZCB_ComplHandler_ZW_SendData_Bridge( - uint8_t txStatus, - TX_STATUS_TYPE *txStatusReport) /* IN Transmit completion status */ -{ - GenerateTxStatusRequest(FUNC_ID_ZW_SEND_DATA_BRIDGE, funcID_ComplHandler_ZW_SendData, txStatus, txStatusReport); -} - -static uint8_t SendDataBridge(uint16_t srcNode, uint16_t destNode, uint8_t dataLength, const uint8_t *pData, uint8_t txOptions, ZW_TX_Callback_t pCallBack) -{ - ASSERT(dataLength <= BUF_SIZE_RX); - if (dataLength > BUF_SIZE_RX) - { - dataLength = BUF_SIZE_RX; - } - // Create transmit frame package - SZwaveTransmitPackage FramePackage = { - .uTransmitParams.SendDataBridge.FrameConfig.Handle = pCallBack, - .uTransmitParams.SendDataBridge.FrameConfig.TransmitOptions = txOptions, - .uTransmitParams.SendDataBridge.FrameConfig.iFrameLength = dataLength, - .uTransmitParams.SendDataBridge.DestNodeId = destNode, - .uTransmitParams.SendDataBridge.SourceNodeId = srcNode, - .eTransmitType = EZWAVETRANSMITTYPE_BRIDGE - }; - memcpy(&FramePackage.uTransmitParams.SendDataBridge.FrameConfig.aFrame, pData, dataLength); - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); - return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_SEND_DATA_BRIDGE) -{ - /* HOST->ZW: srcNodeID | destNodeID | dataLength | pData[] | txOptions | pRoute[4] | funcID */ - /* Devkit 6.0x pRoute[4] not used... Use [0,0,0,0] */ - uint8_t offset = 0; - node_id_t sourceNodeId; - node_id_t destNodeId; - sourceNodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); - destNodeId = (node_id_t)GET_NODEID(&frame->payload[1 + offset], offset); - uint8_t dataLength = frame->payload[offset + 2]; - funcID_ComplHandler_ZW_SendData = frame->payload[offset + 3 + 1 + 4 + dataLength]; - uint8_t tOptions = frame->payload[offset + 3 + dataLength]; - const uint8_t retVal = SendDataBridge(sourceNodeId, destNodeId, dataLength, &frame->payload[offset + 3], tOptions, - (funcID_ComplHandler_ZW_SendData != 0) ? &ZCB_ComplHandler_ZW_SendData_Bridge : NULL); - - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_SEND_DATA_MULTI_BRIDGE -/*================ ComplHandler_ZW_SendDataMulti_Bridge ================== -** Completion handler for ZW_SendDataMulti -** -**--------------------------------------------------------------------------*/ -static void /* RET Nothing */ -ZCB_ComplHandler_ZW_SendDataMulti_Bridge( - uint8_t txStatus, /* IN Transmit completion status */ - __attribute__((unused)) TX_STATUS_TYPE* extendedTxStatus) -{ - BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_SendDataMulti; - BYTE_IN_AR(compl_workbuf, 1) = txStatus; - Request(FUNC_ID_ZW_SEND_DATA_MULTI_BRIDGE, compl_workbuf, 2); -} - -static uint8_t SendDataMultiBridge(node_id_t srcNode, uint8_t numOfNodes, uint8_t *pNodeIDList, - uint8_t dataLength, const uint8_t *pData, uint8_t txOptions, ZW_TX_Callback_t pCallBack) -{ - // when nodeIdBaseType is 2 then we handle the FramePackage.uTransmitParams.SendDataMultiBridge.NodeMask as node list - // when nodeIdBaseType is 1 then we handle the FramePackage.uTransmitParams.SendDataMultiBridge.NodeMask as node mask - // Create transmit frame package - ASSERT(dataLength <= BUF_SIZE_RX); - - SZwaveTransmitPackage FramePackage = { - .uTransmitParams.SendDataMultiBridge.FrameConfig.Handle = pCallBack, - .uTransmitParams.SendDataMultiBridge.FrameConfig.TransmitOptions = txOptions, - .uTransmitParams.SendDataMultiBridge.FrameConfig.iFrameLength = dataLength, - .uTransmitParams.SendDataMultiBridge.SourceNodeId = srcNode, - .eTransmitType = EZWAVETRANSMITTYPE_MULTI_BRIDGE - }; - - memcpy(&FramePackage.uTransmitParams.SendDataMultiBridge.FrameConfig.aFrame, pData, dataLength); - - bool lr_list = false; - bool classic_list = false; - - if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) { - /*if nodeIdBaseType 2 then we should check if the list contain lr only nodes or classic only nodes mixed list is not allowed*/ - if ((MULTICAST_NODE_LIST_SIZE>>1) < numOfNodes) { - /*maximum allowed nodes are 32 */ - numOfNodes = MULTICAST_NODE_LIST_SIZE>>1; - } - for (uint8_t i = 0; i < numOfNodes; i++) - { - node_id_t curNode = (node_id_t) (((node_id_t)pNodeIDList[i<<1] << 8) | // index = i *2 - (pNodeIDList[(i<<1) +1] & 0xFF)); // index = (i *2) +1 - - if ((LOWEST_LONG_RANGE_NODE_ID <= curNode) && (HIGHEST_LONG_RANGE_NODE_ID >= curNode)) { - lr_list = true; - } else { - classic_list = true; - } - if (lr_list && classic_list) { - /* mixed list we bail out*/ - return false; - } - } - if (lr_list) { - /*lr nodes are 16-bit and the list is in bytes then we copy 2 * numOfNodes*/ - memcpy(FramePackage.uTransmitParams.SendDataMultiBridge.NodeMask, pNodeIDList , numOfNodes * 2); - } - } else { - classic_list = true; - if (MAX_GROUP_NODES < numOfNodes) { - numOfNodes = MAX_GROUP_NODES; - } - } - - FramePackage.uTransmitParams.SendDataMultiBridge.lr_nodeid_list = lr_list; - if (classic_list) { - uint8_t tmpNode; - for (uint8_t i = 0; i < numOfNodes; i++) - { - // if the list of classic nodes then the node ID is located in the lsb bytes of the 16-bit nodeID list. - if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) { - tmpNode = pNodeIDList[(i<<1) +1]; - } else { - /* Set the destination node mask bits */ - tmpNode = pNodeIDList[i]; - } - ZW_NodeMaskSetBit(FramePackage.uTransmitParams.SendDataMultiBridge.NodeMask, tmpNode); - } - } - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); - return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_SEND_DATA_MULTI_BRIDGE) -{ - /* HOST->ZW: srcNodeID | numberNodes | pNodeIDList[] | dataLength | pData[] | txOptions | funcId */ - uint8_t numberNodes; - uint8_t dataLength; - uint8_t txOptions; - uint8_t offset = 0; - node_id_t srcNodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); - uint8_t nodeid_list_size; - - numberNodes = frame->payload[offset + 1]; - uint8_t *pNodeList = &frame->payload[offset + 2]; - - if (nodeIdBaseType == SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT) { - nodeid_list_size = numberNodes * 2; - } else { - nodeid_list_size = numberNodes; - } - - dataLength = frame->payload[offset + 2 + nodeid_list_size]; - txOptions = frame->payload[offset + 2 + 1 + nodeid_list_size + dataLength]; - funcID_ComplHandler_ZW_SendDataMulti = frame->payload[offset + 2 + 1 + 1 + nodeid_list_size + dataLength]; - uint8_t *pDataBuf = &frame->payload[offset + 3 + nodeid_list_size]; - - const uint8_t retVal = SendDataMultiBridge(srcNodeId, numberNodes, pNodeList, - dataLength, pDataBuf, txOptions, - (funcID_ComplHandler_ZW_SendDataMulti != 0) ? &ZCB_ComplHandler_ZW_SendDataMulti_Bridge : NULL); - - DoRespond(retVal); -} -#endif - - -#if SUPPORT_MEMORY_GET_ID -ZW_ADD_CMD(FUNC_ID_MEMORY_GET_ID) -{ - uint8_t i = 0; - node_id_t node_id; - uint32_t home_id; - - node_id = ZAF_GetNodeID(); - home_id = ZAF_GetHomeID(); - - /* */ - compl_workbuf[i++] = (uint8_t) ((home_id & 0xff000000) >> 24); - compl_workbuf[i++] = (uint8_t) ((home_id & 0x00ff0000) >> 16); - compl_workbuf[i++] = (uint8_t) ((home_id & 0x0000ff00) >> 8); - compl_workbuf[i++] = (uint8_t) (home_id & 0x000000ff); - if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) - { - // 16 bit nodeID - compl_workbuf[i++] = (uint8_t)(node_id >> 8); // MSB(16bit) - } - compl_workbuf[i++] = (uint8_t)(node_id & 0xFF); // LSB(16bit)/8bit - DoRespond_workbuf(i); -} -#endif - - -#if SUPPORT_MEMORY_GET_BYTE -ZW_ADD_CMD(FUNC_ID_MEMORY_GET_BYTE) -{ - /* offset (MSB) | offset (LSB) */ - uint8_t retVal = 0; - if ((FRAME_LENGTH_MIN + 2) < frame->len) - { - uint16_t offset = ((uint16_t)(frame->payload[0] << 8)) + frame->payload[1]; - if (! SerialApiNvmReadAppData(offset, &retVal, 1)) - { - retVal = 0; - } - } - DoRespond(retVal); -} -#endif - - -#if SUPPORT_MEMORY_PUT_BYTE -ZW_ADD_CMD(FUNC_ID_MEMORY_PUT_BYTE) -{ - uint8_t retVal = 0; - if ((FRAME_LENGTH_MIN + 3) < frame->len) - { - uint16_t offset = ((uint16_t)(frame->payload[0] << 8)) + frame->payload[1]; - retVal = SerialApiNvmWriteAppData(offset, &frame->payload[2], 1); - } - DoRespond(retVal); -} -#endif - - -#if SUPPORT_MEMORY_GET_BUFFER -ZW_ADD_CMD(FUNC_ID_MEMORY_GET_BUFFER) -{ - uint8_t dataLength = 0; - dataLength = frame->payload[2]; - /* Make sure the length isn't larger than the available buffer size */ - if (dataLength > (uint8_t)BUF_SIZE_TX) - { - dataLength = (uint8_t)BUF_SIZE_TX; - } - uint16_t offset = ((uint16_t)(frame->payload[0] << 8)) + frame->payload[1]; - if (!SerialApiNvmReadAppData(offset, compl_workbuf, dataLength)) - { - dataLength = 0; - } - DoRespond_workbuf(dataLength); -} -#endif - - -#if SUPPORT_MEMORY_PUT_BUFFER -uint8_t funcID_ComplHandler_MemoryPutBuffer; - -/*===================== ComplHandler_MemoryPutBuffer ============= -** Completion handler for MemoryPutBuffer -** -**--------------------------------------------------------------------------*/ -static void /* RET Nothing */ -ZCB_ComplHandler_MemoryPutBuffer(void) /* IN Nothing */ -{ - BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_MemoryPutBuffer; - Request(FUNC_ID_MEMORY_PUT_BUFFER, compl_workbuf, 1); -} - -ZW_ADD_CMD(FUNC_ID_MEMORY_PUT_BUFFER) -{ - /* HOST->ZW: - offset(MSB) offset into host application NVM memory array - offset(LSB) - length(MSB) desired length of write operation - length(LSB) - buffer[] buffer - funcID - */ - /* ZW->HOST: - retVal [retVal=0 ==> error| - retVal=1 ==> OK (NVM no change)| - retVal>=2 ==> OK (NVM data bytes written + 1)] - */ - uint16_t length; - uint8_t retVal = 0; - ///* Ignore if frame has no data to write */ - length = ((uint16_t)(frame->payload[2] << 8)) + frame->payload[3]; - /* Ignore write if length exceeds specified data-array */ - if (length < BUF_SIZE_RX ) - { - /* ignore request if length is larger than available buffer */ - if (length < BUF_SIZE_RX) - { - const uint8_t * const pSerInData = frame->payload + 4; - uint16_t offset = ((uint16_t)(frame->payload[0] << 8)) + frame->payload[1]; - retVal = SerialApiNvmWriteAppData(offset, pSerInData, length); - } - } - DoRespond(retVal); - funcID_ComplHandler_MemoryPutBuffer = frame->payload[4 + length]; - if ((0 != retVal) && (0 != funcID_ComplHandler_MemoryPutBuffer) ) - { - ZCB_ComplHandler_MemoryPutBuffer(); - } -} -#endif - - -#if SUPPORT_NVM_BACKUP_RESTORE -ZW_ADD_CMD(FUNC_ID_NVM_BACKUP_RESTORE) -{ - uint8_t length = 0; - func_id_serial_api_nvm_backup_restore(frame_payload_len(frame), frame->payload, compl_workbuf, &length); - DoRespond_workbuf(length); -} -#endif - - -#if SUPPORT_NVM_GET_ID -ZW_ADD_CMD(FUNC_ID_NVM_GET_ID) -{ -} -#endif - - -#if SUPPORT_NVM_EXT_READ_LONG_BYTE -ZW_ADD_CMD(FUNC_ID_NVM_EXT_READ_LONG_BYTE) -{ - /* HOST->ZW: offset3byte(MSB) | offset3byte | offset3byte(LSB) */ - /* ZW->HOST: dataread */ - uint8_t retVal = 0; - if ((FRAME_LENGTH_MIN + 2) < frame->len) - { - uint32_t offset = (((uint32_t)frame->payload[0] << 16) + ((uint32_t)((uint16_t)frame->payload[1] << 8)) + frame->payload[2]); - if (! SerialApiNvmReadAppData(offset, &retVal, 1)) - { - retVal = 0; - } - } - DoRespond(retVal); -} -#endif - - -#if SUPPORT_NVM_EXT_WRITE_LONG_BYTE -ZW_ADD_CMD(FUNC_ID_NVM_EXT_WRITE_LONG_BYTE) -{ - /* HOST->ZW: offset3byte(MSB) | offset3byte | offset3byte(LSB) | data */ - /* ZW->HOST: writestatus */ - uint8_t retVal = 0; - if ((FRAME_LENGTH_MIN + 3) < frame->len) - { - uint32_t offset = (((uint32_t)frame->payload[0] << 16) + ((uint32_t)((uint16_t)frame->payload[1] << 8)) + frame->payload[2]); - const uint8_t retVal = SerialApiNvmWriteAppData(offset, &frame->payload[3], 1); - } - DoRespond(retVal); -} -#endif - - -#if SUPPORT_NVM_EXT_READ_LONG_BUFFER -ZW_ADD_CMD(FUNC_ID_NVM_EXT_READ_LONG_BUFFER) -{ - /* HOST->ZW: offset3byte(MSB) | offset3byte | offset3byte(LSB) | length2byte(MSB) | length2byte(LSB) */ - /* ZW->HOST: data[] */ - uint16_t dataLength = 0; - ///* Ignore if frame is to short */ - if ((FRAME_LENGTH_MIN + 3 + 1) < frame->len) - { - dataLength = ((uint16_t)(frame->payload[3] << 8)) + frame->payload[4]; - /* Make sure the length isn't larger than the available buffer size */ - if (dataLength > (uint8_t)BUF_SIZE_TX) - { - dataLength = (uint8_t)BUF_SIZE_TX; - } - uint32_t offset = (((uint32_t)frame->payload[0] << 16) + ((uint32_t)((uint16_t)frame->payload[1] << 8)) + frame->payload[2]); - if (!SerialApiNvmReadAppData(offset, compl_workbuf, dataLength)) - { - dataLength = 0; - } - } - DoRespond_workbuf((uint8_t)dataLength); -} -#endif - - -#if SUPPORT_NVM_EXT_WRITE_LONG_BUFFER -ZW_ADD_CMD(FUNC_ID_NVM_EXT_WRITE_LONG_BUFFER) -{ - /* HOST->ZW: offset3byte(MSB) | offset3byte | offset2byte(LSB) | length2byte(MSB) | length2byte(LSB) | buffer[] */ - /* ZW->HOST: retVal */ - uint16_t length; - uint8_t retVal = 0; - ///* Ignore if frame has no data to write */ - if ((FRAME_LENGTH_MIN + 5) < frame->len) - { - length = ((uint16_t)(frame->payload[3] << 8)) + frame->payload[4]; - /* Ignore write if length exceeds specified data-array */ - if (length <= frame->len - FRAME_LENGTH_MIN) - { - /* ignore request if length is larger than available buffer */ - if (length < BUF_SIZE_RX) - { - const uint8_t * const pSerInData = frame->payload + 5; - uint32_t offset = (((uint32_t)frame->payload[0] << 16) + ((uint32_t)((uint16_t)frame->payload[1] << 8)) + frame->payload[2]); - const uint8_t retVal = SerialApiNvmWriteAppData(offset, pSerInData, length); - } - } - } - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_NVR_GET_VALUE -ZW_ADD_CMD(FUNC_ID_NVR_GET_VALUE) -{ - /* HOST->ZW: offset | length */ - /* ZW->HOST: NVRdata[] */ - uint8_t dataLength = 0; - /* Ignore if frame is too short */ - if ((FRAME_LENGTH_MIN + 1) < frame->len) - { - /*inputLength paramter is nout used*/ - func_id_serial_api_get_nvr(0, frame->payload, compl_workbuf, &dataLength); - } - DoRespond_workbuf(dataLength); -} -#endif - - -#if SUPPORT_SERIAL_API_GET_APPL_HOST_MEMORY_OFFSET -ZW_ADD_CMD(FUNC_ID_SERIAL_API_GET_APPL_HOST_MEMORY_OFFSET) -{ - DoRespond(0); -} -#endif - - -#if defined(ZW_SLAVE_ROUTING) || defined(ZW_CONTROLLER) -uint8_t funcID_ComplHandler_netWork_Management; -uint8_t management_Func_ID; - -/*===================== ComplHandler_ZW_netWork_Management =============== -** Completion handler for the network management functionality -** -**--------------------------------------------------------------------------*/ -static void /* RET Nothing */ -ZCB_ComplHandler_ZW_netWork_Management( - uint8_t bStatus, /* IN Transmit completion status */ - TX_STATUS_TYPE *txStatusReport) /* IN Detailed transmit information */ -{ - uint8_t bIdx = 0; - BYTE_IN_AR(compl_workbuf, bIdx++) = funcID_ComplHandler_netWork_Management; - BYTE_IN_AR(compl_workbuf, bIdx++) = bStatus; - if (bTxStatusReportEnabled && txStatusReport) /* Check if detailed info is available from protocol */ - { - memcpy(&compl_workbuf[bIdx], (uint8_t *)txStatusReport, sizeof(TX_STATUS_TYPE)); - bIdx += sizeof(TX_STATUS_TYPE); - } - Request(management_Func_ID, compl_workbuf, bIdx); -} -#endif /*ZW_SLAVE_32 ZW_CONTROLLER*/ - - -#if SUPPORT_ZW_REQUEST_NETWORK_UPDATE -static uint8_t RequestNetworkUpdate(ZW_TX_Callback_t pCallBack) -{ - // Create transmit frame package - SZwaveTransmitPackage FramePackage = { - .eTransmitType = EZWAVETRANSMITTYPE_NETWORKUPDATEREQUEST, - .uTransmitParams.NetworkUpdateRequest.Handle = (ZW_Void_Callback_t)pCallBack - }; - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); - return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_REQUEST_NETWORK_UPDATE) -{ - /* funcID */ - funcID_ComplHandler_netWork_Management = frame->payload[0]; - management_Func_ID = frame->cmd; - const uint8_t retVal = RequestNetworkUpdate((frame->payload[0] != 0) ? &ZCB_ComplHandler_ZW_netWork_Management : NULL); - DoRespond(retVal); -} -#endif /* SUPPORT_ZW_REQUEST_NETWORK_UPDATE */ - - -#if SUPPORT_ZW_REQUEST_NODE_NEIGHBOR_UPDATE -uint8_t funcID_ComplHandler_ZW_RequestNodeNeighborUpdate; - -/*=============== ComplHandler_ZW_RequestNodeNeighborUpdate =============== -** Completion handler for ZW_REQUEST_NODE_NEIGHBOR_UPDATE -** -**--------------------------------------------------------------------------*/ -static void /* RET Nothing */ -ZCB_ComplHandler_ZW_RequestNodeNeighborUpdate( - uint8_t txStatus, /* IN Transmit completion status */ - __attribute__((unused)) TX_STATUS_TYPE *txStatusReport) -{ - BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_RequestNodeNeighborUpdate; - BYTE_IN_AR(compl_workbuf, 1) = txStatus; - Request(FUNC_ID_ZW_REQUEST_NODE_NEIGHBOR_UPDATE, compl_workbuf, 2); -} - -static uint8_t RequestNodeNeighborUpdate(uint16_t nodeID, ZW_TX_Callback_t pCallBack) -{ - - SZwaveCommandPackage Request = { - .eCommandType = EZWAVECOMMANDTYPE_REQUESTNODENEIGHBORUPDATE, - .uCommandParams.RequestNodeNeighborUpdate.NodeId = nodeID, - .uCommandParams.RequestNodeNeighborUpdate.Handle = (ZW_Void_Callback_t)pCallBack}; - - // Put the Command on queue (and dont wait for it, queue must be empty) - if (EQUEUENOTIFYING_STATUS_SUCCESS == QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&Request, 0)) - { - // Wait for protocol to handle command - SZwaveCommandStatusPackage status = { 0 }; - if (GetCommandResponse(&status, EZWAVECOMMANDSTATUS_ZW_REQUESTNODENEIGHBORUPDATE)) - { - return status.Content.RequestNodeNeigborUpdateStatus.result; - } - } - return false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_REQUEST_NODE_NEIGHBOR_UPDATE) -{ - uint8_t offset = 0; - node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); - - funcID_ComplHandler_ZW_RequestNodeNeighborUpdate = frame->payload[1 + offset]; - - // Put the package on queue (and dont wait for it) - if (!RequestNodeNeighborUpdate(nodeId, - funcID_ComplHandler_ZW_RequestNodeNeighborUpdate ? &ZCB_ComplHandler_ZW_RequestNodeNeighborUpdate : NULL)) - { - ZCB_ComplHandler_ZW_RequestNodeNeighborUpdate(REQUEST_NEIGHBOR_UPDATE_FAILED, NULL); - } - set_state_and_notify(stateIdle); -} - -uint8_t funcID_ComplHandler_ZW_RequestNodeTypeNeighborUpdate; - -/*=============== ComplHandler_ZW_RequestNodeTypeNeighborUpdate =============== -** Completion handler for ZW_REQUEST_NODE_NEIGHBOR_UPDATE -** -**--------------------------------------------------------------------------*/ -static void /* RET Nothing */ -ZCB_ComplHandler_ZW_RequestNodeTypeNeighborUpdate( - uint8_t txStatus, /* IN Transmit completion status */ - __attribute__((unused)) TX_STATUS_TYPE *txStatusReport) -{ - BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_RequestNodeTypeNeighborUpdate; - BYTE_IN_AR(compl_workbuf, 1) = txStatus; - Request(FUNC_ID_ZW_REQUEST_NODETYPE_NEIGHBOR_UPDATE, compl_workbuf, 2); -} - -static uint8_t RequestNodeTypeNeighborUpdate(uint16_t nodeID, uint8_t nodeType, ZW_TX_Callback_t pCallBack) -{ - - SZwaveCommandPackage Request = { - .eCommandType = EZWAVECOMMANDTYPE_REQUESTNODETYPE_NEIGHBORUPDATE, - .uCommandParams.RequestNodeTypeNeighborUpdate.NodeId = nodeID, - .uCommandParams.RequestNodeTypeNeighborUpdate.NodeType = nodeType, - .uCommandParams.RequestNodeTypeNeighborUpdate.Handle = (ZW_Void_Callback_t)pCallBack}; - - // Put the Command on queue (and dont wait for it, queue must be empty) - if (EQUEUENOTIFYING_STATUS_SUCCESS == QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&Request, 0)) - { - // Wait for protocol to handle command - SZwaveCommandStatusPackage status = { 0 }; - if (GetCommandResponse(&status, EZWAVECOMMANDSTATUS_ZW_REQUESTNODETYPE_NEIGHBORUPDATE)) - { - return status.Content.RequestNodeTypeNeigborUpdateStatus.result; - } - } - return false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_REQUEST_NODETYPE_NEIGHBOR_UPDATE) -{ - uint8_t offset = 0; - E_SYSTEM_TYPE nodeType = 0; - node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); - nodeType = frame->payload[1 + offset]; - ++offset; - - funcID_ComplHandler_ZW_RequestNodeTypeNeighborUpdate = frame->payload[1 + offset]; - - // Put the package on queue (and dont wait for it) - if (!RequestNodeTypeNeighborUpdate(nodeId, nodeType, - funcID_ComplHandler_ZW_RequestNodeTypeNeighborUpdate ? &ZCB_ComplHandler_ZW_RequestNodeTypeNeighborUpdate : NULL)) - { - ZCB_ComplHandler_ZW_RequestNodeTypeNeighborUpdate(REQUEST_NEIGHBOR_UPDATE_FAILED, NULL); - } - set_state_and_notify(stateIdle); -} -#endif - - -#if SUPPORT_ZW_GET_NODE_PROTOCOL_INFO -ZW_ADD_CMD(FUNC_ID_ZW_GET_NODE_PROTOCOL_INFO) -{ - /* bNodeID */ - volatile uint8_t offset = 0; - node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); - GetNodeInfo(nodeId, (t_ExtNodeInfo *)compl_workbuf); - STATIC_ASSERT(sizeof(t_ExtNodeInfo) == 7, STATIC_ASSERT_FAILED_size_mismatch); - DoRespond_workbuf(7); -} -#endif - - -#if SUPPORT_ZW_SET_DEFAULT -uint8_t funcID_ComplHandler_ZW_SetDefault; - -/*===================== ComplHandler_ZW_SetDefault ============= -** Completion handler for ZW_SetDefault -** -**--------------------------------------------------------------------------*/ -static void /* RET Nothing */ -ZCB_ComplHandler_ZW_SetDefault(void) /* IN Nothing */ -{ - BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_SetDefault; - Request(FUNC_ID_ZW_SET_DEFAULT, compl_workbuf, 1); -} - -static void SetDefault(ZW_Void_Callback_t pCallBack) -{ - /* funcID */ - SyncEventUnbind(&SetDefaultCB); - if (0 != pCallBack) - { - SyncEventBind(&SetDefaultCB, pCallBack); - } - SZwaveCommandPackage CommandPackage = { .eCommandType = EZWAVECOMMANDTYPE_SET_DEFAULT }; - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&CommandPackage, 500); - if (EQUEUENOTIFYING_STATUS_SUCCESS != QueueStatus) - { - DPRINT("Warning: Failed to perform SetDefault"); - } -} - -ZW_ADD_CMD(FUNC_ID_ZW_SET_DEFAULT) -{ - /* funcID */ - funcID_ComplHandler_ZW_SetDefault = frame->payload[0]; - SetDefault((0 != funcID_ComplHandler_ZW_SetDefault) ? &ZCB_ComplHandler_ZW_SetDefault : NULL); - set_state_and_notify(stateIdle); -} -#endif - -#ifdef ZW_CONTROLLER -/*======================= ComplHandler_ZW_NodeManagement ================= -** Completion handler for ZW_AddNodeToNetwork, ZW_RemoveNodeFromNetwork -** ZW_CreateNewPrimary, ZW_ControllerChange and ZW_SetLearnMode for -** controller based applications -** -**--------------------------------------------------------------------------*/ - -void /* RET Nothing */ -ZCB_ComplHandler_ZW_NodeManagement( - LEARN_INFO_T *statusInfo) -{ - if (0 == funcID_ComplHandler_ZW_NodeManagement) - { - return; - } - - uint8_t offset = 0; - addState = (*statusInfo).bStatus; - BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_NodeManagement; - BYTE_IN_AR(compl_workbuf, 1) = (*statusInfo).bStatus; - if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) - { - BYTE_IN_AR(compl_workbuf, 2) = (uint8_t)((*statusInfo).bSource >> 8); // MSB - BYTE_IN_AR(compl_workbuf, 3) = (uint8_t)((*statusInfo).bSource & 0xFF); // LSB - offset++; // 16 bit nodeID means the command fields that follow are offset by one byte - } - else - { - BYTE_IN_AR(compl_workbuf, 2) = (uint8_t)((*statusInfo).bSource & 0xFF); // Legacy 8 bit nodeID - } - /* - Buffer boundary check */ - if ((*statusInfo).bLen > (uint8_t)(BUF_SIZE_TX - (offset + 4))) - { - (*statusInfo).bLen = (uint8_t)(BUF_SIZE_TX - (offset + 4)); - } - BYTE_IN_AR(compl_workbuf, offset + 3) = (*statusInfo).bLen; - for (uint8_t i = 0; i < (*statusInfo).bLen; i++) - { - BYTE_IN_AR(compl_workbuf, offset + 4 + i) = (*statusInfo).pCmd[i]; - } - Request(nodeManagement_Func_ID, compl_workbuf, (uint8_t)(offset + (*statusInfo).bLen + 4)); -} - -bool ZW_NodeManagementRunning(void) -{ - return (addState == ADD_NODE_STATUS_NODE_FOUND || - addState == ADD_NODE_STATUS_ADDING_SLAVE || - addState == ADD_NODE_STATUS_ADDING_CONTROLLER); -} -#endif - - -#if SUPPORT_ZW_ADD_NODE_TO_NETWORK -static void AddNodeToNetwork(uint8_t mode, void (*pCallBack)(LEARN_INFO_T *statusInfo)) -{ - SZwaveCommandPackage pCmdPackage = { - .eCommandType = EZWAVECOMMANDTYPE_ADD_NODE_TO_NETWORK, - .uCommandParams.NetworkManagement.mode = mode, - .uCommandParams.NetworkManagement.pHandle = (ZW_Void_Callback_t)pCallBack - }; - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&pCmdPackage, 0); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); -} - -static void AddNodeDskToNetwork(uint8_t mode, const uint8_t* pDsk, void (*pCallBack)(LEARN_INFO_T *statusInfo)) -{ - SZwaveCommandPackage pCmdPackage = { - .eCommandType = EZWAVECOMMANDTYPE_ADD_NODE_DSK_TO_NETWORK, - .uCommandParams.NetworkManagementDSK.mode = mode, - .uCommandParams.NetworkManagementDSK.pHandle = (ZW_Void_Callback_t)pCallBack - }; - memcpy(&pCmdPackage.uCommandParams.NetworkManagementDSK.dsk[0], pDsk, 8); - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&pCmdPackage, 0); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); -} - -ZW_ADD_CMD(FUNC_ID_ZW_ADD_NODE_TO_NETWORK) -{ - /* HOST->ZW: mode | funcID */ - /* HOST->ZW: mode = 0x07 | funcID | DSK[0] | DSK[1] | DSK[2] | DSK[3] | DSK[4] | DSK[5] | DSK[6] | DSK[7] */ - if (ZW_NodeManagementRunning() && ((frame->payload[0] & ADD_NODE_MODE_MASK) != ADD_NODE_STOP)) - { - // A previous node management request is still in progress. Drop this request and go back to idle state. - set_state_and_notify(stateIdle); - return; - } - SetupNodeManagement(frame, 1); - if ((frame->payload[0] & ADD_NODE_MODE_MASK) == ADD_NODE_HOME_ID) - { - AddNodeDskToNetwork(frame->payload[0], - &frame->payload[2], - (funcID_ComplHandler_ZW_NodeManagement != 0) ? &ZCB_ComplHandler_ZW_NodeManagement : NULL); - } - else - { - AddNodeToNetwork(frame->payload[0], - (funcID_ComplHandler_ZW_NodeManagement != 0) ? &ZCB_ComplHandler_ZW_NodeManagement : NULL); - } -} -#endif - -#if defined (SUPPORT_ZW_REMOVE_NODE_ID_FROM_NETWORK) && (SUPPORT_ZW_REMOVE_NODE_ID_FROM_NETWORK == 1) -static void RemoveNodeFromNetwork(uint8_t mode, node_id_t node_id, void (*pCallBack)(LEARN_INFO_T *statusInfo)) -{ - SZwaveCommandPackage pCmdPackage = { - .eCommandType = EZWAVECOMMANDTYPE_REMOVE_NODE_FROM_NETWORK, - .uCommandParams.NetworkManagement.mode = mode, - .uCommandParams.NetworkManagement.pHandle = (ZW_Void_Callback_t)pCallBack - }; - - if (0 != node_id) { - pCmdPackage.eCommandType = EZWAVECOMMANDTYPE_REMOVE_NODEID_FROM_NETWORK; - pCmdPackage.uCommandParams.NetworkManagement.nodeID = node_id; - } - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&pCmdPackage, 0); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); - -} -#endif - -#if SUPPORT_ZW_REMOVE_NODE_ID_FROM_NETWORK -ZW_ADD_CMD(FUNC_ID_ZW_REMOVE_NODE_FROM_NETWORK) -{ - /* HOST->ZW: mode | funcID */ - if (ZW_NodeManagementRunning()) - { - // A previous node management request is still in progress. Drop this request and go back to idle state. - set_state_and_notify(stateIdle); - return; - } - SetupNodeManagement(frame, 1); - RemoveNodeFromNetwork(frame->payload[0], 0, - (funcID_ComplHandler_ZW_NodeManagement != 0) ? &ZCB_ComplHandler_ZW_NodeManagement : NULL); -} -#endif - - -#ifdef ZW_CONTROLLER -ZW_ADD_CMD(FUNC_ID_ZW_REMOVE_NODE_ID_FROM_NETWORK) -{ - /* HOST->ZW: mode | nodeID | funcID */ - uint8_t offset = 0; - uint16_t nodeId = (uint16_t)GET_NODEID(&frame->payload[1], offset); - if (ZW_NodeManagementRunning()) - { - // A previous node management request is still in progress. Drop this request and go back to idle state. - set_state_and_notify(stateIdle); - return; - } - SetupNodeManagement(frame, offset + 2); - - RemoveNodeFromNetwork(frame->payload[0], nodeId, - (funcID_ComplHandler_ZW_NodeManagement != 0) ? &ZCB_ComplHandler_ZW_NodeManagement : NULL); -} -#endif - - -#if SUPPORT_ZW_CONTROLLER_CHANGE -static void ControllerChange(uint8_t mode, void (*pCallBack)(LEARN_INFO_T *statusInfo)) -{ - SZwaveCommandPackage pCmdPackage = { - .eCommandType = EZWAVECOMMANDTYPE_CONTROLLER_CHANGE, - .uCommandParams.NetworkManagement.mode = mode, - .uCommandParams.NetworkManagement.pHandle = (ZW_Void_Callback_t)pCallBack}; - - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&pCmdPackage, 0); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); -} - -ZW_ADD_CMD(FUNC_ID_ZW_CONTROLLER_CHANGE) -{ - /* HOST->ZW: mode | funcID */ - if (ZW_NodeManagementRunning()) - { - // A previous node management request is still in progress. Drop this request and go back to idle state. - set_state_and_notify(stateIdle); - return; - } - SetupNodeManagement(frame, 1); - ControllerChange(frame->payload[0], - (funcID_ComplHandler_ZW_NodeManagement != 0) ? &ZCB_ComplHandler_ZW_NodeManagement : NULL); -} -#endif - - -#if SUPPORT_ZW_SET_LEARN_MODE -#ifdef ZW_SLAVE -uint8_t funcID_ComplHandler_ZW_SetLearnMode; - -/*========================= ComplHandler_ZW_SetLearnMode ================= -** Completion handler for ZW_SetLearnMode -** -**--------------------------------------------------------------------------*/ -static void /*RET Nothing */ -ZCB_ComplHandler_ZW_SetLearnMode( - uint32_t bStatus) /*IN ZW_SetLearnMode status */ -{ - uint8_t i = 0; - node_id_t node_id; - - node_id = ZAF_GetNodeID(); - BYTE_IN_AR(compl_workbuf, i++) = funcID_ComplHandler_ZW_SetLearnMode; - BYTE_IN_AR(compl_workbuf, i++) = (uint8_t)bStatus; - if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) - { - BYTE_IN_AR(compl_workbuf, i++) = (uint8_t)(node_id >> 8); // MSB 16bit node Id - } - BYTE_IN_AR(compl_workbuf, i++) = (uint8_t)(node_id & 0xFF); // LSB(16bit)/Legacy 8 bit node Id - /* For safty we transmit len = 0, to indicate that no data follows */ - BYTE_IN_AR(compl_workbuf, i++) = 0; - Request(FUNC_ID_ZW_SET_LEARN_MODE, compl_workbuf, i); -} -#endif /* ZW_SLAVE */ - -#ifdef ZW_CONTROLLER -static void ZCB_ZW_NodeManagementLearnStatusRelay(uint32_t Status) -{ - node_id_t node_id; - - node_id = ZAF_GetNodeID(); - - LEARN_INFO_T Info = { - .bStatus = (uint8_t)Status, - .bSource = node_id, - 0}; - - ZCB_ComplHandler_ZW_NodeManagement(&Info); -} -#endif /* ZW_CONTROLLER */ - -static uint8_t NetworkLearnModeStart( E_NETWORK_LEARN_MODE_ACTION eLearnMode) -{ - SZwaveCommandPackage learnModeStart = { - .eCommandType = EZWAVECOMMANDTYPE_NETWORK_LEARN_MODE_START, - .uCommandParams.SetSmartStartLearnMode.eLearnMode = eLearnMode}; - // Put the Command on queue (and dont wait for it, queue must be empty) - if (EQUEUENOTIFYING_STATUS_SUCCESS == QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&learnModeStart, 0)) - { - // Wait for protocol to handle command - SZwaveCommandStatusPackage result = { 0 }; - if (GetCommandResponse(&result, EZWAVECOMMANDSTATUS_NETWORK_LEARN_MODE_START)) - { - return result.Content.NetworkManagementStatus.statusInfo[0]; - } - } - return false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_SET_LEARN_MODE) -{ - /* HOST->ZW: mode | funcID */ - /* ZW->HOST: retVal */ - uint8_t retVal = 1; -#ifdef ZW_CONTROLLER - SetupNodeManagement(frame, 1); -#endif /* ZW_CONTROLLER */ -#ifdef ZW_SLAVE - funcID_ComplHandler_ZW_SetLearnMode = frame->payload[1]; -#endif -#ifdef ZW_CONTROLLER_SINGLE - SyncEventArg1Unbind(&LearnModeStatusCb); - if (frame->payload[1] != 0) - { - SyncEventArg1bind(&LearnModeStatusCb, ZCB_ZW_NodeManagementLearnStatusRelay); - } - SZwaveCommandPackage Command = { - .eCommandType = EZWAVECOMMANDTYPE_SET_LEARN_MODE, - .uCommandParams.SetLearnMode.eLearnMode = frame->payload[0], - .uCommandParams.SetLearnMode.useCB = frame->payload[1] != 0 - }; - QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&Command, 0); - -#else - SyncEventArg1Unbind(&LearnModeStatusCb); - if (frame->payload[1] != 0) - { -#ifdef ZW_CONTROLLER - SyncEventArg1Bind(&LearnModeStatusCb, ZCB_ZW_NodeManagementLearnStatusRelay); -#endif -#ifdef ZW_SLAVE - SyncEventArg1Bind(&LearnModeStatusCb, ZCB_ComplHandler_ZW_SetLearnMode); -#endif - } - - if (SERIALPI_SET_LEARN_MODE_LEARN_PLUS_OFFSET > frame->payload[0]) - { - /* Plain ZW_SetLearnMode */ - /* ZW_SET_LEARN_MODE_DISABLE 0x00 */ - /* ZW_SET_LEARN_MODE_CLASSIC 0x01 */ - /* ZW_SET_LEARN_MODE_NWI 0x02 */ - /* ZW_SET_LEARN_MODE_NWE 0x03 */ - SZwaveCommandPackage Command = { - .eCommandType = EZWAVECOMMANDTYPE_SET_LEARN_MODE, - .uCommandParams.SetLearnMode.eLearnMode = frame->payload[0], - .uCommandParams.SetLearnMode.useCB = frame->payload[1] != 0 - }; - QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&Command, 0); - } - else - { - /* HOST want to use Network Management for inclusion/exclusion */ - /* We need to substract the SERIALPI_SET_LEARN_MODE_LEARN_PLUS_OFFSET to get: */ - /* E_NETWORK_LEARN_MODE_DISABLE = 0, Disable learn process */ - /* E_NETWORK_LEARN_MODE_INCLUSION = 1, Enable the learn process to do an inclusion */ - /* E_NETWORK_LEARN_MODE_EXCLUSION = 2, Enable the learn process to do an exclusion */ - /* E_NETWORK_LEARN_MODE_EXCLUSION_NWE = 3 Enable the learn process to do a network wide exclusion */ - /* E_NETWORK_LEARN_MODE_INCLUSION_SMARTSTART = 4 Enable the learn process to initiate SMARTSTART inclusion */ - retVal = NetworkLearnModeStart(frame->payload[0] - SERIALPI_SET_LEARN_MODE_LEARN_PLUS_OFFSET); - } -#endif /* ZW_CONTROLLER_SINGLE */ - DoRespond(retVal); -} -#endif /* SUPPORT_ZW_SET_LEARN_MODE */ - - -#if SUPPORT_ZW_EXPLORE_REQUEST_INCLUSION -static uint8_t ExploreRequestInclusion(void) -{ - // Create transmit frame package - SZwaveTransmitPackage FramePackage = { - .eTransmitType = EZWAVETRANSMITTYPE_EXPLOREINCLUSIONREQUEST - }; - - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); - return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_EXPLORE_REQUEST_INCLUSION) -{ - const uint8_t retVal = ExploreRequestInclusion(); - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_EXPLORE_REQUEST_EXCLUSION -static uint8_t ExploreRequestExclusion(void) -{ - // Create transmit frame package - SZwaveTransmitPackage FramePackage = { - .eTransmitType = EZWAVETRANSMITTYPE_EXPLOREEXCLUSIONREQUEST - }; - - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); - return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_EXPLORE_REQUEST_EXCLUSION) -{ - const uint8_t retVal = ExploreRequestExclusion(); - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_REPLICATION_COMMAND_COMPLETE -static void ReplicationComplete(void) -{ - /* */ - // Create transmit frame package - SZwaveTransmitPackage FramePackage = { - .eTransmitType = EZWAVETRANSMITTYPE_SENDREPLICATIONRECEIVECOMPLETE - }; - // Put the package on queue (and dont wait for it) - QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); -} - -ZW_ADD_CMD(FUNC_ID_ZW_REPLICATION_COMMAND_COMPLETE) -{ - ReplicationComplete(); - set_state_and_notify(stateIdle); -} -#endif - - -#if SUPPORT_ZW_REPLICATION_SEND_DATA -uint8_t funcID_ComplHandler_ZW_ReplicationSendData; - -/*===================== ComplHandler_ZW_ReplicationSendData ============= -** Completion handler for ZW_ReplicationSendData -** -**--------------------------------------------------------------------------*/ -static void /* RET Nothing */ -ZCB_ComplHandler_ZW_ReplicationSendData( - uint8_t txStatus, __attribute__((unused)) TX_STATUS_TYPE* extendedTxStatus) /* IN Transmit completion status */ -{ - BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_ReplicationSendData; - BYTE_IN_AR(compl_workbuf, 1) = txStatus; - Request(FUNC_ID_ZW_REPLICATION_SEND_DATA, compl_workbuf, 2); -} - -static uint8_t ReplicationSendData(uint16_t nodeID, uint8_t dataLength, const uint8_t* pData, uint8_t txOptions, ZW_TX_Callback_t pCallBack) -{ - ASSERT(dataLength <= BUF_SIZE_RX); - SZwaveTransmitPackage FramePackage = { - .uTransmitParams.SendReplication.DestNodeId = nodeID, - .uTransmitParams.SendReplication.FrameConfig.TransmitOptions = txOptions, - .uTransmitParams.SendReplication.FrameConfig.Handle = pCallBack, - .eTransmitType = EZWAVETRANSMITTYPE_SENDREPLICATION, - .uTransmitParams.SendReplication.FrameConfig.iFrameLength = dataLength - }; - memcpy(&FramePackage.uTransmitParams.SendReplication.FrameConfig.aFrame, pData, dataLength); - - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); - return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_REPLICATION_SEND_DATA) -{ - /* nodeID | dataLength | pData[] | txOptions | funcID */ - uint8_t dataLength; - uint8_t txOptions; - uint8_t offset = 0; - node_id_t nodeID; - nodeID = (node_id_t)GET_NODEID(&frame->payload[0], offset); - dataLength = frame->payload[offset + 1]; - txOptions = frame->payload[offset + 2 + dataLength]; - funcID_ComplHandler_ZW_ReplicationSendData = frame->payload[offset + 3 + dataLength]; - const uint8_t retVal = ReplicationSendData(nodeID, dataLength, &frame->payload[offset + 2], txOptions, - (funcID_ComplHandler_ZW_ReplicationSendData != 0) ? &ZCB_ComplHandler_ZW_ReplicationSendData : NULL ); - - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_ASSIGN_RETURN_ROUTE -uint8_t funcID_ComplHandler_ZW_AssignReturnRoute; - -/*===================== ComplHandler_ZW_AssignReturnRoute ============= -** Completion handler for ZW_AssignReturnRoute -** -**--------------------------------------------------------------------------*/ -static void /* RET Nothing */ -ZCB_ComplHandler_ZW_AssignReturnRoute( - uint8_t bStatus, - TX_STATUS_TYPE *txStatusReport) /* IN Transmit completion status */ -{ - uint8_t bIdx = 0; - BYTE_IN_AR(compl_workbuf, bIdx++) = funcID_ComplHandler_ZW_AssignReturnRoute; - BYTE_IN_AR(compl_workbuf, bIdx++) = bStatus; - if (bTxStatusReportEnabled && txStatusReport) /* Check if detailed info is available from protocol */ - { - memcpy(&compl_workbuf[bIdx], (uint8_t *)txStatusReport, sizeof(TX_STATUS_TYPE)); - bIdx += sizeof(TX_STATUS_TYPE); - } - Request(FUNC_ID_ZW_ASSIGN_RETURN_ROUTE, compl_workbuf, bIdx); -} - -static uint8_t AssignReturnRoute(uint16_t srcNode, uint16_t destNode, ZW_TX_Callback_t pCallBack) -{ - // Create transmit frame package - SZwaveTransmitPackage FramePackage = { - .uTransmitParams.AssignReturnRoute.ReturnRouteReceiverNodeId = srcNode, - .uTransmitParams.AssignReturnRoute.RouteDestinationNodeId = destNode, - .uTransmitParams.AssignReturnRoute.Handle = (ZW_Void_Callback_t)pCallBack, - .eTransmitType = EZWAVETRANSMITTYPE_ASSIGNRETURNROUTE - }; - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); - return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_ASSIGN_RETURN_ROUTE) -{ - /* srcNodeID | destNodeID | funcID */ - uint8_t offset = 0; - node_id_t srcNodeID; - node_id_t destNodeID; - srcNodeID = (node_id_t)GET_NODEID(&frame->payload[0], offset); - destNodeID = (node_id_t)GET_NODEID(&frame->payload[1 + offset], offset); - funcID_ComplHandler_ZW_AssignReturnRoute = frame->payload[2 + offset]; - const uint8_t retVal = AssignReturnRoute(srcNodeID, destNodeID, - (funcID_ComplHandler_ZW_AssignReturnRoute != 0) ? &ZCB_ComplHandler_ZW_AssignReturnRoute : NULL); - - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_ASSIGN_PRIORITY_RETURN_ROUTE -uint8_t funcID_ComplHandler_ZW_AssignPriorityReturnRoute; - -/*=============== ZCB_ComplHandler_ZW_AssignPriorityReturnRoute ========= -** Completion handler for ZW_AssignPriorityReturnRoute -** -**--------------------------------------------------------------------------*/ -static void /* RET Nothing */ -ZCB_ComplHandler_ZW_AssignPriorityReturnRoute( - uint8_t bStatus, /* IN Transmit completion status */ - TX_STATUS_TYPE *txStatusReport) -{ - uint8_t bIdx = 0; - BYTE_IN_AR(compl_workbuf, bIdx++) = funcID_ComplHandler_ZW_AssignPriorityReturnRoute; - BYTE_IN_AR(compl_workbuf, bIdx++) = bStatus; - if (bTxStatusReportEnabled && txStatusReport) /* Check if detailed info is available from protocol */ - { - memcpy(&compl_workbuf[bIdx], (uint8_t *)txStatusReport, sizeof(TX_STATUS_TYPE)); - bIdx += sizeof(TX_STATUS_TYPE); - } - Request(FUNC_ID_ZW_ASSIGN_PRIORITY_RETURN_ROUTE, compl_workbuf, bIdx); -} - -static uint8_t AssignPriorityReturnRoute(uint16_t srcNode, uint16_t destNode, const uint8_t* pRoute, uint8_t routeSpeed, ZW_TX_Callback_t pCallBack) -{ - /* srcNodeID | destNodeID | route[5] | funcID */ - // Create transmit frame package - SZwaveTransmitPackage FramePackage = { - .uTransmitParams.AssignReturnRoute.ReturnRouteReceiverNodeId = srcNode, - .uTransmitParams.AssignReturnRoute.RouteDestinationNodeId = destNode, - .uTransmitParams.AssignReturnRoute.PriorityRouteSpeed = routeSpeed, - .uTransmitParams.AssignReturnRoute.Handle = (ZW_Void_Callback_t)pCallBack, - .eTransmitType = EZWAVETRANSMITTYPE_ASSIGNRETURNROUTE - }; - memcpy(FramePackage.uTransmitParams.AssignReturnRoute.aPriorityRouteRepeaters, pRoute, - sizeof(FramePackage.uTransmitParams.AssignReturnRoute.aPriorityRouteRepeaters)); - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); - return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_ASSIGN_PRIORITY_RETURN_ROUTE) -{ - /* srcNodeID | destNodeID | route[5] | funcID */ - uint8_t offset = 0; - node_id_t srcNodeID; - node_id_t destNodeID; - srcNodeID = (node_id_t)GET_NODEID(&frame->payload[0], offset); - destNodeID = (node_id_t)GET_NODEID(&frame->payload[1 + offset], offset); - funcID_ComplHandler_ZW_AssignPriorityReturnRoute = frame->payload[offset + 7]; - // Put the package on queue (and dont wait for it) - const uint8_t retVal = AssignPriorityReturnRoute(srcNodeID, destNodeID, &frame->payload[offset + 2], frame->payload[offset + 6], - (funcID_ComplHandler_ZW_AssignPriorityReturnRoute != 0) ? &ZCB_ComplHandler_ZW_AssignPriorityReturnRoute : NULL ); - - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_DELETE_RETURN_ROUTE -uint8_t funcID_ComplHandler_ZW_DeleteReturnRoute; - -/*===================== ComplHandler_ZW_DeleteReturnRoute ============= -** Completion handler for ZW_DeleteReturnRoute -** -**--------------------------------------------------------------------------*/ -static void /* RET Nothing */ -ZCB_ComplHandler_ZW_DeleteReturnRoute( - uint8_t bStatus, - TX_STATUS_TYPE *txStatusReport) /* IN Transmit completion status */ -{ - uint8_t bIdx = 0; - BYTE_IN_AR(compl_workbuf, bIdx++) = funcID_ComplHandler_ZW_DeleteReturnRoute; - BYTE_IN_AR(compl_workbuf, bIdx++) = bStatus; - if (bTxStatusReportEnabled /* Do HOST want txStatusReport */ - && txStatusReport) /* Check if detailed info is available from protocol */ - { - memcpy(&compl_workbuf[bIdx], (uint8_t *)txStatusReport, sizeof(TX_STATUS_TYPE)); - bIdx += sizeof(TX_STATUS_TYPE); - } - Request(FUNC_ID_ZW_DELETE_RETURN_ROUTE, compl_workbuf, bIdx); -} - -static uint8_t DeleteReturnNode(uint16_t nodeID, ZW_TX_Callback_t pCallBack) -{ - // Create transmit frame package - SZwaveTransmitPackage FramePackage = { - .uTransmitParams.DeleteReturnRoute.DestNodeId = nodeID, - .uTransmitParams.DeleteReturnRoute.Handle = (ZW_Void_Callback_t)pCallBack, - .eTransmitType = EZWAVETRANSMITTYPE_DELETERETURNROUTE - }; - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); - return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_DELETE_RETURN_ROUTE) -{ - /* nodeID | funcID */ - uint8_t offset = 0; - node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); - funcID_ComplHandler_ZW_DeleteReturnRoute = frame->payload[1 + offset]; - const uint8_t retVal = DeleteReturnNode(nodeId, (funcID_ComplHandler_ZW_DeleteReturnRoute != 0) ? &ZCB_ComplHandler_ZW_DeleteReturnRoute : NULL); - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_ASSIGN_SUC_RETURN_ROUTE -static uint8_t AssignSucReturnRoute(uint16_t srcNodeID, uint8_t sucNode, ZW_TX_Callback_t pCallBack) -{ - /* srcNodeID | funcID */ - // Create transmit frame package - SZwaveTransmitPackage FramePackage = { - .uTransmitParams.AssignReturnRoute.ReturnRouteReceiverNodeId = srcNodeID, - .uTransmitParams.AssignReturnRoute.RouteDestinationNodeId = sucNode, - .uTransmitParams.AssignReturnRoute.isSucRoute = true, - .uTransmitParams.AssignReturnRoute.Handle = (ZW_Void_Callback_t)pCallBack, - .eTransmitType = EZWAVETRANSMITTYPE_ASSIGNRETURNROUTE - }; - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); - return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_ASSIGN_SUC_RETURN_ROUTE) -{ - /* srcNodeID | funcID */ - uint8_t retVal = 0; - uint8_t SUCNodeId = (uint8_t)(ZAF_GetSucNodeId() & 0xFF); - uint8_t offset = 0; - node_id_t srcNodeID = (node_id_t)GET_NODEID(&frame->payload[0], offset); - if (SUCNodeId != 0) - { - funcID_ComplHandler_netWork_Management = frame->payload[1 + offset]; - retVal = AssignSucReturnRoute(srcNodeID, SUCNodeId, (funcID_ComplHandler_netWork_Management != 0) ? &ZCB_ComplHandler_ZW_netWork_Management : NULL); - management_Func_ID = frame->cmd; - } - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_ASSIGN_PRIORITY_SUC_RETURN_ROUTE -uint8_t funcID_ComplHandler_ZW_AssignPrioritySUCReturnRoute; - -static uint8_t AssignPrioritySucReturnRoute(uint16_t srcNode, uint8_t sucNode, const uint8_t* pRoute, uint8_t routeSpeed, ZW_TX_Callback_t pCallBack) -{ - // Create transmit frame package - SZwaveTransmitPackage FramePackage = { - .uTransmitParams.AssignReturnRoute.ReturnRouteReceiverNodeId = srcNode, - .uTransmitParams.AssignReturnRoute.RouteDestinationNodeId = sucNode, - .uTransmitParams.AssignReturnRoute.PriorityRouteSpeed = routeSpeed, - .uTransmitParams.AssignReturnRoute.isSucRoute = true, - .uTransmitParams.AssignReturnRoute.Handle = (ZW_Void_Callback_t)pCallBack, - .eTransmitType = EZWAVETRANSMITTYPE_ASSIGNRETURNROUTE - }; - memcpy(FramePackage.uTransmitParams.AssignReturnRoute.aPriorityRouteRepeaters, pRoute, sizeof(FramePackage.uTransmitParams.AssignReturnRoute.aPriorityRouteRepeaters)); - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); - return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_ASSIGN_PRIORITY_SUC_RETURN_ROUTE) -{ - /* srcNodeID | route[5] | funcID */ - uint8_t retVal = 0; - uint8_t SUCNodeId = (uint8_t)(ZAF_GetSucNodeId() & 0xFF); - uint8_t offset = 0; - node_id_t srcNodeID = (node_id_t)GET_NODEID(&frame->payload[0], offset); - if (SUCNodeId != 0) - { - funcID_ComplHandler_netWork_Management = frame->payload[offset + 6]; - retVal = AssignPrioritySucReturnRoute(srcNodeID, SUCNodeId, &frame->payload[offset + 1], frame->payload[offset + 1 + 4], - (funcID_ComplHandler_netWork_Management != 0) ? &ZCB_ComplHandler_ZW_netWork_Management : NULL); - - management_Func_ID = frame->cmd; - } - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_DELETE_SUC_RETURN_ROUTE -static uint8_t DeleteSucReturnRoute(uint16_t srcNode, ZW_TX_Callback_t pCallBack) -{ - /* srcNodeID | funcID */ - - // Create transmit frame package - SZwaveTransmitPackage FramePackage = { - .uTransmitParams.DeleteReturnRoute.DestNodeId = srcNode, - .uTransmitParams.DeleteReturnRoute.bDeleteSuc = true, - .uTransmitParams.DeleteReturnRoute.Handle = (ZW_Void_Callback_t)pCallBack, - .eTransmitType = EZWAVETRANSMITTYPE_DELETERETURNROUTE - }; - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); - return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_DELETE_SUC_RETURN_ROUTE) -{ - /* srcNodeID | funcID */ - uint8_t offset = 0; - node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); - funcID_ComplHandler_netWork_Management = frame->payload[1 + offset]; - const uint8_t retVal = DeleteSucReturnRoute(nodeId, - (funcID_ComplHandler_netWork_Management != 0) ? &ZCB_ComplHandler_ZW_netWork_Management : NULL); - management_Func_ID = frame->cmd; - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_SEND_SUC_ID -uint8_t funcID_ComplHandler_ZW_SendSUC_ID; - -static void -ZCB_ComplHandler_ZW_SendSUC_ID( - uint8_t bStatus, - __attribute__((unused)) TX_STATUS_TYPE *txStatusReport) -{ - BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_SendSUC_ID; - BYTE_IN_AR(compl_workbuf, 1) = bStatus; - Request(FUNC_ID_ZW_SEND_SUC_ID, compl_workbuf, 2); -} - -static uint8_t SendSucID(uint16_t destNode, uint8_t txOptions, ZW_TX_Callback_t pCallBack) -{ - // Create transmit frame package - SZwaveTransmitPackage FramePackage = { - .uTransmitParams.SendSucNodeId.DestNodeId = destNode, - .uTransmitParams.SendSucNodeId.TransmitOptions = txOptions, - .uTransmitParams.SendSucNodeId.Handle = (ZW_Void_Callback_t)pCallBack, - .eTransmitType = EZWAVETRANSMITTYPE_SENDSUCNODEID - }; - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); - return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_SEND_SUC_ID) -{ - /* destNodeID | txOptions | funcID */ - uint8_t offset = 0; - node_id_t destNodeID = (node_id_t)GET_NODEID(&frame->payload[0], offset); - funcID_ComplHandler_ZW_SendSUC_ID = frame->payload[offset + 2]; - - const uint8_t retVal = SendSucID(destNodeID, frame->payload[offset + 2], - (funcID_ComplHandler_ZW_SendSUC_ID != 0) ? &ZCB_ComplHandler_ZW_SendSUC_ID : NULL); - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_SET_SUC_NODE_ID -uint8_t funcID_ComplHandler_ZW_SetSUCNodeID; - -/*==================== ComplHandler_ZW_SetSUCNodeID ====================== -** Function description -** ZW_SUC_SET_SUCCEEDED -** Side effects: -** -**--------------------------------------------------------------------------*/ -static void -ZCB_ComplHandler_ZW_SetSUCNodeID( - uint8_t txStatus, /*IN Completion status*/ - __attribute__((unused)) TX_STATUS_TYPE *txStatusReport) -{ - BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_SetSUCNodeID; - BYTE_IN_AR(compl_workbuf, 1) = txStatus; - Request(FUNC_ID_ZW_SET_SUC_NODE_ID, compl_workbuf, 2); -} - -static uint8_t SetSucNodeID(uint16_t nodeID, uint8_t sucState, uint8_t txOptions, uint8_t capabilities, ZW_TX_Callback_t pCallBack) -{ - // Create transmit frame package - SZwaveTransmitPackage FramePackage = { - .uTransmitParams.SetSucNodeId.SucNodeId = nodeID, - .uTransmitParams.SetSucNodeId.bSucEnable = sucState, - .uTransmitParams.SetSucNodeId.bTxLowPower = txOptions, - .uTransmitParams.SetSucNodeId.Capabilities = capabilities, - .uTransmitParams.SetSucNodeId.Handle = (ZW_Void_Callback_t)pCallBack, - .eTransmitType = EZWAVETRANSMITTYPE_SETSUCNODEID - }; - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); - return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_SET_SUC_NODE_ID) -{ - /* nodeID | SUCState | txOptions | capabilities | funcID */ - uint8_t offset = 0; - node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); - funcID_ComplHandler_ZW_SetSUCNodeID = frame->payload[offset + 4]; - const uint8_t retVal = SetSucNodeID(nodeId, frame->payload[offset + 1], frame->payload[offset + 2], frame->payload[offset + 3], - (funcID_ComplHandler_ZW_SetSUCNodeID != 0) ? &ZCB_ComplHandler_ZW_SetSUCNodeID : NULL); - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_GET_SUC_NODE_ID -ZW_ADD_CMD(FUNC_ID_ZW_GET_SUC_NODE_ID) -{ - uint8_t cmdLength = 0; - node_id_t suc_node_id; - - suc_node_id = ZAF_GetSucNodeId(); - - if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) - { - BYTE_IN_AR(compl_workbuf, 0) = (uint8_t)(suc_node_id >> 8); // MSB - BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)(suc_node_id & 0xFF); // LSB - cmdLength = 2; - } - else - { - BYTE_IN_AR(compl_workbuf, 0) = (uint8_t)(suc_node_id & 0xFF); - cmdLength = 1; - } - DoRespond_workbuf(cmdLength); -} -#endif - - -#if SUPPORT_ZW_REMOVE_FAILED_NODE_ID -uint8_t funcID_ComplHandler_ZW_RemoveFailedNodeID; - -/*===================== ComplHandler_ZW_RemoveFailedNodeID ============== -** Completion handler for ZW_RemoveFailedNodeID -** -**--------------------------------------------------------------------------*/ -void /* RET Nothing */ -ZCB_ComplHandler_ZW_RemoveFailedNodeID( - uint8_t bStatus) -{ - if (0 == funcID_ComplHandler_ZW_RemoveFailedNodeID) - { - return; - } - - BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_RemoveFailedNodeID; - BYTE_IN_AR(compl_workbuf, 1) = bStatus; - Request(FUNC_ID_ZW_REMOVE_FAILED_NODE_ID, compl_workbuf, 2); -} - -static uint8_t RemoveFailedNode(uint16_t nodeID) -{ - - SZwaveCommandPackage cmdPackage = { - .eCommandType = EZWAVECOMMANDTYPE_REMOVE_FAILED_NODE_ID, - .uCommandParams.FailedNodeIDCmd.nodeID = nodeID - }; - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 0); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); - SZwaveCommandStatusPackage cmdStatus = { 0 }; - if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_REMOVE_FAILED_NODE_ID)) - { - return cmdStatus.Content.FailedNodeIDStatus.result; - } - ASSERT(0); - return 0; -} - -ZW_ADD_CMD(FUNC_ID_ZW_REMOVE_FAILED_NODE_ID) -{ - /* nodeID | funcID */ - uint8_t offset = 0; - node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); - funcID_ComplHandler_ZW_RemoveFailedNodeID = frame->payload[1 + offset]; - const uint8_t retVal = RemoveFailedNode(nodeId); - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_IS_FAILED_NODE_ID -static uint8_t IsNodeIDFailed(uint16_t nodeID) -{ - SZwaveCommandPackage cmdPackage = { - .eCommandType = EZWAVECOMMANDTYPE_IS_FAILED_NODE_ID, - .uCommandParams.IsFailedNodeID.nodeID = nodeID}; - - // Put the Command on queue (and dont wait for it, queue must be empty) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 0); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); - - // Wait for protocol to handle command (it shouldnt take long) - SZwaveCommandStatusPackage cmdStatus = { 0 }; - if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_IS_FAILED_NODE_ID)) - { - return cmdStatus.Content.IsFailedNodeIDStatus.result; - } - ASSERT(false); // FIXME We should have more intelligent error handling, we shouldnt assert here. - return 0; -} - -ZW_ADD_CMD(FUNC_ID_ZW_IS_FAILED_NODE_ID) -{ - /* nodeID */ - volatile uint8_t offset = 0; - node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); - const uint8_t retVal = IsNodeIDFailed(nodeId); - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_REPLACE_FAILED_NODE -uint8_t funcID_ComplHandler_ZW_ReplaceFailedNode; - -/*===================== ComplHandler_ZW_RemoveFailedNodeID ============== -** Completion handler for ZW_RemoveFailedNodeID -** -**--------------------------------------------------------------------------*/ -void /* RET Nothing */ -ZCB_ComplHandler_ZW_ReplaceFailedNode( - uint8_t bStatus) /* IN Transmit completion status */ -{ - if (0 == funcID_ComplHandler_ZW_ReplaceFailedNode) - { - return; - } - - BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_ReplaceFailedNode; - BYTE_IN_AR(compl_workbuf, 1) = bStatus; - Request(FUNC_ID_ZW_REPLACE_FAILED_NODE, compl_workbuf, 2); -} - -static uint8_t ReplaceFailedNode(uint16_t nodeID, uint8_t normalPower) -{ - SZwaveCommandPackage cmdPackage = { - .eCommandType = EZWAVECOMMANDTYPE_REPLACE_FAILED_NODE_ID, - .uCommandParams.FailedNodeIDCmd.nodeID = nodeID, - .uCommandParams.FailedNodeIDCmd.normalPower = normalPower - }; - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 0); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); - SZwaveCommandStatusPackage cmdStatus = { 0 }; - if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_REPLACE_FAILED_NODE_ID)) - { - return cmdStatus.Content.FailedNodeIDStatus.result; - } - ASSERT(0); - return 0; - -} - -ZW_ADD_CMD(FUNC_ID_ZW_REPLACE_FAILED_NODE) -{ - /* nodeID | funcID */ - uint8_t offset = 0; - node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); - funcID_ComplHandler_ZW_ReplaceFailedNode = frame->payload[1 + offset]; - const uint8_t retVal = ReplaceFailedNode(nodeId, true); - DoRespond(retVal); -} -#endif - - -#if SUPPORT_GET_ROUTING_TABLE_LINE -static void GetRoutingInfo(uint16_t nodeID, uint8_t options, uint8_t *pRoutingInfo) -{ - SZwaveCommandPackage cmdPackage = { - .eCommandType = EZWAVECOMMANDTYPE_GET_ROUTING_TABLE_LINE, - .uCommandParams.GetRoutingInfo.nodeID = nodeID, - .uCommandParams.GetRoutingInfo.options = options}; - // Put the Command on queue (and dont wait for it, queue must be empty) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 0); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); - - // Wait for protocol to handle command (it shouldnt take long) - SZwaveCommandStatusPackage cmdStatus = { 0 }; - if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_GET_ROUTING_TABLE_LINE)) - { - memcpy(pRoutingInfo, cmdStatus.Content.GetRoutingInfoStatus.RoutingInfo, MAX_NODEMASK_LENGTH); - return; - } - ASSERT(false); // FIXME We should have more intelligent error handling, we shouldnt assert here. -} - -ZW_ADD_CMD(FUNC_ID_GET_ROUTING_TABLE_LINE) -{ - /* HOST->ZW: bLine | bRemoveBad | bRemoveNonReps */ - uint8_t offset = 0; - node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); - GetRoutingInfo(nodeId, - (uint8_t)(((frame->payload[offset + 1]) ? GET_ROUTING_INFO_REMOVE_BAD : 0) | - ((frame->payload[offset + 2]) ? GET_ROUTING_INFO_REMOVE_NON_REPS : 0)), - compl_workbuf); - DoRespond_workbuf(MAX_NODEMASK_LENGTH); -} -#endif - - -#if SUPPORT_GET_TX_COUNTER -ZW_ADD_CMD(FUNC_ID_GET_TX_COUNTER) -{ - /* */ - /* Get the transmit counter */ - /* Not usedin 700 series - Obsoleted */ - DoRespond(0); -} -#endif - - -#if SUPPORT_RESET_TX_COUNTER -ZW_ADD_CMD(FUNC_ID_RESET_TX_COUNTER) -{ - /* */ - /* Reset the transmit counter */ - /* Not usedin 700 series - Obsoleted */ - DoRespond(0); -} -#endif - - -#if SUPPORT_STORE_HOMEID -static void StoreHomeID(uin8_t *pHomeID, uint16_t nodeID) -{ - SZwaveCommandPackage cmdPackage = { - .eCommandType = EZWAVECOMMANDTYPE_STORE_HOMEID, - .uCommandParams.StoreHomeID.nodeID = nodeID, - }; - memcpy(cmdPackage.uCommandParams.StoreHomeID.homeID, pHomeID, sizeof(cmdPackage.uCommandParams.StoreHomeID.homeID)); - // Put the Command on queue (and dont wait for it, queue must be empty) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 0); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); -} - -ZW_ADD_CMD(FUNC_ID_STORE_HOMEID) -{ - /* homeID1 | homeID2 | homeID3 | homeID4 | nodeID */ - /* Store homeID and Node ID. */ - uint8_t offset = 0; - StoreHomeID(frame->payload, GET_NODEID(&frame->payload[4], offset)); - set_state_and_notify(stateIdle); -} -#endif - - -#if SUPPORT_LOCK_ROUTE_RESPONSE -static void LockResponseRoute(uint8_t lockID) -{ - SZwaveCommandPackage cmdPackage = { - .eCommandType = EZWAVECOMMANDTYPE_LOCK_ROUTE_RESPONSE, - .uCommandParams.LockRouteResponse.value = lockID, - }; - // Put the Command on queue (and dont wait for it, queue must be empty) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 0); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); -} - -ZW_ADD_CMD(FUNC_ID_LOCK_ROUTE_RESPONSE) -{ - /* HOST->ZW: lockID */ - /* Lock response routes / Last Working Routes. lockID == nodeID for locking. lockID == 0x00 to unlock */ - LockResponseRoute(frame->payload[0]); - set_state_and_notify(stateIdle); -} -#endif - - -#if SUPPORT_ZW_GET_PRIORITY_ROUTE -static uint8_t GetPriorityRoute(uint16_t nodeID, uint8_t *priRoute) -{ - SZwaveCommandPackage cmdPackage = { - .eCommandType = EZWAVECOMMANDTYPE_GET_PRIORITY_ROUTE, - .uCommandParams.GetPriorityRoute.nodeID = nodeID, - .uCommandParams.GetPriorityRoute.pPriRouteBuffer = priRoute, - }; - // Put the Command on queue (and dont wait for it, queue must be empty) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 0); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); - - // Wait for protocol to handle command (it shouldnt take long) - SZwaveCommandStatusPackage cmdStatus = { 0 }; - if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_GET_PRIORITY_ROUTE)) - { - memcpy(priRoute, cmdStatus.Content.GetPriorityRouteStatus.repeaters, MAX_REPEATERS); - priRoute[4] = cmdStatus.Content.GetPriorityRouteStatus.routeSpeed; - return cmdStatus.Content.GetPriorityRouteStatus.bAnyRouteFound; - } - ASSERT(false); // FIXME We should have more intelligent error handling, we shouldnt assert here. - return 0; -} - -ZW_ADD_CMD(FUNC_ID_ZW_GET_PRIORITY_ROUTE) -{ - /* HOST->ZW: nodeID */ - /* ZW->HOST: nodeID | anyRouteFound | repeater0 | repeater1 | repeater2 | repeater3 | routespeed */ - uint8_t offset = 0; - node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); - if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) - { - BYTE_IN_AR(compl_workbuf, 0) = (uint8_t)(nodeId >> 8); // MSB - BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)(nodeId & 0xFF); // LSB - } - else - { - BYTE_IN_AR(compl_workbuf, 0) = (uint8_t)(nodeId & 0xFF); // Legacy 8 bit nodeIDs - } - BYTE_IN_AR(compl_workbuf, offset + 1) = GetPriorityRoute(nodeId, &compl_workbuf[offset + 2]); - DoRespond_workbuf(offset + 7); -} -#endif - - -#if SUPPORT_ZW_SET_PRIORITY_ROUTE -static uint8_t SetPriorityRoute(uint16_t nodeID, const uint8_t *routeInfo) -{ - SZwaveCommandPackage cmdPackage = { - .eCommandType = EZWAVECOMMANDTYPE_SET_PRIORITY_ROUTE, - .uCommandParams.SetPriorityRoute.nodeID = nodeID, - }; - if (NULL != routeInfo) - { - memcpy(cmdPackage.uCommandParams.SetPriorityRoute.repeaters, routeInfo, MAX_REPEATERS); - cmdPackage.uCommandParams.SetPriorityRoute.routeSpeed = routeInfo[4]; - } - else - { - cmdPackage.uCommandParams.SetPriorityRoute.clearGolden = true; - } - // Put the Command on queue (and dont wait for it, queue must be empty) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 0); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); - - // Wait for protocol to handle command (it shouldnt take long) - SZwaveCommandStatusPackage cmdStatus = { 0 }; - if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_SET_PRIORITY_ROUTE)) - { - return cmdStatus.Content.SetPriorityRouteStatus.bRouteUpdated; - } - ASSERT(false); // FIXME We should have more intelligent error handling, we shouldnt assert here. - return 0; -} - -ZW_ADD_CMD(FUNC_ID_ZW_SET_PRIORITY_ROUTE) -{ - /* HOST->ZW: nodeID | repeater0 | repeater1 | repeater2 | repeater3 | routespeed */ - /* ZW->HOST: nodeID | routeUpdated */ - uint8_t offset = 0; - node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); - if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) - { - BYTE_IN_AR(compl_workbuf, 0) = (uint8_t)(nodeId >> 8); // MSB - BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)(nodeId & 0xFF); // LSB - } - else - { - BYTE_IN_AR(compl_workbuf, 0) = (uint8_t)(nodeId & 0xFF); // Legacy 8 bit nodeIDs - } - if ((offset + 9) <= frame->len) - { - /* Set Priority Route Devkit 6.6x */ - BYTE_IN_AR(compl_workbuf, offset + 1) = SetPriorityRoute(nodeId, &frame->payload[offset + 1]); - } - else - { - /* Clear/Release Golden Route - Devkit 6.6x+ */ - BYTE_IN_AR(compl_workbuf, offset + 1) = SetPriorityRoute(nodeId, NULL); - } - DoRespond_workbuf(2); -} -#endif - - -#if SUPPORT_ZW_GET_VERSION -ZW_ADD_CMD(FUNC_ID_ZW_GET_VERSION) -{ - /* */ - const SProtocolInfo* protocol_info = ZAF_getProtocolInfo(); - uint8_t versionMinor = protocol_info->ProtocolVersion.Minor; - if (255 == zpal_get_app_version_major()) - { - // Special case when running the custom v255 file that is used for testing OTW firmware update. - // Make ZW_GET_VERSION return a unique version string "Z-Wave 7.99" so that test tools can distinguish it from the normal builds. - versionMinor = 99; - } - volatile int32_t iCharacters = snprintf((char *)(&compl_workbuf[0]), 12, "Z-Wave %1d.%02d", protocol_info->ProtocolVersion.Major, versionMinor); - ASSERT(iCharacters == 11); // Serial API must deliver 13 bytes reply. 11 byte string (no zero termination) followed by zero and 1 byte lib type - // We use SNPRINTF zero termination to produce the zero. - STATIC_ASSERT(sizeof(compl_workbuf) >= 13, STATIC_ASSERT_compl_workbuf_to_small); - compl_workbuf[12] = protocol_info->eLibraryType; - DoRespond_workbuf(13); -} -#endif - - -#if SUPPORT_ZW_GET_PROTOCOL_VERSION -ZW_ADD_CMD(FUNC_ID_ZW_GET_PROTOCOL_VERSION) -{ - /* */ - uint8_t len; - func_id_zw_get_protocol_version(0, NULL, compl_workbuf, &len); - DoRespond_workbuf(len); -} -#endif - - -#if SUPPORT_SERIAL_API_APPL_NODE_INFORMATION -#ifdef ZW_CONTROLLER -static void ZW_UpdateCtrlNodeInformation_API_IF(void) -{ - // Create transmit frame package - SZwaveCommandPackage FramePackage ={ - .eCommandType = EZWAVECOMMANDTYPE_ZW_UPDATE_CTRL_NODE_INFORMATION, - .uCommandParams.UpdateCtrlNodeInformation.value = true - }; - // Put the package on queue (and dont wait for it) - QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&FramePackage, 0); -} -#endif - -ZW_ADD_CMD(FUNC_ID_SERIAL_API_APPL_NODE_INFORMATION) -{ - /* listening | generic | specific | parmLength | nodeParms[] */ - SAppNodeInfo_t *AppNodeInfo; - - AppNodeInfo = zaf_get_app_node_info(); - - AppNodeInfo->DeviceOptionsMask = frame->payload[0]; - AppNodeInfo->NodeType.generic = frame->payload[1]; - AppNodeInfo->NodeType.specific = frame->payload[2]; - - // As this serial API command only supports one set of command classes, - // we use the same list for the entire CC set - - // Data for loopifying CC list writes - SCommandClassList_t *const apCCLists[3] = - { - &CommandClasses.UnSecureIncludedCC, - &CommandClasses.SecureIncludedUnSecureCC, - &CommandClasses.SecureIncludedSecureCC - }; - - uint32_t iListLength = frame->payload[3]; - for (uint32_t i = 0; i < 3; i++) - { - // NOTE: These are not really supposed to be edited run time. - // So set list lengths to 0 at first to reduce chaos if protocol - // accesses them while we edit them. - apCCLists[i]->iListLength = 0; - - memset((uint8_t *)(apCCLists[i]->pCommandClasses), 0, CCListSizes[i]); // Clear CCList - memcpy((uint8_t *)(apCCLists[i]->pCommandClasses), &frame->payload[4], Minimum2(iListLength, CCListSizes[i])); - - // Set new list length after finishing CCList - apCCLists[i]->iListLength = (uint8_t)Minimum2(iListLength, CCListSizes[i]); - } - - SaveApplicationSettings(frame->payload[0], frame->payload[1], - frame->payload[2]); - SaveApplicationCCInfo(apCCLists[0]->iListLength, (uint8_t*)apCCLists[0]->pCommandClasses, - 0, NULL, 0, NULL); -#ifdef ZW_CONTROLLER - ZW_UpdateCtrlNodeInformation_API_IF(); -#endif - - set_state_and_notify(stateIdle); -} -#endif - - -#if SUPPORT_SERIAL_API_APPL_NODE_INFORMATION_CMD_CLASSES -ZW_ADD_CMD(FUNC_ID_SERIAL_API_APPL_NODE_INFORMATION_CMD_CLASSES) -{ - /* unincluded_parmLength | unincluded_nodeParm[] | */ - /* included_unsecure_parmLength | included_unsecure_nodeParm[] |*/ - /* included_secure_parmLength | included_secure_nodeParm[] */ - - // Data for loopifying CC list writes - SCommandClassList_t *const apCCLists[3] = - { - &CommandClasses.UnSecureIncludedCC, - &CommandClasses.SecureIncludedUnSecureCC, - &CommandClasses.SecureIncludedSecureCC - }; - - uint32_t iOffset = 0; - for (uint32_t i = 0; i < 3; i++) - { - // NOTE: These are not really supposed to be edited run time. - // So set list lengths to 0 at first to reduce chaos if protocol - // accesses them while we edit them. - apCCLists[i]->iListLength = 0; - - memset((uint8_t *)(apCCLists[i]->pCommandClasses), 0, CCListSizes[i]); // Clear CCList - uint32_t iListLength = frame->payload[iOffset]; - memcpy((uint8_t*)apCCLists[i]->pCommandClasses, &frame->payload[iOffset + 1], Minimum2(iListLength, CCListSizes[i])); - // Set new list length after finishing CCList - apCCLists[i]->iListLength = (uint8_t)iListLength; - - iOffset += iListLength + 1; - } - - const uint8_t retVal = SaveApplicationCCInfo(apCCLists[0]->iListLength, (uint8_t*)apCCLists[0]->pCommandClasses, - apCCLists[1]->iListLength, (uint8_t*)apCCLists[1]->pCommandClasses, - apCCLists[2]->iListLength, (uint8_t*)apCCLists[2]->pCommandClasses - ); - DoRespond(retVal); -} -#endif - - -#if SUPPORT_SERIAL_API_APPL_SLAVE_NODE_INFORMATION -uint8_t funcID_ComplHandler_ZW_SendSlaveNodeInformation; - -/*================= ComplHandler_ZW_SendSlaveNodeInformation ============ -** Completion handler for ZW_SendSlaveNodeInformation -** -**--------------------------------------------------------------------------*/ -static void /* RET Nothing */ -ZCB_ComplHandler_ZW_SendSlaveNodeInformation( - uint8_t txStatus, /* IN Transmit completion status */ - __attribute__((unused)) TX_STATUS_TYPE *txStatusReport) -{ - BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_SendSlaveNodeInformation; - BYTE_IN_AR(compl_workbuf, 1) = txStatus; - Request(FUNC_ID_ZW_SEND_SLAVE_NODE_INFORMATION, compl_workbuf, 2); -} - -static uint8_t SendSlaveNodeInfo(uint16_t srcNode, uint16_t destNode, uint8_t txOptions, ZW_TX_Callback_t pCallBack) -{ - SZwaveTransmitPackage FramePackage = { - .eTransmitType = EZWAVETRANSMITTYPE_SEND_SLAVE_NODE_INFORMATION, - .uTransmitParams.SendSlaveNodeInformation.Handle = (ZW_Void_Callback_t)pCallBack, - .uTransmitParams.SendSlaveNodeInformation.sourceId = srcNode, - .uTransmitParams.SendSlaveNodeInformation.destinationId = destNode, - .uTransmitParams.SendSlaveNodeInformation.txOptions = txOptions, - }; - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); - return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_SEND_SLAVE_NODE_INFORMATION) -{ - /* srcNode | destNode | txOptions | funcID */ - node_id_t srcNodeId, destNodeId; - srcNodeId = (node_id_t)frame->payload[0]; - destNodeId = (node_id_t)frame->payload[1]; - funcID_ComplHandler_ZW_SendSlaveNodeInformation = frame->payload[3]; - const uint8_t retVal = SendSlaveNodeInfo(srcNodeId, destNodeId, frame->payload[2], - (funcID_ComplHandler_ZW_SendSlaveNodeInformation != 0) ? &ZCB_ComplHandler_ZW_SendSlaveNodeInformation : NULL); - DoRespond(retVal); -} - -ZW_ADD_CMD(FUNC_ID_SERIAL_API_APPL_SLAVE_NODE_INFORMATION) -{ - /* srcNodeID | listening | generic | specific | parmLength | nodeParms[] */ - /* frame->payload[0] = srcNodeID */ - - uint32_t iVirtualSlaveIndex = 0; // Choose which Virtual Slave node slot to use - uint8_t offset = 0; - - // Start by removing reference to current configuration - so protocol never sees a partially modified config - apVirtualSlaveNodeInfo[iVirtualSlaveIndex] = NULL; - - // Modify config - aVirtualSlaveNodeInfo[iVirtualSlaveIndex].NodeId = (node_id_t)frame->payload[0]; - aVirtualSlaveNodeInfo[iVirtualSlaveIndex].bListening = frame->payload[offset + 1]; - aVirtualSlaveNodeInfo[iVirtualSlaveIndex].NodeType.generic = frame->payload[offset + 2]; - aVirtualSlaveNodeInfo[iVirtualSlaveIndex].NodeType.specific = frame->payload[offset + 3]; - aVirtualSlaveNodeInfo[iVirtualSlaveIndex].CommandClasses.iListLength = (uint8_t)Minimum2(frame->payload[offset + 4], sizeof(aVirtualSlaveCommandClasses[0])); - - memset(&aVirtualSlaveCommandClasses[iVirtualSlaveIndex][0], 0, sizeof(aVirtualSlaveCommandClasses[0])); - memcpy(&aVirtualSlaveCommandClasses[iVirtualSlaveIndex][0], &frame->payload[offset + 5], aVirtualSlaveNodeInfo[0].CommandClasses.iListLength); - - // Re-activate config - apVirtualSlaveNodeInfo[iVirtualSlaveIndex] = &aVirtualSlaveNodeInfo[iVirtualSlaveIndex]; - - set_state_and_notify(stateIdle); -} -#endif - - -#if SUPPORT_ZW_SET_SLAVE_LEARN_MODE -uint8_t funcID_ComplHandler_ZW_SetSlaveLearnMode; - -/*================= ComplHandler_ZW_SetSlaveLearnMode ==================== -** Completion handler for ZW_SetSlaveLearnMode -** -**--------------------------------------------------------------------------*/ -void /* RET Nothing */ -ZCB_ComplHandler_ZW_SetSlaveLearnMode( - uint8_t bStatus, - uint8_t orgID, - uint8_t newID) /* IN Node ID */ -{ - if (0 == funcID_ComplHandler_ZW_SetSlaveLearnMode) - { - return; - } - - BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_SetSlaveLearnMode; - BYTE_IN_AR(compl_workbuf, 1) = bStatus; - BYTE_IN_AR(compl_workbuf, 2) = orgID; - BYTE_IN_AR(compl_workbuf, 3) = newID; - Request(FUNC_ID_ZW_SET_SLAVE_LEARN_MODE, compl_workbuf, 4); -} - -static uint8_t SetSlaveLearnMode(uint16_t nodeID, uint8_t mode) -{ - SZwaveCommandPackage cmdPackage = { - .eCommandType = EZWAVECOMMANDTYPE_SET_SLAVE_LEARN_MODE, - .uCommandParams.SetSlaveLearnMode.nodeID = nodeID, - .uCommandParams.SetSlaveLearnMode.mode = mode, - }; - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 500); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); - SZwaveCommandStatusPackage cmdStatus = { 0 }; - if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_SET_SLAVE_LEARN_MODE_RESULT)) - { - return cmdStatus.Content.SetSlaveLearnModeStatus.result; - } - return false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_SET_SLAVE_LEARN_MODE) -{ - /* node | mode | funcID */ - uint8_t offset = 0; - node_id_t nodeID = (node_id_t)frame->payload[0]; - funcID_ComplHandler_ZW_SetSlaveLearnMode = frame->payload[offset + 2]; - const uint8_t retVal = SetSlaveLearnMode(nodeID, frame->payload[offset + 1]); - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_SEND_TEST_FRAME -uint8_t funcID_ComplHandler_ZW_SendTestFrame; - -/*================= ComplHandler_ZW_SendTestFrame ==================== -** Completion handler for ZW_SendTestFrame -** -**--------------------------------------------------------------------------*/ -static void -ZCB_ComplHandler_ZW_SendTestFrame( - uint8_t txStatus, - __attribute__((unused)) TX_STATUS_TYPE *txStatusReport) -{ - BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_SendTestFrame; - BYTE_IN_AR(compl_workbuf, 1) = txStatus; - Request(FUNC_ID_ZW_SEND_TEST_FRAME, compl_workbuf, 2); -} - -static uint8_t SendTestFrame(uint16_t nodeID, uint8_t powerLevel, ZW_TX_Callback_t pCallBack) -{ - // Create transmit frame package - SZwaveTransmitPackage FramePackage = { - .eTransmitType = EZWAVETRANSMITTYPE_TESTFRAME, - .uTransmitParams.Test.DestNodeId = nodeID, - .uTransmitParams.Test.PowerLevel = powerLevel, - .uTransmitParams.Test.Handle = pCallBack - }; - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); - return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_SEND_TEST_FRAME) -{ - /* node | powerlevel | funcID */ - uint8_t offset = 0; - node_id_t node = (node_id_t)GET_NODEID(&frame->payload[0], offset); - funcID_ComplHandler_ZW_SendTestFrame = frame->payload[offset + 2]; - const uint8_t retVal = SendTestFrame(node, frame->payload[offset + 1], - (funcID_ComplHandler_ZW_SendTestFrame != 0) ? &ZCB_ComplHandler_ZW_SendTestFrame : NULL); - - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_IS_VIRTUAL_NODE -static uint8_t IsNodeVirtual(uint16_t nodeID) -{ - if(!nodeID || (ZW_MAX_NODES < nodeID)) //Virtual nodes are not implemented for Long Range nodes - { - return false; - } - - SZwaveCommandPackage cmdPackage = { - .eCommandType = EZWAVECOMMANDTYPE_IS_VIRTUAL_NODE, - .uCommandParams.IsVirtualNode.value = nodeID, - }; - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 500); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); - SZwaveCommandStatusPackage cmdStatus = { 0 }; - if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_IS_VIRTUAL_NODE)) - { - return cmdStatus.Content.IsVirtualNodeStatus.result; - } - - ASSERT(false); // FIXME We should have more intelligent error handling, we shouldnt assert here. - return 0; -} - -ZW_ADD_CMD(FUNC_ID_ZW_IS_VIRTUAL_NODE) -{ - /* node */ - node_id_t nodeId = (node_id_t)frame->payload[0]; - const uint8_t retVal = IsNodeVirtual(nodeId); - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_GET_VIRTUAL_NODES -static void GetVirtualNodes(uint8_t *vNodesMask) -{ - SZwaveCommandPackage cmdPackage = { - .eCommandType = EZWAVECOMMANDTYPE_GET_VIRTUAL_NODES}; - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 500); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); - SZwaveCommandStatusPackage cmdStatus = { 0 }; - if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_GET_VIRTUAL_NODES)) - { - memcpy(vNodesMask, cmdStatus.Content.GetVirtualNodesStatus.vNodesMask, MAX_NODEMASK_LENGTH); - return; - } - - ASSERT(false); // FIXME We should have more intelligent error handling, we shouldnt assert here. -} - -ZW_ADD_CMD(FUNC_ID_ZW_GET_VIRTUAL_NODES) -{ - /* */ - GetVirtualNodes(compl_workbuf); - DoRespond_workbuf(ZW_MAX_NODES / 8); -} -#endif - -#if SUPPORT_SERIAL_API_GET_INIT_DATA -ZW_ADD_CMD(FUNC_ID_SERIAL_API_GET_INIT_DATA) -{ - uint8_t length = 0; - func_id_serial_api_get_init_data(frame_payload_len(frame), frame->payload, compl_workbuf, &length); - DoRespond_workbuf(length); -} -#endif -#if SUPPORT_SERIAL_API_GET_LR_NODES -#ifdef ZW_CONTROLLER -ZW_ADD_CMD(FUNC_ID_SERIAL_API_GET_LR_NODES) -{ - uint8_t length = 0; - func_id_serial_api_get_LR_nodes(frame_payload_len(frame), frame->payload, compl_workbuf, &length); - DoRespond_workbuf(length); -} -#endif -#endif - -#if SUPPORT_SERIAL_GET_LR_CHANNEL -ZW_ADD_CMD(FUNC_ID_GET_LR_CHANNEL) -{ - GetLongRangeChannel(&compl_workbuf[0], &compl_workbuf[1]); - DoRespond_workbuf(2); -} -#endif - - -#if SUPPORT_SERIAL_SET_LR_CHANNEL -ZW_ADD_CMD(FUNC_ID_SET_LR_CHANNEL) -{ - const uint8_t retVal = SetLongRangeChannel(frame->payload[0]); - DoRespond(retVal); -} -#endif - -#if SUPPORT_SERIAL_SET_LR_VIRTUAL_IDS -ZW_ADD_CMD(FUNC_ID_ZW_SET_LR_VIRTUAL_IDS) -{ - SetLongRangeVirtualNodes(frame->payload[0]); - set_state_and_notify(stateIdle); -} -#endif - - -#if SUPPORT_SERIAL_ENABLE_RADIO_PTI -ZW_ADD_CMD(FUNC_ID_ENABLE_RADIO_PTI) -{ - const uint8_t retVal = SaveApplicationEnablePTI(frame->payload[0]); - DoRespond(retVal); -} - -ZW_ADD_CMD(FUNC_ID_GET_RADIO_PTI) -{ - const uint8_t retVal = GetPTIConfig(); - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_GET_CONTROLLER_CAPABILITIES -ZW_ADD_CMD(FUNC_ID_ZW_GET_CONTROLLER_CAPABILITIES) -{ - /* HOST->ZW: no params defined */ - const uint8_t retVal = GetControllerCapabilities(); - DoRespond(retVal); -} -#endif - - -#if SUPPORT_ZW_REQUEST_NODE_INFO -/*====================== ComplHandler_ZW_RequestNodeInfo ===================== -** Completion handler for ZW_RequestNodeInfo -** -**--------------------------------------------------------------------------*/ -static void /* RET Nothing */ -ZCB_ComplHandler_ZW_RequestNodeInfo( - uint8_t txStatus, /* IN Transmit completion status */ - __attribute__((unused)) TX_STATUS_TYPE *txStatusReport) -{ - /* */ - if (txStatus != TRANSMIT_COMPLETE_OK) - { - ApplicationNodeUpdate(UPDATE_STATE_NODE_INFO_REQ_FAILED, 0, NULL, 0); - } -} - -static uint8_t RequestNodeID(uint16_t nodeID) -{ - // Create transmit frame package - SZwaveTransmitPackage FramePackage = { - .eTransmitType = EZWAVETRANSMITTYPE_NODEINFORMATIONREQUEST, - .uTransmitParams.NodeInfoRequest.DestNodeId = nodeID, - .uTransmitParams.NodeInfoRequest.Handle = (ZW_Void_Callback_t)ZCB_ComplHandler_ZW_RequestNodeInfo - }; - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); - return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; -} -#if SUPPORT_ZW_REQUEST_NODE_INFO -ZW_ADD_CMD(FUNC_ID_ZW_REQUEST_NODE_INFO) -{ - /* HOST->ZW: nodeID */ - volatile uint8_t offset = 0; - node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); - const uint8_t retVal = RequestNodeID(nodeId); - DoRespond(retVal); -} -#endif -#endif /*SUPPORT_ZW_REQUEST_NODE_INFO*/ - -#if SUPPORT_SERIAL_API_SET_TIMEOUTS -ZW_ADD_CMD(FUNC_ID_SERIAL_API_SET_TIMEOUTS) -{ - /* HOST->ZW: RX_ACK_timeout | RX_BYTE_timeout */ - /* ZW->HOST: RES | oldRX_ACK_timeout | oldRX_BYTE_timeout */ - BYTE_IN_AR(compl_workbuf, 0) = (uint8_t)(comm_interface_get_ack_timeout_ms() / 10); /* Respond with the old timeout settings */ - BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)(comm_interface_get_byte_timeout_ms() / 10); - comm_interface_set_ack_timeout_ms(frame->payload[0] * 10); /* Max time to wait for ACK after frame transmission in 10ms ticks */ - comm_interface_set_byte_timeout_ms(frame->payload[1] * 10); /* Max time to wait for next byte when collecting a new frame in 10ms ticks */ - /* Respond with the old timeout settings */ - DoRespond_workbuf(2); -} -#endif - - -#if SUPPORT_SERIAL_API_SOFT_RESET -ZW_ADD_CMD(FUNC_ID_SERIAL_API_SOFT_RESET) -{ - //Enqueue soft reset command to protocol - SZwaveCommandPackage Command = { - .eCommandType = EZWAVECOMMANDTYPE_SOFT_RESET - }; - QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&Command, 0); -} -#endif - - -#if SUPPORT_SERIAL_API_SETUP -ZW_ADD_CMD(FUNC_ID_SERIAL_API_SETUP) -{ - /* HOST->ZW: Cmd | [CmdData[]] */ - /* ZW->HOST: Cmd | CmdRes[] */ - uint8_t length; - func_id_serial_api_setup(frame_payload_len(frame), frame->payload, compl_workbuf, &length); - DoRespond_workbuf(length); -} -#endif - -#if SUPPORT_SERIAL_API_READY -ZW_ADD_CMD(FUNC_ID_SERIAL_API_READY) -{ - /* HOST->ZW: [serialLinkState] */ - /* serialLinkState is OPTIONAL, if not present then the READY command, means "READY" */ - if ((FRAME_LENGTH_MIN < frame->len) && (SERIAL_LINK_DETACHED == frame->payload[0])) - { - /* HOST want Serial link to be shutdown - SerialAPI will not transmit anything */ - /* via serial link as long as HOST do not reestablish the Serial Link by */ - /* transmitting a valid SerialAPI frame. */ - serialLinkState = SERIAL_LINK_DETACHED; - /* Purge Callback queue */ - PurgeCallbackQueue(); - PurgeCommandQueue(); - } - else - { - /* Missing serialLinkState parameter or Every other serialLinkState value means */ - /* HOST Ready for Serial Communication */ - serialLinkState = SERIAL_LINK_CONNECTED; - } - set_state_and_notify(stateIdle); -} -#endif - - -#if SUPPORT_ZW_TYPE_LIBRARY -ZW_ADD_CMD(FUNC_ID_ZW_TYPE_LIBRARY) -{ - const SProtocolInfo* protocol_info = ZAF_getProtocolInfo(); - DoRespond(protocol_info->eLibraryType); -} -#endif - - -#if SUPPORT_ZW_WATCHDOG_START | SUPPORT_ZW_WATCHDOG_STOP -uint8_t bWatchdogStarted; -#endif - - -#if SUPPORT_ZW_WATCHDOG_START -ZW_ADD_CMD(FUNC_ID_ZW_WATCHDOG_START) -{ - bWatchdogStarted = true; - zpal_enable_watchdog(true); - set_state_and_notify(stateIdle); -} -#endif - - -#if SUPPORT_ZW_WATCHDOG_STOP -ZW_ADD_CMD(FUNC_ID_ZW_WATCHDOG_STOP) -{ - zpal_enable_watchdog(false); - bWatchdogStarted = false; - set_state_and_notify(stateIdle); -} -#endif - - -#if SUPPORT_ZW_SET_ROUTING_MAX -static void zw_set_routing_max_handler(const comm_interface_frame_ptr frame) -{ - SZwaveCommandPackage Command = { - .eCommandType = EZWAVECOMMANDTYPE_SET_ROUTING_MAX, - .uCommandParams.SetRoutingMax.value = frame->payload[0] - }; - QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&Command, 0); - DoRespond(1); -} - -ZW_ADD_CMD(FUNC_ID_ZW_SET_ROUTING_MAX) -{ - zw_set_routing_max_handler(frame); -} - -ZW_ADD_CMD(FUNC_ID_ZW_SET_ROUTING_MAX_6_00) -{ - zw_set_routing_max_handler(frame); -} -#endif - - -#if SUPPORT_ZW_SET_PROMISCUOUS_MODE -static void SetPromiscuousMode(uint8_t mode) -{ - SZwaveCommandPackage PromiscuousMode = { - .eCommandType = EZWAVECOMMANDTYPE_SET_PROMISCUOUS_MODE, - .uCommandParams.SetPromiscuousMode.Enable = mode; - }; - - // Put the Command on queue (and dont wait for it, queue must be empty) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t*)&PromiscuousMode, 0); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); -} - -ZW_ADD_CMD(FUNC_ID_ZW_SET_PROMISCUOUS_MODE) -{ - /* HOST->ZW: promiscuousMode */ - SetPromiscuousMode(frame->payload[0]); - set_state_and_notify(stateIdle); -} -#endif - - -#if SUPPORT_SERIAL_API_TEST -ZW_APPLICATION_META_TX_BUFFER txBuffer; - -uint8_t funcID_ComplHandler_Serial_API_Test; -uint8_t testnodemask[ZW_MAX_NODES / 8]; -uint8_t testresultnodemask[ZW_MAX_NODES / 8]; - -uint8_t testnodemasklen = 0; -uint8_t timerTestHandle = 0xff; -uint8_t testCmd; -bool setON = true; -uint8_t testNodeID = 0; -uint16_t testDelay; -uint16_t testCurrentDelay; -uint8_t testPayloadLen; -uint16_t testCount; -uint16_t testSuccessCount; -uint16_t testFailedCount; -uint8_t testState = 0; -uint8_t testTxOptions; - -void -SendTestReport( - uint8_t txStatus) -{ - if (funcID_ComplHandler_Serial_API_Test != 0) - { - BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_Serial_API_Test; - BYTE_IN_AR(compl_workbuf, 1) = testCmd; - BYTE_IN_AR(compl_workbuf, 2) = testState; - BYTE_IN_AR(compl_workbuf, 3) = testNodeID; - BYTE_IN_AR(compl_workbuf, 4) = txStatus; - BYTE_IN_AR(compl_workbuf, 5) = BYTE_GET_LOW_BYTE_IN_WORD(testCount); - Request(FUNC_ID_SERIAL_API_TEST, compl_workbuf, 6); - } -} - - -void -SendTestRoundReport( - __attribute__((unused)) uint8_t txStatus) -{ - if (funcID_ComplHandler_Serial_API_Test != 0) - { - BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_Serial_API_Test; - BYTE_IN_AR(compl_workbuf, 1) = testCmd; - BYTE_IN_AR(compl_workbuf, 2) = testState; - BYTE_IN_AR(compl_workbuf, 3) = BYTE_GET_HIGH_BYTE_IN_WORD(testCount); - BYTE_IN_AR(compl_workbuf, 4) = BYTE_GET_LOW_BYTE_IN_WORD(testCount); - /* Initialy we assume every node acked, so we assume no nodemask is to be send */ - uint8_t i = 0; - if (ZW_NODE_MASK_BITS_IN(testresultnodemask, testnodemasklen)) - { - for (; i < testnodemasklen; i++) - { - BYTE_IN_AR(compl_workbuf, 6 + i) = testresultnodemask[i]; - } - BYTE_IN_AR(compl_workbuf, 5) = testnodemasklen; - i++; - } - Request(FUNC_ID_SERIAL_API_TEST, compl_workbuf, 5 + i); - } -} - - -void -ZCB_TestDelayNextSendTimeout(void) -{ - if (--testCurrentDelay == 0) - { - if (timerTestHandle != 0xff) - { - TimerCancel(timerTestHandle); - } - timerTestHandle = 0xff; - TestSend(); - } -} - - -void -ZCB_TestDelayTimeout(void) -{ - if (--testCurrentDelay == 0) - { - if (timerTestHandle != 0xff) - { - TimerCancel(timerTestHandle); - } - timerTestHandle = 0xff; - setON = !setON; - TestStartRound(); - } -} - - -bool -TestFindNextNode(void) -{ - do - { - if (ZW_NodeMaskNodeIn(testnodemask, ++testNodeID)) - { - return true; - } - } while (testNodeID < ZW_MAX_NODES); - return false; -} - - -/*=========================== MetaDataSendComplete ========================= -** Function description -** -** -** -** Side effects: -** -**--------------------------------------------------------------------------*/ -void -ZCB_TestSendComplete( - uint8_t bStatus, - __attribute__((unused)) TX_STATUS_TYPE *txStatusReport -) -{ - DPRINT("C"); - DPRINTF("%u", bStatus); - - if (bStatus == TRANSMIT_COMPLETE_OK) - { - testSuccessCount++; - } - else - { - /* Set bit indicating that node failed to acknowledge */ - ZW_NODE_MASK_SET_BIT(testresultnodemask, testNodeID); - testFailedCount++; - } - /* Should we transmit result (to host) after every transmit or do we send one frame after every round? */ - if (testCmd < 0x05) - { - /* One result frame after every transmit */ - SendTestReport(bStatus); - } - if (testState == POWERLEVEL_TEST_NODE_REPORT_ZW_TEST_INPROGRESS) - { - if (TestFindNextNode()) - { - { - testCurrentDelay = testDelay; - if (timerTestHandle != 0xff) - { - TimerCancel(timerTestHandle); - } - timerTestHandle = 0xff; - if (!testCurrentDelay) - { - testCurrentDelay++; - ZCB_TestDelayNextSendTimeout(); - } - else - { - timerTestHandle = TimerStart(ZCB_TestDelayNextSendTimeout, 1, TIMER_FOREVER); - } - } - } - else - { - if (testCmd >= 0x05) - { - /* One result frame after every round */ - SendTestRoundReport(0); - } - /* No more nodes in this round - delay (if any delay to be done) before starting next round */ - if (testCount && (--testCount != 0)) - { - testCurrentDelay = testDelay; - if (timerTestHandle != 0xff) - { - TimerCancel(timerTestHandle); - } - timerTestHandle = 0xff; - if (!testCurrentDelay) - { - testCurrentDelay++; - ZCB_TestDelayTimeout(); - } - else - { - timerTestHandle = TimerStart(ZCB_TestDelayTimeout, 1, TIMER_FOREVER); - } - } - else - { - testState = POWERLEVEL_TEST_NODE_REPORT_ZW_TEST_SUCCES; - SendTestReport(0); - } - } - } - else - { - if (timerTestHandle != 0xff) - { - TimerCancel(timerTestHandle); - } - timerTestHandle = 0xff; - SendTestReport(0); - } -} - - -/*================================= TestSend =============================== -** Function description -** Send the next data frame -** -** -** Side effects: -** -**--------------------------------------------------------------------------*/ -void -TestSend(void) -{ - uint8_t payLoadLen; - - DPRINT("N"); - - if ((testCmd == 0x03) || (testCmd == 0x04) || (testCmd == 0x07) || (testCmd == 0x08)) - { - txBuffer.ZW_BasicSetFrame.cmdClass = COMMAND_CLASS_BASIC; - txBuffer.ZW_BasicSetFrame.cmd = BASIC_SET; - txBuffer.ZW_BasicSetFrame.value = setON ? BASIC_ON : BASIC_OFF; - payLoadLen = sizeof(txBuffer.ZW_BasicSetFrame); - } - else - { - txBuffer.ZW_ManufacturerSpecificReportFrame.cmdClass = COMMAND_CLASS_MANUFACTURER_PROPRIETARY; - txBuffer.ZW_ManufacturerSpecificReportFrame.manufacturerId1 = 0x00; - txBuffer.ZW_ManufacturerSpecificReportFrame.manufacturerId2 = 0x00; - txBuffer.ZW_ManufacturerSpecificReportFrame.productId1 = 0x04; - txBuffer.ZW_ManufacturerSpecificReportFrame.productId2 = 0x81; - *(&(txBuffer.ZW_ManufacturerSpecificReportFrame.productId2) + 1) = 0x00; - *(&(txBuffer.ZW_ManufacturerSpecificReportFrame.productId2) + 2) = BYTE_GET_HIGH_BYTE_IN_WORD(testCount); //data1 - *(&(txBuffer.ZW_ManufacturerSpecificReportFrame.productId2) + 3) = BYTE_GET_LOW_BYTE_IN_WORD(testCount); //data1+1 - payLoadLen = sizeof(txBuffer.ZW_ManufacturerSpecificReportFrame); - } - /* Send meta data frame */ - // Create transmit frame package - uint8_t iFrameLength = (testPayloadLen > payLoadLen) ? testPayloadLen : payLoadLen; - SZwaveTransmitPackage FramePackage = { - .uTransmitParams.SendData.DestNodeId = testNodeID, - .uTransmitParams.SendData.FrameConfig.TransmitOptions = testTxOptions, - .uTransmitParams.SendData.FrameConfig.Handle = &ZCB_TestSendComplete, - .eTransmitType = EZWAVETRANSMITTYPE_STD, - .uTransmitParams.SendData.FrameConfig.iFrameLength = iFrameLength - }; - memcpy(&FramePackage.uTransmitParams.SendData.FrameConfig.aFrame, &txBuffer, iFrameLength); - // Put the package on queue (and dont wait for it) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); - - if (EQUEUENOTIFYING_STATUS_SUCCESS != QueueStatus) - { - ZCB_TestSendComplete(TRANSMIT_COMPLETE_NO_ACK, NULL); - } -} - - -/*============================ TestStartRound ============================ -** Start a Test round -** -** This is an application function example -** -**--------------------------------------------------------------------------*/ -void -TestStartRound(void) -{ - uint8_t bTemp; - - ZW_NODE_MASK_CLEAR(testresultnodemask, ZW_MAX_NODES / 8); - /* Fill the meta data frame with data */ - for (bTemp = 0; bTemp < (META_DATA_MAX_DATA_SIZE - sizeof(ZW_MANUFACTURER_SPECIFIC_REPORT_FRAME)); bTemp++) - { - *(&(txBuffer.ZW_ManufacturerSpecificReportFrame.productId2) + 1 + bTemp) = bTemp + 1; - } - testNodeID = 0; - /* Find first node to transmit to */ - if ((testState == POWERLEVEL_TEST_NODE_REPORT_ZW_TEST_INPROGRESS) && TestFindNextNode()) - { - /* Found a node */ - TestSend(); - } - else - { - testState = POWERLEVEL_TEST_NODE_REPORT_ZW_TEST_FAILED; - SendTestReport(0); - } -} - -ZW_ADD_CMD(FUNC_ID_SERIAL_API_TEST) -{ - /* HOST->ZW: testCmd | testDelay(MSB) | testDelay(LSB) | testPayloadLen | */ - /* testCount(MSB) | testCount(LSB) | testTxOptions | nodemasklen | testnodemask[] | funcID */ - /* testCmd = 0x01 - use sendData */ - /* testCmd = 0x02 - use sendDataMeta */ - /* testCmd = 0x03 - use sendData with Basic Set toggle ON/OFF between rounds */ - /* testCmd = 0x04 - use sendDataMeta with Basic Set toggle ON/OFF between rounds */ - /* testCmd = 0x05 - use sendData with one group result frame (serial) at every round end */ - /* testCmd = 0x06 - use sendDataMeta with one group result frame (serial) at every round end */ - /* testCmd = 0x07 - use sendData with Basic Set toggle ON/OFF and one group result frame (serial) between rounds */ - /* testCmd = 0x08 - use sendDataMeta with Basic Set toggle ON/OFF and one group result frame (serial) between rounds */ - /* ZW->HOST: RES | testStarted */ - uint8_t retVal = 0; - testCmd = frame->payload[0]; - if (testCmd && (testState != POWERLEVEL_TEST_NODE_REPORT_ZW_TEST_INPROGRESS)) - { - WORD_SET_HIGH_LOW_BYTES(testDelay, frame->payload[1], frame->payload[2]); - - testPayloadLen = frame->payload[3]; - WORD_SET_HIGH_LOW_BYTES(testCount, frame->payload[4], frame->payload[5]); - testTxOptions = frame->payload[6]; - testnodemasklen = frame->payload[7]; - /* - Boundary Check */ - if (testnodemasklen > MAX_NODEMASK_LENGTH) - { - testnodemasklen = MAX_NODEMASK_LENGTH; - } - ZW_NODE_MASK_CLEAR(testnodemask, MAX_NODEMASK_LENGTH); - for (uint8_t i = 0; i < testnodemasklen; i++) - { - BYTE_IN_AR(testnodemask, i) = frame->payload[i + 8]; - } - funcID_ComplHandler_Serial_API_Test = frame->payload[frame->payload[7] + 8]; - if (testCount != 0) - { - testFailedCount = 0; - testSuccessCount = 0; - testState = POWERLEVEL_TEST_NODE_REPORT_ZW_TEST_INPROGRESS; - TestStartRound(); - retVal = 1; - } - else - { - testState = POWERLEVEL_TEST_NODE_REPORT_ZW_TEST_FAILED; - SendTestReport(0); - return; - } - } - else - { - /* STOP test ??? */ - if (!testCmd) - { - testState = POWERLEVEL_TEST_NODE_REPORT_ZW_TEST_FAILED; - SendTestReport(0); - retVal = 1; - } - } - DoRespond(retVal); -} -#endif - - -#if SUPPORT_SERIAL_API_EXT -ZW_ADD_CMD(FUNC_ID_SERIAL_API_EXT) -{ - /* HOST->ZW: mode | data */ - /* not used in 700 series - Obsolete */ - if (frame->len > FRAME_LENGTH_MIN) - { - switch (frame->payload[0]) - { - /* since the 700 / 800 series targets don't support the command, - then all values of the mode parameters should return zero*/ - case 0: - case 1: - { - BYTE_IN_AR(compl_workbuf, 0) = 0; - DoRespond_workbuf(1); - } - break; - default: - { - DoRespond(0); - } - break; - } - } -} -#endif - - -#if SUPPORT_ZW_GET_RANDOM -static uint8_t GetRandom(uint8_t noOfRndBytes, uint8_t* rndBytes) -{ - SZwaveCommandPackage GetRandom = { - .eCommandType = EZWAVECOMMANDTYPE_GENERATE_RANDOM, - .uCommandParams.GenerateRandom.iLength = noOfRndBytes}; - - // Put the Command on queue (and dont wait for it, queue must be empty) - if (EQUEUENOTIFYING_STATUS_SUCCESS == QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&GetRandom, 0)) - { - // Wait for protocol to handle command - SZwaveCommandStatusPackage Random = { 0 }; - if (GetCommandResponse(&Random, EZWAVECOMMANDSTATUS_GENERATE_RANDOM)) - { - memcpy(rndBytes, Random.Content.GenerateRandomStatus.aRandomNumber, Random.Content.GenerateRandomStatus.iLength); - return Random.Content.GenerateRandomStatus.iLength; - } - } - return false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_GET_RANDOM) -{ - /* HOST->ZW: noRandomBytes - Optional if not present or equal ZERO then */ - /* 2 random bytes are returned. */ - /* Range 1..32 random bytes are supported */ - /* ZW->HOST: RES | randomGenerationSuccess | noRandomBytesGenerated | noRandomGenerated[] */ - uint8_t noRndBytes = frame->payload[0]; - if ((frame->len > FRAME_LENGTH_MIN) && (noRndBytes != 0)) - { - if (noRndBytes > 32) - { - noRndBytes = 32; - } - } - else - { - noRndBytes = 2; - } - // Prepare failed return - BYTE_IN_AR(compl_workbuf, 0) = false; - BYTE_IN_AR(compl_workbuf, 1) = 0; - uint8_t rndBytes = GetRandom(noRndBytes, &compl_workbuf[2]); - if (rndBytes) - { - BYTE_IN_AR(compl_workbuf, 0) = true; - BYTE_IN_AR(compl_workbuf, 1) = rndBytes; - } - rndBytes += 2; - DoRespond_workbuf(rndBytes); -} -#endif - - -#if SUPPORT_ZW_AES_ECB -static void AesEcb(uint8_t *key, uint8_t *InputData, uint8_t *outData) -{ - SZwaveCommandPackage cmdPackage = {.eCommandType = EZWAVECOMMANDTYPE_AES_ECB}; - memcpy(cmdPackage.uCommandParams.AesEcb.key, key, sizeof(cmdPackage.uCommandParams.AesEcb.key)); - memcpy(cmdPackage.uCommandParams.AesEcb.inputData, InputData, sizeof(cmdPackage.uCommandParams.AesEcb.inputData)); - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 500); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); - SZwaveCommandStatusPackage cmdStatus = { 0 }; - if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_AES_ECB)) - { - memcpy(outData, cmdStatus.Content.AesEcbStatus.outputData, 16); - return; - - } - ASSERT(false); // FIXME We should have more intelligent error handling, we shouldnt assert here. -} - -ZW_ADD_CMD(FUNC_ID_ZW_AES_ECB) -{ - /* HOST->ZW: key[] (16 bytes) | inputDat[] (16 bytes) */ - /* ZW->HOST: RES | outdata[] (16 bytes) */ - AesEcb(&frame->payload[0], &frame->payload[16], compl_workbuf); - DoRespond_workbuf(16); -} -#endif - - -#if SUPPORT_ZW_AUTO_PROGRAMMING -ZW_ADD_CMD(FUNC_ID_AUTO_PROGRAMMING) -{ - //Reboot into bootloader. Calls zpal_bootloader_reboot_and_install(); - SZwaveCommandPackage Command = { - .eCommandType = EZWAVECOMMANDTYPE_BOOTLOADER_REBOOT - }; - QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&Command, 0); -} -#endif - - -#ifdef SUPPORT_ZW_SET_LISTEN_BEFORE_TALK_THRESHOLD -ZW_ADD_CMD(FUNC_ID_ZW_SET_LISTEN_BEFORE_TALK_THRESHOLD) -{ - /* HOST->ZW: bChannel | bThreshold */ - /* ZW->HOST: RES | true */ - uint8_t length; - func_id_set_listen_before_talk(frame_payload_len(frame), frame->payload, compl_workbuf, &length); - DoRespond_workbuf(length); -} -#endif - - -#ifdef SUPPORT_ZW_NETWORK_MANAGEMENT_SET_MAX_INCLUSION_REQUEST_INTERVALS -static bool SetMaxInclReqIntervals( uint32_t maxInclReqIntervals) -{ - SZwaveCommandPackage setMaxInclusionRequestIntervals = { - .eCommandType = EZWAVECOMMANDTYPE_ZW_SET_MAX_INCL_REQ_INTERVALS, - .uCommandParams.SetMaxInclReqInterval.inclusionRequestInterval = maxInclReqIntervals}; - - // Put the Command on queue (and dont wait for it, queue must be empty) - if (EQUEUENOTIFYING_STATUS_SUCCESS == QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&setMaxInclusionRequestIntervals, 0)) - { - // Wait for protocol to handle command - SZwaveCommandStatusPackage result = { 0 }; - if (GetCommandResponse(&result, EZWAVECOMMANDSTATUS_ZW_SET_MAX_INCL_REQ_INTERVALS)) - { - if(result.Content.NetworkManagementStatus.statusInfo[0]) - { - return true; - } - } - } - return false; -} - -ZW_ADD_CMD(FUNC_ID_ZW_NETWORK_MANAGEMENT_SET_MAX_INCLUSION_REQUEST_INTERVALS) -{ - /* HOST->ZW: bChannel | bThreshold */ - /* ZW->HOST: RES | true */ - const uint8_t retVal = SetMaxInclReqIntervals(frame->payload[0]); - DoRespond(retVal); -} -#endif - -// Added to make sure that capabilities is correct. -ZW_ADD_CMD(FUNC_ID_SERIAL_API_STARTED) -{ -} - -// Added to make sure that capabilities is correct. -ZW_ADD_CMD(FUNC_ID_ZW_APPLICATION_UPDATE) -{ -} - -// Added to make sure that capabilities is correct. -ZW_ADD_CMD(FUNC_ID_APPLICATION_COMMAND_HANDLER_BRIDGE) -{ -} - -// Added to make sure that capabilities is correct. -ZW_ADD_CMD(FUNC_ID_ZW_GET_PROTOCOL_STATUS) -{ -} diff --git a/src/zwave_ncp_serial_api_controller/cmd_handlers.h b/src/zwave_ncp_serial_api_controller/cmd_handlers.h deleted file mode 100644 index a76f2717..00000000 --- a/src/zwave_ncp_serial_api_controller/cmd_handlers.h +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @file - * @copyright 2022 Silicon Laboratories Inc. - */ - -#ifndef CMD_HANDLER_H_ -#define CMD_HANDLER_H_ - -#include -#include - -#ifdef ZW_CONTROLLER -#include -#endif - -/** - * @addtogroup Apps - * @{ - * @addtogroup SerialAPI - * @{ - */ - -typedef void (*cmd_handler_t)(const comm_interface_frame_ptr); - -typedef struct -{ - uint8_t cmd; - cmd_handler_t pHandler; -} -cmd_handler_map_t; - -#define CMD_HANDLER_SECTION "_cmd_handlers" - -#define ZW_ADD_CMD(cmd) \ - static void cmd_handler_fcn_##cmd(__attribute__((unused)) const comm_interface_frame_ptr frame); /* Prototype */ \ - static const cmd_handler_map_t cmd_handler_##cmd __attribute__((__used__, __section__( CMD_HANDLER_SECTION ))) = {cmd,cmd_handler_fcn_##cmd}; \ - static void cmd_handler_fcn_##cmd(__attribute__((unused)) const comm_interface_frame_ptr frame) - -/** - * Invoke command handler. - * - * @param[in] frame Frame - * @return true if handler for given @p frame was invoked, false if no handler was found - */ -bool invoke_cmd_handler(const comm_interface_frame_ptr frame); - -typedef void * cmd_context_t; - -typedef bool (*cmd_foreach_callback_t)(cmd_handler_map_t const * const p_cmd_entry, cmd_context_t context); - -/** - * Invokes callback for each registered command. - * - * Will stop if the callback returns true. - * - * @param callback Callback function to invoke. - * @param context Context to pass on to the callback function. - */ -void cmd_foreach(cmd_foreach_callback_t callback, cmd_context_t context); - -#ifdef ZW_CONTROLLER -void ZCB_ComplHandler_ZW_NodeManagement(LEARN_INFO_T *statusInfo); -#endif - -/** - * @} - * @} - */ - -#endif /* CMD_HANDLER_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/cmd_handlers_invoker.c b/src/zwave_ncp_serial_api_controller/cmd_handlers_invoker.c deleted file mode 100644 index 2fdc8244..00000000 --- a/src/zwave_ncp_serial_api_controller/cmd_handlers_invoker.c +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @file cmd_handlers_invoker.c - * @copyright 2022 Silicon Laboratories Inc. - */ - -#include "cmd_handlers.h" -#include "Assert.h" - -/** - * This is the first of the registered handlers - */ -extern const cmd_handler_map_t __start__cmd_handlers; -#define cmd_handlers_start __start__cmd_handlers -/** - * This marks the end of the handlers. The element - * after the last element. This means that this element - * is not valid. - */ -extern const cmd_handler_map_t __stop__cmd_handlers; -#define cmd_handlers_stop __stop__cmd_handlers - - -bool invoke_cmd_handler(const comm_interface_frame_ptr frame) -{ - cmd_handler_map_t const * iter = &cmd_handlers_start; - for ( ; iter < &cmd_handlers_stop; ++iter) - { - if (iter->cmd == frame->cmd) { - iter->pHandler(frame); - return true; - } - } - - return false; -} - -void cmd_foreach(cmd_foreach_callback_t callback, cmd_context_t context) -{ - ASSERT(callback != NULL); - cmd_handler_map_t const * iter = &cmd_handlers_start; - for ( ; iter < &cmd_handlers_stop; ++iter) - { - if (true == callback(iter, context)) { - break; - } - } -} diff --git a/src/zwave_ncp_serial_api_controller/cmds_dcdc.c b/src/zwave_ncp_serial_api_controller/cmds_dcdc.c deleted file mode 100644 index bc9c76af..00000000 --- a/src/zwave_ncp_serial_api_controller/cmds_dcdc.c +++ /dev/null @@ -1,72 +0,0 @@ -/** - * @file - * Offers DCDC configuration for Silabs targets only. - * @attention Must be linked for Silabs build targets only. - * @copyright 2022 Silicon Laboratories Inc. - */ -#include -#include "cmd_handlers.h" -#include "app.h" -#include "sl_dcdc.h" -#include "ZW_typedefs.h" -#include "ZW_SerialAPI.h" -#include "zpal_nvm.h" -#include "serialapi_file.h" -#include "ZAF_nvm_app.h" - -#define DCDC_CONFIG_UNALTERED 0xff - -// 0x00 Auto, 0x01 Bypass, 0x02 LowNoise, 0xFF Original default - -#define FILE_ID_DCDC_CONFIGURATION FILE_ID_PROPRIETARY_1 - -typedef struct -{ - uint8_t dcdc_config; -} -dcdc_configuration_file_t; - -#define DCDC_CONFIGURATION_FILE_SIZE (sizeof(dcdc_configuration_file_t)) - -static dcdc_configuration_file_t dcdc_configuration_file; - -bool SetDcDcConfig(uint8_t DcdcConfig) -{ - bool result = sl_dcdc_config_set(DcdcConfig); - if (true == result) - { - dcdc_configuration_file.dcdc_config = DcdcConfig; - zpal_status_t status = ZAF_nvm_app_write( FILE_ID_DCDC_CONFIGURATION, - &dcdc_configuration_file, - DCDC_CONFIGURATION_FILE_SIZE); - return (ZPAL_STATUS_OK == status); - } - return false; -} - -uint8_t GetDcDcConfig(void) -{ - ZAF_nvm_app_read(FILE_ID_DCDC_CONFIGURATION, &dcdc_configuration_file, DCDC_CONFIGURATION_FILE_SIZE); - return dcdc_configuration_file.dcdc_config; -} - -void SerialAPI_hw_psu_init(void) -{ - uint8_t dcdcConfig = GetDcDcConfig(); - if (DCDC_CONFIG_UNALTERED != dcdcConfig) - { - sl_dcdc_config_set(dcdcConfig); - } -} - -ZW_ADD_CMD(FUNC_ID_GET_DCDC_CONFIG) -{ - uint8_t retVal = GetDcDcConfig(); - DoRespond(retVal); -} - -ZW_ADD_CMD(FUNC_ID_SET_DCDC_CONFIG) -{ - uint8_t retVal = SetDcDcConfig(frame->payload[0]); - DoRespond(retVal); -} diff --git a/src/zwave_ncp_serial_api_controller/cmds_management.c b/src/zwave_ncp_serial_api_controller/cmds_management.c deleted file mode 100644 index 2143b25a..00000000 --- a/src/zwave_ncp_serial_api_controller/cmds_management.c +++ /dev/null @@ -1,585 +0,0 @@ -/** - * @file cmds_management.c - * @copyright 2022 Silicon Laboratories Inc. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//#define DEBUGPRINT -#include -#include "zw_build_no.h" - -#ifdef ZW_CONTROLLER -#include -#endif // ZW_CONTROLLER - -#define PUK_OFFSET 0x23 -#define PRK_OFFSET 0x43 -#define HW_VER_OFFSET 0x70 -#define HW_VER_SIZE 1 - -/** Find the byte in which SERIAL_API_SETUP command will be written */ -#define BYTE_INDEX(x) ((x - 1) / 8) -/** Find the offset in the byte of SERIAL_API_SETUP command */ -#define BYTE_OFFSET(x) (1 << ((x - 1) % 8)) -/** Add the SERIAL_API_SETUP command to the bitmask array */ -#define BITMASK_ADD_CMD(bitmask, cmd) (bitmask[BYTE_INDEX(cmd)] |= BYTE_OFFSET(cmd)) - -#ifndef MAX -/** Return the larger of two values. - * - * \param x An integer-valued expression without side effects. - * \param y An integer-valued expression without side effects. - * - * \return The larger of \p x and \p y. - */ -#define MAX( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) -#endif // MAX - -static const serial_api_setup_cmd_get_region_info_answer_t regions_info[] = { - {.region=REGION_EU, .zw_classic=1, .zw_lr=0, .reserved=0, .included_region=REGION_UNDEFINED}, - {.region=REGION_US, .zw_classic=1, .zw_lr=0, .reserved=0, .included_region=REGION_UNDEFINED}, - {.region=REGION_ANZ, .zw_classic=1, .zw_lr=0, .reserved=0, .included_region=REGION_UNDEFINED}, - {.region=REGION_HK, .zw_classic=1, .zw_lr=0, .reserved=0, .included_region=REGION_UNDEFINED}, - {.region=REGION_IN, .zw_classic=1, .zw_lr=0, .reserved=0, .included_region=REGION_UNDEFINED}, - {.region=REGION_IL, .zw_classic=1, .zw_lr=0, .reserved=0, .included_region=REGION_UNDEFINED}, - {.region=REGION_RU, .zw_classic=1, .zw_lr=0, .reserved=0, .included_region=REGION_UNDEFINED}, - {.region=REGION_CN, .zw_classic=1, .zw_lr=0, .reserved=0, .included_region=REGION_UNDEFINED}, - {.region=REGION_US_LR, .zw_classic=1, .zw_lr=1, .reserved=0, .included_region=REGION_US}, - {.region=REGION_JP, .zw_classic=1, .zw_lr=0, .reserved=0, .included_region=REGION_UNDEFINED}, - {.region=REGION_KR, .zw_classic=1, .zw_lr=0, .reserved=0, .included_region=REGION_UNDEFINED}, -}; -#define REGIONS_INFO_COUNT (sizeof(regions_info)/sizeof(regions_info[0])) -//default answer in case the requested region is not found in the regions_info table. -static const serial_api_setup_cmd_get_region_info_answer_t unknown_region_info = -{ - .region = REGION_UNDEFINED, - .zw_classic = 0, - .zw_lr = 0, - .reserved = 0, - .included_region = 0 -}; -#define REGION_INFO_SIZE (sizeof(serial_api_setup_cmd_get_region_info_answer_t)) - -void func_id_serial_api_get_init_data(__attribute__((unused)) uint8_t inputLength, - __attribute__((unused)) const uint8_t *pInputBuffer, - uint8_t *pOutputBuffer, - uint8_t *pOutputLength) -{ - *pOutputLength = 5; - BYTE_IN_AR(pOutputBuffer, 0) = SERIAL_API_VER; - BYTE_IN_AR(pOutputBuffer, 1) = 0; /* Flag byte - default: controller api, no timer support, no primary, no SUC */ -#ifdef ZW_CONTROLLER - if (!IsPrimaryController()) - { - BYTE_IN_AR(pOutputBuffer, 1) |= GET_INIT_DATA_FLAG_SECONDARY_CTRL; /* Set Primary/secondary bit */ - } - if (GetControllerCapabilities() & CONTROLLER_IS_SUC) /* if (ZW_IS_SUC_ACTIVE()) */ - { - BYTE_IN_AR(pOutputBuffer, 1) |= GET_INIT_DATA_FLAG_IS_SUC; /* Set SUC bit if active */ - } - - /* compl_workbuf[1] is already set to controller api*/ - BYTE_IN_AR(pOutputBuffer, 2) = ZW_MAX_NODES / 8; /* node bitmask length */ - - /* Clear the buffer */ - memset(pOutputBuffer + 3, 0, ZW_MAX_NODES / 8); - - /* Next ZW_MAX_NODES/8 = 29 bytes of compl_workbuf reserved for node bitmask */ - - Get_included_nodes(pOutputBuffer + 3); - - BYTE_IN_AR(pOutputBuffer, 3 + (ZW_MAX_NODES / 8)) = zpal_get_chip_type(); - BYTE_IN_AR(pOutputBuffer, 4 + (ZW_MAX_NODES / 8)) = zpal_get_chip_revision(); - *pOutputLength += (ZW_MAX_NODES / 8); - ASSERT(*pOutputLength <= 34); // Elsewhere, like in zwapi_init.c, the pOutputBuffer is hardcoded to 34 bytes in lenght. -#else - BYTE_IN_AR(pOutputBuffer, 1) |= GET_INIT_DATA_FLAG_SLAVE_API; /* Flag byte */ - BYTE_IN_AR(pOutputBuffer, 2) = 0; /* node bitmask length */ - BYTE_IN_AR(pOutputBuffer, 3) = zpal_get_chip_type(); - BYTE_IN_AR(pOutputBuffer, 4) = zpal_get_chip_revision(); -#endif -} - -#ifdef ZW_CONTROLLER -void func_id_serial_api_get_LR_nodes(__attribute__((unused)) uint8_t inputLength, - const uint8_t *pInputBuffer, - uint8_t *pOutputBuffer, - uint8_t *pOutputLength) -{ - //RES | 0xDA | MORE_NODES | BITMASK_OFFSET | BITMASK_LEN | BITMASK_ARRAY - - /* - * The current implementation of this function is made on the fact - * that there is no support in the Z-Wave protocol code for more than 1024 Long Range nodes in total. - * This Assert is here to remind us to update this function, if in the future the number of supported nodes increases. - * In which case the MAX_LR_NODEMASK_LENGTH define will become greater than 128 - */ - STATIC_ASSERT(MAX_LR_NODEMASK_LENGTH <= 128, STATIC_ASSERT_MAX_LR_NODEMASK_LENGTH_to_big); - - uint8_t bitmaskOffset = pInputBuffer[0]; - *pOutputLength = 3 + MAX_LR_NODEMASK_LENGTH; - BYTE_IN_AR(pOutputBuffer, 0) = 0; // MORE_NODES - No more nodes for now. - // Allowed values for bitmaskOffset are 0, 1, 2, 3 - if (bitmaskOffset > 3) - { - bitmaskOffset = 3; - } - BYTE_IN_AR(pOutputBuffer, 1) = bitmaskOffset; - - // Clean output buffer first - memset(pOutputBuffer + 3, 0, MAX_LR_NODEMASK_LENGTH); - - BYTE_IN_AR(pOutputBuffer, 2) = MAX_LR_NODEMASK_LENGTH; // BITMASK_LEN hardcoded - if (bitmaskOffset < 1) - { - Get_included_lr_nodes(pOutputBuffer + 3); - } -} -#endif - -extern bool bTxStatusReportEnabled; - -zpal_tx_power_t -GetMaxSupportedTxPower(void) -{ - const SApplicationHandles *pAppHandles = ZAF_getAppHandle(); - SZwaveCommandPackage CommandPackage = { - .eCommandType = EZWAVECOMMANDTYPE_ZW_GET_TX_POWER_MAX_SUPPORTED - }; - // Put the Command on queue (and dont wait for it, queue must be empty) - if (EQUEUENOTIFYING_STATUS_SUCCESS == QueueNotifyingSendToBack(pAppHandles->pZwCommandQueue, (uint8_t *)&CommandPackage, 0)) - { - // Wait for protocol to handle command - SZwaveCommandStatusPackage result = { 0 }; - if (GetCommandResponse(&result, EZWAVECOMMANDSTATUS_ZW_GET_TX_POWER_MAX_SUPPORTED)) - { - return result.Content.GetTxPowerMaximumSupported.tx_power_max_supported; - } - } - return ZW_TX_POWER_14DBM; -} - -void func_id_serial_api_setup(uint8_t inputLength, - const uint8_t *pInputBuffer, - uint8_t *pOutputBuffer, - uint8_t *pOutputLength) -{ - uint8_t i=0; - uint8_t cmdRes; - zpal_radio_region_t rfRegion; - zpal_tx_power_t iPowerLevel, iPower0dbmMeasured; - - /* We assume operation is nonesuccessful */ - cmdRes = false; - - if (1 > inputLength) - { - /* Command length must be at least 1 byte. Return with negative response in the out buffer */ - BYTE_IN_AR(pOutputBuffer, i++) = cmdRes; - *pOutputLength = i; - return; - } - - BYTE_IN_AR(pOutputBuffer, i++) = pInputBuffer[0]; /* Set output command ID equal input command ID */ - switch (pInputBuffer[0]) - { - - /* Report which SerialAPI Setup commands are supported beside the SERIAL_API_SETUP_CMD_SUPPORTED */ - case SERIAL_API_SETUP_CMD_SUPPORTED: - /* HOST->ZW: SERIAL_API_SETUP_CMD_SUPPORTED */ - /* ZW->HOST: SERIAL_API_SETUP_CMD_SUPPORTED | - * (SERIAL_API_SETUP_CMD_TX_STATUS_REPORT + SERIAL_API_SETUP_CMD_RF_REGION_GET + SERIAL_API_SETUP_CMD_RF_REGION_SET + - * SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET + SERIAL_API_SETUP_CMD_TX_POWERLEVEL_GET + - * SERIAL_API_SETUP_CMD_TX_GET_MAX_PAYLOAD_SIZE + SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET) | */ - /* supportedBitmask */ - - BYTE_IN_AR(pOutputBuffer, i++) = SERIAL_API_SETUP_CMD_TX_STATUS_REPORT | SERIAL_API_SETUP_CMD_RF_REGION_GET | - SERIAL_API_SETUP_CMD_RF_REGION_SET | SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET | - SERIAL_API_SETUP_CMD_TX_POWERLEVEL_GET | SERIAL_API_SETUP_CMD_TX_GET_MAX_PAYLOAD_SIZE | - SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET | SERIAL_API_SETUP_CMD_SUPPORTED; - - /* Report all supported commands as bitmask of their values */ - uint8_t supportedBitmask[32]; - memset(supportedBitmask, 0, sizeof(supportedBitmask)); - /* For each command in eSerialAPISetupCmd, find a byte number in supportedBitmask where it should be, - * and position (offset) in it and then add it to the array. */ - BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_SUPPORTED); // (1) - BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_TX_STATUS_REPORT); // (2) - BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET); // (4) - BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_TX_POWERLEVEL_GET); // (8) - BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_TX_GET_MAX_PAYLOAD_SIZE); // (16) - BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_RF_REGION_GET); // (32) - BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_RF_REGION_SET); // (64) - BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET); // (128) - - BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_SET); // (3) - BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_GET); // (5) - BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_TX_GET_MAX_LR_PAYLOAD_SIZE); // (17) - BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET_16_BIT); // (18) - BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_TX_POWERLEVEL_GET_16_BIT); // (19) - BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_GET_SUPPORTED_REGION); // (21) - BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_GET_REGION_INFO); // (22) - - /* Currently supported command with the highest value is SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET. - No commands after it. */ - for (int j = 0; j <= SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET/8; j++) - { - BYTE_IN_AR(pOutputBuffer, i++) = supportedBitmask[j]; - } - break; - - case SERIAL_API_SETUP_CMD_TX_STATUS_REPORT: - /* HOST->ZW: SERIAL_API_SETUP_CMD_TX_STATUS_REPORT | EnableTxStatusReport */ - /* ZW->HOST: SERIAL_API_SETUP_CMD_TX_STATUS_REPORT | cmdRes */ - if (SERIAL_API_SETUP_CMD_TX_STATUS_REPORT_CMD_LENGTH_MIN <= inputLength) - { - /* Do we enable or disable */ - bTxStatusReportEnabled = (0 != pInputBuffer[1]); - /* Operation successful */ - cmdRes = true; - } - BYTE_IN_AR(pOutputBuffer, i++) = cmdRes; - break; - - /* Report RF region configuration */ - case SERIAL_API_SETUP_CMD_RF_REGION_GET: - /* HOST->ZW: SERIAL_API_SETUP_CMD_RF_REGION_GET */ - /* ZW->HOST: SERIAL_API_SETUP_CMD_RF_REGION_GET | rfRRegion */ - if (false == ReadApplicationRfRegion(&rfRegion)) - { - /* Error reading value from flash. (Should not happen). Return undefined value. */ - rfRegion = REGION_UNDEFINED; - } - BYTE_IN_AR(pOutputBuffer, i++) = rfRegion; - break; - - /* Set RF region configuration */ - case SERIAL_API_SETUP_CMD_RF_REGION_SET: - /* HOST->ZW: SERIAL_API_SETUP_CMD_RF_REGION_SET | rfRegion */ - /* ZW->HOST: SERIAL_API_SETUP_CMD_RF_REGION_SET | cmdRes */ - if (SERIAL_API_SETUP_CMD_RF_REGION_SET_CMD_LENGTH_MIN <= inputLength) - { - rfRegion = pInputBuffer[1]; - /* Check if the RF Region value is valid, and then store it in flash */ - if ((rfRegion <= REGION_US_LR) || (rfRegion == REGION_JP) || (rfRegion == REGION_KR)) - { - /* Save into nvm */ - cmdRes = SaveApplicationRfRegion(rfRegion); - } - } - BYTE_IN_AR(pOutputBuffer, i++) = cmdRes; - break; - - case SERIAL_API_SETUP_CMD_GET_SUPPORTED_REGION: - { - uint8_t supported_region_count = 0; - uint8_t region_count_index = i; - i++; //skip suported region count, move to first region value; - for (rfRegion = REGION_EU; rfRegion <= REGION_US_LR; rfRegion++) { - if (true == isRfRegionValid(rfRegion)) { - supported_region_count++; - pOutputBuffer[i] = (uint8_t) rfRegion; - i++; - } - } - for (rfRegion = REGION_JP; rfRegion <= REGION_KR; rfRegion++) { - if (true == isRfRegionValid(rfRegion)) { - supported_region_count++; - pOutputBuffer[i] = (uint8_t) rfRegion; - i++; - } - } - pOutputBuffer[region_count_index] = supported_region_count; - break; - } - - case SERIAL_API_SETUP_CMD_GET_REGION_INFO: - { - uint8_t info_idx; - //search for the requested region in the regions_info table. - for (info_idx = 0; info_idx < REGIONS_INFO_COUNT; info_idx++) { - if (regions_info[info_idx].region == pInputBuffer[SAPI_SETUP_GET_REGION_INFO_RX_IDX_REGION]) { - break; - } - } - // Copy the answer in the output buffer. - if (info_idx < REGIONS_INFO_COUNT) { - memcpy(&(pOutputBuffer[i]), &(regions_info[info_idx]), REGION_INFO_SIZE); - } else { - //region not found, answer the unknown region info. - memcpy(&(pOutputBuffer[i]), &unknown_region_info, REGION_INFO_SIZE); - } - i += REGION_INFO_SIZE; - break; - } - - case SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET: - { - zpal_tx_power_t iTxPower, iAdjust; - /** - * HOST->ZW: SERIAL_API_SETUP_CMD_TX_POWER_SET | NormalTxPowerLevel | Measured0dBmPower - * ZW->HOST: SERIAL_API_SETUP_CMD_TX_POWER_SET | cmdRes - */ - if (SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET_CMD_LENGTH_MIN <= inputLength) - { - iTxPower = (int8_t)pInputBuffer[1]; - iAdjust = (int8_t)pInputBuffer[2]; - /** - * The min and max boundaries of int8_t are valid boundaries of the parameters that are being stored. - * However, this command does not support a higher value than 127 deci dBm or lower than -127 deci dBm - * for the parameters as a limitation of this SerialAPI command. - * - * Please use SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET_16_BIT which support our entire tx power range. - */ - cmdRes = SaveApplicationTxPowerlevel(iTxPower, iAdjust); - } - BYTE_IN_AR(pOutputBuffer, i++) = cmdRes; // true if success - break; - } - - case SERIAL_API_SETUP_CMD_TX_POWERLEVEL_GET: - /** - * HOST->ZW: SERIAL_API_SETUP_CMD_TX_POWER_GET - * ZW->HOST: SERIAL_API_SETUP_CMD_TX_POWER_GET | NormalTxPowerLevel | Measured0dBmPower - */ - ReadApplicationTxPowerlevel(&iPowerLevel, &iPower0dbmMeasured); - - /** - * This SerialAPI command has the following limitation that it cannot retrieve stored tx power values that are - * larger than 127 deci dBm or lower than -127 deci dBm. - */ - - // Clamp values to fit into the return parameter type of int8_t. - if (iPowerLevel > INT8_MAX) { - iPowerLevel = INT8_MAX; - } else if (iPowerLevel < INT8_MIN) { - iPowerLevel = INT8_MIN; - } - - if (iPower0dbmMeasured > INT8_MAX) { - iPower0dbmMeasured = INT8_MAX; - } else if (iPower0dbmMeasured < INT8_MIN) { - iPower0dbmMeasured = INT8_MIN; - } - - BYTE_IN_AR(pOutputBuffer, i++) = (uint8_t)iPowerLevel; - BYTE_IN_AR(pOutputBuffer, i++) = (uint8_t)iPower0dbmMeasured; - break; - - case SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET_16_BIT: - { - zpal_tx_power_t iTxPower, iAdjust; - zpal_tx_power_t iTxPowerMaxSupported; - /** - * HOST->ZW: SERIAL_API_SETUP_CMD_TX_POWER_SET | NormalTxPowerLevel (MSB) |NormalTxPowerLevel (LSB) | Measured0dBmPower (MSB)| Measured0dBmPower (LSB) - * ZW->HOST: SERIAL_API_SETUP_CMD_TX_POWER_SET | cmdRes - */ - if (SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET_CMD_LENGTH_MIN <= inputLength) - { - iTxPower = (zpal_tx_power_t)GET_16BIT_VALUE(&pInputBuffer[1]); - iAdjust = (zpal_tx_power_t)GET_16BIT_VALUE(&pInputBuffer[3]); - iTxPowerMaxSupported = GetMaxSupportedTxPower(); - - /** - * Only allow power level between -10dBm and 14 or 20dBm if 20dBm OPN used (API is in deci dBm) - * Only allow measured0dBmPower level between -10dBm and 10dBm - */ - if (( iTxPower >= -ZW_TX_POWER_10DBM) - && (iTxPower <= iTxPowerMaxSupported) - && (iAdjust >= -ZW_TX_POWER_10DBM) - && (iAdjust <= ZW_TX_POWER_10DBM) - ) - { - cmdRes = SaveApplicationTxPowerlevel(iTxPower, iAdjust); - } - } - BYTE_IN_AR(pOutputBuffer, i++) = cmdRes; // true if success - break; - } - - case SERIAL_API_SETUP_CMD_TX_POWERLEVEL_GET_16_BIT: - /** - * HOST->ZW: SERIAL_API_SETUP_CMD_TX_POWER_GET_2 - * ZW->HOST: SERIAL_API_SETUP_CMD_TX_POWER_GET_2 | NormalTxPowerLevel (16bit) | Measured0dBmPower (16bit) - */ - ReadApplicationTxPowerlevel(&iPowerLevel, &iPower0dbmMeasured); - BYTE_IN_AR(pOutputBuffer, i++) = (uint8_t)((iPowerLevel >> 8) & 0xFF); // Big-endian - BYTE_IN_AR(pOutputBuffer, i++) = (uint8_t)(iPowerLevel & 0xFF); - BYTE_IN_AR(pOutputBuffer, i++) = (uint8_t)((iPower0dbmMeasured >> 8) & 0xFF); - BYTE_IN_AR(pOutputBuffer, i++) = (uint8_t)(iPower0dbmMeasured & 0xFF); - break; - - case SERIAL_API_SETUP_CMD_TX_GET_MAX_PAYLOAD_SIZE: - BYTE_IN_AR(pOutputBuffer, i++) = (uint8_t)ZAF_getAppHandle()->pNetworkInfo->MaxPayloadSize; - break; - - case SERIAL_API_SETUP_CMD_TX_GET_MAX_LR_PAYLOAD_SIZE: - BYTE_IN_AR(pOutputBuffer, i++) = (uint8_t)ZAF_getAppHandle()->pLongRangeInfo->MaxLongRangePayloadSize; - break; - - /* Set the Node ID base type */ - case SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET: - /* HOST->ZW: SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET | type */ - /* ZW->HOST: SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET | cmdRes */ - nodeIdBaseType = SERIAL_API_SETUP_NODEID_BASE_TYPE_DEFAULT; - if ( (SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET_CMD_LENGTH_MIN <= inputLength) && - (0 < pInputBuffer[1]) && - (SERIAL_API_SETUP_NODEID_BASE_TYPE_LAST > pInputBuffer[1]) ) - { - /* Set the global Node ID base type if input value is valid */ - nodeIdBaseType = pInputBuffer[1]; - SaveApplicationNodeIdBaseType(nodeIdBaseType); - cmdRes = true; - } - BYTE_IN_AR(pOutputBuffer, i++) = cmdRes; - break; - case SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_SET: - { - /** - * HOST->ZW: SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_SET | maxtxpower (16-bit) - * ZW->HOST: SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_SET | cmdRes - */ - zpal_tx_power_t iTxPower; - zpal_tx_power_t iTxPowerMaxSupported; - - if (SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET_CMD_LENGTH_MIN <= inputLength) - { - iTxPower = (zpal_tx_power_t)GET_16BIT_VALUE(&pInputBuffer[1]); - iTxPowerMaxSupported = GetMaxSupportedTxPower(); - - /** - * Only allow power level between -10dBm and 14 or 20dBm if 20dBm OPN used (API is in deci dBm) - */ - if (( iTxPower >= -ZW_TX_POWER_10DBM) - && (iTxPower <= iTxPowerMaxSupported) - ) - { - cmdRes = SaveApplicationMaxLRTxPwr(iTxPower); - } - } - BYTE_IN_AR(pOutputBuffer, i++) = cmdRes; // true if success - break; - } - - case SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_GET: - /** - * HOST->ZW: SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_GET - * ZW->HOST: SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_GET | maxtxpower (16-bit) - */ - { - int16_t readout; - ReadApplicationMaxLRTxPwr(&readout); - BYTE_IN_AR(pOutputBuffer, i++) = (uint8_t)((readout >> 8) & 0xFF); - BYTE_IN_AR(pOutputBuffer, i++) = (uint8_t)(readout & 0xFF); - } - break; - - default: - /* HOST->ZW: [SomeUnsupportedCmd] | [SomeData] */ - /* ZW->HOST: SERIAL_API_SETUP_CMD_UNSUPPORTED | [SomeUnsupportedCmd] */ - /* All other commands are unsupported */ - BYTE_IN_AR(pOutputBuffer, 0) = SERIAL_API_SETUP_CMD_UNSUPPORTED; - BYTE_IN_AR(pOutputBuffer, i++) = pInputBuffer[0]; - break; - } - - *pOutputLength = i; -} - -void func_id_serial_api_get_nvr(__attribute__((unused)) uint8_t inputLength, - const uint8_t *pInputBuffer, - uint8_t *pOutputBuffer, - uint8_t *pOutputLength) -{ - uint8_t offset = pInputBuffer[0]; - uint8_t bLength = pInputBuffer[1]; - uint8_t dataLen = 0; - if (PUK_OFFSET == offset) - { - dataLen = bLength; - if (TOKEN_MFG_ZW_PUK_SIZE < bLength) - { - dataLen = TOKEN_MFG_ZW_PUK_SIZE; - } - ZW_GetMfgTokenData(pOutputBuffer, TOKEN_MFG_ZW_PUK_ID, dataLen); - } - else if (PRK_OFFSET == offset) - { - dataLen = bLength; - if (TOKEN_MFG_ZW_PRK_SIZE < bLength) - { - dataLen = TOKEN_MFG_ZW_PRK_SIZE; - } - ZW_GetMfgTokenData(pOutputBuffer, TOKEN_MFG_ZW_PRK_ID, dataLen); - } - else if (HW_VER_OFFSET == offset) - { - dataLen = bLength; - if (HW_VER_SIZE < bLength) - { - dataLen = HW_VER_SIZE; - } - *pOutputBuffer = 0xFF; - } - *pOutputLength = dataLen; -} - -void func_id_zw_get_protocol_version(uint8_t inputLength, - const uint8_t *pInputBuffer, - uint8_t *pOutputBuffer, - uint8_t *pOutputLength) -{ - (void)inputLength; - (void)pInputBuffer; - // Defined in the specs to be the max size of the git hash - const uint8_t git_hash_max_size = 16; - uint8_t len = 0; -#if defined(GIT_HASH_ID) - uint8_t git_hash_id[40] = GIT_HASH_ID; -#else /* defined(GIT_HASH_ID) */ - uint8_t *git_hash_id = ZW_GetProtocolGitHash(); -#endif /* defined(GIT_HASH_ID) */ - - const SApplicationHandles *pAppHandles = ZAF_getAppHandle(); - pOutputBuffer[len++] = pAppHandles->pProtocolInfo->eProtocolType; - pOutputBuffer[len++] = pAppHandles->pProtocolInfo->ProtocolVersion.Major; - pOutputBuffer[len++] = pAppHandles->pProtocolInfo->ProtocolVersion.Minor; - pOutputBuffer[len++] = pAppHandles->pProtocolInfo->ProtocolVersion.Revision; - pOutputBuffer[len++] = (uint8_t)(ZAF_BUILD_NO >> 8); - pOutputBuffer[len++] = (uint8_t)(ZAF_BUILD_NO ); - for (uint32_t i = 0 ; i < git_hash_max_size; i++,len++) - { - pOutputBuffer[len] = git_hash_id[i]; - } - *pOutputLength = len; -} - -bool InitiateShutdown( ZW_Void_Callback_t pCallback) -{ - const SApplicationHandles *pAppHandles = ZAF_getAppHandle(); - SZwaveCommandPackage shutdown = { - .eCommandType = EZWAVECOMMANDTYPE_ZW_INITIATE_SHUTDOWN, - .uCommandParams.InitiateShutdown.Handle = pCallback}; - - // Put the Command on queue (and dont wait for it, queue must be empty) - if (EQUEUENOTIFYING_STATUS_SUCCESS == QueueNotifyingSendToBack(pAppHandles->pZwCommandQueue, (uint8_t *)&shutdown, 0)) - { - // Wait for protocol to handle command - SZwaveCommandStatusPackage result = { 0 }; - if (GetCommandResponse(&result, EZWAVECOMMANDSTATUS_ZW_INITIATE_SHUTDOWN)) - { - return result.Content.InitiateShutdownStatus.result; - } - } - return false; -} diff --git a/src/zwave_ncp_serial_api_controller/cmds_management.h b/src/zwave_ncp_serial_api_controller/cmds_management.h deleted file mode 100644 index baaac812..00000000 --- a/src/zwave_ncp_serial_api_controller/cmds_management.h +++ /dev/null @@ -1,180 +0,0 @@ -/** - * @file - * @copyright 2022 Silicon Laboratories Inc. - */ - -#ifndef APPS_SERIALAPI_CMD_MANAGEMENT_H_ -#define APPS_SERIALAPI_CMD_MANAGEMENT_H_ - -#include -#include -/* FUNC_ID_SERIAL_API_SETUP command definitions */ -typedef enum -{ - /** - * The first 8 commands are given as bit-flags, and when all bits were consumed, a byte-array was created to give - * more room. - * The first 8 flags are the only ones that shall be used to fill the first byte when generating the response in - * pOutputBuffer for the command, SERIAL_API_SETUP_CMD_SUPPORTED. - * This is kept for backwards compatibility. - */ - SERIAL_API_SETUP_CMD_UNSUPPORTED, - SERIAL_API_SETUP_CMD_SUPPORTED = 1, //1<<0 - SERIAL_API_SETUP_CMD_TX_STATUS_REPORT = 2, //1<<1 - SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET = 4, //1<<2 @Deprecated - SERIAL_API_SETUP_CMD_TX_POWERLEVEL_GET = 8, //1<<3 @Deprecated - SERIAL_API_SETUP_CMD_TX_GET_MAX_PAYLOAD_SIZE = 16, //1<<4 - SERIAL_API_SETUP_CMD_RF_REGION_GET = 32, //1<<5 - SERIAL_API_SETUP_CMD_RF_REGION_SET = 64, //1<<6 - SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET = 128, //1<<7 - /** - * The below values are not flags and shall only be used with BITMASK_ADD_CMD() when generating - * the response for the command, SERIAL_API_SETUP_CMD_SUPPORTED. - */ - SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_SET = 3, - SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_GET = 5, - // The values 6 and 7 are unused, but not reserved. - SERIAL_API_SETUP_CMD_TX_GET_MAX_LR_PAYLOAD_SIZE = 17, - SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET_16_BIT = 18, - SERIAL_API_SETUP_CMD_TX_POWERLEVEL_GET_16_BIT = 19, - SERIAL_API_SETUP_CMD_GET_SUPPORTED_REGION = 21, - SERIAL_API_SETUP_CMD_GET_REGION_INFO = 22, -} eSerialAPISetupCmd; - -/* SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET definitions */ -typedef enum -{ - SERIAL_API_SETUP_NODEID_BASE_TYPE_8_BIT = 1, - SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT, - SERIAL_API_SETUP_NODEID_BASE_TYPE_LAST, - SERIAL_API_SETUP_NODEID_BASE_TYPE_DEFAULT = SERIAL_API_SETUP_NODEID_BASE_TYPE_8_BIT -} eSerialAPISetupNodeIdBaseType; - -/* Global variable for specifying if the SerialAPI command Node ID fields are 8 or 16 bits */ -extern eSerialAPISetupNodeIdBaseType nodeIdBaseType; - -/* Macro for retrieving a SerialAPI command nodeID value (8 or 16 bit) at address "pData" */ -/* Increments the input argument "idx" if nodeID is two bytes wide (i.e. 16 bit) */ -#define GET_NODEID(pData, idx) \ - ( (nodeIdBaseType == SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT) ? \ - ((((uint8_t*)pData)[0] << 8) | ((uint8_t*)pData)[1]) : /* 16 bit, MSB | LSB */ \ - ((uint8_t*)pData)[0] ); /* 8 bit */ \ - do { \ - if (nodeIdBaseType == SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT) \ - { \ - idx++; \ - } \ - } while (0) - -#define GET_16BIT_VALUE(pData) \ - ( ( (uint16_t)((uint8_t*)pData)[0] << 8) | (uint16_t)((uint8_t*)pData)[1] ) /* 16 bit, MSB | LSB */ - -/* Commands minimum length (bytes) */ -#define SERIAL_API_SETUP_CMD_TX_STATUS_REPORT_CMD_LENGTH_MIN 2 -#define SERIAL_API_SETUP_CMD_RF_REGION_SET_CMD_LENGTH_MIN 2 -#define SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET_CMD_LENGTH_MIN 3 -#define SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET_CMD_LENGTH_MIN 2 -#define SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_SET_CMD_LENGTH_MIN 3 - -// -------------------------------- -// Definitions related to the sub command get region info -/// Index of the region in received buffer -#define SAPI_SETUP_GET_REGION_INFO_RX_IDX_REGION (1) -/// structure used to describe the format of a get region info answer. -#pragma pack(push) -#pragma pack(1) -typedef struct { - uint8_t region; - uint8_t zw_classic:1; ///< the region supports classic Z-Wave - uint8_t zw_lr:1; ///< the region supports Z-Wave Long Range - uint8_t reserved:6; ///< reserved for future use - uint8_t included_region; ///< the selected region include this one (e.g. US_LR include US) -} serial_api_setup_cmd_get_region_info_answer_t; -#pragma pack(pop) - -/** - * Must be called upon receiving a "Node List Command". - * @param inputLength Length of data in input buffer. - * @param pInputBuffer Input buffer - * @param pOutputBuffer Output buffer - * @param pOutputLength Length of data in output buffer. - */ -void func_id_serial_api_get_init_data(uint8_t inputLength, - const uint8_t *pInputBuffer, - uint8_t *pOutputBuffer, - uint8_t *pOutputLength); - -/** - * Returns bitmask of LR node IDs - * @param inputLength Length of data in input buffer. - * @param pInputBuffer Input buffer. First byte should be requested range of nodes. - * Supported values: 0, 1, 2, 3 that corresponds to offset 0, 128, 256, 384. - * @param pOutputBuffer Output buffer, contained of: MORE_NODES | BITMASK_OFFSET | BITMASK_LEN | BITMASK_ARRAY - * @param pOutputLength Length of data in output buffer. - */ -void func_id_serial_api_get_LR_nodes(uint8_t inputLength, - const uint8_t *pInputBuffer, - uint8_t *pOutputBuffer, - uint8_t *pOutputLength); - -/** - * Must be called upon receiving a "Serial API Setup Command". - * @param inputLength Length of data in input buffer. - * @param pInputBuffer Input buffer - * @param pOutputBuffer Output buffer - * @param pOutputLength Length of data in output buffer. - */ -void func_id_serial_api_setup(uint8_t inputLength, - const uint8_t *pInputBuffer, - uint8_t *pOutputBuffer, - uint8_t *pOutputLength); - -/** - * Must be called upon receiving a "Serial API NVR get". - * @param inputLength Length of data in input buffer. - * @param pInputBuffer Input buffer - * @param pOutputBuffer Output buffer - * @param pOutputLength Length of data in output buffer. - */ - -void -func_id_serial_api_get_nvr(uint8_t inputLength, - const uint8_t *pInputBuffer, - uint8_t *pOutputBuffer, - uint8_t *pOutputLength); - -/** - * Must be called upon receiving a "Serial API ZW Get protocol version". - * @param inputLength Length of data in input buffer. - * @param pInputBuffer Input buffer - * @param pOutputBuffer Output buffer - * @param pOutputLength Length of data in output buffer. - */ - -void -func_id_zw_get_protocol_version(uint8_t inputLength, - const uint8_t *pInputBuffer, - uint8_t *pOutputBuffer, - uint8_t *pOutputLength); - -/** - * Remove a specific node from the network - * The node is identified by node ID - * @param inputLength Length of data in input buffer. - * @param pInputBuffer Input buffer - * @param pOutputBuffer Output buffer - * @param pOutputLength Length of data in output buffer. - */ -void func_id_ZW_RemoveNodeIDFromNetwork (uint8_t inputLength, - uint8_t *pInputBuffer, - const uint8_t *pOutputBuffer, - const uint8_t *pOutputLength); - -/** - * Initiate device graceful shutdown - * - * @param pCallback pointer to notifcation callback function. Function is called just before deice go into deepsleep - * @return true if Shutdown process start, else false - */ -bool InitiateShutdown( ZW_Void_Callback_t pCallback); -#endif /* APPS_SERIALAPI_CMD_MANAGEMENT_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/cmds_power_management.c b/src/zwave_ncp_serial_api_controller/cmds_power_management.c deleted file mode 100644 index 0502891e..00000000 --- a/src/zwave_ncp_serial_api_controller/cmds_power_management.c +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @file - * Offers Power Management commands for Silabs targets only. - * @attention Must be linked for Silabs build targets only. - * @copyright 2022 Silicon Laboratories Inc. - */ -#include -#include "cmd_handlers.h" -#include "ZW_SerialAPI.h" -#include "app.h" -#include "zpal_power_manager.h" -#include "SwTimer.h" -#include "AppTimer.h" - -extern zpal_pm_handle_t radio_power_lock; -extern zpal_pm_handle_t io_power_lock; -extern SSwTimer mWakeupTimer; - -ZW_ADD_CMD(FUNC_ID_PM_STAY_AWAKE) -{ - /* HOST->ZW: PowerLock Type, timeout of stay awake, timeout of wakeup */ - /* Power locks type 0 for radio and 1 for peripheral*/ - uint32_t timeout = (uint32_t)(frame->payload[1]<<24); - timeout |= (uint32_t)(frame->payload[2]<<16); - timeout |= (uint32_t)(frame->payload[3]<<8); - timeout |= (uint32_t)(frame->payload[4]); - - uint32_t timeoutwakeup = (uint32_t)(frame->payload[5]<<24); - timeoutwakeup |= (uint32_t)(frame->payload[6]<<16); - timeoutwakeup |= (uint32_t)(frame->payload[7]<<8); - timeoutwakeup |= (uint32_t)(frame->payload[8]); - - if (0 == frame->payload[0]) - { - zpal_pm_stay_awake(radio_power_lock, timeout); - } - else if (1 == frame->payload[0]) - { - zpal_pm_stay_awake(io_power_lock, timeout); - } - - if (timeout && timeoutwakeup) - { - AppTimerDeepSleepPersistentStart(&mWakeupTimer, timeoutwakeup); - } - set_state_and_notify(stateIdle); -} - - -ZW_ADD_CMD(FUNC_ID_PM_CANCEL) -{ - /* HOST->ZW: PowerLock Type*/ - /*Power locks type 0 for radio and 1 for peripheral*/ - if (0 == frame->payload[0]) - { - zpal_pm_cancel(radio_power_lock); - } - else if (1 == frame->payload[0]) - { - zpal_pm_cancel(io_power_lock); - } - set_state_and_notify(stateIdle); -} diff --git a/src/zwave_ncp_serial_api_controller/cmds_rf.c b/src/zwave_ncp_serial_api_controller/cmds_rf.c deleted file mode 100644 index 19dec5b5..00000000 --- a/src/zwave_ncp_serial_api_controller/cmds_rf.c +++ /dev/null @@ -1,32 +0,0 @@ -/**************************************************************************//** - * @file cmds_rf.c - * @brief The source file for command handling of RF related serialAPI - * commands - * @copyright 2022 Silicon Laboratories Inc. - *****************************************************************************/ - -#include -#include -#include -#include - -#ifdef SUPPORT_ZW_SET_LISTEN_BEFORE_TALK_THRESHOLD -void func_id_set_listen_before_talk(__attribute__((unused)) uint8_t inputLength, - const uint8_t *pInputBuffer, - uint8_t *pOutputBuffer, - uint8_t *pOutputLength) -{ - uint8_t bReturn; - SZwaveCommandPackage setLBTMode = { - .eCommandType = EZWAVECOMMANDTYPE_ZW_SET_LBT_THRESHOLD, - .uCommandParams.SetLBTThreshold.channel = pInputBuffer[0], - .uCommandParams.SetLBTThreshold.level = (int8_t)pInputBuffer[1] - }; - - bReturn = QueueProtocolCommand((uint8_t*)&setLBTMode); - - pOutputBuffer[0] = ((EQUEUENOTIFYING_STATUS_SUCCESS == bReturn) ? true : false); - *pOutputLength = 1; -} -#endif - diff --git a/src/zwave_ncp_serial_api_controller/cmds_rf.h b/src/zwave_ncp_serial_api_controller/cmds_rf.h deleted file mode 100644 index 9a85b50d..00000000 --- a/src/zwave_ncp_serial_api_controller/cmds_rf.h +++ /dev/null @@ -1,22 +0,0 @@ -/**************************************************************************//** - * @file - * @brief The header file for command handling of RF related serialAPI - * commands - * @copyright 2022 Silicon Laboratories Inc. - *****************************************************************************/ - -#ifndef APPS_SERIALAPI_CMD_RF_H_ -#define APPS_SERIALAPI_CMD_RF_H_ - -#include - -void func_id_set_listen_before_talk(uint8_t inputLength, - const uint8_t *pInputBuffer, - uint8_t *pOutputBuffer, - uint8_t *pOutputLength); -void func_id_set_powerlevel(uint8_t inputLength, - uint8_t *pInputBuffer, - uint8_t *pOutputBuffer, - uint8_t *pOutputLength); - -#endif /* APPS_SERIALAPI_CMD_RF_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/cmds_security.c b/src/zwave_ncp_serial_api_controller/cmds_security.c deleted file mode 100644 index bd0a077b..00000000 --- a/src/zwave_ncp_serial_api_controller/cmds_security.c +++ /dev/null @@ -1,136 +0,0 @@ -/** - * @file cmds_security.c - * @copyright 2022 Silicon Laboratories Inc. - */ - -#include -#include -#include -#include -#include - -//#define DEBUGPRINT -#include - -#define SUPPORT_ZW_GET_SECURITY_S2_PUBLIC_DSK 1 - -/* FUNC_ID_ZW_SECURITY_SETUP command definitions. */ -typedef enum -{ - E_SECURITY_SETUP_CMD_ZW_GET_SECURITY_KEYS = 0, - E_SECURITY_SETUP_CMD_ZW_SET_SECURITY_S0_NETWORK_KEY, // OBSOLETE - E_SECURITY_SETUP_CMD_ZW_GET_SECURITY_S2_PUBLIC_DSK, - E_SECURITY_SETUP_CMD_ZW_SET_SECURITY_S2_CRITICAL_NODE_ID, // OBSOLETE - E_SECURITY_SETUP_CMD_ZW_SET_SECURITY_S2_INCLUSION_PUBLIC_DSK_CSA, // OBSOLETE - E_SECURITY_SETUP_CMD_SET_SECURITY_INCLUSION_REQUESTED_KEYS, - E_SECURITY_SETUP_CMD_SET_SECURITY_INCLUSION_REQUESTED_AUTHENTICATION, // OBSOLETE - E_SECURITY_SETUP_CMD_GET_SECURITY_CAPABILITIES = 0xFE, - E_SECURITY_SETUP_CMD_UNKNOWN = 0xFF -} eSecuritySetupCmd_t; - -/* FUNC_ID_ZW_SECURITY_SETUP command supported definitions. */ -/* Used together with the Security Setup command GetSecurityCapabilities */ -/* returned supported command bitmask to determine if a specific command are supported */ -typedef enum -{ - E_SECURITY_SETUP_SUPPORT_CMD_ZW_GET_SECURITY_KEYS = (1<ZW: securityFuncID [| bDataLen | abData[bDataLen]] */ - /* ZW->HOST: securityFuncID | bretValLen | retVal[bretValLen] */ - *pOutputBuffer = *pInputBuffer; - switch ((eSecuritySetupCmd_t)*pInputBuffer) - { -#if SUPPORT_ZW_GET_SECURITY_KEYS - case E_SECURITY_SETUP_CMD_ZW_GET_SECURITY_KEYS: - { - /* HOST->ZW: */ - /* ZW->HOST: securityKeys_bitmaskLen(1) | securityKeys_bitmask[securityKeys_bitmaskLen] */ - *(pOutputBuffer + 1) = 1; - *(pOutputBuffer + 2) = ZAF_GetSecurityKeys(); - *pOutputLength = 3; - } - break; - - case E_SECURITY_SETUP_CMD_SET_SECURITY_INCLUSION_REQUESTED_KEYS: - { - /* HOST->ZW: registeredSecurityKeysLen(1) | registeredSecurityKeys */ - /* ZW->HOST: retValLen(1) | retVal[retValLen] */ - bool retVal = false; - if (1 == *(pInputBuffer + 1)) - { - /* Set the requestedSecurityKeysBits requested by protocol when doing S2 inclusion */ - //SecureKeysRequested = serial_frame->payload[2]; - SZwaveCommandPackage Package = { - .eCommandType = EZWAVECOMMANDTYPE_SET_SECURITY_KEYS, - .uCommandParams.SetSecurityKeys.keys = *(pInputBuffer + 2) - }; - QueueNotifyingSendToBack(ZAF_getAppHandle()->pZwCommandQueue, (uint8_t *)&Package, 0); - /* sRequestedSecuritySettings.requestedSecurityKeysBits are either the initialized */ - /* define value (REQUESTED_SECURITY_KEYS) or the value set through the FUNC_ID_ZW_SECURITY_SETUP */ - /* function E_SECURITY_SETUP_CMD_SET_SECURITY_INCLUSION_REQUESTED_AUTHENTICATION */ - // FIXME insert check of if protocol has been started yet. - // if it has - return false. - retVal = true; - } - *(pOutputBuffer + 1) = 1; - *(pOutputBuffer + 2) = retVal; - *pOutputLength = 3; - } - break; -#endif -#if SUPPORT_ZW_GET_SECURITY_S2_PUBLIC_DSK - case E_SECURITY_SETUP_CMD_ZW_GET_SECURITY_S2_PUBLIC_DSK: - { - /* HOST->ZW: */ - /* ZW->HOST: retValLen(SECURITY_KEY_S2_PUBLIC_DSK_LENGTH) | retVal[retValLen] */ - *(pOutputBuffer + 1) = SECURITY_KEY_S2_PUBLIC_DSK_LENGTH; - ZW_GetMfgTokenData(pOutputBuffer + 2, TOKEN_MFG_ZW_PUK_ID, SECURITY_KEY_S2_PUBLIC_DSK_LENGTH); - *pOutputLength = 2 + SECURITY_KEY_S2_PUBLIC_DSK_LENGTH; - } - break; -#endif - - case E_SECURITY_SETUP_CMD_GET_SECURITY_CAPABILITIES: - { - /* HOST->ZW: */ - /* ZW->HOST: securitySetup_bitmaskLen | securityKeys_bitmask[securitySetup_bitmaskLen] */ - *(pOutputBuffer + 1) = 1; - /* LSB first if more than one byte in securityKeys_bitmask[] */ - *(pOutputBuffer + 2) = 0 -#if SUPPORT_ZW_GET_SECURITY_KEYS - | E_SECURITY_SETUP_SUPPORT_CMD_ZW_GET_SECURITY_KEYS - | E_SECURITY_SETUP_SUPPORT_CMD_SET_SECURITY_INCLUSION_REQUESTED_KEYS -#endif -#if SUPPORT_ZW_GET_SECURITY_S2_PUBLIC_DSK - | E_SECURITY_SETUP_SUPPORT_CMD_ZW_GET_SECURITY_S2_PUBLIC_DSK -#endif - ; - *pOutputLength = 3; - } - break; - - default: - { - /* ZW->HOST: E_SECURITY_SETUP_UNKNOWN_COMMAND | retValLen | securityFuncID(called)[retValLen] */ - *(pOutputBuffer + 0) = E_SECURITY_SETUP_CMD_UNKNOWN; - *(pOutputBuffer + 1) = 1; - /* Return the called Unknown FUNC_ID_ZW_SECURITY_SETUP Command */ - *(pOutputBuffer + 2) = *pInputBuffer; - *pOutputLength = 3; - } - break; - } - } -} diff --git a/src/zwave_ncp_serial_api_controller/cmds_security.h b/src/zwave_ncp_serial_api_controller/cmds_security.h deleted file mode 100644 index 54ac23be..00000000 --- a/src/zwave_ncp_serial_api_controller/cmds_security.h +++ /dev/null @@ -1,16 +0,0 @@ -/** - * @file - * @copyright 2022 Silicon Laboratories Inc. - */ - -#ifndef APPS_SERIALAPI_CMDS_SECURITY_H_ -#define APPS_SERIALAPI_CMDS_SECURITY_H_ - -#include - -void func_id_zw_security_setup(uint8_t inputLength, - const uint8_t *pInputBuffer, - uint8_t *pOutputBuffer, - uint8_t *pOutputLength); - -#endif /* APPS_SERIALAPI_CMDS_SECURITY_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/comm_interface.c b/src/zwave_ncp_serial_api_controller/comm_interface.c deleted file mode 100644 index 880d3e29..00000000 --- a/src/zwave_ncp_serial_api_controller/comm_interface.c +++ /dev/null @@ -1,519 +0,0 @@ -/** - * @file - * @copyright 2022 Silicon Laboratories Inc. - */ - -#include "comm_interface.h" -#include "zpal_uart.h" -#include "ZW_SerialAPI.h" -#include "SwTimer.h" -#include "utils.h" -#include -#include "AppTimer.h" -#include "Assert.h" -#include "SerialAPI_hw.h" - -#define BUFFER_CHECK_TIME_MS 250 -#define DEFAULT_ACK_TIMEOUT_MS 1500 -#define DEFAULT_BYTE_TIMEOUT_MS 150 -#define HEADER_LEN 4 -#define ACK_LEN 1 -#define CRC_LEN 1 - -#define COMM_INT_TX_BUFFER_SIZE 200 -#define COMM_INT_RX_BUFFER_SIZE 200 -#define TRANSMIT_BUFFER_SIZE COMM_INT_TX_BUFFER_SIZE - - -typedef enum -{ - COMM_INTERFACE_STATE_SOF = 0, - COMM_INTERFACE_STATE_LEN = 1, - COMM_INTERFACE_STATE_TYPE = 2, - COMM_INTERFACE_STATE_CMD = 3, - COMM_INTERFACE_STATE_DATA = 4, - COMM_INTERFACE_STATE_CHECKSUM = 5, -} comm_interface_state_t; - -typedef struct -{ - transport_t transport; - SSwTimer ack_timer; - bool ack_timeout; - uint32_t ack_timeout_ms; - SSwTimer byte_timer; - bool byte_timeout; - uint32_t byte_timeout_ms; - SSwTimer buffer_check_timer; - comm_interface_state_t state; - uint8_t expect_bytes; - bool ack_needed; - uint8_t buffer_len; - uint8_t buffer[RECEIVE_BUFFER_SIZE]; - bool rx_active; - uint8_t rx_wait_count; -} comm_interface_t; - -typedef struct -{ - uint8_t sof; - uint8_t len; - uint8_t type; - uint8_t cmd; - uint8_t payload[UINT8_MAX]; -} tx_frame_t; - - -static comm_interface_t comm_interface = { 0 }; -comm_interface_frame_ptr const serial_frame = (comm_interface_frame_ptr)comm_interface.buffer; - -static uint8_t tx_data[COMM_INT_TX_BUFFER_SIZE]; -static uint8_t rx_data[COMM_INT_RX_BUFFER_SIZE]; - -static void set_expect_bytes(uint8_t level) -{ - vPortEnterCritical(); - - if (zpal_uart_get_available(comm_interface.transport.handle) >= level) - { - comm_interface.expect_bytes = 0; - TriggerNotification(EAPPLICATIONEVENT_SERIALDATARX); - } - else - { - comm_interface.expect_bytes = level; - } - - vPortExitCritical(); -} - -static void receive_callback(__attribute__((unused)) const zpal_uart_handle_t handle, size_t available) -{ - if (available >= comm_interface.expect_bytes) - { - comm_interface.expect_bytes = 0; - TriggerNotification(EAPPLICATIONEVENT_SERIALDATARX); - } -} - -static void ack_timer_cb(__attribute__((unused)) SSwTimer *timer) -{ - comm_interface.ack_timeout = true; - TriggerNotification(EAPPLICATIONEVENT_SERIALTIMEOUT); -} - -static void byte_timer_cb(__attribute__((unused)) SSwTimer *timer) -{ - comm_interface.byte_timeout = true; - TriggerNotification(EAPPLICATIONEVENT_SERIALTIMEOUT); -} - -static void buffer_check_timer_cb(__attribute__((unused)) SSwTimer *timer) -{ - if(zpal_uart_get_available(comm_interface.transport.handle)) - { - TriggerNotification(EAPPLICATIONEVENT_SERIALDATARX); - } -} - -static uint8_t xor_checksum(uint8_t init, const uint8_t *data, uint8_t len) -{ - uint8_t checksum = init; - - for (int i = 0; i < len; i++) - { - checksum ^= data[i]; - } - - return checksum; -} - -static zpal_status_t comm_interface_transmit(transport_t *transport, const uint8_t *data, size_t len, transmit_done_cb_t cb) -{ - if (transport) - { - switch (transport->type) - { - case TRANSPORT_TYPE_UART: - return zpal_uart_transmit(transport->handle, data, len, cb); - - default: - break; - } - } - - return ZPAL_STATUS_FAIL; -} - -void comm_interface_transmit_frame(uint8_t cmd, uint8_t type, const uint8_t *payload, uint8_t len, transmit_done_cb_t cb) -{ - tx_frame_t frame = { - .sof = SOF - }; - static uint8_t _len, _type, _cmd, _checksum; - static const uint8_t *_payload; - - TimerStop(&comm_interface.ack_timer); - TimerStop(&comm_interface.byte_timer); - TimerStop(&comm_interface.buffer_check_timer); - - comm_interface.byte_timeout = false; - comm_interface.ack_timeout = false; - - if (payload != NULL) - { - frame.len = len + 3; - frame.type = type; - frame.cmd = cmd; - memcpy(frame.payload, payload, len); - frame.payload[len] = xor_checksum(0xFF, &frame.len, frame.len); - - /* store input arguments for retransmission */ - _len = len; - _type = type; - _cmd = cmd; - _payload = payload; - _checksum = frame.payload[len]; - } - else - { - /* retransmit last frame */ - frame.len = _len + 3; - frame.type = _type; - frame.cmd = _cmd; - if(_payload) { - memcpy(frame.payload, _payload, _len); - } - frame.payload[_len] = _checksum; - } - - comm_interface.ack_needed = true; - set_expect_bytes(ACK_LEN); - comm_interface_transmit(&comm_interface.transport, (uint8_t *)&frame, frame.len + 2, cb); - TimerStart(&comm_interface.ack_timer, comm_interface_get_ack_timeout_ms()); - TimerStart(&comm_interface.buffer_check_timer, BUFFER_CHECK_TIME_MS); -} - -void comm_interface_wait_transmit_done(void) -{ - while(zpal_uart_transmit_in_progress(comm_interface.transport.handle)); -} - -void comm_interface_init(void) -{ - const zpal_uart_config_t uart_config = - { - .tx_buffer = tx_data, - .tx_buffer_len = COMM_INT_TX_BUFFER_SIZE, - .rx_buffer = rx_data, - .rx_buffer_len = COMM_INT_RX_BUFFER_SIZE, - .id = ZPAL_UART0, - .baud_rate = 115200, - .data_bits = 8, - .parity_bit = ZPAL_UART_NO_PARITY, - .stop_bits = ZPAL_UART_STOP_BITS_1, - .receive_callback = receive_callback, - .ptr = SerialAPI_get_uart_config_ext(), - }; - - comm_interface_set_ack_timeout_ms(DEFAULT_ACK_TIMEOUT_MS); - comm_interface_set_byte_timeout_ms(DEFAULT_BYTE_TIMEOUT_MS); - - zpal_status_t status = zpal_uart_init(&uart_config, &comm_interface.transport.handle); - ASSERT(status == ZPAL_STATUS_OK); - status = zpal_uart_enable(comm_interface.transport.handle); - ASSERT(status == ZPAL_STATUS_OK); - comm_interface.transport.type = TRANSPORT_TYPE_UART; - - AppTimerRegister(&comm_interface.ack_timer, false, ack_timer_cb); - TimerStop(&comm_interface.ack_timer); - - AppTimerRegister(&comm_interface.byte_timer, false, byte_timer_cb); - TimerStop(&comm_interface.byte_timer); - - AppTimerRegister(&comm_interface.buffer_check_timer, true, buffer_check_timer_cb); - TimerStop(&comm_interface.buffer_check_timer); - - comm_interface.state = COMM_INTERFACE_STATE_SOF; - comm_interface.buffer_len = 0; - set_expect_bytes(HEADER_LEN); -} - -uint32_t comm_interface_get_ack_timeout_ms(void) -{ - return comm_interface.ack_timeout_ms; -} - -void comm_interface_set_ack_timeout_ms(uint32_t t) -{ - comm_interface.ack_timeout_ms = t; -} - -uint32_t comm_interface_get_byte_timeout_ms(void) -{ - return comm_interface.byte_timeout_ms; -} - -void comm_interface_set_byte_timeout_ms(uint32_t t) -{ - comm_interface.byte_timeout_ms = t; -} - -static void store_byte(uint8_t byte) -{ - if (TimerIsActive(&comm_interface.byte_timer)) - TimerRestart(&comm_interface.byte_timer); - else - TimerStart(&comm_interface.byte_timer, comm_interface_get_byte_timeout_ms()); - - comm_interface.byte_timeout = false; - comm_interface.buffer[comm_interface.buffer_len] = byte; - comm_interface.buffer_len++; -} - -static comm_interface_parse_result_t handle_sof(uint8_t input) -{ - comm_interface_parse_result_t result = PARSE_IDLE; - - if (input == SOF) - { - comm_interface.state = COMM_INTERFACE_STATE_LEN; - comm_interface.buffer_len = 0; - comm_interface.rx_active = true; // now we're receiving - check for timeout - store_byte(input); - } - else - { - if (comm_interface.ack_needed) - { - if ((input == ACK) || (input == NAK)) - { - comm_interface.ack_needed = false; // Done - comm_interface.ack_timeout = false; - comm_interface.byte_timeout = false; - TimerStop(&comm_interface.ack_timer); - TimerStop(&comm_interface.byte_timer); - TimerStop(&comm_interface.buffer_check_timer); - } - if (input == ACK) - { - result = PARSE_FRAME_SENT; - } - else if (input == NAK) - { - result = PARSE_TX_TIMEOUT; - } - else - { - // Bogus character received... - } - } - else - { - comm_interface.ack_timeout = false; - TimerStop(&comm_interface.ack_timer); - TimerStop(&comm_interface.buffer_check_timer); - } - } - return result; -} - -static void handle_len(uint8_t input) -{ - // Check for length to be inside valid range - if ((input < FRAME_LENGTH_MIN) || (input > FRAME_LENGTH_MAX)) - { - comm_interface.state = COMM_INTERFACE_STATE_SOF; // Restart looking for SOF - comm_interface.rx_active = false; // Not really active now... - TimerStop(&comm_interface.byte_timer); - comm_interface.byte_timeout = false; - } - else - { - comm_interface.state = COMM_INTERFACE_STATE_TYPE; - store_byte(input); - } -} - -static void handle_type(uint8_t input) -{ - if (input > RESPONSE) - { - comm_interface.state = COMM_INTERFACE_STATE_SOF; // Restart looking for SOF - comm_interface.rx_active = false; // Not really active now... - TimerStop(&comm_interface.byte_timer); - comm_interface.byte_timeout = false; - } - else - { - comm_interface.state = COMM_INTERFACE_STATE_CMD; - store_byte(input); - } -} - -static void handle_cmd(uint8_t input) -{ - store_byte(input); - - if(serial_frame->len > 3) - { - comm_interface.rx_wait_count = serial_frame->len - 3; - comm_interface.state = COMM_INTERFACE_STATE_DATA; - } - else - { - comm_interface.rx_wait_count = 1; - comm_interface.state = COMM_INTERFACE_STATE_CHECKSUM; - } -} - -static void handle_data(uint8_t input) -{ - comm_interface.rx_wait_count--; - store_byte(input); - - if ((comm_interface.buffer_len >= RECEIVE_BUFFER_SIZE) || - (comm_interface.buffer_len > serial_frame->len)) //buffer_len - sizeof(sof) >= serial_frame->len - { - comm_interface.state = COMM_INTERFACE_STATE_CHECKSUM; - } -} - -static comm_interface_parse_result_t handle_checksum(uint8_t input, bool ack) -{ - TimerStop(&comm_interface.byte_timer); - comm_interface.byte_timeout = false; - comm_interface.state = COMM_INTERFACE_STATE_SOF; // Restart looking for SOF - comm_interface.rx_active = false; // Not really active - - /* Default values for ack == false */ - /* It means we are in the process of looking for an acknowledge to a callback request */ - /* Drop the new frame we received - we don't have time to handle it. */ - comm_interface_parse_result_t result = PARSE_IDLE; - uint8_t response = CAN; - - /* Do we send ACK/NAK according to checksum... */ - /* if not then the received frame is dropped! */ - if (ack) - { - uint8_t checksum = xor_checksum(0xFF, &serial_frame->len, serial_frame->len); - result = (input == checksum) ? PARSE_FRAME_RECEIVED : PARSE_FRAME_ERROR; - response = (input == checksum) ? ACK : NAK; - } - - comm_interface_transmit(&comm_interface.transport, &response, sizeof(response), NULL); - - return result; -} - -static void handle_default(void) -{ - comm_interface.state = COMM_INTERFACE_STATE_SOF; // Restart looking for SOF - comm_interface.rx_active = false; // Not really active now... - comm_interface.ack_timeout = false; - comm_interface.byte_timeout = false; - TimerStop(&comm_interface.ack_timer); - TimerStop(&comm_interface.buffer_check_timer); - TimerStop(&comm_interface.byte_timer); -} - -comm_interface_parse_result_t comm_interface_parse_data(bool ack) -{ - uint8_t rx_byte; - comm_interface_parse_result_t result = PARSE_IDLE; - - while ((result == PARSE_IDLE) && zpal_uart_get_available(comm_interface.transport.handle)) - { - zpal_uart_receive(comm_interface.transport.handle, &rx_byte, sizeof(rx_byte)); - - switch (comm_interface.state) - { - case COMM_INTERFACE_STATE_SOF: - result = handle_sof(rx_byte); - break; - - case COMM_INTERFACE_STATE_LEN: - handle_len(rx_byte); - break; - - case COMM_INTERFACE_STATE_TYPE: - handle_type(rx_byte); - break; - - case COMM_INTERFACE_STATE_CMD: - handle_cmd(rx_byte); - break; - - case COMM_INTERFACE_STATE_DATA: - handle_data(rx_byte); - break; - - case COMM_INTERFACE_STATE_CHECKSUM: - result = handle_checksum(rx_byte, ack); - break; - - default : - handle_default(); - break; - } - } - - /* Check for timeouts - if no other events detected */ - if (result == PARSE_IDLE) - { - /* Are we in the middle of collecting a frame and have we timed out? */ - if (comm_interface.rx_active && comm_interface.byte_timeout) - { - comm_interface.byte_timeout = false; - /* Reset to SOF hunting */ - comm_interface.state = COMM_INTERFACE_STATE_SOF; - comm_interface.rx_active = false; /* Not inframe anymore */ - result = PARSE_RX_TIMEOUT; - } - - /* Are we waiting for ACK and have we timed out? */ - if (comm_interface.ack_needed && comm_interface.ack_timeout) - { - comm_interface.ack_timeout = false; - /* Reset to SOF hunting */ - comm_interface.state = COMM_INTERFACE_STATE_SOF; - /* Not waiting for ACK anymore */ - comm_interface.ack_needed = false; - /* Tell upper layer we could not get the frame through */ - result = PARSE_TX_TIMEOUT; - } - } - - /*Check how many bytes we need depending on state.*/ - switch(comm_interface.state) - { - case COMM_INTERFACE_STATE_SOF: - set_expect_bytes(comm_interface.ack_needed ? ACK_LEN : HEADER_LEN); - break; - - case COMM_INTERFACE_STATE_LEN: - set_expect_bytes(HEADER_LEN - 1); - break; - - case COMM_INTERFACE_STATE_TYPE: - set_expect_bytes(HEADER_LEN - 2); - break; - - case COMM_INTERFACE_STATE_CMD: - set_expect_bytes(HEADER_LEN - 3); - break; - - case COMM_INTERFACE_STATE_DATA: - set_expect_bytes(comm_interface.rx_wait_count); - break; - - case COMM_INTERFACE_STATE_CHECKSUM: - set_expect_bytes(CRC_LEN); - break; - - default: - break; - } - - return result; -} diff --git a/src/zwave_ncp_serial_api_controller/comm_interface.h b/src/zwave_ncp_serial_api_controller/comm_interface.h deleted file mode 100644 index be594396..00000000 --- a/src/zwave_ncp_serial_api_controller/comm_interface.h +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @file - * @copyright 2022 Silicon Laboratories Inc. - */ - -#ifndef __COMM_INTERFACE__ -#define __COMM_INTERFACE__ - -#include -#include -#include - -/** - * @addtogroup Apps - * @{ - * @addtogroup SerialAPI - * @{ - */ - -#define RECEIVE_BUFFER_SIZE 180 -#define FRAME_LENGTH_MIN 3 -#define FRAME_LENGTH_MAX RECEIVE_BUFFER_SIZE - -typedef enum -{ - TRANSPORT_TYPE_UART, - TRANSPORT_TYPE_SPI, - TRANSPORT_TYPE_ETHERNET, -} transport_type_t; - -typedef enum -{ - PARSE_IDLE, // returned if nothing special has happened - PARSE_FRAME_RECEIVED, // returned when a valid frame has been received - PARSE_FRAME_SENT, // returned if frame was ACKed by the other end - PARSE_FRAME_ERROR, // returned if frame has error in Checksum - PARSE_RX_TIMEOUT, // returned if Rx timeout has happened - PARSE_TX_TIMEOUT // returned if Tx timeout (waiting for ACK) ahs happened -} comm_interface_parse_result_t; - -typedef void * transport_handle_t; - -typedef void (*transmit_done_cb_t)(transport_handle_t transport); - -typedef struct _transport_t -{ - transport_type_t type; - transport_handle_t handle; -} transport_t; - -typedef struct -{ - uint8_t sof; - uint8_t len; - uint8_t type; - uint8_t cmd; - uint8_t payload[RECEIVE_BUFFER_SIZE]; //size defined to fix SonarQube errors -} * comm_interface_frame_ptr; - -extern comm_interface_frame_ptr const serial_frame; - -static inline uint8_t frame_payload_len(const comm_interface_frame_ptr frame) -{ - return frame->len - 3; -} - -void comm_interface_transmit_frame(uint8_t cmd, uint8_t type, const uint8_t *payload, uint8_t len, transmit_done_cb_t cb); -void comm_interface_wait_transmit_done(void); -void comm_interface_init(void); -uint32_t comm_interface_get_ack_timeout_ms(void); -void comm_interface_set_ack_timeout_ms(uint32_t t); -uint32_t comm_interface_get_byte_timeout_ms(void); -void comm_interface_set_byte_timeout_ms(uint32_t t); -comm_interface_parse_result_t comm_interface_parse_data(bool ack); - -/** - * @} - * @} - */ - -#endif /* __COMM_INTERFACE__ */ diff --git a/src/zwave_ncp_serial_api_controller/config/FreeRTOSConfig.h b/src/zwave_ncp_serial_api_controller/config/FreeRTOSConfig.h deleted file mode 100644 index 66a1bb3a..00000000 --- a/src/zwave_ncp_serial_api_controller/config/FreeRTOSConfig.h +++ /dev/null @@ -1,271 +0,0 @@ -/* -------------------------------------------------------------------------- - * Copyright (c) 2013-2019 Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * 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 - * - * 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. - * - * -------------------------------------------------------------------------- - * - * $Revision: V10.2.0 - * - * Project: CMSIS-FreeRTOS - * Title: FreeRTOS configuration definitions - * - * --------------------------------------------------------------------------*/ - -#ifndef FREERTOS_CONFIG_H -#define FREERTOS_CONFIG_H - -/*----------------------------------------------------------- -* Application specific definitions. -* -* These definitions should be adjusted for your particular hardware and -* application requirements. -* -* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE -* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. -* -* See http://www.freertos.org/a00110.html -*----------------------------------------------------------*/ - -#if !defined(__IAR_SYSTEMS_ASM__) -#if (defined(__ARMCC_VERSION) || defined(__GNUC__) || defined(__ICCARM__)) -#include - -#include "RTE_Components.h" -#include CMSIS_device_header -#endif - -#include "em_assert.h" -#include "em_device.h" - -#if defined(SL_COMPONENT_CATALOG_PRESENT) -#include "sl_component_catalog.h" -#endif -#endif - -#if defined(SL_CATALOG_SYSTEMVIEW_TRACE_PRESENT) -#include "SEGGER_SYSVIEW_FreeRTOS.h" -#endif - -//-------- <<< Use Configuration Wizard in Context Menu >>> -------------------- - -// Minimal stack size [words] <0-65535> -// Stack for idle task and default task stack in words. -// Default: 160 -#define configMINIMAL_STACK_SIZE 160 - -// Total heap size [bytes] <0-0xFFFFFFFF> -// Heap memory size in bytes. -// Default: 8192 -#define configTOTAL_HEAP_SIZE 8192 - -// Kernel tick frequency [Hz] <0-0xFFFFFFFF> -// Kernel tick rate in Hz. -// Default: 1000 -#define configTICK_RATE_HZ 1000 - -// Timer task stack depth [words] <0-65535> -// Stack for timer task in words. -// Default: 160 -#define configTIMER_TASK_STACK_DEPTH 160 - -// Timer task priority <0-56> -// Timer task priority. -// Default: 40 (High) -#define configTIMER_TASK_PRIORITY 55 - -// Timer queue length <0-1024> -// Timer command queue length. -// Default: 10 -#define configTIMER_QUEUE_LENGTH 8 - -// Preemption interrupt priority -// Maximum priority of interrupts that are safe to call FreeRTOS API. -// Default: 96 -#define configMAX_SYSCALL_INTERRUPT_PRIORITY 32 - -// Use time slicing -// Enable setting to use timeslicing. -// Default: 1 -#define configUSE_TIME_SLICING 1 - -// Idle should yield -// Control Yield behaviour of the idle task. -// Default: 1 -#define configIDLE_SHOULD_YIELD 1 - -// Check for stack overflow -// <0=>Disable <1=>Method one <2=>Method two -// Enable or disable stack overflow checking. -// Callback function vApplicationStackOverflowHook implementation is required when stack checking is enabled. -// Default: 2 -#define configCHECK_FOR_STACK_OVERFLOW 2 - -// Use idle hook -// Enable callback function call on each idle task iteration. -// Callback function vApplicationIdleHook implementation is required when idle hook is enabled. -// Default: 0 -#define configUSE_IDLE_HOOK 1 - -// Use tick hook -// Enable callback function call during each tick interrupt. -// Callback function vApplicationTickHook implementation is required when tick hook is enabled. -// Default: 0 -#define configUSE_TICK_HOOK 0 - -// Use deamon task startup hook -// Enable callback function call when timer service starts. -// Callback function vApplicationDaemonTaskStartupHook implementation is required when deamon task startup hook is enabled. -// Default: 0 -#define configUSE_DAEMON_TASK_STARTUP_HOOK 0 - -// Use malloc failed hook -// Enable callback function call when out of dynamic memory. -// Callback function vApplicationMallocFailedHook implementation is required when malloc failed hook is enabled. -// Default: 0 -#define configUSE_MALLOC_FAILED_HOOK 0 - -// Queue registry size -// Define maximum number of queue objects registered for debug purposes. -// The queue registry is used by kernel aware debuggers to locate queue and semaphore structures and display associated text names. -// Default: 10 -#define configQUEUE_REGISTRY_SIZE 10 - -// Port Specific Features -// Enable and configure port specific features. -// Check FreeRTOS documentation for definitions that apply for the used port. - -// Use Floating Point Unit -// Using Floating Point Unit (FPU) affects context handling. -// Enable FPU when application uses floating point operations. -// Default: 1 -#define configENABLE_FPU 1 - -// Use Memory Protection Unit -// Using Memory Protection Unit (MPU) requires detailed memory map definition. -// This setting is only releavant for MPU enabled ports. -// Default: 0 -#define configENABLE_MPU 0 - -// Minimal secure stack size [words] <0-65535> -// Stack for idle task Secure side context in words. -// This setting is only relevant when TrustZone extension is enabled. -// Default: 128 -#define configMINIMAL_SECURE_STACK_SIZE 128 -// - -// Thread Local Storage Settings -// Thread local storage pointers -// Thread local storage (or TLS) allows the application writer to store -// values inside a task's control block, making the value specific to -// (local to) the task itself. -// Default: 0 -#define configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS 0 -// - -// Use Threadsafe Errno -// Enable Threadsafe Errno support. -// Default: 0 -#define configUSE_POSIX_ERRNO 0 - -//------------- <<< end of configuration section >>> --------------------------- - -/* Defines needed by FreeRTOS to implement CMSIS RTOS2 API. Do not change! */ -#define configCPU_CLOCK_HZ (SystemCoreClock) -#define configSUPPORT_STATIC_ALLOCATION 1 -#define configSUPPORT_DYNAMIC_ALLOCATION 1 -#define configUSE_PREEMPTION 1 -#define configUSE_TIMERS 1 -#define configUSE_MUTEXES 1 -#define configUSE_RECURSIVE_MUTEXES 1 -#define configUSE_COUNTING_SEMAPHORES 1 -#define configUSE_TASK_NOTIFICATIONS 1 -#define configUSE_TRACE_FACILITY 1 -#define configUSE_16_BIT_TICKS 0 -#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 -#define configMAX_PRIORITIES 56 -#define configKERNEL_INTERRUPT_PRIORITY 224 - -/* Defines that include FreeRTOS functions which implement CMSIS RTOS2 API. Do not change! */ -#define INCLUDE_xEventGroupSetBitsFromISR 1 -#define INCLUDE_xSemaphoreGetMutexHolder 1 -#define INCLUDE_vTaskDelay 1 -#define INCLUDE_vTaskDelayUntil 1 -#define INCLUDE_vTaskDelete 1 -#define INCLUDE_xTaskGetCurrentTaskHandle 1 -#define INCLUDE_xTaskGetSchedulerState 1 -#define INCLUDE_uxTaskGetStackHighWaterMark 1 -#define INCLUDE_uxTaskPriorityGet 1 -#define INCLUDE_vTaskPrioritySet 1 -#define INCLUDE_eTaskGetState 1 -#define INCLUDE_vTaskSuspend 1 -#define INCLUDE_xTimerPendFunctionCall 1 - -/* Map the FreeRTOS port interrupt handlers to their CMSIS standard names. */ -#define xPortPendSVHandler PendSV_Handler -#define vPortSVCHandler SVC_Handler - -/* Ensure Cortex-M port compatibility. */ -#define SysTick_Handler xPortSysTickHandler - -/* Implement FreeRTOS configASSERT as emlib assert. */ -#define configASSERT(x) EFM_ASSERT(x) - -/* Energy saving modes. */ -#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) -#define configUSE_TICKLESS_IDLE 1 -#else -#define configUSE_TICKLESS_IDLE 0 -#endif - -/* Definition used by Keil to replace default system clock source. */ -#define configOVERRIDE_DEFAULT_TICK_CONFIGURATION 1 - -/* Maximum size of task name. */ -#define configMAX_TASK_NAME_LEN 10 - -/* Use queue sets? */ -#define configUSE_QUEUE_SETS 0 - -/* Generate run-time statistics? */ -#define configGENERATE_RUN_TIME_STATS 0 - -/* Co-routine related definitions. */ -#define configUSE_CO_ROUTINES 0 -#define configMAX_CO_ROUTINE_PRIORITIES 1 - -/* Optional resume from ISR functionality. */ -#define INCLUDE_xResumeFromISR 1 - -/* FreeRTOS Secure Side Only and TrustZone Security Extension */ -#define configRUN_FREERTOS_SECURE_ONLY 0 -#define configENABLE_TRUSTZONE 1 - -/* Thread local storage pointers used by the SDK */ -#ifndef configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS - #define configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS 0 -#endif - -/* PRINT_STRING implementation. iostream_retarget_stdio or third party - printf should be added if this is used */ -#define configPRINT_STRING(X) printf(X) - -#define configNUM_THREAD_LOCAL_STORAGE_POINTERS (configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS \ - + configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS) - -//#if defined(SL_CATALOG_SYSTEMVIEW_TRACE_PRESENT) -//#include "SEGGER_SYSVIEW_FreeRTOS.h" -//#endif -#endif /* FREERTOS_CONFIG_H */ \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/config/app_properties_config.h b/src/zwave_ncp_serial_api_controller/config/app_properties_config.h deleted file mode 100644 index 6951a569..00000000 --- a/src/zwave_ncp_serial_api_controller/config/app_properties_config.h +++ /dev/null @@ -1,65 +0,0 @@ -/***************************************************************************//** - * @file - * @brief Application Properties Header File - ******************************************************************************* - * # License - * Copyright 2021 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* - * - * SPDX-License-Identifier: Zlib - * - * The licensor of this software is Silicon Laboratories Inc. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - ******************************************************************************/ - -#ifndef APP_PROPERTIES_CONFIG_H -#define APP_PROPERTIES_CONFIG_H - -#include "sl_application_type.h" - -// <<< Use Configuration Wizard in Context Menu >>> - -// App Properties settings - -// Type of signature this application is signed with -// Default: APPLICATION_SIGNATURE_NONE(0) -#define SL_APPLICATION_SIGNATURE 0 - -// Location of the signature -// Default: 0xFFFFFFFF -#define SL_APPLICATION_SIGNATURE_LOCATION 0xFFFFFFFF - -// Bitfield representing type of application -#define SL_APPLICATION_TYPE APPLICATION_TYPE - -// Version number for this application -// <0-4294967295:1> -// Default: 1 [0-4294967295] -#define SL_APPLICATION_VERSION 1 - -// Capabilities of this application -// Default: 0 -#define SL_APPLICATION_CAPABILITIES 0 - -//Product ID of the device for which the application is built -#define SL_APPLICATION_PRODUCT_ID { 0 } - -// - -#endif // APP_PROPERTIES_CONFIG_H \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/config/btl_interface_cfg.h b/src/zwave_ncp_serial_api_controller/config/btl_interface_cfg.h deleted file mode 100644 index 13e09116..00000000 --- a/src/zwave_ncp_serial_api_controller/config/btl_interface_cfg.h +++ /dev/null @@ -1,48 +0,0 @@ -/***************************************************************************//** - * @file - * @brief Configuration header of Bootloader Interface - ******************************************************************************* - * # License - * Copyright 2021 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* - * - * The licensor of this software is Silicon Laboratories Inc. Your use of this - * software is governed by the terms of Silicon Labs Master Software License - * Agreement (MSLA) available at - * www.silabs.com/about-us/legal/master-software-license-agreement. This - * software is distributed to you in Source Code format and is governed by the - * sections of the MSLA applicable to Source Code. - * - ******************************************************************************/ -#ifndef BTL_INTERFACE_CFG_H -#define BTL_INTERFACE_CFG_H - -#if !defined(BOOTLOADER_APPLOADER) - -#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_1) -#include "btl_interface_cfg_s2c1.h" -#endif - -#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_2) -#include "btl_interface_cfg_s2c2.h" -#endif - -#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_3) -#include "btl_interface_cfg_s2c3.h" -#endif - -#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_4) -#include "btl_interface_cfg_s2c4.h" -#endif - -#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_5) -#define BOOTLOADER_DISABLE_OLD_BOOTLOADER_MITIGATION 1 -#endif - -#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_8) -#define BOOTLOADER_DISABLE_OLD_BOOTLOADER_MITIGATION 1 -#endif - -#endif // !BOOTLOADER_APPLOADER - -#endif // BTL_INTERFACE_CFG_H \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/config/emlib_core_debug_config.h b/src/zwave_ncp_serial_api_controller/config/emlib_core_debug_config.h deleted file mode 100644 index e4a01682..00000000 --- a/src/zwave_ncp_serial_api_controller/config/emlib_core_debug_config.h +++ /dev/null @@ -1,45 +0,0 @@ -/***************************************************************************//** - * @file - * @brief emlib_core Configuration - ******************************************************************************* - * # License - * Copyright 2019 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* - * - * SPDX-License-Identifier: Zlib - * - * The licensor of this software is Silicon Laboratories Inc. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - ******************************************************************************/ - -#ifndef EM_CORE_DEBUG_CONFIG_H -#define EM_CORE_DEBUG_CONFIG_H - -// <<< Use Configuration Wizard in Context Menu >>> - -// Core Configuration - -// Enables measuring of interrupt disable time for debugging purposes. -// Default: 0 -#define SL_EMLIB_CORE_ENABLE_INTERRUPT_DISABLED_TIMING 0 - -// - -// <<< end of configuration section >>> -#endif // EM_CORE_CONFIG_H \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13.h b/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13.h deleted file mode 100644 index f83a5e81..00000000 --- a/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Provides support for BRD8029A (Buttons and LEDs EXP Board) - * - * @copyright 2018 Silicon Laboratories Inc. - */ - -#ifndef EXTENSION_BOARD_8029A_EFR32XG13_H -#define EXTENSION_BOARD_8029A_EFR32XG13_H - -#include "extension_board_8029a_efr32xg13_button.h" -#include "extension_board_8029a_efr32xg13_led.h" -#include "extension_board_8029a_efr32xg13_slider.h" - -/*************************************************************************/ -/* Map physical board IO devices to application LEDs and buttons */ -/*************************************************************************/ - -/* Map application LEDs to board LEDs */ -#define APP_LED_A BOARD_LED1 -#define APP_LED_INDICATOR BOARD_LED2 // Positioned opposite APP_BUTTON_LEARN_RESET -#define APP_LED_B BOARD_LED4 -#define APP_LED_C BOARD_LED3 - -#define APP_RGB_R BOARD_RGB1_R -#define APP_RGB_G BOARD_RGB1_G -#define APP_RGB_B BOARD_RGB1_B - -/* Mapping application buttons to board buttons */ -#if defined(RADIO_BOARD_EFR32ZG13P32) || defined(RADIO_BOARD_EFR32ZG13L) || defined(RADIO_BOARD_EFR32ZG13S) -// The EFR32ZG13P32 device has reduced number of GPIO pins and therefore -// supports only two of our buttons -#define APP_BUTTON_A BOARD_BUTTON_PB4 -#define APP_BUTTON_LEARN_RESET BOARD_BUTTON_PB3 // Supports EM4 wakeup -#else -#define APP_BUTTON_A BOARD_BUTTON_PB1 -#define APP_BUTTON_LEARN_RESET BOARD_BUTTON_PB2 // Supports EM4 wakeup -#define APP_BUTTON_B BOARD_BUTTON_PB3 // Supports EM4 wakeup -#define APP_BUTTON_C BOARD_BUTTON_PB4 -#define APP_SLIDER_A BOARD_BUTTON_SLIDER1 -#endif - -/* The next two are identical since on the BRD8029A only PB2 and PB3 - * can trigger a wakeup from EM4. PB2 is already used for learn/reset - */ -#define APP_WAKEUP_BTN_SLDR BOARD_BUTTON_PB3 // Use this one when wakeup capability is required and button is preferred to slider -#define APP_WAKEUP_SLDR_BTN BOARD_BUTTON_PB3 // Use this one when wakeup capability is required and slider is preferred to button - -#endif /* EXTENSION_BOARD_8029A_EFR32XG13_H */ \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13_button.h b/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13_button.h deleted file mode 100644 index 8e4dcc1b..00000000 --- a/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13_button.h +++ /dev/null @@ -1,133 +0,0 @@ -/** - * Provides support for BRD8029A (Buttons on EXP Board) - * - * @copyright 2022 Silicon Laboratories Inc. - */ - -#ifndef EXTENSION_BOARD_8029A_EFR32XG13_BUTTON_H -#define EXTENSION_BOARD_8029A_EFR32XG13_BUTTON_H - -/*************************************************************************/ -/* Configure push buttons */ -/*************************************************************************/ - -/* NB: BTN0 on BRD8029A is connected in parallel with PB0 on BRD4001A - * (Wireless Starter Kit mainboard). Not a problem, the two buttons - * simply provide the same functionality. - */ - -// <<< Use Configuration Wizard in Context Menu >>> -// Button Configuration -#define PB1_LABEL "BTN0" - -// Button1 ON value -// <1=> Active high -// <0=> Active low -// 0 -#define PB1_ON_VALUE 0 - -// Button1 interrupt pin number -// 6 -#define PB1_INT_NO 6 - -// Button1 wake up from EM4 -// 0 -#define PB1_CAN_WAKEUP_EM4 0 - -#define PB2_LABEL "BTN1" - -// Button2 ON value -// <1=> Active high -// <0=> Active low -// 0 -#define PB2_ON_VALUE 0 - -// Button2 interrupt pin number -// 7 -#define PB2_INT_NO 7 - -// Button2 wake up from EM4 -// 1 -#define PB2_CAN_WAKEUP_EM4 1 - -#define PB3_LABEL "BTN2" - -// Button3 ON value -// <1=> Active high -// <0=> Active low -// 0 -#define PB3_ON_VALUE 0 - -// Button3 interrupt pin number -// 10 -#define PB3_INT_NO 10 - -// Button3 wake up from EM4 -// 1 -#define PB3_CAN_WAKEUP_EM4 1 - -#define PB4_LABEL "BTN3" - -// Button4 ON value -// <1=> Active high -// <0=> Active low -// 0 -#define PB4_ON_VALUE 0 - -// Button4 interrupt pin number -// 11 -#define PB4_INT_NO 11 - -// Button4 wake up from EM4 -// 0 -#define PB4_CAN_WAKEUP_EM4 0 - -// - -// <<< end of configuration section >>> - -// <<< sl:start pin_tool >>> - -// PB1_GPIO -// $[GPIO_PB1_GPIO] -#ifndef PB1_GPIO_PORT -#define PB1_GPIO_PORT gpioPortF -#endif -#ifndef PB1_GPIO_PIN -#define PB1_GPIO_PIN 6 -#endif -// [GPIO_PB1_GPIO]$ - -// PB2_GPIO -// $[GPIO_PB2_GPIO] -#ifndef PB2_GPIO_PORT -#define PB2_GPIO_PORT gpioPortF -#endif -#ifndef PB2_GPIO_PIN -#define PB2_GPIO_PIN 7 -#endif -// [GPIO_PB2_GPIO]$ - -// PB3_GPIO -// $[GPIO_PB3_GPIO] -#ifndef PB3_GPIO_PORT -#define PB3_GPIO_PORT gpioPortC -#endif -#ifndef PB3_GPIO_PIN -#define PB3_GPIO_PIN 10 -#endif -// [GPIO_PB3_GPIO]$ - -// PB4_GPIO -// $[GPIO_PB4_GPIO] -#ifndef PB4_GPIO_PORT -#define PB4_GPIO_PORT gpioPortC -#endif -#ifndef PB4_GPIO_PIN -#define PB4_GPIO_PIN 11 -#endif -// [GPIO_PB4_GPIO]$ - -// <<< sl:end pin_tool >>> - -#endif /* EXTENSION_BOARD_8029A_EFR32XG13_BUTTON_H */ diff --git a/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13_led.h b/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13_led.h deleted file mode 100644 index e6717eac..00000000 --- a/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13_led.h +++ /dev/null @@ -1,107 +0,0 @@ -/** - * Provides support for BRD8029A (LEDs on EXP Board) - * - * @copyright 2022 Silicon Laboratories Inc. - */ - -#ifndef EXTENSION_BOARD_8029A_EFR32XG13_LED_H -#define EXTENSION_BOARD_8029A_EFR32XG13_LED_H - -/*************************************************************************/ -/* Configure LEDs */ -/*************************************************************************/ - -/* NB: Mounted in parallel with "LED0" on the mainboard. - * - * EFR32 peripheral: (none) - */ - -// <<< Use Configuration Wizard in Context Menu >>> -// LED Configuration -// LED1 ON value -// <0=> Active low -// <1=> Active high -// 1 -#define LED1_ON_VALUE 1 - -// LED2 ON value -// <0=> Active low -// <1=> Active high -// 1 -#define LED2_ON_VALUE 1 - -// LED3 ON value -// <0=> Active low -// <1=> Active high -// 1 -#define LED3_ON_VALUE 1 - -// LED4 ON value -// <0=> Active low -// <1=> Active high -// 1 -#define LED4_ON_VALUE 1 - -// - -// <<< end of configuration section >>> - -// <<< sl:start pin_tool >>> - -#define LED1_LABEL "LED0" -// LED1_GPIO -// $[GPIO_LED1_GPIO] -#ifndef LED1_GPIO_PORT -#define LED1_GPIO_PORT gpioPortF -#endif -#ifndef LED1_GPIO_PIN -#define LED1_GPIO_PIN 4 -#endif -// [GPIO_LED1_GPIO]$ - -#define LED2_LABEL "LED1" -// LED2_GPIO -// $[GPIO_LED2_GPIO] -#ifndef LED2_GPIO_PORT -#define LED2_GPIO_PORT gpioPortF -#endif -#ifndef LED2_GPIO_PIN -#define LED2_GPIO_PIN 3 -#endif -// [GPIO_LED2_GPIO]$ - -#define LED3_LABEL "LED2" -// LED3_GPIO -// $[GPIO_LED3_GPIO] -#ifndef LED3_GPIO_PORT -#define LED3_GPIO_PORT gpioPortA -#endif -#ifndef LED3_GPIO_PIN -#define LED3_GPIO_PIN 2 -#endif -// [GPIO_LED3_GPIO]$ - -/* NB: EFR32 peripheral: US0_CS#0 - */ -#define LED4_LABEL "LED3" -// LED4_GPIO -// $[GPIO_LED4_GPIO] -#ifndef LED4_GPIO_PORT -#define LED4_GPIO_PORT gpioPortA -#endif -#ifndef LED4_GPIO_PIN -#define LED4_GPIO_PIN 3 -#endif -// [GPIO_LED4_GPIO]$ - -// <<< sl:end pin_tool >>> - -/*************************************************************************/ -/* Configure RGB LEDs */ -/*************************************************************************/ - -/* BRD8029A does not have any RGB led! - * If paired with radio board ZGM13 then the RGB on that board can be used - */ - -#endif /* EXTENSION_BOARD_8029A_EFR32XG13_LED_H */ diff --git a/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13_slider.h b/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13_slider.h deleted file mode 100644 index 7b13ffee..00000000 --- a/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13_slider.h +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Provides support for BRD8029A (Slider on EXP Board) - * - * @copyright 2022 Silicon Laboratories Inc. - */ - -#ifndef EXTENSION_BOARD_8029A_EFR32XG13_SLIDER_H -#define EXTENSION_BOARD_8029A_EFR32XG13_SLIDER_H - -/*************************************************************************/ -/* Configure slider button */ -/*************************************************************************/ - -// <<< Use Configuration Wizard in Context Menu >>> -// Slider Configuration -#define SLIDER1_LABEL "SW1" - -// Slider ON value -// <1=> Active high -// <0=> Active low -// 0 -#define SLIDER1_ON_VALUE 0 - -// Interrupt pin number -// 9 -#define SLIDER1_INT_NO 9 - -// Wake up from EM4 -// 0 -#define SLIDER1_CAN_WAKEUP_EM4 0 - -// - -// <<< end of configuration section >>> - -// <<< sl:start pin_tool >>> - -// SLIDER1_GPIO -// $[GPIO_SLIDER1_GPIO] -#ifndef SLIDER1_GPIO_PORT -#define SLIDER1_GPIO_PORT gpioPortC -#endif -#ifndef SLIDER1_GPIO_PIN -#define SLIDER1_GPIO_PIN 9 -#endif -// [GPIO_SLIDER1_GPIO]$ - -// <<< sl:end pin_tool >>> - -#endif /* EXTENSION_BOARD_8029A_EFR32XG13_SLIDER_H */ diff --git a/src/zwave_ncp_serial_api_controller/config/nvm3_default_config.h b/src/zwave_ncp_serial_api_controller/config/nvm3_default_config.h deleted file mode 100644 index 71bb6563..00000000 --- a/src/zwave_ncp_serial_api_controller/config/nvm3_default_config.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef NVM3_DEFAULT_CONFIG_H -#define NVM3_DEFAULT_CONFIG_H - -// <<< Use Configuration Wizard in Context Menu >>> - -// NVM3 Default Instance Configuration - -#ifndef NVM3_DEFAULT_CACHE_SIZE -// NVM3 Default Instance Cache Size -// Number of NVM3 objects to cache. To reduce access times this number -// should be equal to or higher than the number of NVM3 objects in the -// default NVM3 instance. -// Default: 200 -#define NVM3_DEFAULT_CACHE_SIZE 100 -#endif - -#ifndef NVM3_DEFAULT_MAX_OBJECT_SIZE -// NVM3 Default Instance Max Object Size -// Max NVM3 object size that can be stored. -// Default: 254 -#define NVM3_DEFAULT_MAX_OBJECT_SIZE 1900 -#endif - -#ifndef NVM3_DEFAULT_REPACK_HEADROOM -// NVM3 Default Instance User Repack Headroom -// Headroom determining how many bytes below the forced repack limit the user -// repack limit should be placed. The default is 0, which means the user and -// forced repack limits are equal. -// Default: 0 -#define NVM3_DEFAULT_REPACK_HEADROOM 0 -#endif - -#ifndef NVM3_DEFAULT_NVM_SIZE -// NVM3 Default Instance Size -// Size of the NVM3 storage region in flash. This size should be aligned with -// the flash page size of the device. -// Default: 36864 -#define NVM3_DEFAULT_NVM_SIZE 36864 -#endif - -// - -// <<< end of configuration section >>> - -#endif // NVM3_DEFAULT_CONFIG_H \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/config/pin_config.h b/src/zwave_ncp_serial_api_controller/config/pin_config.h deleted file mode 100644 index 740e8856..00000000 --- a/src/zwave_ncp_serial_api_controller/config/pin_config.h +++ /dev/null @@ -1,159 +0,0 @@ -#ifndef PIN_CONFIG_H -#define PIN_CONFIG_H - -// $[ACMP0] -// [ACMP0]$ - -// $[ACMP1] -// [ACMP1]$ - -// $[ADC0] -// [ADC0]$ - -// $[CMU] -// [CMU]$ - -// $[CSEN] -// [CSEN]$ - -// $[DBG] -// DBG SWV on PF2 -#ifndef DBG_SWV_PORT -#define DBG_SWV_PORT gpioPortF -#endif -#ifndef DBG_SWV_PIN -#define DBG_SWV_PIN 2 -#endif -#ifndef DBG_SWV_LOC -#define DBG_SWV_LOC 0 -#endif - -// [DBG]$ - -// $[ETM] -// [ETM]$ - -// $[PTI] -// [PTI]$ - -// $[GPIO] -// [GPIO]$ - -// $[I2C0] -// [I2C0]$ - -// $[I2C1] -// [I2C1]$ - -// $[IDAC0] -// [IDAC0]$ - -// $[LESENSE] -// [LESENSE]$ - -// $[LETIMER0] -// [LETIMER0]$ - -// $[LEUART0] -// [LEUART0]$ - -// $[LFXO] -// [LFXO]$ - -// $[MODEM] -// [MODEM]$ - -// $[PCNT0] -// [PCNT0]$ - -// $[PRS.CH0] -// [PRS.CH0]$ - -// $[PRS.CH1] -// [PRS.CH1]$ - -// $[PRS.CH2] -// [PRS.CH2]$ - -// $[PRS.CH3] -// [PRS.CH3]$ - -// $[PRS.CH4] -// [PRS.CH4]$ - -// $[PRS.CH5] -// [PRS.CH5]$ - -// $[PRS.CH6] -// [PRS.CH6]$ - -// $[PRS.CH7] -// [PRS.CH7]$ - -// $[PRS.CH8] -// [PRS.CH8]$ - -// $[PRS.CH9] -// [PRS.CH9]$ - -// $[PRS.CH10] -// [PRS.CH10]$ - -// $[PRS.CH11] -// [PRS.CH11]$ - -// $[TIMER0] -// [TIMER0]$ - -// $[TIMER1] -// [TIMER1]$ - -// $[USART0] -// USART0 RX on PA1 -#ifndef USART0_RX_PORT -#define USART0_RX_PORT gpioPortA -#endif -#ifndef USART0_RX_PIN -#define USART0_RX_PIN 1 -#endif -#ifndef USART0_RX_LOC -#define USART0_RX_LOC 0 -#endif - -// USART0 TX on PA0 -#ifndef USART0_TX_PORT -#define USART0_TX_PORT gpioPortA -#endif -#ifndef USART0_TX_PIN -#define USART0_TX_PIN 0 -#endif -#ifndef USART0_TX_LOC -#define USART0_TX_LOC 0 -#endif - -// [USART0]$ - -// $[USART1] -// [USART1]$ - -// $[USART2] -// [USART2]$ - -// $[VDAC0] -// [VDAC0]$ - -// $[WTIMER0] -// [WTIMER0]$ - -// $[CUSTOM_PIN_NAME] -#ifndef _PORT -#define _PORT gpioPortA -#endif -#ifndef _PIN -#define _PIN 0 -#endif - -// [CUSTOM_PIN_NAME]$ - -#endif // PIN_CONFIG_H - diff --git a/src/zwave_ncp_serial_api_controller/config/serial_api_config.h b/src/zwave_ncp_serial_api_controller/config/serial_api_config.h deleted file mode 100644 index 0d025455..00000000 --- a/src/zwave_ncp_serial_api_controller/config/serial_api_config.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @file - * Serial API Configuration - * @copyright 2022 Silicon Laboratories Inc. - */ -#ifndef SERIAL_API_CONFIG_H -#define SERIAL_API_CONFIG_H - -#include - -// <<< sl:start pin_tool >>> - -// SERIAL_API - -// $[USART_SERIAL_API] -#ifndef SERIAL_API_PERIPHERAL -#define SERIAL_API_PERIPHERAL USART0 -#endif -#ifndef SERIAL_API_PERIPHERAL_NO -#define SERIAL_API_PERIPHERAL_NO 0 -#endif - -// USART0 TX on PA0 -#ifndef SERIAL_API_TX_PORT -#define SERIAL_API_TX_PORT gpioPortA -#endif -#ifndef SERIAL_API_TX_PIN -#define SERIAL_API_TX_PIN 0 -#endif -#ifndef SERIAL_API_TX_LOC -#define SERIAL_API_TX_LOC 0 -#endif - -// USART0 RX on PA1 -#ifndef SERIAL_API_RX_PORT -#define SERIAL_API_RX_PORT gpioPortA -#endif -#ifndef SERIAL_API_RX_PIN -#define SERIAL_API_RX_PIN 1 -#endif -#ifndef SERIAL_API_RX_LOC -#define SERIAL_API_RX_LOC 0 -#endif -// [USART_SERIAL_API]$ - -// <<< sl:end pin_tool >>> - -#endif // SERIAL_API_CONFIG_H diff --git a/src/zwave_ncp_serial_api_controller/config/sl_board_control_config.h b/src/zwave_ncp_serial_api_controller/config/sl_board_control_config.h deleted file mode 100644 index 3faa30a6..00000000 --- a/src/zwave_ncp_serial_api_controller/config/sl_board_control_config.h +++ /dev/null @@ -1,84 +0,0 @@ -/***************************************************************************//** - * @file - * @brief Board Control - ******************************************************************************* - * # License - * Copyright 2022 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* - * - * SPDX-License-Identifier: Zlib - * - * The licensor of this software is Silicon Laboratories Inc. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - ******************************************************************************/ - -#ifndef SL_BOARD_CONTROL_CONFIG_H -#define SL_BOARD_CONTROL_CONFIG_H - -// <<< Use Configuration Wizard in Context Menu >>> - -// Enable Virtual COM UART -// Default: 0 -#define SL_BOARD_ENABLE_VCOM 1 - -// Enable Display -// Default: 0 -#define SL_BOARD_ENABLE_DISPLAY 0 - -// Enable Relative Humidity and Temperature sensor -// Default: 0 -#define SL_BOARD_ENABLE_SENSOR_RHT 0 - -// <<< end of configuration section >>> - -// <<< sl:start pin_tool >>> - -// SL_BOARD_ENABLE_VCOM -// $[GPIO_SL_BOARD_ENABLE_VCOM] -#ifndef SL_BOARD_ENABLE_VCOM_PORT -#define SL_BOARD_ENABLE_VCOM_PORT gpioPortA -#endif -#ifndef SL_BOARD_ENABLE_VCOM_PIN -#define SL_BOARD_ENABLE_VCOM_PIN 5 -#endif -// [GPIO_SL_BOARD_ENABLE_VCOM]$ - -// SL_BOARD_ENABLE_DISPLAY -// $[GPIO_SL_BOARD_ENABLE_DISPLAY] -#ifndef SL_BOARD_ENABLE_DISPLAY_PORT -#define SL_BOARD_ENABLE_DISPLAY_PORT gpioPortD -#endif -#ifndef SL_BOARD_ENABLE_DISPLAY_PIN -#define SL_BOARD_ENABLE_DISPLAY_PIN 15 -#endif -// [GPIO_SL_BOARD_ENABLE_DISPLAY]$ - -// SL_BOARD_ENABLE_SENSOR_RHT -// $[GPIO_SL_BOARD_ENABLE_SENSOR_RHT] -#ifndef SL_BOARD_ENABLE_SENSOR_RHT_PORT -#define SL_BOARD_ENABLE_SENSOR_RHT_PORT gpioPortD -#endif -#ifndef SL_BOARD_ENABLE_SENSOR_RHT_PIN -#define SL_BOARD_ENABLE_SENSOR_RHT_PIN 15 -#endif -// [GPIO_SL_BOARD_ENABLE_SENSOR_RHT]$ - -// <<< sl:end pin_tool >>> - -#endif // SL_BOARD_CONTROL_CONFIG_H diff --git a/src/zwave_ncp_serial_api_controller/config/sl_debug_swo_config.h b/src/zwave_ncp_serial_api_controller/config/sl_debug_swo_config.h deleted file mode 100644 index 75896a71..00000000 --- a/src/zwave_ncp_serial_api_controller/config/sl_debug_swo_config.h +++ /dev/null @@ -1,109 +0,0 @@ -/***************************************************************************//** - * @file - * @brief SWO configuration - ******************************************************************************* - * # License - * Copyright 2020 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* - * - * SPDX-License-Identifier: Zlib - * - * The licensor of this software is Silicon Laboratories Inc. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - ******************************************************************************/ - -#ifndef SL_DEBUG_SWO_CONFIG_H -#define SL_DEBUG_SWO_CONFIG_H - -// <<< Use Configuration Wizard in Context Menu >>> - -// SWO Configuration - -// SWO Frequency -// Must be 875 kHz for communication with Silicon Labs debuggers -// Default: 875000 -#define SL_DEBUG_SWO_FREQ 875000 - -// Enable interrupt event trace -// Default: 0 -#define SL_DEBUG_SWO_SAMPLE_IRQ 0 - -// Enable Program Counter samples -// Default: 0 -#define SL_DEBUG_SWO_SAMPLE_PC 0 - -// SWO debug sample intervals -// <64=> 64 -// <128=> 128 -// <192=> 192 -// <256=> 256 -// <320=> 320 -// <384=> 384 -// <448=> 448 -// <512=> 512 -// <576=> 576 -// <640=> 640 -// <704=> 704 -// <768=> 768 -// <832=> 832 -// <896=> 896 -// <960=> 960 -// <1024=> 1024 -// <2048=> 2048 -// <3072=> 3072 -// <4096=> 4096 -// <5102=> 5102 -// <6144=> 6144 -// <7168=> 7168 -// <8192=> 8192 -// <9216=> 9216 -// <10240=> 10240 -// <11264=> 11264 -// <12288=> 12288 -// <13312=> 13312 -// <14336=> 14336 -// <15360=> 15360 -// Must be 64, 128, 192, [ n * 64 ], 1024, 2048, 3072, [ n * 1024 ] , 15360 -// Default: 15360 -#define SL_DEBUG_SWO_SAMPLE_INTERVAL 15360 -// - -// <<< end of configuration section >>> - -// <<< sl:start pin_tool >>> -// SL_DEBUG -// $[DBG_SL_DEBUG] -#ifndef SL_DEBUG_PERIPHERAL -#define SL_DEBUG_PERIPHERAL DBG -#endif - -// DBG SWV on PF2 -#ifndef SL_DEBUG_SWV_PORT -#define SL_DEBUG_SWV_PORT gpioPortF -#endif -#ifndef SL_DEBUG_SWV_PIN -#define SL_DEBUG_SWV_PIN 2 -#endif -#ifndef SL_DEBUG_SWV_LOC -#define SL_DEBUG_SWV_LOC 0 -#endif -// [DBG_SL_DEBUG]$ -// <<< sl:end pin_tool >>> - -#endif // SL_DEBUG_SWO_CONFIG_H diff --git a/src/zwave_ncp_serial_api_controller/config/sl_device_init_dcdc_config.h b/src/zwave_ncp_serial_api_controller/config/sl_device_init_dcdc_config.h deleted file mode 100644 index e3deec07..00000000 --- a/src/zwave_ncp_serial_api_controller/config/sl_device_init_dcdc_config.h +++ /dev/null @@ -1,58 +0,0 @@ -/***************************************************************************//** - * @file - * @brief DEVICE_INIT_DCDC Config - ******************************************************************************* - * # License - * Copyright 2022 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* - * - * SPDX-License-Identifier: Zlib - * - * The licensor of this software is Silicon Laboratories Inc. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - ******************************************************************************/ - -#ifndef SL_DEVICE_INIT_DCDC_CONFIG_H -#define SL_DEVICE_INIT_DCDC_CONFIG_H - -// <<< Use Configuration Wizard in Context Menu >>> - -// Enable DC/DC Converter -// -// Default: 1 -#define SL_DEVICE_INIT_DCDC_ENABLE 1 - -// Set DC/DC Converter in Bypass Mode -// -// Default: 0 -#define SL_DEVICE_INIT_DCDC_BYPASS 1 - -// Override for DCDC PFMX Mode Peak Current Setting -// -// Default: 0 -#define SL_DEVICE_INIT_DCDC_PFMX_IPKVAL_OVERRIDE 0 - -// DCDC PFMX Mode Peak Current Setting <0-15> -// -// Default: DCDC_PFMXCTRL_IPKVAL_DEFAULT -#define SL_DEVICE_INIT_DCDC_PFMX_IPKVAL DCDC_PFMXCTRL_IPKVAL_DEFAULT - -// <<< end of configuration section >>> - -#endif // SL_DEVICE_INIT_DCDC_CONFIG_H \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/config/sl_device_init_emu_config.h b/src/zwave_ncp_serial_api_controller/config/sl_device_init_emu_config.h deleted file mode 100644 index 68a04c23..00000000 --- a/src/zwave_ncp_serial_api_controller/config/sl_device_init_emu_config.h +++ /dev/null @@ -1,68 +0,0 @@ -/***************************************************************************//** - * @file - * @brief DEVICE_INIT_EMU Config - ******************************************************************************* - * # License - * Copyright 2019 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* - * - * SPDX-License-Identifier: Zlib - * - * The licensor of this software is Silicon Laboratories Inc. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - ******************************************************************************/ - -#ifndef SL_DEVICE_INIT_EMU_CONFIG_H -#define SL_DEVICE_INIT_EMU_CONFIG_H - -#include "em_emu.h" - -// <<< Use Configuration Wizard in Context Menu >>> - -// EM4H Voltage scaling level -// Fast-wakeup voltage level -// Low-power optimized voltage level -// Default: emuVScaleEM4H_LowPower -#define SL_DEVICE_INIT_EMU_EM4_VSCALE emuVScaleEM4H_LowPower - -// Retain LFXO in EM4 -#define SL_DEVICE_INIT_EMU_EM4_RETAIN_LFXO 0 - -// Retain LFRCO in EM4 -#define SL_DEVICE_INIT_EMU_EM4_RETAIN_LFRCO 1 - -// Retain ULFRCO in EM4S -#define SL_DEVICE_INIT_EMU_EM4_RETAIN_ULFRCO 0 - -// Hibernate or shutoff EM4 state -// EM4 Shutoff -// EM4 Hibernate -// Default: emuEM4Shutoff -#define SL_DEVICE_INIT_EMU_EM4_STATE emuEM4Hibernate - -// EM4 pin retention mode -// No Retention: Pads enter reset state when entering EM4. -// Retention through EM4: Pads enter reset state when exiting EM4. -// Retention through EM4 and wakeup. -// Default: emuPinRetentionDisable -#define SL_DEVICE_INIT_EMU_EM4_PIN_RETENTION_MODE emuPinRetentionLatch - -// <<< end of configuration section >>> - -#endif // SL_DEVICE_INIT_EMU_CONFIG_H \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/config/sl_device_init_hfxo_config.h b/src/zwave_ncp_serial_api_controller/config/sl_device_init_hfxo_config.h deleted file mode 100644 index d8e42433..00000000 --- a/src/zwave_ncp_serial_api_controller/config/sl_device_init_hfxo_config.h +++ /dev/null @@ -1,72 +0,0 @@ -/***************************************************************************//** - * @file - * @brief DEVICE_INIT_HFXO Config - ******************************************************************************* - * # License - * Copyright 2022 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* - * - * SPDX-License-Identifier: Zlib - * - * The licensor of this software is Silicon Laboratories Inc. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - ******************************************************************************/ - -#ifndef SL_DEVICE_INIT_HFXO_CONFIG_H -#define SL_DEVICE_INIT_HFXO_CONFIG_H - -// <<< Use Configuration Wizard in Context Menu >>> - -// Mode -// -// Crystal oscillator -// External digital clock -// Default: cmuOscMode_Crystal -#define SL_DEVICE_INIT_HFXO_MODE cmuOscMode_Crystal - -// Frequency <38000000-40000000> -// Default: 39000000 -#define SL_DEVICE_INIT_HFXO_FREQ 39000000 - -// HFXO precision in PPM <0-65535> -// Default: 500 -#define SL_DEVICE_INIT_HFXO_PRECISION 500 - -// CTUNE <0-511> -// Default: 360 -#define SL_DEVICE_INIT_HFXO_CTUNE 319 - -// Advanced Configurations -// Auto-start HFXO. This feature is incompatible with Power Manager and can only be enabled in applications that do not use Power Manager or a radio protocol stack. - DEPRECATED -// True -// False -// Default: false -#define SL_DEVICE_INIT_HFXO_AUTOSTART false - -// Auto-select HFXO. This feature is incompatible with Power Manager and can only be enabled in applications that do not use Power Manager or a radio protocol stack. - DEPRECATED -// True -// False -// Default: false -#define SL_DEVICE_INIT_HFXO_AUTOSELECT false - -// - -// <<< end of configuration section >>> - -#endif // SL_DEVICE_INIT_HFXO_CONFIG_H \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/config/sl_fem_util_config.h b/src/zwave_ncp_serial_api_controller/config/sl_fem_util_config.h deleted file mode 100644 index f7d358dd..00000000 --- a/src/zwave_ncp_serial_api_controller/config/sl_fem_util_config.h +++ /dev/null @@ -1,95 +0,0 @@ -/***************************************************************************//** - * @file - * @brief Front End Module configuration file. - ******************************************************************************* - * # License - * Copyright 2020 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* - * - * SPDX-License-Identifier: Zlib - * - * The licensor of this software is Silicon Laboratories Inc. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - ******************************************************************************/ - -#ifndef SL_FEM_UTIL_CONFIG_H -#define SL_FEM_UTIL_CONFIG_H - -#include "em_gpio.h" - -// <<< Use Configuration Wizard in Context Menu >>> -// FEM Configuration -// Enable RX Mode -// Default: 0 -#define SL_FEM_UTIL_RX_ENABLE 0 -// Enable TX Mode -// Default: 0 -#define SL_FEM_UTIL_TX_ENABLE 0 -// Enable Bypass Mode -// Default: 0 -#define SL_FEM_UTIL_BYPASS_ENABLE 0 -// Enable TX High Power Mode -// Default: 0 -#define SL_FEM_UTIL_TX_HIGH_POWER_ENABLE 0 -// -// <<< end of configuration section >>> - -// <<< sl:start pin_tool >>> -// SL_FEM_UTIL_RX -// $[PRS_SL_FEM_UTIL_RX] -//#define SL_FEM_UTIL_RX_CHANNEL 5 - -// PRS CH5 on PD10 -//#define SL_FEM_UTIL_RX_PORT gpioPortD -//#define SL_FEM_UTIL_RX_PIN 10 -//#define SL_FEM_UTIL_RX_LOC 0 - -// [PRS_SL_FEM_UTIL_RX]$ - -// SL_FEM_UTIL_TX -// $[PRS_SL_FEM_UTIL_TX] - -// [PRS_SL_FEM_UTIL_TX]$ - -// SL_FEM_UTIL_SLEEP -// $[PRS_SL_FEM_UTIL_SLEEP] -//#define SL_FEM_UTIL_SLEEP_CHANNEL 6 - -// PRS CH6 on PD11 -//#define SL_FEM_UTIL_SLEEP_PORT gpioPortD -//#define SL_FEM_UTIL_SLEEP_PIN 11 -//#define SL_FEM_UTIL_SLEEP_LOC 13 - -// [PRS_SL_FEM_UTIL_SLEEP]$ - -// SL_FEM_UTIL_BYPASS -// $[GPIO_SL_FEM_UTIL_BYPASS] - -// [GPIO_SL_FEM_UTIL_BYPASS]$ - -// SL_FEM_UTIL_TX_HIGH_POWER -// $[GPIO_SL_FEM_UTIL_TX_HIGH_POWER] - -// [GPIO_SL_FEM_UTIL_TX_HIGH_POWER]$ -// <<< sl:end pin_tool >>> - -#define SL_FEM_UTIL_OPTIMIZED_PHY_ENABLE 0 -#define SL_FEM_UTIL_RUNTIME_PHY_SELECT 0 - -#endif // SL_FEM_UTIL_CONFIG_H \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/config/sl_memory_config.h b/src/zwave_ncp_serial_api_controller/config/sl_memory_config.h deleted file mode 100644 index 1c580349..00000000 --- a/src/zwave_ncp_serial_api_controller/config/sl_memory_config.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef SL_MEMORY_CONFIG_H -#define SL_MEMORY_CONFIG_H - -// <<< Use Configuration Wizard in Context Menu >>> -// Memory configuration - -// Stack size for the application. -// Default: 4096 -// The stack size configured here will be used by the stack that the -// application uses when coming out of a reset. -#ifndef SL_STACK_SIZE - #define SL_STACK_SIZE 1280 -#endif - -// Minimum heap size for the application. -// Default: 2048 -// Note that this value will configure the c heap which is normally used by -// malloc() and free() from the c library. The value defines a minimum heap -// size that is guaranteed to be available. The available heap may be larger -// to make use of any memory that would otherwise remain unused. -#ifndef SL_HEAP_SIZE - #define SL_HEAP_SIZE 128 -#endif - -// -// <<< end of configuration section >>> - -#endif diff --git a/src/zwave_ncp_serial_api_controller/config/sl_power_manager_config.h b/src/zwave_ncp_serial_api_controller/config/sl_power_manager_config.h deleted file mode 100644 index e4b1da09..00000000 --- a/src/zwave_ncp_serial_api_controller/config/sl_power_manager_config.h +++ /dev/null @@ -1,64 +0,0 @@ -/***************************************************************************//** - * @file - * @brief Power Manager configuration file. - ******************************************************************************* - * # License - * Copyright 2020 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* - * - * SPDX-License-Identifier: Zlib - * - * The licensor of this software is Silicon Laboratories Inc. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - ******************************************************************************/ - -// <<< Use Configuration Wizard in Context Menu >>> - -#ifndef SL_POWER_MANAGER_CONFIG_H -#define SL_POWER_MANAGER_CONFIG_H - -// Power Manager Configuration - -// Enable custom IRQ handler for external HF oscillator. -// Enable if CMU_IRQHandler/HFXO0_IRQHandler is needed from your application. -// The function sl_power_manager_irq_handler() will have to be called from you custom handler if this is enabled. -// Default: 0 -#define SL_POWER_MANAGER_CUSTOM_HF_OSCILLATOR_IRQ_HANDLER 0 - -// Enable fast wakeup (disable voltage scaling in EM2/3 mode) -// Enable or disable voltage scaling in EM2/3 modes (when available). This decreases wakeup time by about 30 us. -// Deprecated. It is replaced by the function sl_power_manager_em23_voltage_scaling_enable_fast_wakeup() -// Default: 0 -#define SL_POWER_MANAGER_CONFIG_VOLTAGE_SCALING_FAST_WAKEUP 0 - -// Enable debugging feature -// Enable or disable debugging features (trace the different modules that have requirements). -// Default: 0 -#define SL_POWER_MANAGER_DEBUG 0 - -// Maximum numbers of requirements that can be logged -// Default: 10 -#define SL_POWER_MANAGER_DEBUG_POOL_SIZE 10 -// - -// - -#endif /* SL_POWER_MANAGER_CONFIG_H */ - -// <<< end of configuration section >>> \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/config/sl_rail_util_pa_config.h b/src/zwave_ncp_serial_api_controller/config/sl_rail_util_pa_config.h deleted file mode 100644 index 0c983c34..00000000 --- a/src/zwave_ncp_serial_api_controller/config/sl_rail_util_pa_config.h +++ /dev/null @@ -1,80 +0,0 @@ -/***************************************************************************//** - * @file - * @brief Power Amplifier configuration file. - ******************************************************************************* - * # License - * Copyright 2020 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* - * - * SPDX-License-Identifier: Zlib - * - * The licensor of this software is Silicon Laboratories Inc. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - ******************************************************************************/ - -#ifndef SL_RAIL_UTIL_PA_CONFIG_H -#define SL_RAIL_UTIL_PA_CONFIG_H - -#include "rail_types.h" - -// <<< Use Configuration Wizard in Context Menu >>> - -// PA Configuration -// Initial PA Power (deci-dBm, 100 = 10.0 dBm) -// Default: 100 -#define SL_RAIL_UTIL_PA_POWER_DECI_DBM 100 -// PA Ramp Time (microseconds) -// <0-65535:1> -// Default: 10 -#define SL_RAIL_UTIL_PA_RAMP_TIME_US 10 -// Milli-volts on PA supply pin (PA_VDD) -// <0-65535:1> -// Default: 3300 -#define SL_RAIL_UTIL_PA_VOLTAGE_MV 1800 -// 2.4 GHz PA Selection -// High Power -// Low Power -// Disable -// Default: RAIL_TX_POWER_MODE_2P4GIG_HP -#define SL_RAIL_UTIL_PA_SELECTION_2P4GHZ RAIL_TX_POWER_MODE_NONE -// Sub-1 GHz PA Selection -// Enable -// Disable -// Default: RAIL_TX_POWER_MODE_SUBGIG -#define SL_RAIL_UTIL_PA_SELECTION_SUBGHZ RAIL_TX_POWER_MODE_SUBGIG -// - -// PA Curve Configuration -// Header file containing custom PA curves -// Default: "pa_curves_efr32.h" -#define SL_RAIL_UTIL_PA_CURVE_HEADER "pa_curves_efr32.h" -// Header file containing PA curve types -// Default: "pa_curve_types_efr32.h" -#define SL_RAIL_UTIL_PA_CURVE_TYPES "pa_curve_types_efr32.h" -// - -// PA Calibration Configuration -// Apply PA Calibration Factory Offset -// Default: 1 -#define SL_RAIL_UTIL_PA_CALIBRATION_ENABLE 1 -// - -// <<< end of configuration section >>> - -#endif // SL_RAIL_UTIL_PA_CONFIG_H \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/config/sl_rail_util_power_manager_init_config.h b/src/zwave_ncp_serial_api_controller/config/sl_rail_util_power_manager_init_config.h deleted file mode 100644 index a9df48b4..00000000 --- a/src/zwave_ncp_serial_api_controller/config/sl_rail_util_power_manager_init_config.h +++ /dev/null @@ -1,44 +0,0 @@ -/***************************************************************************//** - * @file - * @brief RAIL power manager configuration file. - ******************************************************************************* - * # License - * Copyright 2020 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* - * - * SPDX-License-Identifier: Zlib - * - * The licensor of this software is Silicon Laboratories Inc. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - ******************************************************************************/ - -#ifndef SL_RAIL_UTIL_POWER_MANAGER_INIT_CONFIG_H -#define SL_RAIL_UTIL_POWER_MANAGER_INIT_CONFIG_H - -// <<< Use Configuration Wizard in Context Menu >>> - -// RAIL power manager configuration - -// Enable RAIL power manager initialization -// Default: 1 -#define SL_RAIL_UTIL_RAIL_POWER_MANAGER_INIT 0 - -// -// <<< end of configuration section >>> -#endif // SL_RAIL_UTIL_POWER_MANAGER_INIT_CONFIG_H \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/config/sl_rail_util_sequencer_config.h b/src/zwave_ncp_serial_api_controller/config/sl_rail_util_sequencer_config.h deleted file mode 100644 index 9a584a07..00000000 --- a/src/zwave_ncp_serial_api_controller/config/sl_rail_util_sequencer_config.h +++ /dev/null @@ -1,48 +0,0 @@ -/***************************************************************************//** - * @file - * @brief - ******************************************************************************* - * # License - * Copyright 2023 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* - * - * SPDX-License-Identifier: Zlib - * - * The licensor of this software is Silicon Laboratories Inc. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - ******************************************************************************/ - -#ifndef SL_RAIL_UTIL_SEQUENCER_H -#define SL_RAIL_UTIL_SEQUENCER_H - -#include "rail.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define SL_RAIL_UTIL_SEQUENCER_RUNTIME_IMAGE_SELECTION 0 - -#define SL_RAIL_UTIL_SEQUENCER_IMAGE RAIL_SEQ_IMAGE_ZWAVE - -#ifdef __cplusplus -} -#endif - -#endif // SL_RAIL_UTIL_SEQUENCER_H \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/config/sl_sleeptimer_config.h b/src/zwave_ncp_serial_api_controller/config/sl_sleeptimer_config.h deleted file mode 100644 index bba646d6..00000000 --- a/src/zwave_ncp_serial_api_controller/config/sl_sleeptimer_config.h +++ /dev/null @@ -1,82 +0,0 @@ -/***************************************************************************//** - * @file - * @brief Sleep Timer configuration file. - ******************************************************************************* - * # License - * Copyright 2020 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* - * - * SPDX-License-Identifier: Zlib - * - * The licensor of this software is Silicon Laboratories Inc. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - ******************************************************************************/ - -// <<< Use Configuration Wizard in Context Menu >>> - -#ifndef SL_SLEEPTIMER_CONFIG_H -#define SL_SLEEPTIMER_CONFIG_H - -#define SL_SLEEPTIMER_PERIPHERAL_DEFAULT 0 -#define SL_SLEEPTIMER_PERIPHERAL_RTCC 1 -#define SL_SLEEPTIMER_PERIPHERAL_PRORTC 2 -#define SL_SLEEPTIMER_PERIPHERAL_RTC 3 -#define SL_SLEEPTIMER_PERIPHERAL_SYSRTC 4 -#define SL_SLEEPTIMER_PERIPHERAL_BURTC 5 -#define SL_SLEEPTIMER_PERIPHERAL_WTIMER 6 -#define SL_SLEEPTIMER_PERIPHERAL_TIMER 7 - -// Timer Peripheral Used by Sleeptimer -// Default (auto select) -// RTCC -// Radio internal RTC (PRORTC) -// RTC -// SYSRTC -// Back-Up RTC (BURTC) -// WTIMER -// TIMER -// Selection of the Timer Peripheral Used by the Sleeptimer -#define SL_SLEEPTIMER_PERIPHERAL SL_SLEEPTIMER_PERIPHERAL_DEFAULT - -// TIMER/WTIMER Instance Used by Sleeptimer (not applicable for other peripherals) -// Make sure TIMER instance size is 32bits. Check datasheet for 32bits TIMERs. -// Default: 0 -#define SL_SLEEPTIMER_TIMER_INSTANCE 0 - -// Enable wallclock functionality -// Enable or disable wallclock functionalities (get_time, get_date, etc). -// Default: 0 -#define SL_SLEEPTIMER_WALLCLOCK_CONFIG 0 - -// Timer frequency divider (not applicable for WTIMER/TIMER) -// WTIMER/TIMER peripherals are always prescaled to 1024. -// Default: 1 -#define SL_SLEEPTIMER_FREQ_DIVIDER 1 - -// If Radio internal RTC (PRORTC) HAL is used, determines if it owns the IRQ handler. Enable, if no wireless stack is used. -// Default: 0 -#define SL_SLEEPTIMER_PRORTC_HAL_OWNS_IRQ_HANDLER 0 - -// Enable DEBUGRUN functionality on hardware RTC. -// Default: 0 -#define SL_SLEEPTIMER_DEBUGRUN 0 - -#endif /* SLEEPTIMER_CONFIG_H */ - -// <<< end of configuration section >>> \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/config/zaf_appname_config.h b/src/zwave_ncp_serial_api_controller/config/zaf_appname_config.h deleted file mode 100644 index c52bf4a4..00000000 --- a/src/zwave_ncp_serial_api_controller/config/zaf_appname_config.h +++ /dev/null @@ -1,30 +0,0 @@ -/***************************************************************************//** - * # License - * Copyright 2023 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* - * - * The licensor of this software is Silicon Laboratories Inc. Your use of this - * software is governed by the terms of the Silicon Labs Master Software License - * Agreement (MSLA) available at - * https://www.silabs.com/about-us/legal/master-software-license-agreement - * By installing, copying or otherwise using this software, you agree to the - * terms of the MSLA. - * - ******************************************************************************/ - -#ifndef _ZAF_APPNAME_CONFIG_H_ -#define _ZAF_APPNAME_CONFIG_H_ - -// <<< Use Configuration Wizard in Context Menu >>> - -// ZAF Application Name Configuration - -// Application Name -// "zwave_application" -#define ZAF_APP_NAME "serial_api_controller" - -// - -// <<< end of configuration section >>> - -#endif /* _ZAF_APPNAME_CONFIG_H_ */ \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/config/zaf_config.h b/src/zwave_ncp_serial_api_controller/config/zaf_config.h deleted file mode 100644 index a51b4bf3..00000000 --- a/src/zwave_ncp_serial_api_controller/config/zaf_config.h +++ /dev/null @@ -1,400 +0,0 @@ -/***************************************************************************//** - * # License - * Copyright 2023 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* - * - * The licensor of this software is Silicon Laboratories Inc. Your use of this - * software is governed by the terms of the Silicon Labs Master Software License - * Agreement (MSLA) available at - * https://www.silabs.com/about-us/legal/master-software-license-agreement - * By installing, copying or otherwise using this software, you agree to the - * terms of the MSLA. - * - ******************************************************************************/ - -#ifndef _ZAF_CONFIG_H_ -#define _ZAF_CONFIG_H_ - -// <<< Use Configuration Wizard in Context Menu >>> - -// Command Class Firmware Update - Bootloader update - -// The bootloader target id <1..255:1> -// If the bootloader update is enabled -// This determines which target id should be used by the bootloader firmware -// Default: 1 -#define ZAF_CONFIG_BOOTLOADER_TARGET_ID 1 - -// Indicates if the bootloader can be updated -// Includes the bootloader as a target -// Default: 0 -#define ZAF_CONFIG_BOOTLOADER_UPGRADABLE 0 - -// -// Command Class Firmware Update - Firmware targets - -// Number of firmware targets <0..10:1> -// Defines the number of supported firmware targets. Setting this number to more than 1 requires -// the application to implement CC_Version_GetFirmwareVersion_handler(). The default value is 1 -// because firmware target 0 is the Z-Wave application firmware (including Z-Wave stack). -// Default: 1 -#define ZAF_CONFIG_FIRMWARE_TARGET_COUNT 1 - -// -// Command Class ZwavePlusInfo Configuration - -// User Icon Type -// User Icon Type reported in Z-Wave Plus Info Report Command -// GENERIC_BARRIER -// GENERIC_CENTRAL_CONTROLLER -// GENERIC_DIMMER_WALL_SWITCH -// GENERIC_DISPLAY_SIMPLE -// GENERIC_DOOR_LOCK_KEYPAD -// GENERIC_ENTRY_CONTROL -// GENERIC_FAN_SWITCH -// GENERIC_GATEWAY -// GENERIC_IRRIGATION -// GENERIC_LIGHT_DIMMER_SWITCH -// GENERIC_ON_OFF_POWER_SWITCH -// GENERIC_ON_OFF_WALL_SWITCH -// GENERIC_POWER_STRIP -// GENERIC_REMOTE_CONTROL_AV -// GENERIC_REMOTE_CONTROL_MULTI_PURPOSE -// GENERIC_REMOTE_CONTROL_SIMPLE -// GENERIC_REPEATER -// GENERIC_SENSOR_MULTILEVEL -// GENERIC_SENSOR_NOTIFICATION -// GENERIC_SET_TOP_BOX -// GENERIC_SIREN -// GENERIC_SUB_ENERGY_METER -// GENERIC_SUB_SYSTEM_CONTROLLER -// GENERIC_THERMOSTAT -// GENERIC_THERMOSTAT_SETBACK_OBSOLETED -// GENERIC_TV -// GENERIC_VALVE_OPEN_CLOSE -// GENERIC_WALL_CONTROLLER -// GENERIC_WHOLE_HOME_METER_SIMPLE -// GENERIC_WINDOW_COVERING_ENDPOINT_AWARE -// GENERIC_WINDOW_COVERING_NO_POSITION_ENDPOINT -// GENERIC_WINDOW_COVERING_POSITION_ENDPOINT_AWARE -// SPECIFIC_DIMMER_WALL_SWITCH_FOUR_BUTTONS -// SPECIFIC_DIMMER_WALL_SWITCH_ONE_BUTTON -// SPECIFIC_DIMMER_WALL_SWITCH_ONE_ROTARY -// SPECIFIC_DIMMER_WALL_SWITCH_THREE_BUTTONS -// SPECIFIC_DIMMER_WALL_SWITCH_TWO_BUTTONS -// SPECIFIC_ENTRY_CONTROL_KEYPAD_0_9 -// SPECIFIC_ENTRY_CONTROL_RFID_TAG_READER_NO_BUTTON -// SPECIFIC_LIGHT_DIMMER_SWITCH_CEILING_OUTLET -// SPECIFIC_LIGHT_DIMMER_SWITCH_LAMP_POST_HIGH -// SPECIFIC_LIGHT_DIMMER_SWITCH_LAMP_POST_LOW -// SPECIFIC_LIGHT_DIMMER_SWITCH_PLUGIN -// SPECIFIC_LIGHT_DIMMER_SWITCH_WALL_LAMP -// SPECIFIC_LIGHT_DIMMER_SWITCH_WALL_OUTLET -// SPECIFIC_ON_OFF_POWER_SWITCH_CEILING_OUTLET -// SPECIFIC_ON_OFF_POWER_SWITCH_LAMP_POST_HIGH -// SPECIFIC_ON_OFF_POWER_SWITCH_LAMP_POST_LOW -// SPECIFIC_ON_OFF_POWER_SWITCH_PLUGIN -// SPECIFIC_ON_OFF_POWER_SWITCH_WALL_LAMP -// SPECIFIC_ON_OFF_POWER_SWITCH_WALL_OUTLET -// SPECIFIC_ON_OFF_WALL_SWITCH_DOOR_BELL -// SPECIFIC_ON_OFF_WALL_SWITCH_FOUR_BUTTONS -// SPECIFIC_ON_OFF_WALL_SWITCH_ONE_BUTTON -// SPECIFIC_ON_OFF_WALL_SWITCH_ONE_ROTARY -// SPECIFIC_ON_OFF_WALL_SWITCH_THREE_BUTTONS -// SPECIFIC_ON_OFF_WALL_SWITCH_TWO_BUTTONS -// SPECIFIC_POWER_STRIP_INDIVIDUAL_OUTLET -// SPECIFIC_REMOTE_CONTROL_SIMPLE_KEYFOB -// SPECIFIC_SENSOR_MULTILEVEL_AIR_FLOW -// SPECIFIC_SENSOR_MULTILEVEL_AIR_TEMPERATURE -// SPECIFIC_SENSOR_MULTILEVEL_ANGLE_POSITION -// SPECIFIC_SENSOR_MULTILEVEL_ATMOSPHERIC_PRESSURE -// SPECIFIC_SENSOR_MULTILEVEL_BAROMETRIC_PRESSURE -// SPECIFIC_SENSOR_MULTILEVEL_CO2_LEVEL -// SPECIFIC_SENSOR_MULTILEVEL_CURRENT -// SPECIFIC_SENSOR_MULTILEVEL_DEW_POINT -// SPECIFIC_SENSOR_MULTILEVEL_DIRECTION -// SPECIFIC_SENSOR_MULTILEVEL_DISTANCE -// SPECIFIC_SENSOR_MULTILEVEL_ELECTRICAL_CONDUCTIVITY -// SPECIFIC_SENSOR_MULTILEVEL_ELECTRICAL_RESISTIVITY -// SPECIFIC_SENSOR_MULTILEVEL_FREQUENCY -// SPECIFIC_SENSOR_MULTILEVEL_GENERAL_PURPOSE_VALUE -// SPECIFIC_SENSOR_MULTILEVEL_HUMIDITY -// SPECIFIC_SENSOR_MULTILEVEL_LOUDNESS -// SPECIFIC_SENSOR_MULTILEVEL_LUMINANCE -// SPECIFIC_SENSOR_MULTILEVEL_MOISTURE -// SPECIFIC_SENSOR_MULTILEVEL_MULTIDEVICE -// SPECIFIC_SENSOR_MULTILEVEL_POWER -// SPECIFIC_SENSOR_MULTILEVEL_RAIN_RATE -// SPECIFIC_SENSOR_MULTILEVEL_ROTATION -// SPECIFIC_SENSOR_MULTILEVEL_SEISMIC_INTENSITY -// SPECIFIC_SENSOR_MULTILEVEL_SEISMIC_MAGNITUDE -// SPECIFIC_SENSOR_MULTILEVEL_SOIL_TEMPERATURE -// SPECIFIC_SENSOR_MULTILEVEL_SOLOR_RADIATION -// SPECIFIC_SENSOR_MULTILEVEL_TANK_CAPACITY -// SPECIFIC_SENSOR_MULTILEVEL_TARGET_TEMPERATURE -// SPECIFIC_SENSOR_MULTILEVEL_TIDE_LEVEL -// SPECIFIC_SENSOR_MULTILEVEL_TIME -// SPECIFIC_SENSOR_MULTILEVEL_ULTRAVIOLET -// SPECIFIC_SENSOR_MULTILEVEL_VELOCITY -// SPECIFIC_SENSOR_MULTILEVEL_VOLTAGE -// SPECIFIC_SENSOR_MULTILEVEL_WATER_TEMPERATURE -// SPECIFIC_SENSOR_MULTILEVEL_WEIGHT -// SPECIFIC_SENSOR_NOTIFICATION_ACCESS_CONTROL -// SPECIFIC_SENSOR_NOTIFICATION_APPLIANCE -// SPECIFIC_SENSOR_NOTIFICATION_CLOCK -// SPECIFIC_SENSOR_NOTIFICATION_CO2_ALARM -// SPECIFIC_SENSOR_NOTIFICATION_CO_ALARM -// SPECIFIC_SENSOR_NOTIFICATION_EMERGENCY_ALARM -// SPECIFIC_SENSOR_NOTIFICATION_GAS_ALARM -// SPECIFIC_SENSOR_NOTIFICATION_HEAT_ALARM -// SPECIFIC_SENSOR_NOTIFICATION_HOME_HEALTH -// SPECIFIC_SENSOR_NOTIFICATION_HOME_SECURITY -// SPECIFIC_SENSOR_NOTIFICATION_IRRIGATION -// SPECIFIC_SENSOR_NOTIFICATION_MULTIDEVICE -// SPECIFIC_SENSOR_NOTIFICATION_POWER_MANAGEMENT -// SPECIFIC_SENSOR_NOTIFICATION_SIREN -// SPECIFIC_SENSOR_NOTIFICATION_SMOKE_ALARM -// SPECIFIC_SENSOR_NOTIFICATION_SYSTEM -// SPECIFIC_SENSOR_NOTIFICATION_WATER_ALARM -// SPECIFIC_SENSOR_NOTIFICATION_WATER_VALVE -// SPECIFIC_SENSOR_NOTIFICATION_WEATHER_ALARM -// SPECIFIC_THERMOSTAT_LINE_VOLTAGE -// SPECIFIC_THERMOSTAT_SETBACK -// Default: ICON_TYPE_GENERIC_ON_OFF_POWER_SWITCH -#define ZAF_CONFIG_USER_ICON_TYPE ICON_TYPE_GENERIC_ON_OFF_POWER_SWITCH - -// Installer Icon Type -// Installer Icon Type reported in Z-Wave Plus Info Report Command -// GENERIC_BARRIER -// GENERIC_CENTRAL_CONTROLLER -// GENERIC_DIMMER_WALL_SWITCH -// GENERIC_DISPLAY_SIMPLE -// GENERIC_DOOR_LOCK_KEYPAD -// GENERIC_ENTRY_CONTROL -// GENERIC_FAN_SWITCH -// GENERIC_GATEWAY -// GENERIC_IRRIGATION -// GENERIC_LIGHT_DIMMER_SWITCH -// GENERIC_ON_OFF_POWER_SWITCH -// GENERIC_ON_OFF_WALL_SWITCH -// GENERIC_POWER_STRIP -// GENERIC_REMOTE_CONTROL_AV -// GENERIC_REMOTE_CONTROL_MULTI_PURPOSE -// GENERIC_REMOTE_CONTROL_SIMPLE -// GENERIC_REPEATER -// GENERIC_SENSOR_MULTILEVEL -// GENERIC_SENSOR_NOTIFICATION -// GENERIC_SET_TOP_BOX -// GENERIC_SIREN -// GENERIC_SUB_ENERGY_METER -// GENERIC_SUB_SYSTEM_CONTROLLER -// GENERIC_THERMOSTAT -// GENERIC_THERMOSTAT_SETBACK_OBSOLETED -// GENERIC_TV -// GENERIC_VALVE_OPEN_CLOSE -// GENERIC_WALL_CONTROLLER -// GENERIC_WHOLE_HOME_METER_SIMPLE -// GENERIC_WINDOW_COVERING_ENDPOINT_AWARE -// GENERIC_WINDOW_COVERING_NO_POSITION_ENDPOINT -// GENERIC_WINDOW_COVERING_POSITION_ENDPOINT_AWARE -// SPECIFIC_DIMMER_WALL_SWITCH_FOUR_BUTTONS -// SPECIFIC_DIMMER_WALL_SWITCH_ONE_BUTTON -// SPECIFIC_DIMMER_WALL_SWITCH_ONE_ROTARY -// SPECIFIC_DIMMER_WALL_SWITCH_THREE_BUTTONS -// SPECIFIC_DIMMER_WALL_SWITCH_TWO_BUTTONS -// SPECIFIC_ENTRY_CONTROL_KEYPAD_0_9 -// SPECIFIC_ENTRY_CONTROL_RFID_TAG_READER_NO_BUTTON -// SPECIFIC_LIGHT_DIMMER_SWITCH_CEILING_OUTLET -// SPECIFIC_LIGHT_DIMMER_SWITCH_LAMP_POST_HIGH -// SPECIFIC_LIGHT_DIMMER_SWITCH_LAMP_POST_LOW -// SPECIFIC_LIGHT_DIMMER_SWITCH_PLUGIN -// SPECIFIC_LIGHT_DIMMER_SWITCH_WALL_LAMP -// SPECIFIC_LIGHT_DIMMER_SWITCH_WALL_OUTLET -// SPECIFIC_ON_OFF_POWER_SWITCH_CEILING_OUTLET -// SPECIFIC_ON_OFF_POWER_SWITCH_LAMP_POST_HIGH -// SPECIFIC_ON_OFF_POWER_SWITCH_LAMP_POST_LOW -// SPECIFIC_ON_OFF_POWER_SWITCH_PLUGIN -// SPECIFIC_ON_OFF_POWER_SWITCH_WALL_LAMP -// SPECIFIC_ON_OFF_POWER_SWITCH_WALL_OUTLET -// SPECIFIC_ON_OFF_WALL_SWITCH_DOOR_BELL -// SPECIFIC_ON_OFF_WALL_SWITCH_FOUR_BUTTONS -// SPECIFIC_ON_OFF_WALL_SWITCH_ONE_BUTTON -// SPECIFIC_ON_OFF_WALL_SWITCH_ONE_ROTARY -// SPECIFIC_ON_OFF_WALL_SWITCH_THREE_BUTTONS -// SPECIFIC_ON_OFF_WALL_SWITCH_TWO_BUTTONS -// SPECIFIC_POWER_STRIP_INDIVIDUAL_OUTLET -// SPECIFIC_REMOTE_CONTROL_SIMPLE_KEYFOB -// SPECIFIC_SENSOR_MULTILEVEL_AIR_FLOW -// SPECIFIC_SENSOR_MULTILEVEL_AIR_TEMPERATURE -// SPECIFIC_SENSOR_MULTILEVEL_ANGLE_POSITION -// SPECIFIC_SENSOR_MULTILEVEL_ATMOSPHERIC_PRESSURE -// SPECIFIC_SENSOR_MULTILEVEL_BAROMETRIC_PRESSURE -// SPECIFIC_SENSOR_MULTILEVEL_CO2_LEVEL -// SPECIFIC_SENSOR_MULTILEVEL_CURRENT -// SPECIFIC_SENSOR_MULTILEVEL_DEW_POINT -// SPECIFIC_SENSOR_MULTILEVEL_DIRECTION -// SPECIFIC_SENSOR_MULTILEVEL_DISTANCE -// SPECIFIC_SENSOR_MULTILEVEL_ELECTRICAL_CONDUCTIVITY -// SPECIFIC_SENSOR_MULTILEVEL_ELECTRICAL_RESISTIVITY -// SPECIFIC_SENSOR_MULTILEVEL_FREQUENCY -// SPECIFIC_SENSOR_MULTILEVEL_GENERAL_PURPOSE_VALUE -// SPECIFIC_SENSOR_MULTILEVEL_HUMIDITY -// SPECIFIC_SENSOR_MULTILEVEL_LOUDNESS -// SPECIFIC_SENSOR_MULTILEVEL_LUMINANCE -// SPECIFIC_SENSOR_MULTILEVEL_MOISTURE -// SPECIFIC_SENSOR_MULTILEVEL_MULTIDEVICE -// SPECIFIC_SENSOR_MULTILEVEL_POWER -// SPECIFIC_SENSOR_MULTILEVEL_RAIN_RATE -// SPECIFIC_SENSOR_MULTILEVEL_ROTATION -// SPECIFIC_SENSOR_MULTILEVEL_SEISMIC_INTENSITY -// SPECIFIC_SENSOR_MULTILEVEL_SEISMIC_MAGNITUDE -// SPECIFIC_SENSOR_MULTILEVEL_SOIL_TEMPERATURE -// SPECIFIC_SENSOR_MULTILEVEL_SOLOR_RADIATION -// SPECIFIC_SENSOR_MULTILEVEL_TANK_CAPACITY -// SPECIFIC_SENSOR_MULTILEVEL_TARGET_TEMPERATURE -// SPECIFIC_SENSOR_MULTILEVEL_TIDE_LEVEL -// SPECIFIC_SENSOR_MULTILEVEL_TIME -// SPECIFIC_SENSOR_MULTILEVEL_ULTRAVIOLET -// SPECIFIC_SENSOR_MULTILEVEL_VELOCITY -// SPECIFIC_SENSOR_MULTILEVEL_VOLTAGE -// SPECIFIC_SENSOR_MULTILEVEL_WATER_TEMPERATURE -// SPECIFIC_SENSOR_MULTILEVEL_WEIGHT -// SPECIFIC_SENSOR_NOTIFICATION_ACCESS_CONTROL -// SPECIFIC_SENSOR_NOTIFICATION_APPLIANCE -// SPECIFIC_SENSOR_NOTIFICATION_CLOCK -// SPECIFIC_SENSOR_NOTIFICATION_CO2_ALARM -// SPECIFIC_SENSOR_NOTIFICATION_CO_ALARM -// SPECIFIC_SENSOR_NOTIFICATION_EMERGENCY_ALARM -// SPECIFIC_SENSOR_NOTIFICATION_GAS_ALARM -// SPECIFIC_SENSOR_NOTIFICATION_HEAT_ALARM -// SPECIFIC_SENSOR_NOTIFICATION_HOME_HEALTH -// SPECIFIC_SENSOR_NOTIFICATION_HOME_SECURITY -// SPECIFIC_SENSOR_NOTIFICATION_IRRIGATION -// SPECIFIC_SENSOR_NOTIFICATION_MULTIDEVICE -// SPECIFIC_SENSOR_NOTIFICATION_POWER_MANAGEMENT -// SPECIFIC_SENSOR_NOTIFICATION_SIREN -// SPECIFIC_SENSOR_NOTIFICATION_SMOKE_ALARM -// SPECIFIC_SENSOR_NOTIFICATION_SYSTEM -// SPECIFIC_SENSOR_NOTIFICATION_WATER_ALARM -// SPECIFIC_SENSOR_NOTIFICATION_WATER_VALVE -// SPECIFIC_SENSOR_NOTIFICATION_WEATHER_ALARM -// SPECIFIC_THERMOSTAT_LINE_VOLTAGE -// SPECIFIC_THERMOSTAT_SETBACK -// Default: ICON_TYPE_GENERIC_ON_OFF_POWER_SWITCH -#define ZAF_CONFIG_INSTALLER_ICON_TYPE 0 - -// -// Version Configuration - -// Hardware version <0..255:1> -// The Hardware Version field MUST report a value which is unique to this particular -// version of the product. It MUST be possible to uniquely determine the hardware -// characteristics from the Hardware Version field in combination with the Manufacturer -// ID, Product Type ID and Product ID fields of Manufacturer Specific Info Report -// of the Manufacturer Specific Command Class. -// This information allows a user to pick a firmware image version that is guaranteed -// to work with this particular version of the product. -// Note that the Hardware Version field is intended for the hardware version of the -// entire product, not just the version of the Z-Wave radio chip. -// Default: 1 -#define ZAF_CONFIG_HARDWARE_VERSION 1 - -// -// Command Class Manufacturer Specific - -// Manufacturer ID <0x0000..0xFFFF:0x1> -// The default value is set to 0x0000 which is Silicon Labs. -// The value must be updated according to the official list of manufacturers in the Z-Wave Alliance. -// Default: 0x0000 -#define ZAF_CONFIG_MANUFACTURER_ID 0x0000 - -// Product Type ID <0x0000..0xFFFF:0x1> -// Default is 4 which is a value chosen by Silabs. -// Silabs consider this to indicate that the device is a Z-Wave Plus Version 2 device. -// Default: 0x0004 -#define ZAF_CONFIG_PRODUCT_TYPE_ID 0x0004 - -// Product ID <0x0000..0xFFFF:0x1> -// Default is 0 which is invalid in the context of Silicon Labs Z-Wave apps. According to CC -// Manufacturer Specific specification, zero is a valid value and can be used as a product ID. -// Default: 0x0000 -#define ZAF_CONFIG_PRODUCT_ID 4 - -// -// Device type - -// The generic type of a device. -// The generic type of a device. A certain device type requires a generic type, e.g., the Lock device type requires the generic type to be Entry Control. -// Find more info in the Z-Wave Plus v2 Device Type specification. -// AV Control Point -// Entry Control -// Generic Controller -// Meter -// Repeater End Device -// Sensor Multilevel -// Switch Binary -// Switch Multilevel -// Thermostat -// Wall Controller -// Sensor Notification -// Default: 0 -#define ZAF_CONFIG_GENERIC_TYPE 0 - -// The specific type of a device. -// The specific type of a device. A certain device type requires a specific type, e.g., the Lock device type requires the specific type to be Door Lock. -// Find more info in the Z-Wave Plus v2 Device Type specification. -// Specific type not used -// Door Lock -// Secure Gate -// Secure Barrier (open only) -// Secure Barrier (close only) -// Color Tunable Binary -// Color Tunable Multilevel -// Class A Motor Control -// Class B Motor Control -// Class C Motor Control -// Thermostat General Version 2 -// Sound Switch -// Secure Keypad -// Routing Sensor Multilevel -// Notification Sensor -// Repeater End Device -// Infrared Repeater -// Default: SPECIFIC_TYPE_NOT_USED -#define ZAF_CONFIG_SPECIFIC_TYPE 0 - -// -// Multi Channel Configuration - -// Number of end points <0..255:1> -// Default: 0 -#define ZAF_CONFIG_NUMBER_OF_END_POINTS 0 - -// -// Security Configuration - -// Request S0 network key -// Default: 0 -#define ZAF_CONFIG_REQUEST_KEY_S0 0 - -// Request S2 Unauthenticated network key -// Default: 0 -#define ZAF_CONFIG_REQUEST_KEY_S2_UNAUTHENTICATED 0 - -// Request S2 Authenticated network key -// Default: 0 -#define ZAF_CONFIG_REQUEST_KEY_S2_AUTHENTICATED 0 - -// Request S2 Access network key -// Default: 0 -#define ZAF_CONFIG_REQUEST_KEY_S2_ACCESS 0 - -// Application can only be controlled when included securely -// Default: 0 -#define ZAF_CONFIG_SECURE_ONLY 0 - -// - -// <<< end of configuration section >>> - -#endif /* _ZAF_CONFIG_H_ */ \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/config/zaf_event_distributor_core_config.h b/src/zwave_ncp_serial_api_controller/config/zaf_event_distributor_core_config.h deleted file mode 100644 index b5cd3958..00000000 --- a/src/zwave_ncp_serial_api_controller/config/zaf_event_distributor_core_config.h +++ /dev/null @@ -1,30 +0,0 @@ -/***************************************************************************//** - * # License - * Copyright 2023 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* - * - * The licensor of this software is Silicon Laboratories Inc. Your use of this - * software is governed by the terms of the Silicon Labs Master Software License - * Agreement (MSLA) available at - * https://www.silabs.com/about-us/legal/master-software-license-agreement - * By installing, copying or otherwise using this software, you agree to the - * terms of the MSLA. - * - ******************************************************************************/ - -#ifndef _ZAF_EVENT_DISTRIBUTOR_CORE_CONFIG_H_ -#define _ZAF_EVENT_DISTRIBUTOR_CORE_CONFIG_H_ - -// <<< Use Configuration Wizard in Context Menu >>> - -// ZAF Event Distributor Core Configuration - -// Timeout (in mS) when waiting for event <1..4294967295:1> -// Default: 4294967295 -#define ZAF_EVENT_DISTRIBUTOR_CORE_CONFIG_TIMEOUT 4294967295 - -// - -// <<< end of configuration section >>> - -#endif /* _ZAF_EVENT_DISTRIBUTOR_CORE_CONFIG_H_ */ \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/config/zpal_zwave_nvm_instance_config.h b/src/zwave_ncp_serial_api_controller/config/zpal_zwave_nvm_instance_config.h deleted file mode 100644 index d6ffa898..00000000 --- a/src/zwave_ncp_serial_api_controller/config/zpal_zwave_nvm_instance_config.h +++ /dev/null @@ -1,58 +0,0 @@ -/***************************************************************************//** - * # License - * Copyright 2023 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* - * - * The licensor of this software is Silicon Laboratories Inc. Your use of this - * software is governed by the terms of the Silicon Labs Master Software License - * Agreement (MSLA) available at - * https://www.silabs.com/about-us/legal/master-software-license-agreement - * By installing, copying or otherwise using this software, you agree to the - * terms of the MSLA. - * - ******************************************************************************/ - -#ifndef _ZPAL_ZWAVE_NVM_INSTANCE_CONFIG_H_ -#define _ZPAL_ZWAVE_NVM_INSTANCE_CONFIG_H_ - -// <<< Use Configuration Wizard in Context Menu >>> - -// ZAF NVM3 config - -#ifndef ZPAL_ZW_NVM_CACHE_SIZE -// NVM3 Z-Wave Instance Cache Size -// Number of NVM3 objects to cache. To reduce access times this number -// should be equal to or higher than the number of NVM3 objects in the -// Z-Wave NVM3 instance (all ZAF and application NVM3 objects). -// Count of objects stored by ZAF depend on the application. At least -// 11 object should be reserved for ZAF. -// see [TODO add a user documentation] for more details -// Default: 11 -#define ZPAL_ZW_NVM_CACHE_SIZE 11 -#endif - -#ifndef ZPAL_ZW_NVM_MAX_OBJECT_SIZE -// NVM3 Z-Wave Instance Max Object Size -// Size of the largest object that can be stored by ZAF or application. -// For ZAF, it should be at least the largest of: -// - CC_NOTIFICATION_MAX_NOTIFICATIONS -// - 3 * CC_ASSOCIATION_MAX_NODES_IN_GROUP * (1+ZAF_CONFIG_NUMBER_OF_END_POINTS) + CC_ASSOCIATION_MAX_GROUPS_PER_ENDPOINT -// - 204 (minimum required by nvm3 library) -// - 512 (minimum required for controller) -// Default: 512 -#define ZPAL_ZW_NVM_MAX_OBJECT_SIZE 512 -#endif - -#ifndef ZPAL_ZW_NVM_INSTANCE_REPACK_HEADROOM -// NVM3 Z-Wave Instance User Repack Headroom -// Headroom determining how many bytes below the forced repack limit the user -// repack limit should be placed. -// Default: 12 -#define ZPAL_ZW_NVM_INSTANCE_REPACK_HEADROOM 12 -#endif - -// - -// <<< end of configuration section >>> - -#endif /* _ZPAL_ZWAVE_NVM_INSTANCE_CONFIG_H_ */ \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/config/zw_build_no.h b/src/zwave_ncp_serial_api_controller/config/zw_build_no.h deleted file mode 100644 index 09377ef4..00000000 --- a/src/zwave_ncp_serial_api_controller/config/zw_build_no.h +++ /dev/null @@ -1,17 +0,0 @@ -/** - * @file - * @copyright 2021 Silicon Laboratories Inc. - */ - -#ifndef _ZW_BUILD_NO_H_ -#define _ZW_BUILD_NO_H_ - -#include - -// Application Framework Build number. -// If not otherwise specified, it is the same as Z-Wave Protocol Build number -#ifndef ZAF_BUILD_NO -#define ZAF_BUILD_NO ZW_GetProtocolBuildNumber() -#endif - -#endif /* _ZW_BUILD_NO_H_ */ \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/config/zw_config_rf.h b/src/zwave_ncp_serial_api_controller/config/zw_config_rf.h deleted file mode 100644 index 920d318e..00000000 --- a/src/zwave_ncp_serial_api_controller/config/zw_config_rf.h +++ /dev/null @@ -1,46 +0,0 @@ -/***************************************************************************//** - * # License - * Copyright 2023 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* - * - * The licensor of this software is Silicon Laboratories Inc. Your use of this - * software is governed by the terms of the Silicon Labs Master Software License - * Agreement (MSLA) available at - * https://www.silabs.com/about-us/legal/master-software-license-agreement - * By installing, copying or otherwise using this software, you agree to the - * terms of the MSLA. - * - ******************************************************************************/ - -#ifndef _ZW_CONFIG_RF_H_ -#define _ZW_CONFIG_RF_H_ - -// <<< Use Configuration Wizard in Context Menu >>> - -// Max Tx Power Configuration - -// The maximum allowed Tx power in deci dBm for Z-Wave Long Range network <140..200:1> -// The maximum allowed Tx power in deci dBm for Z-Wave Long Range network -// Default: 140 -#define APP_MAX_TX_POWER_LR 140 - -// The maximum allowed Tx power in deci dBm for Z-Wave network <-100..140:1> -// The maximum allowed Tx power in deci dBm for Z-Wave network -// Default: 0 -#define APP_MAX_TX_POWER 0 - -// The deci dBmoutput measured at a PA setting of 0dBm <-50..50:1> -// The deci dBm output measured at a PA setting of 0dBm -// Default: 0 -#define APP_MEASURED_0DBM_TX_POWER 0 - -// Enable Radio Debug -// Enable Radio Debug -// Default: 0 -#define ENABLE_RADIO_DEBUG 0 - -// - -// <<< end of configuration section >>> - -#endif /* _ZW_CONFIG_RF_H_ */ \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/config/zw_region_config.h b/src/zwave_ncp_serial_api_controller/config/zw_region_config.h deleted file mode 100644 index 60dc9f9a..00000000 --- a/src/zwave_ncp_serial_api_controller/config/zw_region_config.h +++ /dev/null @@ -1,43 +0,0 @@ -/***************************************************************************//** - * # License - * Copyright 2023 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* - * - * The licensor of this software is Silicon Laboratories Inc. Your use of this - * software is governed by the terms of the Silicon Labs Master Software License - * Agreement (MSLA) available at - * https://www.silabs.com/about-us/legal/master-software-license-agreement - * By installing, copying or otherwise using this software, you agree to the - * terms of the MSLA. - * - ******************************************************************************/ - -#ifndef _ZW_REGION_CONFIG_H_ -#define _ZW_REGION_CONFIG_H_ - -// <<< Use Configuration Wizard in Context Menu >>> - -// Z-Wave Radio Configuration - -// The supported region of the device. Used only if region value is not previously written in MFG_ZWAVE_COUNTRY_FREQ token. To delete value from MFG token, run: commander flash --tokengroup znet --token MFG_ZWAVE_COUNTRY_FREQ:0xFF -// The supported region of the device. Used only if region value is not previously written in MFG_ZWAVE_COUNTRY_FREQ token. To delete value from MFG token, run: commander flash --tokengroup znet --token MFG_ZWAVE_COUNTRY_FREQ:0xFF -// Default (Europe) -// Australia / New Zealand -// China -// Europe -// Hong Kong -// Israel -// India -// Japan -// Korea -// Russia -// United States -// United States Long Range -// Default: REGION_DEFAULT -#define ZW_REGION REGION_DEFAULT - -// - -// <<< end of configuration section >>> - -#endif /* _ZW_REGION_CONFIG_H_ */ \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/config/zw_version_config.h b/src/zwave_ncp_serial_api_controller/config/zw_version_config.h deleted file mode 100644 index ba8b15af..00000000 --- a/src/zwave_ncp_serial_api_controller/config/zw_version_config.h +++ /dev/null @@ -1,60 +0,0 @@ -/***************************************************************************//** - * # License - * Copyright 2023 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* - * - * The licensor of this software is Silicon Laboratories Inc. Your use of this - * software is governed by the terms of the Silicon Labs Master Software License - * Agreement (MSLA) available at - * https://www.silabs.com/about-us/legal/master-software-license-agreement - * By installing, copying or otherwise using this software, you agree to the - * terms of the MSLA. - * - ******************************************************************************/ - -#ifndef _ZW_VERSION_CONFIG_H_ -#define _ZW_VERSION_CONFIG_H_ - -// <<< Use Configuration Wizard in Context Menu >>> - -// Override the default application version with USER_APP_* defines" - -// false: Use Default Z-Wave version numbering, true: Use Application Version Configuration numbering -// Default: 0 -#define USE_USER_APP_VERSION 0 - -// -// Application Version Configuration - -// Application Major Version <1..255:1> -// Default: 1 -#define USER_APP_VERSION 1 - -// Application Minor Version <1..255:1> -// Default: 0 -#define USER_APP_REVISION 0 - -// Application Patch Version <1..255:1> -// Default: 0 -#define USER_APP_PATCH 0 - -// - -// <<< end of configuration section >>> - -#if USE_USER_APP_VERSION - #define APP_VERSION USER_APP_VERSION - #define APP_REVISION USER_APP_REVISION - #define APP_PATCH USER_APP_PATCH -#else - #ifdef ZW_SLAVE - #define APP_VERSION ZAF_VERSION_MAJOR - #define APP_REVISION ZAF_VERSION_MINOR - #define APP_PATCH ZAF_VERSION_PATCH - #else - #define APP_VERSION SDK_VERSION_MAJOR - #define APP_REVISION SDK_VERSION_MINOR - #define APP_PATCH SDK_VERSION_PATCH - #endif -#endif -#endif /* _ZW_VERSION_CONFIG_H_ */ \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/controller_supported_func.h b/src/zwave_ncp_serial_api_controller/controller_supported_func.h deleted file mode 100644 index d2789b5a..00000000 --- a/src/zwave_ncp_serial_api_controller/controller_supported_func.h +++ /dev/null @@ -1,211 +0,0 @@ -/** - * @file - * @copyright 2022 Silicon Laboratories Inc. - */ - -/* Generated file copied from Sdk670 with std. functions supported by static controller. */ -/* Following defines has been disable for build purposes: - * SUPPORT_ZW_AES_ECB - * SUPPORT_ZW_SET_EXT_INT_LEVEL - */ -#define SUPPORT_GET_ROUTING_TABLE_LINE 1 /* ZW_GetRoutingInfo */ -#define SUPPORT_LOCK_ROUTE_RESPONSE 1 /* ZW_LockRoute */ -#define SUPPORT_MEMORY_GET_BUFFER 1 /* MemoryGetBuffer */ -#define SUPPORT_MEMORY_GET_BYTE 1 /* MemoryGetByte */ -#define SUPPORT_MEMORY_GET_ID 1 /* MemoryGetID */ -#define SUPPORT_MEMORY_PUT_BUFFER 1 /* MemoryPutBuffer */ -#define SUPPORT_MEMORY_PUT_BYTE 1 /* MemoryPutByte */ -#define SUPPORT_NVM_GET_ID 1 /* NVM_get_id */ -#define SUPPORT_NVM_EXT_READ_LONG_BUFFER 1 /* NVM_ext_read_long_buffer */ -#define SUPPORT_NVM_EXT_READ_LONG_BYTE 1 /* NVM_ext_read_long_byte */ -#define SUPPORT_NVM_EXT_WRITE_LONG_BYTE 0 /* NVM_ext_write_long_byte */ -#define SUPPORT_NVM_EXT_WRITE_LONG_BUFFER 0 /* NVM_ext_write_long_buffer*/ -#define SUPPORT_NVM_BACKUP_RESTORE 1 /* NVM_backup_restore */ -#define SUPPORT_PWR_CLK_PD 0 /* PWR_Clk_PD */ -#define SUPPORT_PWR_CLK_PUP 0 /* PWR_Clk_PUp */ -#define SUPPORT_PWR_SELECT_CLK 0 /* PWR_Select_Clk */ -#define SUPPORT_PWR_SETSTOPMODE 0 /* PWR_SetStopMode */ -#define SUPPORT_STORE_HOMEID 0 /* ZW_StoreHomeID */ -#define SUPPORT_STORE_NODEINFO 0 /* notUsed */ -#define SUPPORT_ZW_ADD_NODE_TO_NETWORK 1 /* ZW_AddNodeToNetwork */ -#define SUPPORT_ZW_AES_ECB 0 /* ZW_AES_ECB */ -#define SUPPORT_ZW_ARE_NODES_NEIGHBOURS 0 /* notUsed */ -#define SUPPORT_ZW_ASSIGN_RETURN_ROUTE 1 /* ZW_AssignReturnRoute */ -#define SUPPORT_ZW_ASSIGN_PRIORITY_RETURN_ROUTE 1 /* ZW_AssignPriorityReturnRoute */ -#define SUPPORT_ZW_ASSIGN_SUC_RETURN_ROUTE 1 /* ZW_AssignSUCReturnRoute */ -#define SUPPORT_ZW_ASSIGN_PRIORITY_SUC_RETURN_ROUTE 1 /* ZW_AssignPrioritySUCReturnRoute */ -#define SUPPORT_ZW_CONTROLLER_CHANGE 1 /* ZW_ControllerChange */ -#define SUPPORT_ZW_CREATE_NEW_PRIMARY 0 /* NotUsed */ -#define SUPPORT_ZW_DELETE_RETURN_ROUTE 1 /* ZW_DeleteReturnRoute */ -#define SUPPORT_ZW_DELETE_SUC_RETURN_ROUTE 1 /* ZW_DeleteSUCReturnRoute */ -#define SUPPORT_ZW_ENABLE_SUC 0 /* ZW_EnableSUC */ -#define SUPPORT_ZW_EXPLORE_REQUEST_INCLUSION 1 /* ZW_ExploreRequestInclusion */ -#define SUPPORT_ZW_EXPLORE_REQUEST_EXCLUSION 1 /* ZW_ExploreRequestExclusion */ -#define SUPPORT_ZW_GET_CONTROLLER_CAPABILITIES 1 /* ZW_GetControllerCapabilities */ -#define SUPPORT_ZW_GET_PRIORITY_ROUTE 1 /* ZW_GetPriorityRoute */ -#define SUPPORT_ZW_SET_PRIORITY_ROUTE 1 /* ZW_SetPriorityRoute */ -#define SUPPORT_ZW_GET_NEIGHBOR_COUNT 0 /*notUsed */ -#define SUPPORT_ZW_GET_NODE_PROTOCOL_INFO 1 /* ZW_GetNodeProtocolInfo */ -#define SUPPORT_ZW_GET_PROTOCOL_STATUS 1 /* ZW_GetProtocolStatus */ -#define SUPPORT_ZW_GET_PROTOCOL_VERSION 1 /* ZW_GetProtocolVersion */ -#define SUPPORT_ZW_GET_RANDOM 1 /* ZW_GetRandomWord */ -#define SUPPORT_ZW_GET_ROUTING_MAX 0 /* ZW_GetRoutingMAX */ -#define SUPPORT_ZW_GET_SUC_NODE_ID 1 /* ZW_GetSUCNodeID */ -#define SUPPORT_ZW_GET_VERSION 1 /* ZW_Version */ -#define SUPPORT_ZW_IS_FAILED_NODE_ID 1 /* ZW_isFailedNode */ -#define SUPPORT_ZW_IS_NODE_WITHIN_DIRECT_RANGE 0 /* NotUsed */ -#define SUPPORT_ZW_IS_PRIMARY_CTRL 0 /* NotUsed */ -#define SUPPORT_ZW_IS_WUT_KICKED 0 /* ZW_IsWutKicked */ -#define SUPPORT_ZW_NEW_CONTROLLER 0 /* ZW_NewController */ -#define SUPPORT_ZW_RANDOM 0 /* NotUsed */ -#define SUPPORT_ZW_REDISCOVERY_NEEDED 0 /* ZW_RediscoveryNeeded */ -#define SUPPORT_ZW_REMOVE_FAILED_NODE_ID 1 /* ZW_RemoveFailedNode */ -#define SUPPORT_ZW_REMOVE_NODE_FROM_NETWORK 1 /* ZW_RemoveNodeFromNetwork */ -#define SUPPORT_ZW_REMOVE_NODE_ID_FROM_NETWORK 1 /* ZW_RemoveNodeIDFromNetwork */ -#define SUPPORT_ZW_REPLACE_FAILED_NODE 1 /* ZW_ReplaceFailedNode */ -#define SUPPORT_ZW_REPLICATION_COMMAND_COMPLETE 1 /* ZW_ReplicationReceiveComplete */ -#define SUPPORT_ZW_REPLICATION_SEND_DATA 1 /* ZW_ReplicationSend */ -#define SUPPORT_ZW_REQUEST_NETWORK_UPDATE 1 /* ZW_RequestNetWorkUpdate */ -#define SUPPORT_ZW_REQUEST_NEW_ROUTE_DESTINATIONS 0 /* NotUsed */ -#define SUPPORT_ZW_REQUEST_NODE_INFO 1 /* ZW_RequestNodeInfo */ -#define SUPPORT_ZW_REQUEST_NODE_NEIGHBOR_UPDATE 1 /* ZW_RequestNodeNeighborUpdate */ -#define SUPPORT_ZW_RF_POWER_LEVEL_GET 0 /* ZW_RFPowerLevelGet */ -#define SUPPORT_ZW_RF_POWER_LEVEL_REDISCOVERY_SET 0 /* NotUsed */ -#define SUPPORT_ZW_RF_POWER_LEVEL_SET 0 /* ZW_RFPowerLevelSet */ -#define SUPPORT_ZW_SEND_DATA 1 /* ZW_SendData */ -#define SUPPORT_ZW_SEND_DATA_EX 0 /* ZW_SendDataEx */ -#define SUPPORT_ZW_SEND_DATA_ABORT 1 /* ZW_SendDataAbort */ -#define SUPPORT_ZW_SEND_DATA_META 0 /* ZW_SendDataMeta */ -#define SUPPORT_ZW_SEND_DATA_META_BRIDGE 0 /* ZW_SendDataMeta_Bridge */ -#define SUPPORT_ZW_SEND_DATA_META_MR 0 /* NotUsed */ -#define SUPPORT_ZW_SEND_DATA_MR 0 /* NotUsed */ -#define SUPPORT_ZW_SEND_DATA_MULTI 1 /* ZW_SendDataMulti */ -#define SUPPORT_ZW_SEND_DATA_MULTI_EX 0 /* ZW_SendDataMultiEx */ -#define SUPPORT_ZW_SET_NETWORK_KEY_S0 0 /* ZW_SetNetworkKeyS0 */ -#define SUPPORT_ZW_GET_SECURITY_KEYS 0 /* ZW_GetSecurityKeys */ -#define SUPPORT_ZW_SEND_NODE_INFORMATION 1 /* ZW_SendNodeInformation */ -#define SUPPORT_ZW_SEND_SLAVE_DATA 0 /* ZW_SendSlaveData */ -#define SUPPORT_ZW_SEND_SUC_ID 1 /* ZW_SendSUCID */ -#define SUPPORT_ZW_SEND_TEST_FRAME 1 /* ZW_SendTestFrame */ -#define SUPPORT_ZW_SET_DEFAULT 1 /* ZW_SetDefault */ -#define SUPPORT_ZW_SET_EXT_INT_LEVEL 0 /* ZW_SetExtIntLevel */ -#define SUPPORT_ZW_SET_LEARN_MODE 1 /* ZW_SetLearnMode */ -#define SUPPORT_ZW_SET_LEARN_NODE_STATE 0 /* ZW_SetLearnNodeState */ -#define SUPPORT_ZW_SET_PROMISCUOUS_MODE 0 /* ZW_SetPromiscuousMode */ -#define SUPPORT_ZW_SET_RF_RECEIVE_MODE 1 /* ZW_SetRFReceiveMode */ -#define SUPPORT_ZW_SET_ROUTING_INFO 0 /* NotUsed */ -#define SUPPORT_ZW_SET_ROUTING_MAX 1 /* ZW_SetRoutingMAX*/ -#define SUPPORT_ZW_SET_SLEEP_MODE 0 /* ZW_SetSleepMode */ -#define SUPPORT_ZW_SET_SUC_NODE_ID 1 /* ZW_SetSUCNodeID */ -#define SUPPORT_ZW_SET_WUT_TIMEOUT 0 /* ZW_SetWutTimeout */ -#define SUPPORT_ZW_SUPPORT9600_ONLY 0 /* ZW_Support9600Only */ -#define SUPPORT_ZW_TYPE_LIBRARY 1 /* ZW_Type_Library */ -#define SUPPORT_ZW_WATCHDOG_DISABLE 0 /* ZW_WatchDogDisable */ -#define SUPPORT_ZW_WATCHDOG_ENABLE 0 /* ZW_WatchDogEnable */ -#define SUPPORT_ZW_WATCHDOG_KICK 0 /* ZW_WatchDogKick */ -#define SUPPORT_ZW_WATCHDOG_START 1 /* ZW_WatchDogEnable */ -#define SUPPORT_ZW_WATCHDOG_STOP 1 /* ZW_WatchDogDisable */ -#define SUPPORT_ZW_NVR_GET_VALUE 1 /* ZW_NVRGetValue */ -#define SUPPORT_FUNC_ID_CLEAR_TX_TIMERS 1 /* ZW_ClearTxTimers */ -#define SUPPORT_FUNC_ID_GET_TX_TIMERS 1 /* ZW_GetTxTimer */ -#define SUPPORT_ZW_CLEAR_NETWORK_STATS 1 /* ZW_ClearNetworkStats */ -#define SUPPORT_ZW_GET_NETWORK_STATS 1 /* ZW_GetNetworkStats */ -#define SUPPORT_ZW_GET_BACKGROUND_RSSI 1 /* ZW_GetBackgroundRSSI */ -#define SUPPORT_ZW_SET_LISTEN_BEFORE_TALK_THRESHOLD 1 - -#define SUPPORT_ZW_NETWORK_MANAGEMENT_SET_MAX_INCLUSION_REQUEST_INTERVALS 1 - -/* SerialAPI functionality support definitions */ -#define SUPPORT_SEND_DATA_TIMING 1 -/* Only Controllers can Add/Remove other nodes */ - -/* Enable support for SerialAPI Startup Notification */ -#define SUPPORT_SERIAL_API_STARTUP_NOTIFICATION 1 - -/* Common SerialAPI functionality support definitions */ -#define SUPPORT_SERIAL_API_GET_INIT_DATA 1 -#define SUPPORT_SERIAL_API_APPL_NODE_INFORMATION 1 -#define SUPPORT_APPLICATION_COMMAND_HANDLER_BRIDGE 1 -#define SUPPORT_APPLICATION_COMMAND_HANDLER 0 -#define SUPPORT_SERIAL_API_SET_TIMEOUTS 1 - -#define SUPPORT_SERIAL_API_SOFT_RESET 1 -#define SUPPORT_SERIAL_API_SETUP 1 -#define SUPPORT_ZW_INITIATE_SHUTDOWN 1 -#define SUPPORT_SERIAL_API_GET_LR_NODES 1 -#define SUPPORT_SERIAL_GET_LR_CHANNEL 1 -#define SUPPORT_SERIAL_SET_LR_CHANNEL 1 -#define SUPPORT_SERIAL_SET_LR_VIRTUAL_IDS 1 -#define SUPPORT_SERIAL_ENABLE_RADIO_PTI 1 - -/* */ -#define SUPPORT_SERIAL_API_GET_APPL_HOST_MEMORY_OFFSET 0 - -/**************************************************************************/ -/* Common for all Controllers */ -/* SerialAPI functionality support definitions */ -#define SUPPORT_ZW_APPLICATION_CONTROLLER_UPDATE 1 -#define SUPPORT_ZW_APPLICATION_UPDATE 1 - - -/**************************************************************************/ -/* Controller */ -/* Specific SerialAPI functionality support definitions */ -/**************************************************************************/ -/* Installer Controller */ -/* Specific SerialAPI functionality support definitions */ -#if defined(ZW_INSTALLER) - -#define SUPPORT_GET_TX_COUNTER 1 -#define SUPPORT_RESET_TX_COUNTER 1 - -#define SUPPORT_SERIAL_API_APPL_SLAVE_NODE_INFORMATION 0 -#define SUPPORT_APPLICATION_SLAVE_COMMAND_HANDLER 0 -#define SUPPORT_ZW_SEND_SLAVE_NODE_INFORMATION 0 - -/* Not supported by any controllers except controller portable and installer libs */ - -#endif /* ZW_INSTALLER */ - -/**************************************************************************/ -/* Bridge Controller */ -/* specific SerialAPI functionality support definitions */ -#ifdef ZW_CONTROLLER_BRIDGE -#define SUPPORT_ZW_SEND_DATA 1 /* ZW_SendData */ -#define SUPPORT_GET_TX_COUNTER 0 -#define SUPPORT_RESET_TX_COUNTER 0 -#define SUPPORT_ZW_GET_VIRTUAL_NODES 1 /* ZW_GetVirtualNodes */ -#define SUPPORT_ZW_IS_VIRTUAL_NODE 1 /* ZW_IsVirtualNode */ -#define SUPPORT_ZW_SEND_DATA_BRIDGE 1 /* ZW_SendData_Bridge */ -#define SUPPORT_ZW_SEND_DATA_MULTI_BRIDGE 1 /* ZW_SendDataMulti_Bridge */ -#define SUPPORT_ZW_SET_SLAVE_LEARN_MODE 1 /* ZW_SetSlaveLearnMode */ -#define SUPPORT_SERIAL_API_APPL_SLAVE_NODE_INFORMATION 1 - -#if SUPPORT_APPLICATION_COMMAND_HANDLER_BRIDGE -#define SUPPORT_APPLICATION_SLAVE_COMMAND_HANDLER 0 -#else -#define SUPPORT_APPLICATION_SLAVE_COMMAND_HANDLER 1 -#endif -#define SUPPORT_ZW_SEND_SLAVE_NODE_INFORMATION 1 - -/* Not supported by any controllers except controller portable and installer libs */ -#else -#define SUPPORT_ZW_SEND_DATA 1 /* ZW_SendData */ -#define SUPPORT_GET_TX_COUNTER 0 -#define SUPPORT_RESET_TX_COUNTER 0 -#define SUPPORT_ZW_GET_VIRTUAL_NODES 0 /* ZW_GetVirtualNodes */ -#define SUPPORT_ZW_IS_VIRTUAL_NODE 0 /* ZW_IsVirtualNode */ -#define SUPPORT_ZW_SEND_DATA_BRIDGE 0 /* ZW_SendData_Bridge */ -#define SUPPORT_ZW_SEND_DATA_MULTI_BRIDGE 0 /* ZW_SendDataMulti_Bridge */ -#define SUPPORT_ZW_SET_SLAVE_LEARN_MODE 0 /* ZW_SetSlaveLearnMode */ -#define SUPPORT_SERIAL_API_APPL_SLAVE_NODE_INFORMATION 0 -#define SUPPORT_APPLICATION_SLAVE_COMMAND_HANDLER 0 -#define SUPPORT_ZW_SEND_SLAVE_NODE_INFORMATION 1 - -#endif /* ZW_CONTROLLER_BRIDGE */ - -#ifdef ZW_CONTROLLER_SINGLE -#define SUPPORT_SERIAL_API_TEST 1 -#else -#define SUPPORT_SERIAL_API_TEST 0 -#endif diff --git a/src/zwave_ncp_serial_api_controller/gbl_metadata.yaml b/src/zwave_ncp_serial_api_controller/gbl_metadata.yaml deleted file mode 100644 index 33221b6e..00000000 --- a/src/zwave_ncp_serial_api_controller/gbl_metadata.yaml +++ /dev/null @@ -1,6 +0,0 @@ -baudrate: 115200 -dynamic: [zwave_version] -fw_type: z-wave -compression: lz4 -sign_key: "{SDK_DIR}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_sign.key" -encrypt_key: "{SDK_DIR}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_encrypt.key" \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/main.c b/src/zwave_ncp_serial_api_controller/main.c deleted file mode 100644 index d760d1b2..00000000 --- a/src/zwave_ncp_serial_api_controller/main.c +++ /dev/null @@ -1,29 +0,0 @@ -/***************************************************************************//** - * @file main.c - * @brief main() function. - ******************************************************************************* - * # License - * Copyright 2022 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* - * - * The licensor of this software is Silicon Laboratories Inc. Your use of this - * software is governed by the terms of Silicon Labs Master Software License - * Agreement (MSLA) available at - * www.silabs.com/about-us/legal/master-software-license-agreement. This - * software is distributed to you in Source Code format and is governed by the - * sections of the MSLA applicable to Source Code. - * - ******************************************************************************/ -#include "sl_component_catalog.h" -#include "sl_system_init.h" -#include "sl_system_kernel.h" - -int main(void) -{ - // Initialize Silicon Labs device, system, service(s) and protocol stack(s). - // Note that processing task(s) will be created by this call. - sl_system_init(); - - // Start the kernel. Task(s) created in app_init() will start running. - sl_system_kernel_start(); -} \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/nvm_backup_restore.c b/src/zwave_ncp_serial_api_controller/nvm_backup_restore.c deleted file mode 100644 index 7c0b848b..00000000 --- a/src/zwave_ncp_serial_api_controller/nvm_backup_restore.c +++ /dev/null @@ -1,292 +0,0 @@ -/** - * @file nvm_backup_restore.c - * @copyright 2022 Silicon Laboratories Inc. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//#define DEBUGPRINT -#include "DebugPrint.h" - -/*WARNING: The backup/restore feature is based on the thesis that the NVM area is one continuous block even if it consist of two blocks, - A protocol and an application block. These blocks are defined in the linker script. The blocks are addressed using the data structure below. - The definition of the NVM blocks should not be changed, changing the definition will result in breaking the backup/restore feature*/ - -#define WORK_BUFFER_SIZE 64 - -/* HOST->ZW: -operation [open=0|read=1|write=2|close=3] -length desired length of read/write operation -offset(MSB) pointer to NVM memory -offset(LSB) -buffer[] buffer only sent for operation=write -*/ -/* ZW->HOST: -retVal [OK=0|error=1|EOF=-1] -length actual length of read/written data -offset(MSB) pointer to NVM memory (EOF ptr for operation=open) -offset(LSB) -buffer[] buffer only returned for operation=read -*/ - -static eNVMBackupRestoreOperation NVMBackupRestoreOperationInProgress = NVMBackupRestoreOperationClose; - -/** - * Must be called to open the backup restore feature - * The function will shut down the RF, Z-Wave timer system , close the NVM system, and disable the watchdog timer - * - * @return true if backup/resotre is opened else false - */ -static bool NvmBackupOpen(void) -{ - SZwaveCommandPackage nvmOpen = { - .eCommandType = EZWAVECOMMANDTYPE_NVM_BACKUP_OPEN, - .uCommandParams.NvmBackupRestore.offset = 0, - .uCommandParams.NvmBackupRestore.length = 0, - }; - zpal_enable_watchdog(false); - uint8_t bReturn = QueueProtocolCommand((uint8_t*)&nvmOpen); - if (EQUEUENOTIFYING_STATUS_SUCCESS == bReturn) - { - SZwaveCommandStatusPackage cmdStatus = { 0 }; - if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_NVM_BACKUP_RESTORE)) - { - if (cmdStatus.Content.NvmBackupRestoreStatus.status) - { - return true; - } - } - } - return false; -} - -/** - * Read data from the NVM area - * - * @param offset[in] The offset of the NVM area to read from - * @param length[in] the length of the NVM area to read - * @param pNvmData[out] the data read from the NVM area - * - * @return true if data is read else false - */ -static uint8_t NvmBackupRead( uint32_t offset, uint8_t length, uint8_t* pNvmData) -{ - SZwaveCommandPackage nvmRead = { - .eCommandType = EZWAVECOMMANDTYPE_NVM_BACKUP_READ, - .uCommandParams.NvmBackupRestore.offset = offset, - .uCommandParams.NvmBackupRestore.length = length, - .uCommandParams.NvmBackupRestore.nvmData = pNvmData - }; - DPRINTF("NVM_Read_ 0x%08x, 0x%08x, 0x%08x\r\n",offset, length, (uint32_t)pNvmData); - uint8_t bReturn = QueueProtocolCommand((uint8_t*)&nvmRead); - if (EQUEUENOTIFYING_STATUS_SUCCESS == bReturn) - { - SZwaveCommandStatusPackage cmdStatus = { 0 }; - if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_NVM_BACKUP_RESTORE)) - { - if (cmdStatus.Content.NvmBackupRestoreStatus.status) - { - DPRINT("NVM_READ_OK\r\n"); - return true; - } - } - } - DPRINT("NVM_READ_ERR\r\n"); - return false; -} - -/** - * Close the open/restore feature - * - * @return true if backup/retore feature is closed else false - */ - -static uint8_t NvmBackupClose(void) -{ - SZwaveCommandPackage nvmClose = { - .eCommandType = EZWAVECOMMANDTYPE_NVM_BACKUP_CLOSE - }; - uint8_t bReturn = QueueProtocolCommand((uint8_t*)&nvmClose); - - return ((EQUEUENOTIFYING_STATUS_SUCCESS == bReturn)? true: false); -} - -/** - * Restore the NVM data - * - * @param offset[in] The offset of the NVM area to wite backup data to - * @param length[in] the length of the backup data - * @param pNvmData[out] the data to be written to the NVM - * - * @return true if data is written else false - */ -static uint8_t NvmBackupRestore( uint32_t offset, uint8_t length, uint8_t* pNvmData) -{ - SZwaveCommandPackage nvmWrite = { - .eCommandType = EZWAVECOMMANDTYPE_NVM_BACKUP_WRITE, - .uCommandParams.NvmBackupRestore.offset = offset, - .uCommandParams.NvmBackupRestore.length = length, - .uCommandParams.NvmBackupRestore.nvmData = pNvmData - }; - uint8_t bReturn = QueueProtocolCommand((uint8_t*)&nvmWrite); - if (EQUEUENOTIFYING_STATUS_SUCCESS == bReturn) - { - SZwaveCommandStatusPackage cmdStatus = { 0 }; - if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_NVM_BACKUP_RESTORE)) - { - if (cmdStatus.Content.NvmBackupRestoreStatus.status) - { - DPRINT("NVM_WRITE_OK\r\n"); - return true; - } - } - } - DPRINT("NVM_WRITE_ERR\r\n"); - return false; -} - -void func_id_serial_api_nvm_backup_restore(__attribute__((unused)) uint8_t inputLength, uint8_t *pInputBuffer, uint8_t *pOutputBuffer, uint8_t *pOutputLength) -{ - uint32_t NVM_WorkPtr; - uint8_t dataLength; - const uint32_t nvm_storage_size = zpal_nvm_backup_get_size(); - - dataLength = 0; /* Assume nothing is read or written */ - pOutputBuffer[0] = NVMBackupRestoreReturnValueOK; /* Assume not at EOF and no ERROR */ - pOutputBuffer[1] = 0; /* Assume no data */ - pOutputBuffer[2] = 0; - pOutputBuffer[3] = 0; - switch (pInputBuffer[0]) /* operation */ - { - case NVMBackupRestoreOperationOpen: /* open */ - { - if (NVMBackupRestoreOperationClose == NVMBackupRestoreOperationInProgress) - { - /* Lock everyone else out from making changes to the NVM content */ - /* Remember to have some kind of dead-mans-pedal to release lock again. */ - /* TODO */ - // here we have to shut down RF and disable power management and close NVM subsystem - if (NvmBackupOpen()) - { - NVMBackupRestoreOperationInProgress = NVMBackupRestoreOperationOpen; - NVM_WorkPtr = 0; - - /* Set the size of the backup/restore. (Number of bytes in flash used for file systems) */ - /* Please note that the special case where nvm_storage_size == 0x10000 is indicated by 0x00 0x00 */ - pOutputBuffer[2] = (uint8_t)(nvm_storage_size >> 8); - pOutputBuffer[3] = (uint8_t)nvm_storage_size; - } - else - { - pOutputBuffer[0] = NVMBackupRestoreReturnValueError; /*Report error we can't open backup restore feature*/ - } - } - } - break; - - case NVMBackupRestoreOperationRead: /* read */ - { - /* Validate input */ - DPRINT("NVM_Read_ \r\n"); - if ((NVMBackupRestoreOperationInProgress != NVMBackupRestoreOperationRead) && - (NVMBackupRestoreOperationInProgress != NVMBackupRestoreOperationOpen)) - { - DPRINT("NVM_Read_Mis \r\n"); - pOutputBuffer[0] = NVMBackupRestoreReturnValueOperationMismatch; - break; - } - NVMBackupRestoreOperationInProgress = NVMBackupRestoreOperationRead; - dataLength = pInputBuffer[1]; /* Requested dataLength */ - NVM_WorkPtr = (((uint32_t)pInputBuffer[2] << 8) + pInputBuffer[3]); - /* Make sure that length isn't larger than the available buffer size */ - if (dataLength > WORK_BUFFER_SIZE) - { - dataLength = WORK_BUFFER_SIZE; - } - /* Make sure that we don't go beyond valid NVM content */ - if ((NVM_WorkPtr + dataLength) >= nvm_storage_size) - { - DPRINT("NVM_Read_EOF \r\n"); - dataLength = (uint8_t)(nvm_storage_size - NVM_WorkPtr); - pOutputBuffer[0] = (uint8_t)NVMBackupRestoreReturnValueEOF; /* Indicate at EOF */ - } - pOutputBuffer[1] = dataLength; - pOutputBuffer[2] = pInputBuffer[2]; - pOutputBuffer[3] = pInputBuffer[3]; - NvmBackupRead(NVM_WorkPtr, dataLength, &pOutputBuffer[4]); - } - break; - - case NVMBackupRestoreOperationWrite: /* write */ - { - /* Validate input */ - if ((NVMBackupRestoreOperationInProgress != NVMBackupRestoreOperationWrite) && - (NVMBackupRestoreOperationInProgress != NVMBackupRestoreOperationOpen)) - { - DPRINT("NVM_Write_mis \r\n"); - pOutputBuffer[0] = NVMBackupRestoreReturnValueOperationMismatch; - break; - } - NVMBackupRestoreOperationInProgress = NVMBackupRestoreOperationWrite; - dataLength = pInputBuffer[1]; /* Requested dataLength */ - NVM_WorkPtr = (uint32_t)(((uint16_t)pInputBuffer[2] << 8) + pInputBuffer[3]); - if (dataLength > WORK_BUFFER_SIZE) - { - DPRINT("NVM_Write_buff_err \r\n"); - pOutputBuffer[0] = NVMBackupRestoreReturnValueError; /* ERROR: ignore request if length is larger than available buffer */ - } - else - { - /* Make sure that we don't go beyond valid NVM content */ - uint8_t tmp_buf[WORK_BUFFER_SIZE]; - if ((NVM_WorkPtr + dataLength) >= nvm_storage_size) - { - DPRINT("NVM_Write_EOF \r\n"); - dataLength = (uint8_t)(nvm_storage_size - NVM_WorkPtr); - pOutputBuffer[0] = (uint8_t)NVMBackupRestoreReturnValueEOF; /* Indicate at EOF */ - } - memcpy(tmp_buf, (uint8_t*)&pInputBuffer[4], dataLength); - NvmBackupRestore(NVM_WorkPtr , dataLength, tmp_buf); - pOutputBuffer[1] = dataLength; /* Data written */ - pOutputBuffer[2] = pInputBuffer[2]; - pOutputBuffer[3] = pInputBuffer[3]; - - } - dataLength = 0; - } - break; - - case NVMBackupRestoreOperationClose: /* close */ - { - /* Unlock NVM content, so everyone else can make changes again */ - // here we have to shut down RF and disable power management - /* TODO */ - if (NVMBackupRestoreOperationInProgress == NVMBackupRestoreOperationClose) - { - break; - } - if (NvmBackupClose()) - { - NVMBackupRestoreOperationInProgress = NVMBackupRestoreOperationClose; - } - else - { - pOutputBuffer[0] = NVMBackupRestoreReturnValueError; /*repoert error we canot close backup restore feature*/ - } - } - break; - - default: - break; - } - *pOutputLength = dataLength + 4; - -} diff --git a/src/zwave_ncp_serial_api_controller/nvm_backup_restore.h b/src/zwave_ncp_serial_api_controller/nvm_backup_restore.h deleted file mode 100644 index a7967c97..00000000 --- a/src/zwave_ncp_serial_api_controller/nvm_backup_restore.h +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @file - * @copyright 2022 Silicon Laboratories Inc. - */ - -#ifndef APPS_SERIALAPI_NVM_BACKUP_RESTROE_H_ -#define APPS_SERIALAPI_NVM_BACKUP_RESTROE_H_ - -#include - -/** - * Must be called upon receiving a "Serial API NVM Backup/restore commands". - * @param inputLength Length of data in input buffer. - * @param pInputBuffer Input buffer - * @param pOutputBuffer Output buffer - * @param pOutputLength Length of data in output buffer. - */ -void func_id_serial_api_nvm_backup_restore(uint8_t inputLength, - uint8_t* pInputBuffer, - uint8_t* pOutputBuffer, - uint8_t* pOutputLength); - -#endif /* APPS_SERIALAPI_NVM_BACKUP_RESTROE_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/postbuild.sh b/src/zwave_ncp_serial_api_controller/postbuild.sh deleted file mode 100644 index 46a8a27b..00000000 --- a/src/zwave_ncp_serial_api_controller/postbuild.sh +++ /dev/null @@ -1,174 +0,0 @@ -#!/bin/bash - -# Usage: bash postbuild.sh BOOTLOADER APPLICATION SERIES SDK -# BOOTLOADER: path/to/bootloader.s37 -# APPLICATION: path/to/application/hex (don't include .hex in your argument) -# SERIES: 1 | 2 -# SDK: path/to/sdk -# BUILD_GBL: True of False, depepending on should gbl file should be generated -# APPLICATION_GBL: Name of gbl file to be generated - -# Functions are kept above all global variables to ensure that they are pure -check_return() -{ - ret=$1 - message=$2 - if [ $ret -ne 0 ]; then - echo $message - exit $ret - fi -} -sign_verify_btl() -{ - bootloader="$1" - sign_key="$2" - - echo "Signing bootloader with ECDSA signature" - commander convert ${bootloader} --secureboot --keyfile ${sign_key} --outfile ${bootloader} - check_return $? "Signing bootloader failed" - - echo "Verifying bootloader signature" - commander util verifysign ${bootloader} --verify ${sign_key} - check_return $? "Bootloader signature verification failed" -} - -sign_verify_app() -{ - hex_file="$1" - sign_key="$2" - - echo "Signing application with ECDSA signature" - commander convert ${hex_file} --secureboot --keyfile ${sign_key} --outfile ${hex_file} - check_return $? "Signing application failed" - - echo "Verifying application signature" - commander util verifysign ${hex_file} --verify ${sign_key} - check_return $? "Verifying application signature failed" -} - -generate_gbl_files() -{ - build_gbl="$1" - series="$2" - gbl_file="$3" - hex_file="$4" - sign_key="$5" - encr_key="$6" - - if [[ "$build_gbl" == "False" ]]; then - # Nothing to do - return - fi - - if [[ "$series" == "1" ]]; then - compression="lz4" - fi - - if [[ "$series" == "2" ]]; then - compression="lzma" - fi - - commander gbl create ${gbl_file} --app ${hex_file} --sign ${sign_key} --encrypt ${encr_key} --compress ${compression} - check_return $? "Failed to generate GBL file" -} - -BOOTLOADER=$1 -APPLICATION=$2 -SERIES=$3 -SDK=$4 -BUILD_GBL=$5 -APPLICATION_GBL=$6 - -if [ $# -lt 5 ]; then - # If argument 5 and 6 are not provided, assume that gbl file should be created - # and use the same name as for application - BUILD_GBL="True" - APPLICATION_GBL=$APPLICATION -fi - -# Set this to YES if we want to enable secure boot on ocelot(series2) -# using ECDSA signature verification during startup and EM4 wakeup. -# SL_APPLICATION_SIGNATURE must be set to APPLICATION_SIGNATURE_ECDSA_P256 in the -# application_properties_config.h - -SECURE_BOOT="NO" - -# Use controller keys for Serial API Controller apps (series 2 and series 1, ZG14) and -# sample keys for other apps. -# We have shipped Serial API Controller signed with sample key for other variants than ZG14. -# We must continue doing that so that customers can firmware upgrade existing Serial API -# Controller apps running on ZG13 / ZGM13. -# To check for the variant we must use the bootloader since the application name might not -# contain the OPN name -if [[ "$SERIES" == "2" && $APPLICATION == *"zwave_ncp_serial_api_controller"* ]]; then - SIGN_KEY=${SDK}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_sign.key - ENCR_KEY=${SDK}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_encrypt.key -elif [[ "$SERIES" == "1" && $APPLICATION == *"zwave_ncp_serial_api_controller"* && $BOOTLOADER == *"EFR32ZG14"* ]]; then - SIGN_KEY=${SDK}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_sign.key - ENCR_KEY=${SDK}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_encrypt.key -else - SIGN_KEY=${SDK}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/sample-keys/sample_sign.key - ENCR_KEY=${SDK}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/sample-keys/sample_encrypt.key -fi - - -# Make a local copy of the bootloader -APPLICATION_DIR="$(dirname "${APPLICATION}")" -BOOTLOADER_NAME="$(basename "${BOOTLOADER}")" -cp -v ${BOOTLOADER} ${APPLICATION_DIR}/${BOOTLOADER_NAME} -BOOTLOADER=${APPLICATION_DIR}/${BOOTLOADER_NAME} - -# Enable secure boot by signing(ECDSA) the application and bootloader images. -if [[ "$SERIES" == "2" && "$SECURE_BOOT" == "YES" ]]; then - # SL_APPLICATION_SIGNATURE must be set to APPLICATION_SIGNATURE_ECDSA_P256 in the - # application_properties_config.h - sign_verify_btl ${BOOTLOADER} ${SIGN_KEY} - sign_verify_app "${APPLICATION}.hex" ${SIGN_KEY} -fi - -echo "Generating gbl file" -generate_gbl_files ${BUILD_GBL} ${SERIES} "${APPLICATION_GBL}.gbl" "${APPLICATION}.hex" ${SIGN_KEY} ${ENCR_KEY} - -# Check if make-v255-file.py exists -if [[ -e "${SDK}/protocol/z-wave/DevTools/internal/make-v255-file.py" ]]; then - echo "Making v255 hex and gbl file" - python ${SDK}/protocol/z-wave/DevTools/internal/make-v255-file.py ${APPLICATION}.out ${APPLICATION}_v255.out - check_return $? "Failed to run make-v255-file.py" - - ${ARM_GCC_DIR}/bin/arm-none-eabi-objcopy -O ihex ${APPLICATION}_v255.out ${APPLICATION}_v255.hex - check_return $? "Failed to run arm-none-eabi-objcopy" - - if [[ "$SERIES" == "2" && "$SECURE_BOOT" == "YES" ]]; then - sign_verify_app "${APPLICATION}_v255.hex" ${SIGN_KEY} - fi - - generate_gbl_files ${BUILD_GBL} ${SERIES} "${APPLICATION_GBL}_v255.gbl" "${APPLICATION}_v255.hex" ${SIGN_KEY} ${ENCR_KEY} - # Cleanup temporary file that was used to generate v255.gbl only - rm "${APPLICATION}_v255.out" -fi - -# Merge is only done for series 2 devices -if [[ "$SERIES" == "2" ]]; then - echo "Combining bootloader and application into one file" - commander convert $BOOTLOADER $APPLICATION.hex --outfile $APPLICATION.hex - check_return $? "Failed to merge bootloader and application" - - # Also merge the _v255 binary if it exists - if [[ -e "${APPLICATION}_v255.hex" ]]; then - echo "Combining bootloader and application v255 into one file" - commander convert $BOOTLOADER ${APPLICATION}_v255.hex --outfile ${APPLICATION}_v255.hex - check_return $? "Failed to merge bootloader and application v255" - fi -fi - -# Generate size report -echo "Generating size report" -${ARM_GCC_DIR}/bin/arm-none-eabi-size -A -x ${APPLICATION}.out > ${APPLICATION}_size.txt -check_return $? "Failed to run arm-none-eabi-size" - -python $SDK/protocol/z-wave/DevTools/size_info_gen.py -i ${APPLICATION}_size.txt -check_return $? "Failed to run size_info_gen.py" - -exit 0 - -# EOF diff --git a/src/zwave_ncp_serial_api_controller/serialapi_file.c b/src/zwave_ncp_serial_api_controller/serialapi_file.c deleted file mode 100644 index e0c4dab8..00000000 --- a/src/zwave_ncp_serial_api_controller/serialapi_file.c +++ /dev/null @@ -1,795 +0,0 @@ -/** - * @file serialapi_file.c - * @copyright 2022 Silicon Laboratories Inc. - * @brief Z-Wave Switch On/Off Sample Application - * @details This sample application is a Z-Wave slave node which has an LED (D2 - * on ZDP03A) that can be turned on or off from another Z-Wave node by sending - * a Basic Set On or a Basic Set Off command. - * - * It can be included and excluded from a Z-Wave network by pressing S1 switch - * on the ZDP03A board 3 times. S2 switch toggles LED D2. S3 switch transmits - * a Node Information Frame (NIF). - * @author Someone who started this sample application at some point in time. - * @author Thomas Roll (TRO) - * @author Christian Salmony Olsen (COLSEN) - */ - -/****************************************************************************/ -/* INCLUDE FILES */ -/****************************************************************************/ - -#include -#include -#include "SizeOf.h" -#include "Assert.h" -#include "DebugPrintConfig.h" -//#define DEBUGPRINT -//#include "DebugPrint.h" -#include "SyncEvent.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "zw_version_config.h" - -#define APPLICATIONSIZE (4*1024) - -#define APPL_DATA_FILE_SIZE 512 - -#define APP_VERSION_7_15_3 0x00070F03 // 7.15.3 (NO_20DBM_SUPPORT) -#define APP_VERSION_7_18_1 0x00071201 /* 7.18.1 - The changes include the capability to set tx power to - * 20+ dBm over the serial link. */ -#define APP_VERSION_7_21_0 0x00071500 /* 7.21.0 - [FIX] save the node ID type. */ - -// Used by the application data file. -typedef struct SApplicationData -{ - uint8_t extNvm[APPL_DATA_FILE_SIZE]; -} SApplicationData; - /* listening | generic | specific | parmLength | nodeParms[] */ -typedef struct SApplicationSettings -{ - uint8_t listening; - uint8_t generic; - uint8_t specific; -} SApplicationSettings; - -typedef struct SApplicationCmdClassInfo -{ - uint8_t UnSecureIncludedCCLen; - uint8_t UnSecureIncludedCC[APPL_NODEPARM_MAX]; - uint8_t SecureIncludedUnSecureCCLen; - uint8_t SecureIncludedUnSecureCC[APPL_NODEPARM_MAX]; - uint8_t SecureIncludedSecureCCLen; - uint8_t SecureIncludedSecureCC[APPL_NODEPARM_MAX]; - -} SApplicationCmdClassInfo; - -typedef struct SApplicationConfiguration_v7_15_3 // Cannot pack this (change size) as it is already in the field. -{ - zpal_radio_region_t rfRegion; - int8_t iTxPower; // changed to zpal_tx_power_t { aka int16_t } in APP_VERSION_7_18_1 - int8_t ipower0dbmMeasured; // changed to zpal_tx_power_t { aka int16_t } in APP_VERSION_7_18_1 - uint8_t radio_debug_enable; - int16_t maxTxPower; // changed to zpal_tx_power_t { aka int16_t } in APP_VERSION_7_18_1 -} SApplicationConfiguration_v7_15_3; - -//declare the old structure only for the migration process. -//No variable should be declared with this type (excepted for migration process). -typedef struct __attribute__((packed)) SApplicationConfiguration_V7_18_1 -{ - zpal_radio_region_t rfRegion; - zpal_tx_power_t iTxPower; - zpal_tx_power_t ipower0dbmMeasured; - uint8_t radio_debug_enable; - zpal_tx_power_t maxTxPower; // For LR only -}SApplicationConfiguration_V7_18_1; - -typedef struct __attribute__((packed)) SApplicationConfiguration // Must be packet as it is saved on NVM. -{ - zpal_radio_region_t rfRegion; - zpal_tx_power_t iTxPower; - zpal_tx_power_t ipower0dbmMeasured; - uint8_t radio_debug_enable; - zpal_tx_power_t maxTxPower; // For LR only - eSerialAPISetupNodeIdBaseType nodeIdBaseType; -} SApplicationConfiguration; - -#define FILE_SIZE_APPLICATIONDATA (sizeof(SApplicationData)) -#define FILE_SIZE_APPLICATIONSETTINGS (sizeof(SApplicationSettings)) -#define FILE_SIZE_APPLICATIONCMDINFO (sizeof(SApplicationCmdClassInfo)) -#define FILE_SIZE_APPLICATIONCONFIGURATION (sizeof(SApplicationConfiguration)) - -static void WriteDefault(void); - -// Application file system -static zpal_nvm_handle_t pFileSystemApplication; - - -static void WriteDefaultApplicationConfiguration(void); -static bool ObjectExist(zpal_nvm_object_key_t key); - -bool SerialAPI_GetZWVersion(uint32_t * appVersion) -{ - return ZAF_nvm_read(ZAF_FILE_ID_APP_VERSION, appVersion, ZAF_FILE_SIZE_APP_VERSION) == ZPAL_STATUS_OK; -} - -bool SerialAPI_SetZWVersion(const uint32_t * appVersion) -{ - return ZAF_nvm_write(ZAF_FILE_ID_APP_VERSION, appVersion, sizeof(appVersion)) == ZPAL_STATUS_OK; -} - -static void -SerialAPI_FileSystemMigrationManagement(void) -{ - //Read present file system version file - uint32_t presentFilesysVersion; - uint32_t expectedFilesysVersion; // This will hold the file system version that current SW will support. - - SerialAPI_GetZWVersion(&presentFilesysVersion); - - expectedFilesysVersion = zpal_get_app_version(); - - if(expectedFilesysVersion < presentFilesysVersion) - { - //System downgrade. Should not be allowed. - ASSERT(false); - } - else if(expectedFilesysVersion > presentFilesysVersion) // File system upgrade needed. Initiating file system migration... - { - /** - * Continuous migration until all needed migrations are performed, - * to lift from any version to the latest file system version. - */ - - // If current version is 7.15.2 or older then update the FILE_ID_APPLICATIONCONFIGURATION file to the current format - if ( presentFilesysVersion < APP_VERSION_7_15_3 ) - { - // Add code for migration of file system to version APP_VERSION_7_15_3 (7.15.3). - - //Get length of legacy file - size_t dataLen; - zpal_nvm_get_object_size(pFileSystemApplication, FILE_ID_APPLICATIONCONFIGURATION, &dataLen); - - //Read legacy file to first members of tApplicationConfiguration - SApplicationConfiguration_v7_15_3 tApplicationConfiguration = { 0 }; - // Initialize, since zpal_nvm_read() might fail. - zpal_nvm_read(pFileSystemApplication, FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, dataLen); - - //Write default values to new members of tApplicationConfiguration and update the file. - tApplicationConfiguration.radio_debug_enable = 0; - tApplicationConfiguration.maxTxPower = 140; - zpal_status_t status = zpal_nvm_write(pFileSystemApplication, FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, - sizeof(tApplicationConfiguration)); - if (ZPAL_STATUS_OK == status) - { - presentFilesysVersion = APP_VERSION_7_15_3; - } - } - - // Migrate files from file system version APP_VERSION_7_15_3 to APP_VERSION_7_18_1. - if ( presentFilesysVersion < APP_VERSION_7_18_1 ) - { - SApplicationConfiguration_v7_15_3 tApplicationConfiguration_v7_15_3 = { 0 }; - SApplicationConfiguration_V7_18_1 tApplicationConfiguration = { 0 }; - zpal_status_t status; - - status = zpal_nvm_read(pFileSystemApplication, FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration_v7_15_3, - sizeof(tApplicationConfiguration_v7_15_3)); - if (ZPAL_STATUS_OK != status) - { - WriteDefaultApplicationConfiguration(); - } - else - { - tApplicationConfiguration.rfRegion = tApplicationConfiguration_v7_15_3.rfRegion; - tApplicationConfiguration.iTxPower = tApplicationConfiguration_v7_15_3.iTxPower; - tApplicationConfiguration.ipower0dbmMeasured = tApplicationConfiguration_v7_15_3.ipower0dbmMeasured; - tApplicationConfiguration.radio_debug_enable = tApplicationConfiguration_v7_15_3.radio_debug_enable; - tApplicationConfiguration.maxTxPower = tApplicationConfiguration_v7_15_3.maxTxPower; - - status = zpal_nvm_write(pFileSystemApplication, FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, - sizeof(tApplicationConfiguration)); /* Do not use FILE_SIZE_APPLICATIONCONFIGURATION in - * migration functions, instead hard-code the size as - * sizes do change with FW upgrades. */ - if (ZPAL_STATUS_OK == status) - { - presentFilesysVersion = APP_VERSION_7_18_1; - } - } - - // Lifted to version APP_VERSION_7_18_1 - } - -#ifdef ZW_MIGRATION_FROM_7_20 - // Migrate files from file system version APP_VERSION_7_20_0 (same as 7_18_1) to APP_VERSION_7_21_0. - if ( presentFilesysVersion < APP_VERSION_7_21_0 ) - { - SApplicationConfiguration sAppCfgMigration = { 0 }; - zpal_status_t status; - - //cannot migrate if the file system is older than V7.18.1. Other migration script should have been called before. - ASSERT(APP_VERSION_7_18_1 <= presentFilesysVersion); - - /*New application configuration has only a new member (no change in the legacy part). So read the - legacy structure directly in the new one, then just set value for new member.*/ - status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCONFIGURATION, &sAppCfgMigration, - sizeof(SApplicationConfiguration_V7_18_1)); - if (ZPAL_STATUS_OK != status) - { - WriteDefaultApplicationConfiguration(); - } - else - { - //default value for new member. - sAppCfgMigration.nodeIdBaseType = SERIAL_API_SETUP_NODEID_BASE_TYPE_DEFAULT; - - status = ZAF_nvm_app_write(FILE_ID_APPLICATIONCONFIGURATION, &sAppCfgMigration, - sizeof(sAppCfgMigration)); /* Do not use FILE_SIZE_APPLICATIONCONFIGURATION in - * migration functions, instead hard-code the size as - * sizes do change with FW upgrades. */ - if (ZPAL_STATUS_OK == status) - { - presentFilesysVersion = APP_VERSION_7_21_0; - } - } - } -#endif /* ZW_MIGRATION_FROM_7_20 */ - - /* - * If this fails, some of the migrations were not performed due to earlier migrations that have failed. - */ - ASSERT(APP_VERSION_7_21_0 <= presentFilesysVersion); - - /** - * @attention This implementation assumes that the build is going to update the ZAF_FILE_ID_APP_VERSION to the current! - */ - - /** - * Write the new file system version number to NMV. - */ - SerialAPI_SetZWVersion(&expectedFilesysVersion); - } -} - -uint8_t SerialApiFileInit(void) -{ - // Init application filesystem - bool initStatus = ZAF_nvm_app_init(); - if (!initStatus) - { - ASSERT(false); //Assert has been kept for debugging , can be removed from production code. This error can only be caused by some internal flash HW failure - } - - initStatus = ZAF_nvm_init(); - if (!initStatus) - { - ASSERT(false); //Assert has been kept for debugging , can be removed from production code. This error can only be caused by some internal flash HW failure - } - - uint32_t appVersion; - bool status = SerialAPI_GetZWVersion(&appVersion); - - if (status) - { - if (zpal_get_app_version() != appVersion) - { - /** - * In case the file-system is older than supported by this version of the FW, then upgrade. - */ - SerialAPI_FileSystemMigrationManagement(); - } - } - else - { - //There are no files on first boot up. Write default files. - WriteDefault(); - return false; - } - - return true; -} - -static -bool ObjectExist(zpal_nvm_object_key_t key) -{ - zpal_status_t status; - size_t tDataLen; - - status = ZAF_nvm_app_get_object_size(key, &tDataLen); - if (ZPAL_STATUS_OK != status) - { - return false; - } - return true; -} - -/** - * @brief Reads application data from file system. - */ -uint8_t SerialApiNvmReadAppData(uint32_t offset, uint8_t* pAppData, uint32_t iLength) -{ - SApplicationData tApplicationData = { 0 }; - - uint8_t dataIsRead = false; - zpal_status_t status; - - if (ObjectExist(FILE_ID_APPLICATIONDATA)) - { - status = ZAF_nvm_app_read(FILE_ID_APPLICATIONDATA, &tApplicationData, FILE_SIZE_APPLICATIONDATA); - if (ZPAL_STATUS_OK == status) - { - dataIsRead = true; - for (uint32_t i = 0; i < iLength; i++) - { - pAppData[i] = tApplicationData.extNvm[i+ offset]; - } - } - } - return dataIsRead; - -} - -/** - * @brief Writes application data to file system. - */ -uint8_t SerialApiNvmWriteAppData(uint32_t offset, const uint8_t* pAppData, uint32_t iLength) -{ - SApplicationData tApplicationData = { 0 }; - uint8_t dataIsWritten = false; - zpal_status_t status; - - status = ZAF_nvm_app_read(FILE_ID_APPLICATIONDATA, &tApplicationData, FILE_SIZE_APPLICATIONDATA); - if (ZPAL_STATUS_OK == status) - { - memcpy((uint8_t *)&tApplicationData + offset, pAppData, iLength); - status = ZAF_nvm_app_write(FILE_ID_APPLICATIONDATA, &tApplicationData, FILE_SIZE_APPLICATIONDATA); - if (ZPAL_STATUS_OK == status) - { - dataIsWritten = true; - } - } - return dataIsWritten; -} - -uint8_t -SaveApplicationSettings(uint8_t bListening, - uint8_t bGeneric, - uint8_t bSpecific - ) -{ - SApplicationSettings tApplicationSettings = { 0 }; - uint8_t dataIsWritten = false; - zpal_status_t status; - - status = ZAF_nvm_app_read(FILE_ID_APPLICATIONSETTINGS, &tApplicationSettings, FILE_SIZE_APPLICATIONSETTINGS); - if (ZPAL_STATUS_OK == status) - { - tApplicationSettings.listening = bListening; - tApplicationSettings.generic = bGeneric; - tApplicationSettings.specific = bSpecific; - status = ZAF_nvm_app_write(FILE_ID_APPLICATIONSETTINGS, &tApplicationSettings, FILE_SIZE_APPLICATIONSETTINGS); - if (ZPAL_STATUS_OK == status) - { - dataIsWritten = true; - } - } - return dataIsWritten; -} - - -uint8_t -ReadApplicationSettings(uint8_t* pListening, - uint8_t* pGeneric, - uint8_t* pSpecific - ) -{ - SApplicationSettings tApplicationSettings = { 0 }; - uint8_t dataIsRead = false; - zpal_status_t status; - - if (ObjectExist(FILE_ID_APPLICATIONSETTINGS)) - { - status = ZAF_nvm_app_read(FILE_ID_APPLICATIONSETTINGS, &tApplicationSettings, FILE_SIZE_APPLICATIONSETTINGS); - if (ZPAL_STATUS_OK == status) - { - *pListening = tApplicationSettings.listening; - *pGeneric = tApplicationSettings.generic ; - *pSpecific = tApplicationSettings.specific; - dataIsRead = true; - } - } - return dataIsRead; - -} - - -uint8_t -SaveApplicationCCInfo (uint8_t bUnSecureIncludedCCLen, - const uint8_t* pUnSecureIncludedCC, - uint8_t bSecureIncludedUnSecureCCLen, - const uint8_t* pSecureIncludedUnSecureCC, - uint8_t bSecureIncludedSecureCCLen, - const uint8_t* pSecureIncludedSecureCC) -{ - SApplicationCmdClassInfo tApplicationCmdClassInfo = { 0 }; - uint8_t dataIsWritten = false; - zpal_status_t status; - - status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCMDINFO, &tApplicationCmdClassInfo, FILE_SIZE_APPLICATIONCMDINFO); - if (ZPAL_STATUS_OK == status) - { - - tApplicationCmdClassInfo.UnSecureIncludedCCLen = bUnSecureIncludedCCLen; - tApplicationCmdClassInfo.SecureIncludedUnSecureCCLen = bSecureIncludedUnSecureCCLen; - tApplicationCmdClassInfo.SecureIncludedSecureCCLen = bSecureIncludedSecureCCLen; - - for (uint8_t i = 0; i < APPL_NODEPARM_MAX; i++) - { - if (i < bUnSecureIncludedCCLen) - { - tApplicationCmdClassInfo.UnSecureIncludedCC[i] = pUnSecureIncludedCC[i]; - } - else - { - tApplicationCmdClassInfo.UnSecureIncludedCC[i] = 0; - } - - if (i < bSecureIncludedUnSecureCCLen) - { - tApplicationCmdClassInfo.SecureIncludedUnSecureCC[i] = pSecureIncludedUnSecureCC[i]; - } - else - { - tApplicationCmdClassInfo.SecureIncludedUnSecureCC[i] = 0; - } - - if (i < bSecureIncludedSecureCCLen) - { - tApplicationCmdClassInfo.SecureIncludedSecureCC[i] = pSecureIncludedSecureCC[i]; - } - else - { - tApplicationCmdClassInfo.SecureIncludedSecureCC[i] = 0; - } - - } - status = ZAF_nvm_app_write(FILE_ID_APPLICATIONCMDINFO, &tApplicationCmdClassInfo, FILE_SIZE_APPLICATIONCMDINFO); - if (ZPAL_STATUS_OK == status) - { - dataIsWritten = true; - } - } - return dataIsWritten; - -} - - -uint8_t -ReadApplicationCCInfo (uint8_t* pUnSecureIncludedCCLen, - uint8_t* pUnSecureIncludedCC, - uint8_t* pSecureIncludedUnSecureCCLen, - uint8_t* pSecureIncludedUnSecureCC, - uint8_t* pSecureIncludedSecureCCLen, - uint8_t* pSecureIncludedSecureCC) -{ - SApplicationCmdClassInfo tApplicationCmdClassInfo = { 0 }; - uint8_t dataIsRead = false; - zpal_status_t status; - - if (ObjectExist(FILE_ID_APPLICATIONCMDINFO)) - { - status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCMDINFO, &tApplicationCmdClassInfo, FILE_SIZE_APPLICATIONCMDINFO); - if (ZPAL_STATUS_OK == status) - { - dataIsRead = true; - *pUnSecureIncludedCCLen = tApplicationCmdClassInfo.UnSecureIncludedCCLen; - *pSecureIncludedUnSecureCCLen = tApplicationCmdClassInfo.SecureIncludedUnSecureCCLen; - *pSecureIncludedSecureCCLen = tApplicationCmdClassInfo.SecureIncludedSecureCCLen; - for (uint8_t i = 0; i < APPL_NODEPARM_MAX; i++) - { - if (i < *pUnSecureIncludedCCLen) - { - pUnSecureIncludedCC[i] = tApplicationCmdClassInfo.UnSecureIncludedCC[i] ; - } - else - { - pUnSecureIncludedCC[i] = 0; - } - - if (i < *pSecureIncludedUnSecureCCLen) - { - pSecureIncludedUnSecureCC[i] = tApplicationCmdClassInfo.SecureIncludedUnSecureCC[i]; - } - else - { - pSecureIncludedUnSecureCC[i] = 0; - } - - if (i < *pSecureIncludedSecureCCLen) - { - pSecureIncludedSecureCC[i] = tApplicationCmdClassInfo.SecureIncludedSecureCC[i]; - } - else - { - pSecureIncludedSecureCC[i] = 0; - } - - } - } - } - return dataIsRead; - -} - -uint8_t -SaveApplicationRfRegion(zpal_radio_region_t rfRegion) -{ - SApplicationConfiguration tApplicationConfiguration = { 0 }; - uint8_t dataIsWritten = false; - zpal_status_t status; - - status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); - if (ZPAL_STATUS_OK == status) - { - tApplicationConfiguration.rfRegion = rfRegion; - status = ZAF_nvm_app_write(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); - if (ZPAL_STATUS_OK == status) - { - dataIsWritten = true; - } - } - return dataIsWritten; -} - -uint8_t -ReadApplicationRfRegion(zpal_radio_region_t* rfRegion) -{ - SApplicationConfiguration tApplicationConfiguration = { 0 }; - uint8_t dataIsRead = false; - zpal_status_t status; - - if (ObjectExist(FILE_ID_APPLICATIONCONFIGURATION)) - { - status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); - if (ZPAL_STATUS_OK == status) - { - *rfRegion = tApplicationConfiguration.rfRegion; - dataIsRead = true; - } - } - return dataIsRead; - -} - -uint8_t -SaveApplicationNodeIdBaseType(eSerialAPISetupNodeIdBaseType nodeIdBaseType) -{ - SApplicationConfiguration tApplicationConfiguration = { 0 }; - uint8_t dataIsWritten = false; - zpal_status_t status; - - status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); - if (ZPAL_STATUS_OK == status) - { - tApplicationConfiguration.nodeIdBaseType = nodeIdBaseType; - status = ZAF_nvm_app_write(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); - if (ZPAL_STATUS_OK == status) - { - dataIsWritten = true; - } - } - return dataIsWritten; -} - -uint8_t -ReadApplicationNodeIdBaseType(eSerialAPISetupNodeIdBaseType* nodeIdBaseType) -{ - SApplicationConfiguration tApplicationConfiguration; - uint8_t dataIsRead = false; - zpal_status_t status; - - if (ObjectExist(FILE_ID_APPLICATIONCONFIGURATION)) - { - status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); - if (ZPAL_STATUS_OK == status) - { - *nodeIdBaseType = tApplicationConfiguration.nodeIdBaseType; - dataIsRead = true; - } - } - return dataIsRead; - -} - -uint8_t -SaveApplicationTxPowerlevel(zpal_tx_power_t ipower, zpal_tx_power_t power0dbmMeasured) -{ - SApplicationConfiguration tApplicationConfiguration = { 0 }; - uint8_t dataIsWritten = false; - zpal_status_t status; - - status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); - if (ZPAL_STATUS_OK == status) - { - tApplicationConfiguration.iTxPower = ipower; - tApplicationConfiguration.ipower0dbmMeasured = power0dbmMeasured; - status = ZAF_nvm_app_write(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); - if (ZPAL_STATUS_OK == status) - { - dataIsWritten = true; - } - } - return dataIsWritten; -} - - -uint8_t -ReadApplicationTxPowerlevel(zpal_tx_power_t *ipower, zpal_tx_power_t *power0dbmMeasured) -{ - SApplicationConfiguration tApplicationConfiguration = { 0 }; - uint8_t dataIsRead = false; - zpal_status_t status; - - if (ObjectExist(FILE_ID_APPLICATIONCONFIGURATION)) - { - status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); - if (ZPAL_STATUS_OK == status) - { - *ipower = tApplicationConfiguration.iTxPower; - *power0dbmMeasured = tApplicationConfiguration.ipower0dbmMeasured; - dataIsRead = true; - } - } - return dataIsRead; -} - - -uint8_t -SaveApplicationMaxLRTxPwr(zpal_tx_power_t maxTxPwr) -{ - SApplicationConfiguration tApplicationConfiguration = { 0 }; - uint8_t dataIsWritten = false; - zpal_status_t status; - - status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); - if (ZPAL_STATUS_OK == status) - { - tApplicationConfiguration.maxTxPower = maxTxPwr; - status = ZAF_nvm_app_write(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); - if (ZPAL_STATUS_OK == status) - { - dataIsWritten = true; - } - } - return dataIsWritten; -} - - -uint8_t -ReadApplicationMaxLRTxPwr(zpal_tx_power_t *maxTxPwr) -{ - SApplicationConfiguration tApplicationConfiguration = { 0 }; - uint8_t dataIsRead = false; - zpal_status_t status; - - if (ObjectExist(FILE_ID_APPLICATIONCONFIGURATION)) - { - status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); - if (ZPAL_STATUS_OK == status) - { - *maxTxPwr = tApplicationConfiguration.maxTxPower; - dataIsRead = true; - } - } - return dataIsRead; -} - - -uint8_t -SaveApplicationEnablePTI(uint8_t radio_debug_enable) -{ - SApplicationConfiguration tApplicationConfiguration = { 0 }; - uint8_t dataIsWritten = false; - zpal_status_t status; - - status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); - if (ZPAL_STATUS_OK == status) - { - tApplicationConfiguration.radio_debug_enable = radio_debug_enable; - status = ZAF_nvm_app_write(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); - if (ZPAL_STATUS_OK == status) - { - dataIsWritten = true; - } - } - return dataIsWritten; -} - - -uint8_t -ReadApplicationEnablePTI(uint8_t *radio_debug_enable) -{ - SApplicationConfiguration tApplicationConfiguration = { 0 }; - uint8_t dataIsRead = false; - zpal_status_t status; - - if (ObjectExist(FILE_ID_APPLICATIONCONFIGURATION)) - { - status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); - if (ZPAL_STATUS_OK == status) - { - *radio_debug_enable = tApplicationConfiguration.radio_debug_enable; - dataIsRead = true; - } - } - return dataIsRead; -} - - -uint32_t -ReadApplicationVersion(void) -{ - uint32_t appVersion; - SerialAPI_GetZWVersion(&appVersion); - - return appVersion; -} - -static void -WriteDefaultApplicationSettings(void) -{ - //Write default Application Settings file - SApplicationSettings tApplicationSettings = { 0 }; - ZAF_nvm_app_write(FILE_ID_APPLICATIONSETTINGS, &tApplicationSettings, sizeof(SApplicationSettings)); -} - -static void -WriteDefaultApplicationCmdClassInfo(void) -{ - //Write default ApplicationCmdClassInfo file - SApplicationCmdClassInfo tApplicationCmdClassInfo = { 0 }; - ZAF_nvm_app_write(FILE_ID_APPLICATIONCMDINFO, &tApplicationCmdClassInfo, sizeof(SApplicationCmdClassInfo)); -} - -static void -WriteDefaultApplicationData(void) -{ - //Write default Controller Info file - SApplicationData tApplicationData = { 0 }; - ZAF_nvm_app_write(FILE_ID_APPLICATIONDATA, &tApplicationData, sizeof(SApplicationData)); -} - -static void -WriteDefaultApplicationConfiguration(void) -{ - //Write default Application Configuration file - SApplicationConfiguration tApplicationConfiguration = { 0 }; - ZAF_nvm_app_write(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, sizeof(SApplicationConfiguration)); -} - -static void -WriteDefaultApplicationFileSystemVersion(void) -{ - //Write Application filesystem version - uint32_t appVersion = (APP_VERSION << 16) | (APP_REVISION << 8) | APP_PATCH; - SerialAPI_SetZWVersion(&appVersion); -} - -static void -WriteDefault(void) -{ - WriteDefaultApplicationSettings(); - - WriteDefaultApplicationCmdClassInfo(); - - WriteDefaultApplicationData(); - - WriteDefaultApplicationConfiguration(); - - WriteDefaultApplicationFileSystemVersion(); -} diff --git a/src/zwave_ncp_serial_api_controller/serialapi_file.h b/src/zwave_ncp_serial_api_controller/serialapi_file.h deleted file mode 100644 index 42051aa2..00000000 --- a/src/zwave_ncp_serial_api_controller/serialapi_file.h +++ /dev/null @@ -1,136 +0,0 @@ -/** - * @file - * @copyright 2022 Silicon Laboratories Inc. - * @brief module that handle SerialAPI application data - * @details This module implement SerialAPI filesystem functions - */ - -#include -#include -#include -#include -#include "cmds_management.h" - -#define FILE_ID_APPLICATIONSETTINGS 102 -#define FILE_ID_APPLICATIONCMDINFO 103 -#define FILE_ID_APPLICATIONCONFIGURATION 104 -#define FILE_ID_APPLICATIONDATA 200 -#define FILE_ID_PROPRIETARY_1 300 - -/** - * @brief Initailize the serialAPI file system - * - * return false if application files was corrupted or didn't exist already, otherwise true - */ -uint8_t SerialApiFileInit(void); - -/** - * @brief Reads application data from file system. - */ -uint8_t SerialApiNvmReadAppData(uint32_t offset, uint8_t* pAppData, uint32_t iLength); - -/** - * @brief Writes application data to file system. - */ -uint8_t SerialApiNvmWriteAppData(uint32_t offset, const uint8_t* pAppData, uint32_t iLength); - -uint8_t -SaveApplicationSettings(uint8_t bListening, - uint8_t bGeneric, - uint8_t bSpecific); - -uint8_t -ReadApplicationSettings(uint8_t* pListening, - uint8_t* pGeneric, - uint8_t* pSpecific); - -/** - * @brief Writes the node cmd class information setting - */ -uint8_t -SaveApplicationCCInfo (uint8_t bUnSecureIncludedCCLen, - const uint8_t* pUnSecureIncludedCC, - uint8_t bSecureIncludedUnSecureCCLen, - const uint8_t* pSecureIncludedUnSecureCC, - uint8_t bSecureIncludedSecureCCLen, - const uint8_t* pSecureIncludedSecureCC); - -/** - * @brief read the node cmd class information setting - */ -uint8_t -ReadApplicationCCInfo (uint8_t* pUnSecureIncludedCCLen, - uint8_t* pUnSecureIncludedCC, - uint8_t* pSecureIncludedUnSecureCCLen, - uint8_t* pSecureIncludedUnSecureCC, - uint8_t* pSecureIncludedSecureCCLen, - uint8_t* pSecureIncludedSecureCC); - -/** - * @brief Writes the application configuration to file system - */ -uint8_t -SaveApplicationRfRegion(zpal_radio_region_t rfRegion); - -/** - * @brief Reads the application configuration from file system - */ -uint8_t -ReadApplicationRfRegion(zpal_radio_region_t* rfRegion); - -uint8_t -SaveApplicationNodeIdBaseType(eSerialAPISetupNodeIdBaseType nodeIdBaseType); - - -uint8_t -ReadApplicationNodeIdBaseType(eSerialAPISetupNodeIdBaseType* nodeIdBaseType); - - -/** - * @brief Writes the application Tx power configuration to file system - */ -uint8_t -SaveApplicationTxPowerlevel(zpal_tx_power_t ipower, zpal_tx_power_t power0dbmMeasured); - -/** - * @brief Reads the application Tx power configuration from file system - */ -uint8_t -ReadApplicationTxPowerlevel(zpal_tx_power_t *ipower, zpal_tx_power_t *power0dbmMeasured); - - -/** - * Writes the application Max LR tx power value configuration to file system - * - * @param maxTxPwr the LR max tx power value in deci - * @return value was saved correctly - */ -uint8_t -SaveApplicationMaxLRTxPwr(zpal_tx_power_t maxTxPwr); - -/** - * Reads the application Max LR tx power value configuration from file system - * - * @param maxTxPwr pointer to the LR max tx power value in deci - * @return value was read correctly - */ -uint8_t -ReadApplicationMaxLRTxPwr(zpal_tx_power_t *maxTxPwr); - -/** - * @brief Writes radio_debug_enable to file system - */ -uint8_t -SaveApplicationEnablePTI(uint8_t radio_debug_enable); - -/** - * @brief Reads radio_debug_enable from file system - */ -uint8_t -ReadApplicationEnablePTI(uint8_t *radio_debug_enable); - -/** - * @brief Reads the application version from NVM - */ -uint32_t -ReadApplicationVersion(void); diff --git a/src/zwave_ncp_serial_api_controller/slave_supported_func.h b/src/zwave_ncp_serial_api_controller/slave_supported_func.h deleted file mode 100644 index 2ed9c2ab..00000000 --- a/src/zwave_ncp_serial_api_controller/slave_supported_func.h +++ /dev/null @@ -1,181 +0,0 @@ -/** - * @file - * @copyright 2022 Silicon Laboratories Inc. - */ - -/* Generated file copied from Sdk670 with std. functions supported by static controller. */ -/* Following defines has been disable for build purposes: - * SUPPORT_ZW_AES_ECB - * SUPPORT_ZW_SET_EXT_INT_LEVEL - */ -#define SUPPORT_GET_ROUTING_TABLE_LINE 0 /* ZW_GetRoutingInfo */ -#define SUPPORT_LOCK_ROUTE_RESPONSE 1 /* ZW_LockRoute */ -#define SUPPORT_MEMORY_GET_BUFFER 1 /* MemoryGetBuffer */ -#define SUPPORT_MEMORY_GET_BYTE 1 /* MemoryGetByte */ -#define SUPPORT_MEMORY_GET_ID 1 /* MemoryGetID */ -#define SUPPORT_MEMORY_PUT_BUFFER 1 /* MemoryPutBuffer */ -#define SUPPORT_MEMORY_PUT_BYTE 1 /* MemoryPutByte */ -#define SUPPORT_NVM_GET_ID 1 /* NVM_get_id */ -#define SUPPORT_NVM_EXT_READ_LONG_BUFFER 1 /* NVM_ext_read_long_buffer */ -#define SUPPORT_NVM_EXT_READ_LONG_BYTE 1 /* NVM_ext_read_long_byte */ -#define SUPPORT_NVM_EXT_WRITE_LONG_BYTE 0 /* NVM_ext_write_long_byte */ -#define SUPPORT_NVM_EXT_WRITE_LONG_BUFFER 0 /* NVM_ext_write_long_buffer*/ -#define SUPPORT_NVM_BACKUP_RESTORE 0 /* MemoryGetBuffer */ -#define SUPPORT_PWR_CLK_PD 0 /* PWR_Clk_PD */ -#define SUPPORT_PWR_CLK_PUP 0 /* PWR_Clk_PUp */ -#define SUPPORT_PWR_SELECT_CLK 0 /* PWR_Select_Clk */ -#define SUPPORT_PWR_SETSTOPMODE 0 /* PWR_SetStopMode */ -#define SUPPORT_STORE_HOMEID 0 /* ZW_StoreHomeID */ -#define SUPPORT_STORE_NODEINFO 0 /* notUsed */ -#define SUPPORT_ZW_ADD_NODE_TO_NETWORK 0 /* ZW_AddNodeToNetwork */ -#define SUPPORT_ZW_AES_ECB 0 /* ZW_AES_ECB */ -#define SUPPORT_ZW_ARE_NODES_NEIGHBOURS 0 /* notUsed */ -#define SUPPORT_ZW_ASSIGN_RETURN_ROUTE 0 /* ZW_AssignReturnRoute */ -#define SUPPORT_ZW_ASSIGN_PRIORITY_RETURN_ROUTE 0 /* ZW_AssignPriorityReturnRoute */ -#define SUPPORT_ZW_ASSIGN_SUC_RETURN_ROUTE 0 /* ZW_AssignSUCReturnRoute */ -#define SUPPORT_ZW_ASSIGN_PRIORITY_SUC_RETURN_ROUTE 0 /* ZW_AssignPrioritySUCReturnRoute */ -#define SUPPORT_ZW_CONTROLLER_CHANGE 0 /* ZW_ControllerChange */ -#define SUPPORT_ZW_CREATE_NEW_PRIMARY 0 /* NotUsed */ -#define SUPPORT_ZW_DELETE_RETURN_ROUTE 0 /* ZW_DeleteReturnRoute */ -#define SUPPORT_ZW_DELETE_SUC_RETURN_ROUTE 0 /* ZW_DeleteSUCReturnRoute */ -#define SUPPORT_ZW_ENABLE_SUC 0 /* ZW_EnableSUC */ -#define SUPPORT_ZW_EXPLORE_REQUEST_INCLUSION 1 /* ZW_ExploreRequestInclusion */ -#define SUPPORT_ZW_EXPLORE_REQUEST_EXCLUSION 1 /* ZW_ExploreRequestExclusion */ -#define SUPPORT_ZW_GET_CONTROLLER_CAPABILITIES 0 /* ZW_GetControllerCapabilities */ -#define SUPPORT_ZW_GET_PRIORITY_ROUTE 0 /* ZW_GetPriorityRoute */ -#define SUPPORT_ZW_SET_PRIORITY_ROUTE 0 /* ZW_SetPriorityRoute */ -#define SUPPORT_ZW_GET_NEIGHBOR_COUNT 0 /*notUsed */ -#define SUPPORT_ZW_GET_NODE_PROTOCOL_INFO 1 /* ZW_GetNodeProtocolInfo */ -#define SUPPORT_ZW_GET_PROTOCOL_STATUS 1 /* ZW_GetProtocolStatus */ -#define SUPPORT_ZW_GET_PROTOCOL_VERSION 1 /* ZW_GetProtocolVersion */ -#define SUPPORT_ZW_GET_RANDOM 1 /* ZW_GetRandomWord */ -#define SUPPORT_ZW_GET_ROUTING_MAX 0 /* ZW_GetRoutingMAX */ -#define SUPPORT_ZW_GET_SUC_NODE_ID 1 /* ZW_GetSUCNodeID */ -#define SUPPORT_ZW_GET_VERSION 1 /* ZW_Version */ -#define SUPPORT_ZW_IS_FAILED_NODE_ID 0 /* ZW_isFailedNode */ -#define SUPPORT_ZW_IS_NODE_WITHIN_DIRECT_RANGE 0 /* NotUsed */ -#define SUPPORT_ZW_IS_PRIMARY_CTRL 0 /* NotUsed */ -#define SUPPORT_ZW_IS_WUT_KICKED 0 /* ZW_IsWutKicked */ -#define SUPPORT_ZW_NEW_CONTROLLER 0 /* ZW_NewController */ -#define SUPPORT_ZW_RANDOM 0 /* NotUsed */ -#define SUPPORT_ZW_REDISCOVERY_NEEDED 0 /* ZW_RediscoveryNeeded */ -#define SUPPORT_ZW_REMOVE_FAILED_NODE_ID 0 /* ZW_RemoveFailedNode */ -#define SUPPORT_ZW_REMOVE_NODE_FROM_NETWORK 0 /* ZW_RemoveNodeFromNetwork */ -#define SUPPORT_ZW_REMOVE_NODE_ID_FROM_NETWORK 0 /* ZW_RemoveNodeIDFromNetwork */ -#define SUPPORT_ZW_REPLACE_FAILED_NODE 0 /* ZW_ReplaceFailedNode */ -#define SUPPORT_ZW_REPLICATION_COMMAND_COMPLETE 0 /* ZW_ReplicationReceiveComplete */ -#define SUPPORT_ZW_REPLICATION_SEND_DATA 0 /* ZW_ReplicationSend */ -#define SUPPORT_ZW_REQUEST_NETWORK_UPDATE 1 /* ZW_RequestNetWorkUpdate */ -#define SUPPORT_ZW_REQUEST_NEW_ROUTE_DESTINATIONS 0 /* NotUsed */ -#define SUPPORT_ZW_REQUEST_NODE_INFO 0 /* ZW_RequestNodeInfo */ -#define SUPPORT_ZW_REQUEST_NODE_NEIGHBOR_UPDATE 0 /* ZW_RequestNodeNeighborUpdate */ -#define SUPPORT_ZW_RF_POWER_LEVEL_GET 0 /* ZW_RFPowerLevelGet */ -#define SUPPORT_ZW_RF_POWER_LEVEL_REDISCOVERY_SET 0 /* NotUsed */ -#define SUPPORT_ZW_RF_POWER_LEVEL_SET 0 /* ZW_RFPowerLevelSet */ -#define SUPPORT_ZW_SEND_DATA 1 /* ZW_SendData */ -#define SUPPORT_ZW_SEND_DATA_EX 1 /* ZW_SendDataEx */ -#define SUPPORT_ZW_SEND_DATA_ABORT 1 /* ZW_SendDataAbort */ -#define SUPPORT_ZW_SEND_DATA_META 0 /* ZW_SendDataMeta */ -#define SUPPORT_ZW_SEND_DATA_META_BRIDGE 0 /* ZW_SendDataMeta_Bridge */ -#define SUPPORT_ZW_SEND_DATA_META_MR 0 /* NotUsed */ -#define SUPPORT_ZW_SEND_DATA_MR 0 /* NotUsed */ -#define SUPPORT_ZW_SEND_DATA_MULTI 1 /* ZW_SendDataMulti */ -#define SUPPORT_ZW_SEND_DATA_MULTI_EX 1 /* ZW_SendDataMultiEx */ -#define SUPPORT_ZW_SET_NETWORK_KEY_S0 0 /* ZW_SetNetworkKeyS0 */ -#define SUPPORT_ZW_GET_SECURITY_KEYS 1 /* ZW_GetSecurityKeys */ -#define SUPPORT_ZW_SEND_NODE_INFORMATION 1 /* ZW_SendNodeInformation */ -#define SUPPORT_ZW_SEND_SLAVE_DATA 0 /* ZW_SendSlaveData */ -#define SUPPORT_ZW_SEND_SUC_ID 0 /* ZW_SendSUCID */ -#define SUPPORT_ZW_SEND_TEST_FRAME 0 /* ZW_SendTestFrame */ -#define SUPPORT_ZW_SET_DEFAULT 1 /* ZW_SetDefault */ -#define SUPPORT_ZW_SET_EXT_INT_LEVEL 0 /* ZW_SetExtIntLevel */ -#define SUPPORT_ZW_SET_LEARN_MODE 1 /* ZW_SetLearnMode */ -#define SUPPORT_ZW_SET_LEARN_NODE_STATE 0 /* ZW_SetLearnNodeState */ -#define SUPPORT_ZW_SET_PROMISCUOUS_MODE 0 /* ZW_SetPromiscuousMode */ -#define SUPPORT_ZW_SET_RF_RECEIVE_MODE 1 /* ZW_SetRFReceiveMode */ -#define SUPPORT_ZW_SET_ROUTING_INFO 0 /* NotUsed */ -#define SUPPORT_ZW_SET_ROUTING_MAX 0 /*notUsed*/ -#define SUPPORT_ZW_SET_SLEEP_MODE 0 /* ZW_SetSleepMode */ -#define SUPPORT_ZW_SET_SUC_NODE_ID 1 /* ZW_SetSUCNodeID */ -#define SUPPORT_ZW_SET_WUT_TIMEOUT 0 /* ZW_SetWutTimeout */ -#define SUPPORT_ZW_SUPPORT9600_ONLY 0 /* ZW_Support9600Only */ -#define SUPPORT_ZW_TYPE_LIBRARY 1 /* ZW_Type_Library */ -#define SUPPORT_ZW_WATCHDOG_DISABLE 0 /* ZW_WatchDogDisable */ -#define SUPPORT_ZW_WATCHDOG_ENABLE 0 /* ZW_WatchDogEnable */ -#define SUPPORT_ZW_WATCHDOG_KICK 0 /* ZW_WatchDogKick */ -#define SUPPORT_ZW_WATCHDOG_START 1 /* ZW_WatchDogEnable */ -#define SUPPORT_ZW_WATCHDOG_STOP 1 /* ZW_WatchDogDisable */ -#define SUPPORT_ZW_NVR_GET_VALUE 0 /* ZW_NVRGetValue */ -#define SUPPORT_FUNC_ID_CLEAR_TX_TIMERS 1 /* ZW_ClearTxTimers */ -#define SUPPORT_FUNC_ID_GET_TX_TIMERS 1 /* ZW_GetTxTimer */ -#define SUPPORT_ZW_CLEAR_NETWORK_STATS 1 /* ZW_ClearNetworkStats */ -#define SUPPORT_ZW_GET_NETWORK_STATS 1 /* ZW_GetNetworkStats */ -#define SUPPORT_ZW_GET_BACKGROUND_RSSI 1 /* ZW_GetBackgroundRSSI */ -/* SerialAPI functionality support definitions */ -#define SUPPORT_SEND_DATA_TIMING 1 -/* Enable support for SerialAPI Startup Notification */ -#define SUPPORT_SERIAL_API_STARTUP_NOTIFICATION 1 - -/* Common SerialAPI functionality support definitions */ -#define SUPPORT_SERIAL_API_GET_INIT_DATA 1 -#define SUPPORT_SERIAL_API_APPL_NODE_INFORMATION 1 - -#define SUPPORT_APPLICATION_COMMAND_HANDLER_BRIDGE 0 -#define SUPPORT_APPLICATION_COMMAND_HANDLER 1 - - -#define SUPPORT_SERIAL_API_SET_TIMEOUTS 1 - -#define SUPPORT_SERIAL_API_SOFT_RESET 1 -#define SUPPORT_SERIAL_API_SETUP 1 -#define SUPPORT_ZW_INITIATE_SHUTDOWN 0 -#define SUPPORT_SERIAL_API_GET_LR_NODES 0 -#define SUPPORT_SERIAL_GET_LR_CHANNEL 0 -#define SUPPORT_SERIAL_SET_LR_CHANNEL 0 -#define SUPPORT_SERIAL_SET_LR_VIRTUAL_IDS 0 -#define SUPPORT_SERIAL_ENABLE_RADIO_PTI 0 - -/* ZW_EnableSUC() no longer exists in the library */ - -/* */ -#define SUPPORT_SERIAL_API_GET_APPL_HOST_MEMORY_OFFSET 0 - -#define SUPPORT_ZW_SET_LISTEN_BEFORE_TALK_THRESHOLD 1 - -#define SUPPORT_ZW_NETWORK_MANAGEMENT_SET_MAX_INCLUSION_REQUEST_INTERVALS 1 - -/**************************************************************************/ -/* Common for all slaves */ -/* SerialAPI functionality support definitions */ -#define SUPPORT_ZW_APPLICATION_UPDATE 1 -#define SUPPORT_APPLICATION_RF_NOTIFY 0 - -#define SUPPORT_ZW_GET_VIRTUAL_NODES 0 /* ZW_GetVirtualNodes */ -#define SUPPORT_ZW_IS_VIRTUAL_NODE 0 /* ZW_IsVirtualNode */ -#define SUPPORT_ZW_SEND_DATA_BRIDGE 0 /* ZW_SendData_Bridge */ -#define SUPPORT_ZW_SEND_DATA_MULTI_BRIDGE 0 /* ZW_SendDataMulti_Bridge */ -#define SUPPORT_ZW_SET_SLAVE_LEARN_MODE 0 /* ZW_SetSlaveLearnMode */ -#define SUPPORT_SERIAL_API_APPL_SLAVE_NODE_INFORMATION 0 -/**************************************************************************/ -/* Slave enhanced */ -/* Specific SerialAPI functionality support definitions */ - -#define SUPPORT_ZW_APPLICATION_CONTROLLER_UPDATE 0 - -#define SUPPORT_GET_TX_COUNTER 0 -#define SUPPORT_RESET_TX_COUNTER 0 - -#define SUPPORT_SERIAL_API_APPL_SLAVE_NODE_INFORMATION 0 -#define SUPPORT_APPLICATION_SLAVE_COMMAND_HANDLER 0 -#define SUPPORT_ZW_SEND_SLAVE_NODE_INFORMATION 0 - - -#define SUPPORT_SERIAL_API_TEST 0 -#define SUPPORT_ZW_APPLICATION_CONTROLLER_UPDATE 0 - -#define SUPPORT_GET_TX_COUNTER 0 -#define SUPPORT_RESET_TX_COUNTER 0 - -#define SUPPORT_SERIAL_API_APPL_SLAVE_NODE_INFORMATION 0 -#define SUPPORT_APPLICATION_SLAVE_COMMAND_HANDLER 0 -#define SUPPORT_ZW_SEND_SLAVE_NODE_INFORMATION 0 diff --git a/src/zwave_ncp_serial_api_controller/utils.c b/src/zwave_ncp_serial_api_controller/utils.c deleted file mode 100644 index bec51e15..00000000 --- a/src/zwave_ncp_serial_api_controller/utils.c +++ /dev/null @@ -1,286 +0,0 @@ -/** - * @file utils.c - * @copyright 2022 Silicon Laboratories Inc. - */ - -#include -#include -#include -#include - -static TaskHandle_t task_handle; - -uint8_t GetCommandResponse(SZwaveCommandStatusPackage *pCmdStatus, EZwaveCommandStatusType cmdType) -{ - const SApplicationHandles * m_pAppHandles = ZAF_getAppHandle(); - TaskHandle_t m_pAppTaskHandle = GetTaskHandle(); - QueueHandle_t Queue = m_pAppHandles->ZwCommandStatusQueue; - for (uint8_t delayCount = 0; delayCount < 100; delayCount++) - { - for (UBaseType_t QueueElmCount = uxQueueMessagesWaiting(Queue); QueueElmCount > 0; QueueElmCount--) - { - if (xQueueReceive(Queue, (uint8_t*)pCmdStatus, 0)) - { - if (pCmdStatus->eStatusType == cmdType) - { - if (m_pAppTaskHandle && (0 < uxQueueMessagesWaiting(Queue))) - { - /* More elements in queue call xTaskNotify */ - BaseType_t Status = xTaskNotify(m_pAppTaskHandle, 1 << EAPPLICATIONEVENT_ZWCOMMANDSTATUS, eSetBits); - ASSERT(Status == pdPASS); // We probably received a bad Task handle - } - return true; - } - else - { - /* Re-insert none-matching message into Queue */ - BaseType_t result = xQueueSendToBack(Queue, (uint8_t*)pCmdStatus, 0); - ASSERT(pdTRUE == result); - } - } - } - vTaskDelay(10); - } - if (m_pAppTaskHandle && (0 < uxQueueMessagesWaiting(Queue))) - { - /* Only call xTaskNotify if still elements in queue */ - BaseType_t Status = xTaskNotify(m_pAppTaskHandle, 1 << EAPPLICATIONEVENT_ZWCOMMANDSTATUS, eSetBits); - ASSERT(Status == pdPASS); // We probably received a bad Task handle - } - return false; -} - -uint8_t IsPrimaryController(void) -{ - const SApplicationHandles *m_pAppHandles = ZAF_getAppHandle(); - SZwaveCommandPackage cmdPackage = { - .eCommandType = EZWAVECOMMANDTYPE_IS_PRIMARY_CTRL - }; - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(m_pAppHandles->pZwCommandQueue, (uint8_t *)&cmdPackage, 500); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); - SZwaveCommandStatusPackage cmdStatus = { 0 }; - if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_IS_PRIMARY_CTRL)) - { - return cmdStatus.Content.IsPrimaryCtrlStatus.result; - } - ASSERT(false); - return 0; -} - -uint8_t GetControllerCapabilities(void) -{ - const SApplicationHandles *m_pAppHandles = ZAF_getAppHandle(); - SZwaveCommandPackage cmdPackage = { - .eCommandType = EZWAVECOMMANDTYPE_GET_CONTROLLER_CAPABILITIES - }; - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(m_pAppHandles->pZwCommandQueue, (uint8_t *)&cmdPackage, 500); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); - SZwaveCommandStatusPackage cmdStatus = { 0 }; - if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_GET_CONTROLLER_CAPABILITIES)) - { - return cmdStatus.Content.GetControllerCapabilitiesStatus.result; - } - ASSERT(false); - return 0; -} - -uint8_t QueueProtocolCommand(uint8_t *pCommand) -{ - const SApplicationHandles *m_pAppHandles = ZAF_getAppHandle(); - // Put the Command on queue (and dont wait for it, queue must be empty) - return (QueueNotifyingSendToBack(m_pAppHandles->pZwCommandQueue, pCommand, 0)); -} - -/** -* Aquire node information from protocol -* -* Method requires CommandStatus queue from protocol to be empty. -* Method requires CommandQueue to protocol to be empty. -* Method will cause assert on failure. -* -* @param[in] NodeId ID of node to get information about. -* @param[out] pNodeInfo Pointer to t_extNodeInfo struct where aquired node info can be stored. -*/ -void GetNodeInfo(uint16_t NodeId, t_ExtNodeInfo* pNodeInfo) -{ - const SApplicationHandles *m_pAppHandles = ZAF_getAppHandle(); - SZwaveCommandPackage GetNodeInfoCommand = { - .eCommandType = EZWAVECOMMANDTYPE_NODE_INFO, - .uCommandParams.NodeInfo.NodeId = NodeId - }; - - // Put the Command on queue (and dont wait for it, queue must be empty) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(m_pAppHandles->pZwCommandQueue, (uint8_t *)&GetNodeInfoCommand, 0); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); - // Wait for protocol to handle command (it shouldnt take long) - SZwaveCommandStatusPackage NodeInfo = { 0 }; - if (GetCommandResponse(&NodeInfo, EZWAVECOMMANDSTATUS_NODE_INFO)) - { - if (NodeInfo.Content.NodeInfoStatus.NodeId == NodeId) - { - memcpy(pNodeInfo, (uint8_t*)&NodeInfo.Content.NodeInfoStatus.extNodeInfo, sizeof(NodeInfo.Content.NodeInfoStatus.extNodeInfo)); - return; - } - } - ASSERT(false); -} - -/** -* Aquire a list of included nodes IDS in the network from protocol -* -* Method requires CommandStatus queue from protocol to be empty. -* Method requires CommandQueue to protocol to be empty. -* Method will cause assert on failure. -* -* @param[out] node_id_list Pointer to bitmask list where aquired included nodes IDs saved -*/ -void Get_included_nodes(uint8_t* node_id_list) -{ - const SApplicationHandles *m_pAppHandles = ZAF_getAppHandle(); - SZwaveCommandPackage GetIncludedNodesCommand = { - .eCommandType = EZWAVECOMMANDTYPE_ZW_GET_INCLUDED_NODES}; - - // Put the Command on queue (and dont wait for it, queue must be empty) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(m_pAppHandles->pZwCommandQueue, (uint8_t *)&GetIncludedNodesCommand, 0); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); - // Wait for protocol to handle command (it shouldnt take long) - SZwaveCommandStatusPackage includedNodes = { 0 }; - if (GetCommandResponse(&includedNodes, EZWAVECOMMANDSTATUS_ZW_GET_INCLUDED_NODES)) - { - memcpy(node_id_list, (uint8_t*)includedNodes.Content.GetIncludedNodes.node_id_list, sizeof(NODE_MASK_TYPE)); - return; - } - ASSERT(false); -} - - -/** -* Acquire a list of included long range nodes IDS in the network from protocol. -* -* Method requires CommandStatus queue from protocol to be empty. -* Method requires CommandQueue to protocol to be empty. -* Method will cause assert on failure. -* -* @param[out] node_id_list Pointer to bitmask list where aquired included nodes IDs saved -*/ -void Get_included_lr_nodes(uint8_t* node_id_list) -{ - const SApplicationHandles * m_pAppHandles = ZAF_getAppHandle(); - SZwaveCommandPackage GetIncludedNodesCommand = { - .eCommandType = EZWAVECOMMANDTYPE_ZW_GET_INCLUDED_LR_NODES - }; - - // Put the Command on queue (and don't wait for it, queue is most likely empty) - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(m_pAppHandles->pZwCommandQueue, (uint8_t *)&GetIncludedNodesCommand, 0); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); - // Wait for protocol to handle command (it shouldn't take long) - SZwaveCommandStatusPackage includedNodes = { 0 }; - if (GetCommandResponse(&includedNodes, EZWAVECOMMANDSTATUS_ZW_GET_INCLUDED_LR_NODES)) - { - memcpy(node_id_list, (uint8_t*)includedNodes.Content.GetIncludedNodesLR.node_id_list, sizeof(LR_NODE_MASK_TYPE)); - return; - } - ASSERT(false); -} - - -void TriggerNotification(EApplicationEvent event) -{ - TaskHandle_t m_pAppTaskHandle = GetTaskHandle(); - if (m_pAppTaskHandle) - { - BaseType_t xHigherPriorityTaskWoken = pdFALSE; - - xTaskNotifyFromISR(m_pAppTaskHandle, - 1 << event, - eSetBits, - &xHigherPriorityTaskWoken - ); - /* If xHigherPriorityTaskWoken is now set to pdTRUE then a context switch - should be performed to ensure the interrupt returns directly to the highest - priority task. The macro used for this purpose is dependent on the port in - use and may be called portEND_SWITCHING_ISR(). */ - portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); - } - -} - -#define LR_AUTO_CHANNEL_CONFIG_MASK 0xF0 -#define LR_CURRENT_ACTIVE_CHANNEL_MASK 0x0F - -void GetLongRangeChannel(uint8_t * channel_n, uint8_t *auto_channel_config) -{ - const SApplicationHandles * m_pAppHandles = ZAF_getAppHandle(); - SZwaveCommandPackage cmdPackage = { - .eCommandType = EZWAVECOMMANDTYPE_ZW_GET_LR_CHANNEL - }; - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(m_pAppHandles->pZwCommandQueue, (uint8_t *)&cmdPackage, 500); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); - SZwaveCommandStatusPackage cmdStatus = { 0 }; - *auto_channel_config = 0; - *channel_n = 0; - if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_ZW_GET_LR_CHANNEL)) - { - *channel_n = cmdStatus.Content.GetLRChannel.result & LR_CURRENT_ACTIVE_CHANNEL_MASK; - *auto_channel_config = cmdStatus.Content.GetLRChannel.result & LR_AUTO_CHANNEL_CONFIG_MASK; - return; - } - ASSERT(false); -} - -bool SetLongRangeChannel(uint8_t channel) -{ - const SApplicationHandles * m_pAppHandles = ZAF_getAppHandle(); - SZwaveCommandPackage cmdPackage = { - .eCommandType = EZWAVECOMMANDTYPE_ZW_SET_LR_CHANNEL, - .uCommandParams.SetLRChannel.value = channel - }; - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(m_pAppHandles->pZwCommandQueue, (uint8_t *)&cmdPackage, 500); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); - SZwaveCommandStatusPackage cmdStatus = { 0 }; - if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_ZW_SET_LR_CHANNEL)) - { - return cmdStatus.Content.SetLRChannel.result; - } - ASSERT(false); - return 0; - -} - -void SetLongRangeVirtualNodes(uint8_t bitmask) -{ - const SApplicationHandles * m_pAppHandles = ZAF_getAppHandle(); - SZwaveCommandPackage cmdPackage = { - .eCommandType = EZWAVECOMMANDTYPE_ZW_SET_LR_VIRTUAL_IDS, - .uCommandParams.SetLRVirtualNodeIDs.value = bitmask - }; - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(m_pAppHandles->pZwCommandQueue, (uint8_t *)&cmdPackage, 500); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); -} - -uint8_t GetPTIConfig(void) -{ - const SApplicationHandles * m_pAppHandles = ZAF_getAppHandle(); - SZwaveCommandPackage cmdPackage = { - .eCommandType = EZWAVECOMMANDTYPE_ZW_GET_PTI_CONFIG - }; - EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(m_pAppHandles->pZwCommandQueue, (uint8_t *)&cmdPackage, 500); - ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); - SZwaveCommandStatusPackage cmdStatus; - if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_ZW_GET_PTI_CONFIG)) - { - return cmdStatus.Content.GetPTIconfig.result; - } - ASSERT(false); - return 0; -} - -void SetTaskHandle(TaskHandle_t new_task_handle) -{ - task_handle = new_task_handle; -} - -TaskHandle_t GetTaskHandle(void) -{ - return task_handle; -} diff --git a/src/zwave_ncp_serial_api_controller/utils.h b/src/zwave_ncp_serial_api_controller/utils.h deleted file mode 100644 index bf34be70..00000000 --- a/src/zwave_ncp_serial_api_controller/utils.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @file - * @copyright 2022 Silicon Laboratories Inc. - */ - -#ifndef APPS_SERIALAPI_UTILS_H_ -#define APPS_SERIALAPI_UTILS_H_ - -#include -#include -#include - -uint8_t QueueProtocolCommand(uint8_t *pCommand); - -uint8_t GetCommandResponse(SZwaveCommandStatusPackage *pCmdStatus, EZwaveCommandStatusType cmdType); - -uint8_t IsPrimaryController(void); - -uint8_t GetControllerCapabilities(void); - -void GetNodeInfo(uint16_t NodeId, t_ExtNodeInfo* pNodeInfo); - -void Get_included_nodes(uint8_t* node_id_list); -void Get_included_lr_nodes(uint8_t* node_id_list); - -void TriggerNotification(EApplicationEvent event); - -void GetLongRangeChannel(uint8_t * channel_n, uint8_t *auto_channel_config); -bool SetLongRangeChannel(uint8_t channel); - -void SetLongRangeVirtualNodes(uint8_t bitmask); - -uint8_t GetPTIConfig(void); - -void SetTaskHandle(TaskHandle_t new_task_handle); -TaskHandle_t GetTaskHandle(void); - -#endif /* APPS_SERIALAPI_UTILS_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/virtual_slave_node_info.c b/src/zwave_ncp_serial_api_controller/virtual_slave_node_info.c deleted file mode 100644 index 3853b093..00000000 --- a/src/zwave_ncp_serial_api_controller/virtual_slave_node_info.c +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @file virtual_slave_node_info.c - * @copyright 2022 Silicon Laboratories Inc. - */ - -#include "virtual_slave_node_info.h" - -#ifdef ZW_CONTROLLER_BRIDGE - -uint8_t aVirtualSlaveCommandClasses[MAX_VIRTUAL_SLAVE_NODES][APPL_SLAVENODEPARM_MAX]; - -SVirtualSlaveNodeInfo_t aVirtualSlaveNodeInfo[MAX_VIRTUAL_SLAVE_NODES] = {{.bListening = true, - .NodeType.generic = GENERIC_TYPE_SWITCH_MULTILEVEL, - .NodeType.specific = SPECIFIC_TYPE_NOT_USED, - .CommandClasses.iListLength = 0, - .CommandClasses.pCommandClasses = &aVirtualSlaveCommandClasses[0][0]}}; -SVirtualSlaveNodeInfo_t *apVirtualSlaveNodeInfo[sizeof_array(aVirtualSlaveNodeInfo)] = {&aVirtualSlaveNodeInfo[0]}; - -const SVirtualSlaveNodeInfoTable_t VirtualSlaveNodeInfoTable = -{ - .iTableLength = sizeof_array(apVirtualSlaveNodeInfo), - .ppNodeInfo = (const SVirtualSlaveNodeInfo_t **)apVirtualSlaveNodeInfo -}; - -#endif // ifdef ZW_CONTROLLER_BRIDGE diff --git a/src/zwave_ncp_serial_api_controller/virtual_slave_node_info.h b/src/zwave_ncp_serial_api_controller/virtual_slave_node_info.h deleted file mode 100644 index 32fa8611..00000000 --- a/src/zwave_ncp_serial_api_controller/virtual_slave_node_info.h +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @file - * @copyright 2022 Silicon Laboratories Inc. - */ - -#ifndef VIRTUAL_SLAVE_NODE_INFO_H_ -#define VIRTUAL_SLAVE_NODE_INFO_H_ - -#include -#include -#include "app.h" - -#ifdef ZW_CONTROLLER_BRIDGE -// Virtual slave node info storage -// array size is number of simultaneous virtual slaves supported - -#define MAX_VIRTUAL_SLAVE_NODES (1) - -extern uint8_t aVirtualSlaveCommandClasses[MAX_VIRTUAL_SLAVE_NODES][APPL_SLAVENODEPARM_MAX]; -extern SVirtualSlaveNodeInfo_t aVirtualSlaveNodeInfo[MAX_VIRTUAL_SLAVE_NODES]; -extern SVirtualSlaveNodeInfo_t *apVirtualSlaveNodeInfo[sizeof_array(aVirtualSlaveNodeInfo)]; -extern const SVirtualSlaveNodeInfoTable_t VirtualSlaveNodeInfoTable; - -#endif // ifdef ZW_CONTROLLER_BRIDGE - -#endif /* VIRTUAL_SLAVE_NODE_INFO_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/zaf_config_security.h b/src/zwave_ncp_serial_api_controller/zaf_config_security.h deleted file mode 100644 index ebe22e80..00000000 --- a/src/zwave_ncp_serial_api_controller/zaf_config_security.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @file - * @copyright 2022 Silicon Laboratories Inc. - */ -#ifndef ZAF_CONFIG_SECURITY_H_ -#define ZAF_CONFIG_SECURITY_H_ - -#include "zaf_config.h" -#include "ZW_security_api.h" - -#if ZAF_CONFIG_REQUEST_KEY_S0==1 -#define S0_BIT SECURITY_KEY_S0_BIT -#else -#define S0_BIT 0 -#endif - -#if ZAF_CONFIG_REQUEST_KEY_S2_UNAUTHENTICATED==1 -#define S2_UNAUTHENTICATED_BIT SECURITY_KEY_S2_UNAUTHENTICATED_BIT -#else -#define S2_UNAUTHENTICATED_BIT 0 -#endif - -#if ZAF_CONFIG_REQUEST_KEY_S2_AUTHENTICATED==1 -#define S2_AUTHENTICATED_BIT SECURITY_KEY_S2_AUTHENTICATED_BIT -#else -#define S2_AUTHENTICATED_BIT 0 -#endif - -#if ZAF_CONFIG_REQUEST_KEY_S2_ACCESS==1 -#define S2_ACCESS_BIT SECURITY_KEY_S2_ACCESS_BIT -#else -#define S2_ACCESS_BIT 0 -#endif - -#define ZAF_CONFIG_REQUESTED_SECURITY_KEYS (S0_BIT | S2_UNAUTHENTICATED_BIT | S2_AUTHENTICATED_BIT | S2_ACCESS_BIT) - -#endif /* ZAF_CONFIG_SECURITY_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/zwave_ncp_serial_api_controller.pintool b/src/zwave_ncp_serial_api_controller/zwave_ncp_serial_api_controller.pintool deleted file mode 100644 index 28168e56..00000000 --- a/src/zwave_ncp_serial_api_controller/zwave_ncp_serial_api_controller.pintool +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/zwave_ncp_serial_api_controller/zwave_ncp_serial_api_controller.slcp b/src/zwave_ncp_serial_api_controller/zwave_ncp_serial_api_controller.slcp deleted file mode 100644 index 421a99d7..00000000 --- a/src/zwave_ncp_serial_api_controller/zwave_ncp_serial_api_controller.slcp +++ /dev/null @@ -1,147 +0,0 @@ -# Silicon Labs Project Configuration Tools: slcp, v0, Component selection file. -project_name: zwave_ncp_serial_api_controller -label: zwave_ncp_serial_api_controller -description: | - The Serial Applications Programming Interface (Serial API) allows a host to communicate with a Z-Wave chip. The host may be a PC or a less powerful embedded host CPU, such as in a remote control or in a gateway device, and so on. -category: Z-Wave|Apps -filter: -- name: Device Type - value: [NCP] -- name: Project Difficulty - value: [Beginner] -- name: Wireless Technology - value: [Z-Wave] -package: Z-Wave -quality: production -readme: -- {path: README.md} -source: -- {path: app_node_info.c} -- {path: cmd_handlers_invoker.c} -- {path: cmd_handlers.c} -- {path: cmd_get_capabilities.c} -- {path: cmds_dcdc.c} -- {path: cmds_power_management.c} -- {path: cmds_management.c} -- {path: cmds_rf.c} -- {path: cmds_security.c} -- {path: comm_interface.c} -- {path: nvm_backup_restore.c} -- {path: serialapi_file.c} -- {path: app.c} -- {path: utils.c} -- {path: virtual_slave_node_info.c} -- {path: main.c} -tag: [prebuilt_demo] -include: -- path: . - file_list: - - {path: app_node_info.h} - - {path: cmd_handlers.h} - - {path: cmds_management.h} - - {path: cmds_rf.h} - - {path: cmds_security.h} - - {path: comm_interface.h} - - {path: controller_supported_func.h} - - {path: nvm_backup_restore.h} - - {path: serialapi_file.h} - - {path: app.h} - - {path: slave_supported_func.h} - - {path: utils.h} - - {path: virtual_slave_node_info.h} - - {path: zaf_config_security.h} -sdk: {id: gecko_sdk, version: 4.4.4} -toolchain_settings: [] -component: -- {id: ZGM130S037HGN} -- {id: ZW_MIGRATION_FROM_7_20} -- {id: brd4207a} -- {id: device_init} -- {id: emlib_letimer} -- {id: emlib_msc} -- {id: emlib_timer} -- {id: gpiointerrupt} -- {id: mpu} -- {id: sl_system} -- {id: zaf_ncp} -- {id: zw_api_controller} -- {id: zw_api_serialapi} -- {id: zw_api_zw} -- {id: zw_app_timer_deep_sleep} -- {id: zw_appshw_serialapi} -- {id: zw_apputilities_minimal} -- {id: zw_core} -- {id: zw_dcdc_override} -- {id: zw_role_type_central_static_controller} -other_file: -- {path: postbuild.sh} -define: -- {name: APP_PROPERTIES_CONFIG_FILE, value: } -- condition: [device_sdid_95] - name: MAX_CALLBACK_QUEUE - value: '4' -- condition: [device_sdid_95] - name: MAX_UNSOLICITED_QUEUE - value: '4' -config_file: -- {path: config/zaf_config.h} -- {path: config/zaf_config.h} -configuration: -- {name: ZAF_CONFIG_GENERIC_TYPE, value: '0'} -- {name: ZAF_CONFIG_SPECIFIC_TYPE, value: '0'} -- {name: ZAF_CONFIG_PRODUCT_ID, value: '4'} -- {name: NVM3_DEFAULT_MAX_OBJECT_SIZE, value: '1900'} -- {name: NVM3_DEFAULT_CACHE_SIZE, value: '100'} -- {name: SL_BOARD_ENABLE_VCOM, value: '1'} -- {name: SL_DEVICE_INIT_EMU_EM4_STATE, value: emuEM4Hibernate} -- {name: SL_DEVICE_INIT_EMU_EM4_RETAIN_LFRCO, value: '1'} -- {name: SL_DEVICE_INIT_EMU_EM4_PIN_RETENTION_MODE, value: emuPinRetentionLatch} -- {name: SL_IOSTREAM_USART_VCOM_CONVERT_BY_DEFAULT_LF_TO_CRLF, value: '1'} -- {name: SL_IOSTREAM_USART_VCOM_RESTRICT_ENERGY_MODE_TO_ALLOW_RECEPTION, value: '0'} -- {name: SL_IOSTREAM_EUSART_VCOM_CONVERT_BY_DEFAULT_LF_TO_CRLF, value: '1'} -- {name: SL_IOSTREAM_EUSART_VCOM_RESTRICT_ENERGY_MODE_TO_ALLOW_RECEPTION, value: '0'} -- {name: configUSE_IDLE_HOOK, value: '1'} -- {name: configTIMER_TASK_PRIORITY, value: '55'} -- condition: [device_series_1] - name: configMAX_SYSCALL_INTERRUPT_PRIORITY - value: '32' -- condition: [device_series_1] - name: configKERNEL_INTERRUPT_PRIORITY - value: '224' -- condition: [device_series_2] - name: configMAX_SYSCALL_INTERRUPT_PRIORITY - value: '16' -- condition: [device_series_2] - name: configKERNEL_INTERRUPT_PRIORITY - value: '112' -- {name: configTIMER_QUEUE_LENGTH, value: '8'} -- {name: SL_DEVICE_INIT_DCDC_BYPASS, value: '1'} -- condition: [device_series_2, device_security_vault] - name: SL_PSA_ITS_USER_MAX_FILES - value: '32' -- condition: [device_series_2, device_security_vault] - name: SL_PSA_KEY_USER_SLOT_COUNT - value: '14' -- condition: [device_series_2] - name: SL_SLEEPTIMER_PERIPHERAL - value: SL_SLEEPTIMER_PERIPHERAL_BURTC -- condition: [device_sdid_95] - name: configTIMER_QUEUE_LENGTH - value: '4' -- condition: [device_sdid_95] - name: configTOTAL_HEAP_SIZE - value: '0' -- condition: [device_sdid_95] - name: SL_STACK_SIZE - value: '1024' -- unless: [device_sdid_95] - name: SL_STACK_SIZE - value: '1280' -- {name: SL_HEAP_SIZE, value: '128'} -- {name: ZAF_CONFIG_INSTALLER_ICON_TYPE, value: '0'} -- {name: ZAF_APP_NAME, value: '"serial_api_controller"'} -- {name: SL_RAIL_UTIL_RAIL_POWER_MANAGER_INIT, value: '0'} -ui_hints: - highlight: - - {path: README.md, focus: true} - diff --git a/src/zwave_ncp_serial_api_controller/zwave_ncp_serial_api_controller.slps b/src/zwave_ncp_serial_api_controller/zwave_ncp_serial_api_controller.slps deleted file mode 100644 index 2ec13eff..00000000 --- a/src/zwave_ncp_serial_api_controller/zwave_ncp_serial_api_controller.slps +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file