diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp index 8ae03f6840b944..f7aaf1e016e129 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -39,6 +39,7 @@ #include #endif #include +#include #include #include #include @@ -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; @@ -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) { @@ -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"); + } +} diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/include/AppEvent.h b/examples/pump-app/cc13x2x7_26x2x7/main/include/AppEvent.h index 14c9f045231e2a..0f501990b2ab76 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/include/AppEvent.h +++ b/examples/pump-app/cc13x2x7_26x2x7/main/include/AppEvent.h @@ -30,6 +30,8 @@ struct AppEvent kEventType_ButtonLeft, kEventType_ButtonRight, kEventType_AppEvent, + kEventType_IdentifyStart, + kEventType_IdentifyStop, }; enum AppEventButtonType diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h b/examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h index dfe9f4a7ecf6fc..08de0237f5b466 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h +++ b/examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h @@ -31,6 +31,8 @@ #include +struct Identify; + class AppTask { public: @@ -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); diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp index 0e77a4a735f0b6..74cbe0d966f161 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -37,6 +37,7 @@ #include #endif #include +#include #include #include #include @@ -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; @@ -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) { @@ -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"); + } +} diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppEvent.h b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppEvent.h index 14c9f045231e2a..0f501990b2ab76 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppEvent.h +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppEvent.h @@ -30,6 +30,8 @@ struct AppEvent kEventType_ButtonLeft, kEventType_ButtonRight, kEventType_AppEvent, + kEventType_IdentifyStart, + kEventType_IdentifyStop, }; enum AppEventButtonType diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppTask.h b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppTask.h index 11e402ebe3bcb9..bf13d20bca6ee6 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppTask.h +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppTask.h @@ -31,6 +31,8 @@ #include +struct Identify; + class AppTask { public: @@ -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);