preCommissionedVideoPlayers = readCachedVideoPlayers();
+
NsdDiscoveryListener nsdDiscoveryListener =
new NsdDiscoveryListener(
nsdManager,
TARGET_SERVICE_TYPE,
DEVICE_TYPE_FILTER,
+ preCommissionedVideoPlayers,
discoverySuccessCallback,
discoveryFailureCallback);
@@ -63,6 +66,7 @@ public void discoverVideoPlayerCommissioners(
new Runnable() {
@Override
public void run() {
+ Log.d(TAG, "TvCastingApp stopping Video Player commissioner discovery");
nsdManager.stopServiceDiscovery(nsdDiscoveryListener);
multicastLock.release();
}
@@ -275,7 +279,7 @@ public native boolean keypadInput_sendKey(
/**
* APPLICATION BASIC
*
- * TODO: Add APIs to subscribe to Application, Status and AllowedVendorList
+ *
TODO: Add APIs to subscribe to & read Application, Status and AllowedVendorList
*/
public native boolean applicationBasic_subscribeToVendorName(
ContentApp contentApp,
@@ -287,7 +291,7 @@ public native boolean applicationBasic_subscribeToVendorName(
public native boolean applicationBasic_subscribeToVendorID(
ContentApp contentApp,
- SuccessCallback readSuccessHandler,
+ SuccessCallback readSuccessHandler,
FailureCallback readFailureHandler,
int minInterval,
int maxInterval,
@@ -303,7 +307,7 @@ public native boolean applicationBasic_subscribeToApplicationName(
public native boolean applicationBasic_subscribeToProductID(
ContentApp contentApp,
- SuccessCallback readSuccessHandler,
+ SuccessCallback readSuccessHandler,
FailureCallback readFailureHandler,
int minInterval,
int maxInterval,
@@ -317,6 +321,31 @@ public native boolean applicationBasic_subscribeToApplicationVersion(
int maxInterval,
SubscriptionEstablishedCallback subscriptionEstablishedHandler);
+ public native boolean applicationBasic_readVendorName(
+ ContentApp contentApp,
+ SuccessCallback readSuccessHandler,
+ FailureCallback readFailureHandler);
+
+ public native boolean applicationBasic_readVendorID(
+ ContentApp contentApp,
+ SuccessCallback readSuccessHandler,
+ FailureCallback readFailureHandler);
+
+ public native boolean applicationBasic_readApplicationName(
+ ContentApp contentApp,
+ SuccessCallback readSuccessHandler,
+ FailureCallback readFailureHandler);
+
+ public native boolean applicationBasic_readProductID(
+ ContentApp contentApp,
+ SuccessCallback readSuccessHandler,
+ FailureCallback readFailureHandler);
+
+ public native boolean applicationBasic_readApplicationVersion(
+ ContentApp contentApp,
+ SuccessCallback readSuccessHandler,
+ FailureCallback readFailureHandlerr);
+
static {
System.loadLibrary("TvCastingApp");
}
diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/VideoPlayer.java b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/VideoPlayer.java
index 85c487850cd08d..9ba557c910b704 100644
--- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/VideoPlayer.java
+++ b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/VideoPlayer.java
@@ -17,10 +17,15 @@
*/
package com.chip.casting;
+import java.net.InetAddress;
+import java.util.HashSet;
import java.util.List;
import java.util.Objects;
+import java.util.Set;
public class VideoPlayer {
+ private static final String TAG = VideoPlayer.class.getSimpleName();
+
private long nodeId;
private byte fabricIndex;
private String deviceName;
@@ -30,6 +35,9 @@ public class VideoPlayer {
private List contentApps;
private boolean isConnected = false;
+ private int numIPs;
+ private List ipAddresses;
+
private boolean isInitialized = false;
public VideoPlayer(
@@ -40,6 +48,8 @@ public VideoPlayer(
int productId,
int deviceType,
List contentApps,
+ int numIPs,
+ List ipAddresses,
boolean isConnected) {
this.nodeId = nodeId;
this.fabricIndex = fabricIndex;
@@ -49,9 +59,43 @@ public VideoPlayer(
this.deviceType = deviceType;
this.contentApps = contentApps;
this.isConnected = isConnected;
+ this.numIPs = numIPs;
+ this.ipAddresses = ipAddresses;
this.isInitialized = true;
}
+ public boolean isSameAs(DiscoveredNodeData discoveredNodeData) {
+ // return false because 'this' VideoPlayer is not null
+ if (discoveredNodeData == null) {
+ return false;
+ }
+
+ // return false because deviceNames are different
+ if (Objects.equals(deviceName, discoveredNodeData.getDeviceName()) == false) {
+ return false;
+ }
+
+ // return false because not even a single IP Address matches
+ if (ipAddresses != null) {
+ boolean matchFound = false;
+ Set discoveredNodeDataIpAddressSet =
+ new HashSet(discoveredNodeData.getIpAddresses());
+ for (InetAddress videoPlayerIpAddress : ipAddresses) {
+ if (discoveredNodeDataIpAddressSet.contains(videoPlayerIpAddress)) {
+ matchFound = true;
+ break;
+ }
+ }
+
+ if (!matchFound) {
+ return false;
+ }
+ }
+
+ // otherwise, return true
+ return true;
+ }
+
public boolean equals(Object object) {
if (this == object) return true;
if (object == null || getClass() != object.getClass()) return false;
@@ -78,8 +122,18 @@ public java.lang.String toString() {
+ vendorId
+ ", productId="
+ productId
+ + ", deviceType="
+ + deviceType
+ + ", contentApps="
+ + contentApps
+ ", isConnected="
+ isConnected
+ + ", numIPs="
+ + numIPs
+ + ", ipAddresses="
+ + ipAddresses
+ + ", isInitialized="
+ + isInitialized
+ '}';
}
diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.cpp
index db59f4a08d1276..8112c6b2acfb90 100644
--- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.cpp
+++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.cpp
@@ -22,6 +22,27 @@
#include
#include
+CHIP_ERROR convertJAppParametersToCppAppParams(jobject appParameters, AppParams & outAppParams)
+{
+ ChipLogProgress(AppServer, "convertJContentAppToTargetEndpointInfo called");
+ JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread();
+ VerifyOrReturnError(appParameters != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+
+ jclass jAppParametersClass;
+ ReturnErrorOnFailure(
+ chip::JniReferences::GetInstance().GetClassRef(env, "com/chip/casting/AppParameters", jAppParametersClass));
+
+ jfieldID jRotatingDeviceIdUniqueIdField = env->GetFieldID(jAppParametersClass, "rotatingDeviceIdUniqueId", "[B");
+ jobject jRotatingDeviceIdUniqueId = env->GetObjectField(appParameters, jRotatingDeviceIdUniqueIdField);
+ if (jRotatingDeviceIdUniqueId != nullptr)
+ {
+ chip::JniByteArray jniRotatingDeviceIdUniqueIdByteArray(env, static_cast(jRotatingDeviceIdUniqueId));
+ outAppParams.SetRotatingDeviceIdUniqueId(MakeOptional(jniRotatingDeviceIdUniqueIdByteArray.byteSpan()));
+ }
+
+ return CHIP_NO_ERROR;
+}
+
CHIP_ERROR convertJContentAppToTargetEndpointInfo(jobject contentApp, TargetEndpointInfo & outTargetEndpointInfo)
{
ChipLogProgress(AppServer, "convertJContentAppToTargetEndpointInfo called");
@@ -99,14 +120,14 @@ CHIP_ERROR convertJVideoPlayerToTargetVideoPlayerInfo(jobject videoPlayer, Targe
jfieldID jFabricIndexField = env->GetFieldID(jVideoPlayerClass, "fabricIndex", "B");
chip::FabricIndex fabricIndex = static_cast(env->GetByteField(videoPlayer, jFabricIndexField));
- jfieldID jVendorIdField = env->GetFieldID(jVideoPlayerClass, "vendorId", "S");
- uint16_t vendorId = static_cast(env->GetShortField(videoPlayer, jVendorIdField));
+ jfieldID jVendorIdField = env->GetFieldID(jVideoPlayerClass, "vendorId", "I");
+ uint16_t vendorId = static_cast(env->GetIntField(videoPlayer, jVendorIdField));
- jfieldID jProductIdField = env->GetFieldID(jVideoPlayerClass, "productId", "S");
- uint16_t productId = static_cast(env->GetShortField(videoPlayer, jProductIdField));
+ jfieldID jProductIdField = env->GetFieldID(jVideoPlayerClass, "productId", "I");
+ uint16_t productId = static_cast(env->GetIntField(videoPlayer, jProductIdField));
- jfieldID jDeviceType = env->GetFieldID(jVideoPlayerClass, "deviceType", "S");
- uint16_t deviceType = static_cast(env->GetShortField(videoPlayer, jDeviceType));
+ jfieldID jDeviceType = env->GetFieldID(jVideoPlayerClass, "deviceType", "I");
+ uint16_t deviceType = static_cast(env->GetIntField(videoPlayer, jDeviceType));
jfieldID getDeviceNameField = env->GetFieldID(jVideoPlayerClass, "deviceName", "Ljava/lang/String;");
jstring jDeviceName = static_cast(env->GetObjectField(videoPlayer, getDeviceNameField));
@@ -152,7 +173,7 @@ CHIP_ERROR convertTargetVideoPlayerInfoToJVideoPlayer(TargetVideoPlayerInfo * ta
ReturnErrorOnFailure(
chip::JniReferences::GetInstance().GetClassRef(env, "com/chip/casting/VideoPlayer", jVideoPlayerClass));
jmethodID jVideoPlayerConstructor =
- env->GetMethodID(jVideoPlayerClass, "", "(JBLjava/lang/String;IIILjava/util/List;Z)V");
+ env->GetMethodID(jVideoPlayerClass, "", "(JBLjava/lang/String;IIILjava/util/List;ILjava/util/List;Z)V");
jobject jContentAppList = nullptr;
TargetEndpointInfo * endpoints = targetVideoPlayerInfo->GetEndpoints();
@@ -166,11 +187,37 @@ CHIP_ERROR convertTargetVideoPlayerInfoToJVideoPlayer(TargetVideoPlayerInfo * ta
chip::JniReferences::GetInstance().AddToList(jContentAppList, contentApp);
}
}
- jstring deviceName = env->NewStringUTF(targetVideoPlayerInfo->GetDeviceName());
- outVideoPlayer = env->NewObject(jVideoPlayerClass, jVideoPlayerConstructor, targetVideoPlayerInfo->GetNodeId(),
+
+ jstring deviceName =
+ targetVideoPlayerInfo->GetDeviceName() == nullptr ? nullptr : env->NewStringUTF(targetVideoPlayerInfo->GetDeviceName());
+
+ jobject jIPAddressList = nullptr;
+ const chip::Inet::IPAddress * ipAddresses = targetVideoPlayerInfo->GetIpAddresses();
+ if (ipAddresses != nullptr)
+ {
+ chip::JniReferences::GetInstance().CreateArrayList(jIPAddressList);
+ for (size_t i = 0; i < targetVideoPlayerInfo->GetNumIPs() && i < chip::Dnssd::CommonResolutionData::kMaxIPAddresses;
+ i++)
+ {
+ char addrCString[chip::Inet::IPAddress::kMaxStringLength];
+ ipAddresses[i].ToString(addrCString, chip::Inet::IPAddress::kMaxStringLength);
+ jstring jIPAddressStr = env->NewStringUTF(addrCString);
+
+ jclass jIPAddressClass;
+ ReturnErrorOnFailure(chip::JniReferences::GetInstance().GetClassRef(env, "java/net/InetAddress", jIPAddressClass));
+ jmethodID jGetByNameMid =
+ env->GetStaticMethodID(jIPAddressClass, "getByName", "(Ljava/lang/String;)Ljava/net/InetAddress;");
+ jobject jIPAddress = env->CallStaticObjectMethod(jIPAddressClass, jGetByNameMid, jIPAddressStr);
+
+ chip::JniReferences::GetInstance().AddToList(jIPAddressList, jIPAddress);
+ }
+ }
+
+ outVideoPlayer = env->NewObject(jVideoPlayerClass, jVideoPlayerConstructor, targetVideoPlayerInfo->GetNodeId(),
targetVideoPlayerInfo->GetFabricIndex(), deviceName, targetVideoPlayerInfo->GetVendorId(),
targetVideoPlayerInfo->GetProductId(), targetVideoPlayerInfo->GetDeviceType(),
- jContentAppList, targetVideoPlayerInfo->GetOperationalDeviceProxy() != nullptr);
+ jContentAppList, targetVideoPlayerInfo->GetNumIPs(), jIPAddressList,
+ targetVideoPlayerInfo->GetOperationalDeviceProxy() != nullptr);
}
return CHIP_NO_ERROR;
}
diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.h b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.h
index 192ffa2b65961d..a2c59596d9e9e5 100644
--- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.h
+++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.h
@@ -16,11 +16,14 @@
*/
#pragma once
+#include "AppParams.h"
#include "TargetEndpointInfo.h"
#include "TargetVideoPlayerInfo.h"
#include
+CHIP_ERROR convertJAppParametersToCppAppParams(jobject appParameters, AppParams & outAppParams);
+
CHIP_ERROR convertJContentAppToTargetEndpointInfo(jobject contentApp, TargetEndpointInfo & outTargetEndpointInfo);
CHIP_ERROR convertTargetEndpointInfoToJContentApp(TargetEndpointInfo * targetEndpointInfo, jobject & outContentApp);
diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.cpp
index 60a10ea2696f5e..862334ae1ee4cb 100644
--- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.cpp
+++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.cpp
@@ -178,7 +178,7 @@ jobject OnConnectionSuccessHandlerJNI::ConvertToJObject(TargetVideoPlayerInfo *
{
ChipLogError(AppServer, "OnConnectionSuccessHandlerJNI::ConvertToJObject failed with %" CHIP_ERROR_FORMAT, err.Format());
}
- return nullptr;
+ return videoPlayer;
}
jobject OnNewOrUpdatedEndpointHandlerJNI::ConvertToJObject(TargetEndpointInfo * targetEndpointInfo)
@@ -383,7 +383,7 @@ jobject VendorIDSuccessHandlerJNI::ConvertToJObject(
chip::app::Clusters::ApplicationBasic::Attributes::VendorID::TypeInfo::DecodableArgType responseData)
{
ChipLogProgress(AppServer, "VendorIDSuccessHandlerJNI::ConvertToJObject called");
- return ConvertToShortJObject(responseData);
+ return ConvertToIntegerJObject(responseData);
}
jobject ApplicationNameSuccessHandlerJNI::ConvertToJObject(
@@ -397,7 +397,7 @@ jobject ProductIDSuccessHandlerJNI::ConvertToJObject(
chip::app::Clusters::ApplicationBasic::Attributes::ProductID::TypeInfo::DecodableArgType responseData)
{
ChipLogProgress(AppServer, "ProductIDSuccessHandlerJNI::ConvertToJObject called");
- return ConvertToShortJObject(responseData);
+ return ConvertToIntegerJObject(responseData);
}
jobject ApplicationVersionSuccessHandlerJNI::ConvertToJObject(
diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.h b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.h
index d78988699b88f9..3261aa60874ad2 100644
--- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.h
+++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.h
@@ -235,7 +235,7 @@ class VendorIDSuccessHandlerJNI
: public SuccessHandlerJNI
{
public:
- VendorIDSuccessHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Short;)V") {}
+ VendorIDSuccessHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Integer;)V") {}
jobject ConvertToJObject(chip::app::Clusters::ApplicationBasic::Attributes::VendorID::TypeInfo::DecodableArgType responseData);
};
@@ -252,7 +252,7 @@ class ProductIDSuccessHandlerJNI
: public SuccessHandlerJNI
{
public:
- ProductIDSuccessHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Short;)V") {}
+ ProductIDSuccessHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Integer;)V") {}
jobject ConvertToJObject(chip::app::Clusters::ApplicationBasic::Attributes::ProductID::TypeInfo::DecodableArgType responseData);
};
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 928f489e2b84a7..33d7c753bf9042 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
@@ -52,6 +52,36 @@ void JNI_OnUnload(JavaVM * jvm, void * reserved)
return AndroidAppServerJNI_OnUnload(jvm, reserved);
}
+JNI_METHOD(jboolean, init)(JNIEnv *, jobject, jobject jAppParameters)
+{
+ chip::DeviceLayer::StackLock lock;
+ ChipLogProgress(AppServer, "JNI_METHOD init called");
+
+ CHIP_ERROR err = CHIP_NO_ERROR;
+ if (jAppParameters == nullptr)
+ {
+ err = CastingServer::GetInstance()->Init();
+ }
+ else
+ {
+ AppParams appParams;
+ err = convertJAppParametersToCppAppParams(jAppParameters, appParams);
+ VerifyOrExit(err == CHIP_NO_ERROR,
+ ChipLogError(AppServer, "Conversion of AppParameters from jobject to Cpp type failed: %" CHIP_ERROR_FORMAT,
+ err.Format()));
+ err = CastingServer::GetInstance()->Init(&appParams);
+ }
+ VerifyOrExit(err == CHIP_NO_ERROR,
+ ChipLogError(AppServer, "Call to CastingServer::GetInstance()->Init() failed: %" CHIP_ERROR_FORMAT, err.Format()));
+exit:
+ if (err != CHIP_NO_ERROR)
+ {
+ return false;
+ }
+
+ return true;
+}
+
JNI_METHOD(void, setDACProvider)(JNIEnv *, jobject, jobject provider)
{
if (!chip::Credentials::IsDeviceAttestationCredentialsProviderSet())
@@ -202,6 +232,7 @@ JNI_METHOD(jobject, getActiveTargetVideoPlayers)(JNIEnv * env, jobject)
JNI_METHOD(jboolean, sendUserDirectedCommissioningRequest)(JNIEnv * env, jobject, jstring addressJStr, jint port)
{
+ chip::DeviceLayer::StackLock lock;
ChipLogProgress(AppServer, "JNI_METHOD sendUserDirectedCommissioningRequest called with port %d", port);
Inet::IPAddress addressInet;
JniUtfString addressJniString(env, addressJStr);
@@ -225,6 +256,7 @@ JNI_METHOD(jboolean, sendUserDirectedCommissioningRequest)(JNIEnv * env, jobject
JNI_METHOD(jboolean, sendCommissioningRequest)(JNIEnv * env, jobject, jobject jDiscoveredNodeData)
{
+ chip::DeviceLayer::StackLock lock;
ChipLogProgress(AppServer, "JNI_METHOD sendCommissioningRequest called");
chip::Dnssd::DiscoveredNodeData commissioner;
@@ -245,12 +277,6 @@ JNI_METHOD(jboolean, sendCommissioningRequest)(JNIEnv * env, jobject, jobject jD
return true;
}
-JNI_METHOD(void, init)(JNIEnv *, jobject)
-{
- ChipLogProgress(AppServer, "JNI_METHOD init called");
- CastingServer::GetInstance()->Init();
-}
-
JNI_METHOD(jboolean, contentLauncherLaunchURL)
(JNIEnv * env, jobject, jobject contentApp, jstring contentUrl, jstring contentDisplayStr, jobject jResponseHandler)
{
@@ -411,9 +437,7 @@ JNI_METHOD(jboolean, contentLauncher_1subscribeToSupportedStreamingProtocols)
err = TvCastingAppJNIMgr().getSupportedStreamingProtocolsSuccessHandler().SetUp(env, jReadSuccessHandler);
VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format()));
- err = TvCastingAppJNIMgr()
- .getSubscriptionReadFailureHandler(ContentLauncher_SupportedStreamingProtocols)
- .SetUp(env, jReadFailureHandler);
+ err = TvCastingAppJNIMgr().getReadFailureHandler(ContentLauncher_SupportedStreamingProtocols).SetUp(env, jReadFailureHandler);
VerifyOrExit(CHIP_NO_ERROR == err,
ChipLogError(AppServer, "SubscriptionReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format()));
@@ -430,7 +454,7 @@ JNI_METHOD(jboolean, contentLauncher_1subscribeToSupportedStreamingProtocols)
TvCastingAppJNIMgr().getSupportedStreamingProtocolsSuccessHandler().Handle(responseData);
},
[](void * context, CHIP_ERROR err) {
- TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(ContentLauncher_SupportedStreamingProtocols).Handle(err);
+ TvCastingAppJNIMgr().getReadFailureHandler(ContentLauncher_SupportedStreamingProtocols).Handle(err);
},
static_cast(minInterval), static_cast(maxInterval),
[](void * context) {
@@ -1742,3 +1766,209 @@ JNI_METHOD(jboolean, applicationBasic_1subscribeToApplicationVersion)
return true;
}
+
+JNI_METHOD(jboolean, applicationBasic_1readVendorName)
+(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler)
+{
+ chip::DeviceLayer::StackLock lock;
+
+ ChipLogProgress(AppServer, "JNI_METHOD applicationBasic_1readVendorName called");
+
+ 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().getReadVendorNameSuccessHandler().SetUp(env, jReadSuccessHandler);
+ VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format()));
+
+ err = TvCastingAppJNIMgr().getReadFailureHandler(ApplicationBasic_VendorName).SetUp(env, jReadFailureHandler);
+ VerifyOrExit(CHIP_NO_ERROR == err,
+ ChipLogError(AppServer, "ReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format()));
+
+ err = CastingServer::GetInstance()->ApplicationBasic_ReadVendorName(
+ &endpoint, nullptr,
+ [](void * context, chip::app::Clusters::ApplicationBasic::Attributes::VendorName::TypeInfo::DecodableArgType responseData) {
+ TvCastingAppJNIMgr().getVendorNameSuccessHandler().Handle(responseData);
+ },
+ [](void * context, CHIP_ERROR err) {
+ TvCastingAppJNIMgr().getReadFailureHandler(ApplicationBasic_VendorName).Handle(err);
+ });
+
+ VerifyOrExit(
+ CHIP_NO_ERROR == err,
+ ChipLogError(AppServer, "CastingServer.applicationBasic_1readVendorName failed %" CHIP_ERROR_FORMAT, err.Format()));
+
+exit:
+ if (err != CHIP_NO_ERROR)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+JNI_METHOD(jboolean, applicationBasic_1readVendorID)
+(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler)
+{
+ chip::DeviceLayer::StackLock lock;
+
+ ChipLogProgress(AppServer, "JNI_METHOD applicationBasic_1readVendorID called");
+
+ 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().getVendorIDSuccessHandler().SetUp(env, jReadSuccessHandler);
+ VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format()));
+
+ err = TvCastingAppJNIMgr().getReadFailureHandler(ApplicationBasic_VendorID).SetUp(env, jReadFailureHandler);
+ VerifyOrExit(CHIP_NO_ERROR == err,
+ ChipLogError(AppServer, "ReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format()));
+
+ err = CastingServer::GetInstance()->ApplicationBasic_ReadVendorID(
+ &endpoint, nullptr,
+ [](void * context, chip::app::Clusters::ApplicationBasic::Attributes::VendorID::TypeInfo::DecodableArgType responseData) {
+ TvCastingAppJNIMgr().getVendorIDSuccessHandler().Handle(responseData);
+ },
+ [](void * context, CHIP_ERROR err) { TvCastingAppJNIMgr().getReadFailureHandler(ApplicationBasic_VendorID).Handle(err); });
+
+ VerifyOrExit(CHIP_NO_ERROR == err,
+ ChipLogError(AppServer, "CastingServer.applicationBasic_ReadVendorID failed %" CHIP_ERROR_FORMAT, err.Format()));
+
+exit:
+ if (err != CHIP_NO_ERROR)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+JNI_METHOD(jboolean, applicationBasic_1readApplicationName)
+(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler)
+{
+ chip::DeviceLayer::StackLock lock;
+
+ ChipLogProgress(AppServer, "JNI_METHOD applicationBasic_1readApplicationName called");
+
+ 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().getApplicationNameSuccessHandler().SetUp(env, jReadSuccessHandler);
+ VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format()));
+
+ err = TvCastingAppJNIMgr().getReadFailureHandler(ApplicationBasic_ApplicationName).SetUp(env, jReadFailureHandler);
+ VerifyOrExit(CHIP_NO_ERROR == err,
+ ChipLogError(AppServer, "ReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format()));
+
+ err = CastingServer::GetInstance()->ApplicationBasic_ReadApplicationName(
+ &endpoint, nullptr,
+ [](void * context,
+ chip::app::Clusters::ApplicationBasic::Attributes::ApplicationName::TypeInfo::DecodableArgType responseData) {
+ TvCastingAppJNIMgr().getApplicationNameSuccessHandler().Handle(responseData);
+ },
+ [](void * context, CHIP_ERROR err) {
+ TvCastingAppJNIMgr().getReadFailureHandler(ApplicationBasic_ApplicationName).Handle(err);
+ });
+
+ VerifyOrExit(
+ CHIP_NO_ERROR == err,
+ ChipLogError(AppServer, "CastingServer.applicationBasic_ReadApplicationName failed %" CHIP_ERROR_FORMAT, err.Format()));
+
+exit:
+ if (err != CHIP_NO_ERROR)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+JNI_METHOD(jboolean, applicationBasic_1readProductID)
+(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler)
+{
+ chip::DeviceLayer::StackLock lock;
+
+ ChipLogProgress(AppServer, "JNI_METHOD applicationBasic_1readProductID called");
+
+ 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().getProductIDSuccessHandler().SetUp(env, jReadSuccessHandler);
+ VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format()));
+
+ err = TvCastingAppJNIMgr().getReadFailureHandler(ApplicationBasic_ProductID).SetUp(env, jReadFailureHandler);
+ VerifyOrExit(CHIP_NO_ERROR == err,
+ ChipLogError(AppServer, "ReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format()));
+
+ err = CastingServer::GetInstance()->ApplicationBasic_ReadProductID(
+ &endpoint, nullptr,
+ [](void * context, chip::app::Clusters::ApplicationBasic::Attributes::ProductID::TypeInfo::DecodableArgType responseData) {
+ TvCastingAppJNIMgr().getProductIDSuccessHandler().Handle(responseData);
+ },
+ [](void * context, CHIP_ERROR err) { TvCastingAppJNIMgr().getReadFailureHandler(ApplicationBasic_ProductID).Handle(err); });
+
+ VerifyOrExit(CHIP_NO_ERROR == err,
+ ChipLogError(AppServer, "CastingServer.applicationBasic_ReadProductID failed %" CHIP_ERROR_FORMAT, err.Format()));
+
+exit:
+ if (err != CHIP_NO_ERROR)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+JNI_METHOD(jboolean, applicationBasic_1readApplicationVersion)
+(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler)
+{
+ chip::DeviceLayer::StackLock lock;
+
+ ChipLogProgress(AppServer, "JNI_METHOD applicationBasic_1readApplicationVersion called");
+
+ 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().getApplicationVersionSuccessHandler().SetUp(env, jReadSuccessHandler);
+ VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format()));
+
+ err = TvCastingAppJNIMgr().getReadFailureHandler(ApplicationBasic_ApplicationVersion).SetUp(env, jReadFailureHandler);
+ VerifyOrExit(CHIP_NO_ERROR == err,
+ ChipLogError(AppServer, "ReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format()));
+
+ err = CastingServer::GetInstance()->ApplicationBasic_ReadApplicationVersion(
+ &endpoint, nullptr,
+ [](void * context,
+ chip::app::Clusters::ApplicationBasic::Attributes::ApplicationVersion::TypeInfo::DecodableArgType responseData) {
+ TvCastingAppJNIMgr().getApplicationVersionSuccessHandler().Handle(responseData);
+ },
+ [](void * context, CHIP_ERROR err) {
+ TvCastingAppJNIMgr().getReadFailureHandler(ApplicationBasic_ApplicationVersion).Handle(err);
+ });
+
+ VerifyOrExit(
+ CHIP_NO_ERROR == err,
+ ChipLogError(AppServer, "CastingServer.applicationBasic_ReadApplicationVersion failed %" CHIP_ERROR_FORMAT, err.Format()));
+
+exit:
+ if (err != CHIP_NO_ERROR)
+ {
+ return false;
+ }
+
+ return true;
+}
diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.h b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.h
index 71bd0bddb466be..7d2b384b3718ae 100644
--- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.h
+++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.h
@@ -45,6 +45,8 @@ class TvCastingAppJNI
return mMediaCommandResponseHandler[name];
}
+ FailureHandlerJNI & getReadFailureHandler(enum MediaAttributeName name) { return mReadFailureHandler[name]; }
+
FailureHandlerJNI & getSubscriptionReadFailureHandler(enum MediaAttributeName name)
{
return mSubscriptionReadFailureHandler[name];
@@ -80,6 +82,15 @@ class TvCastingAppJNI
ProductIDSuccessHandlerJNI & getProductIDSuccessHandler() { return mProductIDSuccessHandlerJNI; }
ApplicationVersionSuccessHandlerJNI & getApplicationVersionSuccessHandler() { return mApplicationVersionSuccessHandlerJNI; }
+ VendorNameSuccessHandlerJNI & getReadVendorNameSuccessHandler() { return mReadVendorNameSuccessHandlerJNI; }
+ VendorIDSuccessHandlerJNI & getReadVendorIDSuccessHandler() { return mReadVendorIDSuccessHandlerJNI; }
+ ApplicationNameSuccessHandlerJNI & getReadApplicationNameSuccessHandler() { return mReadApplicationNameSuccessHandlerJNI; }
+ ProductIDSuccessHandlerJNI & getReadProductIDSuccessHandler() { return mReadProductIDSuccessHandlerJNI; }
+ ApplicationVersionSuccessHandlerJNI & getReadApplicationVersionSuccessHandler()
+ {
+ return mReadApplicationVersionSuccessHandlerJNI;
+ }
+
private:
friend TvCastingAppJNI & TvCastingAppJNIMgr();
@@ -97,6 +108,7 @@ class TvCastingAppJNI
MatterCallbackHandlerJNI mMediaCommandResponseHandler[MEDIA_COMMAND_COUNT];
FailureHandlerJNI mSubscriptionReadFailureHandler[MEDIA_ATTRIBUTE_COUNT];
SubscriptionEstablishedHandlerJNI mSubscriptionEstablishedHandler[MEDIA_ATTRIBUTE_COUNT];
+ FailureHandlerJNI mReadFailureHandler[MEDIA_ATTRIBUTE_COUNT];
CurrentStateSuccessHandlerJNI mCurrentStateSuccessHandlerJNI;
DurationSuccessHandlerJNI mDurationSuccessHandlerJNI;
@@ -119,6 +131,12 @@ class TvCastingAppJNI
ApplicationNameSuccessHandlerJNI mApplicationNameSuccessHandlerJNI;
ProductIDSuccessHandlerJNI mProductIDSuccessHandlerJNI;
ApplicationVersionSuccessHandlerJNI mApplicationVersionSuccessHandlerJNI;
+
+ VendorNameSuccessHandlerJNI mReadVendorNameSuccessHandlerJNI;
+ VendorIDSuccessHandlerJNI mReadVendorIDSuccessHandlerJNI;
+ ApplicationNameSuccessHandlerJNI mReadApplicationNameSuccessHandlerJNI;
+ ProductIDSuccessHandlerJNI mReadProductIDSuccessHandlerJNI;
+ ApplicationVersionSuccessHandlerJNI mReadApplicationVersionSuccessHandlerJNI;
};
inline class TvCastingAppJNI & TvCastingAppJNIMgr()
diff --git a/examples/tv-casting-app/android/App/app/src/main/res/layout/fragment_commissioning.xml b/examples/tv-casting-app/android/App/app/src/main/res/layout/fragment_connection.xml
similarity index 94%
rename from examples/tv-casting-app/android/App/app/src/main/res/layout/fragment_commissioning.xml
rename to examples/tv-casting-app/android/App/app/src/main/res/layout/fragment_connection.xml
index c75708136c4090..f0381f3e5ae773 100644
--- a/examples/tv-casting-app/android/App/app/src/main/res/layout/fragment_commissioning.xml
+++ b/examples/tv-casting-app/android/App/app/src/main/res/layout/fragment_connection.xml
@@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
- tools:context=".CommissioningFragment"
+ tools:context=".ConnectionFragment"
android:padding="10sp">
+
+#ifndef AppParameters_h
+#define AppParameters_h
+
+@interface AppParameters : NSObject
+
+@property NSData * rotatingDeviceIdUniqueId;
+
+- (AppParameters *)initWithRotatingDeviceIdUniqueId:(NSData *)rotatingDeviceIdUniqueId;
+
+@end
+
+#endif /* AppParameters_h */
diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/AppParameters.m b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/AppParameters.m
new file mode 100644
index 00000000000000..287d4ab40fd57c
--- /dev/null
+++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/AppParameters.m
@@ -0,0 +1,33 @@
+/**
+ *
+ * Copyright (c) 2020-2022 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.
+ */
+
+#import
+
+#import "AppParameters.h"
+
+@implementation AppParameters
+
+- (AppParameters *)initWithRotatingDeviceIdUniqueId:(NSData *)rotatingDeviceIdUniqueId
+{
+ self = [super init];
+ if (self) {
+ _rotatingDeviceIdUniqueId = rotatingDeviceIdUniqueId;
+ }
+ return self;
+}
+
+@end
diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.h
index f828ae5f01c70f..b91f930f5327a7 100644
--- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.h
+++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.h
@@ -15,6 +15,7 @@
* limitations under the License.
*/
+#import "AppParameters.h"
#import "ContentApp.h"
#import "ContentLauncherTypes.h"
#import "DiscoveredNodeData.h"
@@ -32,6 +33,10 @@
+ (CastingServerBridge * _Nullable)getSharedInstance;
+- (void)initApp:(AppParameters * _Nullable)appParameters
+ clientQueue:(dispatch_queue_t _Nonnull)clientQueue
+ initAppStatusHandler:(nullable void (^)(bool))initAppStatusHandler;
+
/*!
@brief Browse for on-network commissioner TVs
@@ -1003,6 +1008,100 @@
successCallback:(void (^_Nonnull)(NSString * _Nonnull))successCallback
failureCallback:(void (^_Nonnull)(MatterError * _Nonnull))failureCallback
subscriptionEstablishedCallback:(void (^_Nonnull)())subscriptionEstablishedCallback;
-@end
+/*!
+ @brief Read ApplicationBasic:VendorName
+
+ @param contentApp Content app endpoint to target
+
+ @param clientQueue Queue to invoke callbacks on
+
+ @param requestSentHandler Handler to call on sending the request
+
+ @param successCallback Callback for when a read report is successfully received
+
+ @param failureCallback Callback for when there is a failure in receiving a read report
+ */
+- (void)applicationBasic_readVendorName:(ContentApp * _Nonnull)contentApp
+ clientQueue:(dispatch_queue_t _Nonnull)clientQueue
+ requestSentHandler:(void (^_Nonnull)(MatterError * _Nonnull))requestSentHandler
+ successCallback:(void (^_Nonnull)(NSString * _Nonnull))successCallback
+ failureCallback:(void (^_Nonnull)(MatterError * _Nonnull))failureCallback;
+
+/*!
+ @brief Read ApplicationBasic:VendorID
+
+ @param contentApp Content app endpoint to target
+
+ @param clientQueue Queue to invoke callbacks on
+
+ @param requestSentHandler Handler to call on sending the request
+
+ @param successCallback Callback for when a read report is successfully received
+
+ @param failureCallback Callback for when there is a failure in receiving a read report
+ */
+- (void)applicationBasic_readVendorID:(ContentApp * _Nonnull)contentApp
+ clientQueue:(dispatch_queue_t _Nonnull)clientQueue
+ requestSentHandler:(void (^_Nonnull)(MatterError * _Nonnull))requestSentHandler
+ successCallback:(void (^_Nonnull)(NSNumber * _Nonnull))successCallback
+ failureCallback:(void (^_Nonnull)(MatterError * _Nonnull))failureCallback;
+
+/*!
+ @brief Read ApplicationBasic:ApplicationName
+
+ @param contentApp Content app endpoint to target
+
+ @param clientQueue Queue to invoke callbacks on
+
+ @param requestSentHandler Handler to call on sending the request
+
+ @param successCallback Callback for when a read report is successfully received
+
+ @param failureCallback Callback for when there is a failure in receiving a read report
+ */
+- (void)applicationBasic_readApplicationName:(ContentApp * _Nonnull)contentApp
+ clientQueue:(dispatch_queue_t _Nonnull)clientQueue
+ requestSentHandler:(void (^_Nonnull)(MatterError * _Nonnull))requestSentHandler
+ successCallback:(void (^_Nonnull)(NSString * _Nonnull))successCallback
+ failureCallback:(void (^_Nonnull)(MatterError * _Nonnull))failureCallback;
+
+/*!
+ @brief Read ApplicationBasic:ProductID
+
+ @param contentApp Content app endpoint to target
+
+ @param clientQueue Queue to invoke callbacks on
+
+ @param requestSentHandler Handler to call on sending the request
+
+ @param successCallback Callback for when a read report is successfully received
+
+ @param failureCallback Callback for when there is a failure in receiving a read report
+ */
+- (void)applicationBasic_readProductID:(ContentApp * _Nonnull)contentApp
+ clientQueue:(dispatch_queue_t _Nonnull)clientQueue
+ requestSentHandler:(void (^_Nonnull)(MatterError * _Nonnull))requestSentHandler
+ successCallback:(void (^_Nonnull)(uint16_t))successCallback
+ failureCallback:(void (^_Nonnull)(MatterError * _Nonnull))failureCallback;
+
+/*!
+ @brief Read ApplicationBasic:ApplicationVersion
+
+ @param contentApp Content app endpoint to target
+
+ @param clientQueue Queue to invoke callbacks on
+
+ @param requestSentHandler Handler to call on sending the request
+
+ @param successCallback Callback for when a read report is successfully received
+
+ @param failureCallback Callback for when there is a failure in receiving a read report
+ */
+- (void)applicationBasic_readApplicationVersion:(ContentApp * _Nonnull)contentApp
+ clientQueue:(dispatch_queue_t _Nonnull)clientQueue
+ requestSentHandler:(void (^_Nonnull)(MatterError * _Nonnull))requestSentHandler
+ successCallback:(void (^_Nonnull)(NSString * _Nonnull))successCallback
+ failureCallback:(void (^_Nonnull)(MatterError * _Nonnull))failureCallback;
+@end
#endif /* CastingServerBridge_h */
diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm
index dd89e32cbd42fe..c4ffd87f2a09d8 100644
--- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm
+++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm
@@ -54,6 +54,10 @@ @interface CastingServerBridge ()
@property NSMutableDictionary * subscriptionReadFailureCallbacks;
+@property NSMutableDictionary * readSuccessCallbacks;
+
+@property NSMutableDictionary * readFailureCallbacks;
+
@end
@implementation CastingServerBridge
@@ -122,12 +126,35 @@ - (instancetype)init
_subscriptionReadFailureCallbacks = [NSMutableDictionary dictionary];
chip::DeviceLayer::PlatformMgrImpl().StartEventLoopTask();
-
- CastingServer::GetInstance()->Init();
}
return self;
}
+- (void)initApp:(AppParameters * _Nullable)appParameters
+ clientQueue:(dispatch_queue_t _Nonnull)clientQueue
+ initAppStatusHandler:(nullable void (^)(bool))initAppStatusHandler
+{
+ ChipLogProgress(AppServer, "CastingServerBridge().initApp() called");
+
+ dispatch_async(_chipWorkQueue, ^{
+ bool initAppStatus = true;
+
+ AppParams appParams;
+
+ CHIP_ERROR err = CastingServer::GetInstance()->Init();
+ if (err != CHIP_NO_ERROR) {
+ ChipLogError(AppServer, "CastingServerBridge().initApp() failed: %" CHIP_ERROR_FORMAT, err.Format());
+ initAppStatus = false;
+ }
+
+ dispatch_async(clientQueue, ^{
+ initAppStatusHandler(initAppStatus);
+ });
+ });
+
+ CastingServer::GetInstance()->Init();
+}
+
- (void)discoverCommissioners:(dispatch_queue_t _Nonnull)clientQueue
discoveryRequestSentHandler:(nullable void (^)(bool))discoveryRequestSentHandler
{
@@ -153,11 +180,17 @@ - (void)getDiscoveredCommissioner:(int)index
ChipLogProgress(AppServer, "CastingServerBridge().getDiscoveredCommissioner() called");
dispatch_async(_chipWorkQueue, ^{
+ chip::Optional associatedConnectableVideoPlayer;
DiscoveredNodeData * commissioner = nil;
const chip::Dnssd::DiscoveredNodeData * cppDiscoveredNodeData
- = CastingServer::GetInstance()->GetDiscoveredCommissioner(index);
+ = CastingServer::GetInstance()->GetDiscoveredCommissioner(index, associatedConnectableVideoPlayer);
if (cppDiscoveredNodeData != nullptr) {
commissioner = [ConversionUtils convertToObjCDiscoveredNodeDataFrom:cppDiscoveredNodeData];
+ if (associatedConnectableVideoPlayer.HasValue()) {
+ VideoPlayer * connectableVideoPlayer =
+ [ConversionUtils convertToObjCVideoPlayerFrom:associatedConnectableVideoPlayer.Value()];
+ [commissioner setConnectableVideoPlayer:connectableVideoPlayer];
+ }
}
dispatch_async(clientQueue, ^{
@@ -1725,4 +1758,185 @@ - (void)applicationBasic_subscribeApplicationVersion:(ContentApp * _Nonnull)cont
});
}
+- (void)applicationBasic_readVendorName:(ContentApp * _Nonnull)contentApp
+ clientQueue:(dispatch_queue_t _Nonnull)clientQueue
+ requestSentHandler:(void (^_Nonnull)(MatterError * _Nonnull))requestSentHandler
+ successCallback:(void (^_Nonnull)(NSString * _Nonnull))successCallback
+ failureCallback:(void (^_Nonnull)(MatterError * _Nonnull))failureCallback
+{
+ ChipLogProgress(AppServer, "CastingServerBridge().applicationBasic_readVendorName() called on Content App with endpoint ID %d",
+ contentApp.endpointId);
+
+ [_readSuccessCallbacks setObject:successCallback forKey:@"applicationBasic_readVendorName"];
+ [_readFailureCallbacks setObject:failureCallback forKey:@"applicationBasic_readVendorName"];
+
+ dispatch_async(_chipWorkQueue, ^{
+ TargetEndpointInfo endpoint;
+ [ConversionUtils convertToCppTargetEndpointInfoFrom:contentApp outTargetEndpointInfo:endpoint];
+
+ CHIP_ERROR err = CastingServer::GetInstance()->ApplicationBasic_ReadVendorName(
+ &endpoint, nullptr,
+ [](void * context,
+ chip::app::Clusters::ApplicationBasic::Attributes::VendorName::TypeInfo::DecodableArgType vendorName) {
+ void (^callback)(NSString * _Nonnull) = [[CastingServerBridge getSharedInstance].subscriptionReadSuccessCallbacks
+ objectForKey:@"applicationBasic_readVendorName"];
+ callback([NSString stringWithUTF8String:vendorName.data()]);
+ },
+ [](void * context, CHIP_ERROR err) {
+ void (^callback)(MatterError *) = [[CastingServerBridge getSharedInstance].subscriptionReadFailureCallbacks
+ objectForKey:@"applicationBasic_readVendorName"];
+ callback([[MatterError alloc] initWithCode:err.AsInteger() message:[NSString stringWithUTF8String:err.AsString()]]);
+ });
+ dispatch_async(clientQueue, ^{
+ requestSentHandler([[MatterError alloc] initWithCode:err.AsInteger()
+ message:[NSString stringWithUTF8String:err.AsString()]]);
+ });
+ });
+}
+
+- (void)applicationBasic_readVendorID:(ContentApp * _Nonnull)contentApp
+ clientQueue:(dispatch_queue_t _Nonnull)clientQueue
+ requestSentHandler:(void (^_Nonnull)(MatterError * _Nonnull))requestSentHandler
+ successCallback:(void (^_Nonnull)(NSNumber * _Nonnull))successCallback
+ failureCallback:(void (^_Nonnull)(MatterError * _Nonnull))failureCallback
+{
+ ChipLogProgress(AppServer, "CastingServerBridge().applicationBasic_readVendorID() called on Content App with endpoint ID %d",
+ contentApp.endpointId);
+
+ [_readSuccessCallbacks setObject:successCallback forKey:@"applicationBasic_readVendorID"];
+ [_readFailureCallbacks setObject:failureCallback forKey:@"applicationBasic_readVendorID"];
+
+ dispatch_async(_chipWorkQueue, ^{
+ TargetEndpointInfo endpoint;
+ [ConversionUtils convertToCppTargetEndpointInfoFrom:contentApp outTargetEndpointInfo:endpoint];
+
+ CHIP_ERROR err = CastingServer::GetInstance()->ApplicationBasic_ReadVendorID(
+ &endpoint, nullptr,
+ [](void * context, chip::app::Clusters::ApplicationBasic::Attributes::VendorID::TypeInfo::DecodableArgType vendorID) {
+ void (^callback)(NSNumber * _Nonnull) = [[CastingServerBridge getSharedInstance].subscriptionReadSuccessCallbacks
+ objectForKey:@"applicationBasic_readVendorID"];
+ callback(@(vendorID));
+ },
+ [](void * context, CHIP_ERROR err) {
+ void (^callback)(MatterError *) = [[CastingServerBridge getSharedInstance].subscriptionReadFailureCallbacks
+ objectForKey:@"applicationBasic_readVendorID"];
+ callback([[MatterError alloc] initWithCode:err.AsInteger() message:[NSString stringWithUTF8String:err.AsString()]]);
+ });
+ dispatch_async(clientQueue, ^{
+ requestSentHandler([[MatterError alloc] initWithCode:err.AsInteger()
+ message:[NSString stringWithUTF8String:err.AsString()]]);
+ });
+ });
+}
+
+- (void)applicationBasic_readApplicationName:(ContentApp * _Nonnull)contentApp
+ clientQueue:(dispatch_queue_t _Nonnull)clientQueue
+ requestSentHandler:(void (^_Nonnull)(MatterError * _Nonnull))requestSentHandler
+ successCallback:(void (^_Nonnull)(NSString * _Nonnull))successCallback
+ failureCallback:(void (^_Nonnull)(MatterError * _Nonnull))failureCallback
+{
+ ChipLogProgress(AppServer,
+ "CastingServerBridge().applicationBasic_readApplicationName() called on Content App with endpoint ID %d",
+ contentApp.endpointId);
+
+ [_readSuccessCallbacks setObject:successCallback forKey:@"applicationBasic_readApplicationName"];
+ [_readFailureCallbacks setObject:failureCallback forKey:@"applicationBasic_readApplicationName"];
+
+ dispatch_async(_chipWorkQueue, ^{
+ TargetEndpointInfo endpoint;
+ [ConversionUtils convertToCppTargetEndpointInfoFrom:contentApp outTargetEndpointInfo:endpoint];
+
+ CHIP_ERROR err = CastingServer::GetInstance()->ApplicationBasic_ReadApplicationName(
+ &endpoint, nullptr,
+ [](void * context,
+ chip::app::Clusters::ApplicationBasic::Attributes::ApplicationName::TypeInfo::DecodableArgType applicationName) {
+ void (^callback)(NSString * _Nonnull) = [[CastingServerBridge getSharedInstance].subscriptionReadSuccessCallbacks
+ objectForKey:@"applicationBasic_readApplicationName"];
+ callback([NSString stringWithUTF8String:applicationName.data()]);
+ },
+ [](void * context, CHIP_ERROR err) {
+ void (^callback)(MatterError *) = [[CastingServerBridge getSharedInstance].subscriptionReadFailureCallbacks
+ objectForKey:@"applicationBasic_readApplicationName"];
+ callback([[MatterError alloc] initWithCode:err.AsInteger() message:[NSString stringWithUTF8String:err.AsString()]]);
+ });
+ dispatch_async(clientQueue, ^{
+ requestSentHandler([[MatterError alloc] initWithCode:err.AsInteger()
+ message:[NSString stringWithUTF8String:err.AsString()]]);
+ });
+ });
+}
+
+- (void)applicationBasic_readProductID:(ContentApp * _Nonnull)contentApp
+ clientQueue:(dispatch_queue_t _Nonnull)clientQueue
+ requestSentHandler:(void (^_Nonnull)(MatterError * _Nonnull))requestSentHandler
+ successCallback:(void (^_Nonnull)(uint16_t))successCallback
+ failureCallback:(void (^_Nonnull)(MatterError * _Nonnull))failureCallback
+{
+ ChipLogProgress(AppServer, "CastingServerBridge().applicationBasic_readProductID() called on Content App with endpoint ID %d",
+ contentApp.endpointId);
+
+ [_readSuccessCallbacks setObject:successCallback forKey:@"applicationBasic_readProductID"];
+ [_readFailureCallbacks setObject:failureCallback forKey:@"applicationBasic_readProductID"];
+
+ dispatch_async(_chipWorkQueue, ^{
+ TargetEndpointInfo endpoint;
+ [ConversionUtils convertToCppTargetEndpointInfoFrom:contentApp outTargetEndpointInfo:endpoint];
+
+ CHIP_ERROR err = CastingServer::GetInstance()->ApplicationBasic_ReadProductID(
+ &endpoint, nullptr,
+ [](void * context, chip::app::Clusters::ApplicationBasic::Attributes::ProductID::TypeInfo::DecodableArgType productID) {
+ void (^callback)(uint16_t) = [[CastingServerBridge getSharedInstance].subscriptionReadSuccessCallbacks
+ objectForKey:@"applicationBasic_readProductID"];
+ callback(productID);
+ },
+ [](void * context, CHIP_ERROR err) {
+ void (^callback)(MatterError *) = [[CastingServerBridge getSharedInstance].subscriptionReadFailureCallbacks
+ objectForKey:@"applicationBasic_readProductID"];
+ callback([[MatterError alloc] initWithCode:err.AsInteger() message:[NSString stringWithUTF8String:err.AsString()]]);
+ });
+ dispatch_async(clientQueue, ^{
+ requestSentHandler([[MatterError alloc] initWithCode:err.AsInteger()
+ message:[NSString stringWithUTF8String:err.AsString()]]);
+ });
+ });
+}
+
+- (void)applicationBasic_readApplicationVersion:(ContentApp * _Nonnull)contentApp
+ clientQueue:(dispatch_queue_t _Nonnull)clientQueue
+ requestSentHandler:(void (^_Nonnull)(MatterError * _Nonnull))requestSentHandler
+ successCallback:(void (^_Nonnull)(NSString * _Nonnull))successCallback
+ failureCallback:(void (^_Nonnull)(MatterError * _Nonnull))failureCallback
+{
+ ChipLogProgress(AppServer,
+ "CastingServerBridge().applicationBasic_readApplicationVersion() called on Content App with endpoint ID %d",
+ contentApp.endpointId);
+
+ [_readSuccessCallbacks setObject:successCallback forKey:@"applicationBasic_readApplicationVersion"];
+ [_readFailureCallbacks setObject:failureCallback forKey:@"applicationBasic_readApplicationVersion"];
+
+ dispatch_async(_chipWorkQueue, ^{
+ TargetEndpointInfo endpoint;
+ [ConversionUtils convertToCppTargetEndpointInfoFrom:contentApp outTargetEndpointInfo:endpoint];
+
+ CHIP_ERROR err = CastingServer::GetInstance()->ApplicationBasic_ReadApplicationVersion(
+ &endpoint, nullptr,
+ [](void * context,
+ chip::app::Clusters::ApplicationBasic::Attributes::ApplicationVersion::TypeInfo::DecodableArgType
+ applicationVersion) {
+ void (^callback)(NSString * _Nonnull) = [[CastingServerBridge getSharedInstance].subscriptionReadSuccessCallbacks
+ objectForKey:@"applicationBasic_readApplicationVersion"];
+ callback([NSString stringWithUTF8String:applicationVersion.data()]);
+ },
+ [](void * context, CHIP_ERROR err) {
+ void (^callback)(MatterError *) = [[CastingServerBridge getSharedInstance].subscriptionReadFailureCallbacks
+ objectForKey:@"applicationBasic_readApplicationVersion"];
+ callback([[MatterError alloc] initWithCode:err.AsInteger() message:[NSString stringWithUTF8String:err.AsString()]]);
+ });
+ dispatch_async(clientQueue, ^{
+ requestSentHandler([[MatterError alloc] initWithCode:err.AsInteger()
+ message:[NSString stringWithUTF8String:err.AsString()]]);
+ });
+ });
+}
+
@end
diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/ConversionUtils.hpp b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/ConversionUtils.hpp
index df6a0360816ce8..bf92cf09a0069b 100644
--- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/ConversionUtils.hpp
+++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/ConversionUtils.hpp
@@ -17,10 +17,12 @@
#import
+#import "AppParameters.h"
#import "ContentApp.h"
#import "DiscoveredNodeData.h"
#import "VideoPlayer.h"
+#import
#import
#import
#include
@@ -32,6 +34,8 @@
/**
* @brief Objective C to C++ converters
*/
++ (CHIP_ERROR)convertToCppAppParamsInfoFrom:(AppParameters * _Nonnull)objCAppParameters outAppParams:(AppParams &)outAppParams;
+
+ (CHIP_ERROR)convertToCppTargetEndpointInfoFrom:(ContentApp * _Nonnull)objCContentApp
outTargetEndpointInfo:(TargetEndpointInfo &)outTargetEndpointInfo;
diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/ConversionUtils.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/ConversionUtils.mm
index ca626201fdf236..f71cab0bf0e1c6 100644
--- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/ConversionUtils.mm
+++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/ConversionUtils.mm
@@ -20,6 +20,19 @@
@implementation ConversionUtils
++ (CHIP_ERROR)convertToCppAppParamsInfoFrom:(AppParameters * _Nonnull)objCAppParameters outAppParams:(AppParams &)outAppParams
+{
+ VerifyOrReturnError(objCAppParameters != nil, CHIP_ERROR_INVALID_ARGUMENT);
+
+ if (objCAppParameters.rotatingDeviceIdUniqueId != nil) {
+ chip::ByteSpan rotatingDeviceIdUniqueId
+ = chip::ByteSpan(static_cast(objCAppParameters.rotatingDeviceIdUniqueId.bytes),
+ objCAppParameters.rotatingDeviceIdUniqueId.length);
+ outAppParams.SetRotatingDeviceIdUniqueId(MakeOptional(rotatingDeviceIdUniqueId));
+ }
+ return CHIP_NO_ERROR;
+}
+
+ (CHIP_ERROR)convertToCppTargetEndpointInfoFrom:(ContentApp * _Nonnull)objCContentApp
outTargetEndpointInfo:(TargetEndpointInfo &)outTargetEndpointInfo
{
diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DiscoveredNodeData.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DiscoveredNodeData.h
index 24240cc4a4acda..f4cf95f4be7e6a 100644
--- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DiscoveredNodeData.h
+++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DiscoveredNodeData.h
@@ -17,6 +17,8 @@
#import
+#import "VideoPlayer.h"
+
#ifndef DiscoveredNodeData_h
#define DiscoveredNodeData_h
@@ -54,6 +56,12 @@
- (DiscoveredNodeData *)initWithDeviceName:(NSString *)deviceName vendorId:(uint16_t)vendorId productId:(uint16_t)productId;
+- (bool)isPreCommissioned;
+
+- (VideoPlayer *)getConnectableVideoPlayer;
+
+- (void)setConnectableVideoPlayer:(VideoPlayer *)videoPlayer;
+
@end
#endif /* DiscoveredNodeData_h */
diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DiscoveredNodeData.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DiscoveredNodeData.mm
index 541352b3d31bf9..f8c85e52269dbb 100644
--- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DiscoveredNodeData.mm
+++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DiscoveredNodeData.mm
@@ -20,6 +20,12 @@
#import "DiscoveredNodeData.h"
#include
+@interface DiscoveredNodeData ()
+
+@property (nonatomic) VideoPlayer * connectableVideoPlayer;
+
+@end
+
@implementation DiscoveredNodeData
- (DiscoveredNodeData *)initWithDeviceName:(NSString *)deviceName vendorId:(uint16_t)vendorId productId:(uint16_t)productId
@@ -35,7 +41,12 @@ - (DiscoveredNodeData *)initWithDeviceName:(NSString *)deviceName vendorId:(uint
- (NSString *)description
{
- return [NSString stringWithFormat:@"%@ with Product ID: %d and Vendor ID: %d", _deviceName, _productId, _vendorId];
+ if ([self isPreCommissioned]) {
+ return [NSString
+ stringWithFormat:@"%@ with Product ID: %d and Vendor ID: %d [Pre-Commissioned]", _deviceName, _productId, _vendorId];
+ } else {
+ return [NSString stringWithFormat:@"%@ with Product ID: %d and Vendor ID: %d", _deviceName, _productId, _vendorId];
+ }
}
- (BOOL)isEqualToDiscoveredNodeData:(DiscoveredNodeData *)other
@@ -70,4 +81,19 @@ - (NSUInteger)hash
return result;
}
+- (void)setConnectableVideoPlayer:(VideoPlayer * _Nonnull)videoPlayer
+{
+ _connectableVideoPlayer = videoPlayer;
+}
+
+- (bool)isPreCommissioned
+{
+ return _connectableVideoPlayer != nil;
+}
+
+- (VideoPlayer *)getConnectableVideoPlayer
+{
+ return _connectableVideoPlayer;
+}
+
@end
diff --git a/examples/tv-casting-app/darwin/TvCasting/TvCasting/CommissionerDiscoveryView.swift b/examples/tv-casting-app/darwin/TvCasting/TvCasting/CommissionerDiscoveryView.swift
index 3ee2ac30d4b724..7a33fc7b19e271 100644
--- a/examples/tv-casting-app/darwin/TvCasting/TvCasting/CommissionerDiscoveryView.swift
+++ b/examples/tv-casting-app/darwin/TvCasting/TvCasting/CommissionerDiscoveryView.swift
@@ -55,7 +55,16 @@ struct CommissionerDiscoveryView: View {
Text("Select a commissioner video player...")
ForEach(viewModel.commissioners) { commissioner in
NavigationLink(
- destination: CommissioningView(_selectedCommissioner: commissioner),
+ destination: {
+ if(commissioner.isPreCommissioned())
+ {
+ ConnectionView(_selectedVideoPlayer: commissioner.getConnectableVideoPlayer())
+ }
+ else
+ {
+ CommissioningView(_selectedCommissioner: commissioner)
+ }
+ },
label: {
Text(commissioner.description)
}
diff --git a/examples/tv-casting-app/darwin/TvCasting/TvCasting/ContentView.swift b/examples/tv-casting-app/darwin/TvCasting/TvCasting/ContentView.swift
index e7ca12c9b720cd..b281da172435aa 100644
--- a/examples/tv-casting-app/darwin/TvCasting/TvCasting/ContentView.swift
+++ b/examples/tv-casting-app/darwin/TvCasting/TvCasting/ContentView.swift
@@ -20,7 +20,6 @@ import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
- //CommissionerDiscoveryView()
StartFromCacheView()
}
}
diff --git a/examples/tv-casting-app/darwin/TvCasting/TvCasting/TvCastingApp.swift b/examples/tv-casting-app/darwin/TvCasting/TvCasting/TvCastingApp.swift
index 27dce5b63f55f1..26e4768485d13e 100644
--- a/examples/tv-casting-app/darwin/TvCasting/TvCasting/TvCastingApp.swift
+++ b/examples/tv-casting-app/darwin/TvCasting/TvCasting/TvCastingApp.swift
@@ -16,12 +16,33 @@
*/
import SwiftUI
+import os.log
@main
struct TvCastingApp: App {
+ let Log = Logger(subsystem: "com.matter.casting",
+ category: "TvCastingApp")
+
var body: some Scene {
WindowGroup {
ContentView()
+ .onAppear(perform: {
+ if let castingServerBridge = CastingServerBridge.getSharedInstance()
+ {
+ let appParameters: AppParameters = AppParameters()
+
+ var rotatingDeviceIdUniqueId: [UInt8] = [UInt8](repeating: 0, count: 16 )
+ for i in (0...15)
+ {
+ rotatingDeviceIdUniqueId[i] = UInt8.random(in: 0..<255)
+ }
+ appParameters.rotatingDeviceIdUniqueId = Data(rotatingDeviceIdUniqueId)
+
+ castingServerBridge.initApp(appParameters, clientQueue: DispatchQueue.main, initAppStatusHandler: { (result: Bool) -> () in
+ self.Log.info("initApp result \(result)")
+ })
+ }
+ })
}
}
}
diff --git a/examples/tv-casting-app/linux/CastingUtils.cpp b/examples/tv-casting-app/linux/CastingUtils.cpp
index 760b0435124c47..294339bed585a1 100644
--- a/examples/tv-casting-app/linux/CastingUtils.cpp
+++ b/examples/tv-casting-app/linux/CastingUtils.cpp
@@ -41,7 +41,9 @@ CHIP_ERROR DiscoverCommissioners()
CHIP_ERROR RequestCommissioning(int index)
{
- const Dnssd::DiscoveredNodeData * selectedCommissioner = CastingServer::GetInstance()->GetDiscoveredCommissioner(index);
+ chip::Optional associatedConnectableVideoPlayer;
+ const Dnssd::DiscoveredNodeData * selectedCommissioner =
+ CastingServer::GetInstance()->GetDiscoveredCommissioner(index, associatedConnectableVideoPlayer);
if (selectedCommissioner == nullptr)
{
ChipLogError(AppServer, "No such commissioner with index %d exists", index);
@@ -89,11 +91,19 @@ void InitCommissioningFlow(intptr_t commandArg)
// Display discovered commissioner TVs to ask user to select one
for (int i = 0; i < CHIP_DEVICE_CONFIG_MAX_DISCOVERED_NODES; i++)
{
- const Dnssd::DiscoveredNodeData * commissioner = CastingServer::GetInstance()->GetDiscoveredCommissioner(i);
+ chip::Optional associatedConnectableVideoPlayer;
+ const Dnssd::DiscoveredNodeData * commissioner =
+ CastingServer::GetInstance()->GetDiscoveredCommissioner(i, associatedConnectableVideoPlayer);
if (commissioner != nullptr)
{
ChipLogProgress(AppServer, "Discovered Commissioner #%d", commissionerCount++);
commissioner->LogDetail();
+ if (associatedConnectableVideoPlayer.HasValue())
+ {
+ TargetVideoPlayerInfo * targetVideoPlayerInfo = associatedConnectableVideoPlayer.Value();
+ ChipLogProgress(AppServer, "Previously connected with nodeId 0x" ChipLogFormatX64 " fabricIndex: %d",
+ ChipLogValueX64(targetVideoPlayerInfo->GetNodeId()), targetVideoPlayerInfo->GetFabricIndex());
+ }
}
}
diff --git a/examples/tv-casting-app/tv-casting-common/BUILD.gn b/examples/tv-casting-app/tv-casting-common/BUILD.gn
index 1c356d5cb36b9e..179fa86602367a 100644
--- a/examples/tv-casting-app/tv-casting-common/BUILD.gn
+++ b/examples/tv-casting-app/tv-casting-common/BUILD.gn
@@ -47,6 +47,7 @@ chip_data_model("tv-casting-common") {
"${chip_root}/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp",
"commands/clusters/ModelCommand.cpp",
"commands/common/CHIPCommand.cpp",
+ "include/AppParams.h",
"include/ApplicationBasic.h",
"include/ApplicationLauncher.h",
"include/CastingServer.h",
@@ -57,11 +58,13 @@ chip_data_model("tv-casting-common") {
"include/MediaBase.h",
"include/MediaCommandBase.h",
"include/MediaPlayback.h",
+ "include/MediaReadBase.h",
"include/MediaSubscriptionBase.h",
"include/PersistenceManager.h",
"include/TargetEndpointInfo.h",
"include/TargetNavigator.h",
"include/TargetVideoPlayerInfo.h",
+ "src/AppParams.cpp",
"src/ApplicationLauncher.cpp",
"src/CastingServer.cpp",
"src/Channel.cpp",
diff --git a/examples/tv-casting-app/tv-casting-common/include/AppParams.h b/examples/tv-casting-app/tv-casting-common/include/AppParams.h
new file mode 100644
index 00000000000000..7a42c09b501dda
--- /dev/null
+++ b/examples/tv-casting-app/tv-casting-common/include/AppParams.h
@@ -0,0 +1,42 @@
+/*
+ *
+ * Copyright (c) 2022 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
+#include
+
+/**
+ * @brief Parameters passed to the CastingServer at the time of startup (i.e. init call)
+ */
+class AppParams
+{
+public:
+ AppParams() {}
+#if CHIP_ENABLE_ROTATING_DEVICE_ID
+ AppParams(chip::Optional rotatingDeviceIdUniqueId);
+ void SetRotatingDeviceIdUniqueId(chip::Optional rotatingDeviceIdUniqueId);
+ chip::Optional GetRotatingDeviceIdUniqueId();
+#endif // CHIP_ENABLE_ROTATING_DEVICE_ID
+
+private:
+#if CHIP_ENABLE_ROTATING_DEVICE_ID
+ // if this Optional.hasValue = false, a random one is generated by CastingServer.Init()
+ chip::Optional mRotatingDeviceIdUniqueId;
+#endif // CHIP_ENABLE_ROTATING_DEVICE_ID
+};
diff --git a/examples/tv-casting-app/tv-casting-common/include/ApplicationBasic.h b/examples/tv-casting-app/tv-casting-common/include/ApplicationBasic.h
index d30d659782b18a..ec009de429a8e6 100644
--- a/examples/tv-casting-app/tv-casting-common/include/ApplicationBasic.h
+++ b/examples/tv-casting-app/tv-casting-common/include/ApplicationBasic.h
@@ -16,6 +16,7 @@
* limitations under the License.
*/
+#include "MediaReadBase.h"
#include "MediaSubscriptionBase.h"
#include
@@ -71,3 +72,54 @@ class AllowedVendorListSubscriber
public:
AllowedVendorListSubscriber() : MediaSubscriptionBase(chip::app::Clusters::ApplicationBasic::Id) {}
};
+
+// READER CLASSES
+
+class VendorNameReader : public MediaReadBase
+{
+public:
+ VendorNameReader() : MediaReadBase(chip::app::Clusters::ApplicationBasic::Id) {}
+};
+
+class VendorIDReader : public MediaReadBase
+{
+public:
+ VendorIDReader() : MediaReadBase(chip::app::Clusters::ApplicationBasic::Id) {}
+};
+
+class ApplicationNameReader : public MediaReadBase
+{
+public:
+ ApplicationNameReader() : MediaReadBase(chip::app::Clusters::ApplicationBasic::Id) {}
+};
+
+class ProductIDReader : public MediaReadBase
+{
+public:
+ ProductIDReader() : MediaReadBase(chip::app::Clusters::ApplicationBasic::Id) {}
+};
+
+class ApplicationReader : public MediaReadBase
+{
+public:
+ ApplicationReader() : MediaReadBase(chip::app::Clusters::ApplicationBasic::Id) {}
+};
+
+class StatusReader : public MediaReadBase
+{
+public:
+ StatusReader() : MediaReadBase(chip::app::Clusters::ApplicationBasic::Id) {}
+};
+
+class ApplicationVersionReader
+ : public MediaReadBase
+{
+public:
+ ApplicationVersionReader() : MediaReadBase(chip::app::Clusters::ApplicationBasic::Id) {}
+};
+
+class AllowedVendorListReader : public MediaReadBase
+{
+public:
+ AllowedVendorListReader() : MediaReadBase(chip::app::Clusters::ApplicationBasic::Id) {}
+};
diff --git a/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h b/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h
index bc50cb335e274f..ca3b9bd3ca5be8 100644
--- a/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h
+++ b/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h
@@ -53,3 +53,5 @@
// Enable some test-only interaction model APIs.
#define CONFIG_BUILD_FOR_HOST_UNIT_TEST 1
+
+#define CHIP_ENABLE_ROTATING_DEVICE_ID 1
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 b77e2bd320604b..375ede1f6b8af3 100644
--- a/examples/tv-casting-app/tv-casting-common/include/CastingServer.h
+++ b/examples/tv-casting-app/tv-casting-common/include/CastingServer.h
@@ -18,6 +18,7 @@
#pragma once
+#include "AppParams.h"
#include "ApplicationBasic.h"
#include "ApplicationLauncher.h"
#include "Channel.h"
@@ -51,10 +52,11 @@ class CastingServer
void operator=(const CastingServer &) = delete;
static CastingServer * GetInstance();
- void Init();
+ CHIP_ERROR Init(AppParams * AppParams = nullptr);
CHIP_ERROR DiscoverCommissioners();
- const chip::Dnssd::DiscoveredNodeData * GetDiscoveredCommissioner(int index);
+ const chip::Dnssd::DiscoveredNodeData *
+ GetDiscoveredCommissioner(int index, chip::Optional & outAssociatedConnectableVideoPlayer);
CHIP_ERROR OpenBasicCommissioningWindow(std::function commissioningCompleteCallback,
std::function onConnectionSuccess,
std::function onConnectionFailure,
@@ -333,6 +335,55 @@ class CastingServer
chip::Controller::ReadResponseFailureCallback failureFn, uint16_t minInterval, uint16_t maxInterval,
chip::Controller::SubscriptionEstablishedCallback onSubscriptionEstablished);
+ CHIP_ERROR
+ ApplicationBasic_ReadVendorName(TargetEndpointInfo * endpoint, void * context,
+ chip::Controller::ReadResponseSuccessCallback<
+ chip::app::Clusters::ApplicationBasic::Attributes::VendorName::TypeInfo::DecodableArgType>
+ successFn,
+ chip::Controller::ReadResponseFailureCallback failureFn);
+ CHIP_ERROR
+ ApplicationBasic_ReadVendorID(TargetEndpointInfo * endpoint, void * context,
+ chip::Controller::ReadResponseSuccessCallback<
+ chip::app::Clusters::ApplicationBasic::Attributes::VendorID::TypeInfo::DecodableArgType>
+ successFn,
+ chip::Controller::ReadResponseFailureCallback failureFn);
+ CHIP_ERROR ApplicationBasic_ReadApplicationName(
+ TargetEndpointInfo * endpoint, void * context,
+ chip::Controller::ReadResponseSuccessCallback<
+ chip::app::Clusters::ApplicationBasic::Attributes::ApplicationName::TypeInfo::DecodableArgType>
+ successFn,
+ chip::Controller::ReadResponseFailureCallback failureFn);
+ CHIP_ERROR
+ ApplicationBasic_ReadProductID(TargetEndpointInfo * endpoint, void * context,
+ chip::Controller::ReadResponseSuccessCallback<
+ chip::app::Clusters::ApplicationBasic::Attributes::ProductID::TypeInfo::DecodableArgType>
+ successFn,
+ chip::Controller::ReadResponseFailureCallback failureFn);
+ CHIP_ERROR
+ ApplicationBasic_ReadApplication(TargetEndpointInfo * endpoint, void * context,
+ chip::Controller::ReadResponseSuccessCallback<
+ chip::app::Clusters::ApplicationBasic::Attributes::Application::TypeInfo::DecodableArgType>
+ successFn,
+ chip::Controller::ReadResponseFailureCallback failureFn);
+ CHIP_ERROR
+ ApplicationBasic_ReadStatus(TargetEndpointInfo * endpoint, void * context,
+ chip::Controller::ReadResponseSuccessCallback<
+ chip::app::Clusters::ApplicationBasic::Attributes::Status::TypeInfo::DecodableArgType>
+ successFn,
+ chip::Controller::ReadResponseFailureCallback failureFn);
+ CHIP_ERROR ApplicationBasic_ReadApplicationVersion(
+ TargetEndpointInfo * endpoint, void * context,
+ chip::Controller::ReadResponseSuccessCallback<
+ chip::app::Clusters::ApplicationBasic::Attributes::ApplicationVersion::TypeInfo::DecodableArgType>
+ successFn,
+ chip::Controller::ReadResponseFailureCallback failureFn);
+ CHIP_ERROR ApplicationBasic_ReadAllowedVendorList(
+ TargetEndpointInfo * endpoint, void * context,
+ chip::Controller::ReadResponseSuccessCallback<
+ chip::app::Clusters::ApplicationBasic::Attributes::AllowedVendorList::TypeInfo::DecodableArgType>
+ successFn,
+ chip::Controller::ReadResponseFailureCallback failureFn);
+
/*
* @brief Channel cluster
*/
@@ -361,6 +412,8 @@ class CastingServer
uint16_t mTargetVideoPlayerProductId = 0;
uint16_t mTargetVideoPlayerDeviceType = 0;
char mTargetVideoPlayerDeviceName[chip::Dnssd::kMaxDeviceNameLen + 1] = {};
+ size_t mTargetVideoPlayerNumIPs = 0; // number of valid IP addresses
+ chip::Inet::IPAddress mTargetVideoPlayerIpAddress[chip::Dnssd::CommonResolutionData::kMaxIPAddresses];
chip::Controller::CommissionableNodeController mCommissionableNodeController;
std::function mCommissioningCompleteCallback;
@@ -441,6 +494,15 @@ class CastingServer
ApplicationVersionSubscriber mApplicationVersionSubscriber;
AllowedVendorListSubscriber mAllowedVendorListSubscriber;
+ VendorNameReader mVendorNameReader;
+ VendorIDReader mVendorIDReader;
+ ApplicationNameReader mApplicationNameReader;
+ ProductIDReader mProductIDReader;
+ ApplicationReader mApplicationReader;
+ StatusReader mStatusReader;
+ ApplicationVersionReader mApplicationVersionReader;
+ AllowedVendorListReader mAllowedVendorListReader;
+
/*
* @brief Channel cluster
*/
diff --git a/examples/tv-casting-app/tv-casting-common/include/MediaReadBase.h b/examples/tv-casting-app/tv-casting-common/include/MediaReadBase.h
new file mode 100644
index 00000000000000..3003a08a348f70
--- /dev/null
+++ b/examples/tv-casting-app/tv-casting-common/include/MediaReadBase.h
@@ -0,0 +1,42 @@
+/*
+ *
+ * Copyright (c) 2022 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 "MediaBase.h"
+
+template
+class MediaReadBase : public MediaBase
+{
+public:
+ MediaReadBase(chip::ClusterId clusterId) : MediaBase(clusterId) {}
+
+ CHIP_ERROR ReadAttribute(void * context,
+ chip::Controller::ReadResponseSuccessCallback successFn,
+ chip::Controller::ReadResponseFailureCallback failureFn)
+ {
+ VerifyOrDieWithMsg(mTargetVideoPlayerInfo != nullptr, AppServer, "Target unknown");
+
+ auto deviceProxy = mTargetVideoPlayerInfo->GetOperationalDeviceProxy();
+ ReturnErrorCodeIf(deviceProxy == nullptr || !deviceProxy->ConnectionReady(), CHIP_ERROR_PEER_NODE_NOT_FOUND);
+
+ MediaClusterBase cluster(*deviceProxy->GetExchangeManager(), deviceProxy->GetSecureSession().Value(), mClusterId,
+ mTvEndpoint);
+
+ return cluster.template ReadAttribute(context, successFn, failureFn);
+ }
+};
diff --git a/examples/tv-casting-app/tv-casting-common/include/PersistenceManager.h b/examples/tv-casting-app/tv-casting-common/include/PersistenceManager.h
index d9505e00391126..b1e7bd6c58130d 100644
--- a/examples/tv-casting-app/tv-casting-common/include/PersistenceManager.h
+++ b/examples/tv-casting-app/tv-casting-common/include/PersistenceManager.h
@@ -44,16 +44,20 @@ class PersistenceManager
kEndpointIdTag,
kClusterIdsContainerTag,
kClusterIdTag,
- kCastingDataVersionTag,
+ kCurrentCastingDataVersionTag,
kVideoPlayerVendorIdTag,
kVideoPlayerProductIdTag,
kVideoPlayerDeviceTypeIdTag,
kVideoPlayerDeviceNameTag,
+ kVideoPlayerNumIPsTag,
+ kVideoPlayerIPAddressTag,
+ kIpAddressesContainerTag,
kContextTagMaxNum = UINT8_MAX
};
- constexpr static size_t kCastingDataMaxBytes = 1024 * 100; // 100 KBs
- constexpr static char * kCastingDataKey = (char *) "com.matter.casting";
- constexpr static uint32_t kCastingDataVersion = 1;
+ constexpr static size_t kCastingDataMaxBytes = 1024 * 100; // 100 KBs
+ constexpr static char * kCastingDataKey = (char *) "com.matter.casting";
+ constexpr static uint32_t kCurrentCastingDataVersion = 1;
+ constexpr static uint32_t kSupportedCastingDataVersions[1] = { 1 };
};
diff --git a/examples/tv-casting-app/tv-casting-common/include/TargetVideoPlayerInfo.h b/examples/tv-casting-app/tv-casting-common/include/TargetVideoPlayerInfo.h
index da58e8db11b63e..0f423e2aeb459a 100644
--- a/examples/tv-casting-app/tv-casting-common/include/TargetVideoPlayerInfo.h
+++ b/examples/tv-casting-app/tv-casting-common/include/TargetVideoPlayerInfo.h
@@ -43,6 +43,9 @@ class TargetVideoPlayerInfo
chip::NodeId GetNodeId() const { return mNodeId; }
chip::FabricIndex GetFabricIndex() const { return mFabricIndex; }
const char * GetDeviceName() const { return mDeviceName; }
+ size_t GetNumIPs() const { return mNumIPs; }
+ const chip::Inet::IPAddress * GetIpAddresses() const { return mIpAddress; }
+ bool IsSameAs(const chip::Dnssd::DiscoveredNodeData * discoveredNodeData);
chip::OperationalDeviceProxy * GetOperationalDeviceProxy()
{
@@ -56,7 +59,8 @@ class TargetVideoPlayerInfo
CHIP_ERROR Initialize(chip::NodeId nodeId, chip::FabricIndex fabricIndex,
std::function onConnectionSuccess,
std::function onConnectionFailure, uint16_t vendorId = 0, uint16_t productId = 0,
- uint16_t deviceType = 0, const char * deviceName = {});
+ uint16_t deviceType = 0, const char * deviceName = {}, size_t numIPs = 0,
+ chip::Inet::IPAddress * ipAddressList = nullptr);
CHIP_ERROR FindOrEstablishCASESession(std::function onConnectionSuccess,
std::function onConnectionFailure);
TargetEndpointInfo * GetOrAddEndpoint(chip::EndpointId endpointId);
@@ -107,6 +111,8 @@ class TargetVideoPlayerInfo
uint16_t mProductId = 0;
uint16_t mDeviceType = 0;
char mDeviceName[chip::Dnssd::kMaxDeviceNameLen + 1] = {};
+ size_t mNumIPs = 0; // number of valid IP addresses
+ chip::Inet::IPAddress mIpAddress[chip::Dnssd::CommonResolutionData::kMaxIPAddresses];
chip::Callback::Callback mOnConnectedCallback;
chip::Callback::Callback mOnConnectionFailureCallback;
diff --git a/examples/tv-casting-app/tv-casting-common/src/AppParams.cpp b/examples/tv-casting-app/tv-casting-common/src/AppParams.cpp
new file mode 100644
index 00000000000000..62a98feda4375f
--- /dev/null
+++ b/examples/tv-casting-app/tv-casting-common/src/AppParams.cpp
@@ -0,0 +1,36 @@
+/*
+ *
+ * Copyright (c) 2022 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 "AppParams.h"
+
+#if CHIP_ENABLE_ROTATING_DEVICE_ID
+AppParams::AppParams(chip::Optional rotatingDeviceIdUniqueId)
+{
+ mRotatingDeviceIdUniqueId = rotatingDeviceIdUniqueId;
+}
+
+void AppParams::SetRotatingDeviceIdUniqueId(chip::Optional rotatingDeviceIdUniqueId)
+{
+ mRotatingDeviceIdUniqueId = rotatingDeviceIdUniqueId;
+}
+
+chip::Optional AppParams::GetRotatingDeviceIdUniqueId()
+{
+ return mRotatingDeviceIdUniqueId;
+}
+#endif // CHIP_ENABLE_ROTATING_DEVICE_ID
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 7891070728abfe..505f578086dd71 100644
--- a/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp
+++ b/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp
@@ -25,20 +25,7 @@ using namespace chip::app::Clusters::ContentLauncher::Commands;
CastingServer * CastingServer::castingServer_ = nullptr;
-CastingServer::CastingServer()
-{
-#if CHIP_ENABLE_ROTATING_DEVICE_ID && defined(CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID)
- // generate and set a random uniqueId for generating rotatingId
- uint8_t rotatingDeviceIdUniqueId[chip::DeviceLayer::ConfigurationManager::kRotatingDeviceIDUniqueIDLength];
- for (size_t i = 0; i < sizeof(rotatingDeviceIdUniqueId); i++)
- {
- rotatingDeviceIdUniqueId[i] = chip::Crypto::GetRandU8();
- }
-
- ByteSpan rotatingDeviceIdUniqueIdSpan(rotatingDeviceIdUniqueId);
- chip::DeviceLayer::ConfigurationMgr().SetRotatingDeviceIdUniqueId(rotatingDeviceIdUniqueIdSpan);
-#endif // CHIP_ENABLE_ROTATING_DEVICE_ID && defined(CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID)
-}
+CastingServer::CastingServer() {}
CastingServer * CastingServer::GetInstance()
{
@@ -49,20 +36,44 @@ CastingServer * CastingServer::GetInstance()
return castingServer_;
}
-void CastingServer::Init()
+CHIP_ERROR CastingServer::Init(AppParams * AppParams)
{
if (mInited)
{
- return;
+ return CHIP_NO_ERROR;
+ }
+
+#if CHIP_ENABLE_ROTATING_DEVICE_ID
+ // if this class's client provided a RotatingDeviceIdUniqueId, use that
+ if (AppParams != nullptr && AppParams->GetRotatingDeviceIdUniqueId().HasValue())
+ {
+ ByteSpan rotatingDeviceIdUniqueId(AppParams->GetRotatingDeviceIdUniqueId().Value());
+ chip::DeviceLayer::ConfigurationMgr().SetRotatingDeviceIdUniqueId(rotatingDeviceIdUniqueId);
+ }
+#ifdef CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID
+ else
+ {
+ // otherwise, generate and set a random uniqueId for generating rotatingId
+ uint8_t rotatingDeviceIdUniqueId[chip::DeviceLayer::ConfigurationManager::kRotatingDeviceIDUniqueIDLength];
+ for (size_t i = 0; i < sizeof(rotatingDeviceIdUniqueId); i++)
+ {
+ rotatingDeviceIdUniqueId[i] = chip::Crypto::GetRandU8();
+ }
+
+ // ByteSpan rotatingDeviceIdUniqueIdSpan(rotatingDeviceIdUniqueId);
+ chip::DeviceLayer::ConfigurationMgr().SetRotatingDeviceIdUniqueId(ByteSpan(rotatingDeviceIdUniqueId));
}
+#endif // CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID
+#endif // CHIP_ENABLE_ROTATING_DEVICE_ID
// Initialize binding handlers
- ReturnOnFailure(InitBindingHandlers());
+ ReturnErrorOnFailure(InitBindingHandlers());
// Add callback to send Content casting commands after commissioning completes
- ReturnOnFailure(DeviceLayer::PlatformMgrImpl().AddEventHandler(DeviceEventCallback, 0));
+ ReturnErrorOnFailure(DeviceLayer::PlatformMgrImpl().AddEventHandler(DeviceEventCallback, 0));
mInited = true;
+ return CHIP_NO_ERROR;
}
CHIP_ERROR CastingServer::InitBindingHandlers()
@@ -88,6 +99,12 @@ CHIP_ERROR CastingServer::TargetVideoPlayerInfoInit(NodeId nodeId, FabricIndex f
CHIP_ERROR CastingServer::DiscoverCommissioners()
{
+ TargetVideoPlayerInfo * connectableVideoPlayerList = ReadCachedTargetVideoPlayerInfos();
+ if (connectableVideoPlayerList == nullptr || !connectableVideoPlayerList[0].IsInitialized())
+ {
+ ChipLogProgress(AppServer, "No cached video players found during discovery");
+ }
+
// Send discover commissioners request
return mCommissionableNodeController.DiscoverCommissioners(
Dnssd::DiscoveryFilter(Dnssd::DiscoveryFilterType::kDeviceType, static_cast(35)));
@@ -120,15 +137,32 @@ CHIP_ERROR CastingServer::SendUserDirectedCommissioningRequest(Dnssd::Discovered
mTargetVideoPlayerVendorId = selectedCommissioner->commissionData.vendorId;
mTargetVideoPlayerProductId = selectedCommissioner->commissionData.productId;
mTargetVideoPlayerDeviceType = selectedCommissioner->commissionData.deviceType;
+ mTargetVideoPlayerNumIPs = selectedCommissioner->resolutionData.numIPs;
+ for (size_t i = 0; i < mTargetVideoPlayerNumIPs && i < chip::Dnssd::CommonResolutionData::kMaxIPAddresses; i++)
+ {
+ mTargetVideoPlayerIpAddress[i] = selectedCommissioner->resolutionData.ipAddress[i];
+ }
chip::Platform::CopyString(mTargetVideoPlayerDeviceName, chip::Dnssd::kMaxDeviceNameLen + 1,
selectedCommissioner->commissionData.deviceName);
return CHIP_NO_ERROR;
}
#endif // CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY_CLIENT
-const Dnssd::DiscoveredNodeData * CastingServer::GetDiscoveredCommissioner(int index)
+const Dnssd::DiscoveredNodeData *
+CastingServer::GetDiscoveredCommissioner(int index, chip::Optional & outAssociatedConnectableVideoPlayer)
{
- return mCommissionableNodeController.GetDiscoveredCommissioner(index);
+ const Dnssd::DiscoveredNodeData * discoveredNodeData = mCommissionableNodeController.GetDiscoveredCommissioner(index);
+ if (discoveredNodeData != nullptr)
+ {
+ for (size_t i = 0; i < kMaxCachedVideoPlayers && mCachedTargetVideoPlayerInfo[i].IsInitialized(); i++)
+ {
+ if (mCachedTargetVideoPlayerInfo[i].IsSameAs(discoveredNodeData))
+ {
+ outAssociatedConnectableVideoPlayer = MakeOptional(&mCachedTargetVideoPlayerInfo[i]);
+ }
+ }
+ }
+ return discoveredNodeData;
}
void CastingServer::ReadServerClustersForNode(NodeId nodeId)
@@ -301,7 +335,8 @@ void CastingServer::DeviceEventCallback(const DeviceLayer::ChipDeviceEvent * eve
CastingServer::GetInstance()->mOnConnectionSuccessClientCallback,
CastingServer::GetInstance()->mOnConnectionFailureClientCallback,
CastingServer::GetInstance()->mTargetVideoPlayerVendorId, CastingServer::GetInstance()->mTargetVideoPlayerProductId,
- CastingServer::GetInstance()->mTargetVideoPlayerDeviceType, CastingServer::GetInstance()->mTargetVideoPlayerDeviceName);
+ CastingServer::GetInstance()->mTargetVideoPlayerDeviceType, CastingServer::GetInstance()->mTargetVideoPlayerDeviceName,
+ CastingServer::GetInstance()->mTargetVideoPlayerNumIPs, CastingServer::GetInstance()->mTargetVideoPlayerIpAddress);
CastingServer::GetInstance()->mCommissioningCompleteCallback(err);
}
@@ -823,6 +858,97 @@ CHIP_ERROR CastingServer::ApplicationBasic_SubscribeToAllowedVendorList(
onSubscriptionEstablished);
}
+CHIP_ERROR CastingServer::ApplicationBasic_ReadVendorName(
+ TargetEndpointInfo * endpoint, void * context,
+ chip::Controller::ReadResponseSuccessCallback<
+ chip::app::Clusters::ApplicationBasic::Attributes::VendorName::TypeInfo::DecodableArgType>
+ successFn,
+ chip::Controller::ReadResponseFailureCallback failureFn)
+{
+ ReturnErrorOnFailure(mVendorNameReader.SetTarget(mActiveTargetVideoPlayerInfo, endpoint->GetEndpointId()));
+ return mVendorNameReader.ReadAttribute(context, successFn, failureFn);
+}
+
+CHIP_ERROR
+CastingServer::ApplicationBasic_ReadVendorID(
+ TargetEndpointInfo * endpoint, void * context,
+ chip::Controller::ReadResponseSuccessCallback<
+ chip::app::Clusters::ApplicationBasic::Attributes::VendorID::TypeInfo::DecodableArgType>
+ successFn,
+ chip::Controller::ReadResponseFailureCallback failureFn)
+{
+ ReturnErrorOnFailure(mVendorIDReader.SetTarget(mActiveTargetVideoPlayerInfo, endpoint->GetEndpointId()));
+ return mVendorIDReader.ReadAttribute(context, successFn, failureFn);
+}
+
+CHIP_ERROR CastingServer::ApplicationBasic_ReadApplicationName(
+ TargetEndpointInfo * endpoint, void * context,
+ chip::Controller::ReadResponseSuccessCallback<
+ chip::app::Clusters::ApplicationBasic::Attributes::ApplicationName::TypeInfo::DecodableArgType>
+ successFn,
+ chip::Controller::ReadResponseFailureCallback failureFn)
+{
+ ReturnErrorOnFailure(mApplicationNameReader.SetTarget(mActiveTargetVideoPlayerInfo, endpoint->GetEndpointId()));
+ return mApplicationNameReader.ReadAttribute(context, successFn, failureFn);
+}
+
+CHIP_ERROR
+CastingServer::ApplicationBasic_ReadProductID(
+ TargetEndpointInfo * endpoint, void * context,
+ chip::Controller::ReadResponseSuccessCallback<
+ chip::app::Clusters::ApplicationBasic::Attributes::ProductID::TypeInfo::DecodableArgType>
+ successFn,
+ chip::Controller::ReadResponseFailureCallback failureFn)
+{
+ ReturnErrorOnFailure(mProductIDReader.SetTarget(mActiveTargetVideoPlayerInfo, endpoint->GetEndpointId()));
+ return mProductIDReader.ReadAttribute(context, successFn, failureFn);
+}
+
+CHIP_ERROR CastingServer::ApplicationBasic_ReadApplication(
+ TargetEndpointInfo * endpoint, void * context,
+ chip::Controller::ReadResponseSuccessCallback<
+ chip::app::Clusters::ApplicationBasic::Attributes::Application::TypeInfo::DecodableArgType>
+ successFn,
+ chip::Controller::ReadResponseFailureCallback failureFn)
+{
+ ReturnErrorOnFailure(mApplicationReader.SetTarget(mActiveTargetVideoPlayerInfo, endpoint->GetEndpointId()));
+ return mApplicationReader.ReadAttribute(context, successFn, failureFn);
+}
+
+CHIP_ERROR
+CastingServer::ApplicationBasic_ReadStatus(
+ TargetEndpointInfo * endpoint, void * context,
+ chip::Controller::ReadResponseSuccessCallback<
+ chip::app::Clusters::ApplicationBasic::Attributes::Status::TypeInfo::DecodableArgType>
+ successFn,
+ chip::Controller::ReadResponseFailureCallback failureFn)
+{
+ ReturnErrorOnFailure(mStatusReader.SetTarget(mActiveTargetVideoPlayerInfo, endpoint->GetEndpointId()));
+ return mStatusReader.ReadAttribute(context, successFn, failureFn);
+}
+
+CHIP_ERROR CastingServer::ApplicationBasic_ReadApplicationVersion(
+ TargetEndpointInfo * endpoint, void * context,
+ chip::Controller::ReadResponseSuccessCallback<
+ chip::app::Clusters::ApplicationBasic::Attributes::ApplicationVersion::TypeInfo::DecodableArgType>
+ successFn,
+ chip::Controller::ReadResponseFailureCallback failureFn)
+{
+ ReturnErrorOnFailure(mApplicationVersionReader.SetTarget(mActiveTargetVideoPlayerInfo, endpoint->GetEndpointId()));
+ return mApplicationVersionReader.ReadAttribute(context, successFn, failureFn);
+}
+
+CHIP_ERROR CastingServer::ApplicationBasic_ReadAllowedVendorList(
+ TargetEndpointInfo * endpoint, void * context,
+ chip::Controller::ReadResponseSuccessCallback<
+ chip::app::Clusters::ApplicationBasic::Attributes::AllowedVendorList::TypeInfo::DecodableArgType>
+ successFn,
+ chip::Controller::ReadResponseFailureCallback failureFn)
+{
+ ReturnErrorOnFailure(mAllowedVendorListReader.SetTarget(mActiveTargetVideoPlayerInfo, endpoint->GetEndpointId()));
+ return mAllowedVendorListReader.ReadAttribute(context, successFn, failureFn);
+}
+
/*
* @brief Channel cluster
*/
diff --git a/examples/tv-casting-app/tv-casting-common/src/PersistenceManager.cpp b/examples/tv-casting-app/tv-casting-common/src/PersistenceManager.cpp
index 0d71d28ca83a38..a57415d68c7582 100644
--- a/examples/tv-casting-app/tv-casting-common/src/PersistenceManager.cpp
+++ b/examples/tv-casting-app/tv-casting-common/src/PersistenceManager.cpp
@@ -71,7 +71,7 @@ CHIP_ERROR PersistenceManager::WriteAllVideoPlayers(TargetVideoPlayerInfo videoP
TLV::TLVType outerContainerType = TLV::kTLVType_Structure;
ReturnErrorOnFailure(tlvWriter.StartContainer(TLV::AnonymousTag(), TLV::kTLVType_Structure, outerContainerType));
- ReturnErrorOnFailure(tlvWriter.Put(TLV::ContextTag(kCastingDataVersionTag), kCastingDataVersion));
+ ReturnErrorOnFailure(tlvWriter.Put(TLV::ContextTag(kCurrentCastingDataVersionTag), kCurrentCastingDataVersion));
TLV::TLVType videoPlayersContainerType = TLV::kTLVType_Array;
// Video Players container starts
@@ -92,6 +92,27 @@ CHIP_ERROR PersistenceManager::WriteAllVideoPlayers(TargetVideoPlayerInfo videoP
ReturnErrorOnFailure(tlvWriter.PutBytes(TLV::ContextTag(kVideoPlayerDeviceNameTag),
(const uint8_t *) videoPlayer->GetDeviceName(),
static_cast(strlen(videoPlayer->GetDeviceName()) + 1)));
+ ReturnErrorOnFailure(
+ tlvWriter.Put(TLV::ContextTag(kVideoPlayerNumIPsTag), static_cast(videoPlayer->GetNumIPs())));
+ const Inet::IPAddress * ipAddress = videoPlayer->GetIpAddresses();
+ if (ipAddress != nullptr && videoPlayer->GetNumIPs() > 0)
+ {
+ TLV::TLVType ipAddressesContainerType = TLV::kTLVType_Array;
+ // IP Addresses container starts
+ ReturnErrorOnFailure(tlvWriter.StartContainer(TLV::ContextTag(kIpAddressesContainerTag), TLV::kTLVType_Structure,
+ ipAddressesContainerType));
+ for (size_t i = 0; i < videoPlayer->GetNumIPs() && i < chip::Dnssd::CommonResolutionData::kMaxIPAddresses; i++)
+ {
+ char ipAddressStr[Inet::IPAddress::kMaxStringLength];
+ ipAddress[i].ToString(ipAddressStr, Inet::IPAddress::kMaxStringLength);
+ ReturnErrorOnFailure(tlvWriter.PutBytes(TLV::ContextTag(kVideoPlayerIPAddressTag),
+ (const uint8_t *) ipAddressStr,
+ static_cast(strlen(ipAddressStr) + 1)));
+ }
+ // IP Addresses container ends
+ ReturnErrorOnFailure(tlvWriter.EndContainer(ipAddressesContainerType));
+ }
+
TargetEndpointInfo * endpoints = videoPlayer->GetEndpoints();
if (endpoints != nullptr)
{
@@ -132,7 +153,7 @@ CHIP_ERROR PersistenceManager::WriteAllVideoPlayers(TargetVideoPlayerInfo videoP
ReturnErrorOnFailure(tlvWriter.Finalize());
ChipLogProgress(AppServer,
"PersistenceManager::WriteAllVideoPlayers TLV(CastingData).LengthWritten: %d bytes and version: %d",
- tlvWriter.GetLengthWritten(), kCastingDataVersion);
+ tlvWriter.GetLengthWritten(), kCurrentCastingDataVersion);
return chip::DeviceLayer::PersistedStorage::KeyValueStoreMgr().Put(kCastingDataKey, castingData,
tlvWriter.GetLengthWritten());
}
@@ -162,7 +183,7 @@ CHIP_ERROR PersistenceManager::ReadAllVideoPlayers(TargetVideoPlayerInfo outVide
ReturnErrorOnFailure(reader.Next());
TLV::Tag outerContainerTag = reader.GetTag();
uint8_t outerContainerTagTagNum = static_cast(TLV::TagNumFromTag(outerContainerTag));
- VerifyOrReturnError(outerContainerTagTagNum == kCastingDataVersionTag, CHIP_ERROR_INVALID_TLV_TAG);
+ VerifyOrReturnError(outerContainerTagTagNum == kCurrentCastingDataVersionTag, CHIP_ERROR_INVALID_TLV_TAG);
uint32_t version;
ReturnErrorOnFailure(reader.Get(version));
ChipLogProgress(AppServer, "PersistenceManager::ReadAllVideoPlayers TLV(CastingData) version: %d", version);
@@ -178,6 +199,8 @@ CHIP_ERROR PersistenceManager::ReadAllVideoPlayers(TargetVideoPlayerInfo outVide
uint16_t productId = 0;
uint16_t deviceType = 0;
char deviceName[chip::Dnssd::kMaxDeviceNameLen + 1] = {};
+ size_t numIPs = 0;
+ Inet::IPAddress ipAddress[chip::Dnssd::CommonResolutionData::kMaxIPAddresses];
CHIP_ERROR err;
while ((err = reader.Next()) == CHIP_NO_ERROR)
{
@@ -188,47 +211,91 @@ CHIP_ERROR PersistenceManager::ReadAllVideoPlayers(TargetVideoPlayerInfo outVide
return CHIP_ERROR_INVALID_TLV_TAG;
}
- uint8_t viewPlayersContainerTagNum = static_cast(TLV::TagNumFromTag(videoPlayersContainerTag));
- if (viewPlayersContainerTagNum == kNodeIdTag)
+ uint8_t videoPlayersContainerTagNum = static_cast(TLV::TagNumFromTag(videoPlayersContainerTag));
+ if (videoPlayersContainerTagNum == kNodeIdTag)
{
ReturnErrorOnFailure(reader.Get(nodeId));
continue;
}
- if (viewPlayersContainerTagNum == kFabricIndexTag)
+ if (videoPlayersContainerTagNum == kFabricIndexTag)
{
ReturnErrorOnFailure(reader.Get(fabricIndex));
continue;
}
- if (viewPlayersContainerTagNum == kVideoPlayerVendorIdTag)
+ if (videoPlayersContainerTagNum == kVideoPlayerVendorIdTag)
{
ReturnErrorOnFailure(reader.Get(vendorId));
continue;
}
- if (viewPlayersContainerTagNum == kVideoPlayerProductIdTag)
+ if (videoPlayersContainerTagNum == kVideoPlayerProductIdTag)
{
ReturnErrorOnFailure(reader.Get(productId));
continue;
}
- if (viewPlayersContainerTagNum == kVideoPlayerDeviceTypeIdTag)
+ if (videoPlayersContainerTagNum == kVideoPlayerDeviceTypeIdTag)
{
ReturnErrorOnFailure(reader.Get(deviceType));
continue;
}
- if (viewPlayersContainerTagNum == kVideoPlayerDeviceNameTag)
+ if (videoPlayersContainerTagNum == kVideoPlayerDeviceNameTag)
{
ReturnErrorOnFailure(reader.GetBytes(reinterpret_cast(deviceName), chip::Dnssd::kMaxDeviceNameLen + 1));
continue;
}
- if (viewPlayersContainerTagNum == kContentAppEndpointsContainerTag)
+ if (videoPlayersContainerTagNum == kVideoPlayerNumIPsTag)
+ {
+ ReturnErrorOnFailure(reader.Get(reinterpret_cast(numIPs)));
+ continue;
+ }
+
+ if (videoPlayersContainerTagNum == kIpAddressesContainerTag)
+ {
+ // Entering IP Addresses container
+ TLV::TLVType ipAddressesContainerType = TLV::kTLVType_Array;
+ ReturnErrorOnFailure(reader.EnterContainer(ipAddressesContainerType));
+
+ size_t ipCount = 0;
+ while ((err = reader.Next()) == CHIP_NO_ERROR)
+ {
+ TLV::Tag ipAddressesContainerTag = reader.GetTag();
+ if (!TLV::IsContextTag(ipAddressesContainerTag))
+ {
+ ChipLogError(AppServer, "Unexpected non-context TLV tag.");
+ return CHIP_ERROR_INVALID_TLV_TAG;
+ }
+
+ uint8_t ipAddressesContainerTagNum = static_cast(TLV::TagNumFromTag(ipAddressesContainerTag));
+ if (ipAddressesContainerTagNum == kVideoPlayerIPAddressTag)
+ {
+ char ipAddressStr[Inet::IPAddress::kMaxStringLength];
+ ReturnErrorOnFailure(
+ reader.GetBytes(reinterpret_cast(ipAddressStr), Inet::IPAddress::kMaxStringLength));
+
+ Inet::IPAddress addressInet;
+ VerifyOrReturnError(Inet::IPAddress::FromString(ipAddressStr, addressInet), CHIP_ERROR_INVALID_TLV_ELEMENT);
+ ipAddress[ipCount] = addressInet;
+ ipCount++;
+ continue;
+ }
+ }
+ if (err == CHIP_END_OF_TLV)
+ {
+ // Exiting IP Addresses container
+ ReturnErrorOnFailure(reader.ExitContainer(ipAddressesContainerType));
+ continue;
+ }
+ }
+
+ if (videoPlayersContainerTagNum == kContentAppEndpointsContainerTag)
{
outVideoPlayers[videoPlayerIndex].Initialize(nodeId, fabricIndex, nullptr, nullptr, vendorId, productId, deviceType,
- deviceName);
+ deviceName, numIPs, ipAddress);
// Entering Content App Endpoints container
TLV::TLVType contentAppEndpointArrayContainerType = TLV::kTLVType_Array;
ReturnErrorOnFailure(reader.EnterContainer(contentAppEndpointArrayContainerType));
diff --git a/examples/tv-casting-app/tv-casting-common/src/TargetVideoPlayerInfo.cpp b/examples/tv-casting-app/tv-casting-common/src/TargetVideoPlayerInfo.cpp
index ff85e20eaaa0dd..70609f328fc5ef 100644
--- a/examples/tv-casting-app/tv-casting-common/src/TargetVideoPlayerInfo.cpp
+++ b/examples/tv-casting-app/tv-casting-common/src/TargetVideoPlayerInfo.cpp
@@ -24,7 +24,8 @@ CASEClientPool gCASEClientPool;
CHIP_ERROR TargetVideoPlayerInfo::Initialize(NodeId nodeId, FabricIndex fabricIndex,
std::function onConnectionSuccess,
std::function onConnectionFailure, uint16_t vendorId,
- uint16_t productId, uint16_t deviceType, const char * deviceName)
+ uint16_t productId, uint16_t deviceType, const char * deviceName, size_t numIPs,
+ chip::Inet::IPAddress * ipAddress)
{
ChipLogProgress(NotSpecified, "TargetVideoPlayerInfo nodeId=0x" ChipLogFormatX64 " fabricIndex=%d", ChipLogValueX64(nodeId),
fabricIndex);
@@ -33,6 +34,12 @@ CHIP_ERROR TargetVideoPlayerInfo::Initialize(NodeId nodeId, FabricIndex fabricIn
mVendorId = vendorId;
mProductId = productId;
mDeviceType = deviceType;
+ mNumIPs = numIPs;
+ for (size_t i = 0; i < numIPs && i < chip::Dnssd::CommonResolutionData::kMaxIPAddresses; i++)
+ {
+ mIpAddress[i] = ipAddress[i];
+ }
+
chip::Platform::CopyString(mDeviceName, chip::Dnssd::kMaxDeviceNameLen + 1, deviceName);
for (auto & endpointInfo : mEndpoints)
{
@@ -118,3 +125,47 @@ void TargetVideoPlayerInfo::PrintInfo()
}
}
}
+
+bool TargetVideoPlayerInfo::IsSameAs(const chip::Dnssd::DiscoveredNodeData * discoveredNodeData)
+{
+ // return false because 'this' VideoPlayer is not null
+ if (discoveredNodeData == nullptr)
+ {
+ return false;
+ }
+
+ // return false because deviceNames are different
+ if (strcmp(mDeviceName, discoveredNodeData->commissionData.deviceName) != 0)
+ {
+ return false;
+ }
+
+ // return false because not even a single IP Address matches
+ if (mNumIPs > 0)
+ {
+ bool matchFound = false;
+ for (size_t i = 0; i < mNumIPs && i < chip::Dnssd::CommonResolutionData::kMaxIPAddresses; i++)
+ {
+ for (size_t j = 0;
+ j < discoveredNodeData->resolutionData.numIPs && j < chip::Dnssd::CommonResolutionData::kMaxIPAddresses; j++)
+ {
+ if (mIpAddress[i] == discoveredNodeData->resolutionData.ipAddress[j])
+ {
+ matchFound = true;
+ break;
+ }
+ }
+ if (matchFound)
+ {
+ break;
+ }
+ }
+
+ if (!matchFound)
+ {
+ return false;
+ }
+ }
+
+ return true;
+}
diff --git a/integrations/cloudbuild/build-all.yaml b/integrations/cloudbuild/build-all.yaml
index 40ecf820ee845c..0071bcb413d320 100644
--- a/integrations/cloudbuild/build-all.yaml
+++ b/integrations/cloudbuild/build-all.yaml
@@ -34,8 +34,8 @@ steps:
--target android-arm64-tv-casting-app
--target android-arm64-tv-server
--target android-x64-chip-tool
- --target bl602-light
- --target bouffalolab-BL706-IoT-DVK-light-rpc
+ --target bouffalolab-bl602-iot-matter-v1-light
+ --target bouffalolab-xt-zb6-devkit-light-rpc
--target cc13x2x7_26x2x7-lock-ftd
--target cc13x2x7_26x2x7-lock-mtd
--target cc13x2x7_26x2x7-shell
@@ -74,6 +74,14 @@ steps:
--target k32w-light-no-ota
--target k32w-lock
--target k32w-shell
+ build
+ --create-archives /workspace/artifacts/
+ - name: "connectedhomeip/chip-build-vscode:0.6.03"
+ env:
+ - PW_ENVIRONMENT_ROOT=/pwenv
+ args:
+ - >-
+ ./scripts/build/build_examples.py --enable-flashbundle
--target linux-arm64-all-clusters-clang
--target linux-arm64-all-clusters-app-nodeps
--target linux-arm64-all-clusters-app-nodeps-ipv6only
diff --git a/integrations/docker/images/chip-build-nrf-platform/Dockerfile b/integrations/docker/images/chip-build-nrf-platform/Dockerfile
index 280534cac6c9fe..4e8d66447c3a98 100644
--- a/integrations/docker/images/chip-build-nrf-platform/Dockerfile
+++ b/integrations/docker/images/chip-build-nrf-platform/Dockerfile
@@ -2,7 +2,7 @@ ARG VERSION=latest
FROM connectedhomeip/chip-build:${VERSION} as build
# Compatible Nordic Connect SDK revision.
-ARG NCS_REVISION=v2.0.2
+ARG NCS_REVISION=v2.1.1
RUN set -x \
&& apt-get update \
diff --git a/integrations/docker/images/chip-build-openiotsdk/Dockerfile b/integrations/docker/images/chip-build-openiotsdk/Dockerfile
new file mode 100644
index 00000000000000..d3daf90439b5d3
--- /dev/null
+++ b/integrations/docker/images/chip-build-openiotsdk/Dockerfile
@@ -0,0 +1,52 @@
+ARG VERSION=latest
+FROM connectedhomeip/chip-build:${VERSION} as build
+
+RUN set -x \
+ && apt-get update \
+ && DEBIAN_FRONTEND=noninteractive apt-get install -fy --no-install-recommends \
+ wget=1.20.3-1ubuntu2 \
+ && apt-get clean \
+ && rm -rf /var/lib/apt/lists/ \
+ && : # last line
+
+SHELL ["/bin/bash", "-o", "pipefail", "-c"]
+
+# ------------------------------------------------------------------------------
+# Download ARM GCC toolchain 10.3-2021.10
+RUN set -x \
+ && wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 \
+ && tar -xjf gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 -C /opt \
+ && rm -r gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 \
+ && : # last line
+
+# ------------------------------------------------------------------------------
+# Install FVP Corstone 300
+RUN set -x \
+ && wget -q https://developer.arm.com/-/media/Arm%20Developer%20Community/Downloads/OSS/FVP/Corstone-300/FVP_Corstone_SSE-300_11.16_26.tgz \
+ && tar -xzf FVP_Corstone_SSE-300_11.16_26.tgz \
+ && ./FVP_Corstone_SSE-300.sh --i-agree-to-the-contained-eula -d /opt/FVP_Corstone_SSE-300 -f --no-interactive \
+ && rm -r FVP_Corstone_SSE-300_11.16_26.tgz FVP_Corstone_SSE-300.sh license_terms \
+ && : # last line
+
+FROM connectedhomeip/chip-build:${VERSION}
+
+COPY --from=build /opt/gcc-arm-none-eabi-10.3-2021.10/ /opt/gcc-arm-none-eabi-10.3-2021.10/
+COPY --from=build /opt/FVP_Corstone_SSE-300/ /opt/FVP_Corstone_SSE-300/
+
+# Required packages for building, running and testing
+RUN set -x \
+ && apt-get update \
+ && DEBIAN_FRONTEND=noninteractive apt-get install -fy \
+ expect \
+ telnet \
+ srecord \
+ && apt-get clean \
+ && rm -rf /var/lib/apt/lists/ \
+ && : # last line
+
+# ------------------------------------------------------------------------------
+# Configure environment variables
+ENV FVP_CORSTONE_300_PATH=/opt/FVP_Corstone_SSE-300
+ENV ARM_GCC_TOOLCHAIN_PATH=/opt/gcc-arm-none-eabi-10.3-2021.10
+
+ENV PATH="${PATH}:${FVP_CORSTONE_300_PATH}/models/Linux64_GCC-6.4:${ARM_GCC_TOOLCHAIN_PATH}/bin"
diff --git a/integrations/docker/images/chip-build-openiotsdk/build.sh b/integrations/docker/images/chip-build-openiotsdk/build.sh
new file mode 120000
index 00000000000000..fcb4d4ee75d531
--- /dev/null
+++ b/integrations/docker/images/chip-build-openiotsdk/build.sh
@@ -0,0 +1 @@
+../../build.sh
\ No newline at end of file
diff --git a/integrations/docker/images/chip-build-openiotsdk/run.sh b/integrations/docker/images/chip-build-openiotsdk/run.sh
new file mode 120000
index 00000000000000..ccbd3501b330d9
--- /dev/null
+++ b/integrations/docker/images/chip-build-openiotsdk/run.sh
@@ -0,0 +1 @@
+../../run.sh
\ No newline at end of file
diff --git a/integrations/docker/images/chip-build-openiotsdk/version b/integrations/docker/images/chip-build-openiotsdk/version
new file mode 120000
index 00000000000000..a4280acd348e7f
--- /dev/null
+++ b/integrations/docker/images/chip-build-openiotsdk/version
@@ -0,0 +1 @@
+../chip-build/version
\ No newline at end of file
diff --git a/integrations/docker/images/chip-build-vscode/Dockerfile b/integrations/docker/images/chip-build-vscode/Dockerfile
index 669d00f80138f1..d3c4dc78efe992 100644
--- a/integrations/docker/images/chip-build-vscode/Dockerfile
+++ b/integrations/docker/images/chip-build-vscode/Dockerfile
@@ -12,6 +12,7 @@ FROM connectedhomeip/chip-build-ameba:${VERSION} AS ameba
FROM connectedhomeip/chip-build-k32w:${VERSION} AS k32w
FROM connectedhomeip/chip-build-imx:${VERSION} AS imx
FROM connectedhomeip/chip-build-ti:${VERSION} AS ti
+FROM connectedhomeip/chip-build-openiotsdk:${VERSION} AS openiotsdk
FROM connectedhomeip/chip-build-zap:${VERSION} AS zap
FROM connectedhomeip/chip-build:${VERSION}
@@ -47,6 +48,9 @@ COPY --from=imx /opt/fsl-imx-xwayland /opt/fsl-imx-xwayland
COPY --from=ti /opt/ti/sysconfig_1.13.0 /opt/ti/sysconfig_1.13.0
+COPY --from=openiotsdk /opt/gcc-arm-none-eabi-10.3-2021.10/ /opt/gcc-arm-none-eabi-10.3-2021.10/
+COPY --from=openiotsdk /opt/FVP_Corstone_SSE-300/ /opt/FVP_Corstone_SSE-300/
+
COPY --from=zap /opt/zap /opt/zap
# Android license file "acceping" is done by writing license hashes
@@ -66,6 +70,17 @@ RUN set -x \
&& rm -rf /var/lib/apt/lists/* \
&& : # last line
+# Required for the Open IoT SDK platform
+RUN set -x \
+ && apt-get update \
+ && DEBIAN_FRONTEND=noninteractive apt-get install -fy \
+ expect \
+ telnet \
+ srecord \
+ && apt-get clean \
+ && rm -rf /var/lib/apt/lists/ \
+ && : # last line
+
# Required for the Bouffalolab platform
RUN set -x \
&& pip3 install bflb-iot-tool \
@@ -95,3 +110,6 @@ ENV ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb
ENV TIZEN_VERSION 6.0
ENV TIZEN_SDK_ROOT /opt/tizen-sdk
ENV TIZEN_SDK_SYSROOT $TIZEN_SDK_ROOT/platforms/tizen-$TIZEN_VERSION/mobile/rootstraps/mobile-$TIZEN_VERSION-device.core
+
+ENV FVP_CORSTONE_300_PATH=/opt/FVP_Corstone_SSE-300
+ENV ARM_GCC_TOOLCHAIN_PATH=/opt/gcc-arm-none-eabi-10.3-2021.10
diff --git a/integrations/docker/images/chip-build/Dockerfile b/integrations/docker/images/chip-build/Dockerfile
index 861f5ecb2df4e7..782aa74f64afea 100644
--- a/integrations/docker/images/chip-build/Dockerfile
+++ b/integrations/docker/images/chip-build/Dockerfile
@@ -69,12 +69,12 @@ RUN set -x \
&& git lfs install \
&& : # last line
-# Cmake (Mbed OS requires >=3.19.0-rc3 version which is not available in Ubuntu 20.04 repository)
+# Cmake v3.23.1
RUN set -x \
&& (cd /tmp \
- && wget --progress=dot:giga https://github.com/Kitware/CMake/releases/download/v3.19.3/cmake-3.19.3-Linux-x86_64.sh \
- && sh cmake-3.19.3-Linux-x86_64.sh --exclude-subdir --prefix=/usr/local \
- && rm -rf cmake-3.19.3-Linux-x86_64.sh) \
+ && wget --progress=dot:giga https://github.com/Kitware/CMake/releases/download/v3.23.1/cmake-3.23.1-Linux-x86_64.sh \
+ && sh cmake-3.23.1-Linux-x86_64.sh --exclude-subdir --prefix=/usr/local \
+ && rm -rf cmake-3.23.1-Linux-x86_64.sh) \
&& exec bash \
&& : # last line
diff --git a/integrations/docker/images/chip-build/version b/integrations/docker/images/chip-build/version
index b288fd5e8ac786..a7be338c347fae 100644
--- a/integrations/docker/images/chip-build/version
+++ b/integrations/docker/images/chip-build/version
@@ -1 +1 @@
-0.6.03 Version bump reason: [Ameba] Replace C2 notify with indicate as required by Matter spec
+0.6.05 Version bump reason: [nrfconnect] Update nRF Connect SDK version.
diff --git a/scripts/build/BUILD.gn b/scripts/build/BUILD.gn
index 9ea50936d5382a..60356666c0f6ae 100644
--- a/scripts/build/BUILD.gn
+++ b/scripts/build/BUILD.gn
@@ -41,7 +41,6 @@ pw_python_package("build_examples") {
"builders/__init__.py",
"builders/ameba.py",
"builders/android.py",
- "builders/bl602.py",
"builders/bouffalolab.py",
"builders/builder.py",
"builders/efr32.py",
diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py
index cd5c8cd87ceaa4..71440e607c8c97 100755
--- a/scripts/build/build/targets.py
+++ b/scripts/build/build/targets.py
@@ -34,7 +34,6 @@
from builders.qpg import QpgApp, QpgBoard, QpgBuilder
from builders.telink import TelinkApp, TelinkBoard, TelinkBuilder
from builders.tizen import TizenApp, TizenBoard, TizenBuilder
-from builders.bl602 import Bl602App, Bl602Board, Bl602Builder
from builders.bouffalolab import BouffalolabApp, BouffalolabBoard, BouffalolabBuilder
from builders.imx import IMXApp, IMXBuilder
from builders.genio import GenioApp, GenioBuilder
@@ -442,21 +441,15 @@ def BuildTizenTarget():
return target
-def BuildBl602Target():
- target = BuildTarget('bl602', Bl602Builder)
-
- target.AppendFixedTargets([
- TargetPart('light', board=Bl602Board.BL602BOARD, app=Bl602App.LIGHT),
- ])
-
- return target
-
-
def BuildBouffalolabTarget():
target = BuildTarget('bouffalolab', BouffalolabBuilder)
# Boards
target.AppendFixedTargets([
+ TargetPart('BL602-IoT-Matter-V1', board=BouffalolabBoard.BL602_IoT_Matter_V1, module_type="BL602"),
+ TargetPart('BL602-IOT-DVK-3S', board=BouffalolabBoard.BL602_IOT_DVK_3S, module_type="BL602"),
+ TargetPart('BL602-NIGHT-LIGHT', board=BouffalolabBoard.BL602_NIGHT_LIGHT, module_type="BL602"),
+ TargetPart('XT-ZB6-DevKit', board=BouffalolabBoard.BL706_IoT_DVK, module_type="BL706C-22"),
TargetPart('BL706-IoT-DVK', board=BouffalolabBoard.BL706_IoT_DVK, module_type="BL706C-22"),
TargetPart('BL706-NIGHT-LIGHT', board=BouffalolabBoard.BL706_NIGHT_LIGHT, module_type="BL702"),
])
@@ -466,6 +459,8 @@ def BuildBouffalolabTarget():
TargetPart('light', app=BouffalolabApp.LIGHT),
])
+ target.AppendModifier('shell', enable_shell=True)
+ target.AppendModifier('115200', baudrate=115200)
target.AppendModifier('rpc', enable_rpcs=True)
return target
@@ -516,7 +511,6 @@ def BuildTelinkTarget():
BUILD_TARGETS = [
BuildAmebaTarget(),
BuildAndroidTarget(),
- BuildBl602Target(),
BuildBouffalolabTarget(),
Buildcc13x2x7_26x2x7Target(),
BuildCyw30739Target(),
diff --git a/scripts/build/builders/bl602.py b/scripts/build/builders/bl602.py
deleted file mode 100644
index f8fd4cacf32a5f..00000000000000
--- a/scripts/build/builders/bl602.py
+++ /dev/null
@@ -1,89 +0,0 @@
-# Copyright (c) 2021 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.
-
-import os
-import platform
-from enum import Enum, auto
-
-from .gn import GnBuilder
-
-
-class Bl602App(Enum):
- LOCK = auto()
- LIGHT = auto()
- ALL_CLUSTERS = auto()
-
- def ExampleName(self):
- if self == Bl602App.LIGHT:
- return 'lighting-app'
- else:
- raise Exception('Unknown app type: %r' % self)
-
- def AppNamePrefix(self):
- if self == Bl602App.LIGHT:
- return 'chip-bl602-lighting-example'
- else:
- raise Exception('Unknown app type: %r' % self)
-
- def FlashBundleName(self):
- if self == Bl602App.LOCK:
- return 'lighting_app.flashbundle.txt'
- else:
- raise Exception('Unknown app type: %r' % self)
-
-
-class Bl602Board(Enum):
- BL602BOARD = 1
-
- def GnArgName(self):
- if self == Bl602Board.BL602BOARD:
- return 'BL-HWC-G1'
-
-
-class Bl602Builder(GnBuilder):
-
- def __init__(self,
- root,
- runner,
- app: Bl602App = Bl602App.LIGHT,
- board: Bl602Board = Bl602Board.BL602BOARD):
- super(Bl602Builder, self).__init__(
- root=os.path.join(root, 'examples',
- app.ExampleName(), 'bouffalolab', 'bl602'),
- runner=runner)
-
- self.argsOpt = []
-
- toolchain = os.path.join(root, '../../examples/platform/bouffalolab/common/toolchain')
- toolchain = 'custom_toolchain="{}:riscv_gcc"'.format(toolchain)
- if toolchain:
- self.argsOpt.append(toolchain)
-
- self.app = app
- self.board = board
-
- def GnBuildArgs(self):
- return self.argsOpt + ['bl602_board="%s"' % self.board.GnArgName()]
-
- def build_outputs(self):
- items = {
- '%s.out' % self.app.AppNamePrefix():
- os.path.join(self.output_dir, '%s.out' %
- self.app.AppNamePrefix()),
- '%s.out.map' % self.app.AppNamePrefix():
- os.path.join(self.output_dir,
- '%s.out.map' % self.app.AppNamePrefix()),
- }
-
- return items
diff --git a/scripts/build/builders/bouffalolab.py b/scripts/build/builders/bouffalolab.py
index b391251093653f..2137949a325ff2 100644
--- a/scripts/build/builders/bouffalolab.py
+++ b/scripts/build/builders/bouffalolab.py
@@ -42,11 +42,23 @@ def FlashBundleName(self):
class BouffalolabBoard(Enum):
- BL706_IoT_DVK = 1
- BL706_NIGHT_LIGHT = 2
+ BL602_IoT_Matter_V1 = auto()
+ BL602_IOT_DVK_3S = auto()
+ BL602_NIGHT_LIGHT = auto()
+ XT_ZB6_DevKit = auto()
+ BL706_IoT_DVK = auto()
+ BL706_NIGHT_LIGHT = auto()
def GnArgName(self):
- if self == BouffalolabBoard.BL706_IoT_DVK:
+ if self == BouffalolabBoard.BL602_IoT_Matter_V1:
+ return 'BL602-IoT-Matter-V1'
+ elif self == BouffalolabBoard.BL602_IOT_DVK_3S:
+ return 'BL602-IOT-DVK-3S'
+ elif self == BouffalolabBoard.BL602_NIGHT_LIGHT:
+ return 'BL602-NIGHT-LIGHT'
+ elif self == BouffalolabBoard.XT_ZB6_DevKit:
+ return 'XT-ZB6-DevKit'
+ elif self == BouffalolabBoard.BL706_IoT_DVK:
return 'BL706-IoT-DVK'
elif self == BouffalolabBoard.BL706_NIGHT_LIGHT:
return 'BL706-NIGHT-LIGHT'
@@ -63,6 +75,8 @@ def __init__(self,
board: BouffalolabBoard = BouffalolabBoard.BL706_IoT_DVK,
enable_rpcs: bool = False,
module_type: str = "BL706C-22",
+ baudrate=2000000,
+ enable_shell: bool = False
):
bouffalo_chip = "bl702" if "BL70" in module_type else "bl602"
@@ -83,7 +97,12 @@ def __init__(self,
self.board = board
self.argsOpt.append('board=\"{}\"'.format(self.board.GnArgName()))
- self.argsOpt.append('module_type=\"{}\"'.format(module_type))
+ self.argsOpt.append('baudrate=\"{}\"'.format(baudrate))
+
+ if bouffalo_chip == "bl702":
+ self.argsOpt.append('module_type=\"{}\"'.format(module_type))
+ if enable_shell and not enable_rpcs:
+ self.argsOpt.append('chip_build_libshell=true')
if enable_rpcs:
self.argsOpt.append('import("//with_pw_rpc.gni")')
diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt
index 8073f89ff0dfa6..90c216a9afb0f9 100644
--- a/scripts/build/testdata/all_targets_linux_x64.txt
+++ b/scripts/build/testdata/all_targets_linux_x64.txt
@@ -1,7 +1,6 @@
ameba-amebad-{all-clusters,all-clusters-minimal,light,pigweed}
android-{arm,arm64,x86,x64,androidstudio-arm,androidstudio-arm64,androidstudio-x86,androidstudio-x64}-{chip-tool,chip-test,tv-server,tv-casting-app,java-matter-controller}
-bl602-light
-bouffalolab-{bl706-iot-dvk,bl706-night-light}-light[-rpc]
+bouffalolab-{bl602-iot-matter-v1,bl602-iot-dvk-3s,bl602-night-light,xt-zb6-devkit,bl706-iot-dvk,bl706-night-light}-light[-shell][-115200][-rpc]
cc13x2x7_26x2x7-{all-clusters,all-clusters-minimal,lock,pump,pump-controller,shell}[-ftd][-mtd]
cyw30739-cyw930739m2evb_01-{light,lock,ota-requestor}[-no-progress-logging]
efr32-{brd4161a,brd4187c,brd4163a,brd4164a,brd4166a,brd4170a,brd4186a,brd4187a,brd4304a}-{window-covering,switch,unit-test,light,lock}[-rpc][-with-ota-requestor]
diff --git a/scripts/checkout_submodules.py b/scripts/checkout_submodules.py
index ebea028957dfcf..c5967949b9cd3a 100755
--- a/scripts/checkout_submodules.py
+++ b/scripts/checkout_submodules.py
@@ -45,6 +45,7 @@
'webos',
'mw320',
'genio',
+ 'openiotsdk',
])
Module = namedtuple('Module', 'name path platforms')
diff --git a/scripts/constraints.txt b/scripts/constraints.txt
index f29bbc7d5a4337..de47efb650bebd 100644
--- a/scripts/constraints.txt
+++ b/scripts/constraints.txt
@@ -234,7 +234,14 @@ pyserial==3.5
# mbed-tools
# mobly
pytest==6.2.5 ; platform_machine != "aarch64" and sys_platform == "linux"
- # via -r requirements.mbed.txt
+ # via
+ # -r requirements.mbed.txt
+ # pytest-json-report
+ # pytest-metadata
+pytest-json-report==1.5.0
+ # via -r requirements.openiotsdk.txt
+pytest-metadata==2.0.2
+ # via pytest-json-report
python-dateutil==2.8.1
# via
# pandas
diff --git a/scripts/examples/gn_bl602_example.sh b/scripts/examples/gn_bl602_example.sh
deleted file mode 100755
index 9ae95a0a960d2d..00000000000000
--- a/scripts/examples/gn_bl602_example.sh
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/usr/bin/env bash
-
-#
-# Copyright (c) 2021 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.
-#
-
-set -e
-
-BL602_BOARD=BL-HWC-G1
-
-# Build script for GN examples GitHub workflow.
-
-MATTER_ROOT=$(dirname "$(readlink -f "$0")")/../../
-
-source "$(dirname "$0")/../../scripts/activate.sh"
-
-USAGE="./scripts/examples/gn_bl602_example.sh example_dir output_dir"
-
-if [ $# -lt 2 ]; then
- echo "Usage: $USAGE"
- exit 1
-fi
-
-EXAMPLE_DIR=examples/$1/bouffalolab/bl602/
-shift
-OUTPUT_DIR=$1
-shift
-
-GN_ARGS=()
-
-NINJA_ARGS=()
-
-for arg; do
- case $arg in
- -v)
- NINJA_ARGS+=(-v)
- ;;
- *=*)
- GN_ARGS+=("$arg")
- ;;
- *import*)
- GN_ARGS+=("$arg")
- ;;
- *)
- echo >&2 "invalid argument: $arg"
- exit 2
- ;;
- esac
-done
-
-gn gen --fail-on-unused-args --root="$EXAMPLE_DIR" "$OUTPUT_DIR" --args="${GN_ARGS[*]} custom_toolchain=\"$MATTER_ROOT/examples/platform/bouffalolab/common/toolchain:riscv_gcc\""
-
-ninja -C "$OUTPUT_DIR" "${NINJA_ARGS[@]}"
diff --git a/scripts/examples/gn_bouffalolab_example.sh b/scripts/examples/gn_bouffalolab_example.sh
index f04307607ba30b..a719563f38cb03 100755
--- a/scripts/examples/gn_bouffalolab_example.sh
+++ b/scripts/examples/gn_bouffalolab_example.sh
@@ -23,29 +23,23 @@ set -e
MATTER_ROOT=$(dirname "$(readlink -f "$0")")/../../
source "$MATTER_ROOT/scripts/activate.sh"
-# export BL_IOT_SDK_PATH=$MATTER_ROOT/third_party/bouffalolab/repo
+bl602_boards=("BL602-IoT-Matter-V1" "BL602-NIGHT-LIGHT")
+bl602_module_type="BL602"
-# if [[ "$OSTYPE" == "linux-gnu"* ]]; then
-# export PATH="$BL_IOT_SDK_PATH/toolchain/riscv/Linux/bin:$PATH"
-# elif [[ "$OSTYPE" == "darwin"* ]]; then
-# export PATH="$BL_IOT_SDK_PATH/toolchain/riscv/Darwin/bin:$PATH"
-# fi
-
-bl702_boards=("BL706-IoT-DVK" "BL706-NIGHT-LIGHT")
+bl702_boards=("XT-ZB6-DevKit" "BL706-IoT-DVK" "BL706-NIGHT-LIGHT")
bl702_modules=("BL702" "BL706C-22")
bl702_module_type="BL706C-22"
print_help() {
+ bl602_boards_help=""
+ for board in "${bl602_boards[@]}"; do
+ bl602_boards_help=$bl602_boards_help$board"\n "
+ done
bl702_boards_help=""
for board in "${bl702_boards[@]}"; do
bl702_boards_help=$bl702_boards_help$board"\n "
done
- bl702_modules_help=""
- for module in "${bl702_modules[@]}"; do
- bl702_modules_help=$bl702_modules_help$module"\n "
- done
-
echo -e "Build script for Bouffalolab Matter examples
Format:
./scripts/examples/gn_bouffalolab_example.sh