Skip to content

Commit 5382830

Browse files
jmartinez-silabspull[bot]
authored andcommitted
[Silabs] Consolidated Identify callback implementation to common file (#26928)
* Fix identify server callbacks in silabs app. Move app code to the common BaseApplication. (lighting-app done) * Remove identify callbacks implementation from the remaining silabs appTask.cpp * remove invalid cast on qpg platform
1 parent 53020e7 commit 5382830

File tree

15 files changed

+204
-576
lines changed

15 files changed

+204
-576
lines changed

examples/chef/silabs/include/AppTask.h

-15
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include "BaseApplication.h"
3131
#include "FreeRTOS.h"
3232
#include "timers.h" // provides FreeRTOS timer support
33-
#include <app/clusters/identify-server/identify-server.h>
3433
#include <ble/BLEEndPoint.h>
3534
#include <lib/core/CHIPError.h>
3635
#include <platform/CHIPDeviceLayer.h>
@@ -78,20 +77,6 @@ class AppTask : public BaseApplication
7877
*/
7978
static void ButtonEventHandler(uint8_t button, uint8_t btnAction) override;
8079

81-
/**
82-
* @brief Callback called by the identify-server when an identify command is received
83-
*
84-
* @param identify identify structure the command applies on
85-
*/
86-
static void OnIdentifyStart(Identify * identify);
87-
88-
/**
89-
* @brief Callback called by the identify-server when an identify command is stopped or finished
90-
*
91-
* @param identify identify structure the command applies on
92-
*/
93-
static void OnIdentifyStop(Identify * identify);
94-
9580
private:
9681
static AppTask sAppTask;
9782

examples/chef/silabs/src/AppTask.cpp

+1-66
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@
3535
#include <app/util/attribute-storage.h>
3636
#include <app/util/config.h>
3737

38-
#ifdef EMBER_AF_PLUGIN_IDENTIFY_SERVER
39-
#include <app/clusters/identify-server/identify-server.h>
40-
#endif
41-
4238
#include <assert.h>
4339

4440
#include <platform/silabs/platformAbstraction/SilabsPlatform.h>
@@ -57,67 +53,6 @@ using namespace chip;
5753
using namespace chip::app;
5854
using namespace ::chip::DeviceLayer;
5955

60-
namespace {
61-
62-
#ifdef EMBER_AF_PLUGIN_IDENTIFY_SERVER
63-
Clusters::Identify::EffectIdentifierEnum sIdentifyEffect = Clusters::Identify::EffectIdentifierEnum::kStopEffect;
64-
#endif // EMBER_AF_PLUGIN_IDENTIFY_SERVER
65-
66-
namespace {
67-
#ifdef EMBER_AF_PLUGIN_IDENTIFY_SERVER
68-
void OnTriggerIdentifyEffectCompleted(chip::System::Layer * systemLayer, void * appState)
69-
{
70-
sIdentifyEffect = Clusters::Identify::EffectIdentifierEnum::kStopEffect;
71-
}
72-
#endif // EMBER_AF_PLUGIN_IDENTIFY_SERVER
73-
} // namespace
74-
75-
#ifdef EMBER_AF_PLUGIN_IDENTIFY_SERVER
76-
void OnTriggerIdentifyEffect(Identify * identify)
77-
{
78-
sIdentifyEffect = identify->mCurrentEffectIdentifier;
79-
80-
if (identify->mCurrentEffectIdentifier == Clusters::Identify::EffectIdentifierEnum::kChannelChange)
81-
{
82-
ChipLogProgress(Zcl, "IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE - Not supported, use effect varriant %d",
83-
to_underlying(identify->mEffectVariant));
84-
sIdentifyEffect = static_cast<Clusters::Identify::EffectIdentifierEnum>(identify->mEffectVariant);
85-
}
86-
87-
switch (sIdentifyEffect)
88-
{
89-
case Clusters::Identify::EffectIdentifierEnum::kBlink:
90-
case Clusters::Identify::EffectIdentifierEnum::kBreathe:
91-
case Clusters::Identify::EffectIdentifierEnum::kOkay:
92-
(void) chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(5), OnTriggerIdentifyEffectCompleted,
93-
identify);
94-
break;
95-
case Clusters::Identify::EffectIdentifierEnum::kFinishEffect:
96-
(void) chip::DeviceLayer::SystemLayer().CancelTimer(OnTriggerIdentifyEffectCompleted, identify);
97-
(void) chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(1), OnTriggerIdentifyEffectCompleted,
98-
identify);
99-
break;
100-
case Clusters::Identify::EffectIdentifierEnum::kStopEffect:
101-
(void) chip::DeviceLayer::SystemLayer().CancelTimer(OnTriggerIdentifyEffectCompleted, identify);
102-
sIdentifyEffect = Clusters::Identify::EffectIdentifierEnum::kStopEffect;
103-
break;
104-
default:
105-
ChipLogProgress(Zcl, "No identifier effect");
106-
}
107-
}
108-
#endif // EMBER_AF_PLUGIN_IDENTIFY_SERVER
109-
110-
#ifdef EMBER_AF_PLUGIN_IDENTIFY_SERVER
111-
Identify gIdentify = {
112-
chip::EndpointId{ 1 },
113-
[](Identify *) { ChipLogProgress(Zcl, "onIdentifyStart"); },
114-
[](Identify *) { ChipLogProgress(Zcl, "onIdentifyStop"); },
115-
Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator,
116-
OnTriggerIdentifyEffect,
117-
};
118-
#endif // EMBER_AF_PLUGIN_IDENTIFY_SERVER
119-
120-
} // namespace
12156
using namespace chip::TLV;
12257
using namespace ::chip::DeviceLayer;
12358

@@ -128,7 +63,7 @@ CHIP_ERROR AppTask::Init()
12863
CHIP_ERROR err = CHIP_NO_ERROR;
12964
chip::DeviceLayer::Silabs::GetPlatform().SetButtonsCb(AppTask::ButtonEventHandler);
13065

131-
err = BaseApplication::Init(&gIdentify);
66+
err = BaseApplication::Init();
13267
if (err != CHIP_NO_ERROR)
13368
{
13469
SILABS_LOG("BaseApplication::Init() failed");

examples/light-switch-app/silabs/include/AppTask.h

-15
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include "BaseApplication.h"
3131
#include "FreeRTOS.h"
3232
#include "timers.h" // provides FreeRTOS timer support
33-
#include <app/clusters/identify-server/identify-server.h>
3433
#include <ble/BLEEndPoint.h>
3534
#include <lib/core/CHIPError.h>
3635
#include <platform/CHIPDeviceLayer.h>
@@ -78,20 +77,6 @@ class AppTask : public BaseApplication
7877
*/
7978
static void ButtonEventHandler(uint8_t button, uint8_t btnAction);
8079

81-
/**
82-
* @brief Callback called by the identify-server when an identify command is received
83-
*
84-
* @param identify identify structure the command applies on
85-
*/
86-
static void OnIdentifyStart(Identify * identify);
87-
88-
/**
89-
* @brief Callback called by the identify-server when an identify command is stopped or finished
90-
*
91-
* @param identify identify structure the command applies on
92-
*/
93-
static void OnIdentifyStop(Identify * identify);
94-
9580
private:
9681
static AppTask sAppTask;
9782

examples/light-switch-app/silabs/src/AppTask.cpp

+1-95
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@
4646
#include <setup_payload/QRCodeSetupPayloadGenerator.h>
4747
#include <setup_payload/SetupPayload.h>
4848

49-
#include <app/clusters/identify-server/identify-server.h>
50-
5149
#include <platform/silabs/platformAbstraction/SilabsPlatform.h>
5250

5351
/**********************************************************
@@ -60,89 +58,15 @@
6058
#define APP_LIGHT_SWITCH 1
6159

6260
namespace {
63-
6461
constexpr chip::EndpointId kLightSwitchEndpoint = 1;
6562
constexpr chip::EndpointId kGenericSwitchEndpoint = 2;
66-
6763
} // namespace
6864

6965
using namespace chip;
7066
using namespace chip::app;
7167
using namespace ::chip::DeviceLayer;
7268
using namespace ::chip::DeviceLayer::Silabs;
7369

74-
namespace {
75-
76-
/**********************************************************
77-
* Variable declarations
78-
*********************************************************/
79-
80-
Clusters::Identify::EffectIdentifierEnum sIdentifyEffect = Clusters::Identify::EffectIdentifierEnum::kStopEffect;
81-
82-
/**********************************************************
83-
* Identify Callbacks
84-
*********************************************************/
85-
86-
namespace {
87-
void OnTriggerIdentifyEffectCompleted(chip::System::Layer * systemLayer, void * appState)
88-
{
89-
ChipLogProgress(Zcl, "Trigger Identify Complete");
90-
sIdentifyEffect = Clusters::Identify::EffectIdentifierEnum::kStopEffect;
91-
92-
#if CHIP_DEVICE_CONFIG_ENABLE_SED == 1
93-
AppTask::GetAppTask().StopStatusLEDTimer();
94-
#endif
95-
}
96-
} // namespace
97-
98-
void OnTriggerIdentifyEffect(Identify * identify)
99-
{
100-
ChipLogProgress(Zcl, "Trigger Identify Effect");
101-
sIdentifyEffect = identify->mCurrentEffectIdentifier;
102-
103-
if (identify->mCurrentEffectIdentifier == Clusters::Identify::EffectIdentifierEnum::kChannelChange)
104-
{
105-
ChipLogProgress(Zcl, "IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE - Not supported, use effect varriant %d",
106-
to_underlying(identify->mEffectVariant));
107-
sIdentifyEffect = static_cast<Clusters::Identify::EffectIdentifierEnum>(identify->mEffectVariant);
108-
}
109-
110-
#if CHIP_DEVICE_CONFIG_ENABLE_SED == 1
111-
AppTask::GetAppTask().StartStatusLEDTimer();
112-
#endif
113-
114-
switch (sIdentifyEffect)
115-
{
116-
case Clusters::Identify::EffectIdentifierEnum::kBlink:
117-
case Clusters::Identify::EffectIdentifierEnum::kBreathe:
118-
case Clusters::Identify::EffectIdentifierEnum::kOkay:
119-
(void) chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(5), OnTriggerIdentifyEffectCompleted,
120-
identify);
121-
break;
122-
case Clusters::Identify::EffectIdentifierEnum::kFinishEffect:
123-
(void) chip::DeviceLayer::SystemLayer().CancelTimer(OnTriggerIdentifyEffectCompleted, identify);
124-
(void) chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(1), OnTriggerIdentifyEffectCompleted,
125-
identify);
126-
break;
127-
case Clusters::Identify::EffectIdentifierEnum::kStopEffect:
128-
(void) chip::DeviceLayer::SystemLayer().CancelTimer(OnTriggerIdentifyEffectCompleted, identify);
129-
sIdentifyEffect = Clusters::Identify::EffectIdentifierEnum::kStopEffect;
130-
break;
131-
default:
132-
ChipLogProgress(Zcl, "No identifier effect");
133-
}
134-
}
135-
136-
Identify gIdentify = {
137-
chip::EndpointId{ 1 },
138-
AppTask::GetAppTask().OnIdentifyStart,
139-
AppTask::GetAppTask().OnIdentifyStop,
140-
Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator,
141-
OnTriggerIdentifyEffect,
142-
};
143-
144-
} // namespace
145-
14670
using namespace chip::TLV;
14771
using namespace ::chip::DeviceLayer;
14872

@@ -161,7 +85,7 @@ CHIP_ERROR AppTask::Init()
16185
GetLCD().Init((uint8_t *) "Light Switch");
16286
#endif
16387

164-
err = BaseApplication::Init(&gIdentify);
88+
err = BaseApplication::Init();
16589
if (err != CHIP_NO_ERROR)
16690
{
16791
SILABS_LOG("BaseApplication::Init() failed");
@@ -211,24 +135,6 @@ void AppTask::AppTaskMain(void * pvParameter)
211135
}
212136
}
213137

214-
void AppTask::OnIdentifyStart(Identify * identify)
215-
{
216-
ChipLogProgress(Zcl, "onIdentifyStart");
217-
218-
#if CHIP_DEVICE_CONFIG_ENABLE_SED == 1
219-
sAppTask.StartStatusLEDTimer();
220-
#endif
221-
}
222-
223-
void AppTask::OnIdentifyStop(Identify * identify)
224-
{
225-
ChipLogProgress(Zcl, "onIdentifyStop");
226-
227-
#if CHIP_DEVICE_CONFIG_ENABLE_SED == 1
228-
sAppTask.StopStatusLEDTimer();
229-
#endif
230-
}
231-
232138
void AppTask::SwitchActionEventHandler(AppEvent * aEvent)
233139
{
234140
VerifyOrReturn(aEvent->Type == AppEvent::kEventType_Button);

examples/lighting-app/qpg/src/AppTask.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,17 @@ void OnTriggerIdentifyEffect(Identify * identify)
108108
{
109109
sIdentifyEffect = identify->mCurrentEffectIdentifier;
110110

111-
if (identify->mCurrentEffectIdentifier == Clusters::Identify::EffectIdentifierEnum::kChannelChange)
111+
if (identify->mEffectVariant != Clusters::Identify::EffectVariantEnum::kDefault)
112112
{
113-
ChipLogProgress(Zcl, "IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE - Not supported, use effect variant %d",
114-
to_underlying(identify->mEffectVariant));
115-
sIdentifyEffect = static_cast<Clusters::Identify::EffectIdentifierEnum>(identify->mEffectVariant);
113+
ChipLogDetail(AppServer, "Identify Effect Variant unsupported. Using default");
116114
}
117115

118116
switch (sIdentifyEffect)
119117
{
120118
case Clusters::Identify::EffectIdentifierEnum::kBlink:
121119
case Clusters::Identify::EffectIdentifierEnum::kBreathe:
122120
case Clusters::Identify::EffectIdentifierEnum::kOkay:
121+
case Clusters::Identify::EffectIdentifierEnum::kChannelChange:
123122
SystemLayer().ScheduleLambda([identify] {
124123
(void) chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(5), OnTriggerIdentifyEffectCompleted,
125124
identify);

examples/lighting-app/silabs/include/AppTask.h

-16
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include "FreeRTOS.h"
3232
#include "LightingManager.h"
3333
#include "timers.h" // provides FreeRTOS timer support
34-
#include <app/clusters/identify-server/identify-server.h>
3534
#include <ble/BLEEndPoint.h>
3635
#include <lib/core/CHIPError.h>
3736
#include <platform/CHIPDeviceLayer.h>
@@ -78,21 +77,6 @@ class AppTask : public BaseApplication
7877
* SL_SIMPLE_BUTTON_RELEASED or SL_SIMPLE_BUTTON_DISABLED
7978
*/
8079
static void ButtonEventHandler(uint8_t button, uint8_t btnAction);
81-
82-
/**
83-
* @brief Callback called by the identify-server when an identify command is received
84-
*
85-
* @param identify identify structure the command applies on
86-
*/
87-
static void OnIdentifyStart(Identify * identify);
88-
89-
/**
90-
* @brief Callback called by the identify-server when an identify command is stopped or finished
91-
*
92-
* @param identify identify structure the command applies on
93-
*/
94-
static void OnIdentifyStop(Identify * identify);
95-
9680
void PostLightActionRequest(int32_t aActor, LightingManager::Action_t aAction);
9781

9882
private:

0 commit comments

Comments
 (0)