Skip to content

Commit

Permalink
Add ContentAppObserver cluster and ContentControlCluster. Also Update…
Browse files Browse the repository at this point in the history
…d the spec per suggestions
  • Loading branch information
lazarkov committed Nov 29, 2023
1 parent 37d37ab commit b0c8b9a
Show file tree
Hide file tree
Showing 33 changed files with 2,847 additions and 183 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ jobs:
src/app/zap-templates/zcl/data-model/chip/color-control-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/concentration-measurement-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/content-launch-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/content-app-observer-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/content-control-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/descriptor-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/diagnostic-logs-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/dishwasher-alarm-cluster.xml \
Expand Down
8 changes: 7 additions & 1 deletion data_model/clusters/AccountLogin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,18 @@ Davis, CA 95616, USA
</field>
<field id="1" name="SetupPIN" type="string">
<mandatoryConform/>
<constraint type="minLength" value="11"/>
<constraint type="minLength" value="8"/>
</field>
<field id="2" name="Node" type="node-id">
<optionalConform/>
</field>
</command>
<command id="0x03" name="Logout" response="Y">
<access invokePrivilege="operate" fabricScoped="true" timed="true"/>
<mandatoryConform/>
<field id="0" name="Node" type="node-id">
<optionalConform/>
</field>
</command>
</commands>
<events>
Expand Down
4 changes: 4 additions & 0 deletions examples/tv-app/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ shared_library("jni") {
"include/cluster-init.cpp",
"include/content-launcher/AppContentLauncherManager.cpp",
"include/content-launcher/AppContentLauncherManager.h",
"include/content-control/ContentController.cpp",
"include/content-control/ContentController.h",
"include/content-app-observer/ContentAppObserver.cpp",
"include/content-app-observer/ContentAppObserver.h",
"include/media-playback/AppMediaPlaybackManager.cpp",
"include/media-playback/AppMediaPlaybackManager.h",
"include/target-navigator/TargetNavigatorManager.cpp",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
*
* Copyright (c) 2023 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "ContentAppObserver.h"

#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/util/config.h>

using namespace std;
using namespace chip;
using namespace chip::app::Clusters::ContentAppObserver;

ContentAppObserver::ContentAppObserver()
{
// Create Test Data
}

void ContentAppObserver::HandleContentAppMessage(chip::app::CommandResponseHelper<ContentAppMessageResponse> & helper,
const chip::Optional<chip::CharSpan> & data,
const chip::CharSpan & encodingHint)
{
ChipLogProgress(Zcl, "ContentAppObserver::HandleContentAppMessage");

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <app/AttributeAccessInterface.h>
#include <app/clusters/content-app-observer/content-app-observer.h>
#include <vector>

using ContentAppObserverDelegate = chip::app::Clusters::ContentAppObserver::Delegate;
using ContentAppMessageResponse = chip::app::Clusters::ContentAppObserver::Commands::ContentAppMessageResponse::Type;

class ContentAppObserver : public ContentAppObserverDelegate
{
public:
ContentAppObserver();

void HandleContentAppMessage(chip::app::CommandResponseHelper<ContentAppMessageResponse> & helper,
const chip::Optional<chip::CharSpan> & data,
const chip::CharSpan & encodingHint) override;
void SetEndpointId(chip::EndpointId epId) { mEndpointId = epId; };
protected:
private:
chip::EndpointId mEndpointId;
};
139 changes: 139 additions & 0 deletions examples/tv-app/android/include/content-control/ContentController.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/**
*
* Copyright (c) 2023 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "ContentController.h"
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/util/config.h>

using namespace std;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::DataModel;
using namespace chip::app::Clusters::ContentControl;

ContentController::ContentController()
{
// Create Test Data
}

// Attribute Delegates
bool ContentController::HandleGetEnabled()
{
return false;
}

CHIP_ERROR ContentController::HandleGetOnDemandRatings(chip::app::AttributeValueEncoder & aEncoder)
{
return aEncoder.Encode(chip::CharSpan());
}

chip::CharSpan ContentController::HandleGetOnDemandRatingThreshold()
{
return chip::CharSpan();
}

CHIP_ERROR ContentController::HandleGetScheduledContentRatings(chip::app::AttributeValueEncoder & aEncoder)
{
return aEncoder.Encode(chip::CharSpan());
}

chip::CharSpan ContentController::HandleGetScheduledContentRatingThreshold()
{
return chip::CharSpan();
}

uint32_t ContentController::HandleGetScreenDailyTime()
{
return (uint32_t) 0xFFFFFFFF;
}

uint32_t ContentController::HandleGetRemainingScreenTime()
{
return (uint32_t) 0xFFFFFFFF;
}

bool ContentController::HandleGetBlockUnrated()
{
return false;
}


// Command Delegates
void ContentController::HandleUpdatePIN(chip::Optional<chip::CharSpan> oldPIN, chip::CharSpan newPIN)
{

}

void ContentController::HandleResetPIN(chip::app::CommandResponseHelper<ResetPINResponseType> & helper)
{

}

void ContentController::HandleEnable()
{

}

void ContentController::HandleDisable()
{

}

void ContentController::HandleAddBonusTime(chip::Optional<chip::CharSpan> PINCode, chip::Optional<uint32_t> bonusTime)
{

}

void ContentController::HandleSetScreenDailyTime(uint32_t screenDailyTime)
{

}

void ContentController::HandleBlockUnratedContent()
{

}

void ContentController::HandleUnblockUnratedContent()
{

}

void ContentController::HandleSetOnDemandRatingThreshold(chip::CharSpan rating)
{

}

void ContentController::HandleSetScheduledContentRatingThreshold(chip::CharSpan rating)
{

}



uint32_t ContentController::GetFeatureMap(chip::EndpointId endpoint)
{
if (endpoint >= EMBER_AF_CONTENT_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT)
{
return mDynamicEndpointFeatureMap;
}

uint32_t featureMap = 0;
// TODO: ReEnable the code bellow
// Attributes::FeatureMap::Get(endpoint, &featureMap);
return featureMap;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <app/AttributeAccessInterface.h>
#include <app/clusters/content-control-server/content-control-server.h>
#include <vector>

using ContentControlDelegate = chip::app::Clusters::ContentControl::Delegate;
using ResetPINResponseType = chip::app::Clusters::ContentControl::Commands::ResetPINResponse::Type;

class ContentController : public ContentControlDelegate
{
public:
ContentController();

// Attribute Delegates
bool HandleGetEnabled() override;
CHIP_ERROR HandleGetOnDemandRatings(chip::app::AttributeValueEncoder & aEncoder) override;
chip::CharSpan HandleGetOnDemandRatingThreshold() override;
CHIP_ERROR HandleGetScheduledContentRatings(chip::app::AttributeValueEncoder & aEncoder) override;
chip::CharSpan HandleGetScheduledContentRatingThreshold() override;
uint32_t HandleGetScreenDailyTime() override;
uint32_t HandleGetRemainingScreenTime() override;
bool HandleGetBlockUnrated() override;

// Command Delegates
void HandleUpdatePIN(chip::Optional<chip::CharSpan> oldPIN, chip::CharSpan newPIN) override;
void HandleResetPIN(chip::app::CommandResponseHelper<ResetPINResponseType> & helper) override;
void HandleEnable() override;
void HandleDisable() override;
void HandleAddBonusTime(chip::Optional<chip::CharSpan> PINCode, chip::Optional<uint32_t> bonusTime) override;
void HandleSetScreenDailyTime(uint32_t screenDailyTime) override;
void HandleBlockUnratedContent() override;
void HandleUnblockUnratedContent() override;
void HandleSetOnDemandRatingThreshold(chip::CharSpan rating) override;
void HandleSetScheduledContentRatingThreshold(chip::CharSpan rating) override;

uint32_t GetFeatureMap(chip::EndpointId endpoint) override;
void SetEndpointId(chip::EndpointId epId) { mEndpointId = epId; };

protected:

private:
// TODO: set this based upon meta data from app
uint32_t mDynamicEndpointFeatureMap = 3;
chip::EndpointId mEndpointId;
};
18 changes: 18 additions & 0 deletions examples/tv-app/android/java/AppImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include "../include/account-login/AccountLoginManager.h"
#include "../include/application-basic/ApplicationBasicManager.h"
#include "../include/application-launcher/ApplicationLauncherManager.h"
#include "../include/content-control/ContentController.h"
#include "../include/content-app-observer/ContentAppObserver.h"
#include "../include/content-launcher/AppContentLauncherManager.h"
#include "../include/media-playback/AppMediaPlaybackManager.h"
#include "../include/target-navigator/TargetNavigatorManager.h"
Expand All @@ -48,6 +50,8 @@
#include <app/clusters/application-launcher-server/application-launcher-delegate.h>
#include <app/clusters/channel-server/channel-delegate.h>
#include <app/clusters/content-launch-server/content-launch-delegate.h>
#include <app/clusters/content-app-observer/content-app-observer-delegate.h>
#include <app/clusters/content-control-server/content-control-delegate.h>
#include <app/clusters/keypad-input-server/keypad-input-delegate.h>
#include <app/clusters/media-playback-server/media-playback-delegate.h>
#include <app/clusters/target-navigator-server/target-navigator-delegate.h>
Expand All @@ -72,6 +76,8 @@ using ApplicationBasicDelegate = app::Clusters::ApplicationBasic::Delegate;
using ApplicationLauncherDelegate = app::Clusters::ApplicationLauncher::Delegate;
using ChannelDelegate = app::Clusters::Channel::Delegate;
using ContentLauncherDelegate = app::Clusters::ContentLauncher::Delegate;
using ContentAppObserverDelegate = app::Clusters::ContentAppObserver::Delegate;
using ContentControlDelegate = app::Clusters::ContentControl::Delegate;
using KeypadInputDelegate = app::Clusters::KeypadInput::Delegate;
using MediaPlaybackDelegate = app::Clusters::MediaPlayback::Delegate;
using TargetNavigatorDelegate = app::Clusters::TargetNavigator::Delegate;
Expand Down Expand Up @@ -112,6 +118,16 @@ class DLL_EXPORT ContentAppImpl : public ContentApp
mContentLauncherDelegate.SetEndpointId(GetEndpointId());
return &mContentLauncherDelegate;
};
ContentAppObserverDelegate * GetContentAppObserverDelegate() override
{
mContentAppObserverDelegate.SetEndpointId(GetEndpointId());
return &mContentAppObserverDelegate;
};
ContentControlDelegate * GetContentControlDelegate() override
{
mContentControlDelegate.SetEndpointId(GetEndpointId());
return &mContentControlDelegate;
};
KeypadInputDelegate * GetKeypadInputDelegate() override { return &mKeypadInputDelegate; };
MediaPlaybackDelegate * GetMediaPlaybackDelegate() override
{
Expand All @@ -129,6 +145,8 @@ class DLL_EXPORT ContentAppImpl : public ContentApp
AccountLoginManager mAccountLoginDelegate;
ApplicationLauncherManager mApplicationLauncherDelegate;
ChannelManager mChannelDelegate;
ContentController mContentControlDelegate;
ContentAppObserver mContentAppObserverDelegate;
AppContentLauncherManager mContentLauncherDelegate;
KeypadInputManager mKeypadInputDelegate;
AppMediaPlaybackManager mMediaPlaybackDelegate;
Expand Down
4 changes: 4 additions & 0 deletions examples/tv-app/tv-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ source_set("tv-common-sources") {
"clusters/channel/ChannelManager.h",
"clusters/content-launcher/ContentLauncherManager.cpp",
"clusters/content-launcher/ContentLauncherManager.h",
"clusters/content-control/ContentController.cpp",
"clusters/content-control/ContentController.h",
"clusters/content-app-observer/ContentAppObserver.cpp",
"clusters/content-app-observer/ContentAppObserver.h",
"clusters/keypad-input/KeypadInputManager.cpp",
"clusters/keypad-input/KeypadInputManager.h",
"clusters/low-power/LowPowerManager.cpp",
Expand Down
Loading

0 comments on commit b0c8b9a

Please sign in to comment.