Skip to content

Commit 1ff4959

Browse files
riscv: telink: fix deferred storage compilation errors
- Fix compilation errors caused by Server::GetInstance() type changes . - Ajust the operate instance for deferred storage . - Update zephyr commit to 7f064a1 . - Adjust the CI target . Signed-off-by: Fengtai Xie <fengtai.xie@telink-semi.com>
1 parent 6732940 commit 1ff4959

File tree

4 files changed

+44
-39
lines changed

4 files changed

+44
-39
lines changed

.github/workflows/chef.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ jobs:
111111
platform: telink
112112
- name: Update Zephyr to specific revision (for developers purpose)
113113
shell: bash
114-
run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 16b157bc4caf9a268caf11481624885f5046263f"
114+
run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 7f064a1b02686f050b47e194fde4fc0514507cf6"
115115
- name: CI Examples Telink
116116
shell: bash
117117
run: |

.github/workflows/examples-telink.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
gh-context: ${{ toJson(github) }}
5959

6060
- name: Update Zephyr to specific revision (for developers purpose)
61-
run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 16b157bc4caf9a268caf11481624885f5046263f"
61+
run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 7f064a1b02686f050b47e194fde4fc0514507cf6"
6262

6363
- name: Build tools required for Factory Data
6464
# Run test for master and all PRs
@@ -71,14 +71,14 @@ jobs:
7171
- name: clean out build output (keep tools)
7272
run: rm -rf ./out/telink*
7373

74-
- name: Build example Telink (tl321x) Lighting App with OTA (LZMA), Shell, Factory Data
74+
- name: Build example Telink (tl321x) Lighting App with OTA (LZMA), Factory Data
7575
# Run test for master and all PRs
7676
run: |
7777
./scripts/run_in_build_env.sh \
78-
"./scripts/build/build_examples.py --target 'telink-tl3218x-light-ota-compress-lzma-shell-factory-data' build"
78+
"./scripts/build/build_examples.py --target 'telink-tl3218x-light-ota-compress-lzma-factory-data' build"
7979
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
80-
telink tl3218x light-app-ota-compress-lzma-shell-factory-data \
81-
out/telink-tl3218x-light-ota-compress-lzma-shell-factory-data/zephyr/zephyr.elf \
80+
telink tl3218x light-app-ota-compress-lzma-factory-data \
81+
out/telink-tl3218x-light-ota-compress-lzma-factory-data/zephyr/zephyr.elf \
8282
/tmp/bloat_reports/
8383
8484
- name: clean out build output (keep tools)

examples/lighting-app/telink/src/AppTask.cpp

-33
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include <zephyr/kernel.h>
3030

3131
#include <app-common/zap-generated/attributes/Accessors.h>
32-
#include <app/util/persistence/DeferredAttributePersistenceProvider.h>
3332

3433
LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL);
3534

@@ -45,35 +44,6 @@ RgbColor_t sLedRgb;
4544

4645
AppTask AppTask::sAppTask;
4746

48-
/**
49-
* @brief Set deferred attributes storage
50-
*
51-
* @see Define a custom attribute persister which makes actual write of the CurrentHue, CurrentSaturation, CurrentLevel attributes
52-
* value to the non-volatile storage only when it has remained constant for 5 seconds. This is to reduce the flash wearout when the
53-
* attribute changes frequently as a result of MoveToLevel command. DeferredAttribute object describes a deferred attribute, but
54-
* also holds a buffer with a value to be written, so it must live so long as the DeferredAttributePersistenceProvider object.
55-
*
56-
* @param ATTRIBUTES_ARRAY_SIZE The lenght of the DeferredAttribute array
57-
* @param DEFERRED_STORAGE_TIME The deferred time(ms) to store attributes
58-
*/
59-
#define ATTRIBUTES_ARRAY_SIZE (3U)
60-
#define DEFERRED_STORAGE_TIME (5000U)
61-
62-
DeferredAttribute gPersisters[] = {
63-
#if CONFIG_DEFERRED_ATTR_STORAGE
64-
DeferredAttribute(
65-
ConcreteAttributePath(kExampleEndpointId, Clusters::ColorControl::Id, Clusters::ColorControl::Attributes::CurrentHue::Id)),
66-
DeferredAttribute(ConcreteAttributePath(kExampleEndpointId, Clusters::ColorControl::Id,
67-
Clusters::ColorControl::Attributes::CurrentSaturation::Id)),
68-
DeferredAttribute(
69-
ConcreteAttributePath(kExampleEndpointId, Clusters::LevelControl::Id, Clusters::LevelControl::Attributes::CurrentLevel::Id))
70-
#endif // CONFIG_DEFERRED_ATTR_STORAGE
71-
};
72-
73-
DeferredAttributePersistenceProvider gDeferredAttributePersister(Server::GetInstance().GetDefaultAttributePersister(),
74-
Span<DeferredAttribute>(gPersisters, ATTRIBUTES_ARRAY_SIZE),
75-
System::Clock::Milliseconds32(DEFERRED_STORAGE_TIME));
76-
7747
bool AppTask::IsTurnedOn() const
7848
{
7949
return sfixture_on;
@@ -297,9 +267,6 @@ CHIP_ERROR AppTask::Init(void)
297267
SetExampleButtonCallbacks(LightingActionEventHandler);
298268
InitCommonParts();
299269

300-
/* add deferred storage attribute for provider */
301-
app::SetAttributePersistenceProvider(&gDeferredAttributePersister);
302-
303270
#if CONFIG_CUSTOMER_MODE
304271
if (user_para.val == USER_ZB_SW_VAL)
305272
{

examples/platform/telink/common/src/AppTaskCommon.cpp

+38
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
#include <app/server/Server.h>
4141
#include <app/util/attribute-storage.h>
4242
#include <app/util/endpoint-config-api.h>
43+
#include <app/util/persistence/DefaultAttributePersistenceProvider.h>
44+
#include <app/util/persistence/DeferredAttributePersistenceProvider.h>
4345
#include <data-model-providers/codegen/Instance.h>
4446
#include <setup_payload/OnboardingCodesUtil.h>
4547

@@ -120,6 +122,37 @@ Identify sIdentify = {
120122

121123
#endif
122124

125+
/**
126+
* @brief Set deferred attributes storage
127+
*
128+
* @see Define a custom attribute persister which makes actual write of the CurrentHue, CurrentSaturation, CurrentLevel attributes
129+
* value to the non-volatile storage only when it has remained constant for 5 seconds. This is to reduce the flash wearout when the
130+
* attribute changes frequently as a result of MoveToLevel command. DeferredAttribute object describes a deferred attribute, but
131+
* also holds a buffer with a value to be written, so it must live so long as the DeferredAttributePersistenceProvider object.
132+
*
133+
* @param ATTRIBUTES_ARRAY_SIZE The lenght of the DeferredAttribute array
134+
* @param DEFERRED_STORAGE_TIME The deferred time(ms) to store attributes
135+
*/
136+
#define ATTRIBUTES_ARRAY_SIZE (3U)
137+
#define DEFERRED_STORAGE_TIME (5000U)
138+
139+
DeferredAttribute gPersisters[] = {
140+
#if CONFIG_DEFERRED_ATTR_STORAGE
141+
DeferredAttribute(
142+
ConcreteAttributePath(kExampleEndpointId, Clusters::ColorControl::Id, Clusters::ColorControl::Attributes::CurrentHue::Id)),
143+
DeferredAttribute(ConcreteAttributePath(kExampleEndpointId, Clusters::ColorControl::Id,
144+
Clusters::ColorControl::Attributes::CurrentSaturation::Id)),
145+
DeferredAttribute(
146+
ConcreteAttributePath(kExampleEndpointId, Clusters::LevelControl::Id, Clusters::LevelControl::Attributes::CurrentLevel::Id))
147+
#endif // CONFIG_DEFERRED_ATTR_STORAGE
148+
};
149+
150+
// Deferred persistence will be auto-initialized as soon as the default persistence is initialized
151+
DefaultAttributePersistenceProvider gSimpleAttributePersistence;
152+
DeferredAttributePersistenceProvider gDeferredAttributePersister(gSimpleAttributePersistence,
153+
Span<DeferredAttribute>(gPersisters, ATTRIBUTES_ARRAY_SIZE),
154+
System::Clock::Milliseconds32(DEFERRED_STORAGE_TIME));
155+
123156
// NOTE! This key is for test/certification only and should not be available in production devices!
124157
uint8_t sTestEventTriggerEnableKey[TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
125158
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff };
@@ -590,6 +623,8 @@ CHIP_ERROR AppTaskCommon::InitCommonParts(void)
590623
VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR);
591624
#endif
592625
(void) initParams.InitializeStaticResourcesBeforeServerInit();
626+
VerifyOrDie(gSimpleAttributePersistence.Init(initParams.persistentStorageDelegate) == CHIP_NO_ERROR);
627+
593628
initParams.dataModelProvider = CodegenDataModelProviderInstance(initParams.persistentStorageDelegate);
594629
initParams.appDelegate = &sCallbacks;
595630
initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
@@ -600,6 +635,9 @@ CHIP_ERROR AppTaskCommon::InitCommonParts(void)
600635
chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider);
601636
#endif
602637

638+
/* add deferred storage attribute for provider */
639+
app::SetAttributePersistenceProvider(&gDeferredAttributePersister);
640+
603641
ConfigurationMgr().LogDeviceConfig();
604642
PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE));
605643

0 commit comments

Comments
 (0)