Skip to content

Commit

Permalink
Merge pull request #6 from RafaelMicro/fix-issues
Browse files Browse the repository at this point in the history
fix multiple issues
  • Loading branch information
shih840426 authored Jan 3, 2024
2 parents 422fb6e + edc4c21 commit ab5bd58
Show file tree
Hide file tree
Showing 29 changed files with 153 additions and 203 deletions.
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@
"condition_variable": "cpp",
"numeric": "cpp",
"random": "cpp",
"thread": "cpp"
"thread": "cpp",
"util_log.h": "c"
},
// Configure paths or glob patterns to exclude from file watching.
"files.watcherExclude": {
Expand All @@ -125,7 +126,7 @@
"**/third_party/**": true
},
"files.eol": "\n",
"editor.formatOnSave": true,
"editor.formatOnSave": false,
"better-comments.tags": [
{
"tag": "!",
Expand Down
4 changes: 0 additions & 4 deletions examples/light-switch-app/rt58x/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ assert(!(chip_enable_wifi && chip_enable_openthread))

rt58x_sdk("sdk") {
sources = [
"${examples_plat_dir}/config/FreeRTOSConfig.h",
"${rt58x_project_dir}/include/CHIPProjectConfig.h",
]

Expand All @@ -90,9 +89,6 @@ rt58x_sdk("sdk") {
if (chip_build_platform_attestation_credentials_provider) {
defines += [ "RAFAEL_CERTS_ENABLED=1" ]
}
if (chip_build_libshell) {
defines += [ "CONFIG_ENABLE_CHIP_SHELL=1" ]
}
if (chip_enable_pw_rpc) {
defines += [
"HAL_VCOM_ENABLE=1",
Expand Down
2 changes: 1 addition & 1 deletion examples/light-switch-app/rt58x/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import("${chip_root}/src/platform/RT58x/args.gni")
rt58x_sdk_target = get_label_info(":sdk", "label_no_toolchain")

chip_enable_ota_requestor = false
chip_build_libshell = true
chip_build_libshell = false
chip_build_platform_attestation_credentials_provider = false

pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
Expand Down
27 changes: 27 additions & 0 deletions examples/light-switch-app/rt58x/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "AppTask.h"
#include "AppConfig.h"
#include "AppEvent.h"
#include <OTAConfig.h>

#include <app/clusters/identify-server/identify-server.h>
#include <app/util/attribute-storage.h>
Expand Down Expand Up @@ -55,6 +56,7 @@
#include "bsp.h"
#include "bsp_button.h"
#include "matter_config.h"
#include "fota_define.h"

using namespace chip;
using namespace ::chip::app;
Expand Down Expand Up @@ -166,6 +168,27 @@ void UnlockOpenThreadTask(void)
{
chip::DeviceLayer::ThreadStackMgr().UnlockThreadStack();
}
void MatterFotaInit(void)
{
fota_information_t *p_fota_info = (fota_information_t *)(FOTA_UPDATE_BANK_INFO_ADDRESS);

if (p_fota_info->fotabank_ready == FOTA_IMAGE_READY)
{
if (p_fota_info->fota_result == FOTA_RESULT_SUCCESS)
{
// err("sw ver: %d\r\n", p_fota_info->reserved[0]);
chip::DeviceLayer::ConfigurationMgr().StoreSoftwareVersion(p_fota_info->reserved[0]);
}
else
{
err("fota result: %d\r\n", p_fota_info->fota_result);
}
while (flash_check_busy());
taskENTER_CRITICAL();
flash_erase(FLASH_ERASE_SECTOR, FOTA_UPDATE_BANK_INFO_ADDRESS);
taskEXIT_CRITICAL();
}
}
void AppTask::OpenCommissioning(intptr_t arg)
{
// Enable BLE advertisements
Expand Down Expand Up @@ -284,10 +307,14 @@ void AppTask::InitServer(intptr_t arg)
{
ChipLogError(NotSpecified, "LightSwitchMgr Init failed!");
}
#if RT58x_OTA_ENABLED
OTAConfig::Init();
#endif
}

CHIP_ERROR AppTask::Init()
{
MatterFotaInit();
CHIP_ERROR err;
// ChipLogProgress(NotSpecified, "Current Software Version: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING);

Expand Down
2 changes: 1 addition & 1 deletion examples/light-switch-app/rt58x/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#include <lib/core/CHIPError.h>

#if CONFIG_ENABLE_CHIP_SHELL
#if ENABLE_CHIP_SHELL
#include "matter_shell.h"
#endif

Expand Down
5 changes: 0 additions & 5 deletions examples/lighting-app/rt58x/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ declare_args() {

rt58x_sdk("sdk") {
sources = [
"${examples_plat_dir}/config/FreeRTOSConfig.h",
"${rt58x_project_dir}/include/CHIPProjectConfig.h",
]

Expand All @@ -63,10 +62,6 @@ rt58x_sdk("sdk") {
if (chip_build_platform_attestation_credentials_provider) {
defines += [ "RAFAEL_CERTS_ENABLED=1" ]
}

if (chip_build_libshell) {
defines += [ "CONFIG_ENABLE_CHIP_SHELL=1" ]
}
}

rt58x_executable("lighting_app") {
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/rt58x/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import("${chip_root}/src/platform/RT58x/args.gni")
rt58x_sdk_target = get_label_info(":sdk", "label_no_toolchain")

chip_enable_ota_requestor = false
chip_build_libshell = true
chip_build_libshell = false
chip_build_platform_attestation_credentials_provider = false

# rafael_board = "RT58x"
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/rt58x/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <mbedtls/aes.h>
#include <mbedtls/platform.h>

#if CONFIG_ENABLE_CHIP_SHELL
#if ENABLE_CHIP_SHELL
#include "matter_shell.h"
#endif

Expand Down
4 changes: 0 additions & 4 deletions examples/lock-app/rt58x/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ assert(!(chip_enable_wifi && chip_enable_openthread))

rt58x_sdk("sdk") {
sources = [
"${examples_plat_dir}/config/FreeRTOSConfig.h",
"${rt58x_project_dir}/include/CHIPProjectConfig.h",
]

Expand All @@ -90,9 +89,6 @@ rt58x_sdk("sdk") {
if (chip_build_platform_attestation_credentials_provider) {
defines += [ "RAFAEL_CERTS_ENABLED=1" ]
}
if (chip_build_libshell) {
defines += [ "CONFIG_ENABLE_CHIP_SHELL=1" ]
}
if (chip_enable_pw_rpc) {
defines += [
"HAL_VCOM_ENABLE=1",
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/rt58x/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import("${chip_root}/src/platform/RT58x/args.gni")
rt58x_sdk_target = get_label_info(":sdk", "label_no_toolchain")

chip_enable_ota_requestor = false
chip_build_libshell = true
chip_build_libshell = false
chip_build_platform_attestation_credentials_provider = false

pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
Expand Down
27 changes: 27 additions & 0 deletions examples/lock-app/rt58x/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "AppTask.h"
#include "AppConfig.h"
#include "AppEvent.h"
#include <OTAConfig.h>

#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/cluster-objects.h>
Expand Down Expand Up @@ -56,6 +57,7 @@
#include "bsp_button.h"
#include "bsp_led.h"
#include "matter_config.h"
#include "fota_define.h"


using namespace chip;
Expand Down Expand Up @@ -167,6 +169,27 @@ void UnlockOpenThreadTask(void)
{
chip::DeviceLayer::ThreadStackMgr().UnlockThreadStack();
}
void MatterFotaInit(void)
{
fota_information_t *p_fota_info = (fota_information_t *)(FOTA_UPDATE_BANK_INFO_ADDRESS);

if (p_fota_info->fotabank_ready == FOTA_IMAGE_READY)
{
if (p_fota_info->fota_result == FOTA_RESULT_SUCCESS)
{
// err("sw ver: %d\r\n", p_fota_info->reserved[0]);
chip::DeviceLayer::ConfigurationMgr().StoreSoftwareVersion(p_fota_info->reserved[0]);
}
else
{
err("fota result: %d\r\n", p_fota_info->fota_result);
}
while (flash_check_busy());
taskENTER_CRITICAL();
flash_erase(FLASH_ERASE_SECTOR, FOTA_UPDATE_BANK_INFO_ADDRESS);
taskEXIT_CRITICAL();
}
}
void AppTask::OpenCommissioning(intptr_t arg)
{
// Enable BLE advertisements
Expand Down Expand Up @@ -299,6 +322,9 @@ void AppTask::InitServer(intptr_t arg)
BoltLockMgr().SetCallbacks(ActionInitiated, ActionCompleted);

PlatformMgr().ScheduleWork(UpdateClusterState, 0);
#if RT58x_OTA_ENABLED
OTAConfig::Init();
#endif
}

void AppTask::UpdateStatusLED()
Expand Down Expand Up @@ -358,6 +384,7 @@ void AppTask::ChipEventHandler(const ChipDeviceEvent * aEvent, intptr_t /* arg *

CHIP_ERROR AppTask::Init()
{
MatterFotaInit();
CHIP_ERROR err;
ChipLogProgress(NotSpecified, "Current Software Version: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING);

Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/rt58x/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#include <lib/core/CHIPError.h>

#if CONFIG_ENABLE_CHIP_SHELL
#if ENABLE_CHIP_SHELL
#include "matter_shell.h"
#endif

Expand Down
4 changes: 4 additions & 0 deletions examples/platform/rt58x/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ extern uint32_t SystemCoreClock;
#define configUSE_PREEMPTION (1)
#define configUSE_TIME_SLICING (0)
#define configUSE_PORT_OPTIMISED_TASK_SELECTION (0)
#if(CHIP_CONFIG_ENABLE_ICD_SERVER)
#define configUSE_TICKLESS_IDLE (1)
#else
#define configUSE_TICKLESS_IDLE (0)
#endif

#define configMAX_PRIORITIES (56)
#define configMINIMAL_STACK_SIZE (128) /* Number of words to use for Idle and Timer stacks */
Expand Down
Loading

0 comments on commit ab5bd58

Please sign in to comment.