Skip to content

Commit

Permalink
Support identify functionality in pump and pump controller (cc13x2x7_…
Browse files Browse the repository at this point in the history
…26x2x7) (#16826)

* Support identify functionality in pump and pump controller (cc13x2x7_26x2x7)

* Fixed style issues point out by restyle

* Fixed style issues point out by restyle v2

* Fixed style issues point out by restyle v3
  • Loading branch information
ReneJosefsen authored and pull[bot] committed Aug 25, 2023
1 parent cedcfbb commit 4e3372c
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 0 deletions.
70 changes: 70 additions & 0 deletions examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <platform/cc13x2_26x2/OTAImageProcessorImpl.h>
#endif
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/clusters/identify-server/identify-server.h>
#include <lib/support/CHIPMem.h>
#include <lib/support/CHIPPlatformMemory.h>
#include <platform/CHIPDeviceLayer.h>
Expand Down Expand Up @@ -95,6 +96,12 @@ void InitializeOTARequestor(void)
}
#endif

static const chip::EndpointId sIdentifyEndpointId = 0;
static const uint32_t sIdentifyBlinkRateMs = 500;

::Identify stIdentify = { sIdentifyEndpointId, AppTask::IdentifyStartHandler, AppTask::IdentifyStopHandler,
EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, AppTask::TriggerIdentifyEffectHandler };

int AppTask::StartAppTask()
{
int ret = 0;
Expand Down Expand Up @@ -385,6 +392,26 @@ void AppTask::DispatchEvent(AppEvent * aEvent)
}
break;

case AppEvent::kEventType_IdentifyStart:
LED_setOn(sAppGreenHandle, LED_BRIGHTNESS_MAX);
LED_startBlinking(sAppGreenHandle, sIdentifyBlinkRateMs, LED_BLINK_FOREVER);
PLAT_LOG("Identify started");
break;

case AppEvent::kEventType_IdentifyStop:
LED_stopBlinking(sAppGreenHandle);

if (!PumpMgr().IsStopped())
{
LED_setOn(sAppGreenHandle, LED_BRIGHTNESS_MAX);
}
else
{
LED_setOff(sAppGreenHandle);
}
PLAT_LOG("Identify stopped");
break;

case AppEvent::kEventType_AppEvent:
if (NULL != aEvent->Handler)
{
Expand Down Expand Up @@ -537,3 +564,46 @@ void AppTask::PostEvents()
}
}
}

void AppTask::IdentifyStartHandler(::Identify *)
{
AppEvent event;
event.Type = AppEvent::kEventType_IdentifyStart;
sAppTask.PostEvent(&event);
}

void AppTask::IdentifyStopHandler(::Identify *)
{
AppEvent event;
event.Type = AppEvent::kEventType_IdentifyStop;
sAppTask.PostEvent(&event);
}

void AppTask::TriggerIdentifyEffectHandler(::Identify * identify)
{
switch (identify->mCurrentEffectIdentifier)
{
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK:
PLAT_LOG("Starting blink identifier effect");
IdentifyStartHandler(identify);
break;
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE:
PLAT_LOG("Breathe identifier effect not implemented");
break;
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY:
PLAT_LOG("Okay identifier effect not implemented");
break;
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE:
PLAT_LOG("Channel Change identifier effect not implemented");
break;
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_FINISH_EFFECT:
PLAT_LOG("Finish identifier effect not implemented");
break;
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT:
PLAT_LOG("Stop identifier effect");
IdentifyStopHandler(identify);
break;
default:
PLAT_LOG("No identifier effect");
}
}
2 changes: 2 additions & 0 deletions examples/pump-app/cc13x2x7_26x2x7/main/include/AppEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ struct AppEvent
kEventType_ButtonLeft,
kEventType_ButtonRight,
kEventType_AppEvent,
kEventType_IdentifyStart,
kEventType_IdentifyStop,
};

enum AppEventButtonType
Expand Down
6 changes: 6 additions & 0 deletions examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

#include <ti/drivers/apps/Button.h>

struct Identify;

class AppTask
{
public:
Expand All @@ -43,6 +45,10 @@ class AppTask
void InitOnOffClusterState();
void InitPCCClusterState();

static void IdentifyStartHandler(::Identify *);
static void IdentifyStopHandler(::Identify *);
static void TriggerIdentifyEffectHandler(::Identify * identify);

private:
friend AppTask & GetAppTask(void);

Expand Down
70 changes: 70 additions & 0 deletions examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <platform/cc13x2_26x2/OTAImageProcessorImpl.h>
#endif
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/clusters/identify-server/identify-server.h>
#include <lib/support/CHIPMem.h>
#include <lib/support/CHIPPlatformMemory.h>
#include <platform/CHIPDeviceLayer.h>
Expand Down Expand Up @@ -87,6 +88,12 @@ void InitializeOTARequestor(void)
}
#endif

static const chip::EndpointId sIdentifyEndpointId = 0;
static const uint32_t sIdentifyBlinkRateMs = 500;

::Identify stIdentify = { sIdentifyEndpointId, AppTask::IdentifyStartHandler, AppTask::IdentifyStopHandler,
EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, AppTask::TriggerIdentifyEffectHandler };

int AppTask::StartAppTask()
{
int ret = 0;
Expand Down Expand Up @@ -370,6 +377,26 @@ void AppTask::DispatchEvent(AppEvent * aEvent)
}
break;

case AppEvent::kEventType_IdentifyStart:
LED_setOn(sAppGreenHandle, LED_BRIGHTNESS_MAX);
LED_startBlinking(sAppGreenHandle, sIdentifyBlinkRateMs, LED_BLINK_FOREVER);
PLAT_LOG("Identify started");
break;

case AppEvent::kEventType_IdentifyStop:
LED_stopBlinking(sAppGreenHandle);

if (!PumpMgr().IsStopped())
{
LED_setOn(sAppGreenHandle, LED_BRIGHTNESS_MAX);
}
else
{
LED_setOff(sAppGreenHandle);
}
PLAT_LOG("Identify stopped");
break;

case AppEvent::kEventType_AppEvent:
if (NULL != aEvent->Handler)
{
Expand All @@ -384,3 +411,46 @@ void AppTask::DispatchEvent(AppEvent * aEvent)
}

void AppTask::UpdateClusterState() {}

void AppTask::IdentifyStartHandler(::Identify *)
{
AppEvent event;
event.Type = AppEvent::kEventType_IdentifyStart;
sAppTask.PostEvent(&event);
}

void AppTask::IdentifyStopHandler(::Identify *)
{
AppEvent event;
event.Type = AppEvent::kEventType_IdentifyStop;
sAppTask.PostEvent(&event);
}

void AppTask::TriggerIdentifyEffectHandler(::Identify * identify)
{
switch (identify->mCurrentEffectIdentifier)
{
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK:
PLAT_LOG("Starting blink identifier effect");
IdentifyStartHandler(identify);
break;
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE:
PLAT_LOG("Breathe identifier effect not implemented");
break;
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY:
PLAT_LOG("Okay identifier effect not implemented");
break;
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE:
PLAT_LOG("Channel Change identifier effect not implemented");
break;
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_FINISH_EFFECT:
PLAT_LOG("Finish identifier effect not implemented");
break;
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT:
PLAT_LOG("Stop identifier effect");
IdentifyStopHandler(identify);
break;
default:
PLAT_LOG("No identifier effect");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ struct AppEvent
kEventType_ButtonLeft,
kEventType_ButtonRight,
kEventType_AppEvent,
kEventType_IdentifyStart,
kEventType_IdentifyStop,
};

enum AppEventButtonType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

#include <ti/drivers/apps/Button.h>

struct Identify;

class AppTask
{
public:
Expand All @@ -41,6 +43,10 @@ class AppTask
void PostEvent(const AppEvent * event);
void UpdateClusterState();

static void IdentifyStartHandler(::Identify *);
static void IdentifyStopHandler(::Identify *);
static void TriggerIdentifyEffectHandler(::Identify * identify);

private:
friend AppTask & GetAppTask(void);

Expand Down

0 comments on commit 4e3372c

Please sign in to comment.