Skip to content

Commit

Permalink
Merge branch 'main' into puddly/packet-filter-multicast-extension
Browse files Browse the repository at this point in the history
  • Loading branch information
puddly committed Aug 16, 2024
2 parents 3d40a2a + 170367e commit 0d19db4
Show file tree
Hide file tree
Showing 31 changed files with 14,366 additions and 93 deletions.
20 changes: 4 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,11 @@ RUN \
&& tar -C /opt -xf arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz \
&& rm arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz

# GCC Embedded Toolchain 10.3-2021.10 (for earlier Gecko SDKs)
# Gecko SDK 4.4.4
RUN \
curl -O https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 \
&& tar -C /opt -xf gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 \
&& rm gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2

# Gecko SDK 4.4.3
RUN \
curl -o gecko_sdk_4.4.3.zip -L https://github.com/SiliconLabs/gecko_sdk/releases/download/v4.4.3/gecko-sdk.zip \
&& unzip -q -d gecko_sdk_4.4.3 gecko_sdk_4.4.3.zip \
&& rm gecko_sdk_4.4.3.zip

# Gecko SDK 4.3.1
RUN \
curl -o gecko_sdk_4.3.1.zip -L https://github.com/SiliconLabs/gecko_sdk/releases/download/v4.3.1/gecko-sdk.zip \
&& unzip -q -d gecko_sdk_4.3.1 gecko_sdk_4.3.1.zip \
&& rm gecko_sdk_4.3.1.zip
curl -o gecko_sdk_4.4.4.zip -L https://github.com/SiliconLabs/gecko_sdk/releases/download/v4.4.4/gecko-sdk.zip \
&& unzip -q -d gecko_sdk_4.4.4 gecko_sdk_4.4.4.zip \
&& rm gecko_sdk_4.4.4.zip

ARG USERNAME=builder
ARG USER_UID=1000
Expand Down
2,407 changes: 2,401 additions & 6 deletions misc/firmware-eraser/.cproject

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion misc/firmware-eraser/firmware-eraser.pintool
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ASCII"?>
<device:XMLDevice xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:device="http://www.silabs.com/ss/hwconfig/document/device.ecore" name="pin_tool.EFR32MG21A010F1024IM32" partId="mcu.arm.efr32.mg21.efr32mg21a010f1024im32" contextId="com.silabs.sdk.stack.super:4.4.3._-295637086">
<device:XMLDevice xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:device="http://www.silabs.com/ss/hwconfig/document/device.ecore" name="pin_tool.EFR32MG21A010F1024IM32" partId="mcu.arm.efr32.mg21.efr32mg21a010f1024im32" contextId="com.silabs.sdk.stack.super:4.4.4._-295637083">
<mode name="DefaultMode">
<property object="DefaultMode" propertyId="mode.diagramLocation" value="100, 100"/>
</mode>
Expand Down
2 changes: 1 addition & 1 deletion misc/firmware-eraser/firmware-eraser.slcp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ include:
- path: .
file_list:
- {path: app.h}
sdk: {id: gecko_sdk, version: 4.4.3}
sdk: {id: gecko_sdk, version: 4.4.4}
toolchain_settings: []
component:
- {id: EFR32MG21A010F1024IM32}
Expand Down
2 changes: 1 addition & 1 deletion misc/firmware-eraser/firmware-eraser.slps
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="ASCII"?>
<model:MDescriptors xmlns:model="http://www.silabs.com/ss/Studio.ecore">
<descriptors name="firmware-eraser">
<properties key="projectCommon.sdkId" value="com.silabs.sdk.stack.super:4.4.3._-295637086"/>
<properties key="projectCommon.sdkId" value="com.silabs.sdk.stack.super:4.4.4._-295637083"/>
<properties key="universalConfig.relativeWorkspacePath" value="../firmware-eraser.slcw"/>
<properties key="universalConfig.generationDirectory" value=""/>
<properties key="universalConfig.toolchainCompatibility" value="iar gcc"/>
Expand Down
1,606 changes: 1,603 additions & 3 deletions src/bootloader-uart-xmodem/.cproject

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/bootloader-uart-xmodem/bootloader-uart-xmodem.pintool
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ASCII"?>
<device:XMLDevice xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:device="http://www.silabs.com/ss/hwconfig/document/device.ecore" name="pin_tool.EFR32MG21A010F1024IM32" partId="mcu.arm.efr32.mg21.efr32mg21a010f1024im32" contextId="com.silabs.sdk.stack.super:4.4.3._-295637086">
<device:XMLDevice xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:device="http://www.silabs.com/ss/hwconfig/document/device.ecore" name="pin_tool.EFR32MG21A010F1024IM32" partId="mcu.arm.efr32.mg21.efr32mg21a010f1024im32" contextId="com.silabs.sdk.stack.super:4.4.4._-295637083">
<mode name="DefaultMode">
<property object="DefaultMode" propertyId="mode.diagramLocation" value="100, 100"/>
<property object="GPIO" propertyId="ABModule.selectedRequirement" value="gpio%T%SL_DEBUG%T%btl_debug_cfg.h"/>
Expand Down
2 changes: 1 addition & 1 deletion src/bootloader-uart-xmodem/bootloader-uart-xmodem.slcp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package: bootloader
quality: production
readme:
- {path: readme.md}
sdk: {id: gecko_sdk, version: 4.4.3}
sdk: {id: gecko_sdk, version: 4.4.4}
toolchain_settings: []
component:
- {id: EFR32MG21A010F1024IM32}
Expand Down
2 changes: 1 addition & 1 deletion src/bootloader-uart-xmodem/bootloader-uart-xmodem.slps
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="ASCII"?>
<model:MDescriptors xmlns:model="http://www.silabs.com/ss/Studio.ecore">
<descriptors name="bootloader-uart-xmodem">
<properties key="projectCommon.sdkId" value="com.silabs.sdk.stack.super:4.4.3._-295637086"/>
<properties key="projectCommon.sdkId" value="com.silabs.sdk.stack.super:4.4.4._-295637083"/>
<properties key="universalConfig.relativeWorkspacePath" value="../bootloader-uart-xmodem.slcw"/>
<properties key="universalConfig.generationDirectory" value=""/>
<properties key="universalConfig.toolchainCompatibility" value="iar gcc"/>
Expand Down
2,643 changes: 2,640 additions & 3 deletions src/ncp-uart-hw/.cproject

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/ncp-uart-hw/ncp-uart-hw.pintool
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ASCII"?>
<device:XMLDevice xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:device="http://www.silabs.com/ss/hwconfig/document/device.ecore" name="pin_tool.EFR32MG21A010F1024IM32" partId="mcu.arm.efr32.mg21.efr32mg21a010f1024im32" contextId="com.silabs.sdk.stack.super:4.4.3._-295637086">
<device:XMLDevice xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:device="http://www.silabs.com/ss/hwconfig/document/device.ecore" name="pin_tool.EFR32MG21A010F1024IM32" partId="mcu.arm.efr32.mg21.efr32mg21a010f1024im32" contextId="com.silabs.sdk.stack.super:4.4.4._-295637083">
<mode name="DefaultMode">
<property object="DefaultMode" propertyId="mode.diagramLocation" value="100, 100"/>
</mode>
Expand Down
2 changes: 1 addition & 1 deletion src/ncp-uart-hw/ncp-uart-hw.slcp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ source:
- {path: main.c}
- {path: app.c}
tag: [prebuilt_demo]
sdk: {id: gecko_sdk, version: 4.4.3}
sdk: {id: gecko_sdk, version: 4.4.4}
toolchain_settings: []
component:
- {id: EFR32MG21A010F1024IM32}
Expand Down
2 changes: 1 addition & 1 deletion src/ncp-uart-hw/ncp-uart-hw.slps
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="ASCII"?>
<model:MDescriptors xmlns:model="http://www.silabs.com/ss/Studio.ecore">
<descriptors name="ncp-uart-hw">
<properties key="projectCommon.sdkId" value="com.silabs.sdk.stack.super:4.4.3._-295637086"/>
<properties key="projectCommon.sdkId" value="com.silabs.sdk.stack.super:4.4.4._-295637083"/>
<properties key="universalConfig.relativeWorkspacePath" value="../ncp-uart-hw.slcw"/>
<properties key="universalConfig.generationDirectory" value=""/>
<properties key="universalConfig.toolchainCompatibility" value="iar gcc"/>
Expand Down
2,601 changes: 2,596 additions & 5 deletions src/ot-rcp/.cproject

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions src/ot-rcp/config/sl_rcp_gp_interface_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//-------- <<< Use Configuration Wizard in Context Menu >>> -----------------

// <e> Rx Offset time
// The rx offset time for the bidirectional message.
//
#define GP_RX_OFFSET_IN_MICRO_SECONDS 21000
// </e>

// <e> TX Timeout
// Tx timeout after which the gp outgoing packet is invalid.
//
#define GP_TX_MAX_TIMEOUT_IN_MICRO_SECONDS 5000000
// </e>
// <<< end of configuration section >>>
2 changes: 1 addition & 1 deletion src/ot-rcp/ot-rcp.pintool
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ASCII"?>
<device:XMLDevice xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:device="http://www.silabs.com/ss/hwconfig/document/device.ecore" name="pin_tool.EFR32MG21A010F1024IM32" partId="mcu.arm.efr32.mg21.efr32mg21a010f1024im32" contextId="com.silabs.sdk.stack.super:4.4.3._-295637086">
<device:XMLDevice xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:device="http://www.silabs.com/ss/hwconfig/document/device.ecore" name="pin_tool.EFR32MG21A010F1024IM32" partId="mcu.arm.efr32.mg21.efr32mg21a010f1024im32" contextId="com.silabs.sdk.stack.super:4.4.4._-295637083">
<mode name="DefaultMode">
<property object="DefaultMode" propertyId="mode.diagramLocation" value="100, 100"/>
<property object="GPIO" propertyId="ABModule.selectedRequirement" value="gpio%T%SL_DEBUG%T%sl_debug_swo_config.h"/>
Expand Down
2 changes: 1 addition & 1 deletion src/ot-rcp/ot-rcp.slcp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ include:
file_list:
- {path: app.h}
- {path: reset_util.h}
sdk: {id: gecko_sdk, version: 4.4.3}
sdk: {id: gecko_sdk, version: 4.4.4}
toolchain_settings: []
component:
- {id: EFR32MG21A010F1024IM32}
Expand Down
2 changes: 1 addition & 1 deletion src/ot-rcp/ot-rcp.slps
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="ASCII"?>
<model:MDescriptors xmlns:model="http://www.silabs.com/ss/Studio.ecore">
<descriptors name="ot-rcp">
<properties key="projectCommon.sdkId" value="com.silabs.sdk.stack.super:4.4.3._-295637086"/>
<properties key="projectCommon.sdkId" value="com.silabs.sdk.stack.super:4.4.4._-295637083"/>
<properties key="universalConfig.relativeWorkspacePath" value="../ot-rcp.slcw"/>
<properties key="universalConfig.generationDirectory" value=""/>
<properties key="universalConfig.toolchainCompatibility" value="gcc"/>
Expand Down
2,766 changes: 2,761 additions & 5 deletions src/rcp-uart-802154/.cproject

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/rcp-uart-802154/rcp-uart-802154.pintool
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ASCII"?>
<device:XMLDevice xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:device="http://www.silabs.com/ss/hwconfig/document/device.ecore" name="pin_tool.EFR32MG21A010F1024IM32" partId="mcu.arm.efr32.mg21.efr32mg21a010f1024im32" contextId="com.silabs.sdk.stack.super:4.4.3._-295637086">
<device:XMLDevice xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:device="http://www.silabs.com/ss/hwconfig/document/device.ecore" name="pin_tool.EFR32MG21A010F1024IM32" partId="mcu.arm.efr32.mg21.efr32mg21a010f1024im32" contextId="com.silabs.sdk.stack.super:4.4.4._-295637083">
<mode name="DefaultMode">
<property object="DefaultMode" propertyId="mode.diagramLocation" value="100, 100"/>
<property object="GPIO" propertyId="ABModule.selectedRequirement" value="gpio%T%SL_DEBUG%T%sl_debug_swo_config.h"/>
Expand Down
2 changes: 1 addition & 1 deletion src/rcp-uart-802154/rcp-uart-802154.slcp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ include:
file_list:
- {path: app.h}
- {path: reset_util.h}
sdk: {id: gecko_sdk, version: 4.4.3}
sdk: {id: gecko_sdk, version: 4.4.4}
toolchain_settings: []
component:
- {from: nc_efr32_watchdog, id: nc_efr32_watchdog}
Expand Down
2 changes: 1 addition & 1 deletion src/rcp-uart-802154/rcp-uart-802154.slps
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="ASCII"?>
<model:MDescriptors xmlns:model="http://www.silabs.com/ss/Studio.ecore">
<descriptors name="rcp-uart-802154">
<properties key="projectCommon.sdkId" value="com.silabs.sdk.stack.super:4.4.3._-295637086"/>
<properties key="projectCommon.sdkId" value="com.silabs.sdk.stack.super:4.4.4._-295637083"/>
<properties key="universalConfig.relativeWorkspacePath" value="../rcp-uart-802154.slcw"/>
<properties key="universalConfig.generationDirectory" value=""/>
<properties key="universalConfig.toolchainCompatibility" value="gcc"/>
Expand Down
2,185 changes: 2,176 additions & 9 deletions src/zwave_ncp_serial_api_controller/.cproject

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions src/zwave_ncp_serial_api_controller/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#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
Expand Down Expand Up @@ -473,6 +474,9 @@ appFileSystemInit(void)
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
Expand Down Expand Up @@ -902,7 +906,21 @@ ApplicationInitSW(void)
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
Expand Down
40 changes: 20 additions & 20 deletions src/zwave_ncp_serial_api_controller/cmd_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,26 +128,26 @@ ZW_ADD_CMD(FUNC_ID_GET_TX_TIMERS)

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);
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);
}
Expand Down
70 changes: 70 additions & 0 deletions src/zwave_ncp_serial_api_controller/cmds_management.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,31 @@
#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,
Expand Down Expand Up @@ -202,6 +227,8 @@ void func_id_serial_api_setup(uint8_t inputLength,
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. */
Expand Down Expand Up @@ -253,6 +280,49 @@ void func_id_serial_api_setup(uint8_t inputLength,
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;
Expand Down
Loading

0 comments on commit 0d19db4

Please sign in to comment.