Skip to content

Commit

Permalink
Merge branch 'master' into read-events-chip-repl-02-07-upload
Browse files Browse the repository at this point in the history
  • Loading branch information
tehampson committed Feb 9, 2023
2 parents 05ca534 + a55b245 commit 8b80acc
Show file tree
Hide file tree
Showing 77 changed files with 7,519 additions and 4,350 deletions.
1 change: 0 additions & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
"${chip_root}/src/setup_payload",
"${chip_root}/src/system",
"${chip_root}/src/transport",
"${mbedtls_root}:mbedtls",
"${nlassert_root}:nlassert",
"${nlio_root}:nlio",
"${nlunit_test_root}:nlunit-test",
Expand Down
9 changes: 9 additions & 0 deletions examples/chip-tool/commands/pairing/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ class PairSoftAP : public PairingCommand
{}
};

class PairAlreadyDiscovered : public PairingCommand
{
public:
PairAlreadyDiscovered(CredentialIssuerCommands * credsIssuerConfig) :
PairingCommand("already-discovered", PairingMode::AlreadyDiscovered, PairingNetworkType::None, credsIssuerConfig)
{}
};

class StartUdcServerCommand : public CHIPCommand
{
public:
Expand All @@ -199,6 +207,7 @@ void registerCommandsPairing(Commands & commands, CredentialIssuerCommands * cre
make_unique<PairBleWiFi>(credsIssuerConfig),
make_unique<PairBleThread>(credsIssuerConfig),
make_unique<PairSoftAP>(credsIssuerConfig),
make_unique<PairAlreadyDiscovered>(credsIssuerConfig),
make_unique<PairOnNetwork>(credsIssuerConfig),
make_unique<PairOnNetworkShort>(credsIssuerConfig),
make_unique<PairOnNetworkLong>(credsIssuerConfig),
Expand Down
3 changes: 3 additions & 0 deletions examples/chip-tool/commands/pairing/PairingCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ CHIP_ERROR PairingCommand::RunInternal(NodeId remoteId)
case PairingMode::SoftAP:
err = Pair(remoteId, PeerAddress::UDP(mRemoteAddr.address, mRemotePort, mRemoteAddr.interfaceId));
break;
case PairingMode::AlreadyDiscovered:
err = Pair(remoteId, PeerAddress::UDP(mRemoteAddr.address, mRemotePort, mRemoteAddr.interfaceId));
break;
}

return err;
Expand Down
8 changes: 8 additions & 0 deletions examples/chip-tool/commands/pairing/PairingCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ enum class PairingMode
CodePaseOnly,
Ble,
SoftAP,
AlreadyDiscovered,
OnNetwork,
};

Expand Down Expand Up @@ -106,6 +107,13 @@ class PairingCommand : public CHIPCommand,
AddArgument("device-remote-port", 0, UINT16_MAX, &mRemotePort);
AddArgument("pase-only", 0, 1, &mPaseOnly);
break;
case PairingMode::AlreadyDiscovered:
AddArgument("skip-commissioning-complete", 0, 1, &mSkipCommissioningComplete);
AddArgument("setup-pin-code", 0, 134217727, &mSetupPINCode);
AddArgument("device-remote-ip", &mRemoteAddr);
AddArgument("device-remote-port", 0, UINT16_MAX, &mRemotePort);
AddArgument("pase-only", 0, 1, &mPaseOnly);
break;
}

switch (filterType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ public void onClick(View v) {
private void runCertTests(Activity activity) {
CertTestMatterSuccessFailureCallback successFailureCallback =
new CertTestMatterSuccessFailureCallback(activity);
CertTestMatterSuccessFailureCallbackInteger successFailureCallbackInteger =
new CertTestMatterSuccessFailureCallbackInteger(successFailureCallback);
CertTestMatterSuccessCallback successCallback =
new CertTestMatterSuccessCallback(successFailureCallback);
CertTestMatterFailureCallback failureCallback =
new CertTestMatterFailureCallback(successFailureCallback);
CertTestMatterSuccessCallbackInteger successCallbackInteger =
new CertTestMatterSuccessCallbackInteger(successFailureCallback);
CertTestMatterCallbackHandler callback =
new CertTestMatterCallbackHandler(successFailureCallback);

Expand Down Expand Up @@ -269,39 +273,39 @@ private void runCertTests(Activity activity) {
successFailureCallback,
() -> {
tvCastingApp.applicationBasic_readApplicationVersion(
kContentApp, successFailureCallback, successFailureCallback);
kContentApp, successCallback, failureCallback);
});

runAndWait(
"applicationBasic_readVendorName",
successFailureCallback,
() -> {
tvCastingApp.applicationBasic_readVendorName(
kContentApp, successFailureCallback, successFailureCallback);
kContentApp, successCallback, failureCallback);
});

runAndWait(
"applicationBasic_readApplicationName",
successFailureCallback,
() -> {
tvCastingApp.applicationBasic_readApplicationName(
kContentApp, successFailureCallback, successFailureCallback);
kContentApp, successCallback, failureCallback);
});

runAndWait(
"applicationBasic_readVendorID",
successFailureCallback,
() -> {
tvCastingApp.applicationBasic_readVendorID(
kContentApp, successFailureCallbackInteger, successFailureCallbackInteger);
kContentApp, successCallbackInteger, failureCallback);
});

runAndWait(
"applicationBasic_readProductID",
successFailureCallback,
() -> {
tvCastingApp.applicationBasic_readProductID(
kContentApp, successFailureCallbackInteger, successFailureCallbackInteger);
kContentApp, successCallbackInteger, failureCallback);
});

runAndWait(
Expand All @@ -320,7 +324,7 @@ public void handle(MediaPlaybackTypes.PlaybackStateEnum response) {
activity, MatterError.NO_ERROR, "mediaPlayback_subscribeToCurrentState");
}
},
successFailureCallback,
failureCallback,
0,
20,
new SubscriptionEstablishedCallback() {
Expand Down Expand Up @@ -415,8 +419,7 @@ public void handle(MatterError error) {
}
}

class CertTestMatterSuccessFailureCallback extends FailureCallback
implements SuccessCallback<String> {
class CertTestMatterSuccessFailureCallback {
private Activity activity;
private String testMethod;
private CountDownLatch cdl;
Expand All @@ -433,7 +436,6 @@ public void setCountDownLatch(CountDownLatch cdl) {
this.cdl = cdl;
}

@Override
public void handle(MatterError error) {
try {
cdl.countDown();
Expand All @@ -446,7 +448,6 @@ public void handle(MatterError error) {
}
}

@Override
public void handle(String response) {
try {
cdl.countDown();
Expand All @@ -460,18 +461,38 @@ public void handle(String response) {
}
}

class CertTestMatterSuccessFailureCallbackInteger extends FailureCallback
implements SuccessCallback<Integer> {
class CertTestMatterSuccessCallback extends SuccessCallback<String> {
private CertTestMatterSuccessFailureCallback delegate;

CertTestMatterSuccessCallback(CertTestMatterSuccessFailureCallback delegate) {
this.delegate = delegate;
}

@Override
public void handle(String response) {
delegate.handle(response);
}
}

class CertTestMatterFailureCallback extends FailureCallback {
private CertTestMatterSuccessFailureCallback delegate;

CertTestMatterSuccessFailureCallbackInteger(CertTestMatterSuccessFailureCallback delegate) {
CertTestMatterFailureCallback(CertTestMatterSuccessFailureCallback delegate) {
this.delegate = delegate;
}

@Override
public void handle(MatterError error) {
delegate.handle(error);
public void handle(MatterError err) {
delegate.handle(err);
}
}

class CertTestMatterSuccessCallbackInteger extends SuccessCallback<Integer> {

private CertTestMatterSuccessFailureCallback delegate;

CertTestMatterSuccessCallbackInteger(CertTestMatterSuccessFailureCallback delegate) {
this.delegate = delegate;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import com.chip.casting.ContentApp;
import com.chip.casting.FailureCallback;
import com.chip.casting.MatterError;
Expand Down Expand Up @@ -63,13 +64,16 @@ public void onClick(View v) {
TextView currentStateValue = getView().findViewById(R.id.currentStateValue);

SuccessCallback<MediaPlaybackTypes.PlaybackStateEnum> successCallback =
playbackStateEnum -> {
Log.d(
TAG,
"handle() called on SuccessCallback<MediaPlaybackResponseTypes.PlaybackStateEnum> with "
+ playbackStateEnum);
getActivity()
.runOnUiThread(
new SuccessCallback<MediaPlaybackTypes.PlaybackStateEnum>() {
@Override
public void handle(MediaPlaybackTypes.PlaybackStateEnum playbackStateEnum) {
Log.d(
TAG,
"handle() called on SuccessCallback<MediaPlaybackResponseTypes.PlaybackStateEnum> with "
+ playbackStateEnum);
FragmentActivity fragmentActivity = getActivity();
if (fragmentActivity != null) {
fragmentActivity.runOnUiThread(
new Runnable() {
@Override
public void run() {
Expand All @@ -78,6 +82,8 @@ public void run() {
}
}
});
}
}
};

FailureCallback failureCallback =
Expand All @@ -97,18 +103,22 @@ public void run() {
};

SubscriptionEstablishedCallback subscriptionEstablishedCallback =
(SubscriptionEstablishedCallback)
() -> {
Log.d(TAG, "handle() called on SubscriptionEstablishedCallback");
getActivity()
.runOnUiThread(
new Runnable() {
@Override
public void run() {
subscriptionStatus.setText("Subscription established!");
}
});
};
new SubscriptionEstablishedCallback() {
@Override
public void handle() {
Log.d(TAG, "handle() called on SubscriptionEstablishedCallback");
FragmentActivity fragmentActivity = getActivity();
if (fragmentActivity != null) {
fragmentActivity.runOnUiThread(
new Runnable() {
@Override
public void run() {
subscriptionStatus.setText("Subscription established!");
}
});
}
}
};

boolean retVal =
tvCastingApp.mediaPlayback_subscribeToCurrentState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@
*/
package com.chip.casting;

import android.util.Log;

public abstract class FailureCallback {
private static final String TAG = FailureCallback.class.getSimpleName();

public abstract void handle(MatterError err);

public final void handle(int errorCode, String errorMessage) {
handle(new MatterError(errorCode, errorMessage));
private final void handleInternal(int errorCode, String errorMessage) {
try {
handle(new MatterError(errorCode, errorMessage));
} catch (Throwable t) {
Log.e(TAG, "FailureCallback::Caught an unhandled Throwable from the client: " + t);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@
*/
package com.chip.casting;

import android.util.Log;

public abstract class MatterCallbackHandler {
private static final String TAG = MatterCallbackHandler.class.getSimpleName();

public abstract void handle(MatterError err);

public final void handle(int errorCode, String errorMessage) {
handle(new MatterError(errorCode, errorMessage));
private final void handleInternal(int errorCode, String errorMessage) {
try {
handle(new MatterError(errorCode, errorMessage));
} catch (Throwable t) {
Log.e(TAG, "MatterCallbackHandler::Caught an unhandled Throwable from the client: " + t);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@
*/
package com.chip.casting;

public interface SubscriptionEstablishedCallback {
void handle();
import android.util.Log;

public abstract class SubscriptionEstablishedCallback {
private static final String TAG = SubscriptionEstablishedCallback.class.getSimpleName();

public abstract void handle();

private void handleInternal() {
try {
handle();
} catch (Throwable t) {
Log.e(
TAG,
"SubscriptionEstablishedCallback::Caught an unhandled Throwable from the client: " + t);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@
*/
package com.chip.casting;

public interface SuccessCallback<R> {
void handle(R response);
import android.util.Log;

public abstract class SuccessCallback<R> {
private static final String TAG = SuccessCallback.class.getSimpleName();

public abstract void handle(R response);

public void handleInternal(R response) {
try {
handle(response);
} catch (Throwable t) {
Log.e(TAG, "SuccessCallback::Caught an unhandled Throwable from the client: " + t);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ CHIP_ERROR convertJAppParametersToCppAppParams(jobject appParameters, AppParams
CHIP_ERROR convertJContentAppToTargetEndpointInfo(jobject contentApp, TargetEndpointInfo & outTargetEndpointInfo)
{
ChipLogProgress(AppServer, "convertJContentAppToTargetEndpointInfo called");
VerifyOrReturnError(contentApp != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread();

jclass jContentAppClass;
Expand Down Expand Up @@ -124,6 +125,7 @@ CHIP_ERROR convertTargetEndpointInfoToJContentApp(TargetEndpointInfo * targetEnd
CHIP_ERROR convertJVideoPlayerToTargetVideoPlayerInfo(jobject videoPlayer, TargetVideoPlayerInfo & outTargetVideoPlayerInfo)
{
ChipLogProgress(AppServer, "convertJVideoPlayerToTargetVideoPlayerInfo called");
VerifyOrReturnError(videoPlayer != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread();

jclass jVideoPlayerClass;
Expand Down Expand Up @@ -241,6 +243,7 @@ CHIP_ERROR convertJDiscoveredNodeDataToCppDiscoveredNodeData(jobject jDiscovered
chip::Dnssd::DiscoveredNodeData & outCppDiscoveredNodeData)
{
ChipLogProgress(AppServer, "convertJDiscoveredNodeDataToCppDiscoveredNodeData called");
VerifyOrReturnError(jDiscoveredNodeData != nullptr, CHIP_ERROR_INVALID_ARGUMENT);

JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread();

Expand Down
Loading

0 comments on commit 8b80acc

Please sign in to comment.