Skip to content
Draft
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
1 change: 1 addition & 0 deletions examples/platform/silabs/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,7 @@ void BaseApplication::OnPlatformEvent(const ChipDeviceEvent * event, intptr_t)
chip::System::Clock::Seconds32(MATTER_AWS_INIT_DELAY_SEC), InitMatterAwsHandler, nullptr);
}
#endif // SL_MATTER_ENABLE_AWS

#if SL_MATTER_DISPLAY_ENABLED
SilabsLCD::Screen_e screen;
AppTask::GetLCD().GetScreen(screen);
Expand Down
21 changes: 19 additions & 2 deletions examples/platform/silabs/MatterShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ void cmdSilabsInit()

#endif // SL_CATALOG_CLI_PRESENT

#if defined(SL_SI91X_FREERTOS_HEAP_4_REDIRECT) && SL_SI91X_FREERTOS_HEAP_4_REDIRECT
// NOTE: Changes for HEAP4 + redirect of malloc/free to heap4
#include "sl_si91x_memory_manager.h"
#else
#include "sl_memory_manager.h"
#endif // SL_SI91X_FREERTOS_HEAP_4_REDIRECT

namespace MemoryShellCommands {

Expand All @@ -125,8 +130,20 @@ CHIP_ERROR MemoryCommandHandler(int argc, char ** argv)

CHIP_ERROR DisplayHeapUsage([[maybe_unused]] int argc, [[maybe_unused]] char ** argv)
{
streamer_printf(streamer_get(), "%lu / %lu\r\n", sl_memory_get_used_heap_size(), sl_memory_get_total_heap_size());
streamer_printf(streamer_get(), "High Watermark: %lu\r\n", sl_memory_get_heap_high_watermark());
size_t used_heap_size = 0;
size_t total_heap_size = 0;
size_t high_watermark = 0;
#if defined(SL_SI91X_FREERTOS_HEAP_4_REDIRECT) && SL_SI91X_FREERTOS_HEAP_4_REDIRECT
used_heap_size = sl_si91x_memory_get_used_heap_size();
total_heap_size = sl_si91x_memory_get_free_heap_size() + used_heap_size;
high_watermark = sl_si91x_memory_get_heap_high_watermark();
#else
used_heap_size = sl_memory_get_used_heap_size();
total_heap_size = sl_memory_get_total_heap_size();
high_watermark = sl_memory_get_heap_high_watermark();
#endif // SL_SI91X_FREERTOS_HEAP_4_REDIRECT
streamer_printf(streamer_get(), "%lu / %lu\r\n", used_heap_size, total_heap_size);
streamer_printf(streamer_get(), "High Watermark: %lu\r\n", high_watermark);
return CHIP_NO_ERROR;
}

Expand Down
11 changes: 10 additions & 1 deletion examples/platform/silabs/freertos_config/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define EXTRA_HEAP_k 0
#endif

#if defined(MQTT_USE_HOST_LWIP_TLS) && MQTT_USE_HOST_LWIP_TLS
#define MQTT_EXTRA_HEAP_k 28
#else
#define MQTT_EXTRA_HEAP_k 0
#endif // MQTT_USE_HOST_LWIP_TLS

#ifndef configTOTAL_HEAP_SIZE
#ifdef SL_WIFI
#ifdef SL_MATTER_ENABLE_AWS
Expand All @@ -291,7 +297,10 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configTOTAL_HEAP_SIZE ((size_t) ((68 + EXTRA_HEAP_k) * 1024))
#endif // SLI_SI91X_MCU_INTERFACE
#else
#define configTOTAL_HEAP_SIZE ((size_t) ((42 + EXTRA_HEAP_k) * 1024))
// NOTE: Changes for HEAP4 + redirect of malloc/free to heap4
// NOTE: 42KB heap size is required for HEAP4 and 30KB heap is required for the redirect of malloc/free to heap4
// NOTE: HEAP watermark was 64KB, additional 8KB is overhead provided to the application
#define configTOTAL_HEAP_SIZE ((size_t) ((72 + EXTRA_HEAP_k + MQTT_EXTRA_HEAP_k) * 1024))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems like a huge increase in heap...

#endif // SL_MATTER_ENABLE_AWS
#else // SL_WIFI
#if SL_CONFIG_OPENTHREAD_LIB == 1
Expand Down
26 changes: 26 additions & 0 deletions examples/thermostat/silabs/certs/cacert.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
*
* Copyright (c) 2026 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* @file cacert.h
* @brief Sample (generated) CA certificate for HTTPs and MQTTs clients
*/

#pragma once

const unsigned char kCaCertExample[] = "";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:
this isn't Thermostat Specific, while i know you currently only focused on this app. It is not additional work to place common elements in a common location.

5 changes: 5 additions & 0 deletions examples/thermostat/silabs/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,9 @@ class AppTask : public BaseApplication
* could not be created, or an error propagated from InitSensor().
*/
CHIP_ERROR InitThermostat();

#if defined(SL_MATTER_ENABLE_SERVICES) && SL_MATTER_ENABLE_SERVICES
/** Schedule MQTT/HTTP service demos after internet connectivity is established. */
static void MatterServicesEventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg);
#endif // SL_MATTER_ENABLE_SERVICES
};
54 changes: 54 additions & 0 deletions examples/thermostat/silabs/include/https_offload_example.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
*
* Copyright (c) 2026 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include "sl_status.h"

#ifndef HTTP_SERVER_IP // IP address of the HTTP server
#error "HTTP_SERVER_IP is not defined"
#endif

#ifndef HTTP_HOSTNAME // used for SNI validation
#error "HTTP_HOSTNAME is not defined"
#endif

#ifndef HTTP_PORT // port of the HTTP server
#error "HTTP_PORT is not defined"
#endif

#ifndef HTTP_URL
#define HTTP_URL "/index.html" // URL of the resource on the HTTP server
#endif

#ifndef HTTP_USER
#define HTTP_USER "john" // username for the HTTP server
#endif

#ifndef HTTP_PASS
#define HTTP_PASS "doe" // password for the HTTP server
#endif

#ifndef HTTP_POST_DATA
#define HTTP_POST_DATA \
"employee_name=MR.REDDY&employee_id=RSXYZ123&designation=Engineer&company=SILABS&location=Hyderabad" // POST data for the HTTP
// // server
#endif

/** Load config + start HTTPS offload client demo. */
sl_status_t https_client_demo_start(void);
68 changes: 68 additions & 0 deletions examples/thermostat/silabs/include/mqtt_example.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
*
* Copyright (c) 2026 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @brief Host LwIP Paho MQTT/MQTTS demo entry point
* 1. Init the MqttClient
* 2. Connect to the MQTT broker
* 3. Subscribe to the topic
* 4. Publish the message
* 5. Disconnect from the MQTT broker (optional)
* 6. Deinit the MqttClient (optional)
*/

#pragma once

#include "sl_status.h"

#ifndef MQTT_BROKER_IP
#error "MQTT_BROKER_IP is not defined"
#endif

#ifndef MQTT_TLS_HOSTNAME // The TLS hostname of your MQTT broker
#error "MQTT_TLS_HOSTNAME is not defined"
#endif

#ifndef MQTT_BROKER_PORT // The port of your MQTT broker
#error "MQTT_BROKER_PORT is not defined"
#endif

#ifndef MQTT_CLIENT_PORT // The port of your MQTT client
#define MQTT_CLIENT_PORT 5003
#endif

#ifndef MQTT_CLIENT_ID // The ID of your MQTT client
#define MQTT_CLIENT_ID "WISECONNECT_SDK_TOPIC"
#endif

#ifndef MQTT_USERNAME // The username of your MQTT client
#define MQTT_USERNAME "john"
#endif

#ifndef MQTT_PASSWORD // The password of your MQTT client
#define MQTT_PASSWORD "doe"
#endif

#ifndef MQTT_TOPIC // The topic of your MQTT client
#define MQTT_TOPIC "THERMOSTAT-DATA"
#endif

#ifndef MQTT_PUBLISH_MESSAGE // The message to publish to the MQTT broker
#define MQTT_PUBLISH_MESSAGE "THIS IS MQTT CLIENT DEMO FROM APPLICATION"
#endif

/** Load config + run MQTT demo on the MqttClient service thread (idempotent). */
sl_status_t mqtt_client_demo_start(void);
41 changes: 41 additions & 0 deletions examples/thermostat/silabs/resources/index_html.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
*
* Copyright (c) 2026 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* @file index_html.h
* @brief HTTP page for the HTTPs offload client application,
* this page is uploaded to the server.
*/

#pragma once

const unsigned char sl_index[] =
"<html><head><style "
"type=\"text/css\">body{font-family:Arial;background:#EFF4F3;margin:0;color:#32403f;}#wp{width:600px;margin:0 "
"auto;}p{display:inline-block;font-weight:bold;text-align:right;margin:9px 30px 9px "
"0;}p,input{width:200px;}h1{text-align:center;font-size:3em;margin:0;padding:20px 0;color:#d6e4e1;border:1px solid "
"#7F8D8C;text-shadow:1px 1px 0 #333;}input{height:24px;border:1px solid #ccc;border-radius:4px;padding:2px "
"5px;margin:0 6px 0 20px;}input:focus{border-color:#32403f;}form{padding-top:20px;border-top:1px solid "
"#2B3736;}.btn{width:100px;margin:15px 0 15px 250px;font-weight:700;color:#fff;border:1px solid "
"#000;}h1,.btn{background:#485c5a;background:linear-gradient(#485c5a,#32403f);}.btn:active{background:#32403f;}input["
"type=checkbox],input[type=radio]{width:16px;height:14px;}#msg{margin:0 0 10px 0;}</style></head><body><h1>Employee "
"Details</h1><form id=\"fm\" method=\"post\" action=\"#\" onsubmit=\"return pt()\"><div "
"id=\"wp\"></div><p>Employee_name:</p><input id=\"emp_name\" name=\"emp_name\"><p>Employee ID:</p><input "
"id=\"emp_id\" name=\"emp_id\"><p>Designation:</p><input id=\"designation\" "
"name=\"designation\"><p>Company:</p><input id=\"company\" name=\"company\"><p>Location:</p><input id=\"location\" "
"name=\"location\">";
64 changes: 64 additions & 0 deletions examples/thermostat/silabs/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include <platform/CHIPDeviceLayer.h>
#include <platform/PlatformError.h>
#include <platform/silabs/platformAbstraction/SilabsPlatform.h>
#include <sl_cmsis_os2_common.h>
#include <thermostat-delegate-impl.h>

#if defined(SL_MATTER_USE_SI70XX_SENSOR) && SL_MATTER_USE_SI70XX_SENSOR
Expand All @@ -53,6 +54,18 @@
#include "MatterAwsControl.h"
#endif // SL_MATTER_ENABLE_AWS

#if defined(SL_MATTER_ENABLE_SERVICES) && SL_MATTER_ENABLE_SERVICES
#include <platform/silabs/services/matter_service.h>

#if defined(SL_MATTER_ENABLE_HTTP_SERVICE) && SL_MATTER_ENABLE_HTTP_SERVICE
#include "https_offload_example.h"
#endif // SL_MATTER_ENABLE_HTTP_SERVICE

#if defined(SL_MATTER_ENABLE_MQTT_SERVICE) && SL_MATTER_ENABLE_MQTT_SERVICE
#include "mqtt_example.h"
#endif // SL_MATTER_ENABLE_MQTT_SERVICE
#endif // SL_MATTER_ENABLE_SERVICES

#define APP_FUNCTION_BUTTON 0

using namespace chip;
Expand Down Expand Up @@ -111,6 +124,15 @@ CHIP_ERROR AppTask::AppInit()
appError(err);
}

#if defined(SL_MATTER_ENABLE_SERVICES) && SL_MATTER_ENABLE_SERVICES
err = PlatformMgr().AddEventHandler(MatterServicesEventHandler, 0);
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer, "MatterServicesEventHandler register failed: %" CHIP_ERROR_FORMAT, err.Format());
appError(err);
}
#endif // SL_MATTER_ENABLE_SERVICES

return err;
}

Expand Down Expand Up @@ -360,6 +382,48 @@ void AppTask::DMThermostatClusterInit(chip::EndpointId endpoint)
SetDefaultDelegate(endpoint, &delegate);
}

#if defined(SL_MATTER_ENABLE_SERVICES) && SL_MATTER_ENABLE_SERVICES
namespace {

using chip::DeviceLayer::Silabs::kMatterServicesInitDelaySec;

void InitMatterServicesHandler(System::Layer * /* systemLayer */, void * /* appState */)
{
#if defined(SL_MATTER_ENABLE_MQTT_SERVICE) && SL_MATTER_ENABLE_MQTT_SERVICE
VerifyOrReturn(SL_STATUS_OK == mqtt_client_demo_start(), ChipLogError(AppServer, "mqtt_client_demo_start failed"));
#endif // SL_MATTER_ENABLE_MQTT_SERVICE

#if defined(SL_MATTER_ENABLE_HTTP_SERVICE) && SL_MATTER_ENABLE_HTTP_SERVICE
VerifyOrReturn(SL_STATUS_OK == https_client_demo_start(), ChipLogError(AppServer, "https_client_demo_start failed"));
#endif // SL_MATTER_ENABLE_HTTP_SERVICE
}

} // namespace

void AppTask::MatterServicesEventHandler(const ChipDeviceEvent * event, intptr_t)
{
VerifyOrReturn(event != nullptr);

if (event->Type != DeviceEventType::kInternetConnectivityChange)
{
return;
}

if (event->InternetConnectivityChange.IPv4 != kConnectivity_Established
#if defined(SL_MATTER_ENABLE_DUAL_STACK) && SL_MATTER_ENABLE_DUAL_STACK
&& event->InternetConnectivityChange.IPv6 != kConnectivity_Established
#endif // SL_MATTER_ENABLE_DUAL_STACK
)
{
return;
}

ChipLogProgress(AppServer, "Scheduling Matter Services initialization");
TEMPORARY_RETURN_IGNORED SystemLayer().StartTimer(System::Clock::Seconds32(kMatterServicesInitDelaySec),
InitMatterServicesHandler, nullptr);
}
#endif // SL_MATTER_ENABLE_SERVICES

// emberAfThermostatClusterInitCallback — weak ZAP entry point. CRTP forwarder into AppTask.
void emberAfThermostatClusterInitCallback(chip::EndpointId endpoint)
{
Expand Down
Loading
Loading