Skip to content

Commit

Permalink
[Silabs]DIC refactor changes (#27340)
Browse files Browse the repository at this point in the history
* DIC refactor changes

* Restyled by clang-format

* Restyled by gn

* removed windows src changes in DIC refactor

* removed windows src changes in DIC refactor

* Refactor changes for DIC

* DIC changes for light app

* Restyled by clang-format

* Restyled by gn

* build gn file related changes for DIC

* DIC BUILD gn changes for 917 soc

* 917 soc dic changes

* Addressed review comments

* Restyled by gn

* DIC refactor changes

* Restyled by clang-format

* Restyled by gn

* removed windows src changes in DIC refactor

* removed windows src changes in DIC refactor

* Refactor changes for DIC

* DIC changes for light app

* Restyled by clang-format

* Restyled by gn

* build gn file related changes for DIC

* DIC BUILD gn changes for 917 soc

* 917 soc dic changes

* Addressed review comments

* Restyled by gn

* Added changes with respect to aws ota

* Restyled by gn

* Added DIC AWS OTA Changes

---------

Co-authored-by: Restyled.io <commits@restyled.io>
Co-authored-by: KishorSilabs <kishor.rankhamb@silabs.com>
  • Loading branch information
3 people authored and pull[bot] committed Feb 16, 2024
1 parent 59cc753 commit 1074556
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 60 deletions.
7 changes: 7 additions & 0 deletions examples/lighting-app/silabs/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include <app/ConcreteAttributePath.h>
#include <lib/support/logging/CHIPLogging.h>

#ifdef DIC_ENABLE
#include "dic.h"
#endif // DIC_ENABLE

using namespace ::chip;
using namespace ::chip::app::Clusters;

Expand All @@ -40,6 +44,9 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &

if (clusterId == OnOff::Id && attributeId == OnOff::Attributes::OnOff::Id)
{
#ifdef DIC_ENABLE
dic_sendmsg("light/state", (const char *) (value ? (*value ? "on" : "off") : "invalid"));
#endif // DIC_ENABLE
LightMgr().InitiateAction(AppEvent::kEventType_Light, *value ? LightingManager::ON_ACTION : LightingManager::OFF_ACTION);
}
else if (clusterId == LevelControl::Id)
Expand Down
7 changes: 7 additions & 0 deletions examples/lock-app/silabs/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
#include <lib/core/DataModelTypes.h>
#include <lib/support/logging/CHIPLogging.h>

#ifdef DIC_ENABLE
#include "dic.h"
#endif // DIC_ENABLE

using namespace ::chip::app::Clusters;
using namespace ::chip::DeviceLayer::Internal;
using ::chip::app::DataModel::Nullable;
Expand All @@ -47,6 +51,9 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &
DoorLock::DlLockState lockState = *(reinterpret_cast<DoorLock::DlLockState *>(value));
ChipLogProgress(Zcl, "Door lock cluster: " ChipLogFormatMEI " state %d", ChipLogValueMEI(clusterId),
to_underlying(lockState));
#ifdef DIC_ENABLE
dic_sendmsg("lock/state", (const char *) (lockState == DoorLock::DlLockState::kLocked ? "lock" : "unlock"));
#endif // DIC_ENABLE
}
}

Expand Down
25 changes: 25 additions & 0 deletions examples/platform/silabs/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
#include <platform/silabs/NetworkCommissioningWiFiDriver.h>
#endif // SL_WIFI

#ifdef DIC_ENABLE
#include "dic.h"
#include "dic_control.h"
#endif // DIC_ENABLE

/**********************************************************
* Defines and Constants
*********************************************************/
Expand Down Expand Up @@ -140,6 +145,22 @@ Identify gIdentify = {
#endif // EMBER_AF_PLUGIN_IDENTIFY_SERVER
} // namespace

#ifdef DIC_ENABLE
namespace {
void AppSpecificConnectivityEventCallback(const ChipDeviceEvent * event, intptr_t arg)
{
SILABS_LOG("AppSpecificConnectivityEventCallback: call back for IPV4");
if ((event->Type == DeviceEventType::kInternetConnectivityChange) &&
(event->InternetConnectivityChange.IPv4 == kConnectivity_Established))
{
SILABS_LOG("Got IPv4 Address! Starting DIC module\n");
if (DIC_OK != dic_init(dic::control::subscribeCB))
SILABS_LOG("Failed to initialize DIC module\n");
}
}
} // namespace
#endif // DIC_ENABLE

/**********************************************************
* AppTask Definitions
*********************************************************/
Expand Down Expand Up @@ -220,6 +241,10 @@ CHIP_ERROR BaseApplication::Init()
sStatusLED.Init(SYSTEM_STATE_LED);
#endif // ENABLE_WSTK_LEDS

#ifdef DIC_ENABLE
chip::DeviceLayer::PlatformMgr().AddEventHandler(AppSpecificConnectivityEventCallback, reinterpret_cast<intptr_t>(nullptr));
#endif // DIC_ENABLE

ConfigurationMgr().LogDeviceConfig();

OutputQrCode(true /*refreshLCD at init*/);
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/silabs/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#ifndef configTOTAL_HEAP_SIZE
#ifdef SL_WIFI
#ifdef DIC_ENABLE
#define configTOTAL_HEAP_SIZE ((size_t)(56 * 1024))
#define configTOTAL_HEAP_SIZE ((size_t)(68 * 1024))
#else
#define configTOTAL_HEAP_SIZE ((size_t)(34 * 1024))
#endif // DIC
Expand Down
40 changes: 13 additions & 27 deletions examples/platform/silabs/SiWx917/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -83,33 +83,6 @@ config("chip_examples_project_config") {
]
}

if (enable_dic) {
config("efr32_dic_config") {
include_dirs = [
"${chip_root}/third_party/silabs/mqtt/stack",
"${chip_root}/third_party/silabs/mqtt/mqtt_transport_interface/include",
"${chip_root}/examples/platform/silabs/DIC/matter_abs_interface/include",
]
}

source_set("efr32-dic") {
sources = [
"${chip_root}/examples/platform/silabs/DIC/matter_abs_interface/src/dic.c",
"${chip_root}/third_party/silabs/mqtt/mqtt_transport_interface/src/MQTT_transport.c",
"${chip_root}/third_party/silabs/mqtt/mqtt_transport_interface/src/altcp.c",
"${chip_root}/third_party/silabs/mqtt/mqtt_transport_interface/src/altcp_alloc.c",
"${chip_root}/third_party/silabs/mqtt/mqtt_transport_interface/src/altcp_tcp.c",
"${chip_root}/third_party/silabs/mqtt/mqtt_transport_interface/src/altcp_tls_mbedtls.c",
"${chip_root}/third_party/silabs/mqtt/mqtt_transport_interface/src/altcp_tls_mbedtls_mem.c",
]
public_deps = [
"${chip_root}/src/inet",
"${chip_root}/src/lwip",
]
public_configs = [ ":efr32_dic_config" ]
}
}

source_set("siwx917-matter-shell") {
if (chip_build_libshell) {
defines = [ "ENABLE_CHIP_SHELL" ]
Expand Down Expand Up @@ -293,6 +266,19 @@ source_set("siwx917-common") {
deps += [ ":siwx917-matter-shell" ]
}

# DIC
if (enable_dic) {
public_deps +=
[ "${silabs_common_plat_dir}/DIC/matter_abs_interface:silabs-dic" ]
}

# AWS SDK OTA
if (aws_sdk_ota) {
public_deps += [
"${silabs_common_plat_dir}/DIC/matter_abs_interface:silabs-aws-sdk-ota",
]
}

# Attestation Credentials
if (chip_build_platform_attestation_credentials_provider) {
deps += [ ":siwx917-attestation-credentials" ]
Expand Down
39 changes: 10 additions & 29 deletions examples/platform/silabs/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -97,33 +97,6 @@ config("chip_examples_project_config") {
]
}

if (enable_dic) {
config("efr32_dic_config") {
include_dirs = [
"${chip_root}/third_party/silabs/mqtt/stack",
"${chip_root}/third_party/silabs/mqtt/mqtt_transport_interface/include",
"${chip_root}/examples/platform/silabs/DIC/matter_abs_interface/include",
]
}

source_set("efr32-dic") {
sources = [
"${chip_root}/examples/platform/silabs/DIC/matter_abs_interface/src/dic.c",
"${chip_root}/third_party/silabs/mqtt/mqtt_transport_interface/src/MQTT_transport.c",
"${chip_root}/third_party/silabs/mqtt/mqtt_transport_interface/src/altcp.c",
"${chip_root}/third_party/silabs/mqtt/mqtt_transport_interface/src/altcp_alloc.c",
"${chip_root}/third_party/silabs/mqtt/mqtt_transport_interface/src/altcp_tcp.c",
"${chip_root}/third_party/silabs/mqtt/mqtt_transport_interface/src/altcp_tls_mbedtls.c",
"${chip_root}/third_party/silabs/mqtt/mqtt_transport_interface/src/altcp_tls_mbedtls_mem.c",
]
public_deps = [
"${chip_root}/src/inet",
"${chip_root}/src/lwip",
]
public_configs = [ ":efr32_dic_config" ]
}
}

source_set("openthread_core_config_efr32_chip_examples") {
if (chip_enable_openthread) {
sources = [ "project_include/OpenThreadConfig.h" ]
Expand Down Expand Up @@ -259,9 +232,17 @@ source_set("efr32-common") {
"${efr32_sdk_build_root}:silabs_config",
]

# MQTT
# DIC
if (enable_dic) {
deps += [ "${examples_plat_dir}:efr32-dic" ]
public_deps +=
[ "${silabs_common_plat_dir}/DIC/matter_abs_interface:silabs-dic" ]
}

# AWS SDK OTA
if (aws_sdk_ota) {
public_deps += [
"${silabs_common_plat_dir}/DIC/matter_abs_interface:silabs-aws-sdk-ota",
]
}

include_dirs = [ "." ]
Expand Down
7 changes: 4 additions & 3 deletions src/lwip/silabs/lwipopts-wf200.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,13 @@
#define DNS_RAND_TXID() ((u32_t) rand())
#define MEM_SIZE 5632
#define MEMP_NUM_UDP_PCB (6)
#define TCP_MSS (4 * 1152)
#define TCPIP_THREAD_PRIO (3)
#else
#define LWIP_DNS 0
#define MEMP_NUM_UDP_PCB (5)
#define TCP_MSS (1152)
#define TCPIP_THREAD_PRIO (2)
#endif // DIC_ENABLE

#define LWIP_FREERTOS_USE_STATIC_TCPIP_TASK 1
Expand Down Expand Up @@ -131,7 +135,6 @@
#define PBUF_CUSTOM_POOL_IDX_START (MEMP_PBUF_POOL_SMALL)
#define PBUF_CUSTOM_POOL_IDX_END (MEMP_PBUF_POOL_LARGE)

#define TCP_MSS (1152)
#define TCP_SND_BUF (2 * TCP_MSS)
#define TCP_LISTEN_BACKLOG (1)

Expand All @@ -141,8 +144,6 @@

#define TCPIP_THREAD_STACKSIZE (2048)

#define TCPIP_THREAD_PRIO (2)

#define NETIF_MAX_HWADDR_LEN 8U

#define LWIP_IPV6_NUM_ADDRESSES 5
Expand Down
3 changes: 3 additions & 0 deletions third_party/silabs/efr32_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ template("efr32_sdk") {
assert(chip_enable_wifi_ipv4, "enable chip_enable_wifi_ipv4")
defines += [ "DIC_ENABLE=1" ]
}
if (aws_sdk_ota) {
defines += [ "ENABLE_AWS_OTA_FEAT=1" ]
}
if (chip_enable_wifi_ipv4) {
defines += [ "CHIP_DEVICE_CONFIG_ENABLE_IPV4=1" ]
}
Expand Down
3 changes: 3 additions & 0 deletions third_party/silabs/silabs_board.gni
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ declare_args() {
#Disable MQTT by default
enable_dic = false

# Disable AWS SDK OTA by default
aws_sdk_ota = false

# Disable UART log forwarding by default
sl_uart_log_output = false
}
Expand Down

0 comments on commit 1074556

Please sign in to comment.