Skip to content

Commit

Permalink
Fix casting lifecycle issues (#20138)
Browse files Browse the repository at this point in the history
chrisdecenzo authored Jun 30, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent a45d571 commit 39a8af0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions examples/platform/linux/CommissionerMain.cpp
Original file line number Diff line number Diff line change
@@ -117,6 +117,7 @@ MyServerStorageDelegate gServerStorage;
ExampleOperationalCredentialsIssuer gOpCredsIssuer;
NodeId gLocalId = kMaxOperationalNodeId;
Credentials::GroupDataProviderImpl gGroupDataProvider;
AutoCommissioner gAutoCommissioner;

CHIP_ERROR InitCommissioner(uint16_t commissionerPort, uint16_t udcListenPort)
{
@@ -172,6 +173,8 @@ CHIP_ERROR InitCommissioner(uint16_t commissionerPort, uint16_t udcListenPort)
params.controllerICAC = icacSpan;
params.controllerNOC = nocSpan;

params.defaultCommissioner = &gAutoCommissioner;

auto & factory = Controller::DeviceControllerFactory::GetInstance();
ReturnErrorOnFailure(factory.Init(factoryParams));
ReturnErrorOnFailure(factory.SetupCommissioner(params, gCommissioner));
@@ -322,10 +325,10 @@ void PairingCommand::OnDeviceConnectedFn(void * context, chip::OperationalDevice

if (cdc != nullptr)
{
// TODO: get from DAC!
UDCClientState * udc = cdc->GetUDCClientState();
uint16_t vendorId = (udc == nullptr ? 0 : udc->GetVendorId());
uint16_t productId = (udc == nullptr ? 0 : udc->GetProductId());
uint16_t vendorId = gAutoCommissioner.GetCommissioningParameters().GetRemoteVendorId().Value();
uint16_t productId = gAutoCommissioner.GetCommissioningParameters().GetRemoteProductId().Value();
ChipLogProgress(Support, " ----- AutoCommissioner -- Commissionee vendorId=0x%04X productId=0x%04X", vendorId, productId);

cdc->CommissioningSucceeded(vendorId, productId, gRemoteId, device);
}
}
@@ -345,6 +348,7 @@ CHIP_ERROR CommissionerPairOnNetwork(uint32_t pincode, uint16_t disc, Transport:
{
RendezvousParameters params = RendezvousParameters().SetSetupPINCode(pincode).SetDiscriminator(disc).SetPeerAddress(address);

gOpCredsIssuer.GetRandomOperationalNodeId(&gRemoteId);
gCommissioner.RegisterPairingDelegate(&gPairingCommand);
gCommissioner.PairDevice(gRemoteId, params);

0 comments on commit 39a8af0

Please sign in to comment.