Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into bridge-and-provisioni…
Browse files Browse the repository at this point in the history
…ng-update
  • Loading branch information
SirRu24 committed Jun 28, 2024
2 parents 22f0ef1 + 61306c6 commit dd4f1ac
Show file tree
Hide file tree
Showing 56 changed files with 492 additions and 288 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <sys_api.h>
#include "log_service.h"
#include "wifi_conf.h"
extern u32 deinitPref(void);
#if MATTER_OTA_REQUESTOR_APP
extern void amebaQueryImageCmdHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@

#undef configTOTAL_HEAP_SIZE
#undef CONFIG_DYNAMIC_HEAP_SIZE
#undef INCLUDE_uxTaskGetStackSize
#undef INCLUDE_uxTaskGetFreeStackSize

#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 200 * 1024 ) ) //default
#define CONFIG_DYNAMIC_HEAP_SIZE 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
#define CONFIG_EXAMPLE_MATTER_CHIPTEST 1
#define CONFIG_EXAMPLE_MATTER_LIGHT 0
#define CONFIG_EXAMPLE_MATTER_THERMOSTAT 0
#define CONFIG_EXAMPLE_MATTER_BRIDGE 0
#define CONFIG_EXAMPLE_MATTER_AIRCON 0
#define CONFIG_EXAMPLE_MATTER_DISHWASHER 0
#define CONFIG_EXAMPLE_MATTER_LAUNDRY_WASHER 0
#define CONFIG_EXAMPLE_MATTER_REFRIGERATOR 0

Expand Down
20 changes: 11 additions & 9 deletions component/common/application/matter/common/port/matter_dcts.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ bool checkExist(const char *domain, const char *key)
}

len = VARIABLE_VALUE_SIZE2;
ret = dct_get_variable_new2(&handle, key, str, &len);
ret = dct_get_variable_new2(&handle, key, (char *)str, &len);
if(ret == DCT_SUCCESS)
{
printf("checkExist key=%s found.\n", key);
Expand Down Expand Up @@ -604,6 +604,7 @@ s32 getPref_str_new(const char *domain, const char *key, char * buf, size_t bufS
dct_handle_t handle;
s32 ret;
char ns[15];
uint16_t *len = (uint16_t *)(&bufSize);

// Loop over DCT1 modules
for (size_t i=0; i<MODULE_NUM; i++)
Expand All @@ -616,9 +617,9 @@ s32 getPref_str_new(const char *domain, const char *key, char * buf, size_t bufS
goto exit;
}
#if CONFIG_ENABLE_DCT_ENCRYPTION
ret = dct_get_encrypted_variable(&handle, key, buf, &bufSize, DCT_REGION_1);
ret = dct_get_encrypted_variable(&handle, key, buf, len, DCT_REGION_1);
#else
ret = dct_get_variable_new(&handle, key, buf, &bufSize);
ret = dct_get_variable_new(&handle, key, buf, len);
#endif
dct_close_module(&handle);
if (ret == DCT_SUCCESS)
Expand All @@ -639,9 +640,9 @@ s32 getPref_str_new(const char *domain, const char *key, char * buf, size_t bufS
goto exit;
}
#if CONFIG_ENABLE_DCT_ENCRYPTION
ret = dct_get_encrypted_variable(&handle, key, buf, &bufSize, DCT_REGION_2);
ret = dct_get_encrypted_variable(&handle, key, buf, len, DCT_REGION_2);
#else
ret = dct_get_variable_new2(&handle, key, buf, &bufSize);
ret = dct_get_variable_new2(&handle, key, buf, len);
#endif
dct_close_module2(&handle);
if (ret == DCT_SUCCESS)
Expand All @@ -660,6 +661,7 @@ s32 getPref_bin_new(const char *domain, const char *key, u8 * buf, size_t bufSiz
dct_handle_t handle;
s32 ret;
char ns[15];
uint16_t *len = (uint16_t *)(&bufSize);

// Loop over DCT1 modules
for (size_t i=0; i<MODULE_NUM; i++)
Expand All @@ -672,9 +674,9 @@ s32 getPref_bin_new(const char *domain, const char *key, u8 * buf, size_t bufSiz
goto exit;
}
#if CONFIG_ENABLE_DCT_ENCRYPTION
ret = dct_get_encrypted_variable(&handle, key, (char *)buf, &bufSize, DCT_REGION_1);
ret = dct_get_encrypted_variable(&handle, key, (char *)buf, len, DCT_REGION_1);
#else
ret = dct_get_variable_new(&handle, key, (char *)buf, &bufSize);
ret = dct_get_variable_new(&handle, key, (char *)buf, len);
#endif
dct_close_module(&handle);
if (ret == DCT_SUCCESS)
Expand All @@ -695,9 +697,9 @@ s32 getPref_bin_new(const char *domain, const char *key, u8 * buf, size_t bufSiz
goto exit;
}
#if CONFIG_ENABLE_DCT_ENCRYPTION
ret = dct_get_encrypted_variable(&handle, key, (char *)buf, &bufSize, DCT_REGION_2);
ret = dct_get_encrypted_variable(&handle, key, (char *)buf, len, DCT_REGION_2);
#else
ret = dct_get_variable_new2(&handle, key, (char *)buf, &bufSize);
ret = dct_get_variable_new2(&handle, key, (char *)buf, len);
#endif
dct_close_module2(&handle);
if (ret == DCT_SUCCESS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "stddef.h"
#include "string.h"
#include "errno.h"
#include "sntp/sntp.h"
#include "FreeRTOS.h"
#include "chip_porting.h"
#include "time.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ int32_t ReadFactory(uint8_t *buffer, uint16_t *pfactorydata_len)

// The first 2 bytes of the binary file is the length of the FactoryData
device_mutex_lock(RT_DEV_LOCK_FLASH);
ret = flash_stream_read(&flash, address, length_bytes, pfactorydata_len);
ret = flash_stream_read(&flash, address, length_bytes, (uint8_t *)pfactorydata_len);
device_mutex_unlock(RT_DEV_LOCK_FLASH);

// Check if factory data length is more than 4096
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "wifi_conf.h"
#include "chip_porting.h"
#include "osdep_service.h"
#include "lwip/dhcp.h"

u32 apNum = 0; // no of total AP scanned
u8 matter_wifi_trigger = 0;
Expand Down Expand Up @@ -273,6 +274,12 @@ static void matter_wifi_autoreconnect_thread(void *param)
wext_set_support_wpa3(ENABLE);
#endif

if (ret == RTW_SUCCESS) {
RTW_API_INFO("WiFi connected successfully\n");
} else {
RTW_API_INFO("WiFi connection failed with error code %d\n", ret);
}

matter_param_indicator = NULL;
rtw_delete_task(&matter_wifi_autoreconnect_task);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ You may add clusters and attributes handling in `matter_driver_uplink_update_han
## How to build

### Configurations
Enable `CONFIG_EXAMPLE_MATTER` and `CONFIG_EXAMPLE_MATTER_LAUNDRYWASHER` in `platform_opts_matter.h`.
Enable `CONFIG_EXAMPLE_MATTER` and `CONFIG_EXAMPLE_MATTER_LAUNDRY_WASHER` in `platform_opts_matter.h`.
Ensure that `CONFIG_EXAMPLE_MATTER_CHIPTEST` is disabled.

### Setup the Build Environment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "matter_drivers.h"
#include "matter_interaction.h"

#if defined(CONFIG_EXAMPLE_MATTER_LAUNDRYWASHER) && CONFIG_EXAMPLE_MATTER_LAUNDRYWASHER
#if defined(CONFIG_EXAMPLE_MATTER_LAUNDRY_WASHER) && CONFIG_EXAMPLE_MATTER_LAUNDRY_WASHER

static void example_matter_laundrywasher_task(void *pvParameters)
{
Expand Down Expand Up @@ -54,4 +54,4 @@ extern "C" void example_matter_laundrywasher(void)
ChipLogProgress(DeviceLayer, "\n\r%s xTaskCreate(example_matter_laundrywasher) failed", __FUNCTION__);
}

#endif /* CONFIG_EXAMPLE_MATTER_LAUNDRY_WASHER */
#endif /* CONFIG_EXAMPLE_MATTER_LAUNDRY_WASHER */
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef EXAMPLE_MATTER_LAUNDRYWASHER_H
#define EXAMPLE_MATTER_LAUNDRYWASHER_H
#ifndef EXAMPLE_MATTER_LAUNDRY_WASHER_H
#define EXAMPLE_MATTER_LAUNDRY_WASHER_H

void example_matter_laundrywasher_task(void);

#endif /* EXAMPLE_MATTER_LAUNDRYWASHER_H */
#endif /* EXAMPLE_MATTER_LAUNDRY_WASHER_H */
54 changes: 54 additions & 0 deletions component/common/application/matter/example/matter_example_entry.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

/******************************************************************************
*
* Copyright(c) 2007 - 2015 Realtek Corporation. All rights reserved.
*
*
******************************************************************************/
#include <platform_opts.h>

#if defined(CONFIG_EXAMPLE_MATTER) && (CONFIG_EXAMPLE_MATTER == 1)

#if defined(CONFIG_EXAMPLE_MATTER_CHIPTEST) && (CONFIG_EXAMPLE_MATTER_CHIPTEST == 1)
#include <chiptest/example_matter.h>
#elif defined(CONFIG_EXAMPLE_MATTER_AIRCON) && (CONFIG_EXAMPLE_MATTER_AIRCON == 1)
#include <aircon/example_matter_aircon.h>
#elif defined(CONFIG_EXAMPLE_MATTER_BRIDGE) && (CONFIG_EXAMPLE_MATTER_BRIDGE == 1)
#include <bridge_dm/example_matter_bridge.h>
#elif defined(CONFIG_EXAMPLE_MATTER_DISHWASHER) && (CONFIG_EXAMPLE_MATTER_DISHWASHER == 1)
#include <dishwasher/example_matter_dishwasher.h>
#elif defined(CONFIG_EXAMPLE_MATTER_LAUNDRY_WASHER) && (CONFIG_EXAMPLE_MATTER_LAUNDRY_WASHER == 1)
#include <laundrywasher/example_matter_laundrywasher.h>
#elif defined(CONFIG_EXAMPLE_MATTER_LIGHT) && (CONFIG_EXAMPLE_MATTER_LIGHT == 1)
#include <light/example_matter_light.h>
#elif defined(CONFIG_EXAMPLE_MATTER_REFRIGERATOR) && (CONFIG_EXAMPLE_MATTER_REFRIGERATOR == 1)
#include <refrigerator/example_matter_refrigerator.h>
#elif defined(CONFIG_EXAMPLE_MATTER_THERMOSTAT) && (CONFIG_EXAMPLE_MATTER_THERMOSTAT == 1)
#include <thermostat/example_matter_thermostat.h>
#endif

/*
All of the examples are disabled by default for code size consideration
The configuration is enabled in platform_opts_matter.h
*/
void matter_example_entry(void)
{
#if defined(CONFIG_EXAMPLE_MATTER_CHIPTEST) && (CONFIG_EXAMPLE_MATTER_CHIPTEST == 1)
example_matter_task();
#elif defined(CONFIG_EXAMPLE_MATTER_AIRCON) && (CONFIG_EXAMPLE_MATTER_AIRCON == 1)
example_matter_aircon();
#elif defined(CONFIG_EXAMPLE_MATTER_BRIDGE) && (CONFIG_EXAMPLE_MATTER_BRIDGE == 1)
example_matter_bridge();
#elif defined(CONFIG_EXAMPLE_MATTER_DISHWASHER) && (CONFIG_EXAMPLE_MATTER_DISHWASHER == 1)
example_matter_dishwasher();
#elif defined(CONFIG_EXAMPLE_MATTER_LAUNDRY_WASHER) && (CONFIG_EXAMPLE_MATTER_LAUNDRY_WASHER == 1)
example_matter_laundrywasher();
#elif defined(CONFIG_EXAMPLE_MATTER_LIGHT) && (CONFIG_EXAMPLE_MATTER_LIGHT == 1)
example_matter_light();
#elif defined(CONFIG_EXAMPLE_MATTER_REFRIGERATOR) && (CONFIG_EXAMPLE_MATTER_REFRIGERATOR == 1)
example_matter_refrigerator();
#elif defined(CONFIG_EXAMPLE_MATTER_THERMOSTAT) && (CONFIG_EXAMPLE_MATTER_THERMOSTAT == 1)
example_matter_thermostat();
#endif
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef __MATTER_EXAMPLE_ENTRY_H__
#define __MATTER_EXAMPLE_ENTRY_H__

void matter_example_entry(void);

#endif //#ifndef __MATTER_EXAMPLE_ENTRY_H__
89 changes: 44 additions & 45 deletions component/common/application/matter/project/amebad/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
# Basic Configurations #
#*****************************************************************************#

CURRENT_DIR = $(shell pwd)
ABS_ROOTDIR = $(shell pwd)/../../../../../../project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk
MATTER_DIR = $(ABS_ROOTDIR)/../../../../../component/common/application/matter
ROOT_DIR = $(shell pwd)/../../../../..
ABS_ROOTDIR = $(ROOT_DIR)/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk
MAKE_INCLUDE_GEN = $(ABS_ROOTDIR)/Makefile.include.gen

MATTER_DIR = $(ROOT_DIR)/component/common/application/matter
MATTER_BUILDDIR = $(MATTER_DIR)/project/amebad

CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \
else echo sh; fi ; fi)

include $(MAKE_INCLUDE_GEN)
include $(CURRENT_DIR)/Makefile.include.matter.hp.gen

#*****************************************************************************#
# MATTER ZAP files #
#*****************************************************************************#
Expand Down Expand Up @@ -44,57 +43,57 @@ LAUNDRYWASHER_PORT_ZAP = $(BASEDIR)/component/common/application/matter/example/
#*****************************************************************************#
# MATTER MAKE DEFINES #
#*****************************************************************************#
all_clusters: $(ALL_CLUSTERS_FILE)
make -C make/chip/all_clusters_app all
make -C make/chip_main/all_clusters_app all
all_clusters: build_target_folder copy_ld_img2 check_toolchain build_info.h $(ALL_CLUSTERS_FILE)
make -C $(MATTER_BUILDDIR)/make/chip/all_clusters_app all
make -C $(MATTER_BUILDDIR)/make/chip_main/all_clusters_app all

aircon_port: $(AIRCON_PORT_FILE)
make -C make/chip/aircon_app all
make -C make/chip_main/aircon_port all
aircon_port: build_target_folder copy_ld_img2 check_toolchain build_info.h $(AIRCON_PORT_FILE)
make -C $(MATTER_BUILDDIR)/make/chip/aircon_app all
make -C $(MATTER_BUILDDIR)/make/chip_main/aircon_port all

air_purifier: $(AIR_PURIFIER_FILE)
make -C make/chip/air_purifier_app all
make -C make/chip_main/air_purifier_app all
air_purifier: build_target_folder copy_ld_img2 check_toolchain build_info.h $(AIR_PURIFIER_FILE)
make -C $(MATTER_BUILDDIR)/make/chip/air_purifier_app all
make -C $(MATTER_BUILDDIR)/make/chip_main/air_purifier_app all

bridge_port: $(BRIDGE_PORT_FILE)
make -C make/chip/bridge_app all
make -C make/chip_main/bridge_port all
bridge_port: build_target_folder copy_ld_img2 check_toolchain build_info.h $(BRIDGE_PORT_FILE)
make -C $(MATTER_BUILDDIR)/make/chip/bridge_app all
make -C $(MATTER_BUILDDIR)/make/chip_main/bridge_port all

bridge_dm: $(BRIDGE_DM_FILE) copy_gen_files_bridge_dm
make -C make/chip/bridge_app all
make -C make/chip_main/bridge_dm_app all
bridge_dm: build_target_folder copy_ld_img2 check_toolchain build_info.h $(BRIDGE_DM_FILE) copy_gen_files_bridge_dm
make -C $(MATTER_BUILDDIR)/make/chip/bridge_app all
make -C $(MATTER_BUILDDIR)/make/chip_main/bridge_dm_app all

dishwasher_port: $(DISHWASHER_PORT_FILE)
make -C make/chip/dishwasher_app all
make -C make/chip_main/dishwasher_port all
dishwasher_port: build_target_folder copy_ld_img2 check_toolchain build_info.h $(DISHWASHER_PORT_FILE)
make -C $(MATTER_BUILDDIR)/make/chip/dishwasher_app all
make -C $(MATTER_BUILDDIR)/make/chip_main/dishwasher_port all

laundrywasher_port: $(LAUNDRYWASHER_PORT_FILE)
make -C make/chip/laundrywasher_app all
make -C make/chip_main/laundrywasher_port all
laundrywasher_port: build_target_folder copy_ld_img2 check_toolchain build_info.h $(LAUNDRYWASHER_PORT_FILE)
make -C $(MATTER_BUILDDIR)/make/chip/laundrywasher_app all
make -C $(MATTER_BUILDDIR)/make/chip_main/laundrywasher_port all

light: $(LIGHTING_FILE)
make -C make/chip/lighting_app all
make -C make/chip_main/lighting_app all
light: build_target_folder copy_ld_img2 check_toolchain build_info.h $(LIGHTING_FILE)
make -C $(MATTER_BUILDDIR)/make/chip/lighting_app all
make -C $(MATTER_BUILDDIR)/make/chip_main/lighting_app all

light_port: $(LIGHTING_FILE)
make -C make/chip/lighting_app all
make -C make/chip_main/lighting_port all
light_port: build_target_folder copy_ld_img2 check_toolchain build_info.h $(LIGHTING_FILE)
make -C $(MATTER_BUILDDIR)/make/chip/lighting_app all
make -C $(MATTER_BUILDDIR)/make/chip_main/lighting_port all

light_dm: $(LIGHTING_FILE) copy_gen_files_light_dm
make -C make/chip/lighting_app all
make -C make/chip_main/lighting_dm_app all
light_dm: build_target_folder copy_ld_img2 check_toolchain build_info.h $(LIGHTING_FILE) copy_gen_files_light_dm
make -C $(MATTER_BUILDDIR)/make/chip/lighting_app all
make -C $(MATTER_BUILDDIR)/make/chip_main/lighting_dm_app all

light_switch: $(LIGHT_SWITCH_FILE)
make -C make/chip/light_switch_app all
make -C make/chip_main/light_switch_app all
light_switch: build_target_folder copy_ld_img2 check_toolchain build_info.h $(LIGHT_SWITCH_FILE)
make -C $(MATTER_BUILDDIR)/make/chip/light_switch_app all
make -C $(MATTER_BUILDDIR)/make/chip_main/light_switch_app all

refrigerator_port: $(REFRIGERATOR_PORT_FILE)
make -C make/chip/refrigerator_app all
make -C make/chip_main/refrigerator_port all
refrigerator_port: build_target_folder copy_ld_img2 check_toolchain build_info.h $(REFRIGERATOR_PORT_FILE)
make -C $(MATTER_BUILDDIR)/make/chip/refrigerator_app all
make -C $(MATTER_BUILDDIR)/make/chip_main/refrigerator_port all

thermostat_port: $(THERMOSTAT_PORT_FILE)
make -C make/chip/thermostat_app all
make -C make/chip_main/thermostat_port all
thermostat_port: build_target_folder copy_ld_img2 check_toolchain build_info.h $(THERMOSTAT_PORT_FILE)
make -C $(MATTER_BUILDDIR)/make/chip/thermostat_app all
make -C $(MATTER_BUILDDIR)/make/chip_main/thermostat_port all

#*****************************************************************************#
# RULES TO MAKE MATTER DIRS #
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CHIPDIR = $(BASEDIR)/third_party/connectedhomeip
MATTER_TOOLDIR = $(BASEDIR)/tools/matter
MATTER_DIR = $(BASEDIR)/component/common/application/matter
MATTER_EXAMPLEDIR = $(BASEDIR)/component/common/application/matter/example
MBEDTLSDIR = $(BASEDIR)/component/common/network/ssl/mbedtls-2.28.1

ifeq ($(COMPILEOS),$(LINUX_OS))
Expand All @@ -23,10 +24,12 @@ IFLAGS += -I$(BASEDIR)/component/common/application/matter/common/
IFLAGS += -I$(BASEDIR)/component/common/application/matter/common/port
IFLAGS += -I$(BASEDIR)/component/common/application/matter/common/protobuf
IFLAGS += -I$(BASEDIR)/component/common/application/matter/common/protobuf/nanopb
IFLAGS += -I$(BASEDIR)/component/common/application/matter/example

IFLAGS += -I$(MBEDTLSDIR)/include
IFLAGS += -I$(MBEDTLSDIR)/include/mbedtls
IFLAGS += -I$(MBEDTLSDIR)/library

IFLAGS += -I$(CHIPDIR)/config/ameba
IFLAGS += -I$(BASEDIR)/component/common/application/matter/common/mbedtls

Expand Down
Loading

0 comments on commit dd4f1ac

Please sign in to comment.