Skip to content

Commit 39f0764

Browse files
authored
[Ameba] Update Ameba platform (#40450)
* [Ameba] Update Ameba platform * Update compatible builds to docker version to 153 only for Ameba Platform. * Added Ameba Device Info Provider implementation to support Fixed Label, User Label, Locales, and Calendar. * Moved HandleEventTrigger from header file to .cpp to allow platform implementation to override the Test Event Trigger. * Added AmebaDeviceManager to receive post-attribute change callbacks in platform applications layer. * Fixed incorrect default value retrieval for hardware version. * Added GetSoftwareVersionString to correctly retrieve the software version string. * Tidy up chipinterface.cpp * Removed hardcode values and get from persist storage or user settings. * Simplify DeviceInfoProvider flow and improve code clarity * Remove redundant code. * Simplify code implementation.
1 parent 9095405 commit 39f0764

File tree

23 files changed

+607
-189
lines changed

23 files changed

+607
-189
lines changed

.github/workflows/examples-ameba.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
if: github.actor != 'restyled-io[bot]'
4040

4141
container:
42-
image: ghcr.io/project-chip/chip-build-ameba:140
42+
image: ghcr.io/project-chip/chip-build-ameba:153
4343
options: --user root
4444

4545
steps:

examples/air-purifier-app/ameba/main/chipinterface.cpp

100644100755
Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,36 @@
1515
* limitations under the License.
1616
*/
1717

18+
#include <chip_porting.h>
1819
#include <platform_stdlib.h>
1920

20-
#include "AmebaObserver.h"
21-
#include "CHIPDeviceManager.h"
22-
#include "DeviceCallbacks.h"
23-
#include "Server.h"
24-
#include <DeviceInfoProviderImpl.h>
25-
26-
#include "chip_porting.h"
27-
#include <platform/CHIPDeviceLayer.h>
28-
#include <support/CHIPMem.h>
21+
#include <AmebaObserver.h>
22+
#include <CHIPDeviceManager.h>
23+
#include <DeviceCallbacks.h>
2924

3025
#include <air-purifier-manager.h>
3126
#include <app/clusters/identify-server/identify-server.h>
3227
#include <app/clusters/network-commissioning/network-commissioning.h>
28+
#include <app/server/Server.h>
29+
#if CHIP_ENABLE_AMEBA_TERMS_AND_CONDITION
30+
#include <app/server/TermsAndConditionsManager.h>
31+
#endif
3332
#include <app/util/endpoint-config-api.h>
3433
#include <data-model-providers/codegen/Instance.h>
3534
#include <lib/core/ErrorStr.h>
3635
#include <platform/Ameba/AmebaConfig.h>
36+
#include <platform/Ameba/DeviceInfoProviderImpl.h>
3737
#include <platform/Ameba/NetworkCommissioningDriver.h>
38+
#if CONFIG_ENABLE_AMEBA_CRYPTO
39+
#include <platform/Ameba/crypto/AmebaPersistentStorageOperationalKeystore.h>
40+
#endif
3841
#include <platform/CHIPDeviceLayer.h>
3942
#include <setup_payload/ManualSetupPayloadGenerator.h>
4043
#include <setup_payload/OnboardingCodesUtil.h>
4144
#include <setup_payload/QRCodeSetupPayloadGenerator.h>
42-
#if CONFIG_ENABLE_AMEBA_CRYPTO
43-
#include <platform/Ameba/crypto/AmebaPersistentStorageOperationalKeystore.h>
44-
#endif
45-
46-
#include <lwip_netconf.h>
47-
45+
#include <support/CHIPMem.h>
4846
#if CONFIG_ENABLE_PW_RPC
49-
#include "Rpc.h"
47+
#include <Rpc.h>
5048
#endif
5149

5250
#define AIR_PURIFIER_ENDPOINT 1
@@ -61,6 +59,9 @@ using namespace ::chip::DeviceManager;
6159
using namespace ::chip::DeviceLayer;
6260
using namespace ::chip::System;
6361

62+
static DeviceCallbacks EchoCallbacks;
63+
chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;
64+
6465
namespace { // Network Commissioning
6566
constexpr EndpointId kNetworkCommissioningEndpointMain = 0;
6667
constexpr EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE;
@@ -78,9 +79,6 @@ void NetWorkCommissioningInstInit()
7879
emberAfEndpointEnableDisable(kNetworkCommissioningEndpointSecondary, false);
7980
}
8081

81-
static DeviceCallbacks EchoCallbacks;
82-
chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;
83-
8482
void OnIdentifyStart(Identify *)
8583
{
8684
ChipLogProgress(Zcl, "OnIdentifyStart");
@@ -136,12 +134,14 @@ static void InitServer(intptr_t context)
136134
static chip::CommonCaseDeviceServerInitParams initParams;
137135
(void) initParams.InitializeStaticResourcesBeforeServerInit();
138136
initParams.dataModelProvider = CodegenDataModelProviderInstance(initParams.persistentStorageDelegate);
137+
139138
#if CONFIG_ENABLE_AMEBA_CRYPTO
140139
ChipLogProgress(DeviceLayer, "platform crypto enabled!");
141140
static chip::AmebaPersistentStorageOperationalKeystore sAmebaPersistentStorageOpKeystore;
142141
VerifyOrDie((sAmebaPersistentStorageOpKeystore.Init(initParams.persistentStorageDelegate)) == CHIP_NO_ERROR);
143142
initParams.operationalKeystore = &sAmebaPersistentStorageOpKeystore;
144143
#endif
144+
145145
static AmebaObserver sAmebaObserver;
146146
initParams.appDelegate = &sAmebaObserver;
147147
chip::Server::GetInstance().Init(initParams);
@@ -150,6 +150,13 @@ static void InitServer(intptr_t context)
150150

151151
NetWorkCommissioningInstInit();
152152

153+
#if CHIP_ENABLE_AMEBA_TERMS_AND_CONDITION
154+
const Optional<app::TermsAndConditions> termsAndConditions = Optional<app::TermsAndConditions>(
155+
app::TermsAndConditions(CHIP_AMEBA_TC_REQUIRED_ACKNOWLEDGEMENTS, CHIP_AMEBA_TC_MIN_REQUIRED_VERSION));
156+
PersistentStorageDelegate & persistentStorageDelegate = Server::GetInstance().GetPersistentStorage();
157+
chip::app::TermsAndConditionsManager::GetInstance()->Init(&persistentStorageDelegate, termsAndConditions);
158+
#endif
159+
153160
if (RTW_SUCCESS != wifi_is_connected_to_ap())
154161
{
155162
// QR code will be used with CHIP Tool

examples/all-clusters-app/ameba/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ The CHIP demo application is supported on
2727

2828
- Pull docker image:
2929

30-
$ docker pull ghcr.io/project-chip/chip-build-ameba:140
30+
$ docker pull ghcr.io/project-chip/chip-build-ameba:153
3131

3232
- Run docker container:
3333

34-
$ docker run -it -v ${CHIP_DIR}:/root/chip ghcr.io/project-chip/chip-build-ameba:140
34+
$ docker run -it -v ${CHIP_DIR}:/root/chip ghcr.io/project-chip/chip-build-ameba:153
3535

3636
- Setup build environment:
3737

examples/all-clusters-app/ameba/chip_main.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,6 @@ list(
203203
${chip_dir}/examples/platform/ameba/route_hook/ameba_route_table.c
204204

205205
${chip_dir}/examples/platform/ameba/test_event_trigger/AmebaTestEventTriggerDelegate.cpp
206-
207-
${chip_dir}/examples/providers/DeviceInfoProviderImpl.cpp
208206
)
209207

210208
add_library(

examples/all-clusters-app/ameba/main/CHIPDeviceManager.cpp

100644100755
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525

2626
#include <stdlib.h>
2727

28-
#include "CHIPDeviceManager.h"
28+
#if CONFIG_ENABLE_AMEBA_ATTRIBUTE_CALLBACK
29+
#include <matter_attribute_callbacks.h>
30+
#endif
31+
#include <CHIPDeviceManager.h>
2932
#include <app/ConcreteAttributePath.h>
3033
#include <app/util/basic-types.h>
3134
#include <core/ErrorStr.h>
@@ -36,6 +39,8 @@
3639
#include <support/CodeUtils.h>
3740

3841
using namespace ::chip;
42+
using namespace ::chip::app;
43+
using namespace ::chip::app::Clusters;
3944
using namespace ::chip::Credentials;
4045

4146
namespace chip {
@@ -103,10 +108,18 @@ void CHIPDeviceManager::Shutdown()
103108

104109
void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & path, uint8_t type, uint16_t size, uint8_t * value)
105110
{
111+
#if CONFIG_ENABLE_AMEBA_ATTRIBUTE_CALLBACK
112+
if (AmebaDeviceManager::GetInstance() != nullptr)
113+
{
114+
AmebaDeviceManager::GetInstance()->AmebaPostAttributeChangeCallback(path.mEndpointId, path.mClusterId, path.mAttributeId,
115+
type, size, value);
116+
}
117+
#else
106118
chip::DeviceManager::CHIPDeviceManagerCallbacks * cb =
107119
chip::DeviceManager::CHIPDeviceManager::GetInstance().GetCHIPDeviceManagerCallbacks();
108120
if (cb != nullptr)
109121
{
110122
cb->PostAttributeChangeCallback(path.mEndpointId, path.mClusterId, path.mAttributeId, type, size, value);
111123
}
124+
#endif
112125
}

examples/all-clusters-app/ameba/main/chipinterface.cpp

100644100755
Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,48 +15,55 @@
1515
* limitations under the License.
1616
*/
1717

18+
#include <chip_porting.h>
1819
#include <platform_stdlib.h>
19-
20-
#include "AmebaObserver.h"
21-
#include "BindingHandler.h"
22-
#include "CHIPDeviceManager.h"
23-
#include "DeviceCallbacks.h"
24-
#include "Globals.h"
25-
#include "LEDWidget.h"
26-
#include "chip_porting.h"
27-
#if CHIP_AMEBA_APP_TASK
28-
#include "ameba_main_task.h"
20+
#if CONFIG_ENABLE_AMEBA_APP_TASK
21+
#include <ameba_main_task.h>
2922
#endif
30-
#include <DeviceInfoProviderImpl.h>
23+
24+
#include <AmebaObserver.h>
25+
#include <BindingHandler.h>
26+
#include <CHIPDeviceManager.h>
27+
#include <DeviceCallbacks.h>
28+
#include <Globals.h>
29+
#include <LEDWidget.h>
3130

3231
#include <app/clusters/identify-server/identify-server.h>
3332
#include <app/clusters/network-commissioning/network-commissioning.h>
3433
#include <app/server/Server.h>
34+
#if CHIP_ENABLE_AMEBA_TERMS_AND_CONDITION
35+
#include <app/server/TermsAndConditionsManager.h>
36+
#endif
3537
#include <app/util/endpoint-config-api.h>
3638
#include <data-model-providers/codegen/Instance.h>
3739
#include <lib/core/ErrorStr.h>
38-
#include <setup_payload/OnboardingCodesUtil.h>
39-
4040
#include <platform/Ameba/AmebaConfig.h>
41+
#include <platform/Ameba/DeviceInfoProviderImpl.h>
4142
#include <platform/Ameba/NetworkCommissioningDriver.h>
4243
#if CONFIG_ENABLE_AMEBA_CRYPTO
4344
#include <platform/Ameba/crypto/AmebaPersistentStorageOperationalKeystore.h>
4445
#endif
4546
#include <platform/CHIPDeviceLayer.h>
4647
#include <setup_payload/ManualSetupPayloadGenerator.h>
48+
#include <setup_payload/OnboardingCodesUtil.h>
4749
#include <setup_payload/QRCodeSetupPayloadGenerator.h>
4850
#include <support/CHIPMem.h>
49-
5051
#if CONFIG_ENABLE_AMEBA_TEST_EVENT_TRIGGER
5152
#include <test_event_trigger/AmebaTestEventTriggerDelegate.h>
5253
#endif
53-
54+
#if CONFIG_ENABLE_CHIP_SHELL
55+
#include <shell/launch_shell.h>
56+
#endif
5457
#if CONFIG_ENABLE_PW_RPC
5558
#include <Rpc.h>
5659
#endif
5760

58-
#if CONFIG_ENABLE_CHIP_SHELL
59-
#include <shell/launch_shell.h>
61+
#ifdef CONFIG_PLATFORM_8721D
62+
#define STATUS_LED_GPIO_NUM PB_5
63+
#elif defined(CONFIG_PLATFORM_8710C)
64+
#define STATUS_LED_GPIO_NUM PA_20
65+
#else
66+
#define STATUS_LED_GPIO_NUM NC
6067
#endif
6168

6269
using namespace ::chip;
@@ -65,6 +72,14 @@ using namespace ::chip::DeviceManager;
6572
using namespace ::chip::DeviceLayer;
6673
using namespace ::chip::System;
6774

75+
static DeviceCallbacks EchoCallbacks;
76+
chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;
77+
78+
#if CONFIG_ENABLE_AMEBA_TEST_EVENT_TRIGGER
79+
uint8_t sTestEventTriggerEnableKey[TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
80+
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff };
81+
#endif
82+
6883
namespace { // Network Commissioning
6984
constexpr EndpointId kNetworkCommissioningEndpointMain = 0;
7085
constexpr EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE;
@@ -121,22 +136,6 @@ Identify gIdentify1 = {
121136
OnIdentifyTriggerEffect,
122137
};
123138

124-
#ifdef CONFIG_PLATFORM_8721D
125-
#define STATUS_LED_GPIO_NUM PB_5
126-
#elif defined(CONFIG_PLATFORM_8710C)
127-
#define STATUS_LED_GPIO_NUM PA_20
128-
#else
129-
#define STATUS_LED_GPIO_NUM NC
130-
#endif
131-
132-
static DeviceCallbacks EchoCallbacks;
133-
chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;
134-
135-
#if CONFIG_ENABLE_AMEBA_TEST_EVENT_TRIGGER
136-
uint8_t sTestEventTriggerEnableKey[TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
137-
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff };
138-
#endif
139-
140139
static void InitServer(intptr_t context)
141140
{
142141
// Init ZCL Data Model and CHIP App Server
@@ -146,6 +145,7 @@ static void InitServer(intptr_t context)
146145
static AmebaTestEventTriggerDelegate sTestEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) };
147146
initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
148147
#endif
148+
149149
static AmebaObserver sAmebaObserver;
150150
initParams.appDelegate = &sAmebaObserver;
151151

@@ -164,6 +164,13 @@ static void InitServer(intptr_t context)
164164
// TODO: Use our own DeviceInfoProvider
165165
chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider);
166166

167+
#if CHIP_ENABLE_AMEBA_TERMS_AND_CONDITION
168+
const Optional<app::TermsAndConditions> termsAndConditions = Optional<app::TermsAndConditions>(
169+
app::TermsAndConditions(CHIP_AMEBA_TC_REQUIRED_ACKNOWLEDGEMENTS, CHIP_AMEBA_TC_MIN_REQUIRED_VERSION));
170+
PersistentStorageDelegate & persistentStorageDelegate = Server::GetInstance().GetPersistentStorage();
171+
chip::app::TermsAndConditionsManager::GetInstance()->Init(&persistentStorageDelegate, termsAndConditions);
172+
#endif
173+
167174
NetWorkCommissioningInstInit();
168175

169176
if (RTW_SUCCESS != wifi_is_connected_to_ap())
@@ -175,9 +182,11 @@ static void InitServer(intptr_t context)
175182
#if CONFIG_ENABLE_CHIP_SHELL
176183
InitBindingHandler();
177184
#endif
178-
#if CHIP_AMEBA_APP_TASK
185+
186+
#if CONFIG_ENABLE_AMEBA_APP_TASK
179187
AppTaskInit();
180188
#endif
189+
181190
chip::Server::GetInstance().GetFabricTable().AddFabricDelegate(&sAmebaObserver);
182191
}
183192

@@ -216,7 +225,7 @@ extern "C" void ChipTestShutdown(void)
216225
deviceMgr.Shutdown();
217226
}
218227

219-
bool lowPowerClusterSleep()
228+
bool lowPowerClusterSleep(void)
220229
{
221230
return true;
222231
}

examples/all-clusters-minimal-app/ameba/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ The CHIP demo application is supported on
2727
- Pull docker image:
2828

2929
```
30-
$ docker pull ghcr.io/project-chip/chip-build-ameba:140
30+
$ docker pull ghcr.io/project-chip/chip-build-ameba:153
3131
```
3232

3333
- Run docker container:
3434

3535
```
36-
$ docker run -it -v ${CHIP_DIR}:/root/chip ghcr.io/project-chip/chip-build-ameba:140
36+
$ docker run -it -v ${CHIP_DIR}:/root/chip ghcr.io/project-chip/chip-build-ameba:153
3737
```
3838

3939
- Setup build environment:

0 commit comments

Comments
 (0)