Skip to content

Commit 5733465

Browse files
carol-applepull[bot]
authored andcommitted
Add logging for OTA QueryImage, AnnounceOTAProvider, and BDX Output Event 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
1 parent 98d6313 commit 5733465

File tree

6 files changed

+53
-5
lines changed

6 files changed

+53
-5
lines changed

examples/ota-provider-app/ota-provider-common/BdxOtaSender.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void BdxOtaSender::HandleTransferSessionOutput(TransferSession::OutputEvent & ev
5353

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

5959
switch (event.EventType)

examples/ota-requestor-app/ota-requestor-common/BDXDownloader.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void BdxDownloader::HandleTransferSessionOutput(TransferSession::OutputEvent & e
4040

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

4646
switch (event.EventType)

examples/ota-requestor-app/ota-requestor-common/ExampleOTARequestor.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,15 @@ EmberAfStatus ExampleOTARequestor::HandleAnnounceOTAProvider(
9191
mProviderNodeId = providerLocation;
9292
mProviderFabricIndex = commandObj->GetExchangeContext()->GetSessionHandle().GetFabricIndex();
9393

94-
ChipLogProgress(SoftwareUpdate, "Notified of Provider at NodeID: 0x" ChipLogFormatX64 " on FabricIndex 0x%" PRIu8,
95-
ChipLogValueX64(mProviderNodeId), mProviderFabricIndex);
94+
ChipLogProgress(SoftwareUpdate, "OTA Requestor received AnnounceOTAProvider");
95+
ChipLogDetail(SoftwareUpdate, " FabricIndex: %" PRIu8, mProviderFabricIndex);
96+
ChipLogDetail(SoftwareUpdate, " ProviderNodeID: 0x" ChipLogFormatX64, ChipLogValueX64(mProviderNodeId));
97+
ChipLogDetail(SoftwareUpdate, " VendorID: 0x%" PRIx16, commandData.vendorId);
98+
ChipLogDetail(SoftwareUpdate, " AnnouncementReason: %" PRIu8, announcementReason);
99+
if (commandData.metadataForNode.HasValue())
100+
{
101+
ChipLogDetail(SoftwareUpdate, " MetadataForNode: %zu", commandData.metadataForNode.Value().size());
102+
}
96103

97104
// If reason is URGENT_UPDATE_AVAILABLE, we start OTA immediately. Otherwise, respect the timer value set in mOtaStartDelayMs.
98105
// This is done to exemplify what a real-world OTA Requestor might do while also being configurable enough to use as a test app.

src/app/clusters/ota-provider/ota-provider.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,15 @@ bool emberAfOtaSoftwareUpdateProviderClusterQueryImageCallback(app::CommandHandl
184184
return true;
185185
};
186186

187-
ChipLogDetail(Zcl, "OTA Provider received QueryImage");
187+
ChipLogProgress(Zcl, "OTA Provider received QueryImage");
188+
ChipLogDetail(Zcl, " VendorID: 0x%" PRIx16, vendorId);
189+
ChipLogDetail(Zcl, " ProductID: %" PRIu16, productId);
190+
ChipLogDetail(Zcl, " SoftwareVersion: %" PRIu32, softwareVersion);
191+
ChipLogDetail(Zcl, " ProtocolsSupported: %" PRIu8, protocolsSupported);
192+
ChipLogDetail(Zcl, " HardwareVersion: %" PRIu16, hardwareVersion);
193+
ChipLogDetail(Zcl, " Location: %.*s", static_cast<int>(location.size()), location.data());
194+
ChipLogDetail(Zcl, " RequestorCanConsent: %" PRIu8, requestorCanConsent);
195+
ChipLogDetail(Zcl, " MetadataForProvider: %zu", metadataForProvider.size());
188196

189197
if (location.size() != kLocationLen)
190198
{

src/protocols/bdx/BdxTransferSession.cpp

+31
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,37 @@ bool TransferSession::IsTransferLengthDefinite()
774774
return (mTransferLength > 0);
775775
}
776776

777+
const char * TransferSession::OutputEvent::ToString(OutputEventType outputEventType)
778+
{
779+
switch (outputEventType)
780+
{
781+
case OutputEventType::kNone:
782+
return "None";
783+
case OutputEventType::kMsgToSend:
784+
return "MsgToSend";
785+
case OutputEventType::kInitReceived:
786+
return "InitReceived";
787+
case OutputEventType::kAcceptReceived:
788+
return "AcceptReceived";
789+
case OutputEventType::kBlockReceived:
790+
return "BlockReceived";
791+
case OutputEventType::kQueryReceived:
792+
return "QueryReceived";
793+
case OutputEventType::kAckReceived:
794+
return "AckReceived";
795+
case OutputEventType::kAckEOFReceived:
796+
return "AckEOFReceived";
797+
case OutputEventType::kStatusReceived:
798+
return "StatusReceived";
799+
case OutputEventType::kInternalError:
800+
return "InternalError";
801+
case OutputEventType::kTransferTimeout:
802+
return "TransferTimeout";
803+
default:
804+
return "Unknown";
805+
}
806+
}
807+
777808
TransferSession::OutputEvent TransferSession::OutputEvent::TransferInitEvent(TransferInitData data, System::PacketBufferHandle msg)
778809
{
779810
OutputEvent event(OutputEventType::kInitReceived);

src/protocols/bdx/BdxTransferSession.h

+2
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ class DLL_EXPORT TransferSession
125125
OutputEvent() : EventType(OutputEventType::kNone) { statusData = { StatusCode::kNone }; }
126126
OutputEvent(OutputEventType type) : EventType(type) { statusData = { StatusCode::kNone }; }
127127

128+
const char * ToString(OutputEventType outputEventType);
129+
128130
static OutputEvent TransferInitEvent(TransferInitData data, System::PacketBufferHandle msg);
129131
static OutputEvent TransferAcceptEvent(TransferAcceptData data);
130132
static OutputEvent TransferAcceptEvent(TransferAcceptData data, System::PacketBufferHandle msg);

0 commit comments

Comments
 (0)