Skip to content

Commit

Permalink
Fix casting lifecycle issues (#20138)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdecenzo authored and pull[bot] committed Nov 9, 2023
1 parent b2f2781 commit 0b7b739
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
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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);

Expand Down

0 comments on commit 0b7b739

Please sign in to comment.