Skip to content

Commit

Permalink
[pump-app] Add PCC Event example (#13081)
Browse files Browse the repository at this point in the history
* WIP

* WIP

* Disabled unrelevant diagnostics clusters to free up space for the code to build

* Added an example of event usage for the PPC cluster

* Reverted unintended changes to tasks.json

* Changed comments and log output for PCC event posting

* Fixed zap configuration and heap size to the app builds and runs

* Enabled Software diagnostics cluster and fixed submodule version

* Removed unused protope from platformmanager

* Corrected a LF

* Restyled by whitespace

Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
2 people authored and pull[bot] committed Feb 26, 2024
1 parent cef0dca commit 1069842
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 209 deletions.
31 changes: 27 additions & 4 deletions examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <credentials/DeviceAttestationCredsProvider.h>
#include <credentials/examples/DeviceAttestationCredsExample.h>

#include <app/EventLogging.h>
#include <app/util/af-types.h>
#include <app/util/af.h>

Expand All @@ -55,9 +56,11 @@
#define ONOFF_CLUSTER_ENDPOINT 1
#define EXTENDED_DISCOVERY_TIMEOUT_SEC 20

using namespace ::chip::Credentials;
using namespace ::chip::DeviceLayer;
using namespace ::chip::app::Clusters;
using namespace chip;
using namespace chip::app;
using namespace chip::Credentials;
using namespace chip::DeviceLayer;
using namespace chip::app::Clusters;

static TaskHandle_t sAppTaskHandle;
static QueueHandle_t sAppEventQueue;
Expand Down Expand Up @@ -325,12 +328,15 @@ void AppTask::DispatchEvent(AppEvent * aEvent)
case AppEvent::kEventType_ButtonLeft:
if (AppEvent::kAppEventButtonType_Clicked == aEvent->ButtonEvent.Type)
{
// Post event for demonstration purposes
sAppTask.PostEvents();

// Toggle BLE advertisements
if (!ConnectivityMgr().IsBLEAdvertisingEnabled())
{
if (chip::Server::GetInstance().GetCommissioningWindowManager().OpenBasicCommissioningWindow() == CHIP_NO_ERROR)
{
PLAT_LOG("Enabled BLE Advertisement");
PLAT_LOG("Enabled BLE Advertisements");
}
else
{
Expand Down Expand Up @@ -485,3 +491,20 @@ void AppTask::UpdateClusterState()
ChipLogError(NotSpecified, "ERR: Updating MaxConstTemp %" PRIx8, status);
}
}

void AppTask::PostEvents()
{
// Example on posting events - here we post the general fault event on endpoints with PCC Server enabled
for (auto endpoint : EnabledEndpointsWithServerCluster(PumpConfigurationAndControl::Id))
{
PumpConfigurationAndControl::Events::GeneralFault::Type event;
EventNumber eventNumber;

ChipLogProgress(Zcl, "AppTask: Post PCC GeneralFault event");
// Using default priority for the event
if (CHIP_NO_ERROR != LogEvent(event, endpoint, eventNumber))
{
ChipLogError(Zcl, "AppTask: Failed to record GeneralFault event");
}
}
}
1 change: 1 addition & 0 deletions examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class AppTask
static void ButtonLeftEventHandler(Button_Handle handle, Button_EventMask events);
static void ButtonRightEventHandler(Button_Handle handle, Button_EventMask events);
static void TimerEventHandler(void * p_context);
static void PostEvents();

enum Function_t
{
Expand Down
2 changes: 1 addition & 1 deletion examples/pump-app/cc13x2x7_26x2x7/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <ti/drivers/SHA2.h>

#include <bget.h>
#define TOTAL_ICALL_HEAP_SIZE (0xE000)
#define TOTAL_ICALL_HEAP_SIZE (0xCB00)

using namespace ::chip;
using namespace ::chip::Inet;
Expand Down
4 changes: 2 additions & 2 deletions examples/pump-app/pump-common/pump-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -2906,7 +2906,7 @@
"mfgCode": null,
"define": "WIFI_NETWORK_DIAGNOSTICS_CLUSTER",
"side": "server",
"enabled": 1,
"enabled": 0,
"commands": [],
"attributes": [
{
Expand Down Expand Up @@ -3177,7 +3177,7 @@
"mfgCode": null,
"define": "ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER",
"side": "server",
"enabled": 1,
"enabled": 0,
"commands": [],
"attributes": [
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 0 additions & 16 deletions zzz_generated/pump-app/zap-generated/callback-stub.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1069842

Please sign in to comment.