diff --git a/.github/workflows/darwin.yaml b/.github/workflows/darwin.yaml index 0602b735d36b88..088c541495665b 100644 --- a/.github/workflows/darwin.yaml +++ b/.github/workflows/darwin.yaml @@ -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 diff --git a/examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/fragments/TerminalFragment.java b/examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/fragments/TerminalFragment.java index 660025e76c2a83..30faf145b5b97b 100644 --- a/examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/fragments/TerminalFragment.java +++ b/examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/fragments/TerminalFragment.java @@ -24,6 +24,8 @@ public class TerminalFragment extends Fragment { private static String TERMINAL_INSTRUCTIONS = "add [] Add app with given vendor ID [1, 2, 9050]. Usage: add 9050\r\n" + "remove Remove app at given endpoint [6, 7, etc]. Usage: remove 6\r\n" + + "appobserver Send app observer command to client node of the given app endpoint. Usage: appobserver 4 0 data hint\r\n" + + "printclients Print list of client nodes for the given app endpoint. Usage: printclients 4\r\n" + "setpin Set pincode for app with given endpoint ID. Usage: setpin 6 34567890\r\n" + "commission Commission given udc-entry using given pincode from corresponding app. Usage:" + "commission 0\r\n" diff --git a/examples/tv-app/android/java/AppImpl.cpp b/examples/tv-app/android/java/AppImpl.cpp index 3c50d759d6900f..1dfae0f8afd3f2 100644 --- a/examples/tv-app/android/java/AppImpl.cpp +++ b/examples/tv-app/android/java/AppImpl.cpp @@ -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(gDataVersions[i]), Span(gContentAppDeviceType)); return app; @@ -422,11 +423,16 @@ std::list 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, @@ -434,7 +440,8 @@ std::list ContentAppFactoryImpl::GetAllowedClusterListForStaticEndpoi 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 {}; } diff --git a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessagesManagerStub.java b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessagesManagerStub.java index b31f14a112304b..4f115c5130e25d 100644 --- a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessagesManagerStub.java +++ b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessagesManagerStub.java @@ -31,13 +31,6 @@ public class MessagesManagerStub implements MessagesManager { public MessagesManagerStub(int endpoint) { this.endpoint = endpoint; Log.d(TAG, "MessagesManagerStub: at " + this.endpoint); - - HashMap responseOptions = new HashMap(); - 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 diff --git a/examples/tv-app/tv-common/shell/AppTvShellCommands.cpp b/examples/tv-app/tv-common/shell/AppTvShellCommands.cpp index c66beb94e1dd7f..6b946766fae60a 100644 --- a/examples/tv-app/tv-common/shell/AppTvShellCommands.cpp +++ b/examples/tv-app/tv-common/shell/AppTvShellCommands.cpp @@ -193,6 +193,11 @@ static CHIP_ERROR PrintAllCommands() #if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED streamer_printf(sout, " add [] Add app with given vendor ID [1, 2, 9050]. Usage: app add 9050\r\n"); streamer_printf(sout, " remove Remove app at given endpoint [6, 7, etc]. Usage: app remove 6\r\n"); + streamer_printf(sout, + " appobserver Send app observer command to client node of " + "the given app endpoint. Usage: appobserver 4 0 data hint\r\n"); + streamer_printf( + sout, " printclients Print list of client nodes for the given app endpoint. Usage: printclients 4\r\n"); streamer_printf( sout, " setpin Set pincode for app with given endpoint ID. Usage: app setpin 6 34567890\r\n"); streamer_printf(sout, @@ -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) diff --git a/examples/tv-app/tv-common/src/AppTv.cpp b/examples/tv-app/tv-common/src/AppTv.cpp index 939e14be5315cc..8fd076b227b882 100644 --- a/examples/tv-app/tv-common/src/AppTv.cpp +++ b/examples/tv-app/tv-common/src/AppTv.cpp @@ -549,11 +549,16 @@ std::list 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, @@ -561,7 +566,8 @@ std::list ContentAppFactoryImpl::GetAllowedClusterListForStaticEndpoi 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 {}; } diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/CertTestFragment.java b/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/CertTestFragment.java index 340563c28b322c..7ee9fa3c46a0ae 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/CertTestFragment.java +++ b/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/CertTestFragment.java @@ -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, diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java index 24852986768e7c..9dd0fa500d9e2b 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java +++ b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java @@ -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"); } diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/Constants.h b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/Constants.h index b1947541c9c9b7..735cabf2375f51 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/Constants.h +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/Constants.h @@ -37,6 +37,7 @@ enum MediaCommandName MediaPlayback_Seek, MediaPlayback_SkipForward, MediaPlayback_SkipBackward, + Messages_PresentMessagesRequest, ApplicationLauncher_LaunchApp, ApplicationLauncher_StopApp, ApplicationLauncher_HideApp, diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp index 0cbfab8b5864b8..6dbdfba9c83449 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp @@ -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) { diff --git a/examples/tv-casting-app/tv-casting-common/BUILD.gn b/examples/tv-casting-app/tv-casting-common/BUILD.gn index ea6607a724b5cb..72f14fb7bffeee 100644 --- a/examples/tv-casting-app/tv-casting-common/BUILD.gn +++ b/examples/tv-casting-app/tv-casting-common/BUILD.gn @@ -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", @@ -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", diff --git a/examples/tv-casting-app/tv-casting-common/include/CastingServer.h b/examples/tv-casting-app/tv-casting-common/include/CastingServer.h index 349edaefb31a79..d64f5049df1a8f 100644 --- a/examples/tv-casting-app/tv-casting-common/include/CastingServer.h +++ b/examples/tv-casting-app/tv-casting-common/include/CastingServer.h @@ -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" @@ -186,6 +187,12 @@ class CastingServer : public AppDelegate CHIP_ERROR OnOff_Off(TargetEndpointInfo * endpoint, std::function responseCallback); CHIP_ERROR OnOff_Toggle(TargetEndpointInfo * endpoint, std::function responseCallback); + /** + * @brief Messages cluster + */ + CHIP_ERROR Messages_PresentMessagesRequest(TargetEndpointInfo * endpoint, const char * messageText, + std::function responseCallback); + /** * @brief Media Playback cluster */ @@ -510,6 +517,11 @@ class CastingServer : public AppDelegate OffCommand mOffCommand; ToggleCommand mToggleCommand; + /** + * @brief OnOff cluster + */ + PresentMessagesRequestCommand mPresentMessagesRequestCommand; + /** * @brief Media Playback cluster */ diff --git a/examples/tv-casting-app/tv-casting-common/include/Messages.h b/examples/tv-casting-app/tv-casting-common/include/Messages.h new file mode 100644 index 00000000000000..623ede9e914074 --- /dev/null +++ b/examples/tv-casting-app/tv-casting-common/include/Messages.h @@ -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 +#include + +#include + +// COMMAND CLASSES +class PresentMessagesRequestCommand : public MediaCommandBase +{ +public: + PresentMessagesRequestCommand() : MediaCommandBase(chip::app::Clusters::Messages::Id) {} + + CHIP_ERROR + Invoke(const char * messageText, std::function responseCallback); +}; diff --git a/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp b/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp index a3de0a263c3efe..4cb72732292a2e 100644 --- a/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp +++ b/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp @@ -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 responseCallback) +{ + ReturnErrorOnFailure(mPresentMessagesRequestCommand.SetTarget(mActiveTargetVideoPlayerInfo, endpoint->GetEndpointId())); + return mPresentMessagesRequestCommand.Invoke(messageText, responseCallback); +} + /** * @brief Media Playback cluster */ diff --git a/examples/tv-casting-app/tv-casting-common/src/Messages.cpp b/examples/tv-casting-app/tv-casting-common/src/Messages.cpp new file mode 100644 index 00000000000000..ea6176fd93405e --- /dev/null +++ b/examples/tv-casting-app/tv-casting-common/src/Messages.cpp @@ -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 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(0)); + request.startTime = DataModel::Nullable(static_cast(0)); + request.duration = DataModel::Nullable(static_cast(60 * 1000)); + + return MediaCommandBase::Invoke(request, responseCallback); +} diff --git a/integrations/docker/images/base/chip-build/Dockerfile b/integrations/docker/images/base/chip-build/Dockerfile index b16429fcc8eab2..39aada6fec7af8 100644 --- a/integrations/docker/images/base/chip-build/Dockerfile +++ b/integrations/docker/images/base/chip-build/Dockerfile @@ -152,6 +152,7 @@ RUN set -x \ portpicker \ pygit \ PyGithub \ + ruff \ tabulate \ && : # last line diff --git a/integrations/docker/images/base/chip-build/version b/integrations/docker/images/base/chip-build/version index fe142046be7c1c..498993f769c75d 100644 --- a/integrations/docker/images/base/chip-build/version +++ b/integrations/docker/images/base/chip-build/version @@ -1 +1 @@ -38 : [NXP] Update Docker image for K32W1 SDK +40 : [NuttX] Add support for NuttX SDK diff --git a/integrations/docker/images/stage-2/chip-build-nuttx/Dockerfile b/integrations/docker/images/stage-2/chip-build-nuttx/Dockerfile new file mode 100644 index 00000000000000..0912ea49f15477 --- /dev/null +++ b/integrations/docker/images/stage-2/chip-build-nuttx/Dockerfile @@ -0,0 +1,41 @@ +ARG VERSION=1 +FROM ghcr.io/project-chip/chip-build:${VERSION} +LABEL org.opencontainers.image.source https://github.com/project-chip/connectedhomeip + +# ------------------------------------------------------------------------------ +# Install prerequisites +RUN set -x \ + && dpkg --add-architecture i386 \ + && apt update -y \ + && apt install -y genromfs xxd libgmp-dev libmpfr-dev libmpc-dev \ + && : # last line + +# ------------------------------------------------------------------------------ +# Download and build g++-13 +RUN set -x \ + && ! test -d /opt/nuttx/gcc-13 \ + && wget -P gcc_build https://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-13.1.0/gcc-13.1.0.tar.gz \ + && cd gcc_build \ + && tar xzf gcc-13.1.0.tar.gz \ + && cd gcc-13.1.0 \ + && ./configure --prefix=/opt/nuttx/gcc-13 --disable-multilib \ + && make -j8 \ + && make install-strip \ + && rm -rf ../../gcc_build \ + && : # last line + +# ------------------------------------------------------------------------------ +# Download NuttX SDK +RUN set -x \ + && cd /opt/nuttx \ + && wget -q -O nuttx.zip https://codeload.github.com/apache/nuttx/zip/b8e0423 \ + && unzip -q nuttx.zip \ + && mv nuttx-b8e0423 nuttx \ + && rm nuttx.zip + +RUN set -x \ + && cd /opt/nuttx \ + && wget -q -O nuttx_app.zip https://codeload.github.com/apache/nuttx-apps/zip/9c48a8d \ + && unzip -q nuttx_app.zip \ + && mv nuttx-apps-9c48a8d apps \ + && rm nuttx_app.zip diff --git a/integrations/docker/images/stage-2/chip-build-nuttx/build.sh b/integrations/docker/images/stage-2/chip-build-nuttx/build.sh new file mode 120000 index 00000000000000..46b20313461454 --- /dev/null +++ b/integrations/docker/images/stage-2/chip-build-nuttx/build.sh @@ -0,0 +1 @@ +../../../build.sh \ No newline at end of file diff --git a/integrations/docker/images/stage-2/chip-build-nuttx/run.sh b/integrations/docker/images/stage-2/chip-build-nuttx/run.sh new file mode 120000 index 00000000000000..9bbfad86d46e50 --- /dev/null +++ b/integrations/docker/images/stage-2/chip-build-nuttx/run.sh @@ -0,0 +1 @@ +../../../run.sh \ No newline at end of file diff --git a/integrations/docker/images/stage-2/chip-build-nuttx/version b/integrations/docker/images/stage-2/chip-build-nuttx/version new file mode 120000 index 00000000000000..a40ba48b0188a8 --- /dev/null +++ b/integrations/docker/images/stage-2/chip-build-nuttx/version @@ -0,0 +1 @@ +../../base/chip-build/version \ No newline at end of file diff --git a/integrations/docker/images/vscode/chip-build-vscode/Dockerfile b/integrations/docker/images/vscode/chip-build-vscode/Dockerfile index 91e9a9b5036158..83556ee8ef6d0e 100644 --- a/integrations/docker/images/vscode/chip-build-vscode/Dockerfile +++ b/integrations/docker/images/vscode/chip-build-vscode/Dockerfile @@ -17,6 +17,7 @@ FROM ghcr.io/project-chip/chip-build-ti:${VERSION} AS ti FROM ghcr.io/project-chip/chip-build-openiotsdk:${VERSION} AS openiotsdk FROM ghcr.io/project-chip/chip-build-bouffalolab:${VERSION} AS bouffalolab FROM ghcr.io/project-chip/chip-build-asr:${VERSION} AS asr +FROM ghcr.io/project-chip/chip-build-nuttx:${VERSION} AS nuttx FROM ghcr.io/project-chip/chip-build:${VERSION} LABEL org.opencontainers.image.source https://github.com/project-chip/connectedhomeip @@ -67,6 +68,8 @@ COPY --from=efr32 /opt/silabs/gecko_sdk /opt/silabs/gecko_sdk COPY --from=efr32 /opt/silabs/wiseconnect-wifi-bt-sdk /opt/silabs/wiseconnect-wifi-bt-sdk COPY --from=efr32 /opt/silabs/wifi_sdk /opt/silabs/wifi_sdk +COPY --from=nuttx /opt/nuttx /opt/nuttx + # Android license file "acceping" is done by writing license hashes # into the 'licenses' subfolder. This allows any user (in particular # 'vscode' to accept licenses) diff --git a/src/app/app-platform/ContentApp.cpp b/src/app/app-platform/ContentApp.cpp index 3bc16e9555ced5..9a6b4ad6b5e317 100644 --- a/src/app/app-platform/ContentApp.cpp +++ b/src/app/app-platform/ContentApp.cpp @@ -44,6 +44,8 @@ namespace AppPlatform { #define ZCL_DESCRIPTOR_CLUSTER_REVISION (1u) #define ZCL_APPLICATION_BASIC_CLUSTER_REVISION (1u) +inline constexpr EndpointId kCastingVideoPlayerEndpointId = 1; + Status ContentApp::HandleReadAttribute(ClusterId clusterId, AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength) { ChipLogProgress(DeviceLayer, @@ -62,6 +64,113 @@ Status ContentApp::HandleWriteAttribute(ClusterId clusterId, AttributeId attribu return Status::Failure; } +void ContentApp::AddClientNode(NodeId subjectNodeId) +{ + mClientNodes[mNextClientNodeIndex++] = subjectNodeId; + if (mClientNodeCount < kMaxClientNodes) + { + mClientNodeCount++; + } + if (mNextClientNodeIndex >= kMaxClientNodes) + { + // if we exceed the max number, then overwrite the oldest entry + mNextClientNodeIndex = 0; + } +} + +void ContentApp::SendAppObserverCommand(chip::Controller::DeviceCommissioner * commissioner, NodeId clientNodeId, char * data, + char * encodingHint) +{ + ChipLogProgress(Controller, "Attempting to send AppObserver command"); + if (mContentAppClientCommandSender.IsBusy()) + { + ChipLogProgress(Controller, "SendAppObserverCommand busy"); + return; + } + + mContentAppClientCommandSender.SendContentAppMessage(commissioner, clientNodeId, kCastingVideoPlayerEndpointId, data, + encodingHint); + + ChipLogProgress(Controller, "Completed send of AppObserver command"); +} + +CHIP_ERROR ContentAppClientCommandSender::SendContentAppMessage(chip::Controller::DeviceCommissioner * commissioner, + chip::NodeId destinationId, chip::EndpointId endPointId, + char * data, char * encodingHint) +{ + if (mIsBusy) + { + return CHIP_ERROR_INCORRECT_STATE; + } + mIsBusy = true; + mDestinationId = destinationId; + mEndPointId = endPointId; + mData = std::string(data); + mEncodingHint = std::string(encodingHint); + + ChipLogProgress(Controller, "Sending command to node 0x" ChipLogFormatX64, ChipLogValueX64(mDestinationId)); + + return commissioner->GetConnectedDevice(mDestinationId, &mOnDeviceConnectedCallback, &mOnDeviceConnectionFailureCallback); +} + +void ContentAppClientCommandSender::OnDeviceConnectedFn(void * context, chip::Messaging::ExchangeManager & exchangeMgr, + const chip::SessionHandle & sessionHandle) +{ + ChipLogProgress(Controller, "ContentAppClientCommandSender::OnDeviceConnectedFn"); + ContentAppClientCommandSender * sender = reinterpret_cast(context); + VerifyOrReturn(sender != nullptr, ChipLogError(chipTool, "OnDeviceConnectedFn: context is null")); + + sender->SendMessage(exchangeMgr, sessionHandle); +} + +CHIP_ERROR ContentAppClientCommandSender::SendMessage(chip::Messaging::ExchangeManager & exchangeMgr, + const chip::SessionHandle & sessionHandle) +{ + ChipLogProgress(Controller, "ContentAppClientCommandSender::SendMessage"); + + chip::Controller::ClusterBase cluster(exchangeMgr, sessionHandle, mEndPointId); + + chip::app::Clusters::ContentAppObserver::Commands::ContentAppMessage::Type request; + request.data = Optional(CharSpan::fromCharString(mData.c_str())); + request.encodingHint = CharSpan::fromCharString(mEncodingHint.c_str()); + CHIP_ERROR err = cluster.InvokeCommand(request, nullptr, OnCommandResponse, OnCommandFailure); + if (err != CHIP_NO_ERROR) + { + ChipLogDetail(Controller, "ContentAppClientCommandSender SendMessage error err %s", ErrorStr(err)); + } + + mIsBusy = false; + ChipLogProgress(Controller, "ContentAppClientCommandSender: Completed send of AppObserver command"); + + return CHIP_NO_ERROR; +} + +void ContentAppClientCommandSender::OnDeviceConnectionFailureFn(void * context, const chip::ScopedNodeId & peerId, CHIP_ERROR err) +{ + ChipLogProgress(Controller, "ContentAppClientCommandSender::OnDeviceConnectedFn error err %s", ErrorStr(err)); + + ContentAppClientCommandSender * sender = reinterpret_cast(context); + VerifyOrReturn(sender != nullptr, ChipLogError(chipTool, "OnDeviceConnectionFailureFn: context is null")); + + sender->Cleanup(); +} + +void ContentAppClientCommandSender::Cleanup() +{ + ChipLogProgress(Controller, "ContentAppClientCommandSender::Cleanup"); + mIsBusy = false; +} + +void ContentAppClientCommandSender::OnCommandResponse(void * context, const ContentAppMessageResponseDecodableType & response) +{ + ChipLogProgress(Controller, "ContentAppClientCommandSender::OnCommandResponse"); +} + +void ContentAppClientCommandSender::OnCommandFailure(void * context, CHIP_ERROR error) +{ + ChipLogProgress(Controller, "ContentAppClientCommandSender::OnCommandFailure error err %s", ErrorStr(error)); +} + } // namespace AppPlatform } // namespace chip diff --git a/src/app/app-platform/ContentApp.h b/src/app/app-platform/ContentApp.h index d3b7d1fb2b2187..34b1dd5ef41893 100644 --- a/src/app/app-platform/ContentApp.h +++ b/src/app/app-platform/ContentApp.h @@ -33,6 +33,7 @@ #include #include #include +#include #include namespace chip { @@ -48,6 +49,46 @@ using KeypadInputDelegate = app::Clusters::KeypadInput::Delegate; using MediaPlaybackDelegate = app::Clusters::MediaPlayback::Delegate; using TargetNavigatorDelegate = app::Clusters::TargetNavigator::Delegate; +inline constexpr uint8_t kMaxClientNodes = 8; + +class ContentAppClientCommandSender +{ +public: + ContentAppClientCommandSender() : + mOnDeviceConnectedCallback(OnDeviceConnectedFn, this), mOnDeviceConnectionFailureCallback(OnDeviceConnectionFailureFn, this) + {} + + bool IsBusy() const { return mIsBusy; } + CHIP_ERROR SendContentAppMessage(chip::Controller::DeviceCommissioner * commissioner, chip::NodeId destinationId, + chip::EndpointId endPointId, char * data, char * encodingHint); + +protected: + CHIP_ERROR SendMessage(chip::Messaging::ExchangeManager & exchangeMgr, const chip::SessionHandle & sessionHandle); + + void Cleanup(); + +private: + static void OnDeviceConnectedFn(void * context, chip::Messaging::ExchangeManager & exchangeMgr, + const chip::SessionHandle & sessionHandle); + static void OnDeviceConnectionFailureFn(void * context, const chip::ScopedNodeId & peerId, CHIP_ERROR error); + + using ContentAppMessageResponseDecodableType = + chip::app::Clusters::ContentAppObserver::Commands::ContentAppMessageResponse::DecodableType; + + static void OnCommandResponse(void * context, const ContentAppMessageResponseDecodableType & response); + static void OnCommandFailure(void * context, CHIP_ERROR error); + + chip::Callback::Callback mOnDeviceConnectedCallback; + chip::Callback::Callback mOnDeviceConnectionFailureCallback; + + bool mIsBusy = false; + chip::NodeId mDestinationId = 0; + chip::EndpointId mEndPointId = 0; + + std::string mData; + std::string mEncodingHint; +}; + class DLL_EXPORT ContentApp { public: @@ -70,8 +111,21 @@ class DLL_EXPORT ContentApp uint16_t maxReadLength); Protocols::InteractionModel::Status HandleWriteAttribute(ClusterId clusterId, AttributeId attributeId, uint8_t * buffer); + void AddClientNode(NodeId clientNodeId); + uint8_t GetClientNodeCount() const { return mClientNodeCount; } + NodeId GetClientNode(uint8_t index) const { return mClientNodes[index]; } + + void SendAppObserverCommand(chip::Controller::DeviceCommissioner * commissioner, NodeId clientNodeId, char * data, + char * encodingHint); + protected: EndpointId mEndpointId = 0; + + uint8_t mClientNodeCount = 0; + uint8_t mNextClientNodeIndex = 0; + NodeId mClientNodes[kMaxClientNodes]; + + ContentAppClientCommandSender mContentAppClientCommandSender; }; } // namespace AppPlatform diff --git a/src/app/app-platform/ContentAppPlatform.cpp b/src/app/app-platform/ContentAppPlatform.cpp index 09d6c55b14454d..3d17a521996b65 100644 --- a/src/app/app-platform/ContentAppPlatform.cpp +++ b/src/app/app-platform/ContentAppPlatform.cpp @@ -716,6 +716,7 @@ CHIP_ERROR ContentAppPlatform::ManageClientAccess(Messaging::ExchangeManager & e continue; } + bool accessAllowed = false; for (const auto & allowedVendor : app->GetApplicationBasicDelegate()->GetAllowedVendorList()) { if (allowedVendor == targetVendorId) @@ -732,6 +733,12 @@ CHIP_ERROR ContentAppPlatform::ManageClientAccess(Messaging::ExchangeManager & e .fabricIndex = kUndefinedFabricIndex, }); } + accessAllowed = true; + } + if (accessAllowed) + { + // notify content app about this nodeId + app->AddClientNode(subjectNodeId); } } } diff --git a/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-provider.cpp b/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-provider.cpp index 26a988b1c51450..69ec2a5e13a65e 100644 --- a/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-provider.cpp +++ b/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-provider.cpp @@ -670,16 +670,9 @@ CHIP_ERROR WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, a break; case Attributes::ActiveNetworkFaultsList::Id: { - err = encoder.EncodeList([](const auto & aEncoder) -> CHIP_ERROR { - // TODO activeNetworkFaultsList isn't tracked. Encode the list of 4 entries at 0 none the less - NetworkFaultEnum activeNetworkFaultsList[4] = { NetworkFaultEnum(0) }; - for (auto fault : activeNetworkFaultsList) - { - ReturnErrorOnFailure(aEncoder.Encode(fault)); - } - - return CHIP_NO_ERROR; - }); + // activeNetworkFaults are not tracked by the thread stack nor the ThreadStackManager. + // Encode an emptyList to indicate there are currently no active faults. + err = encoder.EncodeEmptyList(); } break; diff --git a/src/app/tests/TestReadInteraction.cpp b/src/app/tests/TestReadInteraction.cpp index 9e8bc58e5d87da..13ae20862a4c35 100644 --- a/src/app/tests/TestReadInteraction.cpp +++ b/src/app/tests/TestReadInteraction.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/src/controller/CommissionerDiscoveryController.cpp b/src/controller/CommissionerDiscoveryController.cpp index 86849a32f91271..ee94bc87b92670 100644 --- a/src/controller/CommissionerDiscoveryController.cpp +++ b/src/controller/CommissionerDiscoveryController.cpp @@ -110,8 +110,25 @@ void CommissionerDiscoveryController::OnUserDirectedCommissioningRequest(UDCClie ChipLogDetail(Controller, "------Via Shell Enter: controller ux ok|cancel"); } +/// Callback for getting execution into the main chip thread +void CallbackOk(System::Layer * aSystemLayer, void * aAppState) +{ + ChipLogDetail(AppServer, "UX Ok: now on main thread"); + CommissionerDiscoveryController * cdc = static_cast(aAppState); + cdc->InternalOk(); +} + void CommissionerDiscoveryController::Ok() { + ChipLogDetail(AppServer, "UX Ok: moving to main thread"); + // need to ensure callback is on main chip thread + assertChipStackLockedByCurrentThread(); + DeviceLayer::SystemLayer().StartTimer(System::Clock::Seconds32(0), CallbackOk, this); +} + +void CommissionerDiscoveryController::InternalOk() +{ + ChipLogDetail(AppServer, "UX InternalOk"); if (!mPendingConsent) { ChipLogError(AppServer, "UX Ok: no current instance"); diff --git a/src/controller/CommissionerDiscoveryController.h b/src/controller/CommissionerDiscoveryController.h index 42a0bb6f327fc9..f0dcf6d5f95869 100644 --- a/src/controller/CommissionerDiscoveryController.h +++ b/src/controller/CommissionerDiscoveryController.h @@ -273,6 +273,7 @@ class CommissionerDiscoveryController : public chip::Protocols::UserDirectedComm * indicated in the UserPrompter's PromptForCommissionOKPermission callback */ void Ok(); + void InternalOk(); /** * This method should be called after the user has declined to give consent for commissioning of the client diff --git a/src/darwin/Framework/CHIP/MTRDevice.mm b/src/darwin/Framework/CHIP/MTRDevice.mm index 2fe8032ce294a0..fa6b524fb6fab6 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.mm +++ b/src/darwin/Framework/CHIP/MTRDevice.mm @@ -939,7 +939,7 @@ - (void)_handleEventReport:(NSArray *> *)eventRepor } } } - MTR_LOG_INFO("%@ _getCachedDataVersions dataVersions count: %lu readCache count: %lu", self, dataVersions.count, _readCache.count); + MTR_LOG_INFO("%@ _getCachedDataVersions dataVersions count: %lu readCache count: %lu", self, static_cast(dataVersions.count), static_cast(_readCache.count)); os_unfair_lock_unlock(&self->_lock); return dataVersions; @@ -1996,7 +1996,7 @@ - (NSArray *)_getAttributesToReportWithReportedValues:(NSArray *)attributeValues reportChanges:(BOOL)reportChanges { - MTR_LOG_INFO("%@ setAttributeValues count: %lu reportChanges: %d", self, attributeValues.count, reportChanges); + MTR_LOG_INFO("%@ setAttributeValues count: %lu reportChanges: %d", self, static_cast(attributeValues.count), reportChanges); os_unfair_lock_lock(&self->_lock); if (reportChanges) { diff --git a/src/darwin/Framework/CHIP/MTRDeviceController.mm b/src/darwin/Framework/CHIP/MTRDeviceController.mm index 8b7c1a3a231a2f..fa90eb2f542831 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceController.mm @@ -887,7 +887,7 @@ - (MTRDevice *)deviceForNodeID:(NSNumber *)nodeID // Load persisted attributes if they exist. NSArray * attributesFromCache = [_controllerDataStore getStoredAttributesForNodeID:nodeID]; - MTR_LOG_INFO("Loaded %lu attributes from storage for %@", attributesFromCache.count, deviceToReturn); + MTR_LOG_INFO("Loaded %lu attributes from storage for %@", static_cast(attributesFromCache.count), deviceToReturn); if (attributesFromCache.count) { [deviceToReturn setAttributeValues:attributesFromCache reportChanges:NO]; } diff --git a/src/include/platform/ThreadStackManager.h b/src/include/platform/ThreadStackManager.h index cda3c7acdccbd5..523b4fe8ceaad9 100644 --- a/src/include/platform/ThreadStackManager.h +++ b/src/include/platform/ThreadStackManager.h @@ -23,6 +23,8 @@ #pragma once +#include + #include #include #include diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.ipp b/src/include/platform/internal/GenericConfigurationManagerImpl.ipp index ad463a8eba9eea..24c6a28113906d 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.ipp +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.ipp @@ -397,7 +397,7 @@ template CHIP_ERROR GenericConfigurationManagerImpl::GetPrimary802154MACAddress(uint8_t * buf) { #if CHIP_DEVICE_CONFIG_ENABLE_THREAD - return ThreadStackManager().GetPrimary802154MACAddress(buf); + return ThreadStackMgr().GetPrimary802154MACAddress(buf); #else return CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD diff --git a/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.h b/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.h index 456d843c488224..3e0e6c1a18a171 100755 --- a/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.h +++ b/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.h @@ -25,6 +25,7 @@ #pragma once #include +#include #include #include diff --git a/src/include/platform/internal/GenericConnectivityManagerImpl_WiFi.h b/src/include/platform/internal/GenericConnectivityManagerImpl_WiFi.h index 61c2db51954c8e..24cc0032389280 100644 --- a/src/include/platform/internal/GenericConnectivityManagerImpl_WiFi.h +++ b/src/include/platform/internal/GenericConnectivityManagerImpl_WiFi.h @@ -23,6 +23,7 @@ #pragma once +#include #include #include #include diff --git a/src/messaging/ReliableMessageMgr.cpp b/src/messaging/ReliableMessageMgr.cpp index 2db80c5ffd337e..2445bf4611a06e 100644 --- a/src/messaging/ReliableMessageMgr.cpp +++ b/src/messaging/ReliableMessageMgr.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include #include diff --git a/src/messaging/ReliableMessageProtocolConfig.cpp b/src/messaging/ReliableMessageProtocolConfig.cpp index d1a4deece9c0f8..d2cda6123af5cb 100644 --- a/src/messaging/ReliableMessageProtocolConfig.cpp +++ b/src/messaging/ReliableMessageProtocolConfig.cpp @@ -21,14 +21,13 @@ * for the CHIP Reliable Messaging Protocol. * */ - #include +#include +#include #include #include -#include - #if CHIP_CONFIG_ENABLE_ICD_SERVER #include // nogncheck #endif diff --git a/src/messaging/tests/TestAbortExchangesForFabric.cpp b/src/messaging/tests/TestAbortExchangesForFabric.cpp index 455462bb14e2e4..a9999eb6c2f9e0 100644 --- a/src/messaging/tests/TestAbortExchangesForFabric.cpp +++ b/src/messaging/tests/TestAbortExchangesForFabric.cpp @@ -21,6 +21,7 @@ * one) for a fabric. */ +#include #include #include #include diff --git a/src/messaging/tests/TestReliableMessageProtocol.cpp b/src/messaging/tests/TestReliableMessageProtocol.cpp index cfdd00bff624f5..505a54f4b0a11e 100644 --- a/src/messaging/tests/TestReliableMessageProtocol.cpp +++ b/src/messaging/tests/TestReliableMessageProtocol.cpp @@ -22,6 +22,7 @@ * implementation. */ +#include #include #include #include diff --git a/src/platform/Linux/BUILD.gn b/src/platform/Linux/BUILD.gn index 061f052869d883..4f28b2d520e066 100644 --- a/src/platform/Linux/BUILD.gn +++ b/src/platform/Linux/BUILD.gn @@ -74,6 +74,7 @@ static_library("Linux") { ] deps = [ + "${chip_root}/src/app/icd/server:icd-server-config", "${chip_root}/src/credentials:credentials_header", "${chip_root}/src/setup_payload", ] diff --git a/src/platform/Linux/ThreadStackManagerImpl.h b/src/platform/Linux/ThreadStackManagerImpl.h index e262837dd84c76..8b0cf242bcbd34 100755 --- a/src/platform/Linux/ThreadStackManagerImpl.h +++ b/src/platform/Linux/ThreadStackManagerImpl.h @@ -21,6 +21,7 @@ #include #include +#include #include #include #include diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h index 8ce0805182dcaa..aa3d2e1951ce7e 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h @@ -37,6 +37,7 @@ #include #endif +#include #include #include #include diff --git a/src/platform/silabs/DiagnosticDataProviderImpl.cpp b/src/platform/silabs/DiagnosticDataProviderImpl.cpp index 4322f0641d3928..03afa5efe29487 100644 --- a/src/platform/silabs/DiagnosticDataProviderImpl.cpp +++ b/src/platform/silabs/DiagnosticDataProviderImpl.cpp @@ -31,6 +31,7 @@ #include "AppConfig.h" #include "FreeRTOS.h" #include "heap_4_silabs.h" +#include #include using namespace ::chip::app::Clusters::GeneralDiagnostics; @@ -249,13 +250,32 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** #if CHIP_DEVICE_CONFIG_ENABLE_THREAD const char * threadNetworkName = otThreadGetNetworkName(ThreadStackMgrImpl().OTInstance()); ifp->name = Span(threadNetworkName, strlen(threadNetworkName)); - ifp->isOperational = true; + ifp->type = InterfaceTypeEnum::kThread; + ifp->isOperational = ThreadStackMgrImpl().IsThreadAttached(); ifp->offPremiseServicesReachableIPv4.SetNull(); ifp->offPremiseServicesReachableIPv6.SetNull(); - ifp->type = InterfaceTypeEnum::kThread; - uint8_t macBuffer[ConfigurationManager::kPrimaryMACAddressLength]; - ConfigurationMgr().GetPrimary802154MACAddress(macBuffer); - ifp->hardwareAddress = ByteSpan(macBuffer, ConfigurationManager::kPrimaryMACAddressLength); + + ThreadStackMgrImpl().GetPrimary802154MACAddress(ifp->MacAddress); + ifp->hardwareAddress = ByteSpan(ifp->MacAddress, kMaxHardwareAddrSize); + + // The Thread implementation has only 1 interface and is IPv6-only + Inet::InterfaceAddressIterator interfaceAddressIterator; + uint8_t ipv6AddressesCount = 0; + while (interfaceAddressIterator.HasCurrent() && ipv6AddressesCount < kMaxIPv6AddrCount) + { + Inet::IPAddress ipv6Address; + if (interfaceAddressIterator.GetAddress(ipv6Address) == CHIP_NO_ERROR) + { + memcpy(ifp->Ipv6AddressesBuffer[ipv6AddressesCount], ipv6Address.Addr, kMaxIPv6AddrSize); + ifp->Ipv6AddressSpans[ipv6AddressesCount] = ByteSpan(ifp->Ipv6AddressesBuffer[ipv6AddressesCount]); + ipv6AddressesCount++; + } + interfaceAddressIterator.Next(); + } + + ifp->IPv6Addresses = app::DataModel::List(ifp->Ipv6AddressSpans, ipv6AddressesCount); + + *netifpp = ifp; #else NetworkInterface * head = NULL; for (Inet::InterfaceIterator interfaceIterator; interfaceIterator.HasCurrent(); interfaceIterator.Next()) @@ -331,7 +351,6 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** *netifpp = head; #endif - *netifpp = ifp; return CHIP_NO_ERROR; } diff --git a/src/protocols/secure_channel/tests/TestPASESession.cpp b/src/protocols/secure_channel/tests/TestPASESession.cpp index f94ebb0921a533..a68b69f417838b 100644 --- a/src/protocols/secure_channel/tests/TestPASESession.cpp +++ b/src/protocols/secure_channel/tests/TestPASESession.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include #include