Skip to content

Commit

Permalink
[Telink] Use LED for Identify
Browse files Browse the repository at this point in the history
  • Loading branch information
s07641069 committed May 13, 2024
1 parent 4804fa0 commit 1622e71
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 4 additions & 0 deletions examples/platform/telink/common/include/AppTaskCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class LedManager;
class PwmManager;
class ButtonManager;

struct Identify;

class AppTaskCommon
{
public:
Expand All @@ -66,6 +68,8 @@ class AppTaskCommon
void PostEvent(AppEvent * event);

static void IdentifyEffectHandler(Clusters::Identify::EffectIdentifierEnum aEffect);
static void IdentifyStartHandler(Identify *);
static void IdentifyStopHandler(Identify *);

#ifdef CONFIG_CHIP_PW_RPC
enum ButtonId_t
Expand Down
28 changes: 26 additions & 2 deletions examples/platform/telink/common/src/AppTaskCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ void OnIdentifyTriggerEffect(Identify * identify)

Identify sIdentify = {
kExampleEndpointId,
[](Identify *) { ChipLogProgress(Zcl, "OnIdentifyStart"); },
[](Identify *) { ChipLogProgress(Zcl, "OnIdentifyStop"); },
AppTask::IdentifyStartHandler,
AppTask::IdentifyStopHandler,
Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator,
OnIdentifyTriggerEffect,
};
Expand Down Expand Up @@ -319,6 +319,30 @@ CHIP_ERROR AppTaskCommon::InitCommonParts(void)
return CHIP_NO_ERROR;
}

void AppTaskCommon::IdentifyStartHandler(Identify *)
{
AppEvent event;

event.Type = AppEvent::kEventType_IdentifyStart;
event.Handler = [](AppEvent *event) {
ChipLogProgress(Zcl, "OnIdentifyStart");
PwmManager::getInstance().setPwmBlink(PwmManager::EAppPwm_Indication, kIdentifyBlinkRateMs, kIdentifyBlinkRateMs);
};
GetAppTask().PostEvent(&event);
}

void AppTaskCommon::IdentifyStopHandler(Identify *)
{
AppEvent event;

event.Type = AppEvent::kEventType_IdentifyStop;
event.Handler = [](AppEvent *event) {
ChipLogProgress(Zcl, "OnIdentifyStop");
PwmManager::getInstance().setPwm(PwmManager::EAppPwm_Indication, false);
};
GetAppTask().PostEvent(&event);
}

#ifdef CONFIG_CHIP_PW_RPC
void AppTaskCommon::ButtonEventHandler(ButtonId_t btnId, bool btnPressed)
{
Expand Down

0 comments on commit 1622e71

Please sign in to comment.