diff --git a/include/openthread/message.h b/include/openthread/message.h index 879eb3612..3e0177850 100644 --- a/include/openthread/message.h +++ b/include/openthread/message.h @@ -142,7 +142,7 @@ void otMessageFree(otMessage *aMessage); * @sa otMessageSetLength * */ -uint16_t otMessageGetLength(otMessage *aMessage); +uint16_t otMessageGetLength(const otMessage *aMessage); /** * Set the message length in bytes. @@ -180,7 +180,7 @@ otError otMessageSetLength(otMessage *aMessage, uint16_t aLength); * @sa otMessageWrite * */ -uint16_t otMessageGetOffset(otMessage *aMessage); +uint16_t otMessageGetOffset(const otMessage *aMessage); /** * Set the message offset in bytes. @@ -211,7 +211,7 @@ otError otMessageSetOffset(otMessage *aMessage, uint16_t aOffset); * @retval FALSE If link security is not enabled. * */ -bool otMessageIsLinkSecurityEnabled(otMessage *aMessage); +bool otMessageIsLinkSecurityEnabled(const otMessage *aMessage); /** * This function sets/forces the message to be forwarded using direct transmission. @@ -230,7 +230,7 @@ void otMessageSetDirectTransmission(otMessage *aMessage, bool aEnabled); * @returns The average RSS value (in dBm) or OT_RADIO_RSSI_INVALID if no average RSS is available. * */ -int8_t otMessageGetRss(otMessage *aMessage); +int8_t otMessageGetRss(const otMessage *aMessage); /** * Append bytes to a message. @@ -272,7 +272,7 @@ otError otMessageAppend(otMessage *aMessage, const void *aBuf, uint16_t aLength) * @sa otMessageWrite * */ -int otMessageRead(otMessage *aMessage, uint16_t aOffset, void *aBuf, uint16_t aLength); +int otMessageRead(const otMessage *aMessage, uint16_t aOffset, void *aBuf, uint16_t aLength); /** * Write bytes to a message. diff --git a/src/core/api/message_api.cpp b/src/core/api/message_api.cpp index 99e9718c5..274f9db4c 100644 --- a/src/core/api/message_api.cpp +++ b/src/core/api/message_api.cpp @@ -44,9 +44,9 @@ void otMessageFree(otMessage *aMessage) static_cast(aMessage)->Free(); } -uint16_t otMessageGetLength(otMessage *aMessage) +uint16_t otMessageGetLength(const otMessage *aMessage) { - Message &message = *static_cast(aMessage); + const Message &message = *static_cast(aMessage); return message.GetLength(); } @@ -56,9 +56,9 @@ otError otMessageSetLength(otMessage *aMessage, uint16_t aLength) return message.SetLength(aLength); } -uint16_t otMessageGetOffset(otMessage *aMessage) +uint16_t otMessageGetOffset(const otMessage *aMessage) { - Message &message = *static_cast(aMessage); + const Message &message = *static_cast(aMessage); return message.GetOffset(); } @@ -68,9 +68,9 @@ otError otMessageSetOffset(otMessage *aMessage, uint16_t aOffset) return message.SetOffset(aOffset); } -bool otMessageIsLinkSecurityEnabled(otMessage *aMessage) +bool otMessageIsLinkSecurityEnabled(const otMessage *aMessage) { - Message &message = *static_cast(aMessage); + const Message &message = *static_cast(aMessage); return message.IsLinkSecurityEnabled(); } @@ -88,9 +88,9 @@ void otMessageSetDirectTransmission(otMessage *aMessage, bool aEnabled) } } -int8_t otMessageGetRss(otMessage *aMessage) +int8_t otMessageGetRss(const otMessage *aMessage) { - Message &message = *static_cast(aMessage); + const Message &message = *static_cast(aMessage); return message.GetAverageRss(); } @@ -100,9 +100,9 @@ otError otMessageAppend(otMessage *aMessage, const void *aBuf, uint16_t aLength) return message.Append(aBuf, aLength); } -int otMessageRead(otMessage *aMessage, uint16_t aOffset, void *aBuf, uint16_t aLength) +int otMessageRead(const otMessage *aMessage, uint16_t aOffset, void *aBuf, uint16_t aLength) { - Message &message = *static_cast(aMessage); + const Message &message = *static_cast(aMessage); return message.Read(aOffset, aLength, aBuf); }