Skip to content

Commit 978dfcb

Browse files
[TI] ICD support for TI CC13x4 (#32823)
* ICD support for TI CC13x4 * spelling fix * Restyled by whitespace * Restyled by clang-format * Restyled by gn * Restyled by prettier-markdown * replaced SED define with ICD server defines + other code cleanup * Restyled by whitespace * Restyled by clang-format --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 0c0c6d6 commit 978dfcb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+948
-578
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Configuring Intermittently Connected Devices on TI CC13x4 Platforms
2+
3+
## Overview
4+
5+
Intermittently Connected Devices are devices in a network that do not always
6+
need to be active. Matter has defined a cluster that helps capture this
7+
behavior; this configuration is ideal for devices that need to operate with low
8+
power consumption or do not have a need to always be on the network. Matter
9+
examples on the TI CC13x4 platform can be configured to act as ICDs.
10+
11+
## Platform Code Changes
12+
13+
To configure a TI example as an ICD, open up the `args.gni` file of the example
14+
and set the following parameter to true:
15+
16+
```
17+
chip_enable_icd_server = true
18+
```
19+
20+
TI examples have only been tested with the ICD Server configuration. To enable
21+
the client configuration, set `chip_enable_icd_client` to true.
22+
23+
Persistent subscriptions allow devices to attempt resuming existing
24+
subscriptions following a device reset. To enable persistent subscriptions, set
25+
the following parameter to true:
26+
27+
```
28+
chip_persist_subscriptions = true
29+
```
30+
31+
Subscription timeout resumption allows devices to attempt re-establishing
32+
subscriptions that may have expired. This feature is disabled out of box.
33+
34+
In addition, various ICD parameters such as idle/active mode duration, active
35+
mode threshold, and polling intervals can be configured in
36+
`src/platform/cc13xx_26xx/cc13x4_26x4/CHIPPlatformConfig.h`
37+
38+
```
39+
#define CHIP_CONFIG_ICD_ACTIVE_MODE_DURATION_MS 1000
40+
#define CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS 500
41+
#define CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC 300
42+
#define CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL chip::System::Clock::Milliseconds32(5000)
43+
#define CHIP_DEVICE_CONFIG_ICD_FAST_POLL_INTERVAL chip::System::Clock::Milliseconds32(100)
44+
```
45+
46+
## ZAP File Changes
47+
48+
Open up the ZAP file (in `examples/<example-name>/<example-name>-common`) for
49+
the example being configured as an ICD. Add the ICD Management Cluster for
50+
Endpoint 0.
51+
52+
Open up the .matter file (in `examples/<example-name>/<example-name>-common`)
53+
corresponding to the example and add in the ICDManagement cluster.
54+
55+
In addition, each endpoint has a list of clusters that it supports. Add the
56+
ICDManagement cluster to this list.
57+
58+
The lock-app example's .matter file can be used as a reference. These additions
59+
allow the ICDManagement cluster's callbacks to be accessed.

examples/all-clusters-app/cc13x4_26x4/BUILD.gn

+8-4
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ ti_sysconfig("sysconfig") {
6767

6868
cflags = [
6969
"-Wno-comment",
70-
"@" + rebase_path("${target_gen_dir}/sysconfig/ti_ble_app_config.opt",
71-
root_build_dir),
72-
"@" + rebase_path("${target_gen_dir}/sysconfig/ti_build_config.opt",
70+
"@" + rebase_path("${target_gen_dir}/sysconfig/ti_utils_build_compiler.opt",
7371
root_build_dir),
7472
]
7573
}
@@ -117,8 +115,14 @@ ti_simplelink_executable("all-clusters-app") {
117115
deps += [ "${chip_root}/third_party/openthread/repo:libopenthread-mtd" ]
118116
}
119117

118+
defines = []
119+
120120
if (custom_factory_data) {
121-
defines = [ "CC13XX_26XX_FACTORY_DATA" ]
121+
defines += [ "CC13XX_26XX_FACTORY_DATA" ]
122+
}
123+
124+
if (chip_enable_icd_server) {
125+
defines += [ "TI_ICD_ENABLE_SERVER" ]
122126
}
123127

124128
include_dirs = [

examples/all-clusters-app/cc13x4_26x4/args.gni

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
import("//build_overrides/chip.gni")
16+
import("//build_overrides/freertos.gni")
1617
import("${chip_root}/config/standalone/args.gni")
1718
import("${chip_root}/examples/platform/cc13x4_26x4/args.gni")
1819

@@ -52,3 +53,10 @@ matter_software_ver = "0x0001"
5253
matter_software_ver_str = "1.0.1+1"
5354

5455
custom_factory_data = true
56+
57+
# ICD Default configurations
58+
chip_enable_icd_server = false
59+
chip_persist_subscriptions = false
60+
chip_subscription_timeout_resumption = false
61+
62+
freertos_root = "//third_party/connectedhomeip/third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx/source/third_party/freertos"

examples/all-clusters-app/cc13x4_26x4/main/AppTask.cpp

+92-71
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@
5555
#define APP_TASK_PRIORITY 4
5656
#define APP_EVENT_QUEUE_SIZE 10
5757

58+
#if (CHIP_CONFIG_ENABLE_ICD_SERVER == 1)
59+
#define LED_ENABLE 0
60+
#else
61+
#define LED_ENABLE 1
62+
#endif
63+
#define BUTTON_ENABLE 1
64+
5865
using namespace ::chip;
5966
using namespace ::chip::Credentials;
6067
using namespace ::chip::DeviceLayer;
@@ -164,38 +171,9 @@ int AppTask::StartAppTask()
164171

165172
int AppTask::Init()
166173
{
167-
LED_Params ledParams;
168-
Button_Params buttonParams;
169-
170174
cc13xx_26xxLogInit();
171175

172-
// Initialize LEDs
173-
PLAT_LOG("Initialize LEDs");
174-
LED_init();
175-
176-
LED_Params_init(&ledParams); // default PWM LED
177-
sAppRedHandle = LED_open(CONFIG_LED_RED, &ledParams);
178-
LED_setOff(sAppRedHandle);
179-
180-
LED_Params_init(&ledParams); // default PWM LED
181-
sAppGreenHandle = LED_open(CONFIG_LED_GREEN, &ledParams);
182-
LED_setOff(sAppGreenHandle);
183-
184-
// Initialize buttons
185-
PLAT_LOG("Initialize buttons");
186-
Button_init();
187-
188-
Button_Params_init(&buttonParams);
189-
buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED;
190-
buttonParams.longPressDuration = 1000U; // ms
191-
sAppLeftHandle = Button_open(CONFIG_BTN_LEFT, &buttonParams);
192-
Button_setCallback(sAppLeftHandle, ButtonLeftEventHandler);
193-
194-
Button_Params_init(&buttonParams);
195-
buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED;
196-
buttonParams.longPressDuration = 1000U; // ms
197-
sAppRightHandle = Button_open(CONFIG_BTN_RIGHT, &buttonParams);
198-
Button_setCallback(sAppRightHandle, ButtonRightEventHandler);
176+
uiInit();
199177

200178
// Init Chip memory management before the stack
201179
Platform::MemoryInit();
@@ -218,11 +196,12 @@ int AppTask::Init()
218196

219197
#if CHIP_DEVICE_CONFIG_THREAD_FTD
220198
ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router);
221-
#elif CONFIG_OPENTHREAD_MTD_SED
199+
#elif CHIP_CONFIG_ENABLE_ICD_SERVER
222200
ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice);
223201
#else
224202
ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice);
225203
#endif
204+
226205
if (ret != CHIP_NO_ERROR)
227206
{
228207
PLAT_LOG("ConnectivityMgr().SetThreadDeviceType() failed");
@@ -312,46 +291,6 @@ void AppTask::PostEvent(const AppEvent * aEvent)
312291
}
313292
}
314293

315-
void AppTask::ButtonLeftEventHandler(Button_Handle handle, Button_EventMask events)
316-
{
317-
AppEvent event;
318-
event.Type = AppEvent::kEventType_ButtonLeft;
319-
320-
if (events & Button_EV_CLICKED)
321-
{
322-
event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked;
323-
}
324-
else if (events & Button_EV_LONGCLICKED)
325-
{
326-
event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked;
327-
}
328-
// button callbacks are in ISR context
329-
if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS)
330-
{
331-
/* Failed to post the message */
332-
}
333-
}
334-
335-
void AppTask::ButtonRightEventHandler(Button_Handle handle, Button_EventMask events)
336-
{
337-
AppEvent event;
338-
event.Type = AppEvent::kEventType_ButtonRight;
339-
340-
if (events & Button_EV_CLICKED)
341-
{
342-
event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked;
343-
}
344-
else if (events & Button_EV_LONGCLICKED)
345-
{
346-
event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked;
347-
}
348-
// button callbacks are in ISR context
349-
if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS)
350-
{
351-
/* Failed to post the message */
352-
}
353-
}
354-
355294
void AppTask::DispatchEvent(AppEvent * aEvent)
356295
{
357296
switch (aEvent->Type)
@@ -405,3 +344,85 @@ void AppTask::DispatchEvent(AppEvent * aEvent)
405344
break;
406345
}
407346
}
347+
348+
#if (BUTTON_ENABLE == 1)
349+
void AppTask::ButtonLeftEventHandler(Button_Handle handle, Button_EventMask events)
350+
{
351+
AppEvent event;
352+
event.Type = AppEvent::kEventType_ButtonLeft;
353+
354+
if (events & Button_EV_CLICKED)
355+
{
356+
event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked;
357+
}
358+
else if (events & Button_EV_LONGCLICKED)
359+
{
360+
event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked;
361+
}
362+
// button callbacks are in ISR context
363+
if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS)
364+
{
365+
/* Failed to post the message */
366+
}
367+
}
368+
369+
void AppTask::ButtonRightEventHandler(Button_Handle handle, Button_EventMask events)
370+
{
371+
AppEvent event;
372+
event.Type = AppEvent::kEventType_ButtonRight;
373+
374+
if (events & Button_EV_CLICKED)
375+
{
376+
event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked;
377+
}
378+
else if (events & Button_EV_LONGCLICKED)
379+
{
380+
event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked;
381+
}
382+
// button callbacks are in ISR context
383+
if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS)
384+
{
385+
/* Failed to post the message */
386+
}
387+
}
388+
#endif // BUTTON_ENABLE
389+
390+
void AppTask::uiInit(void)
391+
{
392+
#if (LED_ENABLE == 1)
393+
394+
LED_Params ledParams;
395+
396+
// Initialize LEDs
397+
PLAT_LOG("Initialize LEDs");
398+
LED_init();
399+
400+
LED_Params_init(&ledParams); // default PWM LED
401+
sAppRedHandle = LED_open(CONFIG_LED_RED, &ledParams);
402+
LED_setOff(sAppRedHandle);
403+
404+
LED_Params_init(&ledParams); // default PWM LED
405+
sAppGreenHandle = LED_open(CONFIG_LED_GREEN, &ledParams);
406+
LED_setOff(sAppGreenHandle);
407+
#endif // LED ENABLE
408+
409+
#if (BUTTON_ENABLE == 1)
410+
Button_Params buttonParams;
411+
412+
// Initialize buttons
413+
PLAT_LOG("Initialize buttons");
414+
Button_init();
415+
416+
Button_Params_init(&buttonParams);
417+
buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED;
418+
buttonParams.longPressDuration = 1000U; // ms
419+
sAppLeftHandle = Button_open(CONFIG_BTN_LEFT, &buttonParams);
420+
Button_setCallback(sAppLeftHandle, ButtonLeftEventHandler);
421+
422+
Button_Params_init(&buttonParams);
423+
buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED;
424+
buttonParams.longPressDuration = 1000U; // ms
425+
sAppRightHandle = Button_open(CONFIG_BTN_RIGHT, &buttonParams);
426+
Button_setCallback(sAppRightHandle, ButtonRightEventHandler);
427+
#endif // BUTTON ENABLE
428+
}

examples/all-clusters-app/cc13x4_26x4/main/include/AppTask.h

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class AppTask
4848
int Init();
4949

5050
void DispatchEvent(AppEvent * event);
51+
void uiInit();
5152

5253
static void ButtonLeftEventHandler(Button_Handle handle, Button_EventMask events);
5354
static void ButtonRightEventHandler(Button_Handle handle, Button_EventMask events);

examples/all-clusters-app/cc13x4_26x4/main/main.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ uint32_t heapSize = TOTAL_ICALL_HEAP_SIZE;
4848
// ================================================================================
4949
// FreeRTOS Callbacks
5050
// ================================================================================
51-
extern "C" void vApplicationStackOverflowHook(void)
52-
{
53-
while (1)
54-
{
55-
;
56-
}
57-
}
58-
5951
/* Wrapper functions for using the queue registry regardless of whether it is enabled or disabled */
6052
extern "C" void vQueueAddToRegistryWrapper(QueueHandle_t xQueue, const char * pcQueueName)
6153
{

examples/lighting-app/cc13x4_26x4/BUILD.gn

+8-4
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ ti_sysconfig("sysconfig") {
6767

6868
cflags = [
6969
"-Wno-comment",
70-
"@" + rebase_path("${target_gen_dir}/sysconfig/ti_ble_app_config.opt",
71-
root_build_dir),
72-
"@" + rebase_path("${target_gen_dir}/sysconfig/ti_build_config.opt",
70+
"@" + rebase_path("${target_gen_dir}/sysconfig/ti_utils_build_compiler.opt",
7371
root_build_dir),
7472
]
7573
}
@@ -99,8 +97,14 @@ ti_simplelink_executable("lighting_app") {
9997
deps += [ "${chip_root}/third_party/openthread/repo:libopenthread-mtd" ]
10098
}
10199

100+
defines = []
101+
102102
if (custom_factory_data) {
103-
defines = [ "CC13XX_26XX_FACTORY_DATA" ]
103+
defines += [ "CC13XX_26XX_FACTORY_DATA" ]
104+
}
105+
106+
if (chip_enable_icd_server) {
107+
defines += [ "TI_ICD_ENABLE_SERVER" ]
104108
}
105109

106110
include_dirs = [

examples/lighting-app/cc13x4_26x4/args.gni

+13-4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
import("//build_overrides/chip.gni")
16+
import("//build_overrides/freertos.gni")
1617
import("${chip_root}/config/standalone/args.gni")
1718
import("${chip_root}/examples/platform/cc13x4_26x4/args.gni")
1819

@@ -29,13 +30,13 @@ lwip_debug = false
2930

3031
chip_enable_ota_requestor = true
3132

32-
chip_openthread_ftd = true
33+
chip_openthread_ftd = false
3334
openthread_external_platform = "${chip_root}/third_party/openthread/platforms/cc13x4_26x4:libopenthread-cc13x4_cc26x4"
3435

3536
# Disable CHIP Logging
36-
#chip_progress_logging = false
37-
#chip_detail_logging = false
38-
#chip_automation_logging = false
37+
chip_progress_logging = true
38+
chip_detail_logging = true
39+
chip_automation_logging = true
3940

4041
# BLE options
4142
chip_config_network_layer_ble = true
@@ -50,3 +51,11 @@ matter_software_ver = "0x0001"
5051
matter_software_ver_str = "1.0.1+1"
5152

5253
custom_factory_data = true
54+
55+
# ICD Default configurations
56+
# when enabled the device will be configured as a sleepy end device
57+
chip_enable_icd_server = false
58+
chip_persist_subscriptions = false
59+
chip_subscription_timeout_resumption = false
60+
61+
freertos_root = "//third_party/connectedhomeip/third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx/source/third_party/freertos"

0 commit comments

Comments
 (0)