單次安裝出價
這個模組包含控制 CoAP 通訊的功能。
摘要
啟用 CoAP API 功能 (OPENTHREAD_CONFIG_COAP_API_ENABLE
) 後,就能使用這個模組中的函式。
Typedefs |
|
---|---|
otCoapBlockSzx
|
typedefenum otCoapBlockSzx
CoAP 區塊大小指數。 |
otCoapBlockwiseReceiveHook)(void *aContext, const uint8_t *aBlock, uint32_t aPosition, uint16_t aBlockLength, bool aMore, uint32_t aTotalLength)
|
typedefotError(*
收到包含封鎖區塊轉移選項的 CoAP 訊息時,系統會呼叫此函式指標。 |
otCoapBlockwiseResource
|
typedefstruct otCoapBlockwiseResource
這個結構代表以區塊轉移的 CoAP 資源。 |
otCoapBlockwiseTransmitHook)(void *aContext, uint8_t *aBlock, uint32_t aPosition, uint16_t *aBlockLength, bool *aMore)
|
typedefotError(*
系統會先呼叫此函式指標,再傳送區塊區塊傳輸的下一個區塊。 |
otCoapCode
|
typedefenum otCoapCode
CoAP 代碼值。 |
otCoapOption
|
typedefstruct otCoapOption
這個結構代表 CoAP 選項。 |
otCoapOptionContentFormat
|
typedef CoAP 內容格式代碼。 |
otCoapOptionIterator
|
typedefstruct otCoapOptionIterator
此結構可做為 CoAP 選項的疊代器。 |
otCoapOptionType
|
typedefenum otCoapOptionType
CoAP 選項編號。 |
otCoapRequestHandler)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
|
typedefvoid(*
收到包含指定 Uri-Path 的 CoAP 請求時,系統會呼叫此函式指標。 |
otCoapResource
|
typedefstruct otCoapResource
這個結構代表 CoAP 資源。 |
otCoapResponseHandler)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, otError aResult)
|
typedefvoid(*
收到 CoAP 回應或要求逾時時,系統會呼叫此函式指標。 |
otCoapTxParameters
|
typedefstruct otCoapTxParameters
這個結構代表 CoAP 傳輸參數。 |
otCoapType
|
typedefenum otCoapType
CoAP 類型值 (2 位元無符號整數)。 |
Functions |
|
---|---|
otCoapAddBlockWiseResource(otInstance *aInstance, otCoapBlockwiseResource *aResource)
|
void
這個函式會將區塊化資源新增至 CoAP 伺服器。
|
otCoapAddResource(otInstance *aInstance, otCoapResource *aResource)
|
void
這個函式會將資源新增至 CoAP 伺服器。
|
otCoapBlockSizeFromExponent(otCoapBlockSzx aSize)
|
uint16_t
這個函式會將 CoAP Block 選項 SZX 欄位轉換為實際區塊大小。
|
otCoapMessageAppendBlock1Option(otMessage *aMessage, uint32_t aNum, bool aMore, otCoapBlockSzx aSize)
|
這個函式會附加 Block1 選項。
|
otCoapMessageAppendBlock2Option(otMessage *aMessage, uint32_t aNum, bool aMore, otCoapBlockSzx aSize)
|
這個函式會附加 Block2 選項。
|
otCoapMessageAppendContentFormatOption(otMessage *aMessage, otCoapOptionContentFormat aContentFormat)
|
這個函式會附加 https://tools.ietf.org/html/rfc7252#page-92 中指定的內容格式 CoAP 選項。
|
otCoapMessageAppendMaxAgeOption(otMessage *aMessage, uint32_t aMaxAge)
|
這個函式會附加 Max-Age 選項。
|
otCoapMessageAppendObserveOption(otMessage *aMessage, uint32_t aObserve)
|
這個函式會附加觀察項目選項。
|
otCoapMessageAppendOption(otMessage *aMessage, uint16_t aNumber, uint16_t aLength, const void *aValue)
|
這個函式會在標頭中附加 CoAP 選項。
|
otCoapMessageAppendProxyUriOption(otMessage *aMessage, const char *aUriPath)
|
這個函式會附加 Proxy-Uri 選項。
|
otCoapMessageAppendUintOption(otMessage *aMessage, uint16_t aNumber, uint32_t aValue)
|
這個函式會附加 https://tools.ietf.org/html/rfc7252#section-3.2 中指定的未簽署整數 CoAP 選項。
|
otCoapMessageAppendUriPathOptions(otMessage *aMessage, const char *aUriPath)
|
這個函式會附加 Uri-Path 選項。
|
otCoapMessageAppendUriQueryOption(otMessage *aMessage, const char *aUriQuery)
|
這個函式會附加單一 UriQuery 選項。
|
otCoapMessageCodeToString(const otMessage *aMessage)
|
const char *
這個方法會傳回 CoAP 程式碼做為使用者可理解的字串。
|
otCoapMessageGenerateToken(otMessage *aMessage, uint8_t aTokenLength)
|
void
這個函式會設定權杖長度,並隨機將其值。
|
otCoapMessageGetCode(const otMessage *aMessage)
|
這個函式會傳回代碼值。
|
otCoapMessageGetMessageId(const otMessage *aMessage)
|
uint16_t
這個函式會傳回訊息 ID 值。
|
otCoapMessageGetToken(const otMessage *aMessage)
|
const uint8_t *
這個函式會傳回指向 Token 值的指標。
|
otCoapMessageGetTokenLength(const otMessage *aMessage)
|
uint8_t
這個函式會傳回權杖長度。
|
otCoapMessageGetType(const otMessage *aMessage)
|
這個函式會傳回類型值。
|
otCoapMessageInit(otMessage *aMessage, otCoapType aType, otCoapCode aCode)
|
void
這個函式會初始化 CoAP 標頭。
|
otCoapMessageInitResponse(otMessage *aResponse, const otMessage *aRequest, otCoapType aType, otCoapCode aCode)
|
這個函式會初始化回應訊息。
|
otCoapMessageSetCode(otMessage *aMessage, otCoapCode aCode)
|
void
這個函式會設定代碼值。
|
otCoapMessageSetPayloadMarker(otMessage *aMessage)
|
這個函式會將酬載標記新增至酬載的 CoAP 標頭。
|
otCoapMessageSetToken(otMessage *aMessage, const uint8_t *aToken, uint8_t aTokenLength)
|
這個函式會在標頭中設定權杖值和長度。
|
otCoapNewMessage(otInstance *aInstance, const otMessageSettings *aSettings)
|
這個函式會建立新的 CoAP 訊息。
|
otCoapOptionIteratorGetFirstOption(otCoapOptionIterator *aIterator)
|
const otCoapOption *
這個函式會傳回第一個選項的指標。
|
otCoapOptionIteratorGetFirstOptionMatching(otCoapOptionIterator *aIterator, uint16_t aOption)
|
const otCoapOption *
這個函式會傳回指標,指向指定選項編號的第一個選項。
|
otCoapOptionIteratorGetNextOption(otCoapOptionIterator *aIterator)
|
const otCoapOption *
這個函式會傳回指向下一個選項的指標。
|
otCoapOptionIteratorGetNextOptionMatching(otCoapOptionIterator *aIterator, uint16_t aOption)
|
const otCoapOption *
這個函式會傳回指向符合指定選項編號的下一個選項的指標。
|
otCoapOptionIteratorGetOptionUintValue(otCoapOptionIterator *aIterator, uint64_t *aValue)
|
根據 https://tools.ietf.org/html/rfc7252#section-3.2 編碼時,這個函式會將目前選項值填入
aValue 中。 |
otCoapOptionIteratorGetOptionValue(otCoapOptionIterator *aIterator, void *aValue)
|
這個函式會將目前的選項值填入
aValue 。 |
otCoapOptionIteratorInit(otCoapOptionIterator *aIterator, const otMessage *aMessage)
|
這個函式會初始化指定訊息中選項的疊代器。
|
otCoapRemoveBlockWiseResource(otInstance *aInstance, otCoapBlockwiseResource *aResource)
|
void
這個函式會從 CoAP 伺服器中移除區塊資源,
|
otCoapRemoveResource(otInstance *aInstance, otCoapResource *aResource)
|
void
這個函式會從 CoAP 伺服器中移除資源。
|
otCoapSendRequest(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, otCoapResponseHandler aHandler, void *aContext)
|
這個函式會傳送 CoAP 要求。
|
otCoapSendRequestBlockWise(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, otCoapResponseHandler aHandler, void *aContext, otCoapBlockwiseTransmitHook aTransmitHook, otCoapBlockwiseReceiveHook aReceiveHook)
|
這個函式是以區塊方式傳送 CoAP 要求。
|
otCoapSendRequestBlockWiseWithParameters(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, otCoapResponseHandler aHandler, void *aContext, const otCoapTxParameters *aTxParameters, otCoapBlockwiseTransmitHook aTransmitHook, otCoapBlockwiseReceiveHook aReceiveHook)
|
這個函式會以自訂傳輸參數來區塊傳送 CoAP 要求。
|
otCoapSendRequestWithParameters(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, otCoapResponseHandler aHandler, void *aContext, const otCoapTxParameters *aTxParameters)
|
這個函式會傳送含有自訂傳輸參數的 CoAP 要求。
|
otCoapSendResponse(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo)
|
這個函式會從伺服器傳送 CoAP 回應。
|
otCoapSendResponseBlockWise(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, void *aContext, otCoapBlockwiseTransmitHook aTransmitHook)
|
這個函式會以區塊方式從伺服器傳送 CoAP 回應。
|
otCoapSendResponseBlockWiseWithParameters(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, const otCoapTxParameters *aTxParameters, void *aContext, otCoapBlockwiseTransmitHook aTransmitHook)
|
這個函式會透過自訂傳輸參數,以區塊方式從伺服器傳送 CoAP 回應。
|
otCoapSendResponseWithParameters(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, const otCoapTxParameters *aTxParameters)
|
這個函式會從伺服器傳送自訂傳輸參數的 CoAP 回應,
|
otCoapSetDefaultHandler(otInstance *aInstance, otCoapRequestHandler aHandler, void *aContext)
|
void
這個函式會設定未處理的 CoAP 要求的預設處理常式。
|
otCoapStart(otInstance *aInstance, uint16_t aPort)
|
這個函式會啟動 CoAP 伺服器。
|
otCoapStop(otInstance *aInstance)
|
這個函式會停止 CoAP 伺服器。
|
結構 |
|
---|---|
otCoapBlockwiseResource |
這個結構代表以區塊轉移的 CoAP 資源。 |
otCoapOption |
這個結構代表 CoAP 選項。 |
otCoapOptionIterator |
此結構可做為 CoAP 選項的疊代器。 |
otCoapResource |
這個結構代表 CoAP 資源。 |
otCoapTxParameters |
這個結構代表 CoAP 傳輸參數。 |
列舉
OTCoapBlockSzx
otCoapBlockSzx
CoAP 區塊大小指數。
otCoapCode
otCoapCode
CoAP 代碼值。
屬性 | |
---|---|
OT_COAP_CODE_BAD_GATEWAY
|
閘道不佳, |
OT_COAP_CODE_BAD_OPTION
|
選項無效。 |
OT_COAP_CODE_BAD_REQUEST
|
錯誤的要求。 |
OT_COAP_CODE_CHANGED
|
已變更。 |
OT_COAP_CODE_CONTENT
|
內容。 |
OT_COAP_CODE_CONTINUE
|
RFC7959 繼續。 |
OT_COAP_CODE_CREATED
|
已建立。 |
OT_COAP_CODE_DELETE
|
。 |
OT_COAP_CODE_DELETED
|
已刪除。 |
OT_COAP_CODE_EMPTY
|
無訊息代碼。 |
OT_COAP_CODE_FORBIDDEN
|
禁止存取。 |
OT_COAP_CODE_GATEWAY_TIMEOUT
|
閘道逾時, |
OT_COAP_CODE_GET
|
立即取得。 |
OT_COAP_CODE_INTERNAL_ERROR
|
發生內部伺服器錯誤。 |
OT_COAP_CODE_METHOD_NOT_ALLOWED
|
系統不允許的方法。 |
OT_COAP_CODE_NOT_ACCEPTABLE
|
不可接受。 |
OT_COAP_CODE_NOT_FOUND
|
找不到。 |
OT_COAP_CODE_NOT_IMPLEMENTED
|
未執行。 |
OT_COAP_CODE_POST
|
貼文。 |
OT_COAP_CODE_PRECONDITION_FAILED
|
先決條件失敗。 |
OT_COAP_CODE_PROXY_NOT_SUPPORTED
|
不支援 Proxy。 |
OT_COAP_CODE_PUT
|
加入 |
OT_COAP_CODE_REQUEST_INCOMPLETE
|
RFC7959 要求實體不完整。 |
OT_COAP_CODE_REQUEST_TOO_LARGE
|
Request Entity Too Large (要求實體過大)。 |
OT_COAP_CODE_RESPONSE_MIN
|
2.00 |
OT_COAP_CODE_SERVICE_UNAVAILABLE
|
無法使用服務。 |
OT_COAP_CODE_UNAUTHORIZED
|
未經授權, |
OT_COAP_CODE_UNSUPPORTED_FORMAT
|
不支援的內容格式。 |
OT_COAP_CODE_VALID
|
有效。 |
otCoapOptionContentFormat
otCoapOptionContentFormat
CoAP 內容格式代碼。
如要查看完整清單,請前往 https://www.iana.org/assignments/core-parameters/core-parameters.xhtml#content-formats
otCoapOptionType
otCoapOptionType
CoAP 選項編號。
屬性 | |
---|---|
OT_COAP_OPTION_ACCEPT
|
接受。 |
OT_COAP_OPTION_BLOCK1
|
區塊 1 (RFC7959) |
OT_COAP_OPTION_BLOCK2
|
區塊 2 (RFC7959) |
OT_COAP_OPTION_CONTENT_FORMAT
|
內容格式。 |
OT_COAP_OPTION_E_TAG
|
ETag。 |
OT_COAP_OPTION_IF_MATCH
|
If-Match。 |
OT_COAP_OPTION_IF_NONE_MATCH
|
If-None-Match。 |
OT_COAP_OPTION_LOCATION_PATH
|
位置路徑。 |
OT_COAP_OPTION_LOCATION_QUERY
|
Location-Query。 |
OT_COAP_OPTION_MAX_AGE
|
Max-Age。 |
OT_COAP_OPTION_OBSERVE
|
請觀察 [RFC7641]。 |
OT_COAP_OPTION_PROXY_SCHEME
|
Proxy 配置。 |
OT_COAP_OPTION_PROXY_URI
|
Proxy-Uri。 |
OT_COAP_OPTION_SIZE1
|
大小 1。 |
OT_COAP_OPTION_SIZE2
|
大小 2 (RFC7959) |
OT_COAP_OPTION_URI_HOST
|
U-Host。 |
OT_COAP_OPTION_URI_PATH
|
URI 路徑。 |
OT_COAP_OPTION_URI_PORT
|
URI 通訊埠。 |
OT_COAP_OPTION_URI_QUERY
|
Uri-Query。 |
otCoapType
otCoapType
CoAP 類型值 (2 位元無符號整數)。
屬性 | |
---|---|
OT_COAP_TYPE_ACKNOWLEDGMENT
|
認證。 |
OT_COAP_TYPE_CONFIRMABLE
|
可確認。 |
OT_COAP_TYPE_NON_CONFIRMABLE
|
無法確認。 |
OT_COAP_TYPE_RESET
|
重設。 |
Typedefs
OTCoapBlockwiseReceiveHook
otError(* otCoapBlockwiseReceiveHook)(void *aContext, const uint8_t *aBlock, uint32_t aPosition, uint16_t aBlockLength, bool aMore, uint32_t aTotalLength)
收到包含封鎖區塊轉移選項的 CoAP 訊息時,系統會呼叫此函式指標。
您必須啟用 OPENNON_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE 設定,才能使用這項功能。
詳情 | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||||||
傳回值 |
|
OTCoapBlockwiseResource
struct otCoapBlockwiseResource otCoapBlockwiseResource
這個結構代表以區塊轉移的 CoAP 資源。
OTCoapBlockwiseTransmitHook
otError(* otCoapBlockwiseTransmitHook)(void *aContext, uint8_t *aBlock, uint32_t aPosition, uint16_t *aBlockLength, bool *aMore)
系統會先呼叫此函式指標,再傳送區塊區塊傳輸的下一個區塊。
您必須啟用 OPENNON_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE 設定,才能使用這項功能。
變更 aBlockLength 的值後,系統會重新協商整個廣告交易平台的區塊大小。建議您在收到第一個區塊後執行此動作,因為後續變更可能會導致其他 CoAP 實作發生問題。
詳情 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||||
傳回值 |
|
otCoapOptionContentFormat
enum otCoapOptionContentFormat otCoapOptionContentFormat
CoAP 內容格式代碼。
如要查看完整清單,請前往 https://www.iana.org/assignments/core-parameters/core-parameters.xhtml#content-formats
otCoapRequestHandler
void(* otCoapRequestHandler)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
收到包含指定 Uri-Path 的 CoAP 請求時,系統會呼叫此函式指標。
詳情 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
otCoapResponseHandler
void(* otCoapResponseHandler)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, otError aResult)
收到 CoAP 回應或要求逾時時,系統會呼叫此函式指標。
詳情 | |||||||||
---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||
傳回值 |
|
Functions
OTCoapAddBlockWiseResource
void otCoapAddBlockWiseResource( otInstance *aInstance, otCoapBlockwiseResource *aResource )
這個函式會將區塊化資源新增至 CoAP 伺服器。
詳情 | |||||
---|---|---|---|---|---|
參數 |
|
otCoapAddResource
void otCoapAddResource( otInstance *aInstance, otCoapResource *aResource )
這個函式會將資源新增至 CoAP 伺服器。
詳情 | |||||
---|---|---|---|---|---|
參數 |
|
otCoapBlockSizeFromExponent
uint16_t otCoapBlockSizeFromExponent( otCoapBlockSzx aSize )
這個函式會將 CoAP Block 選項 SZX 欄位轉換為實際區塊大小。
詳情 | |||
---|---|---|---|
參數 |
|
||
傳回 |
實際大小指數值。
|
otCoapMessage 附加封鎖 1 選項
otError otCoapMessageAppendBlock1Option( otMessage *aMessage, uint32_t aNum, bool aMore, otCoapBlockSzx aSize )
這個函式會附加 Block1 選項。
詳情 | |||||||||
---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||
傳回值 |
|
otCoapMessage 附加封鎖 2 選項
otError otCoapMessageAppendBlock2Option( otMessage *aMessage, uint32_t aNum, bool aMore, otCoapBlockSzx aSize )
這個函式會附加 Block2 選項。
詳情 | |||||||||
---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||
傳回值 |
|
otCoapMessage 附加內容格式選項
otError otCoapMessageAppendContentFormatOption( otMessage *aMessage, otCoapOptionContentFormat aContentFormat )
這個函式會附加 https://tools.ietf.org/html/rfc7252#page-92 中指定的內容格式 CoAP 選項。
如果訊息中含有酬載,您「必須」呼叫 otCoapMessageSetPayloadMarker。
這個函式是 otCoapMessageAttachUintOption 的便利包裝函式,如果 otCoapOptionContentFormat 中未列出所需格式類型代碼,請改用此基本函式。
詳情 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
||||||
傳回值 |
|
otCoapMessageAttachMaxAgeOption
otError otCoapMessageAppendMaxAgeOption( otMessage *aMessage, uint32_t aMaxAge )
這個函式會附加 Max-Age 選項。
詳情 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
||||||
傳回值 |
|
otCoapMessageAttachObserveOption
otError otCoapMessageAppendObserveOption( otMessage *aMessage, uint32_t aObserve )
這個函式會附加觀察項目選項。
詳情 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
||||||
傳回值 |
|
otCoapMessage 附加選項
otError otCoapMessageAppendOption( otMessage *aMessage, uint16_t aNumber, uint16_t aLength, const void *aValue )
這個函式會在標頭中附加 CoAP 選項。
詳情 | |||||||||
---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||
傳回值 |
|
otCoapMessageAttachProxyUriOption
otError otCoapMessageAppendProxyUriOption( otMessage *aMessage, const char *aUriPath )
這個函式會附加 Proxy-Uri 選項。
詳情 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
||||||
傳回值 |
|
otCoapMessageAttachUintOption
otError otCoapMessageAppendUintOption( otMessage *aMessage, uint16_t aNumber, uint32_t aValue )
這個函式會附加 https://tools.ietf.org/html/rfc7252#section-3.2 中指定的未簽署整數 CoAP 選項。
詳情 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
||||||
傳回值 |
|
otCoapMessageGetOptionUintValue
otCoapMessageAttachUriPathOptions
otError otCoapMessageAppendUriPathOptions( otMessage *aMessage, const char *aUriPath )
這個函式會附加 Uri-Path 選項。
詳情 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
||||||
傳回值 |
|
otCoapMessageAttachUriQueryOption
otError otCoapMessageAppendUriQueryOption( otMessage *aMessage, const char *aUriQuery )
這個函式會附加單一 UriQuery 選項。
詳情 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
||||||
傳回值 |
|
otCoapMessageCodeToString
const char * otCoapMessageCodeToString( const otMessage *aMessage )
這個方法會傳回 CoAP 程式碼做為使用者可理解的字串。
@ 會以字串傳回 CoAP 代碼。
詳情 | |||
---|---|---|---|
參數 |
|
otCoapMessageGenerateToken
void otCoapMessageGenerateToken( otMessage *aMessage, uint8_t aTokenLength )
這個函式會設定權杖長度,並隨機將其值。
詳情 | |||||
---|---|---|---|---|---|
參數 |
|
otCoapMessageGetCode
otCoapCode otCoapMessageGetCode( const otMessage *aMessage )
這個函式會傳回代碼值。
詳情 | |||
---|---|---|---|
參數 |
|
||
傳回 |
代碼值。
|
otCoapMessageGetMessageId
uint16_t otCoapMessageGetMessageId( const otMessage *aMessage )
這個函式會傳回訊息 ID 值。
詳情 | |||
---|---|---|---|
參數 |
|
||
傳回 |
郵件 ID 值。
|
otCoapMessageGetToken
const uint8_t * otCoapMessageGetToken( const otMessage *aMessage )
這個函式會傳回指向 Token 值的指標。
詳情 | |||
---|---|---|---|
參數 |
|
||
傳回 |
指向 Token 值的指標。
|
otCoapMessageGetTokenLength
uint8_t otCoapMessageGetTokenLength( const otMessage *aMessage )
這個函式會傳回權杖長度。
詳情 | |||
---|---|---|---|
參數 |
|
||
傳回 |
權杖長度。
|
otCoapMessageGetType
otCoapType otCoapMessageGetType( const otMessage *aMessage )
這個函式會傳回類型值。
詳情 | |||
---|---|---|---|
參數 |
|
||
傳回 |
類型值。
|
otCoapMessageInit
void otCoapMessageInit( otMessage *aMessage, otCoapType aType, otCoapCode aCode )
這個函式會初始化 CoAP 標頭。
詳情 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
otCoapMessageInitResponse
otError otCoapMessageInitResponse( otMessage *aResponse, const otMessage *aRequest, otCoapType aType, otCoapCode aCode )
這個函式會初始化回應訊息。
詳情 | |||||||||
---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||
傳回值 |
|
otCoapMessageSetCode
void otCoapMessageSetCode( otMessage *aMessage, otCoapCode aCode )
這個函式會設定代碼值。
詳情 | |||||
---|---|---|---|---|---|
參數 |
|
otCoapMessageSetPayloadMarker
otError otCoapMessageSetPayloadMarker( otMessage *aMessage )
這個函式會將酬載標記新增至酬載的 CoAP 標頭。
詳情 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回值 |
|
otCoapMessageSetToken
otError otCoapMessageSetToken( otMessage *aMessage, const uint8_t *aToken, uint8_t aTokenLength )
這個函式會在標頭中設定權杖值和長度。
詳情 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
||||||
傳回值 |
|
otCoapNewMessage
otMessage * otCoapNewMessage( otInstance *aInstance, const otMessageSettings *aSettings )
這個函式會建立新的 CoAP 訊息。
詳情 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回 |
如果沒有可用的訊息緩衝區或參數無效,表示訊息緩衝區的指標。
|
otCoapOptionIteratorGetFirstOption
const otCoapOption * otCoapOptionIteratorGetFirstOption( otCoapOptionIterator *aIterator )
這個函式會傳回第一個選項的指標。
詳情 | |||
---|---|---|---|
參數 |
|
||
傳回 |
第一個選項的指標。如果沒有選項,則會傳回 NULL 指標。
|
otCoapOptionIteratorGetFirstOptionMatching
const otCoapOption * otCoapOptionIteratorGetFirstOptionMatching( otCoapOptionIterator *aIterator, uint16_t aOption )
這個函式會傳回指標,指向指定選項編號的第一個選項。
詳情 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回 |
第一個比對選項的指標。如果沒有相符選項,則不會傳回 NULL 指標。
|
otCoapOptionIteratorGetNextOption
const otCoapOption * otCoapOptionIteratorGetNextOption( otCoapOptionIterator *aIterator )
這個函式會傳回指向下一個選項的指標。
詳情 | |||
---|---|---|---|
參數 |
|
||
傳回 |
指向下一個選項的指標。如果沒有其他選項,則會傳回 NULL 指標。
|
otCoapOptionIteratorGetNextOptionMatching
const otCoapOption * otCoapOptionIteratorGetNextOptionMatching( otCoapOptionIterator *aIterator, uint16_t aOption )
這個函式會傳回指向符合指定選項編號的下一個選項的指標。
詳情 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回 |
指向下一個相符選項的指標。如果沒有進一步比對選項,則不會傳回 NULL 指標。
|
otCoapOptionIteratorGetOptionUintValue
otError otCoapOptionIteratorGetOptionUintValue( otCoapOptionIterator *aIterator, uint64_t *aValue )
根據 https://tools.ietf.org/html/rfc7252#section-3.2 編碼時,這個函式會將目前選項值填入 aValue
中。
詳情 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
||||||
傳回值 |
|
otCoapMessageAttachUintOption
otCoapOptionIteratorGetOptionValue
otError otCoapOptionIteratorGetOptionValue( otCoapOptionIterator *aIterator, void *aValue )
這個函式會將目前的選項值填入 aValue
。
詳情 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回值 |
|
otCoapOptionIteratorInit
otError otCoapOptionIteratorInit( otCoapOptionIterator *aIterator, const otMessage *aMessage )
這個函式會初始化指定訊息中選項的疊代器。
詳情 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回值 |
|
otCoapRemoveBlockWiseResource
void otCoapRemoveBlockWiseResource( otInstance *aInstance, otCoapBlockwiseResource *aResource )
這個函式會從 CoAP 伺服器中移除區塊資源,
詳情 | |||||
---|---|---|---|---|---|
參數 |
|
otCoapRemoveResource
void otCoapRemoveResource( otInstance *aInstance, otCoapResource *aResource )
這個函式會從 CoAP 伺服器中移除資源。
詳情 | |||||
---|---|---|---|---|---|
參數 |
|
otCoapSendRequest
otError otCoapSendRequest( otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, otCoapResponseHandler aHandler, void *aContext )
這個函式會傳送 CoAP 要求。
如果要求回應,應提供個別函式和情境資訊。如果預期沒有回應,這些引數應為 NULL 指標。
詳情 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||||
傳回值 |
|
otCoapSendRequestBlockWise
otError otCoapSendRequestBlockWise( otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, otCoapResponseHandler aHandler, void *aContext, otCoapBlockwiseTransmitHook aTransmitHook, otCoapBlockwiseReceiveHook aReceiveHook )
這個函式是以區塊方式傳送 CoAP 要求。
您必須啟用 OPENNON_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE 設定,才能使用這項功能。
如果要求回應,應提供個別函式和情境資訊。如果回應預計是區塊封鎖,就應該提供對應的掛鉤函式。如果預期沒有回應,這些引數應為 NULL 指標。
詳情 | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||||||||
傳回值 |
|
otCoapSendRequestBlockWiseWithParameters
otError otCoapSendRequestBlockWiseWithParameters( otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, otCoapResponseHandler aHandler, void *aContext, const otCoapTxParameters *aTxParameters, otCoapBlockwiseTransmitHook aTransmitHook, otCoapBlockwiseReceiveHook aReceiveHook )
這個函式會以自訂傳輸參數來區塊傳送 CoAP 要求。
您必須啟用 OPENNON_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE 設定,才能使用這項功能。
如果要求回應,應提供個別函式和情境資訊。如果回應預計是區塊封鎖,就應該提供對應的掛鉤函式。如果預期沒有回應,這些引數應為 NULL 指標。
詳情 | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||||||||||
傳回值 |
|
otCoapSendRequestWithParameters
otError otCoapSendRequestWithParameters( otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, otCoapResponseHandler aHandler, void *aContext, const otCoapTxParameters *aTxParameters )
這個函式會傳送含有自訂傳輸參數的 CoAP 要求。
如果要求回應,應提供個別函式和情境資訊。如果預期沒有回應,這些引數應為 NULL 指標。
詳情 | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||||||
傳回值 |
|
otCoapSendResponse
otError otCoapSendResponse( otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo )
這個函式會從伺服器傳送 CoAP 回應。
詳情 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
||||||
傳回值 |
|
OTCoapSendResponseBlockWise
otError otCoapSendResponseBlockWise( otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, void *aContext, otCoapBlockwiseTransmitHook aTransmitHook )
這個函式會以區塊方式從伺服器傳送 CoAP 回應。
您必須啟用 OPENNON_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE 設定,才能使用這項功能。
詳情 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||||
傳回值 |
|
otCoapSendResponseBlockWiseWithParameters
otError otCoapSendResponseBlockWiseWithParameters( otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, const otCoapTxParameters *aTxParameters, void *aContext, otCoapBlockwiseTransmitHook aTransmitHook )
這個函式會透過自訂傳輸參數,以區塊方式從伺服器傳送 CoAP 回應。
您必須啟用 OPENNON_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE 設定,才能使用這項功能。
詳情 | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||||||
傳回值 |
|
otCoapSendResponseWithParameters
otError otCoapSendResponseWithParameters( otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, const otCoapTxParameters *aTxParameters )
這個函式會從伺服器傳送自訂傳輸參數的 CoAP 回應,
詳情 | |||||||||
---|---|---|---|---|---|---|---|---|---|
參數 |
|
||||||||
傳回值 |
|
otCoapSetDefaultHandler
void otCoapSetDefaultHandler( otInstance *aInstance, otCoapRequestHandler aHandler, void *aContext )
這個函式會設定未處理的 CoAP 要求的預設處理常式。
詳情 | |||||||
---|---|---|---|---|---|---|---|
參數 |
|
otCoapStart
otError otCoapStart( otInstance *aInstance, uint16_t aPort )
這個函式會啟動 CoAP 伺服器。
詳情 | |||||
---|---|---|---|---|---|
參數 |
|
||||
傳回值 |
|
otCoapStop
otError otCoapStop( otInstance *aInstance )
這個函式會停止 CoAP 伺服器。
詳情 | |||
---|---|---|---|
參數 |
|
||
傳回值 |
|
巨集
OT_COAP_CODE
OT_COAP_CODE ((((c)&0x7) << 5) | ((d)&0x1f))
用來定義 CoAP 代碼值的輔助巨集。
OT_COAP_DEFAULT_TOKEN_LENGTH
OT_COAP_DEFAULT_TOKEN_LENGTH 2
預設權杖長度。
OT_COAP_MAX_RETRANSMIT
OT_COAP_MAX_RETRANSMIT 20
OpenThread 支援的重新傳輸上限。
OT_COAP_MAX_TOKEN_LENGTH
OT_COAP_MAX_TOKEN_LENGTH 8
指定權杖長度上限 (RFC 7252)。
OT_COAP_MIN_ACK_TIMEOUT
OT_COAP_MIN_ACK_TIMEOUT 1000
OpenThread 支援的最小 ACK 逾時時間 (以毫秒為單位)。
OTONEDEFAULT_COAP_PORT
OT_DEFAULT_COAP_PORT 5683
預設的 CoAP 通訊埠,如 RFC 7252 中所述。
資源
OpenThread API 參考資料主題出自原始碼,可於 GitHub 取得。如需更多資訊,或想參閱我們的說明文件,請參閱資源。