Skip to content

Commit

Permalink
Update Infineon CYW30739 TE8 fixes. (#18733)
Browse files Browse the repository at this point in the history
* Update CYW30739 TE8 fixes.

* DoFactoryReset would clear the key-value storage.
* Enable OTA requestor for CYW30739 apps.
* Refine the flash layout for the OTA functions.
* Disable loggings for lighting and lock app.
* Reuse Matter heap APIs for CYW30739 OpenThread implementation.
* Enable MBEDTLS_CCM_ALT, MBEDTLS_AES_ALT, and MBEDTLS_SHA256_ALT.
* Group keys into factory keys and config keys.
* Fix CYW30739Config write methods.
* Correct the storage entry count for additional keys.
* Add and process OTA image header for CYW30739.
* Implement network-interfaces and reboot-count.
* Fix currentLevel value mismatch.
* Implement PICS_MANUAL_OCCUPANCY_CHANGE.
* Instantiate identify object for lighting app.
* Implement IsFirstImageRun and ConfirmCurrentImage methods of OTAImageProcessorImpl.
* Compress large "Data" entries in DS.
* Change CHIP_CONFIG_MAX_FABRICS to 5 from 4.
* Add a debug arg for CYW30739 SDK.
* Implement SupportedCalendarTypes and SupportedLocales.
* Implement Door lock cluster.

* Revert implementing SupportedCalendarTypes and SupportedLocales.

* Remove unneeded codes.

* Turn OTAConfig into a namespace.

* Use Platform::New Platform::Delete for NetworkInterface.

* Fix clang-tidy: readability-else-after-return

* Add license blurbs and improve readability for CYW30739 SDK scripts.

* Add CHIP license blurbs into CYW30739 SDK scripts.

* Remove unneeded returning value from the gen_image function.
  • Loading branch information
hsusid authored and pull[bot] committed Jun 23, 2023
1 parent 8444771 commit 1b55ed7
Show file tree
Hide file tree
Showing 56 changed files with 2,697 additions and 668 deletions.
5 changes: 2 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
[submodule "third_party/openthread/ot-ifx"]
path = third_party/openthread/ot-ifx
url = https://github.com/Infineon/ot-ifx-release.git
branch = cyw30739
platforms = cyw30739
[submodule "third_party/mbed-os/repo"]
path = third_party/mbed-os/repo
Expand Down Expand Up @@ -203,15 +202,15 @@
url = https://github.com/open-source-parsers/jsoncpp.git
[submodule "cyw30739_sdk/30739A0"]
path = third_party/cyw30739_sdk/repos/30739A0
url = https://github.com/Infineon/30739A0.git
url = https://github.com/Infineon/OT-Matter-30739A0.git
platforms = cyw30739
[submodule "cyw30739_sdk/include"]
path = third_party/cyw30739_sdk/repos/btsdk-include
url = https://github.com/Infineon/btsdk-include.git
platforms = cyw30739
[submodule "cyw30739_sdk/target"]
path = third_party/cyw30739_sdk/repos/CYW930739M2EVB-01
url = https://github.com/Infineon/TARGET_CYW930739M2EVB-01.git
url = https://github.com/Infineon/OT-Matter-TARGET_CYW930739M2EVB-01.git
platforms = cyw30739
[submodule "cyw30739_sdk/tools"]
path = third_party/cyw30739_sdk/repos/btsdk-tools
Expand Down
13 changes: 12 additions & 1 deletion examples/lighting-app/cyw30739/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import("${cyw30739_sdk_build_root}/cyw30739_executable.gni")
import("${cyw30739_sdk_build_root}/cyw30739_sdk.gni")

cyw30739_project_dir = "${chip_root}/examples/lighting-app/cyw30739"
examples_plat_dir = "${chip_root}/examples/platform/cyw30739"

declare_args() {
setupPinCode = 20202021
Expand All @@ -29,7 +30,10 @@ declare_args() {
cyw30739_sdk("sdk") {
sources = [ "${cyw30739_project_dir}/include/CHIPProjectConfig.h" ]

include_dirs = [ "${cyw30739_project_dir}/include" ]
include_dirs = [
"${cyw30739_project_dir}/include",
"${examples_plat_dir}",
]

defines = [
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
Expand All @@ -56,6 +60,13 @@ cyw30739_executable("lighting_app") {
]

include_dirs = [ "include" ]

if (chip_enable_ota_requestor) {
sources += [
"${examples_plat_dir}/OTAConfig.cpp",
"${examples_plat_dir}/OTAConfig.h",
]
}
}

group("cyw30739") {
Expand Down
7 changes: 7 additions & 0 deletions examples/lighting-app/cyw30739/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,10 @@ import("${chip_root}/src/platform/CYW30739/args.gni")
cyw30739_sdk_target = get_label_info(":sdk", "label_no_toolchain")

chip_openthread_ftd = true

chip_enable_ota_requestor = true

chip_error_logging = false
chip_progress_logging = false
chip_detail_logging = false
chip_automation_logging = false
2 changes: 1 addition & 1 deletion examples/lighting-app/cyw30739/include/LightingManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ class LightingManager
typedef void (*Callback_fn_initiated)(Actor_t, Action_t, uint8_t);
typedef void (*Callback_fn_completed)(Action_t);
void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB);
void WriteClusterLevel(uint8_t value);

private:
void WriteClusterState(uint8_t value);
void WriteClusterLevel(uint8_t value);

friend LightingManager & LightMgr(void);
State_t mState;
Expand Down
15 changes: 13 additions & 2 deletions examples/lighting-app/cyw30739/src/ButtonHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@

#include <ButtonHandler.h>
#include <LightingManager.h>
#include <app-common/zap-generated/attributes/Accessors.h>
#include <platform/CHIPDeviceLayer.h>
#include <stdio.h>
#include <wiced.h>
#include <wiced_button_manager.h>
#include <wiced_platform.h>

using namespace chip::app::Clusters;

/******************************************************
* Macros
******************************************************/
Expand Down Expand Up @@ -56,7 +60,7 @@ wiced_result_t app_button_init(void)
memset(app_buttons, 0, (sizeof(button_manager_button_t) * APP_MAX_BUTTON_DEF));

app_button_configurations[ON_OFF_BUTTON].button = PLATFORM_BUTTON_1;
app_button_configurations[ON_OFF_BUTTON].button_event_mask = BUTTON_CLICK_EVENT;
app_button_configurations[ON_OFF_BUTTON].button_event_mask = BUTTON_CLICK_EVENT | BUTTON_HOLDING_EVENT;
app_buttons[ON_OFF_BUTTON].configuration = &app_button_configurations[ON_OFF_BUTTON];

result = wiced_button_manager_init(&app_button_manager, &app_button_manager_configuration, app_buttons, 1);
Expand All @@ -71,7 +75,7 @@ wiced_result_t app_button_init(void)
void app_button_event_handler(const button_manager_button_t * button_mgr, button_manager_event_t event,
button_manager_button_state_t state)
{

uint8_t attributeValue;
if (button_mgr[0].configuration->button == PLATFORM_BUTTON_1 && event == BUTTON_CLICK_EVENT && state == BUTTON_STATE_RELEASED)
{
if (LightMgr().IsLightOn())
Expand All @@ -85,4 +89,11 @@ void app_button_event_handler(const button_manager_button_t * button_mgr, button
LightMgr().InitiateAction(LightingManager::ACTOR_BUTTON, LightingManager::ON_ACTION, 0);
}
}
else if (button_mgr[0].configuration->button == PLATFORM_BUTTON_1 && event == BUTTON_HOLDING_EVENT)
{
// update the current occupancy here for hardcoded endpoint 1
OccupancySensing::Attributes::Occupancy::Get(1, &attributeValue);
printf("Button Holding Toggle: %d -> %d\n", attributeValue, !attributeValue);
OccupancySensing::Attributes::Occupancy::Set(1, !attributeValue);
}
}
4 changes: 4 additions & 0 deletions examples/lighting-app/cyw30739/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ void MatterPostAttributeChangeCallback(const app::ConcreteAttributePath & attrib
return;
}
break;
case Identify::Id:
ChipLogProgress(Zcl, "Identify attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u",
ChipLogValueMEI(attributePath.mClusterId), type, *value, size);
return;
default:
printf("Unhandled cluster ID: 0x%04lx\n", attributePath.mClusterId);
return;
Expand Down
19 changes: 18 additions & 1 deletion examples/lighting-app/cyw30739/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <platform/CHIPDeviceLayer.h>

#include <AppShellCommands.h>
#include <ButtonHandler.h>
#include <ChipShellCollection.h>
#include <LightingManager.h>
#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
#include <OTAConfig.h>
#endif
#include <app/clusters/identify-server/identify-server.h>
#include <app/server/Server.h>
#include <credentials/examples/DeviceAttestationCredsExample.h>
#include <lib/shell/Engine.h>
#include <lib/support/CHIPPlatformMemory.h>
#include <mbedtls/platform.h>
#include <platform/CHIPDeviceLayer.h>
#include <protocols/secure_channel/PASESession.h>
#include <sparcommon.h>
#include <stdio.h>
Expand All @@ -47,6 +52,13 @@ static wiced_led_config_t chip_lighting_led_config = {
.bright = 50,
};

static Identify gIdentify = {
chip::EndpointId{ 1 },
[](Identify *) { ChipLogProgress(Zcl, "onIdentifyStart"); },
[](Identify *) { ChipLogProgress(Zcl, "onIdentifyStop"); },
EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED,
};

APPLICATION_START()
{
CHIP_ERROR err;
Expand Down Expand Up @@ -144,6 +156,11 @@ void InitApp(intptr_t args)

LightMgr().Init();
LightMgr().SetCallbacks(LightManagerCallback, NULL);
LightMgr().WriteClusterLevel(254);

#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
OTAConfig::Init();
#endif
}

void EventHandler(const ChipDeviceEvent * event, intptr_t arg)
Expand Down
16 changes: 13 additions & 3 deletions examples/lock-app/cyw30739/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import("${cyw30739_sdk_build_root}/cyw30739_executable.gni")
import("${cyw30739_sdk_build_root}/cyw30739_sdk.gni")

cyw30739_project_dir = "${chip_root}/examples/lock-app/cyw30739"
examples_plat_dir = "${chip_root}/examples/platform/cyw30739"

declare_args() {
setupPinCode = 20202021
Expand All @@ -29,7 +30,10 @@ declare_args() {
cyw30739_sdk("sdk") {
sources = [ "${cyw30739_project_dir}/include/CHIPProjectConfig.h" ]

include_dirs = [ "${cyw30739_project_dir}/include" ]
include_dirs = [
"${cyw30739_project_dir}/include",
"${examples_plat_dir}",
]

defines = [
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
Expand All @@ -42,8 +46,8 @@ cyw30739_executable("lock_app") {

sources = [
"src/AppShellCommands.cpp",
"src/BoltLockManager.cpp",
"src/ButtonHandler.cpp",
"src/LockManager.cpp",
"src/ZclCallbacks.cpp",
"src/main.cpp",
]
Expand All @@ -53,10 +57,16 @@ cyw30739_executable("lock_app") {
"${chip_root}/examples/lock-app/lock-common",
"${chip_root}/examples/shell/shell_common:shell_common",
"${chip_root}/src/lib",
"${chip_root}/third_party/openthread/repo:libopenthread-ftd",
]

include_dirs = [ "include" ]

if (chip_enable_ota_requestor) {
sources += [
"${examples_plat_dir}/OTAConfig.cpp",
"${examples_plat_dir}/OTAConfig.h",
]
}
}

group("cyw30739") {
Expand Down
9 changes: 9 additions & 0 deletions examples/lock-app/cyw30739/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,12 @@ import("//build_overrides/chip.gni")
import("${chip_root}/src/platform/CYW30739/args.gni")

cyw30739_sdk_target = get_label_info(":sdk", "label_no_toolchain")

chip_openthread_ftd = true

chip_enable_ota_requestor = true

chip_error_logging = false
chip_progress_logging = false
chip_detail_logging = false
chip_automation_logging = false
52 changes: 52 additions & 0 deletions examples/lock-app/cyw30739/include/AppEvent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
*
* Copyright (c) 2020 Project CHIP Authors
* Copyright (c) 2018 Nest Labs, Inc.
* 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 <stdint.h>

struct AppEvent
{
enum AppEventTypes
{
kEventType_Button = 0,
kEventType_Timer,
kEventType_Lock,
kEventType_Install,
};

uint16_t Type;

union
{
struct
{
uint8_t Action;
} ButtonEvent;
struct
{
void * Context;
} TimerEvent;
struct
{
uint8_t Action;
int32_t Actor;
} LockEvent;
};
};
86 changes: 0 additions & 86 deletions examples/lock-app/cyw30739/include/BoltLockManager.h

This file was deleted.

Loading

0 comments on commit 1b55ed7

Please sign in to comment.