Skip to content

Commit

Permalink
use CHIP_ERROR_FORMAT
Browse files Browse the repository at this point in the history
  • Loading branch information
holbrookt committed Oct 25, 2021
1 parent c6249e6 commit d7c9eaa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
8 changes: 5 additions & 3 deletions examples/ota-requestor-app/linux/ExampleSelfCommissioning.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ CHIP_ERROR DoExampleSelfCommissioning(DeviceController & controller, ExampleOper
VerifyOrExit(storage != nullptr && opCredsIssuer != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT);

err = opCredsIssuer->Initialize(*storage);
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Init failure! Operational Cred Issuer: %s", err.Format()));
VerifyOrExit(err == CHIP_NO_ERROR,
ChipLogError(Controller, "Init failure! Operational Cred Issuer: %" CHIP_ERROR_FORMAT, err.Format()));

VerifyOrExit(rcac.Alloc(chip::Controller::kMaxCHIPDERCertLength), err = CHIP_ERROR_NO_MEMORY);
VerifyOrExit(noc.Alloc(chip::Controller::kMaxCHIPDERCertLength), err = CHIP_ERROR_NO_MEMORY);
Expand Down Expand Up @@ -74,10 +75,11 @@ CHIP_ERROR DoExampleSelfCommissioning(DeviceController & controller, ExampleOper
auto & factory = chip::Controller::DeviceControllerFactory::GetInstance();

err = factory.Init(initParams);
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Controller Factory init failure! %s", err.Format()));
VerifyOrExit(err == CHIP_NO_ERROR,
ChipLogError(Controller, "Controller Factory init failure! %" CHIP_ERROR_FORMAT, err.Format()));

err = factory.SetupController(setupParams, controller);
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Controller init failure! %s", err.Format()));
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Controller init failure! %" CHIP_ERROR_FORMAT, err.Format()));
}

exit:
Expand Down
20 changes: 9 additions & 11 deletions examples/ota-requestor-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,21 @@ void OnConnection(void * context, Device * device)
err = cluster.Associate(device, kOtaProviderEndpoint);
if (err != CHIP_NO_ERROR)
{
ChipLogError(SoftwareUpdate, "Associate() failed: %s", err.Format());
ChipLogError(SoftwareUpdate, "Associate() failed: %" CHIP_ERROR_FORMAT, err.Format());
return;
}
err = cluster.QueryImage(successCallback, failureCallback, kExampleVendorId, kExampleProductId, kExampleHWVersion,
kExampleSoftwareVersion, kExampleProtocolsSupported, exampleLocation, kExampleClientCanConsent,
metadata);
if (err != CHIP_NO_ERROR)
{
ChipLogError(SoftwareUpdate, "QueryImage() failed: %s", err.Format());
ChipLogError(SoftwareUpdate, "QueryImage() failed: %" CHIP_ERROR_FORMAT, err.Format());
}
}

void OnConnectFail(void * context, chip::NodeId deviceId, CHIP_ERROR error)
{
ChipLogError(SoftwareUpdate, "failed to connect to 0x%" PRIX64 ": %s", deviceId, chip::ErrorStr(error));
ChipLogError(SoftwareUpdate, "failed to connect to 0x%" PRIX64 ": %" CHIP_ERROR_FORMAT, deviceId, error.Format());
}

Callback<OnDeviceConnected> mConnectionCallback(OnConnection, nullptr);
Expand Down Expand Up @@ -261,20 +261,18 @@ int main(int argc, char * argv[])

chip::DeviceLayer::ConfigurationMgr().LogDeviceConfig();
err = mStorage.Init();
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Init Storage failure: %s", err.Format()));
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Init Storage failure: %" CHIP_ERROR_FORMAT, err.Format()));

chip::Logging::SetLogFilter(mStorage.GetLoggingLevel());

VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "failed to set UDP port: %s", err.Format()));

err = chip::DeviceLayer::ConfigurationMgr().StoreSetupDiscriminator(setupDiscriminator);
if (err == CHIP_NO_ERROR)
{
ChipLogProgress(SoftwareUpdate, "Setup discriminator set to: %d \n", setupDiscriminator);
}
else
{
ChipLogError(SoftwareUpdate, "Setup discriminator setting failed with code: %s \n", chip::ErrorStr(err));
ChipLogError(SoftwareUpdate, "Setup discriminator setting failed with code: %" CHIP_ERROR_FORMAT "\n", err.Format());
goto exit;
}

Expand Down Expand Up @@ -302,25 +300,25 @@ int main(int argc, char * argv[])
err = DoExampleSelfCommissioning(mController, &mOpCredsIssuer, &mStorage, mStorage.GetLocalNodeId(),
mStorage.GetListenPort());
VerifyOrExit(err == CHIP_NO_ERROR,
ChipLogError(SoftwareUpdate, "example self-commissioning failed: %s", chip::ErrorStr(err)));
ChipLogError(SoftwareUpdate, "example self-commissioning failed: %" CHIP_ERROR_FORMAT, err.Format()));

err = chip::Controller::DeviceControllerFactory::GetInstance().ServiceEvents();
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "ServiceEvents() failed: %s", chip::ErrorStr(err)));
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "ServiceEvents() failed: %" CHIP_ERROR_FORMAT, err.Format()));

ChipLogProgress(SoftwareUpdate, "Attempting to connect to device 0x%" PRIX64, providerNodeId);

// WARNING: In order for this to work, you must first commission the OTA Provider device using chip-tool.
// Currently, that pairing action will persist the CASE session in persistent memory, which will then be read by the
// following call.
err = mController.GetDevice(providerNodeId, &providerDevice);
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "No device found: %s", chip::ErrorStr(err)));
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "No device found: %" CHIP_ERROR_FORMAT, err.Format()));

err = providerDevice->EstablishConnectivity(&mConnectionCallback, &mConnectFailCallback);
}

chip::DeviceLayer::PlatformMgr().RunEventLoop();

exit:
ChipLogDetail(SoftwareUpdate, "%s", ErrorStr(err));
ChipLogDetail(SoftwareUpdate, "%" CHIP_ERROR_FORMAT, err.Format());
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void BdxDownloader::HandleTransferSessionOutput(TransferSession::OutputEvent & e
}
err = mExchangeCtx->SendMessage(event.msgTypeData.ProtocolId, event.msgTypeData.MessageType, std::move(event.MsgData),
sendFlags);
VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(BDX, "SendMessage failed: %s", err.Format()));
VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(BDX, "SendMessage failed: %" CHIP_ERROR_FORMAT, err.Format()));
break;
}
case TransferSession::OutputEventType::kAcceptReceived:
Expand All @@ -83,13 +83,13 @@ void BdxDownloader::HandleTransferSessionOutput(TransferSession::OutputEvent & e
if (event.blockdata.IsEof)
{
err = mTransfer.PrepareBlockAck();
VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(BDX, "PrepareBlockAck failed: %s", err.Format()));
VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(BDX, "PrepareBlockAck failed: %" CHIP_ERROR_FORMAT, err.Format()));
mIsTransferComplete = true;
}
else
{
err = mTransfer.PrepareBlockQuery();
VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(BDX, "PrepareBlockQuery failed: %s", err.Format()));
VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(BDX, "PrepareBlockQuery failed: %" CHIP_ERROR_FORMAT, err.Format()));
}
break;
}
Expand Down

0 comments on commit d7c9eaa

Please sign in to comment.