Skip to content

Commit 92fd90d

Browse files
authored
Merge branch 'master' into granbery/preset_setpoint_sync
2 parents 6c0101c + 1d1319b commit 92fd90d

File tree

77 files changed

+1676
-377
lines changed

Some content is hidden

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

77 files changed

+1676
-377
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ set(PRIV_INCLUDE_DIRS_LIST
2222
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/energy-management-app/energy-management-common/device-energy-management/include"
2323
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/energy-management-app/energy-management-common/energy-evse/include"
2424
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/energy-management-app/energy-management-common/energy-reporting/include"
25+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/energy-management-app/energy-management-common/water-heater/include"
2526
"${CMAKE_CURRENT_LIST_DIR}/include"
2627
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers"
2728
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32"
@@ -36,6 +37,7 @@ set(SRC_DIRS_LIST
3637
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/energy-management-app/energy-management-common/device-energy-management/src"
3738
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/energy-management-app/energy-management-common/energy-evse/src"
3839
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/energy-management-app/energy-management-common/energy-reporting/src"
40+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/energy-management-app/energy-management-common/water-heater/src"
3941
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers"
4042
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/ota"
4143
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/common"

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

+6-5
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ if (chip_enable_pw_rpc) {
2929

3030
source_set("chip-all-clusters-common") {
3131
sources = [
32-
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/WhmDelegateImpl.cpp",
33-
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/WhmInstance.cpp",
34-
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/WhmMain.cpp",
35-
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/WhmManufacturer.cpp",
3632
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/air-quality-instance.cpp",
3733
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/binding-handler.cpp",
3834
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/boolcfg-stub.cpp",
@@ -62,7 +58,6 @@ source_set("chip-all-clusters-common") {
6258
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp",
6359
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-temperature-levels.cpp",
6460
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/tcc-mode.cpp",
65-
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/water-heater-mode.cpp",
6661
"${chip_root}/examples/all-clusters-app/linux/diagnostic-logs-provider-delegate-impl.cpp",
6762
"${chip_root}/examples/energy-management-app/energy-management-common/common/src/EnergyTimeUtils.cpp",
6863
"${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/src/DeviceEnergyManagementDelegateImpl.cpp",
@@ -75,6 +70,11 @@ source_set("chip-all-clusters-common") {
7570
"${chip_root}/examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseTargetsStore.cpp",
7671
"${chip_root}/examples/energy-management-app/energy-management-common/energy-evse/src/energy-evse-mode.cpp",
7772
"${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalPowerMeasurementDelegate.cpp",
73+
"${chip_root}/examples/energy-management-app/energy-management-common/water-heater/src/WhmDelegateImpl.cpp",
74+
"${chip_root}/examples/energy-management-app/energy-management-common/water-heater/src/WhmInstance.cpp",
75+
"${chip_root}/examples/energy-management-app/energy-management-common/water-heater/src/WhmMain.cpp",
76+
"${chip_root}/examples/energy-management-app/energy-management-common/water-heater/src/WhmManufacturer.cpp",
77+
"${chip_root}/examples/energy-management-app/energy-management-common/water-heater/src/water-heater-mode.cpp",
7878
"${chip_root}/examples/thermostat/thermostat-common/src/thermostat-delegate-impl.cpp",
7979
"AllClustersCommandDelegate.cpp",
8080
"AllClustersCommandDelegate.h",
@@ -102,6 +102,7 @@ source_set("chip-all-clusters-common") {
102102
"${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/include",
103103
"${chip_root}/examples/energy-management-app/energy-management-common/energy-evse/include",
104104
"${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/include",
105+
"${chip_root}/examples/energy-management-app/energy-management-common/water-heater/include",
105106
"${chip_root}/examples/thermostat/thermostat-common/include",
106107
]
107108

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

-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ void ApplicationShutdown()
285285
Clusters::WaterHeaterMode::Shutdown();
286286

287287
Clusters::WaterHeaterManagement::WhmApplicationShutdown();
288-
Clusters::WaterHeaterMode::Shutdown();
289288

290289
if (sChipNamedPipeCommands.Stop() != CHIP_NO_ERROR)
291290
{

examples/chef/common/clusters/media-input/MediaInputManager.cpp

+39-12
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,26 @@
1515
* limitations under the License.
1616
*/
1717

18+
#include <app-common/zap-generated/attributes/Accessors.h>
1819
#include <app/util/config.h>
20+
#include <map>
21+
1922
#ifdef MATTER_DM_PLUGIN_MEDIA_INPUT_SERVER
2023
#include "MediaInputManager.h"
2124

2225
using namespace std;
2326
using namespace chip;
2427
using namespace chip::app::Clusters::MediaInput;
28+
using Protocols::InteractionModel::Status;
2529

26-
MediaInputManager::MediaInputManager()
30+
MediaInputManager::MediaInputManager(chip::EndpointId endpoint) : mEndpoint(endpoint)
2731
{
28-
struct InputData inputData1(1, chip::app::Clusters::MediaInput::InputTypeEnum::kHdmi, "HDMI 1",
29-
"High-Definition Multimedia Interface");
32+
struct InputData inputData1(1, InputTypeEnum::kHdmi, "HDMI 1", "High-Definition Multimedia Interface");
3033
mInputs.push_back(inputData1);
31-
struct InputData inputData2(2, chip::app::Clusters::MediaInput::InputTypeEnum::kHdmi, "HDMI 2",
32-
"High-Definition Multimedia Interface");
34+
struct InputData inputData2(2, InputTypeEnum::kHdmi, "HDMI 2", "High-Definition Multimedia Interface");
3335
mInputs.push_back(inputData2);
34-
struct InputData inputData3(3, chip::app::Clusters::MediaInput::InputTypeEnum::kHdmi, "HDMI 3",
35-
"High-Definition Multimedia Interface");
36+
struct InputData inputData3(3, InputTypeEnum::kHdmi, "HDMI 3", "High-Definition Multimedia Interface");
3637
mInputs.push_back(inputData3);
37-
38-
mCurrentInput = 1;
3938
}
4039

4140
CHIP_ERROR MediaInputManager::HandleGetInputList(chip::app::AttributeValueEncoder & aEncoder)
@@ -51,16 +50,32 @@ CHIP_ERROR MediaInputManager::HandleGetInputList(chip::app::AttributeValueEncode
5150

5251
uint8_t MediaInputManager::HandleGetCurrentInput()
5352
{
54-
return mCurrentInput;
53+
uint8_t currentInput = 1;
54+
Status status = Attributes::CurrentInput::Get(mEndpoint, &currentInput);
55+
if (Status::Success != status)
56+
{
57+
ChipLogError(Zcl, "Unable to get CurrentInput attribute, err:0x%x", to_underlying(status));
58+
}
59+
return currentInput;
5560
}
5661

5762
bool MediaInputManager::HandleSelectInput(const uint8_t index)
5863
{
64+
if (HandleGetCurrentInput() == index)
65+
{
66+
ChipLogProgress(Zcl, "CurrentInput is same as new value: %u", index);
67+
return true;
68+
}
5969
for (auto const & inputData : mInputs)
6070
{
6171
if (inputData.index == index)
6272
{
63-
mCurrentInput = index;
73+
// Sync the CurrentInput to attribute storage while reporting changes
74+
Status status = Attributes::CurrentInput::Set(mEndpoint, index);
75+
if (Status::Success != status)
76+
{
77+
ChipLogError(Zcl, "CurrentInput is not stored successfully, err:0x%x", to_underlying(status));
78+
}
6479
return true;
6580
}
6681
}
@@ -70,11 +85,12 @@ bool MediaInputManager::HandleSelectInput(const uint8_t index)
7085

7186
bool MediaInputManager::HandleShowInputStatus()
7287
{
88+
uint8_t currentInput = HandleGetCurrentInput();
7389
ChipLogProgress(Zcl, " MediaInputManager::HandleShowInputStatus()");
7490
for (auto const & inputData : mInputs)
7591
{
7692
ChipLogProgress(Zcl, " [%d] type=%d selected=%d name=%s desc=%s", inputData.index,
77-
static_cast<uint16_t>(inputData.inputType), (mCurrentInput == inputData.index ? 1 : 0),
93+
static_cast<uint16_t>(inputData.inputType), (currentInput == inputData.index ? 1 : 0),
7894
inputData.name.c_str(), inputData.description.c_str());
7995
}
8096
return true;
@@ -99,4 +115,15 @@ bool MediaInputManager::HandleRenameInput(const uint8_t index, const chip::CharS
99115

100116
return false;
101117
}
118+
119+
static std::map<chip::EndpointId, std::unique_ptr<MediaInputManager>> gMediaInputManagerInstance{};
120+
121+
void emberAfMediaInputClusterInitCallback(EndpointId endpoint)
122+
{
123+
ChipLogProgress(Zcl, "TV Linux App: MediaInput::SetDefaultDelegate, endpoint=%x", endpoint);
124+
125+
gMediaInputManagerInstance[endpoint] = std::make_unique<MediaInputManager>(endpoint);
126+
127+
SetDefaultDelegate(endpoint, gMediaInputManagerInstance[endpoint].get());
128+
}
102129
#endif // MATTER_DM_PLUGIN_MEDIA_INPUT_SERVER

examples/chef/common/clusters/media-input/MediaInputManager.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class MediaInputManager : public chip::app::Clusters::MediaInput::Delegate
2929
using InputInfoType = chip::app::Clusters::MediaInput::Structs::InputInfoStruct::Type;
3030

3131
public:
32-
MediaInputManager();
32+
MediaInputManager(chip::EndpointId endpoint);
3333

3434
CHIP_ERROR HandleGetInputList(chip::app::AttributeValueEncoder & aEncoder) override;
3535
uint8_t HandleGetCurrentInput() override;
@@ -63,7 +63,7 @@ class MediaInputManager : public chip::app::Clusters::MediaInput::Delegate
6363
};
6464

6565
protected:
66-
uint8_t mCurrentInput;
66+
chip::EndpointId mEndpoint;
6767
std::vector<InputData> mInputs;
6868

6969
private:

examples/chef/common/clusters/media-playback/MediaPlaybackManager.cpp

+85-29
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,34 @@
1515
* limitations under the License.
1616
*/
1717

18-
#include <app/util/config.h>
19-
#ifdef MATTER_DM_PLUGIN_MEDIA_PLAYBACK_SERVER
20-
#include "MediaPlaybackManager.h"
2118
#include <app-common/zap-generated/attributes/Accessors.h>
2219
#include <app/util/config.h>
23-
20+
#include <map>
2421
#include <string>
22+
#ifdef MATTER_DM_PLUGIN_MEDIA_PLAYBACK_SERVER
23+
#include "MediaPlaybackManager.h"
2524

2625
using namespace std;
26+
using namespace chip;
27+
using namespace chip::app;
2728
using namespace chip::app::DataModel;
2829
using namespace chip::app::Clusters::MediaPlayback;
29-
using namespace chip::Uint8;
3030

3131
using chip::CharSpan;
3232
using chip::app::AttributeValueEncoder;
3333
using chip::app::CommandResponseHelper;
34+
using chip::Protocols::InteractionModel::Status;
3435

3536
PlaybackStateEnum MediaPlaybackManager::HandleGetCurrentState()
3637
{
37-
return mCurrentState;
38+
PlaybackStateEnum currentState = PlaybackStateEnum::kPlaying;
39+
40+
Status status = Attributes::CurrentState::Get(mEndpoint, &currentState);
41+
if (Status::Success != status)
42+
{
43+
ChipLogError(Zcl, "Unable to get CurrentStage attribute, err:0x%x", to_underlying(status));
44+
}
45+
return currentState;
3846
}
3947

4048
uint64_t MediaPlaybackManager::HandleGetStartTime()
@@ -54,7 +62,14 @@ CHIP_ERROR MediaPlaybackManager::HandleGetSampledPosition(AttributeValueEncoder
5462

5563
float MediaPlaybackManager::HandleGetPlaybackSpeed()
5664
{
57-
return mPlaybackSpeed;
65+
float playbackSpeed = 1.0;
66+
67+
Status status = Attributes::PlaybackSpeed::Get(mEndpoint, &playbackSpeed);
68+
if (Status::Success != status)
69+
{
70+
ChipLogError(Zcl, "Unable to get PlaybackSpeed attribute, err:0x%x", to_underlying(status));
71+
}
72+
return playbackSpeed;
5873
}
5974

6075
uint64_t MediaPlaybackManager::HandleGetSeekRangeStart()
@@ -99,10 +114,34 @@ CHIP_ERROR MediaPlaybackManager::HandleGetAvailableTextTracks(AttributeValueEnco
99114
});
100115
}
101116

117+
CHIP_ERROR MediaPlaybackManager::HandleSetCurrentState(PlaybackStateEnum currentState)
118+
{
119+
Status status = Attributes::CurrentState::Set(mEndpoint, currentState);
120+
121+
if (Status::Success != status)
122+
{
123+
ChipLogError(Zcl, "Unable to set CurrentState attribute, 0x%x", to_underlying(status));
124+
}
125+
126+
return CHIP_ERROR_IM_GLOBAL_STATUS_VALUE(status);
127+
}
128+
129+
CHIP_ERROR MediaPlaybackManager::HandleSetPlaybackSpeed(float playbackSpeed)
130+
{
131+
Status status = Attributes::PlaybackSpeed::Set(mEndpoint, playbackSpeed);
132+
133+
if (Status::Success != status)
134+
{
135+
ChipLogError(Zcl, "Unable to set PlaybackSpeed attribute, 0x%x", to_underlying(status));
136+
}
137+
138+
return CHIP_ERROR_IM_GLOBAL_STATUS_VALUE(status);
139+
}
140+
102141
void MediaPlaybackManager::HandlePlay(CommandResponseHelper<Commands::PlaybackResponse::Type> & helper)
103142
{
104-
mCurrentState = PlaybackStateEnum::kPlaying;
105-
mPlaybackSpeed = 1;
143+
HandleSetCurrentState(PlaybackStateEnum::kPlaying);
144+
HandleSetPlaybackSpeed(1);
106145

107146
Commands::PlaybackResponse::Type response;
108147
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
@@ -112,8 +151,8 @@ void MediaPlaybackManager::HandlePlay(CommandResponseHelper<Commands::PlaybackRe
112151

113152
void MediaPlaybackManager::HandlePause(CommandResponseHelper<Commands::PlaybackResponse::Type> & helper)
114153
{
115-
mCurrentState = PlaybackStateEnum::kPaused;
116-
mPlaybackSpeed = 0;
154+
HandleSetCurrentState(PlaybackStateEnum::kPaused);
155+
HandleSetPlaybackSpeed(0);
117156

118157
Commands::PlaybackResponse::Type response;
119158
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
@@ -123,8 +162,8 @@ void MediaPlaybackManager::HandlePause(CommandResponseHelper<Commands::PlaybackR
123162

124163
void MediaPlaybackManager::HandleStop(CommandResponseHelper<Commands::PlaybackResponse::Type> & helper)
125164
{
126-
mCurrentState = PlaybackStateEnum::kNotPlaying;
127-
mPlaybackSpeed = 0;
165+
HandleSetCurrentState(PlaybackStateEnum::kNotPlaying);
166+
HandleSetPlaybackSpeed(0);
128167
mPlaybackPosition = { 0, chip::app::DataModel::Nullable<uint64_t>(0) };
129168

130169
Commands::PlaybackResponse::Type response;
@@ -136,7 +175,9 @@ void MediaPlaybackManager::HandleStop(CommandResponseHelper<Commands::PlaybackRe
136175
void MediaPlaybackManager::HandleFastForward(CommandResponseHelper<Commands::PlaybackResponse::Type> & helper,
137176
const chip::Optional<bool> & audioAdvanceUnmuted)
138177
{
139-
if (mPlaybackSpeed == kPlaybackMaxForwardSpeed)
178+
float playbackSpeed = HandleGetPlaybackSpeed();
179+
180+
if (playbackSpeed == kPlaybackMaxForwardSpeed)
140181
{
141182
// if already at max speed, return error
142183
Commands::PlaybackResponse::Type response;
@@ -146,13 +187,14 @@ void MediaPlaybackManager::HandleFastForward(CommandResponseHelper<Commands::Pla
146187
return;
147188
}
148189

149-
mCurrentState = PlaybackStateEnum::kPlaying;
150-
mPlaybackSpeed = (mPlaybackSpeed <= 0 ? 1 : mPlaybackSpeed * 2);
151-
if (mPlaybackSpeed > kPlaybackMaxForwardSpeed)
190+
HandleSetCurrentState(PlaybackStateEnum::kPlaying);
191+
// Normalize to correct range
192+
playbackSpeed = (playbackSpeed <= 0 ? 1 : playbackSpeed * 2);
193+
if (playbackSpeed > kPlaybackMaxForwardSpeed)
152194
{
153-
// don't exceed max speed
154-
mPlaybackSpeed = kPlaybackMaxForwardSpeed;
195+
playbackSpeed = kPlaybackMaxForwardSpeed;
155196
}
197+
HandleSetPlaybackSpeed(playbackSpeed);
156198

157199
Commands::PlaybackResponse::Type response;
158200
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
@@ -162,8 +204,8 @@ void MediaPlaybackManager::HandleFastForward(CommandResponseHelper<Commands::Pla
162204

163205
void MediaPlaybackManager::HandlePrevious(CommandResponseHelper<Commands::PlaybackResponse::Type> & helper)
164206
{
165-
mCurrentState = PlaybackStateEnum::kPlaying;
166-
mPlaybackSpeed = 1;
207+
HandleSetCurrentState(PlaybackStateEnum::kPlaying);
208+
HandleSetPlaybackSpeed(1);
167209
mPlaybackPosition = { 0, chip::app::DataModel::Nullable<uint64_t>(0) };
168210

169211
Commands::PlaybackResponse::Type response;
@@ -175,7 +217,9 @@ void MediaPlaybackManager::HandlePrevious(CommandResponseHelper<Commands::Playba
175217
void MediaPlaybackManager::HandleRewind(CommandResponseHelper<Commands::PlaybackResponse::Type> & helper,
176218
const chip::Optional<bool> & audioAdvanceUnmuted)
177219
{
178-
if (mPlaybackSpeed == kPlaybackMaxRewindSpeed)
220+
float playbackSpeed = HandleGetPlaybackSpeed();
221+
222+
if (playbackSpeed == kPlaybackMaxRewindSpeed)
179223
{
180224
// if already at max speed in reverse, return error
181225
Commands::PlaybackResponse::Type response;
@@ -185,13 +229,14 @@ void MediaPlaybackManager::HandleRewind(CommandResponseHelper<Commands::Playback
185229
return;
186230
}
187231

188-
mCurrentState = PlaybackStateEnum::kPlaying;
189-
mPlaybackSpeed = (mPlaybackSpeed >= 0 ? -1 : mPlaybackSpeed * 2);
190-
if (mPlaybackSpeed < kPlaybackMaxRewindSpeed)
232+
HandleSetCurrentState(PlaybackStateEnum::kPlaying);
233+
// Normalize to correct range
234+
playbackSpeed = (playbackSpeed >= 0 ? -1 : playbackSpeed * 2);
235+
if (playbackSpeed < kPlaybackMaxRewindSpeed)
191236
{
192-
// don't exceed max rewind speed
193-
mPlaybackSpeed = kPlaybackMaxRewindSpeed;
237+
playbackSpeed = kPlaybackMaxRewindSpeed;
194238
}
239+
HandleSetPlaybackSpeed(playbackSpeed);
195240

196241
Commands::PlaybackResponse::Type response;
197242
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
@@ -249,8 +294,8 @@ void MediaPlaybackManager::HandleSeek(CommandResponseHelper<Commands::PlaybackRe
249294

250295
void MediaPlaybackManager::HandleNext(CommandResponseHelper<Commands::PlaybackResponse::Type> & helper)
251296
{
252-
mCurrentState = PlaybackStateEnum::kPlaying;
253-
mPlaybackSpeed = 1;
297+
HandleSetCurrentState(PlaybackStateEnum::kPlaying);
298+
HandleSetPlaybackSpeed(1);
254299
mPlaybackPosition = { 0, chip::app::DataModel::Nullable<uint64_t>(0) };
255300

256301
Commands::PlaybackResponse::Type response;
@@ -338,4 +383,15 @@ uint16_t MediaPlaybackManager::GetClusterRevision(chip::EndpointId endpoint)
338383
return clusterRevision;
339384
}
340385

386+
static std::map<chip::EndpointId, std::unique_ptr<MediaPlaybackManager>> gMediaPlaybackManagerInstance{};
387+
388+
void emberAfMediaPlaybackClusterInitCallback(EndpointId endpoint)
389+
{
390+
ChipLogProgress(Zcl, "TV Linux App: MediaPlayback::SetDefaultDelegate, endpoint=%x", endpoint);
391+
392+
gMediaPlaybackManagerInstance[endpoint] = std::make_unique<MediaPlaybackManager>(endpoint);
393+
394+
SetDefaultDelegate(endpoint, gMediaPlaybackManagerInstance[endpoint].get());
395+
}
396+
341397
#endif /// MATTER_DM_PLUGIN_MEDIA_PLAYBACK_SERVER

0 commit comments

Comments
 (0)