Skip to content

Commit

Permalink
Merge branch 'master' into darwin_attestation_challenge
Browse files Browse the repository at this point in the history
  • Loading branch information
mburshteyn1 authored Aug 30, 2022
2 parents a61f427 + b444d25 commit 6cfda3c
Show file tree
Hide file tree
Showing 21 changed files with 170 additions and 16 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/examples-qpg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ jobs:
run: |
config/qpg/chip-gn/build.sh
- name: Prepare some bloat report from the previous builds
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
qpg qpg6105+debug lighting-app \
out/qpg-light/chip-qpg6105-lighting-example.out \
/tmp/bloat_reports/
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
qpg qpg6105+debug lock-app \
out/qpg-lock/chip-qpg6105-lock-example.out \
/tmp/bloat_reports/
- name: Uploading Size Reports
uses: actions/upload-artifact@v2
if: ${{ !env.ACT }}
Expand Down
2 changes: 2 additions & 0 deletions examples/all-clusters-app/cc13x2x7_26x2x7/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ ti_simplelink_executable("all-clusters-app") {
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/binding-handler.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp",
"${chip_root}/examples/providers/DeviceInfoProviderImpl.cpp",
"${project_dir}/main/AppTask.cpp",
"${project_dir}/main/ClusterManager.cpp",
"${project_dir}/main/Globals.cpp",
Expand All @@ -102,6 +103,7 @@ ti_simplelink_executable("all-clusters-app") {
"${project_dir}",
"${project_dir}/main",
"${chip_root}/examples/all-clusters-app/all-clusters-common/include",
"${chip_root}/examples/providers/",
]

cflags = [
Expand Down
7 changes: 7 additions & 0 deletions examples/all-clusters-app/cc13x2x7_26x2x7/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <credentials/DeviceAttestationCredsProvider.h>
#include <credentials/examples/DeviceAttestationCredsExample.h>

#include <DeviceInfoProviderImpl.h>
#include <platform/CHIPDeviceLayer.h>

#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
Expand Down Expand Up @@ -64,6 +65,7 @@ static QueueHandle_t sAppEventQueue;

static Button_Handle sAppLeftHandle;
static Button_Handle sAppRightHandle;
static DeviceInfoProviderImpl sExampleDeviceInfoProvider;

AppTask AppTask::sAppTask;

Expand Down Expand Up @@ -243,6 +245,11 @@ int AppTask::Init()
PLAT_LOG("Initialize Server");
static chip::CommonCaseDeviceServerInitParams initParams;
(void) initParams.InitializeStaticResourcesBeforeServerInit();

// Initialize info provider
sExampleDeviceInfoProvider.SetStorageDelegate(initParams.persistentStorageDelegate);
SetDeviceInfoProvider(&sExampleDeviceInfoProvider);

chip::Server::GetInstance().Init(initParams);

ConfigurationMgr().LogDeviceConfig();
Expand Down
2 changes: 2 additions & 0 deletions examples/all-clusters-minimal-app/cc13x2x7_26x2x7/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ ti_simplelink_executable("all-clusters-minimal-app") {
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/binding-handler.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp",
"${chip_root}/examples/providers/DeviceInfoProviderImpl.cpp",
"${project_dir}/main/AppTask.cpp",
"${project_dir}/main/ClusterManager.cpp",
"${project_dir}/main/Globals.cpp",
Expand All @@ -102,6 +103,7 @@ ti_simplelink_executable("all-clusters-minimal-app") {
"${project_dir}",
"${project_dir}/main",
"${chip_root}/examples/all-clusters-app/all-clusters-common/include",
"${chip_root}/examples/providers/",
]

cflags = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <credentials/DeviceAttestationCredsProvider.h>
#include <credentials/examples/DeviceAttestationCredsExample.h>

#include <DeviceInfoProviderImpl.h>
#include <platform/CHIPDeviceLayer.h>

#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
Expand Down Expand Up @@ -64,6 +65,7 @@ static QueueHandle_t sAppEventQueue;

static Button_Handle sAppLeftHandle;
static Button_Handle sAppRightHandle;
static DeviceInfoProviderImpl sExampleDeviceInfoProvider;

AppTask AppTask::sAppTask;

Expand Down Expand Up @@ -243,6 +245,11 @@ int AppTask::Init()
PLAT_LOG("Initialize Server");
static chip::CommonCaseDeviceServerInitParams initParams;
(void) initParams.InitializeStaticResourcesBeforeServerInit();

// Initialize info provider
sExampleDeviceInfoProvider.SetStorageDelegate(initParams.persistentStorageDelegate);
SetDeviceInfoProvider(&sExampleDeviceInfoProvider);

chip::Server::GetInstance().Init(initParams);

ConfigurationMgr().LogDeviceConfig();
Expand Down
2 changes: 2 additions & 0 deletions examples/lock-app/cc13x2x7_26x2x7/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ ti_simplelink_executable("lock_app") {
output_name = "chip-${ti_simplelink_board}-lock-example.out"

sources = [
"${chip_root}/examples/providers/DeviceInfoProviderImpl.cpp",
"${project_dir}/main/AppTask.cpp",
"${project_dir}/main/BoltLockManager.cpp",
"${project_dir}/main/ZclCallbacks.cpp",
Expand All @@ -96,6 +97,7 @@ ti_simplelink_executable("lock_app") {
include_dirs = [
"${project_dir}",
"${project_dir}/main",
"${chip_root}/examples/providers/",
]

cflags = [
Expand Down
7 changes: 7 additions & 0 deletions examples/lock-app/cc13x2x7_26x2x7/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <credentials/DeviceAttestationCredsProvider.h>
#include <credentials/examples/DeviceAttestationCredsExample.h>

#include <DeviceInfoProviderImpl.h>
#include <platform/CHIPDeviceLayer.h>

#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
Expand Down Expand Up @@ -63,6 +64,7 @@ static LED_Handle sAppRedHandle;
static LED_Handle sAppGreenHandle;
static Button_Handle sAppLeftHandle;
static Button_Handle sAppRightHandle;
static DeviceInfoProviderImpl sExampleDeviceInfoProvider;

AppTask AppTask::sAppTask;

Expand Down Expand Up @@ -166,6 +168,11 @@ int AppTask::Init()
PLAT_LOG("Initialize Server");
static chip::CommonCaseDeviceServerInitParams initParams;
(void) initParams.InitializeStaticResourcesBeforeServerInit();

// Initialize info provider
sExampleDeviceInfoProvider.SetStorageDelegate(initParams.persistentStorageDelegate);
SetDeviceInfoProvider(&sExampleDeviceInfoProvider);

chip::Server::GetInstance().Init(initParams);

// Initialize device attestation config
Expand Down
18 changes: 18 additions & 0 deletions src/controller/AutoCommissioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ CHIP_ERROR AutoCommissioner::SetCommissioningParameters(const CommissioningParam
}
mParams.SetCSRNonce(ByteSpan(mCSRNonce, sizeof(mCSRNonce)));

if (params.GetSkipCommissioningComplete().HasValue())
{
ChipLogProgress(Controller, "Setting PASE-only commissioning from parameters");
mParams.SetSkipCommissioningComplete(params.GetSkipCommissioningComplete().Value());
}

return CHIP_NO_ERROR;
}

Expand Down Expand Up @@ -252,6 +258,10 @@ CommissioningStage AutoCommissioner::GetNextCommissioningStageInternal(Commissio
}
else
{
if (mParams.GetSkipCommissioningComplete().ValueOr(false))
{
return CommissioningStage::kCleanup;
}
return CommissioningStage::kFindOperational;
}
case CommissioningStage::kWiFiNetworkSetup:
Expand Down Expand Up @@ -280,11 +290,19 @@ CommissioningStage AutoCommissioner::GetNextCommissioningStageInternal(Commissio
{
return CommissioningStage::kThreadNetworkEnable;
}
else if (mParams.GetSkipCommissioningComplete().ValueOr(false))
{
return CommissioningStage::kCleanup;
}
else
{
return CommissioningStage::kFindOperational;
}
case CommissioningStage::kThreadNetworkEnable:
if (mParams.GetSkipCommissioningComplete().ValueOr(false))
{
return CommissioningStage::kCleanup;
}
return CommissioningStage::kFindOperational;
case CommissioningStage::kFindOperational:
return CommissioningStage::kSendComplete;
Expand Down
8 changes: 7 additions & 1 deletion src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1572,7 +1572,6 @@ void DeviceCommissioner::CommissioningStageComplete(CHIP_ERROR err, Commissionin
{
// Once this stage is complete, reset mDeviceBeingCommissioned - this will be reset when the delegate calls the next step.
MATTER_TRACE_EVENT_SCOPE("CommissioningStageComplete", "DeviceCommissioner");

if (mDeviceBeingCommissioned == nullptr)
{
// We are getting a stray callback (e.g. due to un-cancellable
Expand Down Expand Up @@ -1654,6 +1653,13 @@ void DeviceCommissioner::OnDeviceConnectionFailureFn(void * context, const Scope
error = CHIP_ERROR_INTERNAL;
}

if (commissioner->mDeviceBeingCommissioned == nullptr ||
commissioner->mDeviceBeingCommissioned->GetDeviceId() != peerId.GetNodeId())
{
// Not the device we are trying to commission.
return;
}

if (commissioner->mCommissioningStage == CommissioningStage::kFindOperational &&
commissioner->mCommissioningDelegate != nullptr)
{
Expand Down
4 changes: 4 additions & 0 deletions src/controller/CommissioningDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ const char * StageToString(CommissioningStage stage)
return "Cleanup";
break;

case kNeedsNetworkCreds:
return "NeedsNetworkCreds";
break;

default:
return "???";
break;
Expand Down
10 changes: 10 additions & 0 deletions src/controller/CommissioningDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,15 @@ class CommissioningParameters
return *this;
}

// Only perform the PASE steps of commissioning.
// Commissioning will be completed by another admin on the network.
Optional<bool> GetSkipCommissioningComplete() const { return mSkipCommissioningComplete; }
CommissioningParameters & SetSkipCommissioningComplete(bool skipCommissioningComplete)
{
mSkipCommissioningComplete = MakeOptional(skipCommissioningComplete);
return *this;
}

private:
// Items that can be set by the commissioner
Optional<uint16_t> mFailsafeTimerSeconds;
Expand Down Expand Up @@ -407,6 +416,7 @@ class CommissioningParameters
nullptr; // Delegate to handle device attestation failures during commissioning
Optional<bool> mAttemptWiFiNetworkScan;
Optional<bool> mAttemptThreadNetworkScan; // This automatically gets set to false when a ThreadOperationalDataset is set
Optional<bool> mSkipCommissioningComplete;
};

struct RequestedCertificate
Expand Down
3 changes: 2 additions & 1 deletion src/controller/java/AndroidDeviceControllerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew(
chip::Inet::EndPointManager<Inet::UDPEndPoint> * udpEndPointManager, AndroidOperationalCredentialsIssuerPtr opCredsIssuerPtr,
jobject keypairDelegate, jbyteArray rootCertificate, jbyteArray intermediateCertificate, jbyteArray nodeOperationalCertificate,
jbyteArray ipkEpochKey, uint16_t listenPort, uint16_t controllerVendorId, uint16_t failsafeTimerSeconds,
bool attemptNetworkScanWiFi, bool attemptNetworkScanThread, CHIP_ERROR * errInfoOnFailure)
bool attemptNetworkScanWiFi, bool attemptNetworkScanThread, bool skipCommissioningComplete, CHIP_ERROR * errInfoOnFailure)
{
if (errInfoOnFailure == nullptr)
{
Expand Down Expand Up @@ -156,6 +156,7 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew(
params.SetFailsafeTimerSeconds(failsafeTimerSeconds);
params.SetAttemptWiFiNetworkScan(attemptNetworkScanWiFi);
params.SetAttemptThreadNetworkScan(attemptNetworkScanThread);
params.SetSkipCommissioningComplete(skipCommissioningComplete);
wrapper->UpdateCommissioningParameters(params);

CHIP_ERROR err = wrapper->mGroupDataProvider.Init();
Expand Down
3 changes: 2 additions & 1 deletion src/controller/java/AndroidDeviceControllerWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class AndroidDeviceControllerWrapper : public chip::Controller::DevicePairingDel
* @param[in] failsafeTimerSeconds the failsafe timer in seconds
* @param[in] attemptNetworkScanWiFi whether to attempt a network scan when configuring the network for a WiFi device
* @param[in] attemptNetworkScanThread whether to attempt a network scan when configuring the network for a Thread device
* @param[in] skipCommissioningComplete whether to skip the CASE commissioningComplete command during commissioning
* @param[out] errInfoOnFailure a pointer to a CHIP_ERROR that will be populated if this method returns nullptr
*/
static AndroidDeviceControllerWrapper *
Expand All @@ -148,7 +149,7 @@ class AndroidDeviceControllerWrapper : public chip::Controller::DevicePairingDel
AndroidOperationalCredentialsIssuerPtr opCredsIssuer, jobject keypairDelegate, jbyteArray rootCertificate,
jbyteArray intermediateCertificate, jbyteArray nodeOperationalCertificate, jbyteArray ipkEpochKey,
uint16_t listenPort, uint16_t controllerVendorId, uint16_t failsafeTimerSeconds, bool attemptNetworkScanWiFi,
bool attemptNetworkScanThread, CHIP_ERROR * errInfoOnFailure);
bool attemptNetworkScanThread, bool skipCommissioningComplete, CHIP_ERROR * errInfoOnFailure);

chip::Controller::AndroidOperationalCredentialsIssuer * GetAndroidOperationalCredentialsIssuer()
{
Expand Down
15 changes: 11 additions & 4 deletions src/controller/java/CHIPDeviceController-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self, jobject contr
&getAttemptNetworkScanThread);
SuccessOrExit(err);

jmethodID getSkipCommissioningComplete;
err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getSkipCommissioningComplete", "()Z",
&getSkipCommissioningComplete);
SuccessOrExit(err);

jmethodID getKeypairDelegate;
err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getKeypairDelegate",
"()Lchip/devicecontroller/KeypairDelegate;", &getKeypairDelegate);
Expand Down Expand Up @@ -324,6 +329,7 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self, jobject contr
uint16_t failsafeTimerSeconds = env->CallIntMethod(controllerParams, getFailsafeTimerSeconds);
bool attemptNetworkScanWiFi = env->CallBooleanMethod(controllerParams, getAttemptNetworkScanWiFi);
bool attemptNetworkScanThread = env->CallBooleanMethod(controllerParams, getAttemptNetworkScanThread);
bool skipCommissioningComplete = env->CallBooleanMethod(controllerParams, getSkipCommissioningComplete);
uint64_t adminSubject = env->CallLongMethod(controllerParams, getAdminSubject);

std::unique_ptr<chip::Controller::AndroidOperationalCredentialsIssuer> opCredsIssuer(
Expand All @@ -332,7 +338,7 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self, jobject contr
sJVM, self, kLocalDeviceId, fabricId, chip::kUndefinedCATs, &DeviceLayer::SystemLayer(),
DeviceLayer::TCPEndPointManager(), DeviceLayer::UDPEndPointManager(), std::move(opCredsIssuer), keypairDelegate,
rootCertificate, intermediateCertificate, operationalCertificate, ipk, listenPort, controllerVendorId,
failsafeTimerSeconds, attemptNetworkScanWiFi, attemptNetworkScanThread, &err);
failsafeTimerSeconds, attemptNetworkScanWiFi, attemptNetworkScanThread, skipCommissioningComplete, &err);
SuccessOrExit(err);

if (adminSubject != kUndefinedNodeId)
Expand Down Expand Up @@ -384,7 +390,7 @@ JNI_METHOD(void, commissionDevice)

ChipLogProgress(Controller, "commissionDevice() called");

CommissioningParameters commissioningParams = CommissioningParameters();
CommissioningParameters commissioningParams = wrapper->GetCommissioningParameters();
if (networkCredentials != nullptr)
{
err = wrapper->ApplyNetworkCredentials(commissioningParams, networkCredentials);
Expand Down Expand Up @@ -422,7 +428,7 @@ JNI_METHOD(void, pairDevice)
#endif
.SetPeerAddress(Transport::PeerAddress::BLE());

CommissioningParameters commissioningParams = CommissioningParameters();
CommissioningParameters commissioningParams = wrapper->GetCommissioningParameters();
wrapper->ApplyNetworkCredentials(commissioningParams, networkCredentials);

if (csrNonce != nullptr)
Expand Down Expand Up @@ -456,7 +462,8 @@ JNI_METHOD(void, pairDeviceWithAddress)
.SetDiscriminator(discriminator)
.SetSetupPINCode(pinCode)
.SetPeerAddress(Transport::PeerAddress::UDP(const_cast<char *>(addrJniString.c_str()), port));
CommissioningParameters commissioningParams = CommissioningParameters();

CommissioningParameters commissioningParams = wrapper->GetCommissioningParameters();
if (csrNonce != nullptr)
{
JniByteArray jniCsrNonce(env, csrNonce);
Expand Down
Loading

0 comments on commit 6cfda3c

Please sign in to comment.