Skip to content

Commit

Permalink
Silicon Labs Matter Extension v2.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarthak-Shaha committed Oct 10, 2024
1 parent 578f76f commit 3f1e18d
Show file tree
Hide file tree
Showing 181 changed files with 2,611 additions and 9,866 deletions.
30 changes: 17 additions & 13 deletions examples/platform/silabs/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,10 @@ void BaseApplication::ScheduleFactoryReset()
{
Provision::Manager::GetInstance().SetProvisionRequired(true);
}
#if SL_WIFI
// Removing the matter services on factory reset
chip::Dnssd::ServiceAdvertiser::Instance().RemoveServices();
#endif // SL_WIFI
PlatformMgr().HandleServerShuttingDown(); // HandleServerShuttingDown calls OnShutdown() which is only implemented for the
// basic information cluster it seems. And triggers and Event flush, which is not
// relevant when there are no fabrics left
Expand Down Expand Up @@ -867,10 +871,20 @@ void BaseApplication::OnPlatformEvent(const ChipDeviceEvent * event, intptr_t)

if (DIC_OK != dic_init(dic::control::subscribeCB))
{
ChipLogError(AppServer, "Failed to initialize DIC module\n");
ChipLogError(AppServer, "dic_init failed");
}
}
#endif // DIC_ENABLE
#ifdef DISPLAY_ENABLED
SilabsLCD::Screen_e screen;
AppTask::GetLCD().GetScreen(screen);
// Update the LCD screen with SSID and connected state
if (screen == SilabsLCD::Screen_e::StatusScreen)
{
BaseApplication::UpdateLCDStatusScreen(false);
AppTask::GetLCD().SetScreen(screen);
}
#endif // DISPLAY_ENABLED
if ((event->ThreadConnectivityChange.Result == kConnectivity_Established) ||
(event->InternetConnectivityChange.IPv6 == kConnectivity_Established))
{
Expand Down Expand Up @@ -925,18 +939,8 @@ void BaseApplication::OnPlatformEvent(const ChipDeviceEvent * event, intptr_t)
#endif /* CHIP_CONFIG_ENABLE_ICD_SERVER && RS911X_WIFI */
}
break;

case DeviceEventType::kWiFiConnectivityChange: {
#ifdef DISPLAY_ENABLED
SilabsLCD::Screen_e screen;
AppTask::GetLCD().GetScreen(screen);
// Update the LCD screen with SSID and connected state
VerifyOrReturn(screen == SilabsLCD::Screen_e::StatusScreen);
BaseApplication::UpdateLCDStatusScreen(false);
AppTask::GetLCD().SetScreen(screen);
#endif // DISPLAY_ENABLED
}
break;
default:
break;
}
}

Expand Down
75 changes: 40 additions & 35 deletions examples/platform/silabs/DIC/matter_abs_interface/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ config("silabs_dic_config") {
"${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("silabs-dic") {
sources = [
"${chip_root}/examples/platform/silabs/DIC/matter_abs_interface/src/dic.cpp",
Expand All @@ -34,47 +35,51 @@ source_set("silabs-dic") {
"${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",
app_data_model,
]

public_configs = [ ":silabs_dic_config" ]
}

config("silabs_aws_sdk_ota_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",
"${chip_root}/third_party/silabs/aws_ota_sdk/demos/ota/ota_demo_core_mqtt",
"${chip_root}/third_party/silabs/aws_ota_sdk/demos/ota/common/include",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/include",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/portable/os",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/dependency/3rdparty/tinycbor/src",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/dependency/coreJSON/source/include",
]
}
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",
"${chip_root}/third_party/silabs/aws_ota_sdk/demos/ota/ota_demo_core_mqtt",
"${chip_root}/third_party/silabs/aws_ota_sdk/demos/ota/common/include",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/include",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/portable/os",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/dependency/3rdparty/tinycbor/src",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/dependency/coreJSON/source/include",
]
}

source_set("silabs-aws-sdk-ota") {
sources = [
"${chip_root}/third_party/silabs/aws_ota_sdk/demos/ota/ota_demo_core_mqtt/ota_demo_core_mqtt.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/demos/ota/common/src/mqtt_subscription_manager.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/demos/ota/common/src/pal.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/demos/ota/ota_demo_core_mqtt/ota.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/ota_base64.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/ota_interface.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/ota_mqtt.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/ota_cbor.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/portable/os/ota_os_freertos.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/dependency/coreJSON/source/core_json.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/dependency/3rdparty/tinycbor/src/cborparser.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/dependency/3rdparty/tinycbor/src/cborencoder.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/dependency/3rdparty/tinycbor/src/cborencoder_close_container_checked.c",
]
public_deps = [
"${chip_root}/src/inet",
"${chip_root}/src/lwip",
]
public_configs = [ ":silabs_aws_sdk_ota_config" ]
}
source_set("silabs-aws-sdk-ota") {
sources = [
"${chip_root}/third_party/silabs/aws_ota_sdk/demos/ota/common/src/mqtt_subscription_manager.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/demos/ota/common/src/pal.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/demos/ota/ota_demo_core_mqtt/ota.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/demos/ota/ota_demo_core_mqtt/ota_demo_core_mqtt.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/dependency/3rdparty/tinycbor/src/cborencoder.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/dependency/3rdparty/tinycbor/src/cborencoder_close_container_checked.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/dependency/3rdparty/tinycbor/src/cborparser.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/dependency/coreJSON/source/core_json.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/ota_base64.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/ota_cbor.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/ota_interface.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/ota_mqtt.c",
"${chip_root}/third_party/silabs/aws_ota_sdk/ota-for-aws-iot-embedded-sdk/source/portable/os/ota_os_freertos.c",
]

public_deps = [
"${chip_root}/src/inet",
"${chip_root}/src/lwip",

]
public_configs = [ ":silabs_aws_sdk_ota_config" ]
}
54 changes: 28 additions & 26 deletions examples/platform/silabs/DIC/matter_abs_interface/include/dic.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @brief Matter abstraction layer for Direct Internet Connectivity.
*******************************************************************************
* # License
* <b>Copyright 2020 Silicon Laboratories Inc.
* <b>Copyright 2023 Silicon Laboratories Inc.
*www.silabs.com</b>
*******************************************************************************
*
Expand All @@ -20,45 +20,47 @@

#ifndef __DIC_H
#define __DIC_H

#include <stdint.h>

#include "dic_config.h"

#ifdef __cplusplus
extern "C" {
#endif
#include "mqtt.h"
#include "stdint.h"
typedef enum {
DIC_OK = 0,
DIC_ERR_INVAL,
DIC_ERR_MEM,
DIC_ERR_FAIL,
DIC_ERR_CONN,
DIC_ERR_PUBLISH,
typedef enum
{
DIC_OK = 0,
DIC_ERR_INVAL,
DIC_ERR_MEM,
DIC_ERR_FAIL,
DIC_ERR_CONN,
DIC_ERR_PUBLISH,
} dic_err_t;

#define MQTT_QOS_0 0

typedef struct {
uint8_t *dataP;
uint16_t dataLen;
typedef struct
{
uint8_t * dataP;
uint16_t dataLen;
} dic_buff_t;

typedef void (* dic_subscribe_cb)(void);
typedef void (*dic_subscribe_cb)(void);

dic_err_t dic_init(dic_subscribe_cb subs_cb);

dic_err_t dic_mqtt_subscribe(mqtt_client_t *client, mqtt_incoming_publish_cb_t publish_cb, mqtt_incoming_data_cb_t data_cb, const char * topic, uint8_t qos);

dic_err_t dic_sendmsg(const char *subject, const char *content);
dic_err_t dic_mqtt_subscribe(mqtt_client_t * client, mqtt_incoming_publish_cb_t publish_cb, mqtt_incoming_data_cb_t data_cb,
const char * topic, uint8_t qos);

dic_err_t dic_sendmsg(const char * subject, const char * content);

#ifdef ENABLE_AWS_OTA_FEAT

#define AWS_OTA_TASK_STACK_SIZE 1024
#define AWS_OTA_TASK_PRIORITY 1

typedef void (*callback_t)(const char * sub_topic, uint16_t top_len, const void *pload, uint16_t pLoadLength);
struct sub_cb_info{
char *sub_topic;
callback_t cb;
typedef void (*callback_t)(const char * sub_topic, uint16_t top_len, const void * pload, uint16_t pLoadLength);
struct sub_cb_info
{
char * sub_topic;
callback_t cb;
};

int dic_init_status(void);
Expand All @@ -72,7 +74,7 @@ dic_err_t dic_aws_ota_subscribe(const char * topic, uint8_t qos, callback_t subs
dic_err_t dic_aws_ota_process();

dic_err_t dic_aws_ota_close();
#endif
#endif // ENABLE_AWS_OTA_FEAT

#ifdef __cplusplus
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @brief Matter abstraction layer for Direct Internet Connectivity.
*******************************************************************************
* # License
* <b>Copyright 2020 Silicon Laboratories Inc.
* <b>Copyright 2023 Silicon Laboratories Inc.
*www.silabs.com</b>
*******************************************************************************
*
Expand All @@ -21,31 +21,41 @@
#ifndef __DIC_CONFIG_H
#define __DIC_CONFIG_H

/*certificates*/
#define USE_AWS 1
#define USE_MOSQUITTO 0
/* Instance configuration */

/* Task Configuration*/
#ifndef SL_DIC_NVM_EMBED_CERT
#define SL_DIC_NVM_EMBED_CERT (0)
#endif

/* Task Configuration */
#define DIC_TASK_NAME "DIC"
#define DIC_TASK_STACK_SIZE (2*1024) //2k
#define DIC_TASK_PRIORITY 5
#define DIC_TASK_STACK_SIZE (2 * 1024) // 2k
#define DIC_TASK_PRIORITY (5)

/* Network Configuration*/
#define DIC_SERVER_PORT 8883
/* Network Configuration */
#define DIC_SERVER_HOST ""
#define DIC_SERVER_PORT (8883)

#define DIC_KEEP_ALIVE 0
#define DIC_KEEP_ALIVE (0)

#if USE_AWS
#define DIC_CLIENT_ID "SQA_DIC_C2"
/* MQTT Client Configuration */
#define DIC_CLIENT_ID "sl_dic_client"
#define DIC_CLIENT_USER NULL
#define DIC_CLIENT_PASS NULL

#elif USE_MOSQUITTO

#define DIC_CLIENT_USER ""
#define DIC_CLIENT_PASS ""
#define MQTT_QOS_0 (0)
#define MQTT_SUBSCRIBE_TOPIC "command"

/* MQTT Client Certification Configuration */
#define DIC_CA_CERT_LENGTH (1212)
#define DIC_DEV_CERT_LENGTH (1212)
#define DIC_DEV_KEY_LENGTH (1212)
#define DIC_HOSTNAME_LENGTH (55)
#define DIC_CLIENTID_LENGTH (30)

#endif //USE_MOSQUITTO
#ifdef ENABLE_AWS_OTA_FEAT
#define AWS_OTA_TASK_STACK_SIZE (1024)
#define AWS_OTA_TASK_PRIORITY (1)
#endif // ENABLE_AWS_OTA_FEAT

#endif // __DIC_CONFIG_H
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @brief Matter abstraction layer for Direct Internet Connectivity.
*******************************************************************************
* # License
* <b>Copyright 2020 Silicon Laboratories Inc.
* <b>Copyright 2023 Silicon Laboratories Inc.
*www.silabs.com</b>
*******************************************************************************
*
Expand All @@ -22,27 +22,26 @@

#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/ids/Attributes.h>
#include <lib/support/CHIPMemString.h>
#include <zap-generated/gen_config.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <zap-generated/gen_config.h>

#define MQTT_SUBSCRIBE_TOPIC "command"
#include "dic_config.h"

using namespace chip;
using namespace ::chip::DeviceLayer;

namespace dic {
namespace control {
void dic_incoming_data_cb(void* arg, const char* topic, const uint8_t* data, uint16_t len, uint8_t flags);
namespace control {
void dic_incoming_data_cb(void * arg, const char * topic, const uint8_t * data, uint16_t len, uint8_t flags);

void SubscribeMQTT(intptr_t context);
void SubscribeMQTT(intptr_t context);

void subscribeCB(void);
void subscribeCB(void);

#ifdef ZCL_USING_THERMOSTAT_CLUSTER_SERVER
void AttributeHandler(EndpointId endpointId, AttributeId attributeId);
#endif //ZCL_USING_THERMOSTAT_CLUSTER_SERVER
#ifdef ZCL_USING_THERMOSTAT_CLUSTER_SERVER
void AttributeHandler(EndpointId endpointId, AttributeId attributeId);
#endif // ZCL_USING_THERMOSTAT_CLUSTER_SERVER

}
}
} // namespace control
} // namespace dic
#endif //__DIC_CONTROL_H
Loading

0 comments on commit 3f1e18d

Please sign in to comment.