Skip to content

Commit 315cef5

Browse files
committed
ICD support for TI CC13x4
1 parent 824ba6d commit 315cef5

Some content is hidden

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

46 files changed

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

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

+5-3
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
}
@@ -121,6 +119,10 @@ ti_simplelink_executable("all-clusters-app") {
121119
defines = [ "CC13XX_26XX_FACTORY_DATA" ]
122120
}
123121

122+
if(chip_enable_icd_server){
123+
defines += ["CHIP_DEVICE_CONFIG_ENABLE_SED", "TI_ICD_ENABLE_SERVER"]
124+
}
125+
124126
include_dirs = [
125127
"${project_dir}",
126128
"${project_dir}/main",

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/chip.syscfg

-2
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,12 @@ LED1.$name = "CONFIG_LED_RED";
168168
LED1.$hardware = system.deviceData.board.components.LED_RED;
169169
LED1.gpioPin.$name = "CONFIG_GPIO_RLED";
170170
LED1.gpioPin.mode = "Output";
171-
LED1.gpioPin.callbackFunction = "";
172171

173172
/* Green LED */
174173
LED2.$name = "CONFIG_LED_GREEN";
175174
LED2.$hardware = system.deviceData.board.components.LED_GREEN;
176175
LED2.gpioPin.$name = "CONFIG_GPIO_GLED";
177176
LED2.gpioPin.mode = "Output";
178-
LED2.gpioPin.callbackFunction = "";
179177

180178
/* Debug UART */
181179
UART2.$hardware = system.deviceData.board.components.XDS110UART;

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

+91-69
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,7 +196,7 @@ 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_DEVICE_CONFIG_ENABLE_SED
222200
ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice);
223201
#else
224202
ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice);
@@ -312,45 +290,7 @@ void AppTask::PostEvent(const AppEvent * aEvent)
312290
}
313291
}
314292

315-
void AppTask::ButtonLeftEventHandler(Button_Handle handle, Button_EventMask events)
316-
{
317-
AppEvent event;
318-
event.Type = AppEvent::kEventType_ButtonLeft;
319293

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-
}
354294

355295
void AppTask::DispatchEvent(AppEvent * aEvent)
356296
{
@@ -405,3 +345,85 @@ void AppTask::DispatchEvent(AppEvent * aEvent)
405345
break;
406346
}
407347
}
348+
349+
#ifdef BUTTON_ENABLE
350+
void AppTask::ButtonLeftEventHandler(Button_Handle handle, Button_EventMask events)
351+
{
352+
AppEvent event;
353+
event.Type = AppEvent::kEventType_ButtonLeft;
354+
355+
if (events & Button_EV_CLICKED)
356+
{
357+
event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked;
358+
}
359+
else if (events & Button_EV_LONGCLICKED)
360+
{
361+
event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked;
362+
}
363+
// button callbacks are in ISR context
364+
if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS)
365+
{
366+
/* Failed to post the message */
367+
}
368+
}
369+
370+
void AppTask::ButtonRightEventHandler(Button_Handle handle, Button_EventMask events)
371+
{
372+
AppEvent event;
373+
event.Type = AppEvent::kEventType_ButtonRight;
374+
375+
if (events & Button_EV_CLICKED)
376+
{
377+
event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked;
378+
}
379+
else if (events & Button_EV_LONGCLICKED)
380+
{
381+
event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked;
382+
}
383+
// button callbacks are in ISR context
384+
if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS)
385+
{
386+
/* Failed to post the message */
387+
}
388+
}
389+
#endif // BUTTON_ENABLE
390+
391+
void AppTask::uiInit(void)
392+
{
393+
#ifdef LED_ENABLE
394+
395+
LED_Params ledParams;
396+
397+
// Initialize LEDs
398+
PLAT_LOG("Initialize LEDs");
399+
LED_init();
400+
401+
LED_Params_init(&ledParams); // default PWM LED
402+
sAppRedHandle = LED_open(CONFIG_LED_RED, &ledParams);
403+
LED_setOff(sAppRedHandle);
404+
405+
LED_Params_init(&ledParams); // default PWM LED
406+
sAppGreenHandle = LED_open(CONFIG_LED_GREEN, &ledParams);
407+
LED_setOff(sAppGreenHandle);
408+
#endif //LED ENABLE
409+
410+
#ifdef BUTTON_ENABLE
411+
Button_Params buttonParams;
412+
413+
// Initialize buttons
414+
PLAT_LOG("Initialize buttons");
415+
Button_init();
416+
417+
Button_Params_init(&buttonParams);
418+
buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED;
419+
buttonParams.longPressDuration = 1000U; // ms
420+
sAppLeftHandle = Button_open(CONFIG_BTN_LEFT, &buttonParams);
421+
Button_setCallback(sAppLeftHandle, ButtonLeftEventHandler);
422+
423+
Button_Params_init(&buttonParams);
424+
buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED;
425+
buttonParams.longPressDuration = 1000U; // ms
426+
sAppRightHandle = Button_open(CONFIG_BTN_RIGHT, &buttonParams);
427+
Button_setCallback(sAppRightHandle, ButtonRightEventHandler);
428+
#endif //BUTTON ENABLE
429+
}

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

+7-4
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,8 @@ 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",
73-
root_build_dir),
70+
"@" + rebase_path("${target_gen_dir}/sysconfig/ti_utils_build_compiler.opt",
71+
root_build_dir),
7472
]
7573
}
7674

@@ -103,6 +101,11 @@ ti_simplelink_executable("lighting_app") {
103101
defines = [ "CC13XX_26XX_FACTORY_DATA" ]
104102
}
105103

104+
if(chip_enable_icd_server){
105+
defines += ["CHIP_DEVICE_CONFIG_ENABLE_SED",
106+
"TI_ICD_ENABLE_SERVER"]
107+
}
108+
106109
include_dirs = [
107110
"${project_dir}",
108111
"${chip_root}/examples/providers/",

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"

examples/lighting-app/cc13x4_26x4/chip.syscfg

-2
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,12 @@ LED1.$name = "CONFIG_LED_RED";
168168
LED1.$hardware = system.deviceData.board.components.LED_RED;
169169
LED1.gpioPin.$name = "CONFIG_GPIO_RLED";
170170
LED1.gpioPin.mode = "Output";
171-
LED1.gpioPin.callbackFunction = "";
172171

173172
/* Green LED */
174173
LED2.$name = "CONFIG_LED_GREEN";
175174
LED2.$hardware = system.deviceData.board.components.LED_GREEN;
176175
LED2.gpioPin.$name = "CONFIG_GPIO_GLED";
177176
LED2.gpioPin.mode = "Output";
178-
LED2.gpioPin.callbackFunction = "";
179177

180178
/* Debug UART */
181179
UART2.$hardware = system.deviceData.board.components.XDS110UART;

0 commit comments

Comments
 (0)