Skip to content

Commit b0af6ba

Browse files
authored
Add delegate API methods to media clusters (project-chip#13259)
* Update app/clusters with delegate methods * Update test and Content App * Update Linux TV app * Update android TV app * Run zap regen tool & update random other folders and references * Restyle fix * Fix TV app Linux build
1 parent 462dd77 commit b0af6ba

File tree

119 files changed

+3903
-2272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+3903
-2272
lines changed

examples/all-clusters-app/esp32/main/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ set(SRC_DIRS_LIST
7777
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ias-zone-server"
7878
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ethernet-network-diagnostics-server"
7979
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/wifi-network-diagnostics-server"
80+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/wake-on-lan-server"
8081
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/pump-configuration-and-control-server"
8182
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/power-source-configuration-server"
8283
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/all-clusters-app/all-clusters-common/src"

examples/all-clusters-app/linux/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ executable("chip-all-clusters-app") {
2121
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/ota-requestor-stub.cpp",
2222
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp",
2323
"include/tv-callbacks.cpp",
24+
"include/tv-callbacks.h",
2425
"main.cpp",
2526
]
2627

examples/all-clusters-app/linux/include/tv-callbacks.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@
2222
*******************************************************************************
2323
******************************************************************************/
2424

25-
#include <list>
26-
#include <string>
25+
#include "tv-callbacks.h"
2726

28-
bool lowPowerClusterSleep()
27+
bool LowPowerManager::HandleSleep()
2928
{
3029
return true;
3130
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
*
3+
* Copyright (c) 2021 Project CHIP Authors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/****************************************************************************
19+
* @file
20+
* @brief Routines for TV stubs
21+
*server stub implementation of TV cluster code.
22+
*******************************************************************************
23+
******************************************************************************/
24+
25+
#include <app/clusters/low-power-server/low-power-server.h>
26+
27+
class LowPowerManager : public chip::app::Clusters::LowPower::Delegate
28+
{
29+
public:
30+
bool HandleSleep() override;
31+
};

examples/all-clusters-app/linux/main.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* limitations under the License.
1717
*/
1818

19+
#include "include/tv-callbacks.h"
1920
#include <app/CommandHandler.h>
2021
#include <app/clusters/identify-server/identify-server.h>
2122
#include <app/clusters/network-commissioning/network-commissioning.h>
@@ -28,6 +29,10 @@ using namespace chip;
2829
using namespace chip::app;
2930
using namespace chip::DeviceLayer;
3031

32+
namespace {
33+
static LowPowerManager lowPowerManager;
34+
} // namespace
35+
3136
bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * commandObj)
3237
{
3338
emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS);
@@ -108,3 +113,9 @@ int main(int argc, char * argv[])
108113
ChipLinuxAppMainLoop();
109114
return 0;
110115
}
116+
117+
void emberAfLowPowerClusterInitCallback(EndpointId endpoint)
118+
{
119+
ChipLogProgress(Zcl, "TV Linux App: LowPower::SetDefaultDelegate");
120+
chip::app::Clusters::LowPower::SetDefaultDelegate(endpoint, &lowPowerManager);
121+
}

examples/all-clusters-app/mbed/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ target_sources(${APP_TARGET} PRIVATE
131131
${APP_CLUSTERS}/ethernet-network-diagnostics-server/ethernet-network-diagnostics-server.cpp
132132
${APP_CLUSTERS}/software-diagnostics-server/software-diagnostics-server.cpp
133133
${APP_CLUSTERS}/thread-network-diagnostics-server/thread-network-diagnostics-server.cpp
134+
${APP_CLUSTERS}/wake-on-lan-server/wake-on-lan-server.cpp
134135
${APP_CLUSTERS}/wifi-network-diagnostics-server/wifi-network-diagnostics-server.cpp
135136
${APP_CLUSTERS}/pump-configuration-and-control-server/pump-configuration-and-control-server.cpp
136137
${APP_CLUSTERS}/administrator-commissioning-server/administrator-commissioning-server.cpp

examples/all-clusters-app/mbed/main/LowPowerManager.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
* limitations under the License.
1717
*/
1818

19-
bool lowPowerClusterSleep()
19+
#include "LowPowerManager.h"
20+
21+
bool LowPowerManager::HandleSleep()
2022
{
23+
// TODO: Insert code here
2124
return true;
2225
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
*
3+
* Copyright (c) 2021 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#pragma once
20+
21+
#include <app/clusters/low-power-server/low-power-server.h>
22+
23+
class LowPowerManager : public chip::app::Clusters::LowPower::Delegate
24+
{
25+
public:
26+
bool HandleSleep() override;
27+
};

examples/thermostat/linux/include/low-power/LowPowerManager.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#include "LowPowerManager.h"
2020

21-
bool lowPowerClusterSleep()
21+
bool LowPowerManager::HandleSleep()
2222
{
2323
// TODO: Insert code here
2424
return true;

examples/thermostat/linux/include/low-power/LowPowerManager.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818

1919
#pragma once
2020

21-
#include <lib/core/CHIPError.h>
21+
#include <app/clusters/low-power-server/low-power-server.h>
2222

23-
class LowPowerManager
23+
class LowPowerManager : public chip::app::Clusters::LowPower::Delegate
2424
{
2525
public:
26+
bool HandleSleep() override;
2627
};

examples/tv-app/android/include/account-login/AccountLoginManager.cpp

+16-56
Original file line numberDiff line numberDiff line change
@@ -17,75 +17,35 @@
1717
*/
1818

1919
#include "AccountLoginManager.h"
20-
#include <app-common/zap-generated/attribute-id.h>
21-
#include <app-common/zap-generated/attribute-type.h>
22-
#include <app-common/zap-generated/cluster-id.h>
23-
#include <app-common/zap-generated/command-id.h>
24-
#include <app-common/zap-generated/enums.h>
2520
#include <app/CommandHandler.h>
2621
#include <app/util/af.h>
2722

2823
using namespace std;
24+
using namespace chip::app::Clusters::AccountLogin;
2925

30-
bool AccountLoginManager::isUserLoggedIn(string requestTempAccountIdentifier, string requestSetupPin)
26+
bool AccountLoginManager::HandleLogin(const chip::CharSpan & tempAccountIdentifier, const chip::CharSpan & setupPin)
3127
{
32-
// TODO: Fix hardcoding length of strings
33-
requestTempAccountIdentifier = requestTempAccountIdentifier.substr(0, 4);
34-
requestSetupPin = requestSetupPin.substr(0, 10);
35-
for (auto it = accounts.cbegin(); it != accounts.cend(); ++it)
36-
{
37-
ChipLogProgress(Zcl, "temporary account id: %s", it->first.c_str());
38-
ChipLogProgress(Zcl, "setup pin %s", it->second.c_str());
39-
}
28+
string tempAccountIdentifierString(tempAccountIdentifier.data(), tempAccountIdentifier.size());
29+
string setupPinString(setupPin.data(), setupPin.size());
30+
ChipLogProgress(Zcl, "temporary account id: %s", tempAccountIdentifierString.c_str());
31+
ChipLogProgress(Zcl, "setup pin %s", setupPinString.c_str());
4032

41-
if (accounts.find(requestTempAccountIdentifier) != accounts.end())
42-
{
43-
bool found = accounts[requestTempAccountIdentifier] == requestSetupPin;
44-
if (!found)
45-
{
46-
ChipLogError(Zcl, "User is not logged in, failed to match request setup pin.");
47-
}
48-
return found;
49-
}
50-
else
51-
{
52-
ChipLogError(Zcl, "User is not logged in, failed to find temp account identifier.");
53-
return false;
54-
}
55-
}
56-
57-
void AccountLoginManager::setTempAccountIdentifierForPin(string tempAccountIdentifier, string setupPin)
58-
{
59-
// TODO: Fix hardcoding length of strings
60-
string tempId = tempAccountIdentifier.substr(0, 4);
61-
accounts[tempId] = setupPin;
62-
}
63-
64-
string AccountLoginManager::proxySetupPinRequest(string requestTempAccountIdentifier, chip::EndpointId endpoint)
65-
{
66-
// TODO: Insert your code here to send temp account identifier request
67-
return "tempPin123";
33+
// TODO: Insert your code here to handle login request
34+
return true;
6835
}
6936

70-
bool AccountLoginManager::proxyLogout()
37+
bool AccountLoginManager::HandleLogout()
7138
{
7239
// TODO: Insert your code here to send logout request
7340
return true;
7441
}
7542

76-
bool accountLoginClusterIsUserLoggedIn(std::string requestTempAccountIdentifier, std::string requestSetupPin)
77-
{
78-
return AccountLoginManager().GetInstance().isUserLoggedIn(requestTempAccountIdentifier, requestSetupPin);
79-
}
80-
81-
bool accountLoginClusterLogout()
82-
{
83-
return AccountLoginManager().GetInstance().proxyLogout();
84-
}
85-
86-
std::string accountLoginClusterGetSetupPin(std::string requestTempAccountIdentifier, chip::EndpointId endpoint)
43+
Commands::GetSetupPINResponse::Type AccountLoginManager::HandleGetSetupPin(const chip::CharSpan & tempAccountIdentifier)
8744
{
88-
string responseSetupPin = AccountLoginManager().proxySetupPinRequest(requestTempAccountIdentifier, endpoint);
89-
AccountLoginManager().GetInstance().setTempAccountIdentifierForPin(requestTempAccountIdentifier, responseSetupPin);
90-
return responseSetupPin;
45+
string tempAccountIdentifierString(tempAccountIdentifier.data(), tempAccountIdentifier.size());
46+
ChipLogProgress(Zcl, "temporary account id: %s", tempAccountIdentifierString.c_str());
47+
// TODO: Insert your code here to handle get setup pin
48+
Commands::GetSetupPINResponse::Type response;
49+
response.setupPIN = chip::CharSpan("tempPin123", strlen("tempPin123"));
50+
return response;
9151
}

examples/tv-app/android/include/account-login/AccountLoginManager.h

+7-17
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,15 @@
1818

1919
#pragma once
2020

21+
#include <app/clusters/account-login-server/account-login-server.h>
22+
2123
#include <app/util/af-types.h>
22-
#include <lib/core/CHIPError.h>
23-
#include <map>
24-
#include <string>
2524

26-
class AccountLoginManager
25+
class AccountLoginManager : public chip::app::Clusters::AccountLogin::Delegate
2726
{
2827
public:
29-
bool isUserLoggedIn(std::string requestTempAccountIdentifier, std::string requestSetupPin);
30-
bool proxyLogout();
31-
std::string proxySetupPinRequest(std::string requestTempAccountIdentifier, chip::EndpointId endpoint);
32-
void setTempAccountIdentifierForPin(std::string requestTempAccountIdentifier, std::string requestSetupPin);
33-
34-
static AccountLoginManager & GetInstance()
35-
{
36-
static AccountLoginManager instance;
37-
return instance;
38-
}
39-
40-
private:
41-
std::map<std::string, std::string> accounts;
28+
bool HandleLogin(const chip::CharSpan & tempAccountIdentifierString, const chip::CharSpan & setupPinString) override;
29+
bool HandleLogout() override;
30+
chip::app::Clusters::AccountLogin::Commands::GetSetupPINResponse::Type
31+
HandleGetSetupPin(const chip::CharSpan & tempAccountIdentifierString) override;
4232
};

0 commit comments

Comments
 (0)