@@ -69,6 +69,65 @@ class CastingPlayerAttributes
69
69
chip::FabricIndex fabricIndex = 0 ;
70
70
};
71
71
72
+ /* *
73
+ * This class contains the optional parameters used in the IdentificationDeclaration Message, sent by the Commissionee to the
74
+ * Commissioner. The options specify information relating to the requested UDC commissioning session.
75
+ */
76
+ class IdentificationDeclarationOptions
77
+ {
78
+ public:
79
+ constexpr static size_t kMaxTargetAppInfos = 10 ;
80
+ uint8_t mNumTargetAppInfos = 0 ; // The number of TargetAppInfos included.
81
+ /* *
82
+ * Feature: Target Content Application
83
+ * The set of content app Vendor IDs (and optionally, Product IDs) that can be used for authentication.
84
+ * Also, if TargetAppInfo is passed in, VerifyOrEstablishConnection() will force User Directed Commissioning, in case the
85
+ * desired TargetApp is not found in the on-device CastingStore.
86
+ */
87
+ chip::Protocols::UserDirectedCommissioning::TargetAppInfo mTargetAppInfos [kMaxTargetAppInfos ];
88
+
89
+ /* *
90
+ * Feature: Target Content Application
91
+ * Flag to instruct the Commissioner not to display a Passcode input dialog, and instead send a CommissionerDeclaration message
92
+ * if a commissioning Passcode is needed.
93
+ */
94
+ bool mNoPasscode = false ;
95
+ /* *
96
+ * Feature: Coordinate Passcode Dialogs
97
+ * Flag to instruct the Commissioner to send a CommissionerDeclaration message when the Passcode input dialog on the
98
+ * Commissioner has been shown to the user.
99
+ */
100
+ bool mCdUponPasscodeDialog = false ;
101
+ /* *
102
+ * Feature: Commissioner-Generated Passcode
103
+ * Flag to instruct the Commissioner to use the Commissioner-generated Passcode for commissioning.
104
+ */
105
+ bool mCommissionerPasscode = false ;
106
+ /* *
107
+ * Feature: Commissioner-Generated Passcode
108
+ * Flag to indicate whether or not the Commissionee has obtained the Commissioner Passcode from the user and is therefore ready
109
+ * for commissioning.
110
+ */
111
+ bool mCommissionerPasscodeReady = false ;
112
+ /* *
113
+ * Feature: Coordinate Passcode Dialogs
114
+ * Flag to indicate when the Commissionee user has decided to exit the commissioning process.
115
+ */
116
+ bool mCancelPasscode = false ;
117
+ };
118
+
119
+ // TODO: In the following PRs. This is work in progress. Break out to a seperate cpp file.
120
+ class CommissionerDeclarationHandler : public chip ::Protocols::UserDirectedCommissioning::CommissionerDeclarationHandler
121
+ {
122
+ public:
123
+ void OnCommissionerDeclarationMessage (const chip::Transport::PeerAddress & source,
124
+ chip::Protocols::UserDirectedCommissioning::CommissionerDeclaration cd) override
125
+ {
126
+ ChipLogProgress (AppServer, " CastingPlayer::CommissionerDeclarationHandler::OnCommissionerDeclarationMessage() called" );
127
+ cd.DebugLog ();
128
+ }
129
+ };
130
+
72
131
class Endpoint ;
73
132
74
133
/* *
@@ -93,7 +152,11 @@ using ConnectCallback = std::function<void(CHIP_ERROR, CastingPlayer *)>;
93
152
class CastingPlayer : public std ::enable_shared_from_this<CastingPlayer>
94
153
{
95
154
public:
96
- CastingPlayer (CastingPlayerAttributes playerAttributes) { mAttributes = playerAttributes; }
155
+ CastingPlayer (CastingPlayerAttributes playerAttributes)
156
+ {
157
+ mAttributes = playerAttributes;
158
+ mCommissionerDeclarationHandler = new CommissionerDeclarationHandler ();
159
+ }
97
160
98
161
/* *
99
162
* @brief Get the CastingPlayer object targeted currently (may not be connected)
@@ -123,13 +186,15 @@ class CastingPlayer : public std::enable_shared_from_this<CastingPlayer>
123
186
* For failure - called back with an error and nullptr.
124
187
* @param commissioningWindowTimeoutSec (Optional) time (in sec) to keep the commissioning window open, if commissioning is
125
188
* required. Needs to be >= kCommissioningWindowTimeoutSec.
126
- * @param desiredEndpointFilter (Optional) Attributes (such as VendorId) describing an Endpoint that the client wants to
127
- * interact with after commissioning. If this value is passed in, the VerifyOrEstablishConnection will force User Directed
128
- * Commissioning, in case the desired Endpoint is not found in the on device CastingStore.
189
+ * @param idOptions (Optional) Parameters in the IdentificationDeclaration message sent by the Commissionee to the Commissioner.
190
+ * These parameters specify the information relating to the requested commissioning session.
191
+ * Furthermore, attributes (such as VendorId) describe the TargetApp that the client wants to interact with after commissioning.
192
+ * If this value is passed in, VerifyOrEstablishConnection() will force User Directed Commissioning, in case the desired
193
+ * TargetApp is not found in the on-device CastingStore.
129
194
*/
130
195
void VerifyOrEstablishConnection (ConnectCallback onCompleted,
131
196
unsigned long long int commissioningWindowTimeoutSec = kCommissioningWindowTimeoutSec ,
132
- EndpointFilter desiredEndpointFilter = EndpointFilter ());
197
+ IdentificationDeclarationOptions idOptions = IdentificationDeclarationOptions ());
133
198
134
199
/* *
135
200
* @brief Sets the internal connection state of this CastingPlayer to "disconnected"
@@ -197,6 +262,17 @@ class CastingPlayer : public std::enable_shared_from_this<CastingPlayer>
197
262
std::vector<memory::Strong<Endpoint>> mEndpoints ;
198
263
ConnectionState mConnectionState = CASTING_PLAYER_NOT_CONNECTED;
199
264
CastingPlayerAttributes mAttributes ;
265
+ IdentificationDeclarationOptions mIdOptions ;
266
+ /* *
267
+ * Flag to indicate whether or not the Commissionee (tv-casting-app) is enabled for the Commissioner-Generated Passcode flow.
268
+ */
269
+ bool mUdcCommissionerPasscodeEnabled = false ;
270
+ /* *
271
+ * Flag to indicate whether or not the Commissionee has obtained the Commissioner Passcode from the user and is therefore ready
272
+ * for commissioning.
273
+ */
274
+ bool mUdcCommissionerPasscodeReady = false ;
275
+ CommissionerDeclarationHandler * mCommissionerDeclarationHandler ;
200
276
static CastingPlayer * mTargetCastingPlayer ;
201
277
unsigned long long int mCommissioningWindowTimeoutSec = kCommissioningWindowTimeoutSec ;
202
278
ConnectCallback mOnCompleted = {};
@@ -217,12 +293,14 @@ class CastingPlayer : public std::enable_shared_from_this<CastingPlayer>
217
293
#endif // CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY_CLIENT
218
294
219
295
/* *
220
- * @brief Checks if the cachedCastingPlayer contains an Endpoint that matches the description of the desiredEndpointFilter
221
- *
222
- * @return true - cachedCastingPlayer contains at least one endpoint that matches all the (non-default) values in
223
- * desiredEndpointFilter, false otherwise
296
+ * @brief Checks if the cachedCastingPlayer contains at least one Endpoint/TargetApp described in the desiredTargetApps list.
297
+ * @return true - cachedCastingPlayer contains at least one endpoints with matching (non-default) values as described in the
298
+ * desiredTargetApps list, false otherwise.
299
+ * @param numTargetApps Specifies the number of TargetAppInfos passed in the desiredTargetApps array.
224
300
*/
225
- bool ContainsDesiredEndpoint (core::CastingPlayer * cachedCastingPlayer, EndpointFilter desiredEndpointFilter);
301
+ bool ContainsDesiredTargetApp (core::CastingPlayer * cachedCastingPlayer,
302
+ chip::Protocols::UserDirectedCommissioning::TargetAppInfo * desiredTargetApps,
303
+ uint8_t numTargetApps);
226
304
227
305
// ChipDeviceEventHandler handles chip::DeviceLayer::ChipDeviceEvent events and helps the CastingPlayer class commission with
228
306
// and connect to a CastingPlayer
0 commit comments