[api] update message API to create message with priority (#3199)

This commit is contained in:
Zhanglong Xia
2018-11-05 12:48:39 -08:00
committed by Jonathan Hui
parent f5fdf506ad
commit f8909593a9
28 changed files with 176 additions and 91 deletions
+8 -4
View File
@@ -485,13 +485,17 @@ const otCoapOption *otCoapHeaderGetNextOption(otCoapHeader *aHeader);
/**
* This function creates a new message with a CoAP header.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aHeader A pointer to a CoAP header that is used to create the message.
* @note If @p aSettings is 'NULL', the link layer security is enabled and the message priority is set to
* OT_MESSAGE_PRIORITY_NORMAL by default.
*
* @returns A pointer to the message or NULL if failed to allocate message.
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aHeader A pointer to a CoAP header that is used to create the message.
* @param[in] aSettings A pointer to the message settings or NULL to set default settings.
*
* @returns A pointer to the message buffer or NULL if no message buffers are available or parameters are invalid.
*
*/
otMessage *otCoapNewMessage(otInstance *aInstance, const otCoapHeader *aHeader);
otMessage *otCoapNewMessage(otInstance *aInstance, const otCoapHeader *aHeader, const otMessageSettings *aSettings);
/**
* This function sends a CoAP request.
+7 -4
View File
@@ -370,14 +370,17 @@ otError otIp6CreateSemanticallyOpaqueIid(otInstance *aInstance, otNetifAddress *
/**
* Allocate a new message buffer for sending an IPv6 message.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aLinkSecurityEnabled TRUE if the message should be secured at Layer 2
* @note If @p aSettings is 'NULL', the link layer security is enabled and the message priority is set to
* OT_MESSAGE_PRIORITY_NORMAL by default.
*
* @returns A pointer to the message buffer or NULL if no message buffers are available.
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aSettings A pointer to the message settings or NULL to set default settings.
*
* @returns A pointer to the message buffer or NULL if no message buffers are available or parameters are invalid.
*
* @sa otFreeMessage
*/
otMessage *otIp6NewMessage(otInstance *aInstance, bool aLinkSecurityEnabled);
otMessage *otIp6NewMessage(otInstance *aInstance, const otMessageSettings *aSettings);
/**
* This function pointer is called when an IPv6 datagram is received.
+21
View File
@@ -88,6 +88,27 @@ typedef struct otBufferInfo
uint16_t mApplicationCoapBuffers; ///< The number of buffers in the application CoAP send queue.
} otBufferInfo;
/**
* This enumeration defines the Openthread message priority levels.
*
*/
typedef enum otMessagePriority
{
OT_MESSAGE_PRIORITY_LOW = 0, ///< Low priority level.
OT_MESSAGE_PRIORITY_NORMAL = 1, ///< Normal priority level.
OT_MESSAGE_PRIORITY_HIGH = 2, ///< High priority level.
} otMessagePriority;
/**
* This structure represents a message settings.
*
*/
typedef struct otMessageSettings
{
bool mLinkSecurityEnabled; ///< TRUE if the message should be secured at Layer 2.
otMessagePriority mPriority; ///< The message priority level.
} otMessageSettings;
/**
* Free an allocated message buffer.
*
+7 -4
View File
@@ -96,15 +96,18 @@ typedef struct otUdpSocket
/**
* Allocate a new message buffer for sending a UDP message.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aLinkSecurityEnabled TRUE if the message should be secured at Layer 2.
* @note If @p aSettings is 'NULL', the link layer security is enabled and the message priority is set to
* OT_MESSAGE_PRIORITY_NORMAL by default.
*
* @returns A pointer to the message buffer or NULL if no message buffers are available.
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aSettings A pointer to the message settings or NULL to set default settings.
*
* @returns A pointer to the message buffer or NULL if no message buffers are available or parameters are invalid.
*
* @sa otFreeMessage
*
*/
otMessage *otUdpNewMessage(otInstance *aInstance, bool aLinkSecurityEnabled);
otMessage *otUdpNewMessage(otInstance *aInstance, const otMessageSettings *aSettings);
/**
* Open a UDP/IPv6 socket.