mirror of
https://github.com/espressif/openthread.git
synced 2026-08-06 18:57:47 +00:00
[coap] add new helper to allocate and init CoAP message (#7631)
This commit adds new helper methods in `Coap` to allocate a new message and initialize it as a confirmable or non-confirmable post to a given URI path. It also adds a new helper method to allocate a CoAP response message for a given request. These methods help simplify the preparation of CoAP and TMF messages.
This commit is contained in:
@@ -455,10 +455,8 @@ void DuaManager::PerformNextRegistration(void)
|
||||
}
|
||||
|
||||
// Prepare DUA.req
|
||||
VerifyOrExit((message = Get<Tmf::Agent>().NewPriorityMessage()) != nullptr, error = kErrorNoBufs);
|
||||
|
||||
SuccessOrExit(error = message->InitAsConfirmablePost(UriPath::kDuaRegistrationRequest));
|
||||
SuccessOrExit(error = message->SetPayloadMarker());
|
||||
message = Get<Tmf::Agent>().NewPriorityConfirmablePostMessage(UriPath::kDuaRegistrationRequest);
|
||||
VerifyOrExit(message != nullptr, error = kErrorNoBufs);
|
||||
|
||||
#if OPENTHREAD_CONFIG_DUA_ENABLE
|
||||
if (mDuaState == kToRegister && mDelay.mFields.mRegistrationDelay == 0)
|
||||
@@ -728,10 +726,8 @@ void DuaManager::SendAddressNotification(Ip6::Address & aAddress,
|
||||
Tmf::MessageInfo messageInfo(GetInstance());
|
||||
Error error;
|
||||
|
||||
VerifyOrExit((message = Get<Tmf::Agent>().NewPriorityMessage()) != nullptr, error = kErrorNoBufs);
|
||||
|
||||
SuccessOrExit(error = message->InitAsConfirmablePost(UriPath::kDuaRegistrationNotify));
|
||||
SuccessOrExit(error = message->SetPayloadMarker());
|
||||
message = Get<Tmf::Agent>().NewPriorityConfirmablePostMessage(UriPath::kDuaRegistrationNotify);
|
||||
VerifyOrExit(message != nullptr, error = kErrorNoBufs);
|
||||
|
||||
SuccessOrExit(error = Tlv::Append<ThreadStatusTlv>(*message, aStatus));
|
||||
SuccessOrExit(error = Tlv::Append<ThreadTargetTlv>(*message, aAddress));
|
||||
|
||||
Reference in New Issue
Block a user