[coap] add 'otCoapMessageSetCode' (#7339) (#7351)

Provide a setter for the message code to change it after
initialization of the message.

This complements the existing getter function `otCoapMessageGetCode`.
This commit is contained in:
wohdo
2022-01-26 21:28:18 -08:00
committed by GitHub
parent 5896eefc21
commit 69ed42f491
3 changed files with 15 additions and 1 deletions
+9
View File
@@ -717,6 +717,15 @@ otCoapType otCoapMessageGetType(const otMessage *aMessage);
*/
otCoapCode otCoapMessageGetCode(const otMessage *aMessage);
/**
* This function sets the Code value.
*
* @param[inout] aMessage A pointer to the CoAP message to initialize.
* @param[in] aCode CoAP message code.
*
*/
void otCoapMessageSetCode(otMessage *aMessage, otCoapCode aCode);
/**
* This method returns the CoAP Code as human readable string.
*
+1 -1
View File
@@ -53,7 +53,7 @@ extern "C" {
* @note This number versions both OpenThread platform and user APIs.
*
*/
#define OPENTHREAD_API_VERSION (186)
#define OPENTHREAD_API_VERSION (187)
/**
* @addtogroup api-instance
+5
View File
@@ -144,6 +144,11 @@ otCoapCode otCoapMessageGetCode(const otMessage *aMessage)
return static_cast<otCoapCode>(AsCoapMessage(aMessage).GetCode());
}
void otCoapMessageSetCode(otMessage *aMessage, otCoapCode aCode)
{
AsCoapMessage(aMessage).SetCode(MapEnum(aCode));
}
const char *otCoapMessageCodeToString(const otMessage *aMessage)
{
return AsCoapMessage(aMessage).CodeToString();