Skip to content

Commit ac1c96a

Browse files
Tv casting app stop connect when user navigates back before confirming passcode in commission (#37278)
* [Amazon] StopConnect for UDC in Android tv-casting-app Updated Android & iOS tv-casting-app to send stopConnect command when user exits UDC before confirming passcode Changes 1. Added IsPendingPasscodeFromUser() to CastingPlayer. This function will return true if we are still connecting and pending user action for passcode 2. ConnectionExampleFragment.java onDestroy() calls stopConnect() if user has not confirmed passcode 4. MCConnectionExampleView ConnectingView dissapear calls stopConnect() if user has not confirmed passcode Test 1. Manually verified UDC attempt is successful both Android iOS for following 1. Attempt UDC attempt (both commissionee & commissioner generated passcode) 2. Navigate back to discovery page 3. Start new UDC attempt (both commissionee & commissioner generated passcode) 2. Manually verified UDC attempt is successful both Android iOS for following. UDC will finish in the background. 1. Attempt UDC attempt (both commissionee & commissioner generated passcode) 2. Confirm passcode on TV app or casting app depending on who generated passcode 3. Navigate back before commission fnishes. 3. Manual regression test following * UDC attempt happy path (no navigate back) for both commissinee & commissioner generated passcode * [Amazon] StopConnect for UDC in Android tv-casting-app Updated native layer and iOS tv-casting-app to use native layer ConnectionState instead of a pendingPasscode customer check. Changes * Expose native layer ConnectionState to iOS tv-casting-app * Update iOS tv-casting-app to use ConnectionState to determine if we should call stopConnect() * Only call stopConnect() on navigate back from ConnectionExampleView * Updated doc to indicate when a object method will free itself as a side effect Test 1. Manually verified UDC attempt is successful both Android iOS for following 1. Attempt UDC attempt (both commissionee & commissioner generated passcode) 2. Navigate back to discovery page 3. Start new UDC attempt (both commissionee & commissioner generated passcode) 2. Manually verified UDC attempt is successful both Android iOS for following. UDC will finish in the background. 1. Attempt UDC attempt (both commissionee & commissioner generated passcode) 2. Confirm passcode on TV app or casting app depending on who generated passcode 3. Navigate back before commission fnishes. 3. Manual regression test following * UDC attempt happy path (no navigate back) for both commissinee & commissioner generated passcode * [Amazon] StopConnect for UDC in Android tv-casting-app Updated JNI and Android tv-casting-app to use native layer ConnectionState instead of a pendingPasscode customer check. Changes * Expose native layer ConnectionState to Android tv-casting-app * Update Android tv-casting-app to use ConnectionState to determine if we should call stopConnect() * Only call stopConnect() on navigate back from ConnectionExampleFragmnet Test 1. Manually verified UDC attempt is successful both Android iOS for following 1. Attempt UDC attempt (both commissionee & commissioner generated passcode) 2. Navigate back to discovery page 3. Start new UDC attempt (both commissionee & commissioner generated passcode) 2. Manually verified UDC attempt is successful both Android iOS for following. UDC will finish in the background. 1. Attempt UDC attempt (both commissionee & commissioner generated passcode) 2. Confirm passcode on TV app or casting app depending on who generated passcode 3. Navigate back before commission fnishes. 3. Manual regression test following * UDC attempt happy path (no navigate back) for both commissinee & commissioner generated passcode * [Amazon] StopConnect for UDC in Android tv-casting-app Applied restyle formatting * [Amazon] StopConnect for UDC in Android tv-casting-app Fix restyle CI error * [Amazon] StopConnect for UDC in Android tv-casting-app Updated JNI and Android tv-casting-app to use CharToStringUTF util function to create jstring and handle NULL JNIEnv interface Changes * JNI to use CharToStringUTF util function to create jstring * Updated documentation for new JNI functions Test 1. Manually verified UDC attempt is successful both Android iOS for following 1. Attempt UDC attempt (both commissionee & commissioner generated passcode) 2. Navigate back to discovery page 3. Start new UDC attempt (both commissionee & commissioner generated passcode) 2. Manually verified UDC attempt is successful both Android iOS for following. UDC will finish in the background. 1. Attempt UDC attempt (both commissionee & commissioner generated passcode) 2. Confirm passcode on TV app or casting app depending on who generated passcode 3. Navigate back before commission fnishes. 3. Manual regression test following * UDC attempt happy path (no navigate back) for both commissinee & commissioner generated passcode * [Amazon] StopConnect for UDC in Android tv-casting-app Updated JNI and Android tv-casting-app to use CharToStringUTF util function to create jstring and handle NULL JNIEnv interface Changes * JNI to use CharToStringUTF util function to create jstring for all ConnectionState and not just errors Test 1. Manually verified UDC attempt is successful both Android iOS for following 1. Attempt UDC attempt (both commissionee & commissioner generated passcode) 2. Navigate back to discovery page 3. Start new UDC attempt (both commissionee & commissioner generated passcode) 2. Manually verified UDC attempt is successful both Android iOS for following. UDC will finish in the background. 1. Attempt UDC attempt (both commissionee & commissioner generated passcode) 2. Confirm passcode on TV app or casting app depending on who generated passcode 3. Navigate back before commission fnishes. 3. Manual regression test following * UDC attempt happy path (no navigate back) for both commissinee & commissioner generated passcode
1 parent 5087ebc commit ac1c96a

File tree

12 files changed

+209
-58
lines changed

12 files changed

+209
-58
lines changed

examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ConnectionExampleFragment.java

+19-24
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,21 @@ public void handle(CommissionerDeclaration cd) {
262262
});
263263
}
264264

265+
@Override
266+
public void onStop() {
267+
super.onStop();
268+
// Only stop connection if we are still connecting to the device
269+
if (targetCastingPlayer.getConnectionState() == CastingPlayer.ConnectionState.CONNECTING) {
270+
// NOTE, once stopConnecting() is called, the targetCastingPlayer's native object is freed
271+
MatterError err = targetCastingPlayer.stopConnecting();
272+
if (err.hasError()) {
273+
Log.e(
274+
TAG,
275+
"Going back before connection finishes but stopConnecting() failed due to: " + err);
276+
}
277+
}
278+
}
279+
265280
private void displayPasscodeInputDialog(Context context) {
266281
AlertDialog.Builder builder = new AlertDialog.Builder(context);
267282

@@ -336,18 +351,9 @@ public void onClick(DialogInterface dialog, int which) {
336351
connectionFragmentStatusTextView.setText(
337352
"Casting Player CONTINUE CONNECTING failed due to: "
338353
+ finalErr
339-
+ "\n\n");
354+
+ ". Route back to disconnect & try again. \n\n");
340355
});
341-
Log.e(
342-
TAG,
343-
"displayPasscodeInputDialog() continueConnecting() failed, calling stopConnecting() due to: "
344-
+ err);
345-
// Since continueConnecting() failed, Attempt to cancel the connection attempt with
346-
// the CastingPlayer/Commissioner.
347-
err = targetCastingPlayer.stopConnecting();
348-
if (err.hasError()) {
349-
Log.e(TAG, "displayPasscodeInputDialog() stopConnecting() failed due to: " + err);
350-
}
356+
Log.e(TAG, "displayPasscodeInputDialog() continueConnecting() failed due to: " + err);
351357
}
352358
}
353359
});
@@ -359,20 +365,9 @@ public void onClick(DialogInterface dialog, int which) {
359365
public void onClick(DialogInterface dialog, int which) {
360366
Log.i(
361367
TAG,
362-
"displayPasscodeInputDialog() user cancelled the CastingPlayer/Commissioner-Generated Passcode input dialog. Calling stopConnecting()");
368+
"displayPasscodeInputDialog() user cancelled the CastingPlayer/Commissioner-Generated Passcode input dialog");
363369
connectionFragmentStatusTextView.setText(
364-
"Connection attempt with Casting Player cancelled by the Casting Client/Commissionee user. \n\nRoute back to exit. \n\n");
365-
MatterError err = targetCastingPlayer.stopConnecting();
366-
if (err.hasError()) {
367-
MatterError finalErr = err;
368-
getActivity()
369-
.runOnUiThread(
370-
() -> {
371-
connectionFragmentStatusTextView.setText(
372-
"Casting Player CANCEL failed due to: " + finalErr + "\n\n");
373-
});
374-
Log.e(TAG, "displayPasscodeInputDialog() stopConnecting() failed due to: " + err);
375-
}
370+
"Connection attempt with Casting Player cancelled by the Casting Client/Commissionee user. \n\nRoute back to disconnect & exit. \n\n");
376371
dialog.cancel();
377372
}
378373
});

examples/tv-casting-app/android/App/app/src/main/jni/com/matter/casting/core/CastingPlayer.java

+25
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@
2929
* about the service discovered/resolved.
3030
*/
3131
public interface CastingPlayer {
32+
33+
/** @brief CastingPlayer's Conenction State */
34+
public enum ConnectionState {
35+
/** State when CastingPlayer is not connected */
36+
NOT_CONNECTED,
37+
38+
/** State when CastingPlayer is attempting to connect */
39+
CONNECTING,
40+
41+
/** State when CastingPlayer is connnected */
42+
CONNECTED,
43+
}
44+
3245
boolean isConnected();
3346

3447
String getDeviceId();
@@ -152,4 +165,16 @@ MatterError verifyOrEstablishConnection(
152165

153166
/** @brief Sets the internal connection state of this CastingPlayer to "disconnected" */
154167
void disconnect();
168+
169+
/**
170+
* @brief Get CastingPlayer's current ConnectionState.
171+
* @return Current ConnectionState.
172+
*/
173+
ConnectionState getConnectionState();
174+
175+
/**
176+
* @brief Get the Current ConnectionState of a CastingPlayer from the native layer.
177+
* @returns A String representation of the CastingPlayer's current connectation.
178+
*/
179+
String getConnectionStateNative();
155180
}

examples/tv-casting-app/android/App/app/src/main/jni/com/matter/casting/core/MatterCastingPlayer.java

+25
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
*/
3333
public class MatterCastingPlayer implements CastingPlayer {
3434
private static final String TAG = MatterCastingPlayer.class.getSimpleName();
35+
3536
/**
3637
* Time (in sec) to keep the commissioning window open, if commissioning is required. Must be >= 3
3738
* minutes.
@@ -267,4 +268,28 @@ public MatterError continueConnecting() {
267268

268269
@Override
269270
public native void disconnect();
271+
272+
/**
273+
* @brief Get CastingPlayer's current ConnectionState.
274+
* @throws IllegalArgumentException or NullPointerException when native layer returns invalid
275+
* state.
276+
* @return Current ConnectionState.
277+
*/
278+
@Override
279+
public ConnectionState getConnectionState() {
280+
return ConnectionState.valueOf(getConnectionStateNative());
281+
}
282+
283+
/*
284+
* @brief Get the Current ConnectionState of a CastingPlayer from the native layer.
285+
*
286+
* @returns A String representation of the CastingPlayer's current connectation.
287+
* Possible return values are
288+
* - "NOT_CONNECTED"
289+
* - "CONNECTING"
290+
* - "CONNECTED"
291+
* - Error message or NULL on error
292+
*/
293+
@Override
294+
public native String getConnectionStateNative();
270295
}

examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/MatterCastingPlayer-JNI.cpp

+39
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,45 @@ JNI_METHOD(void, disconnect)
165165
castingPlayer->Disconnect();
166166
}
167167

168+
JNI_METHOD(jstring, getConnectionStateNative)
169+
(JNIEnv * env, jobject thiz)
170+
{
171+
char error_str[50];
172+
jobject jstr_obj = nullptr;
173+
174+
if (NULL == env)
175+
{
176+
LogErrorOnFailure(
177+
chip::JniReferences::GetInstance().CharToStringUTF(CharSpan::fromCharString("JNIEnv interface is NULL"), jstr_obj));
178+
return static_cast<jstring>(jstr_obj);
179+
}
180+
181+
chip::DeviceLayer::StackLock lock;
182+
ChipLogProgress(AppServer, "MatterCastingPlayer-JNI::getConnectionState()");
183+
184+
CastingPlayer * castingPlayer = support::convertCastingPlayerFromJavaToCpp(thiz);
185+
VerifyOrReturnValue(castingPlayer != nullptr, env->NewStringUTF("Cast Player is nullptr"));
186+
187+
matter::casting::core::ConnectionState state = castingPlayer->GetConnectionState();
188+
switch (state)
189+
{
190+
case matter::casting::core::ConnectionState::CASTING_PLAYER_NOT_CONNECTED:
191+
LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(CharSpan::fromCharString("NOT_CONNECTED"), jstr_obj));
192+
break;
193+
case matter::casting::core::ConnectionState::CASTING_PLAYER_CONNECTING:
194+
LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(CharSpan::fromCharString("CONNECTING"), jstr_obj));
195+
break;
196+
case matter::casting::core::ConnectionState::CASTING_PLAYER_CONNECTED:
197+
LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(CharSpan::fromCharString("CONNECTED"), jstr_obj));
198+
break;
199+
default:
200+
snprintf(error_str, sizeof(error_str), "Unsupported Connection State: %d", state);
201+
LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(CharSpan::fromCharString(error_str), jstr_obj));
202+
break;
203+
}
204+
return static_cast<jstring>(jstr_obj);
205+
}
206+
168207
JNI_METHOD(jobject, getEndpoints)
169208
(JNIEnv * env, jobject thiz)
170209
{

examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingPlayer.h

+17
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@
2626

2727
@class MCEndpoint;
2828

29+
/**
30+
* @brief Represents CastingPlayer ConnectionState.
31+
* @note Should be kept up to date with matter::casting::core::ConnectionState.
32+
*/
33+
typedef enum {
34+
MC_CASTING_PLAYER_NOT_CONNECTED,
35+
MC_CASTING_PLAYER_CONNECTING,
36+
MC_CASTING_PLAYER_CONNECTED,
37+
} MCCastingPlayerConnectionState;
38+
2939
/**
3040
* @brief MCCastingPlayer represents a Matter commissioner that is able to play media to a physical
3141
* output or to a display screen which is part of the device.
@@ -148,6 +158,13 @@
148158
*/
149159
- (void)disconnect;
150160

161+
/**
162+
* @brief Get the CastingPlayer's connection state
163+
* @param state The current connection state that will be return.
164+
* @return nil if request submitted successfully, otherwise a NSError object corresponding to the error.
165+
*/
166+
- (NSError * _Nullable)getConnectionState:(MCCastingPlayerConnectionState * _Nonnull)state;
167+
151168
- (NSString * _Nonnull)identifier;
152169
- (NSString * _Nonnull)deviceName;
153170
- (uint16_t)vendorId;

examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingPlayer.mm

+29
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,35 @@ - (void)disconnect
190190
});
191191
}
192192

193+
- (NSError * _Nullable)getConnectionState:(MCCastingPlayerConnectionState * _Nonnull)state;
194+
{
195+
ChipLogProgress(AppServer, "MCCastingPlayer.getConnectionState() called");
196+
VerifyOrReturnValue([[MCCastingApp getSharedInstance] isRunning], [MCErrorUtils NSErrorFromChipError:CHIP_ERROR_INCORRECT_STATE], ChipLogError(AppServer, "MCCastingPlayer.getConnectionState() MCCastingApp NOT running"));
197+
198+
__block matter::casting::core::ConnectionState native_state = matter::casting::core::ConnectionState::CASTING_PLAYER_NOT_CONNECTED;
199+
dispatch_queue_t workQueue = [[MCCastingApp getSharedInstance] getWorkQueue];
200+
dispatch_sync(workQueue, ^{
201+
native_state = _cppCastingPlayer->GetConnectionState();
202+
});
203+
204+
switch (native_state) {
205+
case matter::casting::core::ConnectionState::CASTING_PLAYER_NOT_CONNECTED:
206+
*state = MC_CASTING_PLAYER_NOT_CONNECTED;
207+
break;
208+
case matter::casting::core::ConnectionState::CASTING_PLAYER_CONNECTING:
209+
*state = MC_CASTING_PLAYER_CONNECTING;
210+
break;
211+
case matter::casting::core::ConnectionState::CASTING_PLAYER_CONNECTED:
212+
*state = MC_CASTING_PLAYER_CONNECTED;
213+
break;
214+
default:
215+
[NSException raise:@"Unhandled matter::casting::core::ConnectionState" format:@"%d is not handled", native_state];
216+
break;
217+
}
218+
219+
return nil;
220+
}
221+
193222
- (instancetype _Nonnull)initWithCppCastingPlayer:(matter::casting::memory::Strong<matter::casting::core::CastingPlayer>)cppCastingPlayer
194223
{
195224
if (self = [super init]) {

examples/tv-casting-app/darwin/TvCasting/TvCasting/MCConnectionExampleView.swift

+3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ struct MCConnectionExampleView: View {
8888
viewModel.connect(selectedCastingPlayer: self.selectedCastingPlayer, useCommissionerGeneratedPasscode: self.useCommissionerGeneratedPasscode)
8989
}
9090
})
91+
.onDisappear(perform: {
92+
viewModel.cancelConnectionAttempt(selectedCastingPlayer: self.selectedCastingPlayer)
93+
})
9194
}
9295
}
9396

examples/tv-casting-app/darwin/TvCasting/TvCasting/MCConnectionExampleViewModel.swift

+28-28
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,29 @@ class MCConnectionExampleViewModel: ObservableObject {
4242

4343
@Published var errorCodeDescription: String?
4444

45+
func cancelConnectionAttempt(selectedCastingPlayer: MCCastingPlayer?) {
46+
DispatchQueue.main.async {
47+
// Only stop connection if we are pending passcode confirmation
48+
var connectionState = MC_CASTING_PLAYER_NOT_CONNECTED;
49+
let err = selectedCastingPlayer?.getConnectionState(&connectionState)
50+
if err != nil {
51+
self.Log.error("MCConnectionExampleViewModel cancelConnect() MCCastingPlayer.getConnectionState() failed due to: \(err)")
52+
}
53+
54+
if connectionState == MC_CASTING_PLAYER_CONNECTING {
55+
self.Log.info("MCConnectionExampleViewModel cancelConnect(). User navigating back from ConnectionView")
56+
let err = selectedCastingPlayer?.stopConnecting()
57+
if err == nil {
58+
self.connectionStatus = "User cancelled the connection attempt with CastingPlayer.stopConnecting()."
59+
self.Log.info("MCConnectionExampleViewModel cancelConnect() MCCastingPlayer.stopConnecting() succeeded.")
60+
} else {
61+
self.connectionStatus = "Cancel connection failed due to: \(String(describing: err))."
62+
self.Log.error("MCConnectionExampleViewModel cancelConnect() MCCastingPlayer.stopConnecting() failed due to: \(err)")
63+
}
64+
}
65+
}
66+
}
67+
4568
func connect(selectedCastingPlayer: MCCastingPlayer?, useCommissionerGeneratedPasscode: Bool) {
4669
self.Log.info("MCConnectionExampleViewModel.connect() useCommissionerGeneratedPasscode: \(String(describing: useCommissionerGeneratedPasscode))")
4770

@@ -108,17 +131,9 @@ class MCConnectionExampleViewModel: ObservableObject {
108131
dataSource.update(newCommissionableData)
109132
self.Log.info("MCConnectionExampleViewModel connect() commissionerDeclarationCallback, Updated MCAppParametersDataSource instance with new MCCommissionableData.")
110133
} else {
111-
self.Log.error("MCConnectionExampleViewModel connect() commissionerDeclarationCallback, InitializationExample.getAppParametersDataSource() failed, calling stopConnecting()")
112-
self.connectionStatus = "Failed to update the MCAppParametersDataSource with the user entered passcode: \n\nRoute back and try again."
134+
self.Log.error("MCConnectionExampleViewModel connect() commissionerDeclarationCallback, InitializationExample.getAppParametersDataSource() failed")
135+
self.connectionStatus = "Failed to update the MCAppParametersDataSource with the user entered passcode: \n\nRoute back to disconnect and try again."
113136
self.connectionSuccess = false
114-
// Since we failed to update the passcode, Attempt to cancel the connection attempt with
115-
// the CastingPlayer/Commissioner.
116-
let err = selectedCastingPlayer?.stopConnecting()
117-
if err == nil {
118-
self.Log.info("MCConnectionExampleViewModel connect() commissionerDeclarationCallback, InitializationExample.getAppParametersDataSource() failed, then stopConnecting() succeeded")
119-
} else {
120-
self.Log.error("MCConnectionExampleViewModel connect() commissionerDeclarationCallback, InitializationExample.getAppParametersDataSource() failed, then stopConnecting() failed due to: \(err)")
121-
}
122137
return
123138
}
124139

@@ -127,28 +142,13 @@ class MCConnectionExampleViewModel: ObservableObject {
127142
if errContinue == nil {
128143
self.connectionStatus = "Continuing to connect with user entered passcode: \(userEnteredPasscode)"
129144
} else {
130-
self.connectionStatus = "Continue Connecting to Casting Player failed with: \(String(describing: errContinue)) \n\nRoute back and try again."
145+
self.connectionStatus = "Continue Connecting to Casting Player failed with: \(String(describing: errContinue)) \n\nRoute back to disconnect and try again."
131146
self.Log.error("MCConnectionExampleViewModel connect() commissionerDeclarationCallback, MCCastingPlayer.continueConnecting() failed due to: \(errContinue)")
132-
// Since continueConnecting() failed, Attempt to cancel the connection attempt with
133-
// the CastingPlayer/Commissioner.
134-
let err = selectedCastingPlayer?.stopConnecting()
135-
if err == nil {
136-
self.Log.info("MCConnectionExampleViewModel connect() commissionerDeclarationCallback, MCCastingPlayer.continueConnecting() failed, then stopConnecting() succeeded")
137-
} else {
138-
self.Log.error("MCConnectionExampleViewModel connect() commissionerDeclarationCallback, MCCastingPlayer.continueConnecting() failed, then stopConnecting() failed due to: \(err)")
139-
}
140147
}
141148
}, cancelConnecting: {
142-
self.Log.info("MCConnectionExampleViewModel connect() commissionerDeclarationCallback, Connection attempt cancelled by the user, calling MCCastingPlayer.stopConnecting()")
143-
let err = selectedCastingPlayer?.stopConnecting()
149+
self.Log.info("MCConnectionExampleViewModel connect() commissionerDeclarationCallback, Connection attempt cancelled by the user")
144150
self.connectionSuccess = false
145-
if err == nil {
146-
self.connectionStatus = "User cancelled the connection attempt with CastingPlayer. \n\nRoute back to exit."
147-
self.Log.info("MCConnectionExampleViewModel connect() commissionerDeclarationCallback, User cancelled the connection attempt with MCCastingPlayer, MCCastingPlayer.stopConnecting() succeeded.")
148-
} else {
149-
self.connectionStatus = "Cancel connection failed due to: \(String(describing: err)) \n\nRoute back to exit."
150-
self.Log.error("MCConnectionExampleViewModel connect() commissionerDeclarationCallback, MCCastingPlayer.stopConnecting() failed due to: \(err)")
151-
}
151+
self.connectionStatus = "User cancelled the connection attempt with CastingPlayer. \n\nRoute back to disconnect & exit."
152152
})
153153
}
154154
}

examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,6 @@ CHIP_ERROR CastingPlayer::ContinueConnecting()
228228

229229
CHIP_ERROR CastingPlayer::StopConnecting()
230230
{
231-
VerifyOrReturnValue(
232-
mIdOptions.mCommissionerPasscode, CHIP_ERROR_INCORRECT_STATE,
233-
ChipLogError(AppServer,
234-
"CastingPlayer::StopConnecting() mIdOptions.mCommissionerPasscode == false, ContinueConnecting() should only "
235-
"be called when the CastingPlayer/Commissioner-Generated passcode commissioning flow is in progress."););
236231
// Calling the internal StopConnecting() API with the shouldSendIdentificationDeclarationMessage set to true to notify the
237232
// CastingPlayer/Commissioner that the commissioning session was cancelled by the Casting Client/Commissionee user. This will
238233
// result in the Casting Client/Commissionee sending a CancelPasscode IdentificationDeclaration message to the CastingPlayer.

examples/tv-casting-app/tv-casting-common/core/CastingPlayer.h

+11-1
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,15 @@ class CastingPlayer : public std::enable_shared_from_this<CastingPlayer>
210210
* otherwise. StopConnecting() can only be called by the client during the CastingPlayer/Commissioner-Generated passcode
211211
* commissioning flow. Calling StopConnecting() during the Client/Commissionee-Generated commissioning flow will return a
212212
* CHIP_ERROR_INCORRECT_STATE error.
213+
*
214+
* @note This method will free the calling object as a side effect.
213215
*/
214216
CHIP_ERROR StopConnecting();
215217

216218
/**
217219
* @brief Sets the internal connection state of this CastingPlayer to "disconnected"
220+
*
221+
* @note This method will free the calling object as a side effect.
218222
*/
219223
void Disconnect();
220224

@@ -278,7 +282,11 @@ class CastingPlayer : public std::enable_shared_from_this<CastingPlayer>
278282
/**
279283
* @brief Return the current state of the CastingPlayer
280284
*/
281-
ConnectionState GetConnectionState() const { return mConnectionState; }
285+
ConnectionState GetConnectionState() const
286+
{
287+
ChipLogError(AppServer, "CastingPlayer::GetConnectionState() state: %d", mConnectionState);
288+
return mConnectionState;
289+
}
282290

283291
private:
284292
std::vector<memory::Strong<Endpoint>> mEndpoints;
@@ -318,6 +326,8 @@ class CastingPlayer : public std::enable_shared_from_this<CastingPlayer>
318326
/**
319327
* @brief resets this CastingPlayer's state and calls mOnCompleted with the CHIP_ERROR. Also, after calling mOnCompleted, it
320328
* clears mOnCompleted by setting it to a nullptr.
329+
*
330+
* @note This method will free the calling object as a side effect.
321331
*/
322332
void resetState(CHIP_ERROR err);
323333

0 commit comments

Comments
 (0)