Skip to content

Commit

Permalink
Add logging for OTA QueryImage, AnnounceOTAProvider, and BDX Output E…
Browse files Browse the repository at this point in the history
…vent Type (#11241)

* Add logging for OTA QueryImage, AnnounceOTAProvider, and BDX Output Event Type

- These logs are to be parsed from testing side for test validation

* Use suggested format specifiers

* Only print the size of TLV fields
  • Loading branch information
carol-apple authored and pull[bot] committed Dec 20, 2021
1 parent 89ee8be commit 1082324
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void BdxOtaSender::HandleTransferSessionOutput(TransferSession::OutputEvent & ev

if (event.EventType != TransferSession::OutputEventType::kNone)
{
ChipLogDetail(BDX, "OutputEvent type: %d", static_cast<uint16_t>(event.EventType));
ChipLogDetail(BDX, "OutputEvent type: %s", event.ToString(event.EventType));
}

switch (event.EventType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void BdxDownloader::HandleTransferSessionOutput(TransferSession::OutputEvent & e

if (event.EventType != TransferSession::OutputEventType::kNone)
{
ChipLogDetail(BDX, "OutputEvent type: %d", static_cast<uint16_t>(event.EventType));
ChipLogDetail(BDX, "OutputEvent type: %s", event.ToString(event.EventType));
}

switch (event.EventType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,15 @@ EmberAfStatus ExampleOTARequestor::HandleAnnounceOTAProvider(
mProviderNodeId = providerLocation;
mProviderFabricIndex = commandObj->GetExchangeContext()->GetSessionHandle().GetFabricIndex();

ChipLogProgress(SoftwareUpdate, "Notified of Provider at NodeID: 0x" ChipLogFormatX64 " on FabricIndex 0x%" PRIu8,
ChipLogValueX64(mProviderNodeId), mProviderFabricIndex);
ChipLogProgress(SoftwareUpdate, "OTA Requestor received AnnounceOTAProvider");
ChipLogDetail(SoftwareUpdate, " FabricIndex: %" PRIu8, mProviderFabricIndex);
ChipLogDetail(SoftwareUpdate, " ProviderNodeID: 0x" ChipLogFormatX64, ChipLogValueX64(mProviderNodeId));
ChipLogDetail(SoftwareUpdate, " VendorID: 0x%" PRIx16, commandData.vendorId);
ChipLogDetail(SoftwareUpdate, " AnnouncementReason: %" PRIu8, announcementReason);
if (commandData.metadataForNode.HasValue())
{
ChipLogDetail(SoftwareUpdate, " MetadataForNode: %zu", commandData.metadataForNode.Value().size());
}

// If reason is URGENT_UPDATE_AVAILABLE, we start OTA immediately. Otherwise, respect the timer value set in mOtaStartDelayMs.
// This is done to exemplify what a real-world OTA Requestor might do while also being configurable enough to use as a test app.
Expand Down
10 changes: 9 additions & 1 deletion src/app/clusters/ota-provider/ota-provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,15 @@ bool emberAfOtaSoftwareUpdateProviderClusterQueryImageCallback(app::CommandHandl
return true;
};

ChipLogDetail(Zcl, "OTA Provider received QueryImage");
ChipLogProgress(Zcl, "OTA Provider received QueryImage");
ChipLogDetail(Zcl, " VendorID: 0x%" PRIx16, vendorId);
ChipLogDetail(Zcl, " ProductID: %" PRIu16, productId);
ChipLogDetail(Zcl, " SoftwareVersion: %" PRIu32, softwareVersion);
ChipLogDetail(Zcl, " ProtocolsSupported: %" PRIu8, protocolsSupported);
ChipLogDetail(Zcl, " HardwareVersion: %" PRIu16, hardwareVersion);
ChipLogDetail(Zcl, " Location: %.*s", static_cast<int>(location.size()), location.data());
ChipLogDetail(Zcl, " RequestorCanConsent: %" PRIu8, requestorCanConsent);
ChipLogDetail(Zcl, " MetadataForProvider: %zu", metadataForProvider.size());

if (location.size() != kLocationLen)
{
Expand Down
31 changes: 31 additions & 0 deletions src/protocols/bdx/BdxTransferSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,37 @@ bool TransferSession::IsTransferLengthDefinite()
return (mTransferLength > 0);
}

const char * TransferSession::OutputEvent::ToString(OutputEventType outputEventType)
{
switch (outputEventType)
{
case OutputEventType::kNone:
return "None";
case OutputEventType::kMsgToSend:
return "MsgToSend";
case OutputEventType::kInitReceived:
return "InitReceived";
case OutputEventType::kAcceptReceived:
return "AcceptReceived";
case OutputEventType::kBlockReceived:
return "BlockReceived";
case OutputEventType::kQueryReceived:
return "QueryReceived";
case OutputEventType::kAckReceived:
return "AckReceived";
case OutputEventType::kAckEOFReceived:
return "AckEOFReceived";
case OutputEventType::kStatusReceived:
return "StatusReceived";
case OutputEventType::kInternalError:
return "InternalError";
case OutputEventType::kTransferTimeout:
return "TransferTimeout";
default:
return "Unknown";
}
}

TransferSession::OutputEvent TransferSession::OutputEvent::TransferInitEvent(TransferInitData data, System::PacketBufferHandle msg)
{
OutputEvent event(OutputEventType::kInitReceived);
Expand Down
2 changes: 2 additions & 0 deletions src/protocols/bdx/BdxTransferSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ class DLL_EXPORT TransferSession
OutputEvent() : EventType(OutputEventType::kNone) { statusData = { StatusCode::kNone }; }
OutputEvent(OutputEventType type) : EventType(type) { statusData = { StatusCode::kNone }; }

const char * ToString(OutputEventType outputEventType);

static OutputEvent TransferInitEvent(TransferInitData data, System::PacketBufferHandle msg);
static OutputEvent TransferAcceptEvent(TransferAcceptData data);
static OutputEvent TransferAcceptEvent(TransferAcceptData data, System::PacketBufferHandle msg);
Expand Down

0 comments on commit 1082324

Please sign in to comment.