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