Skip to content

Commit

Permalink
Merge branch 'master' into contact-sensor-app/linux
Browse files Browse the repository at this point in the history
  • Loading branch information
lboue authored May 23, 2024
2 parents 8e7f35a + 174f2a0 commit 9346ac0
Show file tree
Hide file tree
Showing 28 changed files with 871 additions and 31 deletions.
24 changes: 24 additions & 0 deletions examples/light-switch-app/infineon/cyw30739/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ An example showing the use of Matter on the Infineon CYW30739 platform.
- [Commissionable Data](#commissionable-data)
- [Device Information](#device-information)
- [DAC / DAC Key / PAI Certificate / Certificate Declaration](#dac--dac-key--pai-certificate--certificate-declaration)
- [Use Provisioned Optiga Trust M](#use-provisioned-optiga-trust-m)
- [Flashing the Application](#flashing-the-application)
- [Enter Recovery Mode](#enter-recovery-mode)
- [Run Flash Script](#run-flash-script)
Expand Down Expand Up @@ -163,6 +164,29 @@ keys, and CD by the following arguments:
'matter_cd="/path/to/cd.der"'
```

### Use Provisioned Optiga Trust M

For boards supported by Optiga Trust M, CYW30739 will provision factory data to
the Optiga Trust M by default for easy development.

The Optiga Trust M on a production board should come with provisioned factory
data. To ensure its optimal use, please configure the Optiga using the following
arguments:

- `use_provisioned_optiga`, `optiga_dac_object_id`,
`optiga_dac_key_object_id`, `optiga_pai_cert_object_id`

```bash
$ cd ~/connectedhomeip
$ scripts/examples/gn_build_example.sh examples/light-switch-app/infineon/cyw30739 out/cyw30739-light-switch \
'optiga_dac_object_id="0xe0e0"' \
'optiga_dac_key_object_id="0xe0f0"' \
'optiga_pai_cert_object_id="0xe0e8"'
```

The developer must set the object IDs to corresponding values matching the
configurations used in the Optiga provisioning procedure.

## Flashing the Application

### Enter Recovery Mode
Expand Down
24 changes: 24 additions & 0 deletions examples/lighting-app/infineon/cyw30739/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ An example showing the use of Matter on the Infineon CYW30739 platform.
- [Commissionable Data](#commissionable-data)
- [Device Information](#device-information)
- [DAC / DAC Key / PAI Certificate / Certificate Declaration](#dac--dac-key--pai-certificate--certificate-declaration)
- [Use Provisioned Optiga Trust M](#use-provisioned-optiga-trust-m)
- [Flashing the Application](#flashing-the-application)
- [Enter Recovery Mode](#enter-recovery-mode)
- [Run Flash Script](#run-flash-script)
Expand Down Expand Up @@ -163,6 +164,29 @@ keys, and CD by the following arguments:
'matter_cd="/path/to/cd.der"'
```

### Use Provisioned Optiga Trust M

For boards supported by Optiga Trust M, CYW30739 will provision factory data to
the Optiga Trust M by default for easy development.

The Optiga Trust M on a production board should come with provisioned factory
data. To ensure its optimal use, please configure the Optiga using the following
arguments:

- `use_provisioned_optiga`, `optiga_dac_object_id`,
`optiga_dac_key_object_id`, `optiga_pai_cert_object_id`

```bash
$ cd ~/connectedhomeip
$ scripts/examples/gn_build_example.sh examples/lighting-app/infineon/cyw30739 out/cyw30739-light \
'optiga_dac_object_id="0xe0e0"' \
'optiga_dac_key_object_id="0xe0f0"' \
'optiga_pai_cert_object_id="0xe0e8"'
```

The developer must set the object IDs to corresponding values matching the
configurations used in the Optiga provisioning procedure.

## Flashing the Application

### Enter Recovery Mode
Expand Down
24 changes: 24 additions & 0 deletions examples/lock-app/infineon/cyw30739/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ An example showing the use of Matter on the Infineon CYW30739 platform.
- [Commissionable Data](#commissionable-data)
- [Device Information](#device-information)
- [DAC / DAC Key / PAI Certificate / Certificate Declaration](#dac--dac-key--pai-certificate--certificate-declaration)
- [Use Provisioned Optiga Trust M](#use-provisioned-optiga-trust-m)
- [Flashing the Application](#flashing-the-application)
- [Enter Recovery Mode](#enter-recovery-mode)
- [Run Flash Script](#run-flash-script)
Expand Down Expand Up @@ -163,6 +164,29 @@ keys, and CD by the following arguments:
'matter_cd="/path/to/cd.der"'
```

### Use Provisioned Optiga Trust M

For boards supported by Optiga Trust M, CYW30739 will provision factory data to
the Optiga Trust M by default for easy development.

The Optiga Trust M on a production board should come with provisioned factory
data. To ensure its optimal use, please configure the Optiga using the following
arguments:

- `use_provisioned_optiga`, `optiga_dac_object_id`,
`optiga_dac_key_object_id`, `optiga_pai_cert_object_id`

```bash
$ cd ~/connectedhomeip
$ scripts/examples/gn_build_example.sh examples/lock-app/infineon/cyw30739 out/cyw30739-lock \
'optiga_dac_object_id="0xe0e0"' \
'optiga_dac_key_object_id="0xe0f0"' \
'optiga_pai_cert_object_id="0xe0e8"'
```

The developer must set the object IDs to corresponding values matching the
configurations used in the Optiga provisioning procedure.

## Flashing the Application

### Enter Recovery Mode
Expand Down
2 changes: 2 additions & 0 deletions examples/platform/infineon/cyw30739/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import("${cyw30739_sdk_build_root}/cyw30739_sdk.gni")

static_library("platform") {
sources = [
"EventManagementTestEventTriggerHandler.h",
"LEDWidget.h",
"OTAConfig.h",
"SoftwareDiagnostics.h",
"main.cpp",
]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
*
* Copyright (c) 2024 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.
*/

#include "EventManagementTestEventTriggerHandler.h"

#include "SoftwareDiagnostics.h"

namespace chip {
namespace DeviceLayer {
namespace Infineon {
namespace CYW30739 {

CHIP_ERROR EventManagementTestEventTriggerHandler::HandleEventTrigger(uint64_t eventTrigger)
{
switch (eventTrigger)
{
case kFillUpEventLoggingBuffer:
return HandleFillUpEventLoggingBufferEventTriger();
default:
return CHIP_ERROR_INVALID_ARGUMENT;
}
}

void EventManagementTestEventTriggerHandler::TriggerSoftwareFaultEvent(const char * faultRecordString)
{
OnSoftwareFaultEventHandler(faultRecordString);
}

} // namespace CYW30739
} // namespace Infineon
} // namespace DeviceLayer
} // namespace chip
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
*
* Copyright (c) 2024 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 <app/GenericEventManagementTestEventTriggerHandler.h>

namespace chip {
namespace DeviceLayer {
namespace Infineon {
namespace CYW30739 {

class EventManagementTestEventTriggerHandler : public app::GenericEventManagementTestEventTriggerHandler
{
public:
static constexpr uint64_t kFillUpEventLoggingBuffer = 0xffff'ffff'1388'0000;

CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override;

private:
virtual void TriggerSoftwareFaultEvent(const char * faultRecordString) override;
};

} // namespace CYW30739
} // namespace Infineon
} // namespace DeviceLayer
} // namespace chip
62 changes: 62 additions & 0 deletions examples/platform/infineon/cyw30739/SoftwareDiagnostics.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
*
* Copyright (c) 2024 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.
*/

#include "SoftwareDiagnostics.h"

#include <app/clusters/software-diagnostics-server/software-diagnostics-server.h>
#include <app/util/config.h>
#include <platform/CHIPDeviceLayer.h>

namespace chip {
namespace DeviceLayer {
namespace Infineon {
namespace CYW30739 {

using namespace chip::app::Clusters;

void OnSoftwareFaultEventHandler(const char * faultRecordString)
{
#ifdef MATTER_DM_PLUGIN_SOFTWARE_DIAGNOSTICS_SERVER
SoftwareDiagnostics::Events::SoftwareFault::Type softwareFault;

/* Unable to access thread ID in the application layer. */
softwareFault.id = 0;

if (DeviceLayer::PlatformMgrImpl().IsCurrentTask())
{
softwareFault.name.SetValue("Matter"_span);
}
else if (DeviceLayer::ThreadStackMgrImpl().IsCurrentTask())
{
softwareFault.name.SetValue("Thread"_span);
}
else
{
softwareFault.name.SetValue("App"_span);
}

softwareFault.faultRecording.SetValue(ByteSpan(Uint8::from_const_char(faultRecordString), strlen(faultRecordString)));

SoftwareDiagnosticsServer::Instance().OnSoftwareFaultDetect(softwareFault);
#endif // MATTER_DM_PLUGIN_SOFTWARE_DIAGNOSTICS_SERVER
}

} // namespace CYW30739
} // namespace Infineon
} // namespace DeviceLayer
} // namespace chip
29 changes: 29 additions & 0 deletions examples/platform/infineon/cyw30739/SoftwareDiagnostics.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
*
* Copyright (c) 2024 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.
*/

namespace chip {
namespace DeviceLayer {
namespace Infineon {
namespace CYW30739 {

void OnSoftwareFaultEventHandler(const char * faultRecordString);

} // namespace CYW30739
} // namespace Infineon
} // namespace DeviceLayer
} // namespace chip
2 changes: 2 additions & 0 deletions examples/platform/infineon/cyw30739/cyw30739_example.gni
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ template("cyw30739_example") {

static_library(target_name) {
sources = [
"${cyw30739_example_dir}/EventManagementTestEventTriggerHandler.cpp",
"${cyw30739_example_dir}/LEDWidget.cpp",
"${cyw30739_example_dir}/OTAConfig.cpp",
"${cyw30739_example_dir}/SoftwareDiagnostics.cpp",
"${cyw30739_example_dir}/matter_config.cpp",
]

Expand Down
30 changes: 25 additions & 5 deletions examples/platform/infineon/cyw30739/matter_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "matter_config.h"
#include "AppTask.h"
#include "EventManagementTestEventTriggerHandler.h"
#ifdef BOARD_ENABLE_DISPLAY
#include "GUI.h"
#endif
Expand All @@ -44,14 +45,21 @@
#include <lib/support/CHIPPlatformMemory.h>
#include <mbedtls/platform.h>
#include <platform/DeviceInstanceInfoProvider.h>
#include <platform/Infineon/CYW30739/FactoryDataProvider.h>
#include <platform/KeyValueStoreManager.h>
#include <protocols/secure_channel/PASESession.h>
#ifdef BOARD_ENABLE_OPTIGA
#include "wiced_optiga.h"
#endif
#include <wiced_rtos.h>

#ifdef BOARD_USE_OPTIGA
#include "wiced_optiga.h"
#ifdef USE_PROVISIONED_OPTIGA
#include <platform/Infineon/CYW30739/OptigaFactoryDataProvider.h>
#else /* !USE_PROVISIONED_OPTIGA */
#include <platform/Infineon/CYW30739/UnprovisionedOptigaFactoryDataProvider.h>
#endif /* USE_PROVISIONED_OPTIGA */
#else /* !BOARD_USE_OPTIGA */
#include <platform/Infineon/CYW30739/FactoryDataProvider.h>
#endif /* BOARD_USE_OPTIGA */

using namespace ::chip;
using namespace ::chip::Inet;
using namespace ::chip::Credentials;
Expand All @@ -60,7 +68,15 @@ using namespace ::chip::Shell;
using namespace ::chip::app;

static DeviceInfoProviderImpl sExampleDeviceInfoProvider;
#ifdef BOARD_USE_OPTIGA
#ifdef USE_PROVISIONED_OPTIGA
static OptigaFactoryDataProvider sFactoryDataProvider;
#else /* !USE_PROVISIONED_OPTIGA */
static UnprovisionedOptigaFactoryDataProvider sFactoryDataProvider;
#endif /* USE_PROVISIONED_OPTIGA */
#else /* !BOARD_USE_OPTIGA */
static FactoryDataProvider sFactoryDataProvider;
#endif /* BOARD_USE_OPTIGA */

// NOTE! This key is for test/certification only and should not be available in production devices!
uint8_t sTestEventTriggerEnableKey[chip::TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55,
Expand Down Expand Up @@ -135,7 +151,7 @@ void CYW30739MatterConfig::InitBoard(void)
#ifdef BOARD_ENABLE_DISPLAY
GUI_Init();
#endif
#ifdef BOARD_ENABLE_OPTIGA
#ifdef BOARD_USE_OPTIGA
wiced_optiga_init();
#endif
}
Expand Down Expand Up @@ -186,13 +202,17 @@ void CYW30739MatterConfig::InitApp(void)
LogAppInit();
ConfigurationMgr().LogDeviceConfig();

sFactoryDataProvider.Init();

// Print QR Code URL
PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE));
/* Start CHIP datamodel server */
static chip::SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{};
static chip::OTATestEventTriggerHandler sOtaTestEventTriggerHandler{};
static Infineon::CYW30739::EventManagementTestEventTriggerHandler sEventManagementTestEventTriggerHandler{};
VerifyOrDie(sTestEventTriggerDelegate.Init(chip::ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR);
VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR);
VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sEventManagementTestEventTriggerHandler) == CHIP_NO_ERROR);
// Create initParams with SDK example defaults here
static chip::CommonCaseDeviceServerInitParams initParams;
(void) initParams.InitializeStaticResourcesBeforeServerInit();
Expand Down
Loading

0 comments on commit 9346ac0

Please sign in to comment.