Skip to content

Commit 1179cb6

Browse files
samples: matter: Fix identify on EP1 in Matter Bridge App
The identify cluster was enabled for EP1 in Matter Bridge App, whereas it was not implemented in the code. Signed-off-by: Arkadiusz Balys <[email protected]>
1 parent 414a956 commit 1179cb6

File tree

4 files changed

+102
-8
lines changed

4 files changed

+102
-8
lines changed

applications/matter_bridge/src/app_task.cpp

Lines changed: 83 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <app-common/zap-generated/attributes/Accessors.h>
2626
#include <app-common/zap-generated/ids/Attributes.h>
2727
#include <app-common/zap-generated/ids/Clusters.h>
28+
#include <app/clusters/identify-server/identify-server.h>
2829
#include <setup_payload/OnboardingCodesUtil.h>
2930

3031
#ifdef CONFIG_BRIDGED_DEVICE_BT
@@ -41,21 +42,32 @@ LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL);
4142
using namespace ::chip;
4243
using namespace ::chip::app;
4344
using namespace ::chip::DeviceLayer;
45+
4446
namespace
4547
{
4648

49+
constexpr EndpointId kBridgeEndpointId = 1;
50+
constexpr uint16_t kTriggerEffectTimeout = 5000;
51+
constexpr uint16_t kTriggerEffectFinishTimeout = 1000;
52+
53+
k_timer sTriggerEffectTimer;
54+
bool sIsTriggerEffectActive;
55+
56+
Identify sIdentify = { kBridgeEndpointId, AppTask::IdentifyStartHandler, AppTask::IdentifyStopHandler,
57+
Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator, AppTask::TriggerIdentifyEffectHandler };
58+
4759
#ifdef CONFIG_BRIDGED_DEVICE_BT
48-
static const bt_uuid *sUuidLbs = BT_UUID_LBS;
49-
static const bt_uuid *sUuidEs = BT_UUID_ESS;
50-
static const bt_uuid *sUuidServices[] = { sUuidLbs, sUuidEs };
51-
static constexpr uint8_t kUuidServicesNumber = ARRAY_SIZE(sUuidServices);
60+
const bt_uuid *sUuidLbs = BT_UUID_LBS;
61+
const bt_uuid *sUuidEs = BT_UUID_ESS;
62+
const bt_uuid *sUuidServices[] = { sUuidLbs, sUuidEs };
63+
constexpr uint8_t kUuidServicesNumber = ARRAY_SIZE(sUuidServices);
5264
/**
5365
* @brief Blink rates for indication the BLE Connectivity Manager state.
5466
*
5567
*/
56-
constexpr static uint32_t kPairingBlinkRate{ 100 };
57-
constexpr static uint32_t kScanningBlinkRate_ms{ 300 };
58-
constexpr static uint32_t kLostBlinkRate_ms{ 1000 };
68+
constexpr uint32_t kPairingBlinkRate{ 100 };
69+
constexpr uint32_t kScanningBlinkRate_ms{ 300 };
70+
constexpr uint32_t kLostBlinkRate_ms{ 1000 };
5971
#ifndef CONFIG_BRIDGE_SMART_PLUG_SUPPORT
6072
void BLEStateChangeCallback(Nrf::BLEConnectivityManager::State state)
6173
{
@@ -103,6 +115,67 @@ void AppFactoryResetHandler(const ChipDeviceEvent *event, intptr_t /* unused */)
103115

104116
} /* namespace */
105117

118+
void AppTask::IdentifyStartHandler(Identify *)
119+
{
120+
Nrf::PostTask(
121+
[] { Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED2).Blink(Nrf::LedConsts::kIdentifyBlinkRate_ms); });
122+
}
123+
124+
void AppTask::IdentifyStopHandler(Identify *)
125+
{
126+
Nrf::PostTask([] {
127+
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED2).Set(false);
128+
});
129+
}
130+
131+
void AppTask::TriggerEffectTimerTimeoutCallback(k_timer *timer)
132+
{
133+
LOG_INF("Identify effect completed");
134+
135+
sIsTriggerEffectActive = false;
136+
137+
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED2).Set(false);
138+
139+
}
140+
141+
void AppTask::TriggerIdentifyEffectHandler(Identify *identify)
142+
{
143+
switch (identify->mCurrentEffectIdentifier) {
144+
/* Just handle all effects in the same way. */
145+
case Clusters::Identify::EffectIdentifierEnum::kBlink:
146+
case Clusters::Identify::EffectIdentifierEnum::kBreathe:
147+
case Clusters::Identify::EffectIdentifierEnum::kOkay:
148+
case Clusters::Identify::EffectIdentifierEnum::kChannelChange:
149+
LOG_INF("Identify effect identifier changed to %d",
150+
static_cast<uint8_t>(identify->mCurrentEffectIdentifier));
151+
152+
sIsTriggerEffectActive = false;
153+
154+
k_timer_stop(&sTriggerEffectTimer);
155+
k_timer_start(&sTriggerEffectTimer, K_MSEC(kTriggerEffectTimeout), K_NO_WAIT);
156+
157+
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED2).Blink(Nrf::LedConsts::kIdentifyBlinkRate_ms);
158+
break;
159+
case Clusters::Identify::EffectIdentifierEnum::kFinishEffect:
160+
LOG_INF("Identify effect finish triggered");
161+
k_timer_stop(&sTriggerEffectTimer);
162+
k_timer_start(&sTriggerEffectTimer, K_MSEC(kTriggerEffectFinishTimeout), K_NO_WAIT);
163+
break;
164+
case Clusters::Identify::EffectIdentifierEnum::kStopEffect:
165+
if (sIsTriggerEffectActive) {
166+
sIsTriggerEffectActive = false;
167+
168+
k_timer_stop(&sTriggerEffectTimer);
169+
170+
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED2).Set(false);
171+
}
172+
break;
173+
default:
174+
LOG_ERR("Received invalid effect identifier.");
175+
break;
176+
}
177+
}
178+
106179
CHIP_ERROR AppTask::RestoreBridgedDevices()
107180
{
108181
uint8_t count;
@@ -216,6 +289,9 @@ CHIP_ERROR AppTask::Init()
216289
ReturnErrorOnFailure(Nrf::Matter::RegisterEventHandler(AppFactoryResetHandler, 0));
217290
#endif
218291

292+
/* Initialize trigger effect timer */
293+
k_timer_init(&sTriggerEffectTimer, &AppTask::TriggerEffectTimerTimeoutCallback, nullptr);
294+
219295
return Nrf::Matter::StartServer();
220296
}
221297

applications/matter_bridge/src/app_task.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
#include "board/board.h"
1010
#include <platform/CHIPDeviceLayer.h>
1111

12+
struct k_timer;
13+
struct Identify;
14+
1215
class AppTask {
1316
public:
1417
static AppTask &Instance()
@@ -24,6 +27,11 @@ class AppTask {
2427
static void SmartplugOnOffEventHandler();
2528
#endif /* CONFIG_BRIDGE_SMART_PLUG_SUPPORT */
2629

30+
static void IdentifyStartHandler(Identify *);
31+
static void IdentifyStopHandler(Identify *);
32+
static void TriggerIdentifyEffectHandler(Identify *);
33+
static void TriggerEffectTimerTimeoutCallback(k_timer *timer);
34+
2735
private:
2836
CHIP_ERROR Init();
2937

doc/nrf/releases_and_maturity/known_issues.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,15 @@ Matter
578578

579579
The issues in this section are related to the :ref:`ug_matter` protocol.
580580

581+
.. rst-class:: v3-0-2 v3-0-1 v3-0-0 v2-9-0-nRF54H20-1 v2-9-2 v2-9-1 v2-9-0 v2-8-0 v2-7-0
582+
583+
KRKNWK-20019: The identify time does not update for the endpoint 1 in the Matter Bridge application
584+
The identify cluster is enabled in the :file:`.zap` file, but not in the application.
585+
586+
**Affected platforms:** nRF7002, nRF5340
587+
588+
**Workaround:** Remove the identify cluster from the :file:`.zap` file, as this cluster is optional for the aggregator endpoint type.
589+
581590
.. rst-class:: v3-0-1 v3-0-0
582591

583592
KRKNWK-20308: The ``MyCluster.xml`` file example in the :ref:`ug_matter_creating_custom_cluster` user guide does not contain the ``ExtendedCommandResponse`` command

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ IPC radio firmware
258258
Matter bridge
259259
-------------
260260

261-
|no_changes_yet_note|
261+
* Implemented the missing identify cluster for the endpoint 1.
262+
This resolves the :ref:`known issue <known_issues>` KRKNWK-20019.
262263

263264
nRF5340 Audio
264265
-------------

0 commit comments

Comments
 (0)