Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SL-TEMP] Merge 2.5 to 2.6 (20-03-25) #364

Open
wants to merge 5 commits into
base: release_2.6-1.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/examples-efr32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
if: github.actor != 'restyled-io[bot]'

container:
image: ghcr.io/project-chip/chip-build-efr32:95
image: ghcr.io/project-chip/chip-build-efr32:115
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/silabs-common-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest

container:
image: ghcr.io/project-chip/chip-build-efr32:95
image: ghcr.io/project-chip/chip-build-efr32:115

strategy:
matrix:
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,17 @@
[submodule "third_party/silabs/simplicity_sdk"]
path = third_party/silabs/simplicity_sdk
url = https://github.com/SiliconLabs/simplicity_sdk.git
branch = v2024.6.2
branch = v2024.12.1-0
platforms = silabs
[submodule "third_party/silabs/wiseconnect-wifi-bt-sdk"]
path = third_party/silabs/wiseconnect-wifi-bt-sdk
url = https://github.com/SiliconLabs/wiseconnect-wifi-bt-sdk.git
branch = 2.10.3
branch = 2.11.2
platforms = silabs
[submodule "third_party/silabs/wifi_sdk"]
path = third_party/silabs/wifi_sdk
url = https://github.com/SiliconLabs/wiseconnect.git
branch = v3.3.3
branch = v3.4.1
platforms = silabs
[submodule "editline"]
path = third_party/editline/repo
Expand Down
54 changes: 54 additions & 0 deletions examples/platform/silabs/cmp/sl-matter-attribute-storage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*****************************************************************************
* @file sl-matter-attribute-storage.cpp
* @brief Link zigbee datamodel attribute changes to Matter attribute storage.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc.
*www.silabs.com</b>
*******************************************************************************
*
* 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 <app/util/attribute-metadata.h>
#include <app/util/attribute-table.h>
#include <lib/support/TypeTraits.h>
#include <lib/support/logging/CHIPLogging.h>
#include <protocols/interaction_model/StatusCode.h>
#include <sl-matter-attribute-storage.h>
#include <sl_component_catalog.h>

namespace {
// This is called from simplicity_sdk/protocol/zigbee/app/framework/util/attribute-storage.c on ZB attribute write
// when GENERATED_MULTI_PROTOCOL_ATTRIBUTE_MAPPING and SL_CATALOG_MULTIPROTOCOL_ZIGBEE_MATTER_COMMON_PRESENT are defined.
extern "C" sl_status_t sli_matter_af_write_attribute(uint16_t endpointId, uint32_t clusterId, uint32_t attributeId,
uint8_t * attributeValue, uint8_t type)
{
// All type shall be directly applicable. We expect compilation error if type changes.
chip::EndpointId matterEndpointId = endpointId;
chip::ClusterId matterClusterId = clusterId;
chip::AttributeId matterAttributeId = attributeId;
EmberAfAttributeType matterDataType = type;

chip::Protocols::InteractionModel::Status imStatus =
emberAfWriteAttribute(matterEndpointId, matterClusterId, matterAttributeId, attributeValue, matterDataType);

// For sl internal use so we return a known status type to our stack
sl_status_t slStatus = SL_STATUS_OK;
if (imStatus != chip::Protocols::InteractionModel::Status::Success)
{
ChipLogError(Zcl, "Failed to write Matter attribute from multiprotocol update. Err:0x%02x", chip::to_underlying(imStatus));
slStatus = SL_STATUS_FAIL;
}

return slStatus;
}
} // namespace
55 changes: 55 additions & 0 deletions examples/platform/silabs/cmp/sl-matter-attribute-storage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*******************************************************************************
* @file sl-matter-attribute-storage.h
* @brief Link zigbee datamodel attribute changes to Matter attribute storage.
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* 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 SL_MATTER_ATTRIBUTE_STORAGE
#define SL_MATTER_ATTRIBUTE_STORAGE

#include <sl_status.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief Writes an attribute value to the Matter attribute storage.
*
* *** This is a Silabs internal api. ***
*
* It exposes the Matter API that writes to the Matter attribute storage to our zigbee datamodel stack,
* implemented in C, for multiprotocol usecases, without exposing matter datamodel elements
*
* This function expect that either the used Zigbee cluster/attributes maps 1 to 1 to the matter counter part
* or that the caller translated the Zigbee attribute parameters to Matter attribute parameters.
*
* The function ultimaly uses those fields in the Matter API to perform the attribute write operation.
*
* @param endpointId Linked ZB/Matter endpoint identifier.
* @param clusterId Linked ZB/Matter cluster identifier.
* @param attributeId Linked ZB/Matter attribute identifier.
* @param attributeValue Pointer to the attribute value to be written.
* @param type The data type of the attribute. Shall match Matters' EmberAfAttributeType
* @return sl_status_t Status of the write operation, SL_STATUS_OK if successful, otherwise SL_STATUS_FAIL.
*/
sl_status_t sli_matter_af_write_attribute(uint16_t endpointId, uint32_t clusterId, uint32_t attributeId, uint8_t * attributeValue,
uint8_t type);

#ifdef __cplusplus
}
#endif

#endif // SL_MATTER_ATTRIBUTE_STORAGE
2 changes: 2 additions & 0 deletions examples/platform/silabs/matter-platform.slcp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ configuration:
- {name: SL_BT_RTOS_LINK_LAYER_TASK_STACK_SIZE, value: 1024}
- {name: SL_BT_RTOS_HOST_STACK_TASK_STACK_SIZE, value: 2048}
- {name: SL_BT_RTOS_EVENT_HANDLER_STACK_SIZE, value: 1536}
- {name: SL_MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS, value: 1}
- {name: SL_OPENTHREAD_ENABLE_SERIAL_TASK, value: 0}

template_contribution:
- name: mbedtls_ssl_content_len_in_requirement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
#include <platform/silabs/multi-ota/OtaTlvEncryptionKey.h>
#endif // OTA_ENCRYPTION_ENABLE

#if !SL_MATTER_GN_BUILD
#include <sl_matter_provision_config.h>
#endif

using namespace chip::Credentials;

#if SLI_SI91X_MCU_INTERFACE
Expand Down
4 changes: 1 addition & 3 deletions src/platform/silabs/wifi/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ source_set("wifi-platform") {
"${silabs_platform_dir}/wifi/SiWx/WifiInterface.cpp",
"${silabs_platform_dir}/wifi/wiseconnect-abstraction/WiseconnectInterfaceAbstraction.cpp",
"${silabs_platform_dir}/wifi/wiseconnect-abstraction/WiseconnectInterfaceAbstraction.h",

# Wi-Fi Config - Using the file sdk support until the wiseconnect file is fixed
"${matter_support_root}/sdk-copies/components/service/network_manager/src/sl_net_for_lwip.c",
"${wifi_sdk_root}/components/service/network_manager/src/sl_net_for_lwip.c",
]

public_deps += [ "${lwip_root}:lwip" ]
Expand Down
117 changes: 25 additions & 92 deletions src/platform/silabs/wifi/SiWx/WifiInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,11 @@ bool ps_requirement_added = false;
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER

bool hasNotifiedWifiConnectivity = false;
bool hasNotifiedIPV6 = false;
#if (CHIP_DEVICE_CONFIG_ENABLE_IPV4)
bool hasNotifiedIPV4 = false;
#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */

wfx_wifi_scan_ext_t temp_reset;

osSemaphoreId_t sScanCompleteSemaphore;
osSemaphoreId_t sScanInProgressSemaphore;
osTimerId_t sDHCPTimer;
osMessageQueueId_t sWifiEventQueue = nullptr;

sl_net_wifi_lwip_context_t wifi_client_context;
Expand All @@ -134,7 +129,8 @@ const sl_wifi_device_configuration_t config = {
#ifdef SLI_SI91X_MCU_INTERFACE
(SL_SI91X_FEAT_SECURITY_OPEN | SL_SI91X_FEAT_WPS_DISABLE),
#else
(SL_SI91X_FEAT_SECURITY_OPEN | SL_SI91X_FEAT_AGGREGATION),
(SL_SI91X_FEAT_SECURITY_OPEN | SL_SI91X_FEAT_AGGREGATION | SL_SI91X_FEAT_ULP_GPIO_BASED_HANDSHAKE |
SL_SI91X_FEAT_DEV_TO_HOST_ULP_GPIO_1),
#endif
.tcp_ip_feature_bit_map = (SL_SI91X_TCP_IP_FEAT_DHCPV4_CLIENT | SL_SI91X_TCP_IP_FEAT_DNS_CLIENT |
SL_SI91X_TCP_IP_FEAT_SSL | SL_SI91X_TCP_IP_FEAT_BYPASS
Expand Down Expand Up @@ -207,27 +203,6 @@ constexpr uint8_t kWfxQueueSize = 10;
// TODO: Figure out why we actually need this, we are already handling failure and retries somewhere else.
constexpr uint16_t kWifiScanTimeoutTicks = 10000;

void DHCPTimerEventHandler(void * arg)
{
WifiEvent event = WifiEvent::kStationDhcpPoll;
sl_matter_wifi_post_event(event);
}

void CancelDHCPTimer(void)
{
VerifyOrReturn(osTimerIsRunning(sDHCPTimer), ChipLogDetail(DeviceLayer, "CancelDHCPTimer: timer not running"));
VerifyOrReturn(osTimerStop(sDHCPTimer) == osOK, ChipLogError(DeviceLayer, "CancelDHCPTimer: failed to stop timer"));
}

void StartDHCPTimer(uint32_t timeout)
{
// Cancel timer if already started
CancelDHCPTimer();

VerifyOrReturn(osTimerStart(sDHCPTimer, pdMS_TO_TICKS(timeout)) == osOK,
ChipLogError(DeviceLayer, "StartDHCPTimer: failed to start timer"));
}

sl_status_t sl_wifi_siwx917_init(void)
{
sl_status_t status = SL_STATUS_OK;
Expand Down Expand Up @@ -356,7 +331,10 @@ sl_status_t SetWifiConfigurations()
VerifyOrReturnError(status == SL_STATUS_OK, status,
ChipLogError(DeviceLayer, "sl_wifi_set_listen_interval failed: 0x%lx", status));

sl_wifi_advanced_client_configuration_t client_config = { .max_retry_attempts = 5 };
// This is be triggered on the disconnect use case, providing the amount of TA tries
// Setting the TA retry to 1 and giving the control to the M4 for improved power efficiency
// When max_retry_attempts is set to 0, TA will retry indefinitely.
sl_wifi_advanced_client_configuration_t client_config = { .max_retry_attempts = 1 };
status = sl_wifi_set_advanced_client_configuration(SL_WIFI_CLIENT_INTERFACE, &client_config);
VerifyOrReturnError(status == SL_STATUS_OK, status,
ChipLogError(DeviceLayer, "sl_wifi_set_advanced_client_configuration failed: 0x%lx", status));
Expand Down Expand Up @@ -513,11 +491,6 @@ sl_status_t sl_matter_wifi_platform_init(void)
sWifiEventQueue = osMessageQueueNew(kWfxQueueSize, sizeof(WifiEvent), nullptr);
VerifyOrReturnError(sWifiEventQueue != nullptr, SL_STATUS_ALLOCATION_FAILED);

// Create timer for DHCP polling
// TODO: Use LWIP timer instead of creating a new one here
sDHCPTimer = osTimerNew(DHCPTimerEventHandler, osTimerPeriodic, nullptr, nullptr);
VerifyOrReturnError(sDHCPTimer != nullptr, SL_STATUS_ALLOCATION_FAILED);

return status;
}

Expand Down Expand Up @@ -661,53 +634,29 @@ sl_status_t bg_scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_

/// NotifyConnectivity
/// @brief Notify the application about the connectivity status if it has not been notified yet.
/// Helper function for HandleDHCPPolling.
void NotifyConnectivity(void)
{
VerifyOrReturn(!hasNotifiedWifiConnectivity);
wfx_connected_notify(CONNECTION_STATUS_SUCCESS, &wfx_rsi.ap_mac);
hasNotifiedWifiConnectivity = true;
}

void HandleDHCPPolling(void)
/// NotifySuccessfulConnection
/// @brief Processing function responsible for notifying the upper layers of a succesful connection attempt.
void NotifySuccessfulConnection(void)
{
WifiEvent event;

// TODO: Notify the application that the interface is not set up or Chipdie here because we are in an unkonwn state
struct netif * sta_netif = &wifi_client_context.netif;
VerifyOrReturn(sta_netif != nullptr, ChipLogError(DeviceLayer, "HandleDHCPPolling: failed to get STA netif"));

#if (CHIP_DEVICE_CONFIG_ENABLE_IPV4)
uint8_t dhcp_state = dhcpclient_poll(sta_netif);
if (dhcp_state == DHCP_ADDRESS_ASSIGNED && !hasNotifiedIPV4)
{
wfx_dhcp_got_ipv4((uint32_t) sta_netif->ip_addr.u_addr.ip4.addr);
hasNotifiedIPV4 = true;
event = WifiEvent::kStationDhcpDone;
sl_matter_wifi_post_event(event);
NotifyConnectivity();
}
else if (dhcp_state == DHCP_OFF)
{
wfx_ip_changed_notify(IP_STATUS_FAIL);
hasNotifiedIPV4 = false;
}
wfx_dhcp_got_ipv4((uint32_t) sta_netif->ip_addr.u_addr.ip4.addr);
#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */
/* Checks if the assigned IPv6 address is preferred by evaluating
* the first block of IPv6 address ( block 0)
*/
if ((ip6_addr_ispreferred(netif_ip6_addr_state(sta_netif, 0))) && !hasNotifiedIPV6)
{
char addrStr[chip::Inet::IPAddress::kMaxStringLength] = { 0 };
VerifyOrReturn(ip6addr_ntoa_r(netif_ip6_addr(sta_netif, 0), addrStr, sizeof(addrStr)) != nullptr);
ChipLogProgress(DeviceLayer, "SLAAC OK: linklocal addr: %s", addrStr);
wfx_ipv6_notify(GET_IPV6_SUCCESS);
hasNotifiedIPV6 = true;
event = WifiEvent::kStationDhcpDone;
sl_matter_wifi_post_event(event);
NotifyConnectivity();
}
char addrStr[chip::Inet::IPAddress::kMaxStringLength] = { 0 };
VerifyOrReturn(ip6addr_ntoa_r(netif_ip6_addr(sta_netif, 0), addrStr, sizeof(addrStr)) != nullptr);
ChipLogProgress(DeviceLayer, "SLAAC OK: linklocal addr: %s", addrStr);
wfx_ipv6_notify(GET_IPV6_SUCCESS);
NotifyConnectivity();
}

void sl_matter_wifi_post_event(WifiEvent event)
{
sl_status_t status = osMessageQueuePut(sWifiEventQueue, &event, 0, 0);
Expand All @@ -719,19 +668,14 @@ void sl_matter_wifi_post_event(WifiEvent event)
// Chipdie, etc.
}
}
/// ResetDHCPNotificationFlags
/// ResetConnectivityNotificationFlags
/// @brief Reset the flags that are used to notify the application about DHCP connectivity
/// and emits a WifiEvent::kStationDoDhcp event to trigger DHCP polling checks. Helper function for ProcessEvent.
void ResetDHCPNotificationFlags(void)
/// and emits a WifiEvent::kConnectionComplete event to trigger DHCP polling checks. Helper function for ProcessEvent.
void ResetConnectivityNotificationFlags(void)
{

#if (CHIP_DEVICE_CONFIG_ENABLE_IPV4)
hasNotifiedIPV4 = false;
#endif // CHIP_DEVICE_CONFIG_ENABLE_IPV4
hasNotifiedIPV6 = false;
hasNotifiedWifiConnectivity = false;

WifiEvent event = WifiEvent::kStationDoDhcp;
WifiEvent event = WifiEvent::kConnectionComplete;
sl_matter_wifi_post_event(event);
}

Expand All @@ -743,7 +687,7 @@ void ProcessEvent(WifiEvent event)
case WifiEvent::kStationConnect:
ChipLogDetail(DeviceLayer, "WifiEvent::kStationConnect");
wfx_rsi.dev_state.Set(WifiState::kStationConnected);
ResetDHCPNotificationFlags();
ResetConnectivityNotificationFlags();
break;

case WifiEvent::kStationDisconnect: {
Expand All @@ -756,7 +700,7 @@ void ProcessEvent(WifiEvent event)
.Clear(WifiState::kStationDhcpDone);

/* TODO: Implement disconnect notify */
ResetDHCPNotificationFlags();
ResetConnectivityNotificationFlags();
#if (CHIP_DEVICE_CONFIG_ENABLE_IPV4)
wfx_ip_changed_notify(0); // for IPV4
wfx_ip_changed_notify(IP_STATUS_FAIL);
Expand Down Expand Up @@ -833,20 +777,9 @@ void ProcessEvent(WifiEvent event)
JoinWifiNetwork();
break;

case WifiEvent::kStationDoDhcp:
ChipLogDetail(DeviceLayer, "WifiEvent::kStationDoDhcp");
StartDHCPTimer(WFX_RSI_DHCP_POLL_INTERVAL);
break;

case WifiEvent::kStationDhcpDone:
ChipLogDetail(DeviceLayer, "WifiEvent::kStationDhcpDone");
CancelDHCPTimer();
break;

case WifiEvent::kStationDhcpPoll:
ChipLogDetail(DeviceLayer, "WifiEvent::kStationDhcpPoll");
HandleDHCPPolling();
break;
case WifiEvent::kConnectionComplete:
ChipLogDetail(DeviceLayer, "WifiPlatformEvent::kConnectionComplete");
NotifySuccessfulConnection();

default:
break;
Expand Down
Loading
Loading