Implement more CoAP Options (#1362)

* Implement more CoAP Options

* Observe
* Max-Age
* Uri-Query
This commit is contained in:
Giedrius
2017-02-27 09:08:50 -08:00
committed by Jonathan Hui
parent 250249ac38
commit b8ae672251
4 changed files with 136 additions and 0 deletions
+39
View File
@@ -91,8 +91,11 @@ typedef enum otCoapCode
*/
typedef enum otCoapOptionType
{
kCoapOptionObserve = 6, ///< Observe
kCoapOptionUriPath = 11, ///< Uri-Path
kCoapOptionContentFormat = 12, ///< Content-Format
kCoapOptionMaxAge = 14, ///< Max-Age
kCoapOptionUriQuery = 15, ///< Uri-Query
} otCoapOptionType;
/**
@@ -214,6 +217,18 @@ void otCoapHeaderGenerateToken(otCoapHeader *aHeader, uint8_t aTokenLength);
*/
ThreadError otCoapHeaderAppendOption(otCoapHeader *aHeader, const otCoapOption *aOption);
/**
* This function appends an Observe option.
*
* @param[inout] aHeader A pointer to the CoAP header.
* @param[in] aObserve Observe field value.
*
* @retval kThreadError_None Successfully appended the option.
* @retval kThreadError_InvalidArgs The option type is not equal or greater than the last option type.
* @retval kThreadError_NoBufs The option length exceeds the buffer size.
*/
ThreadError otCoapHeaderAppendObserveOption(otCoapHeader *aHeader, uint32_t aObserve);
/**
* This function appends an Uri-Path option.
*
@@ -227,6 +242,30 @@ ThreadError otCoapHeaderAppendOption(otCoapHeader *aHeader, const otCoapOption *
*/
ThreadError otCoapHeaderAppendUriPathOptions(otCoapHeader *aHeader, const char *aUriPath);
/**
* This function appends a Max-Age option.
*
* @param[inout] aHeader A pointer to the CoAP header.
* @param[in] aMaxAge The Max-Age value.
*
* @retval kThreadError_None Successfully appended the option.
* @retval kThreadError_InvalidArgs The option type is not equal or greater than the last option type.
* @retval kThreadError_NoBufs The option length exceeds the buffer size.
*/
ThreadError otCoapHeaderAppendMaxAgeOption(otCoapHeader *aHeader, uint32_t aMaxAge);
/**
* This function appends a single Uri-Query option.
*
* @param[inout] aHeader A pointer to the CoAP header.
* @param[in] aUriQuery A pointer to NULL-terminated string, which should contain a single key=value pair.
*
* @retval kThreadError_None Successfully appended the option.
* @retval kThreadError_InvalidArgs The option type is not equal or greater than the last option type.
* @retval kThreadError_NoBufs The option length exceeds the buffer size.
*/
ThreadError otCoapHeaderAppendUriQueryOption(otCoapHeader *aHeader, const char *aUriQuery);
/**
* This function adds Payload Marker indicating beginning of the payload to the CoAP header.
*