nRF5 SDK for Thread v0.9.0
Data Structures | Functions
Message Buffers

This module includes functions that manipulate OpenThread message buffers. More...

Data Structures

struct  otMessageQueue
 

Functions

ThreadError otMessageFree (otMessage *aMessage)
 
uint16_t otMessageGetLength (otMessage *aMessage)
 
ThreadError otMessageSetLength (otMessage *aMessage, uint16_t aLength)
 
uint16_t otMessageGetOffset (otMessage *aMessage)
 
ThreadError otMessageSetOffset (otMessage *aMessage, uint16_t aOffset)
 
bool otMessageIsLinkSecurityEnabled (otMessage *aMessage)
 
void otMessageSetDirectTransmission (otMessage *aMessage, bool aEnabled)
 
ThreadError otMessageAppend (otMessage *aMessage, const void *aBuf, uint16_t aLength)
 
int otMessageRead (otMessage *aMessage, uint16_t aOffset, void *aBuf, uint16_t aLength)
 
int otMessageWrite (otMessage *aMessage, uint16_t aOffset, const void *aBuf, uint16_t aLength)
 
void otMessageQueueInit (otMessageQueue *aQueue)
 
ThreadError otMessageQueueEnqueue (otMessageQueue *aQueue, otMessage *aMessage)
 
ThreadError otMessageQueueDequeue (otMessageQueue *aQueue, otMessage *aMessage)
 
otMessageotMessageQueueGetHead (otMessageQueue *aQueue)
 
otMessageotMessageQueueGetNext (otMessageQueue *aQueue, const otMessage *aMessage)
 
OTAPI void OTCALL otMessageGetBufferInfo (otInstance *aInstance, otBufferInfo *aBufferInfo)
 

Detailed Description

This module includes functions that manipulate OpenThread message buffers.

Function Documentation

ThreadError otMessageAppend ( otMessage aMessage,
const void *  aBuf,
uint16_t  aLength 
)

Append bytes to a message.

Parameters
[in]aMessageA pointer to a message buffer.
[in]aBufA pointer to the data to append.
[in]aLengthNumber of bytes to append.
Return values
kThreadErrorNoneSuccessfully appended to the message
kThreadErrorNoBufsNo available buffers to grow the message.
See Also
otMessageFree
otMessageGetLength
otMessageSetLength
otMessageGetOffset
otMessageSetOffset
otMessageRead
otMessageWrite
ThreadError otMessageFree ( otMessage aMessage)

Free an allocated message buffer.

Parameters
[in]aMessageA pointer to a message buffer.
Return values
kThreadErrorNoneSuccessfully freed the message buffer.
See Also
otMessageAppend
otMessageGetLength
otMessageSetLength
otMessageGetOffset
otMessageSetOffset
otMessageRead
otMessageWrite
OTAPI void OTCALL otMessageGetBufferInfo ( otInstance *  aInstance,
otBufferInfo aBufferInfo 
)

Get the Message Buffer information.

Parameters
[in]aInstanceA pointer to the OpenThread instance.
[out]aBufferInfoA pointer where the message buffer information is written.
uint16_t otMessageGetLength ( otMessage aMessage)

Get the message length in bytes.

Parameters
[in]aMessageA pointer to a message buffer.
Returns
The message length in bytes.
See Also
otMessageFree
otMessageAppend
otMessageSetLength
otMessageGetOffset
otMessageSetOffset
otMessageRead
otMessageWrite
otMessageSetLength
uint16_t otMessageGetOffset ( otMessage aMessage)

Get the message offset in bytes.

Parameters
[in]aMessageA pointer to a message buffer.
Returns
The message offset value.
See Also
otMessageFree
otMessageAppend
otMessageGetLength
otMessageSetLength
otMessageSetOffset
otMessageRead
otMessageWrite
bool otMessageIsLinkSecurityEnabled ( otMessage aMessage)

This function indicates whether or not link security is enabled for the message.

Parameters
[in]aMessageA pointer to a message buffer.
Return values
TRUEIf link security is enabled.
FALSEIf link security is not enabled.
ThreadError otMessageQueueDequeue ( otMessageQueue aQueue,
otMessage aMessage 
)

This function removes a message from the given message queue.

Parameters
[in]aQueueA pointer to the message queue.
[in]aMessageThe message to remove.
Return values
kThreadError_NoneSuccessfully removed the message from the queue.
kThreadError_NotFoundThe message is not enqueued in this queue.
ThreadError otMessageQueueEnqueue ( otMessageQueue aQueue,
otMessage aMessage 
)

This function adds a message to the end of the given message queue.

Parameters
[in]aQueueA pointer to the message queue.
[in]aMessageThe message to add.
Return values
kThreadError_NoneSuccessfully added the message to the queue.
kThreadError_AlreadyThe message is already enqueued in a queue.
otMessage* otMessageQueueGetHead ( otMessageQueue aQueue)

This function returns a pointer to the message at the head of the queue.

Parameters
[in]aQueueA pointer to a message queue.
Returns
A pointer to the message at the head of queue or NULL if queue is empty.
otMessage* otMessageQueueGetNext ( otMessageQueue aQueue,
const otMessage aMessage 
)

This function returns a pointer to the next message in the queue by iterating forward (from head to tail).

Parameters
[in]aQueueA pointer to a message queue.
[in]aMessageA pointer to current message buffer.
Returns
A pointer to the next message in the queue after aMessage or NULL if aMessage is the tail of queue. NULL is returned ifaMessageis not in the queueaQueue`.
void otMessageQueueInit ( otMessageQueue aQueue)

Initialize the message queue.

This function MUST be called once and only once for a otMessageQueue instance before any other otMessageQueue functions. The behavior is undefined if other queue APIs are used with an otMessageQueue before it being initialized or if it is initialized more than once.

Parameters
[in]aQueueA pointer to a message queue.
int otMessageRead ( otMessage aMessage,
uint16_t  aOffset,
void *  aBuf,
uint16_t  aLength 
)

Read bytes from a message.

Parameters
[in]aMessageA pointer to a message buffer.
[in]aOffsetAn offset in bytes.
[in]aBufA pointer to a buffer that message bytes are read to.
[in]aLengthNumber of bytes to read.
Returns
The number of bytes read.
See Also
otMessageFree
otMessageAppend
otMessageGetLength
otMessageSetLength
otMessageGetOffset
otMessageSetOffset
otMessageWrite
void otMessageSetDirectTransmission ( otMessage aMessage,
bool  aEnabled 
)

This function sets/forces the message to be forwarded using direct transmission. Default setting for a new message is false.

Parameters
[in]aMessageA pointer to a message buffer.
[in]aEnabledIf true message will be forced to use direct transmission. If false message will follow the normal procedure.
ThreadError otMessageSetLength ( otMessage aMessage,
uint16_t  aLength 
)

Set the message length in bytes.

Parameters
[in]aMessageA pointer to a message buffer.
[in]aLengthA length in bytes.
Return values
kThreadErrorNoneSuccessfully set the message length.
kThreadErrorNoBufsNo available buffers to grow the message.
See Also
otMessageFree
otMessageAppend
otMessageGetLength
otMessageGetOffset
otMessageSetOffset
otMessageRead
otMessageWrite
ThreadError otMessageSetOffset ( otMessage aMessage,
uint16_t  aOffset 
)

Set the message offset in bytes.

Parameters
[in]aMessageA pointer to a message buffer.
[in]aOffsetAn offset in bytes.
Return values
kThreadErrorNoneSuccessfully set the message offset.
kThreadErrorInvalidArgThe offset is beyond the message length.
See Also
otMessageFree
otMessageAppend
otMessageGetLength
otMessageSetLength
otMessageGetOffset
otMessageRead
otMessageWrite
int otMessageWrite ( otMessage aMessage,
uint16_t  aOffset,
const void *  aBuf,
uint16_t  aLength 
)

Write bytes to a message.

Parameters
[in]aMessageA pointer to a message buffer.
[in]aOffsetAn offset in bytes.
[in]aBufA pointer to a buffer that message bytes are written from.
[in]aLengthNumber of bytes to write.
Returns
The number of bytes written.
See Also
otMessageFree
otMessageAppend
otMessageGetLength
otMessageSetLength
otMessageGetOffset
otMessageSetOffset
otMessageRead

Documentation feedback | Developer Zone | Subscribe | Updated