@@ -688,15 +688,16 @@ func startDiscovery() {
688
688
}
689
689
```
690
690
691
- Note : You will need to connect with a Casting Player as described below to see
691
+ Note : You will need to connect with a Casting Player as described below to se
692
692
the list of Endpoints that they support. Refer to the
693
693
[Connection ](#connect- to- a- casting- player) section for details on how to
694
694
discover available endpoints supported by a Casting Player .
695
695
696
696
### Connect to a Casting Player
697
697
698
698
_{Complete Connection examples: [Linux ](linux/ simple- app- helper. cpp) |
699
- [iOS](darwin/ TvCasting / TvCasting / MCConnectionExampleViewModel . swift)}_
699
+ [Android ](android/ App / app/ src/ main/ java/ com/ matter/ casting/ ConnectionExampleFragment . java)
700
+ | [iOS](darwin/ TvCasting / TvCasting / MCConnectionExampleViewModel . swift)}_
700
701
701
702
Each `CastingPlayer ` object created during
702
703
[Discovery ](#discover- casting- players) contains information such as
@@ -830,7 +831,7 @@ func connect(selectedCastingPlayer: MCCastingPlayer?) {
830
831
### Select an Endpoint on the Casting Player
831
832
832
833
_{Complete Endpoint selection examples: [Linux](linux/simple-app-helper.cpp) |
833
- [Android](android/App/app/src/main/java/com/matter/casting/ContentLauncherLaunchURLExampleFragment .java)
834
+ [Android](android/App/app/src/main/java/com/matter/casting/EndpointSelectorExample .java)
834
835
|
835
836
[iOS](darwin/TvCasting/TvCasting/MCContentLauncherLaunchURLExampleViewModel.swift)}_
836
837
@@ -863,7 +864,7 @@ On Android, it can select an `Endpoint` as shown below.
863
864
```java
864
865
private static final Integer SAMPLE_ENDPOINT_VID = 65521;
865
866
866
- private Endpoint selectEndpoint ()
867
+ private Endpoint selectFirstEndpointByVID ()
867
868
{
868
869
Endpoint endpoint = null;
869
870
if(selectedCastingPlayer != null)
@@ -905,18 +906,25 @@ Once the Casting Client has selected an `Endpoint`, it is ready to
905
906
[issue commands](#issuing-commands) to it, [read](#read-operations) current
906
907
playback state, and [subscribe](#subscriptions) to playback events.
907
908
908
- On Linux refer to the following platform specific files:
909
+ Refer to the following platform specific files, to find the list of clusters,
910
+ commands and attributes, with their request/response types available for use
911
+ with the Matter TV Casting library.
912
+
913
+ For Linux, refer to the following files:
909
914
910
- 1. For a list of clusters, commands and attributes supported by the Matter TV
911
- Casting library:
915
+ 1. For a list of supported clusters, commands and attributes:
912
916
[tv-casting-common/clusters/Clusters.h](tv-casting-common/clusters/Clusters.h)
913
917
2. For the IDs and request / response types to use with these APIs:
914
918
[/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h](/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h)
915
919
916
- On iOS refer to the following platform specific files:
920
+ For Android, refer to the following files:
921
+
922
+ 1. For a list of supported clusters, commands and attributes:
923
+ [/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java](/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java)
917
924
918
- 1. For a list of clusters, commands and attributes supported by the Matter TV
919
- Casting library:
925
+ On iOS, refer to the following files:
926
+
927
+ 1. For a list of supported clusters, commands and attribute:
920
928
[darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCClusterObjects.h](darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCClusterObjects.h)
921
929
2. For the IDs and request / response types to use with the commands:
922
930
[darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCCommandObjects.h](darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCCommandObjects.h)
@@ -929,6 +937,8 @@ On iOS refer to the following platform specific files:
929
937
### Issuing Commands
930
938
931
939
_{Complete Command invocation examples: [Linux](linux/simple-app-helper.cpp) |
940
+ [Android](android/App/app/src/main/java/com/matter/casting/ContentLauncherLaunchURLExampleFragment.java)
941
+ |
932
942
[iOS](darwin/TvCasting/TvCasting/MCContentLauncherLaunchURLExampleViewModel.swift)}_
933
943
934
944
The Casting Client can get a reference to an `Endpoint` on a `CastingPlayer`,
@@ -975,6 +985,51 @@ void InvokeContentLauncherLaunchURL(matter::casting::memory::Strong<matter::cast
975
985
}
976
986
```
977
987
988
+ On Android, given an `Endpoint`, it can send a `LaunchURL` command (part of the
989
+ Content Launcher cluster) by calling the `launchURL` API on a
990
+ `ChipClusters.ContentLauncherCluster` object.
991
+
992
+ ```java
993
+ // get ChipClusters.ContentLauncherCluster from the endpoint
994
+ ChipClusters.ContentLauncherCluster cluster =
995
+ endpoint.getCluster(ChipClusters.ContentLauncherCluster.class);
996
+ if (cluster == null) {
997
+ Log.e(TAG, "Could not get ContentLauncherCluster for endpoint with ID: " + endpoint.getId());
998
+ return;
999
+ }
1000
+
1001
+ // call launchURL on the cluster object while passing in a
1002
+ // ChipClusters.ContentLauncherCluster.LauncherResponseCallback and request parameters
1003
+ cluster.launchURL(
1004
+ new ChipClusters.ContentLauncherCluster.LauncherResponseCallback() {
1005
+ @Override
1006
+ public void onSuccess(Integer status, Optional<String> data) {
1007
+ Log.d(TAG, "LaunchURL success. Status: " + status + ", Data: " + data);
1008
+ new Handler(Looper.getMainLooper())
1009
+ .post(
1010
+ () -> {
1011
+ TextView launcherResult = getView().findViewById(R.id.launcherResult);
1012
+ launcherResult.setText(
1013
+ "LaunchURL result\n Status: " + status + ", Data: " + data);
1014
+ });
1015
+ }
1016
+
1017
+ @Override
1018
+ public void onError(Exception error) {
1019
+ Log.e(TAG, "LaunchURL failure " + error);
1020
+ new Handler(Looper.getMainLooper())
1021
+ .post(
1022
+ () -> {
1023
+ TextView launcherResult = getView().findViewById(R.id.launcherResult);
1024
+ launcherResult.setText("LaunchURL result\n Error: " + error);
1025
+ });
1026
+ }
1027
+ },
1028
+ contentUrl,
1029
+ Optional.of(contentDisplayString),
1030
+ Optional.empty());
1031
+ ```
1032
+
978
1033
On iOS, given an `MCEndpoint` endpoint, it can send a `LaunchURL` command (part
979
1034
of the Content Launcher cluster) by calling the `invoke` API on a
980
1035
`MCContentLauncherClusterLaunchURLCommand`
@@ -1033,6 +1088,8 @@ timedInvokeTimeoutMs: 5000) // time out after 5000ms
1033
1088
### Read Operations
1034
1089
1035
1090
_{Complete Attribute Read examples: [Linux](linux/simple-app-helper.cpp) |
1091
+ [Android](android/App/app/src/main/java/com/matter/casting/ApplicationBasicReadVendorIDExampleFragment.java)
1092
+ |
1036
1093
[iOS](darwin/TvCasting/TvCasting/MCApplicationBasicReadVendorIDExampleViewModel.swift)}_
1037
1094
1038
1095
The `CastingClient` may read an Attribute from the `Endpoint` on the
@@ -1080,6 +1137,45 @@ void ReadApplicationBasicVendorID(matter::casting::memory::Strong<matter::castin
1080
1137
}
1081
1138
```
1082
1139
1140
+ On Android, given an `Endpoint`, the `VendorID` can be read, by calling
1141
+ `readVendorIDAttribute` on the `ChipClusters.ApplicationBasicCluster` object.
1142
+
1143
+ ```java
1144
+ // get ChipClusters.ApplicationBasic from the endpoint
1145
+ ChipClusters.ApplicationBasicCluster cluster = endpoint.getCluster(ChipClusters.ApplicationBasicCluster.class);
1146
+ if (cluster == null) {
1147
+ Log.e(TAG, "Could not get ApplicationBasicCluster for endpoint with ID: " + endpoint.getId());
1148
+ return;
1149
+ }
1150
+
1151
+ // call readVendorIDAttribute on the cluster object while passing in a
1152
+ // ChipClusters.IntegerAttributeCallback
1153
+ cluster.readVendorIDAttribute(new ChipClusters.IntegerAttributeCallback() {
1154
+ @Override
1155
+ public void onSuccess(int value) {
1156
+ Log.d(TAG, "ReadVendorID success. Value: " + value);
1157
+ new Handler(Looper.getMainLooper())
1158
+ .post(
1159
+ () -> {
1160
+ TextView vendorIdResult = getView().findViewById(R.id.vendorIdResult);
1161
+ vendorIdResult.setText(
1162
+ "Read VendorID result\n Value: " + value );
1163
+ });
1164
+ }
1165
+
1166
+ @Override
1167
+ public void onError(Exception error) {
1168
+ Log.e(TAG, "ReadVendorID failure " + error);
1169
+ new Handler(Looper.getMainLooper())
1170
+ .post(
1171
+ () -> {
1172
+ TextView vendorIdResult = getView().findViewById(R.id.vendorIdResult);
1173
+ vendorIdResult.setText("Read VendorID result\n Error: " + error);
1174
+ });
1175
+ }
1176
+ });
1177
+ ```
1178
+
1083
1179
On iOS, given a `MCEndpoint`, the `VendorID` can be read similarly, by calling
1084
1180
the `read` API on the `MCApplicationBasicClusterVendorIDAttribute`
1085
1181
@@ -1138,6 +1234,9 @@ vendorIDAttribute!.read(nil) { context, before, after, err in
1138
1234
### Subscriptions
1139
1235
1140
1236
_{Complete Attribute subscription examples: [Linux](linux/simple-app-helper.cpp)
1237
+ |
1238
+ [Android](android/App/app/src/main/java/com/matter/casting/MediaPlaybackSubscribeToCurrentStateExampleFragment.java)
1239
+ |
1141
1240
|[iOS](darwin/TvCasting/TvCasting/MCMediaPlaybackSubscribeToCurrentStateExampleViewModel.swift)}_
1142
1241
1143
1242
A Casting Client may subscribe to an attribute on an `Endpoint` of the
@@ -1187,6 +1286,49 @@ void SubscribeToMediaPlaybackCurrentState(matter::casting::memory::Strong<matter
1187
1286
}
1188
1287
```
1189
1288
1289
+ On Android, given an `Endpoint`, `CurrentState` can be subscribe to by calling
1290
+ `subscribeCurrentStateAttribute` on a `ChipClusters.MediaPlaybackCluster`
1291
+ object.
1292
+
1293
+ ```java
1294
+ // get ChipClusters.MediaPlaybackCluster from the endpoint
1295
+ ChipClusters.MediaPlaybackCluster cluster =
1296
+ endpoint.getCluster(ChipClusters.MediaPlaybackCluster.class);
1297
+ if (cluster == null) {
1298
+ Log.e(
1299
+ TAG,
1300
+ "Could not get ApplicationBasicCluster for endpoint with ID: " + endpoint.getId());
1301
+ return;
1302
+ }
1303
+
1304
+ // call subscribeCurrentStateAttribute on the cluster object while passing in a
1305
+ // ChipClusters.IntegerAttributeCallback and [0, 1] for min and max interval params
1306
+ cluster.subscribeCurrentStateAttribute(new ChipClusters.IntegerAttributeCallback() {
1307
+ @Override
1308
+ public void onSuccess(int value) {
1309
+ Log.d(TAG, "Read success on subscription. Value: " + value + " @ " + new Date());
1310
+ new Handler(Looper.getMainLooper())
1311
+ .post(
1312
+ () -> {
1313
+ TextView currentStateResult = getView().findViewById(R.id.currentStateResult);
1314
+ currentStateResult.setText(
1315
+ "Current State result\n Value: " + value );
1316
+ });
1317
+ }
1318
+
1319
+ @Override
1320
+ public void onError(Exception error) {
1321
+ Log.e(TAG, "Read failure on subscription: " + error);
1322
+ new Handler(Looper.getMainLooper())
1323
+ .post(
1324
+ () -> {
1325
+ TextView currentStateResult = getView().findViewById(R.id.currentStateResult);
1326
+ currentStateResult.setText("Current State result\n Error: " + error);
1327
+ });
1328
+ }
1329
+ }, 0, 1);
1330
+ ```
1331
+
1190
1332
On iOS, given a `MCEndpoint`, `CurrentState` can be subscribed to by calling the
1191
1333
`subscribe` API on the it can subscribe to the `CurrentState` (part of the Media
1192
1334
Playback Basic cluster) by calling the `Subscribe` API on the
0 commit comments