[tmf] add UriToString() for logging (#8930)

This commit adds a helper function `UriToString<Uri>()` to convert
a given `Uri` enumeration value to a human-readable string. This is
used for logging.
This commit is contained in:
Abtin Keshavarzian
2023-04-05 18:00:30 -07:00
committed by GitHub
parent cbdabbc542
commit adde085fce
17 changed files with 163 additions and 71 deletions
+1 -1
View File
@@ -85,7 +85,7 @@ Error AnnounceBeginClient::SendRequest(uint32_t aChannelMask,
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo));
LogInfo("sent announce begin query");
LogInfo("Sent %s", UriToString<kUriAnnounceBegin>());
exit:
FreeMessageOnError(message, error);
+14 -14
View File
@@ -695,7 +695,7 @@ Error Commissioner::SendMgmtCommissionerGetRequest(const uint8_t *aTlvs, uint8_t
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo,
Commissioner::HandleMgmtCommissionerGetResponse, this));
LogInfo("sent MGMT_COMMISSIONER_GET.req to leader");
LogInfo("Sent %s to leader", UriToString<kUriCommissionerGet>());
exit:
FreeMessageOnError(message, error);
@@ -718,7 +718,7 @@ void Commissioner::HandleMgmtCommissionerGetResponse(Coap::Message *aMe
OT_UNUSED_VARIABLE(aMessageInfo);
VerifyOrExit(aResult == kErrorNone && aMessage->GetCode() == Coap::kCodeChanged);
LogInfo("received MGMT_COMMISSIONER_GET response");
LogInfo("Received %s response", UriToString<kUriCommissionerGet>());
exit:
return;
@@ -764,7 +764,7 @@ Error Commissioner::SendMgmtCommissionerSetRequest(const Dataset &aDataset, cons
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo,
Commissioner::HandleMgmtCommissionerSetResponse, this));
LogInfo("sent MGMT_COMMISSIONER_SET.req to leader");
LogInfo("Sent %s to leader", UriToString<kUriCommissionerSet>());
exit:
FreeMessageOnError(message, error);
@@ -787,7 +787,7 @@ void Commissioner::HandleMgmtCommissionerSetResponse(Coap::Message *aMe
OT_UNUSED_VARIABLE(aMessageInfo);
VerifyOrExit(aResult == kErrorNone && aMessage->GetCode() == Coap::kCodeChanged);
LogInfo("received MGMT_COMMISSIONER_SET response");
LogInfo("Received %s response", UriToString<kUriCommissionerSet>());
exit:
return;
@@ -813,7 +813,7 @@ Error Commissioner::SendPetition(void)
SuccessOrExit(
error = Get<Tmf::Agent>().SendMessage(*message, messageInfo, Commissioner::HandleLeaderPetitionResponse, this));
LogInfo("sent petition");
LogInfo("Sent %s", UriToString<kUriLeaderPetition>());
exit:
FreeMessageOnError(message, error);
@@ -842,7 +842,7 @@ void Commissioner::HandleLeaderPetitionResponse(Coap::Message *aMessage
VerifyOrExit(aResult == kErrorNone && aMessage->GetCode() == Coap::kCodeChanged,
retransmit = (mState == kStatePetition));
LogInfo("received Leader Petition response");
LogInfo("Received %s response", UriToString<kUriLeaderPetition>());
SuccessOrExit(Tlv::Find<StateTlv>(*aMessage, state));
VerifyOrExit(state == StateTlv::kAccept, IgnoreError(Stop(kDoNotSendKeepAlive)));
@@ -900,7 +900,7 @@ void Commissioner::SendKeepAlive(uint16_t aSessionId)
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo,
Commissioner::HandleLeaderKeepAliveResponse, this));
LogInfo("sent keep alive");
LogInfo("Sent %s", UriToString<kUriLeaderKeepAlive>());
exit:
FreeMessageOnError(message, error);
@@ -928,7 +928,7 @@ void Commissioner::HandleLeaderKeepAliveResponse(Coap::Message *aMessag
VerifyOrExit(aResult == kErrorNone && aMessage->GetCode() == Coap::kCodeChanged,
IgnoreError(Stop(kDoNotSendKeepAlive)));
LogInfo("received Leader keep-alive response");
LogInfo("Received %s response", UriToString<kUriLeaderKeepAlive>());
SuccessOrExit(Tlv::Find<StateTlv>(*aMessage, state));
VerifyOrExit(state == StateTlv::kAccept, IgnoreError(Stop(kDoNotSendKeepAlive)));
@@ -985,7 +985,7 @@ template <> void Commissioner::HandleTmf<kUriRelayRx>(Coap::Message &aMessage, c
{
if (mJoinerIid != joinerIid)
{
LogNote("Ignore Relay Receive (%s, 0x%04x), session in progress with (%s, 0x%04x)",
LogNote("Ignore %s (%s, 0x%04x), session in progress with (%s, 0x%04x)", UriToString<kUriRelayRx>(),
joinerIid.ToString().AsCString(), joinerRloc, mJoinerIid.ToString().AsCString(), mJoinerRloc);
ExitNow();
@@ -995,7 +995,7 @@ template <> void Commissioner::HandleTmf<kUriRelayRx>(Coap::Message &aMessage, c
mJoinerPort = joinerPort;
mJoinerRloc = joinerRloc;
LogInfo("Received Relay Receive (%s, 0x%04x)", mJoinerIid.ToString().AsCString(), mJoinerRloc);
LogInfo("Received %s (%s, 0x%04x)", UriToString<kUriRelayRx>(), mJoinerIid.ToString().AsCString(), mJoinerRloc);
aMessage.SetOffset(offset);
SuccessOrExit(error = aMessage.SetLength(offset + length));
@@ -1026,11 +1026,11 @@ void Commissioner::HandleTmf<kUriDatasetChanged>(Coap::Message &aMessage, const
VerifyOrExit(mState == kStateActive);
VerifyOrExit(aMessage.IsConfirmablePostRequest());
LogInfo("received dataset changed");
LogInfo("Received %s", UriToString<kUriDatasetChanged>());
SuccessOrExit(Get<Tmf::Agent>().SendEmptyAck(aMessage, aMessageInfo));
LogInfo("sent dataset changed acknowledgment");
LogInfo("Sent %s ack", UriToString<kUriDatasetChanged>());
exit:
return;
@@ -1046,7 +1046,7 @@ void Commissioner::HandleTmf<kUriJoinerFinalize>(Coap::Message &aMessage, const
VerifyOrExit(mState == kStateActive);
LogInfo("received joiner finalize");
LogInfo("Received %s", UriToString<kUriJoinerFinalize>());
switch (Tlv::Find<ProvisioningUrlTlv>(aMessage, provisioningUrl))
{
@@ -1116,7 +1116,7 @@ void Commissioner::SendJoinFinalizeResponse(const Coap::Message &aRequest, State
RemoveJoiner(*mActiveJoiner, kRemoveJoinerDelay);
}
LogInfo("sent joiner finalize response");
LogInfo("Sent %s response", UriToString<kUriJoinerFinalize>());
exit:
FreeMessageOnError(message, error);
+3 -3
View File
@@ -91,7 +91,7 @@ Error EnergyScanClient::SendQuery(uint32_t aChannelMas
messageInfo.SetSockAddrToRlocPeerAddrTo(aAddress);
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo));
LogInfo("sent query");
LogInfo("Sent %s", UriToString<kUriEnergyScan>());
mCallback.Set(aCallback, aContext);
@@ -108,7 +108,7 @@ void EnergyScanClient::HandleTmf<kUriEnergyReport>(Coap::Message &aMessage, cons
VerifyOrExit(aMessage.IsConfirmablePostRequest());
LogInfo("received report");
LogInfo("Received %s", UriToString<kUriEnergyReport>());
VerifyOrExit((mask = MeshCoP::ChannelMaskTlv::GetChannelMask(aMessage)) != 0);
@@ -118,7 +118,7 @@ void EnergyScanClient::HandleTmf<kUriEnergyReport>(Coap::Message &aMessage, cons
SuccessOrExit(Get<Tmf::Agent>().SendEmptyAck(aMessage, aMessageInfo));
LogInfo("sent report response");
LogInfo("Sent %s ack", UriToString<kUriEnergyReport>());
exit:
return;
+4 -4
View File
@@ -486,7 +486,7 @@ void Joiner::SendJoinerFinalize(void)
SuccessOrExit(Get<Tmf::SecureAgent>().SendMessage(*mFinalizeMessage, Joiner::HandleJoinerFinalizeResponse, this));
mFinalizeMessage = nullptr;
LogInfo("Joiner sent finalize");
LogInfo("Sent %s", UriToString<kUriJoinerFinalize>());
exit:
return;
@@ -517,7 +517,7 @@ void Joiner::HandleJoinerFinalizeResponse(Coap::Message *aMessage, const Ip6::Me
SetState(kStateEntrust);
mTimer.Start(kReponseTimeout);
LogInfo("Joiner received finalize response %d", state);
LogInfo("Received %s %d", UriToString<kUriJoinerFinalize>(), state);
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
LogCertMessage("[THCI] direction=recv | type=JOIN_FIN.rsp |", *aMessage);
@@ -535,7 +535,7 @@ template <> void Joiner::HandleTmf<kUriJoinerEntrust>(Coap::Message &aMessage, c
VerifyOrExit(mState == kStateEntrust && aMessage.IsConfirmablePostRequest(), error = kErrorDrop);
LogInfo("Joiner received entrust");
LogInfo("Received %s", UriToString<kUriJoinerEntrust>());
LogCert("[THCI] direction=recv | type=JOIN_ENT.ntf");
datasetInfo.Clear();
@@ -574,7 +574,7 @@ void Joiner::SendJoinerEntrustResponse(const Coap::Message &aRequest, const Ip6:
SetState(kStateJoined);
LogInfo("Joiner sent entrust response");
LogInfo("Sent %s response", UriToString<kUriJoinerEntrust>());
LogCert("[THCI] direction=send | type=JOIN_ENT.rsp");
exit:
+4 -5
View File
@@ -155,7 +155,7 @@ void JoinerRouter::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &a
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo));
LogInfo("Sent relay rx");
LogInfo("Sent %s", UriToString<kUriRelayRx>());
exit:
FreeMessageOnError(message, error);
@@ -177,7 +177,7 @@ template <> void JoinerRouter::HandleTmf<kUriRelayTx>(Coap::Message &aMessage, c
VerifyOrExit(aMessage.IsNonConfirmablePostRequest(), error = kErrorDrop);
LogInfo("Received relay transmit");
LogInfo("Received %s", UriToString<kUriRelayTx>());
SuccessOrExit(error = Tlv::Find<JoinerUdpPortTlv>(aMessage, joinerPort));
SuccessOrExit(error = Tlv::Find<JoinerIidTlv>(aMessage, joinerIid));
@@ -273,11 +273,10 @@ Error JoinerRouter::SendJoinerEntrust(const Ip6::MessageInfo &aMessageInfo)
IgnoreError(Get<Tmf::Agent>().AbortTransaction(&JoinerRouter::HandleJoinerEntrustResponse, this));
LogInfo("Sending JOIN_ENT.ntf");
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, aMessageInfo,
&JoinerRouter::HandleJoinerEntrustResponse, this));
LogInfo("Sent joiner entrust length = %d", message->GetLength());
LogInfo("Sent %s (len= %d)", UriToString<kUriJoinerEntrust>(), message->GetLength());
LogCert("[THCI] direction=send | type=JOIN_ENT.ntf");
exit:
@@ -382,7 +381,7 @@ void JoinerRouter::HandleJoinerEntrustResponse(Coap::Message *aMessage,
VerifyOrExit(aMessage->GetCode() == Coap::kCodeChanged);
LogInfo("Receive joiner entrust response");
LogInfo("Receive %s response", UriToString<kUriJoinerEntrust>());
LogCert("[THCI] direction=recv | type=JOIN_ENT.rsp");
exit:
+5 -5
View File
@@ -71,7 +71,7 @@ template <> void Leader::HandleTmf<kUriLeaderPetition>(Coap::Message &aMessage,
CommissionerIdTlv commissionerId;
StateTlv::State state = StateTlv::kReject;
LogInfo("received petition");
LogInfo("Received %s", UriToString<kUriLeaderPetition>());
VerifyOrExit(Get<Mle::MleRouter>().IsRoutingLocator(aMessageInfo.GetPeerAddr()));
SuccessOrExit(Tlv::FindTlv(aMessage, commissionerId));
@@ -136,7 +136,7 @@ void Leader::SendPetitionResponse(const Coap::Message &aRequest,
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, aMessageInfo));
LogInfo("sent petition response");
LogInfo("Sent %s response", UriToString<kUriLeaderPetition>());
exit:
FreeMessageOnError(message, error);
@@ -150,7 +150,7 @@ template <> void Leader::HandleTmf<kUriLeaderKeepAlive>(Coap::Message &aMessage,
BorderAgentLocatorTlv *borderAgentLocator;
StateTlv::State responseState;
LogInfo("received keep alive");
LogInfo("Received %s", UriToString<kUriLeaderKeepAlive>());
SuccessOrExit(Tlv::Find<StateTlv>(aMessage, state));
@@ -202,7 +202,7 @@ void Leader::SendKeepAliveResponse(const Coap::Message &aRequest,
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, aMessageInfo));
LogInfo("sent keep alive response");
LogInfo("Sent %s response", UriToString<kUriLeaderKeepAlive>());
exit:
FreeMessageOnError(message, error);
@@ -221,7 +221,7 @@ void Leader::SendDatasetChanged(const Ip6::Address &aAddress)
messageInfo.SetSockAddrToRlocPeerAddrTo(aAddress);
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo));
LogInfo("sent dataset changed");
LogInfo("Sent %s", UriToString<kUriDatasetChanged>());
exit:
FreeMessageOnError(message, error);
+3 -3
View File
@@ -85,7 +85,7 @@ Error PanIdQueryClient::SendQuery(uint16_t aPanId,
messageInfo.SetSockAddrToRlocPeerAddrTo(aAddress);
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo));
LogInfo("sent panid query");
LogInfo("Sent %s", UriToString<kUriPanIdQuery>());
mCallback.Set(aCallback, aContext);
@@ -102,7 +102,7 @@ void PanIdQueryClient::HandleTmf<kUriPanIdConflict>(Coap::Message &aMessage, con
VerifyOrExit(aMessage.IsConfirmablePostRequest());
LogInfo("received panid conflict");
LogInfo("Received %s", UriToString<kUriPanIdConflict>());
SuccessOrExit(Tlv::Find<MeshCoP::PanIdTlv>(aMessage, panId));
@@ -112,7 +112,7 @@ void PanIdQueryClient::HandleTmf<kUriPanIdConflict>(Coap::Message &aMessage, con
SuccessOrExit(Get<Tmf::Agent>().SendEmptyAck(aMessage, aMessageInfo));
LogInfo("sent panid query conflict response");
LogInfo("Sent %s response", UriToString<kUriPanIdConflict>());
exit:
return;
+16 -15
View File
@@ -600,7 +600,7 @@ Error AddressResolver::SendAddressQuery(const Ip6::Address &aEid)
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo));
LogInfo("Sending address query for %s", aEid.ToString().AsCString());
LogInfo("Sent %s for %s", UriToString<kUriAddressQuery>(), aEid.ToString().AsCString());
exit:
@@ -612,8 +612,8 @@ exit:
{
uint16_t selfRloc16 = Get<Mle::MleRouter>().GetRloc16();
LogInfo("Extending ADDR.qry to BB.qry for target=%s, rloc16=%04x(self)", aEid.ToString().AsCString(),
selfRloc16);
LogInfo("Extending %s to %s for target %s, rloc16=%04x(self)", UriToString<kUriAddressQuery>(),
UriToString<kUriBackboneQuery>(), aEid.ToString().AsCString(), selfRloc16);
IgnoreError(Get<BackboneRouter::Manager>().SendBackboneQuery(aEid, selfRloc16));
}
#endif
@@ -649,7 +649,7 @@ void AddressResolver::HandleTmf<kUriAddressNotify>(Coap::Message &aMessage, cons
ExitNow();
}
LogInfo("Received address notification from 0x%04x for %s to 0x%04x",
LogInfo("Received %s from 0x%04x for %s to 0x%04x", UriToString<kUriAddressNotify>(),
aMessageInfo.GetPeerAddr().GetIid().GetLocator(), target.ToString().AsCString(), rloc16);
entry = FindCacheEntry(target, list, prev);
@@ -681,7 +681,7 @@ void AddressResolver::HandleTmf<kUriAddressNotify>(Coap::Message &aMessage, cons
if (Get<Tmf::Agent>().SendEmptyAck(aMessage, aMessageInfo) == kErrorNone)
{
LogInfo("Sending address notification acknowledgment");
LogInfo("Sent %s ack", UriToString<kUriAddressNotify>());
}
Get<MeshForwarder>().HandleResolved(target, kErrorNone);
@@ -718,14 +718,14 @@ void AddressResolver::SendAddressError(const Ip6::Address &aTarget,
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo));
LogInfo("Sending address error for target %s", aTarget.ToString().AsCString());
LogInfo("Sent %s for target %s", UriToString<kUriAddressError>(), aTarget.ToString().AsCString());
exit:
if (error != kErrorNone)
{
FreeMessage(message);
LogInfo("Failed to send address error: %s", ErrorToString(error));
LogInfo("Failed to send %s: %s", UriToString<kUriAddressError>(), ErrorToString(error));
}
}
@@ -744,13 +744,13 @@ void AddressResolver::HandleTmf<kUriAddressError>(Coap::Message &aMessage, const
VerifyOrExit(aMessage.IsPostRequest(), error = kErrorDrop);
LogInfo("Received address error notification");
LogInfo("Received %s", UriToString<kUriAddressError>());
if (aMessage.IsConfirmable() && !aMessageInfo.GetSockAddr().IsMulticast())
{
if (Get<Tmf::Agent>().SendEmptyAck(aMessage, aMessageInfo) == kErrorNone)
{
LogInfo("Sent address error notification acknowledgment");
LogInfo("Sent %s ack", UriToString<kUriAddressError>());
}
}
@@ -807,7 +807,7 @@ exit:
if (error != kErrorNone)
{
LogWarn("Error while processing address error notification: %s", ErrorToString(error));
LogWarn("Error %s when processing %s", ErrorToString(error), UriToString<kUriAddressError>());
}
}
@@ -823,8 +823,8 @@ void AddressResolver::HandleTmf<kUriAddressQuery>(Coap::Message &aMessage, const
SuccessOrExit(Tlv::Find<ThreadTargetTlv>(aMessage, target));
LogInfo("Received address query from 0x%04x for target %s", aMessageInfo.GetPeerAddr().GetIid().GetLocator(),
target.ToString().AsCString());
LogInfo("Received %s from 0x%04x for target %s", UriToString<kUriAddressQuery>(),
aMessageInfo.GetPeerAddr().GetIid().GetLocator(), target.ToString().AsCString());
if (Get<ThreadNetif>().HasUnicastAddress(target))
{
@@ -853,7 +853,8 @@ void AddressResolver::HandleTmf<kUriAddressQuery>(Coap::Message &aMessage, const
{
uint16_t srcRloc16 = aMessageInfo.GetPeerAddr().GetIid().GetLocator();
LogInfo("Extending ADDR.qry to BB.qry for target=%s, rloc16=%04x", target.ToString().AsCString(), srcRloc16);
LogInfo("Extending %s to %s for target %s rloc16=%04x", UriToString<kUriAddressQuery>(),
UriToString<kUriBackboneQuery>(), target.ToString().AsCString(), srcRloc16);
IgnoreError(Get<BackboneRouter::Manager>().SendBackboneQuery(target, srcRloc16));
}
#endif
@@ -887,7 +888,7 @@ void AddressResolver::SendAddressQueryResponse(const Ip6::Address &a
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo));
LogInfo("Sending address notification for target %s", aTarget.ToString().AsCString());
LogInfo("Sent %s for target %s", UriToString<kUriAddressNotify>(), aTarget.ToString().AsCString());
exit:
FreeMessageOnError(message, error);
@@ -955,7 +956,7 @@ void AddressResolver::HandleTimeTick(void)
mQueryList.PopAfter(prev);
mQueryRetryList.Push(*entry);
LogInfo("Timed out waiting for address notification for %s, retry: %d",
LogInfo("Timed out waiting for %s for %s, retry: %d", UriToString<kUriAddressNotify>(),
entry->GetTarget().ToString().AsCString(), entry->GetTimeout());
Get<MeshForwarder>().HandleResolved(entry->GetTarget(), kErrorDrop);
+1 -1
View File
@@ -81,7 +81,7 @@ void AnnounceBeginServer::HandleTmf<kUriAnnounceBegin>(Coap::Message &aMessage,
if (aMessage.IsConfirmable() && !aMessageInfo.GetSockAddr().IsMulticast())
{
SuccessOrExit(Get<Tmf::Agent>().SendEmptyAck(aMessage, aMessageInfo));
LogInfo("Sent announce begin response");
LogInfo("Sent %s response", UriToString<kUriAnnounceBegin>());
}
exit:
+8 -7
View File
@@ -541,7 +541,7 @@ void DuaManager::PerformNextRegistration(void)
Get<DataPollSender>().SendFastPolls();
}
LogInfo("Sent DUA.req for DUA %s", dua.ToString().AsCString());
LogInfo("Sent %s for DUA %s", UriToString<kUriDuaRegistrationRequest>(), dua.ToString().AsCString());
exit:
if (error == kErrorNoBufs)
@@ -592,7 +592,7 @@ exit:
mRegistrationTask.Post();
}
LogInfo("Received DUA.rsp: %s", ErrorToString(error));
LogInfo("Received %s response: %s", UriToString<kUriDuaRegistrationRequest>(), ErrorToString(error));
}
template <>
@@ -606,14 +606,14 @@ void DuaManager::HandleTmf<kUriDuaRegistrationNotify>(Coap::Message &aMessage, c
if (aMessage.IsConfirmable() && Get<Tmf::Agent>().SendEmptyAck(aMessage, aMessageInfo) == kErrorNone)
{
LogInfo("Sent DUA.ntf acknowledgment");
LogInfo("Sent %s ack", UriToString<kUriDuaRegistrationNotify>());
}
error = ProcessDuaResponse(aMessage);
exit:
OT_UNUSED_VARIABLE(error);
LogInfo("Received DUA.ntf: %s", ErrorToString(error));
LogInfo("Received %s: %s", UriToString<kUriDuaRegistrationNotify>(), ErrorToString(error));
}
Error DuaManager::ProcessDuaResponse(Coap::Message &aMessage)
@@ -743,7 +743,8 @@ void DuaManager::SendAddressNotification(Ip6::Address &aAddress,
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo));
LogInfo("Sent ADDR_NTF for child %04x DUA %s", aChild.GetRloc16(), aAddress.ToString().AsCString());
LogInfo("Sent %s for child %04x DUA %s", UriToString<kUriDuaRegistrationNotify>(), aChild.GetRloc16(),
aAddress.ToString().AsCString());
exit:
@@ -752,8 +753,8 @@ exit:
FreeMessage(message);
// TODO: (DUA) (P4) may enhance to guarantee the delivery of DUA.ntf
LogWarn("Sent ADDR_NTF for child %04x DUA %s Error %s", aChild.GetRloc16(), aAddress.ToString().AsCString(),
ErrorToString(error));
LogWarn("Sent %s for child %04x DUA %s Error %s", UriToString<kUriDuaRegistrationNotify>(), aChild.GetRloc16(),
aAddress.ToString().AsCString(), ErrorToString(error));
}
}
+2 -2
View File
@@ -102,7 +102,7 @@ void EnergyScanServer::HandleTmf<kUriEnergyScan>(Coap::Message &aMessage, const
if (aMessage.IsConfirmable() && !aMessageInfo.GetSockAddr().IsMulticast())
{
SuccessOrExit(Get<Tmf::Agent>().SendEmptyAck(aMessage, aMessageInfo));
LogInfo("sent energy scan query response");
LogInfo("Sent %s ack", UriToString<kUriEnergyScan>());
}
exit:
@@ -197,7 +197,7 @@ void EnergyScanServer::SendReport(void)
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*mReportMessage, messageInfo));
LogInfo("sent scan results");
LogInfo("Sent %s", UriToString<kUriEnergyReport>());
exit:
FreeMessageOnError(mReportMessage, error);
+4 -4
View File
@@ -134,7 +134,7 @@ template <> void Leader::HandleTmf<kUriServerData>(Coap::Message &aMessage, cons
VerifyOrExit(Get<Mle::Mle>().IsLeader() && !mWaitingForNetDataSync);
LogInfo("Received network data registration");
LogInfo("Received %s", UriToString<kUriServerData>());
VerifyOrExit(aMessageInfo.GetPeerAddr().GetIid().IsRoutingLocator());
@@ -162,7 +162,7 @@ template <> void Leader::HandleTmf<kUriServerData>(Coap::Message &aMessage, cons
SuccessOrExit(Get<Tmf::Agent>().SendEmptyAck(aMessage, aMessageInfo));
LogInfo("Sent network data registration acknowledgment");
LogInfo("Sent %s ack", UriToString<kUriServerData>());
exit:
return;
@@ -332,7 +332,7 @@ void Leader::SendCommissioningGetResponse(const Coap::Message &aRequest,
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, aMessageInfo));
LogInfo("sent commissioning dataset get response");
LogInfo("Sent %s response", UriToString<kUriCommissionerGet>());
exit:
FreeMessageOnError(message, error);
@@ -352,7 +352,7 @@ void Leader::SendCommissioningSetResponse(const Coap::Message &aRequest,
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, aMessageInfo));
LogInfo("sent commissioning dataset set response");
LogInfo("sent %s response", UriToString<kUriCommissionerSet>());
exit:
FreeMessageOnError(message, error);
+1 -1
View File
@@ -211,7 +211,7 @@ Error Notifier::SendServerDataNotification(uint16_t aOldRloc16, const NetworkDat
IgnoreError(messageInfo.SetSockAddrToRlocPeerAddrToLeaderAloc());
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo, HandleCoapResponse, this));
LogInfo("Sent server data notification");
LogInfo("Sent %s", UriToString<kUriServerData>());
exit:
FreeMessageOnError(message, error);
+4 -4
View File
@@ -782,16 +782,16 @@ const char *NetworkDiagnostic::UriToString(Uri aUri)
switch (aUri)
{
case kUriDiagnosticGetQuery:
str = "DiagGetQuery";
str = ot::UriToString<kUriDiagnosticGetQuery>();
break;
case kUriDiagnosticGetRequest:
str = "DiagGetRequest";
str = ot::UriToString<kUriDiagnosticGetRequest>();
break;
case kUriDiagnosticReset:
str = "DiagReset";
str = ot::UriToString<kUriDiagnosticReset>();
break;
case kUriDiagnosticGetAnswer:
str = "DiagGetAnswer";
str = ot::UriToString<kUriDiagnosticGetAnswer>();
break;
default:
break;
+2 -2
View File
@@ -76,7 +76,7 @@ void PanIdQueryServer::HandleTmf<kUriPanIdQuery>(Coap::Message &aMessage, const
if (aMessage.IsConfirmable() && !aMessageInfo.GetSockAddr().IsMulticast())
{
SuccessOrExit(Get<Tmf::Agent>().SendEmptyAck(aMessage, aMessageInfo));
LogInfo("sent panid query response");
LogInfo("Sent %s ack", UriToString<kUriPanIdQuery>());
}
exit:
@@ -123,7 +123,7 @@ void PanIdQueryServer::SendConflict(void)
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo));
LogInfo("sent panid conflict");
LogInfo("Sent %s", UriToString<kUriPanIdConflict>());
exit:
FreeMessageOnError(message, error);
+40
View File
@@ -161,4 +161,44 @@ exit:
return uri;
}
template <> const char *UriToString<kUriAddressError>(void) { return "AddressError"; }
template <> const char *UriToString<kUriAddressNotify>(void) { return "AddressNotify"; }
template <> const char *UriToString<kUriAddressQuery>(void) { return "AddressQuery"; }
template <> const char *UriToString<kUriAddressRelease>(void) { return "AddressRelease"; }
template <> const char *UriToString<kUriAddressSolicit>(void) { return "AddressSolicit"; }
template <> const char *UriToString<kUriServerData>(void) { return "ServerData"; }
template <> const char *UriToString<kUriAnycastLocate>(void) { return "AnycastLocate"; }
template <> const char *UriToString<kUriBackboneAnswer>(void) { return "BackboneAnswer"; }
template <> const char *UriToString<kUriBackboneMlr>(void) { return "BackboneMlr"; }
template <> const char *UriToString<kUriBackboneQuery>(void) { return "BackboneQuery"; }
template <> const char *UriToString<kUriAnnounceBegin>(void) { return "AnnounceBegin"; }
template <> const char *UriToString<kUriActiveGet>(void) { return "ActiveGet"; }
template <> const char *UriToString<kUriActiveSet>(void) { return "ActiveSet"; }
template <> const char *UriToString<kUriCommissionerKeepAlive>(void) { return "CommissionerKeepAlive"; }
template <> const char *UriToString<kUriCommissionerGet>(void) { return "CommissionerGet"; }
template <> const char *UriToString<kUriCommissionerPetition>(void) { return "CommissionerPetition"; }
template <> const char *UriToString<kUriCommissionerSet>(void) { return "CommissionerSet"; }
template <> const char *UriToString<kUriDatasetChanged>(void) { return "DatasetChanged"; }
template <> const char *UriToString<kUriEnergyReport>(void) { return "EnergyReport"; }
template <> const char *UriToString<kUriEnergyScan>(void) { return "EnergyScan"; }
template <> const char *UriToString<kUriJoinerEntrust>(void) { return "JoinerEntrust"; }
template <> const char *UriToString<kUriJoinerFinalize>(void) { return "JoinerFinalize"; }
template <> const char *UriToString<kUriLeaderKeepAlive>(void) { return "LeaderKeepAlive"; }
template <> const char *UriToString<kUriLeaderPetition>(void) { return "LeaderPetition"; }
template <> const char *UriToString<kUriPanIdConflict>(void) { return "PanIdConflict"; }
template <> const char *UriToString<kUriPendingGet>(void) { return "PendingGet"; }
template <> const char *UriToString<kUriPanIdQuery>(void) { return "PanIdQuery"; }
template <> const char *UriToString<kUriPendingSet>(void) { return "PendingSet"; }
template <> const char *UriToString<kUriRelayRx>(void) { return "RelayRx"; }
template <> const char *UriToString<kUriRelayTx>(void) { return "RelayTx"; }
template <> const char *UriToString<kUriProxyRx>(void) { return "ProxyRx"; }
template <> const char *UriToString<kUriProxyTx>(void) { return "ProxyTx"; }
template <> const char *UriToString<kUriDiagnosticGetAnswer>(void) { return "DiagGetAnswer"; }
template <> const char *UriToString<kUriDiagnosticGetRequest>(void) { return "DiagGetRequest"; }
template <> const char *UriToString<kUriDiagnosticGetQuery>(void) { return "DiagGetQuery"; }
template <> const char *UriToString<kUriDiagnosticReset>(void) { return "DiagReset"; }
template <> const char *UriToString<kUriDuaRegistrationNotify>(void) { return "DuaRegNotify"; }
template <> const char *UriToString<kUriDuaRegistrationRequest>(void) { return "DuaRegRequest"; }
template <> const char *UriToString<kUriMlr>(void) { return "Mlr"; }
} // namespace ot
+51
View File
@@ -108,6 +108,57 @@ const char *PathForUri(Uri aUri);
*/
Uri UriFromPath(const char *aPath);
/**
* This template function converts a given URI to a human-readable string.
*
* @tparam kUri The URI to convert to string.
*
* @returns The string representation of @p kUri.
*
*/
template <Uri kUri> const char *UriToString(void);
// Declaring specializations of `UriToString` for every `Uri`
template <> const char *UriToString<kUriAddressError>(void);
template <> const char *UriToString<kUriAddressNotify>(void);
template <> const char *UriToString<kUriAddressQuery>(void);
template <> const char *UriToString<kUriAddressRelease>(void);
template <> const char *UriToString<kUriAddressSolicit>(void);
template <> const char *UriToString<kUriServerData>(void);
template <> const char *UriToString<kUriAnycastLocate>(void);
template <> const char *UriToString<kUriBackboneAnswer>(void);
template <> const char *UriToString<kUriBackboneMlr>(void);
template <> const char *UriToString<kUriBackboneQuery>(void);
template <> const char *UriToString<kUriAnnounceBegin>(void);
template <> const char *UriToString<kUriActiveGet>(void);
template <> const char *UriToString<kUriActiveSet>(void);
template <> const char *UriToString<kUriCommissionerKeepAlive>(void);
template <> const char *UriToString<kUriCommissionerGet>(void);
template <> const char *UriToString<kUriCommissionerPetition>(void);
template <> const char *UriToString<kUriCommissionerSet>(void);
template <> const char *UriToString<kUriDatasetChanged>(void);
template <> const char *UriToString<kUriEnergyReport>(void);
template <> const char *UriToString<kUriEnergyScan>(void);
template <> const char *UriToString<kUriJoinerEntrust>(void);
template <> const char *UriToString<kUriJoinerFinalize>(void);
template <> const char *UriToString<kUriLeaderKeepAlive>(void);
template <> const char *UriToString<kUriLeaderPetition>(void);
template <> const char *UriToString<kUriPanIdConflict>(void);
template <> const char *UriToString<kUriPendingGet>(void);
template <> const char *UriToString<kUriPanIdQuery>(void);
template <> const char *UriToString<kUriPendingSet>(void);
template <> const char *UriToString<kUriRelayRx>(void);
template <> const char *UriToString<kUriRelayTx>(void);
template <> const char *UriToString<kUriProxyRx>(void);
template <> const char *UriToString<kUriProxyTx>(void);
template <> const char *UriToString<kUriDiagnosticGetAnswer>(void);
template <> const char *UriToString<kUriDiagnosticGetRequest>(void);
template <> const char *UriToString<kUriDiagnosticGetQuery>(void);
template <> const char *UriToString<kUriDiagnosticReset>(void);
template <> const char *UriToString<kUriDuaRegistrationNotify>(void);
template <> const char *UriToString<kUriDuaRegistrationRequest>(void);
template <> const char *UriToString<kUriMlr>(void);
} // namespace ot
#endif // URI_PATHS_HPP_