Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Nov 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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