Skip to content

Commit

Permalink
Update example apps for Infineon P6 Platform (#16652)
Browse files Browse the repository at this point in the history
  • Loading branch information
praveenCY authored Mar 26, 2022
1 parent 4479621 commit f05afad
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 49 deletions.
6 changes: 0 additions & 6 deletions examples/all-clusters-app/p6/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,3 @@ import("${chip_root}/src/platform/P6/args.gni")

p6_target_project =
get_label_info(":all_clusters_app_sdk_sources", "label_no_toolchain")

declare_args() {
# Disable lock tracking, since our FreeRTOS configuration does not set
# INCLUDE_xSemaphoreGetMutexHolder
chip_stack_lock_tracking = "none"
}
2 changes: 1 addition & 1 deletion examples/all-clusters-app/p6/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class AppTask

static AppTask sAppTask;
void DispatchEvent(AppEvent * event);
static void OnOffUpdateClusterState(void);
static void OnOffUpdateClusterState(intptr_t context);
};

inline AppTask & GetAppTask(void)
Expand Down
18 changes: 12 additions & 6 deletions examples/all-clusters-app/p6/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ void NetWorkCommissioningInstInit()
sWiFiNetworkCommissioningInstance.Init();
}

static void InitServer(intptr_t context)
{
// Init ZCL Data Model
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
}

CHIP_ERROR AppTask::StartAppTask()
{
sAppEventQueue = xQueueCreateStatic(APP_EVENT_QUEUE_SIZE, sizeof(AppEvent), sAppEventQueueBuffer, &sAppEventQueueStruct);
Expand Down Expand Up @@ -112,11 +121,8 @@ CHIP_ERROR AppTask::Init()
}
},
0);
// Init ZCL Data Model
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast<intptr_t>(nullptr));

// Initialise WSTK buttons PB0 and PB1 (including debounce).
ButtonHandler::Init();
Expand Down Expand Up @@ -166,7 +172,7 @@ void AppTask::LightActionEventHandler(AppEvent * aEvent)
sLightLED.Invert();

/* Update OnOff Cluster state */
sAppTask.OnOffUpdateClusterState();
chip::DeviceLayer::PlatformMgr().ScheduleWork(OnOffUpdateClusterState, reinterpret_cast<intptr_t>(nullptr));
}

void AppTask::ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction)
Expand Down Expand Up @@ -232,7 +238,7 @@ void AppTask::DispatchEvent(AppEvent * aEvent)
}
}

void AppTask::OnOffUpdateClusterState(void)
void AppTask::OnOffUpdateClusterState(intptr_t context)
{
uint8_t onoff = sLightLED.Get();

Expand Down
6 changes: 0 additions & 6 deletions examples/lighting-app/p6/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,3 @@ import("${chip_root}/src/platform/P6/args.gni")

p6_target_project =
get_label_info(":lighting_app_sdk_sources", "label_no_toolchain")

declare_args() {
# Disable lock tracking, since our FreeRTOS configuration does not set
# INCLUDE_xSemaphoreGetMutexHolder
chip_stack_lock_tracking = "none"
}
2 changes: 1 addition & 1 deletion examples/lighting-app/p6/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class AppTask
static void LightActionEventHandler(AppEvent * aEvent);
static void TimerEventHandler(TimerHandle_t xTimer);

static void UpdateClusterState(void);
static void UpdateClusterState(intptr_t context);

void StartTimer(uint32_t aTimeoutMs);

Expand Down
19 changes: 12 additions & 7 deletions examples/lighting-app/p6/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ void NetWorkCommissioningInstInit()
sWiFiNetworkCommissioningInstance.Init();
}

static void InitServer(intptr_t context)
{
// Init ZCL Data Model
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
}

CHIP_ERROR AppTask::StartAppTask()
{
sAppEventQueue = xQueueCreateStatic(APP_EVENT_QUEUE_SIZE, sizeof(AppEvent), sAppEventQueueBuffer, &sAppEventQueueStruct);
Expand Down Expand Up @@ -117,11 +126,8 @@ CHIP_ERROR AppTask::Init()
}
},
0);
// Init ZCL Data Model
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast<intptr_t>(nullptr));

// Initialise WSTK buttons PB0 and PB1 (including debounce).
ButtonHandler::Init();
Expand Down Expand Up @@ -153,7 +159,6 @@ CHIP_ERROR AppTask::Init()
sStatusLED.Init(SYSTEM_STATE_LED);
sLightLED.Init(LIGHT_LED);
sLightLED.Set(LightMgr().IsLightOn());
UpdateClusterState();

ConfigurationMgr().LogDeviceConfig();

Expand Down Expand Up @@ -445,7 +450,7 @@ void AppTask::ActionCompleted(LightingManager::Action_t aAction)

if (sAppTask.mSyncClusterToButtonAction)
{
UpdateClusterState();
chip::DeviceLayer::PlatformMgr().ScheduleWork(UpdateClusterState, reinterpret_cast<intptr_t>(nullptr));
sAppTask.mSyncClusterToButtonAction = false;
}
}
Expand Down Expand Up @@ -504,7 +509,7 @@ void AppTask::DispatchEvent(AppEvent * aEvent)
}
}

void AppTask::UpdateClusterState(void)
void AppTask::UpdateClusterState(intptr_t context)
{
uint8_t newValue = LightMgr().IsLightOn();

Expand Down
6 changes: 0 additions & 6 deletions examples/lock-app/p6/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,3 @@ import("${chip_root}/src/platform/P6/args.gni")

p6_target_project =
get_label_info(":lock_app_sdk_sources", "label_no_toolchain")

declare_args() {
# Disable lock tracking, since our FreeRTOS configuration does not set
# INCLUDE_xSemaphoreGetMutexHolder
chip_stack_lock_tracking = "none"
}
2 changes: 2 additions & 0 deletions examples/lock-app/p6/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class AppTask
static void LockActionEventHandler(AppEvent * event);
static void TimerEventHandler(TimerHandle_t timer);

static void UpdateCluster(intptr_t context);

void StartTimer(uint32_t aTimeoutMs);

enum class Function
Expand Down
23 changes: 17 additions & 6 deletions examples/lock-app/p6/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ void NetWorkCommissioningInstInit()
sWiFiNetworkCommissioningInstance.Init();
}

static void InitServer(intptr_t context)
{
// Init ZCL Data Model
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
}

CHIP_ERROR AppTask::StartAppTask()
{
sAppEventQueue = xQueueCreate(APP_EVENT_QUEUE_SIZE, sizeof(AppEvent));
Expand Down Expand Up @@ -115,11 +124,8 @@ CHIP_ERROR AppTask::Init()
}
},
0);
// Init ZCL Data Model
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast<intptr_t>(nullptr));

// Initialise WSTK buttons PB0 and PB1 (including debounce).
ButtonHandler::Init();
Expand Down Expand Up @@ -151,7 +157,6 @@ CHIP_ERROR AppTask::Init()
sStatusLED.Init(SYSTEM_STATE_LED);
sLockLED.Init(LOCK_STATE_LED);
sLockLED.Set(!BoltLockMgr().IsUnlocked());
UpdateClusterState();

ConfigurationMgr().LogDeviceConfig();

Expand Down Expand Up @@ -490,7 +495,7 @@ void AppTask::DispatchEvent(AppEvent * event)
}
}

void AppTask::UpdateClusterState(void)
void AppTask::UpdateCluster(intptr_t context)
{
uint8_t newValue = !BoltLockMgr().IsUnlocked();

Expand All @@ -502,6 +507,12 @@ void AppTask::UpdateClusterState(void)
P6_LOG("ERR: updating on/off %x", status);
}
}

void AppTask::UpdateClusterState(void)
{
chip::DeviceLayer::PlatformMgr().ScheduleWork(UpdateCluster, reinterpret_cast<intptr_t>(nullptr));
}

void vApplicationStackOverflowHook(TaskHandle_t pxTask, char * pcTaskName)
{
(void) pxTask;
Expand Down
4 changes: 2 additions & 2 deletions examples/ota-requestor-app/p6/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ will then join the network.

* Build the P6 OTA Requestor application from the chip root dir:

$ ./examples/ota-requestor-app/examples/ota_base_build.sh
$ ./examples/ota-requestor-app/p6/ota_base_build.sh

* Build the P6 OTA Update application from the chip root dir:

$ ./examples/ota-requestor-app/examples/ota_update_build.sh
$ ./examples/ota-requestor-app/p6/ota_update_build.sh

* On a RPi4: Build the Linux OTA Provider application from the chip root dir:

Expand Down
4 changes: 0 additions & 4 deletions examples/ota-requestor-app/p6/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ import("${chip_root}/src/platform/P6/args.gni")

declare_args() {
chip_enable_ota_requestor = true

# Disable lock tracking, since our FreeRTOS configuration does not set
# INCLUDE_xSemaphoreGetMutexHolder
chip_stack_lock_tracking = "none"
}

p6_target_project =
Expand Down
14 changes: 10 additions & 4 deletions examples/ota-requestor-app/p6/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ void NetWorkCommissioningInstInit()
sWiFiNetworkCommissioningInstance.Init();
}

static void InitServer(intptr_t context)
{
// Init ZCL Data Model
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
}

CHIP_ERROR AppTask::StartAppTask()
{
sAppEventQueue = xQueueCreateStatic(APP_EVENT_QUEUE_SIZE, sizeof(AppEvent), sAppEventQueueBuffer, &sAppEventQueueStruct);
Expand Down Expand Up @@ -151,11 +160,8 @@ CHIP_ERROR AppTask::Init()
}
},
0);
// Init ZCL Data Model
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast<intptr_t>(nullptr));

// Initialise WSTK buttons PB0 and PB1 (including debounce).
ButtonHandler::Init();
Expand Down
1 change: 1 addition & 0 deletions third_party/p6/p6_sdk/configs/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ to exclude the API function. */
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskIsTaskFinished 1
#define INCLUDE_xTimerPendFunctionCall 1
#define INCLUDE_xSemaphoreGetMutexHolder 1

/* Normal assert() semantics without relying on the provision of an assert.h
header file. */
Expand Down

0 comments on commit f05afad

Please sign in to comment.