Skip to content

Commit

Permalink
Merge branch 'master' into update_zap_files_to_spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarthak-Shaha authored Mar 4, 2024
2 parents 23aaf85 + 33a2c5f commit 7af575f
Show file tree
Hide file tree
Showing 40 changed files with 582 additions and 244 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/darwin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ jobs:
- name: Validate zap-cli is NOT available
# run_in_build_env.sh is used to ensure PATH is set to something that would otherwise find zap-cli
run: scripts/run_in_build_env.sh '(zap-cli --version && exit 1) || exit 0'
- name: Run watchOS Build Debug
working-directory: src/darwin/Framework
# Disable availability annotations, since we are not building a system
# Matter.framework.
run: xcodebuild -target "Matter" -sdk watchos -configuration Debug GCC_PREPROCESSOR_DEFINITIONS='${inherited} MTR_NO_AVAILABILITY=1'
- name: Run iOS Build Debug
working-directory: src/darwin/Framework
# Disable availability annotations, since we are not building a system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class TerminalFragment extends Fragment {
private static String TERMINAL_INSTRUCTIONS =
"add <vid> [<pid>] Add app with given vendor ID [1, 2, 9050]. Usage: add 9050\r\n"
+ "remove <endpoint> Remove app at given endpoint [6, 7, etc]. Usage: remove 6\r\n"
+ "appobserver <appendpoint> <clientnodeindex> <data> <hint> Send app observer command to client node of the given app endpoint. Usage: appobserver 4 0 data hint\r\n"
+ "printclients <appendpoint> Print list of client nodes for the given app endpoint. Usage: printclients 4\r\n"
+ "setpin <endpoint> <pincode> Set pincode for app with given endpoint ID. Usage: setpin 6 34567890\r\n"
+ "commission <udc-entry> Commission given udc-entry using given pincode from corresponding app. Usage:"
+ "commission 0\r\n"
Expand Down
19 changes: 13 additions & 6 deletions examples/tv-app/android/java/AppImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ ContentApp * ContentAppFactoryImpl::LoadContentApp(const CatalogVendorApp & vend
ChipLogProgress(DeviceLayer, " Looking next=%s ", app->GetApplicationBasicDelegate()->GetCatalogVendorApp()->applicationId);
if (app->GetApplicationBasicDelegate()->GetCatalogVendorApp()->Matches(vendorApp))
{
// need to think about loading apk here?
ContentAppPlatform::GetInstance().AddContentApp(app, &contentAppEndpoint, Span<DataVersion>(gDataVersions[i]),
Span<const EmberAfDeviceType>(gContentAppDeviceType));
return app;
Expand Down Expand Up @@ -422,19 +423,25 @@ std::list<ClusterId> ContentAppFactoryImpl::GetAllowedClusterListForStaticEndpoi
ChipLogProgress(DeviceLayer,
"ContentAppFactoryImpl GetAllowedClusterListForStaticEndpoint priviledged vendor accessible clusters "
"being returned.");
return { chip::app::Clusters::Descriptor::Id, chip::app::Clusters::OnOff::Id,
chip::app::Clusters::WakeOnLan::Id, chip::app::Clusters::MediaPlayback::Id,
chip::app::Clusters::LowPower::Id, chip::app::Clusters::KeypadInput::Id,
chip::app::Clusters::ContentLauncher::Id, chip::app::Clusters::AudioOutput::Id,
chip::app::Clusters::ApplicationLauncher::Id };
return { chip::app::Clusters::Descriptor::Id,
chip::app::Clusters::OnOff::Id,
chip::app::Clusters::WakeOnLan::Id,
chip::app::Clusters::MediaPlayback::Id,
chip::app::Clusters::LowPower::Id,
chip::app::Clusters::KeypadInput::Id,
chip::app::Clusters::ContentLauncher::Id,
chip::app::Clusters::AudioOutput::Id,
chip::app::Clusters::ApplicationLauncher::Id,
chip::app::Clusters::Messages::Id };
}
ChipLogProgress(
DeviceLayer,
"ContentAppFactoryImpl GetAllowedClusterListForStaticEndpoint operator vendor accessible clusters being returned.");
return { chip::app::Clusters::Descriptor::Id, chip::app::Clusters::OnOff::Id,
chip::app::Clusters::WakeOnLan::Id, chip::app::Clusters::MediaPlayback::Id,
chip::app::Clusters::LowPower::Id, chip::app::Clusters::KeypadInput::Id,
chip::app::Clusters::ContentLauncher::Id, chip::app::Clusters::AudioOutput::Id };
chip::app::Clusters::ContentLauncher::Id, chip::app::Clusters::AudioOutput::Id,
chip::app::Clusters::Messages::Id };
}
return {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ public class MessagesManagerStub implements MessagesManager {
public MessagesManagerStub(int endpoint) {
this.endpoint = endpoint;
Log.d(TAG, "MessagesManagerStub: at " + this.endpoint);

HashMap<Long, String> responseOptions = new HashMap<Long, String>();
responseOptions.put(new Long(1), "Yes");
responseOptions.put(new Long(2), "No");
presentMessages(
"31323334353637383930313233343536", 1, 1, 30, 60000, "TestMessage", responseOptions);
Log.d(TAG, "MessagesManagerStub: added dummy message");
}

@Override
Expand Down
62 changes: 62 additions & 0 deletions examples/tv-app/tv-common/shell/AppTvShellCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ static CHIP_ERROR PrintAllCommands()
#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
streamer_printf(sout, " add <vid> [<pid>] Add app with given vendor ID [1, 2, 9050]. Usage: app add 9050\r\n");
streamer_printf(sout, " remove <endpoint> Remove app at given endpoint [6, 7, etc]. Usage: app remove 6\r\n");
streamer_printf(sout,
" appobserver <appendpoint> <clientnodeindex> <data> <hint> Send app observer command to client node of "
"the given app endpoint. Usage: appobserver 4 0 data hint\r\n");
streamer_printf(
sout, " printclients <appendpoint> Print list of client nodes for the given app endpoint. Usage: printclients 4\r\n");
streamer_printf(
sout, " setpin <endpoint> <pincode> Set pincode for app with given endpoint ID. Usage: app setpin 6 34567890\r\n");
streamer_printf(sout,
Expand Down Expand Up @@ -277,6 +282,63 @@ static CHIP_ERROR AppPlatformHandler(int argc, char ** argv)

return CHIP_NO_ERROR;
}
else if (strcmp(argv[0], "printclients") == 0)
{
if (argc < 2)
{
return PrintAllCommands();
}
char * eptr;

uint16_t endpoint = (uint16_t) strtol(argv[1], &eptr, 10);
ContentApp * app = ContentAppPlatform::GetInstance().GetContentApp(endpoint);
if (app == nullptr)
{
ChipLogProgress(DeviceLayer, "app not found");
return CHIP_ERROR_BAD_REQUEST;
}
uint8_t count = app->GetClientNodeCount();
ChipLogProgress(DeviceLayer, " node count: %d", count);
for (uint8_t i = 0; i < count; i++)
{
NodeId node = app->GetClientNode(i);
ChipLogProgress(DeviceLayer, " node[%d] " ChipLogFormatX64, i, ChipLogValueX64(node));
}
}
#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE
else if (strcmp(argv[0], "appobserver") == 0)
{
if (argc < 5)
{
return PrintAllCommands();
}
char * eptr;

uint16_t endpoint = (uint16_t) strtol(argv[1], &eptr, 10);
ContentApp * app = ContentAppPlatform::GetInstance().GetContentApp(endpoint);
if (app == nullptr)
{
ChipLogProgress(DeviceLayer, "app not found");
return CHIP_ERROR_BAD_REQUEST;
}
uint8_t clientNodeIndex = (uint8_t) strtol(argv[2], &eptr, 10);
if (clientNodeIndex >= app->GetClientNodeCount())
{
ChipLogProgress(DeviceLayer, "illegal client node index");
return CHIP_ERROR_BAD_REQUEST;
}
NodeId clientNode = app->GetClientNode(clientNodeIndex);

char * data = argv[3];
char * encodingHint = argv[4];

app->SendAppObserverCommand(GetDeviceCommissioner(), clientNode, data, encodingHint);

ChipLogProgress(DeviceLayer, "sent appobserver command");

return CHIP_NO_ERROR;
}
#endif // CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE
else if (strcmp(argv[0], "setpin") == 0)
{
if (argc < 3)
Expand Down
18 changes: 12 additions & 6 deletions examples/tv-app/tv-common/src/AppTv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,19 +549,25 @@ std::list<ClusterId> ContentAppFactoryImpl::GetAllowedClusterListForStaticEndpoi
ChipLogProgress(DeviceLayer,
"ContentAppFactoryImpl GetAllowedClusterListForStaticEndpoint priviledged vendor accessible clusters "
"being returned.");
return { chip::app::Clusters::Descriptor::Id, chip::app::Clusters::OnOff::Id,
chip::app::Clusters::WakeOnLan::Id, chip::app::Clusters::MediaPlayback::Id,
chip::app::Clusters::LowPower::Id, chip::app::Clusters::KeypadInput::Id,
chip::app::Clusters::ContentLauncher::Id, chip::app::Clusters::AudioOutput::Id,
chip::app::Clusters::ApplicationLauncher::Id };
return { chip::app::Clusters::Descriptor::Id,
chip::app::Clusters::OnOff::Id,
chip::app::Clusters::WakeOnLan::Id,
chip::app::Clusters::MediaPlayback::Id,
chip::app::Clusters::LowPower::Id,
chip::app::Clusters::KeypadInput::Id,
chip::app::Clusters::ContentLauncher::Id,
chip::app::Clusters::AudioOutput::Id,
chip::app::Clusters::ApplicationLauncher::Id,
chip::app::Clusters::Messages::Id }; // TODO: messages?
}
ChipLogProgress(
DeviceLayer,
"ContentAppFactoryImpl GetAllowedClusterListForStaticEndpoint operator vendor accessible clusters being returned.");
return { chip::app::Clusters::Descriptor::Id, chip::app::Clusters::OnOff::Id,
chip::app::Clusters::WakeOnLan::Id, chip::app::Clusters::MediaPlayback::Id,
chip::app::Clusters::LowPower::Id, chip::app::Clusters::KeypadInput::Id,
chip::app::Clusters::ContentLauncher::Id, chip::app::Clusters::AudioOutput::Id };
chip::app::Clusters::ContentLauncher::Id, chip::app::Clusters::AudioOutput::Id,
chip::app::Clusters::Messages::Id };
}
return {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,13 @@ private void runCertTests(Activity activity) {
kContentApp, successCallbackInteger, failureCallback);
});

runAndWait(
"messages_presentMessages",
successFailureCallback,
() -> {
tvCastingApp.messages_presentMessages(kTVApp, "CastingAppTestMessage", callback);
});

runAndWait(
"mediaPlayback_subscribeToCurrentState",
successFailureCallback,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,9 @@ public native boolean applicationBasic_readApplicationVersion(

public native boolean onOff_toggle(ContentApp contentApp, Object responseHandler);

public native boolean messages_presentMessages(
ContentApp contentApp, String messageText, Object responseHandler);

static {
System.loadLibrary("TvCastingApp");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ enum MediaCommandName
MediaPlayback_Seek,
MediaPlayback_SkipForward,
MediaPlayback_SkipBackward,
Messages_PresentMessagesRequest,
ApplicationLauncher_LaunchApp,
ApplicationLauncher_StopApp,
ApplicationLauncher_HideApp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,36 @@ JNI_METHOD(jboolean, onOff_1toggle)
return (err == CHIP_NO_ERROR);
}

JNI_METHOD(jboolean, messages_1presentMessages)
(JNIEnv * env, jobject, jobject contentApp, jstring messageText, jobject jResponseHandler)
{
chip::DeviceLayer::StackLock lock;

ChipLogProgress(AppServer, "JNI_METHOD messages_presentMessages called");
const char * nativeMessageText = env->GetStringUTFChars(messageText, 0);

TargetEndpointInfo endpoint;
CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint);
VerifyOrExit(err == CHIP_NO_ERROR,
ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT,
err.Format()));

err = TvCastingAppJNIMgr().getMediaCommandResponseHandler(Messages_PresentMessagesRequest).SetUp(env, jResponseHandler);
VerifyOrExit(CHIP_NO_ERROR == err,
ChipLogError(AppServer, "MatterCallbackHandlerJNI.SetUp failed %" CHIP_ERROR_FORMAT, err.Format()));

err = CastingServer::GetInstance()->Messages_PresentMessagesRequest(&endpoint, nativeMessageText, [](CHIP_ERROR err) {
TvCastingAppJNIMgr().getMediaCommandResponseHandler(Messages_PresentMessagesRequest).Handle(err);
});
VerifyOrExit(CHIP_NO_ERROR == err,
ChipLogError(AppServer, "CastingServer.Messages_PresentMessagesRequest failed %" CHIP_ERROR_FORMAT, err.Format()));

env->ReleaseStringUTFChars(messageText, nativeMessageText);

exit:
return (err == CHIP_NO_ERROR);
}

JNI_METHOD(jboolean, mediaPlayback_1play)
(JNIEnv * env, jobject, jobject contentApp, jobject jResponseHandler)
{
Expand Down
2 changes: 2 additions & 0 deletions examples/tv-casting-app/tv-casting-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ chip_data_model("tv-casting-common") {
"include/MediaPlayback.h",
"include/MediaReadBase.h",
"include/MediaSubscriptionBase.h",
"include/Messages.h",
"include/OnOff.h",
"include/PersistenceManager.h",
"include/TargetEndpointInfo.h",
Expand All @@ -83,6 +84,7 @@ chip_data_model("tv-casting-common") {
"src/KeypadInput.cpp",
"src/LevelControl.cpp",
"src/MediaPlayback.cpp",
"src/Messages.cpp",
"src/OnOff.cpp",
"src/PersistenceManager.cpp",
"src/TargetEndpointInfo.cpp",
Expand Down
12 changes: 12 additions & 0 deletions examples/tv-casting-app/tv-casting-common/include/CastingServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "KeypadInput.h"
#include "LevelControl.h"
#include "MediaPlayback.h"
#include "Messages.h"
#include "OnOff.h"
#include "PersistenceManager.h"
#include "TargetEndpointInfo.h"
Expand Down Expand Up @@ -186,6 +187,12 @@ class CastingServer : public AppDelegate
CHIP_ERROR OnOff_Off(TargetEndpointInfo * endpoint, std::function<void(CHIP_ERROR)> responseCallback);
CHIP_ERROR OnOff_Toggle(TargetEndpointInfo * endpoint, std::function<void(CHIP_ERROR)> responseCallback);

/**
* @brief Messages cluster
*/
CHIP_ERROR Messages_PresentMessagesRequest(TargetEndpointInfo * endpoint, const char * messageText,
std::function<void(CHIP_ERROR)> responseCallback);

/**
* @brief Media Playback cluster
*/
Expand Down Expand Up @@ -510,6 +517,11 @@ class CastingServer : public AppDelegate
OffCommand mOffCommand;
ToggleCommand mToggleCommand;

/**
* @brief OnOff cluster
*/
PresentMessagesRequestCommand mPresentMessagesRequestCommand;

/**
* @brief Media Playback cluster
*/
Expand Down
36 changes: 36 additions & 0 deletions examples/tv-casting-app/tv-casting-common/include/Messages.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
*
* Copyright (c) 2024 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.
*/

#include "MediaCommandBase.h"
#include "MediaSubscriptionBase.h"

#include <controller/CHIPCluster.h>
#include <functional>

#include <app-common/zap-generated/cluster-objects.h>

// COMMAND CLASSES
class PresentMessagesRequestCommand : public MediaCommandBase<chip::app::Clusters::Messages::Commands::PresentMessagesRequest::Type,
chip::app::DataModel::NullObjectType>
{
public:
PresentMessagesRequestCommand() : MediaCommandBase(chip::app::Clusters::Messages::Id) {}

CHIP_ERROR
Invoke(const char * messageText, std::function<void(CHIP_ERROR)> responseCallback);
};
10 changes: 10 additions & 0 deletions examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,16 @@ CHIP_ERROR CastingServer::OnOff_Toggle(TargetEndpointInfo * endpoint, std::funct
return mToggleCommand.Invoke(responseCallback);
}

/**
* @brief Messages cluster
*/
CHIP_ERROR CastingServer::Messages_PresentMessagesRequest(TargetEndpointInfo * endpoint, const char * messageText,
std::function<void(CHIP_ERROR)> responseCallback)
{
ReturnErrorOnFailure(mPresentMessagesRequestCommand.SetTarget(mActiveTargetVideoPlayerInfo, endpoint->GetEndpointId()));
return mPresentMessagesRequestCommand.Invoke(messageText, responseCallback);
}

/**
* @brief Media Playback cluster
*/
Expand Down
38 changes: 38 additions & 0 deletions examples/tv-casting-app/tv-casting-common/src/Messages.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
*
* Copyright (c) 2024 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.
*/

#include "Messages.h"

using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::Messages;

CHIP_ERROR PresentMessagesRequestCommand::Invoke(const char * messageText, std::function<void(CHIP_ERROR)> responseCallback)
{
Messages::Commands::PresentMessagesRequest::Type request;
uint8_t buf[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 };

request.messageID = ByteSpan(buf, sizeof(buf));
request.messageText = CharSpan::fromCharString(messageText);
request.priority = MessagePriorityEnum(static_cast<uint8_t>(0));
request.startTime = DataModel::Nullable<uint32_t>(static_cast<uint32_t>(0));
request.duration = DataModel::Nullable<uint64_t>(static_cast<uint64_t>(60 * 1000));

return MediaCommandBase::Invoke(request, responseCallback);
}
2 changes: 1 addition & 1 deletion integrations/docker/images/base/chip-build/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
39 : [Python] Add ruff Python linter to chip-build
40 : [NuttX] Add support for NuttX SDK
Loading

0 comments on commit 7af575f

Please sign in to comment.