訊息
這個模組含有會操控 OpenThread 訊息緩衝區的函式。
摘要
列舉 |
|
---|---|
otMessageOrigin{
|
列舉 定義 OpenThread 訊息來源。 |
otMessagePriority{
|
列舉 定義 OpenThread 訊息的優先順序等級。 |
Typedefs |
|
---|---|
otBufferInfo
|
typedefstruct otBufferInfo
代表 OpenThread 堆疊使用的不同佇列的訊息緩衝區資訊。 |
otMessage
|
typedefstruct otMessage
以不透明形式呈現 OpenThread 訊息緩衝區。 |
otMessageOrigin
|
typedefenum otMessageOrigin
定義 OpenThread 訊息來源。 |
otMessagePriority
|
typedefenum otMessagePriority
定義 OpenThread 訊息的優先順序等級。 |
otMessageQueueInfo
|
typedefstruct otMessageQueueInfo
代表訊息佇列的相關資訊。 |
otMessageSettings
|
typedefstruct otMessageSettings
代表訊息設定。 |
函式 |
|
---|---|
otMessageAppend(otMessage *aMessage, const void *aBuf, uint16_t aLength)
|
在訊息中附加位元組。
|
otMessageFree(otMessage *aMessage)
|
void
釋出分配的訊息緩衝區。
|
otMessageGetBufferInfo(otInstance *aInstance, otBufferInfo *aBufferInfo)
|
void
取得郵件緩衝區資訊。
|
otMessageGetLength(const otMessage *aMessage)
|
uint16_t
取得訊息長度 (以位元組為單位)。
|
otMessageGetOffset(const otMessage *aMessage)
|
uint16_t
取得訊息偏移 (以位元組為單位)。
|
otMessageGetOrigin(const otMessage *aMessage)
|
取得訊息來源。
|
otMessageGetRss(const otMessage *aMessage)
|
int8_t
傳回與訊息相關聯的平均 RSS (接收訊號強度)。
|
otMessageIsLinkSecurityEnabled(const otMessage *aMessage)
|
bool
指出郵件是否已啟用連結安全性。
|
otMessageIsLoopbackToHostAllowed(const otMessage *aMessage)
|
bool
指出系統是否允許訊息循環播放至主機。
|
otMessageIsMulticastLoopEnabled(otMessage *aMessage)
|
bool
指出在多點傳播目的地地址中,特定訊息是否可循環播放。
|
otMessageQueueDequeue(otMessageQueue *aQueue, otMessage *aMessage)
|
void
從指定訊息佇列移除訊息。
|
otMessageQueueEnqueue(otMessageQueue *aQueue, otMessage *aMessage)
|
void
將訊息新增至指定訊息佇列結尾。
|
otMessageQueueEnqueueAtHead(otMessageQueue *aQueue, otMessage *aMessage)
|
void
在指定訊息佇列的標題/前端新增訊息。
|
otMessageQueueGetHead(otMessageQueue *aQueue)
|
傳回佇列標頭訊息的指標。
|
otMessageQueueGetNext(otMessageQueue *aQueue, const otMessage *aMessage)
|
透過疊代 (從頭到尾) 傳回佇列中下一封郵件的指標。
|
otMessageQueueInit(otMessageQueue *aQueue)
|
void
初始化訊息佇列。
|
otMessageRead(const otMessage *aMessage, uint16_t aOffset, void *aBuf, uint16_t aLength)
|
uint16_t
讀取郵件的位元組。
|
otMessageResetBufferInfo(otInstance *aInstance)
|
void
重設訊息緩衝區資訊計數器,同時追蹤使用中的緩衝區數量上限。
|
otMessageSetDirectTransmission(otMessage *aMessage, bool aEnabled)
|
void
設定/強制使用直接傳輸功能轉寄郵件。
|
otMessageSetLength(otMessage *aMessage, uint16_t aLength)
|
設定訊息長度 (以位元組為單位)。
|
otMessageSetLoopbackToHostAllowed(otMessage *aMessage, bool aAllowLoopbackToHost)
|
void
設定是否允許郵件循環播放至主機。
|
otMessageSetMulticastLoopEnabled(otMessage *aMessage, bool aEnabled)
|
void
控制在多點傳播目的地位址的情況下,特定訊息是否可循環播放。
|
otMessageSetOffset(otMessage *aMessage, uint16_t aOffset)
|
void
設定訊息偏移 (以位元組為單位)。
|
otMessageSetOrigin(otMessage *aMessage, otMessageOrigin aOrigin)
|
void
設定訊息來源。
|
otMessageWrite(otMessage *aMessage, uint16_t aOffset, const void *aBuf, uint16_t aLength)
|
int
將位元組寫入訊息。
|
結構 |
|
---|---|
otBufferInfo |
代表 OpenThread 堆疊使用的不同佇列的訊息緩衝區資訊。 |
otMessageQueue |
代表 OpenThread 訊息佇列。 |
otMessageQueueInfo |
代表訊息佇列的相關資訊。 |
otMessageSettings |
代表訊息設定。 |
列舉
otMessageOrigin
otMessageOrigin
定義 OpenThread 訊息來源。
屬性 | |
---|---|
OT_MESSAGE_ORIGIN_HOST_TRUSTED
|
來自主機上可信任來源的郵件。 |
OT_MESSAGE_ORIGIN_HOST_UNTRUSTED
|
主機上來自不受信任來源的郵件。 |
OT_MESSAGE_ORIGIN_THREAD_NETIF
|
Thread Netif 的訊息。 |
otMessagePriority
otMessagePriority
定義 OpenThread 訊息的優先順序等級。
屬性 | |
---|---|
OT_MESSAGE_PRIORITY_HIGH
|
高優先順序等級。 |
OT_MESSAGE_PRIORITY_LOW
|
低優先順序等級。 |
OT_MESSAGE_PRIORITY_NORMAL
|
一般優先順序等級。 |
Typedefs
函式
otMessageAppend
otError otMessageAppend(
otMessage *aMessage,
const void *aBuf,
uint16_t aLength
)
在訊息中附加位元組。
詳細說明 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
||||||
傳回值 |
|
otMessageFree
otMessageGetLength
otMessageSetLength
otMessageGetOffset
otMessageSetOffset
otMessageRead
otMessageWrite
otMessageFree
void otMessageFree(
otMessage *aMessage
)
釋出分配的訊息緩衝區。
詳細說明 | |||
---|---|---|---|
參數 |
|
otMessageAppend
otMessageGetLength
otMessageSetLength
otMessageGetOffset
otMessageSetOffset
otMessageRead
otMessageWrite
otMessageGetBufferInfo
void otMessageGetBufferInfo(
otInstance *aInstance,
otBufferInfo *aBufferInfo
)
取得郵件緩衝區資訊。
詳細說明 | |||||
---|---|---|---|---|---|
參數 |
|
otMessageGetLength
uint16_t otMessageGetLength(
const otMessage *aMessage
)
取得訊息長度 (以位元組為單位)。
詳細說明 | |||
---|---|---|---|
參數 |
|
||
傳回 |
訊息長度 (以位元組為單位)。
|
otMessageFree
otMessageAppend
otMessageSetLength
otMessageGetOffset
otMessageSetOffset
otMessageRead
otMessageWrite
otMessageWrite
otMessageSetLength
otMessageGetOffset
uint16_t otMessageGetOffset(
const otMessage *aMessage
)
取得訊息偏移 (以位元組為單位)。
詳細說明 | |||
---|---|---|---|
參數 |
|
||
傳回 |
訊息偏移值。
|
otMessageFree
otMessageGetLength
otMessageSetLength
otMessageSetOffset
otMessageRead
otMessageWrite
otMessageGetOrigin
otMessageOrigin otMessageGetOrigin(
const otMessage *aMessage
)
取得訊息來源。
詳細說明 | |||
---|---|---|---|
參數 |
|
||
傳回 |
訊息來源。
|
otMessageGetRss
int8_t otMessageGetRss(
const otMessage *aMessage
)
傳回與訊息相關聯的平均 RSS (接收訊號強度)。
詳細說明 | |
---|---|
傳回 |
如果沒有平均 RSS 資訊,則平均 RSS 值 (以 dBm 表示) 或 OT_RADIO_RSSI_INVALID。
|
otMessageIsLinkSecurityEnabled
bool otMessageIsLinkSecurityEnabled(
const otMessage *aMessage
)
指出郵件是否已啟用連結安全性。
詳細說明 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回值 |
|
otMessageIsLoopbackToHostAllowed
bool otMessageIsLoopbackToHostAllowed(
const otMessage *aMessage
)
指出系統是否允許訊息循環播放至主機。
詳細說明 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回值 |
|
otMessageIsMulticastLoopEnabled
bool otMessageIsMulticastLoopEnabled(
otMessage *aMessage
)
指出在多點傳播目的地地址中,特定訊息是否可循環播放。
如果將 aMessage
與 otMessageInfo
搭配使用,系統會優先採用 otMessageInfo
結構的 mMulticastLoop
欄位,而非 aMessage
上設定的值。
這個 API 主要是搭配 otIp6Send()
使用,以便搭配準備好的 IPv6 訊息。
詳細說明 | |||
---|---|---|---|
參數 |
|
otMessageQueueDequeue
void otMessageQueueDequeue(
otMessageQueue *aQueue,
otMessage *aMessage
)
從指定訊息佇列移除訊息。
詳細說明 | |||||
---|---|---|---|---|---|
參數 |
|
otMessageQueueEnqueue
void otMessageQueueEnqueue(
otMessageQueue *aQueue,
otMessage *aMessage
)
將訊息新增至指定訊息佇列結尾。
詳細說明 | |||||
---|---|---|---|---|---|
參數 |
|
otMessageQueueEnqueueAtHead
void otMessageQueueEnqueueAtHead(
otMessageQueue *aQueue,
otMessage *aMessage
)
在指定訊息佇列的標題/前端新增訊息。
詳細說明 | |||||
---|---|---|---|---|---|
參數 |
|
otMessageQueueGetHead
otMessage * otMessageQueueGetHead(
otMessageQueue *aQueue
)
傳回佇列標頭訊息的指標。
詳細說明 | |||
---|---|---|---|
參數 |
|
||
傳回 |
指向佇列標頭的訊息指標,如果佇列為空白,則指向 NULL。
|
otMessageQueueGetNext
otMessage * otMessageQueueGetNext(
otMessageQueue *aQueue,
const otMessage *aMessage
)
透過疊代 (從頭到尾) 傳回佇列中下一封郵件的指標。
詳細說明 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回 |
指向
aMessage 之後的下一則訊息;如果為 aMessage is the tail of queue. NULL is returned if aMessageis not in the queue aQueue,則為 NULL。 |
otMessageQueueInit
void otMessageQueueInit(
otMessageQueue *aQueue
)
初始化訊息佇列。
每個 otMessageQueue
例項都必須呼叫一次,而且只能在任何其他 otMessageQueue
函式之前呼叫。如果在初始化前搭配 otMessageQueue
使用其他佇列 API,或該工作多次初始化,則未定義該行為。
詳細說明 | |||
---|---|---|---|
參數 |
|
otMessageRead
uint16_t otMessageRead(
const otMessage *aMessage,
uint16_t aOffset,
void *aBuf,
uint16_t aLength
)
讀取郵件的位元組。
詳細說明 | |||||||||
---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||
傳回 |
讀取的位元組數。
|
otMessageFree
otMessageGetLength
otMessageSetLength
otMessageGetOffset
otMessageSetOffset
otMessageWrite
otMessageResetBufferInfo
void otMessageResetBufferInfo(
otInstance *aInstance
)
重設訊息緩衝區資訊計數器,同時追蹤使用中的緩衝區數量上限。
這會重設 otBufferInfo
中的 mMaxUsedBuffers
。
詳細說明 | |||
---|---|---|---|
參數 |
|
otMessageSetDirectTransmission
void otMessageSetDirectTransmission(
otMessage *aMessage,
bool aEnabled
)
設定/強制使用直接傳輸功能轉寄郵件。
新訊息的預設設定為 false
。
詳細說明 | |||||
---|---|---|---|---|---|
參數 |
|
otMessageSetLength
otError otMessageSetLength(
otMessage *aMessage,
uint16_t aLength
)
設定訊息長度 (以位元組為單位)。
詳細說明 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回值 |
|
otMessageFree
otMessageGetLength
otMessageGetOffset
otMessageSetOffset
otMessageRead
otMessageWrite
otMessageSetLoopbackToHostAllowed
void otMessageSetLoopbackToHostAllowed(
otMessage *aMessage,
bool aAllowLoopbackToHost
)
設定是否允許郵件循環播放至主機。
詳細說明 | |||||
---|---|---|---|---|---|
參數 |
|
otMessageSetMulticastLoopEnabled
void otMessageSetMulticastLoopEnabled(
otMessage *aMessage,
bool aEnabled
)
控制在多點傳播目的地位址的情況下,特定訊息是否可循環播放。
詳細說明 | |||||
---|---|---|---|---|---|
參數 |
|
otMessageSetOffset
void otMessageSetOffset(
otMessage *aMessage,
uint16_t aOffset
)
設定訊息偏移 (以位元組為單位)。
詳細說明 | |||||
---|---|---|---|---|---|
參數 |
|
otMessageFree
otMessageGetLength
otMessageSetLength
otMessageGetOffset
otMessageRead
otMessageWrite
otMessageSetOrigin
void otMessageSetOrigin(
otMessage *aMessage,
otMessageOrigin aOrigin
)
設定訊息來源。
詳細說明 | |||||
---|---|---|---|---|---|
參數 |
|
otMessageWrite
int otMessageWrite(
otMessage *aMessage,
uint16_t aOffset,
const void *aBuf,
uint16_t aLength
)
將位元組寫入訊息。
詳細說明 | |||||||||
---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||
傳回 |
已寫入的位元組數。
|
otMessageFree
otMessageGetLength
otMessageSetLength
otMessageGetOffset
otMessageSetOffset
otMessageRead
資源
OpenThread API 參考資料主題源自原始碼,請前往 GitHub 取得。如要瞭解詳情或對說明文件做出貢獻,請參閱資源。