Combine CoAP Client and Server into a single CoAP agent. (#1745)

This commit is contained in:
Jonathan Hui
2017-05-12 11:51:19 -07:00
committed by GitHub
parent 08e52e55a5
commit 39b1162b1e
72 changed files with 1722 additions and 2349 deletions
+5 -15
View File
@@ -449,11 +449,12 @@ ThreadError otCoapSendRequest(otInstance *aInstance, otMessage *aMessage, const
* This function starts the CoAP server.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aPort The local UDP port to bind to.
*
* @retval kThreadError_None Successfully started the CoAP server.
*
*/
ThreadError otCoapServerStart(otInstance *aInstance);
ThreadError otCoapStart(otInstance *aInstance, uint16_t aPort);
/**
* This function stops the CoAP server.
@@ -463,18 +464,7 @@ ThreadError otCoapServerStart(otInstance *aInstance);
* @retval kThreadError_None Successfully stopped the CoAP server.
*
*/
ThreadError otCoapServerStop(otInstance *aInstance);
/**
* This function sets CoAP server's port number.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aPort A port number to set.
*
* @retval kThreadError_None Binding with a port succeeded.
*
*/
ThreadError otCoapServerSetPort(otInstance *aInstance, uint16_t aPort);
ThreadError otCoapStop(otInstance *aInstance);
/**
* This function adds a resource to the CoAP server.
@@ -486,7 +476,7 @@ ThreadError otCoapServerSetPort(otInstance *aInstance, uint16_t aPort);
* @retval kThreadError_Already The @p aResource was already added.
*
*/
ThreadError otCoapServerAddResource(otInstance *aInstance, otCoapResource *aResource);
ThreadError otCoapAddResource(otInstance *aInstance, otCoapResource *aResource);
/**
* This function removes a resource from the CoAP server.
@@ -495,7 +485,7 @@ ThreadError otCoapServerAddResource(otInstance *aInstance, otCoapResource *aReso
* @param[in] aResource A pointer to the resource.
*
*/
void otCoapServerRemoveResource(otInstance *aInstance, otCoapResource *aResource);
void otCoapRemoveResource(otInstance *aInstance, otCoapResource *aResource);
/**
* This function sends a CoAP response from the server.
+42 -13
View File
@@ -57,12 +57,13 @@
WPP_DEFINE_BIT(OT_MAC) /* 0x00000400 */ \
WPP_DEFINE_BIT(OT_MEM) /* 0x00000800 */ \
WPP_DEFINE_BIT(OT_NCP) /* 0x00001000 */ \
WPP_DEFINE_BIT(OT_COAP) /* 0x00002000 */ \
WPP_DEFINE_BIT(OT_MESHCOP) /* 0x00002000 */ \
WPP_DEFINE_BIT(OT_DEFAULT) /* 0x00004000 */ \
WPP_DEFINE_BIT(OT_MBEDTLS) /* 0x00008000 */ \
WPP_DEFINE_BIT(OT_DUMP) /* 0x00010000 */ \
WPP_DEFINE_BIT(OT_NDIAG) /* 0x00020000 */ \
WPP_DEFINE_BIT(API_DEFAULT) /* 0x00040000 */ \
WPP_DEFINE_BIT(OT_COAP) /* 0x00040000 */ \
WPP_DEFINE_BIT(API_DEFAULT) /* 0x00080000 */ \
)
#define WPP_LEVEL_FLAGS_LOGGER(lvl,flag) WPP_FLAG_LOGGER(flag)
@@ -197,31 +198,31 @@
// otLogDebgNcp{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_NCP}(CTX, MSG, ...);
// end_wpp
// ==COAP==
// ==MESHCOP==
// begin_wpp config
// USEPREFIX (otLogCritMeshCoP, "[%p]COAP%!SPACE!", CTX);
// otLogCritMeshCoP{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_COAP}(CTX, MSG, ...);
// USEPREFIX (otLogCritMeshCoP, "[%p]MESHCOP%!SPACE!", CTX);
// otLogCritMeshCoP{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_MESHCOP}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogWarnMeshCoP, "[%p]COAP%!SPACE!", CTX);
// otLogWarnMeshCoP{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_COAP}(CTX, MSG, ...);
// USEPREFIX (otLogWarnMeshCoP, "[%p]MESHCOP%!SPACE!", CTX);
// otLogWarnMeshCoP{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_MESHCOP}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogInfoMeshCoP, "[%p]COAP%!SPACE!", CTX);
// otLogInfoMeshCoP{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_COAP}(CTX, MSG, ...);
// USEPREFIX (otLogInfoMeshCoP, "[%p]MESHCOP%!SPACE!", CTX);
// otLogInfoMeshCoP{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_MESHCOP}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogDebgMeshCoP, "[%p]COAP%!SPACE!", CTX);
// otLogDebgMeshCoP{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_COAP}(CTX, MSG, ...);
// USEPREFIX (otLogDebgMeshCoP, "[%p]MESHCOP%!SPACE!", CTX);
// otLogDebgMeshCoP{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_MESHCOP}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogCertMeshCoP, "[%p]COAP%!SPACE!", CTX);
// otLogCertMeshCoP{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_COAP}(CTX, MSG, ...);
// USEPREFIX (otLogCertMeshCoP, "[%p]MESHCOP%!SPACE!", CTX);
// otLogCertMeshCoP{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_MESHCOP}(CTX, MSG, ...);
// end_wpp
// ==MBEDTLS==
@@ -440,6 +441,34 @@
// otLogDebgNetDiag{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_NDIAG}(CTX, MSG, ...);
// end_wpp
// ==COAP==
// begin_wpp config
// USEPREFIX (otLogCritCoap, "[%p]COAP%!SPACE!", CTX);
// otLogCritCoap{LEVEL=TRACE_LEVEL_ERROR,FLAGS=OT_COAP}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogWarnCoap, "[%p]COAP%!SPACE!", CTX);
// otLogWarnCoap{LEVEL=TRACE_LEVEL_WARNING,FLAGS=OT_COAP}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogInfoCoap, "[%p]COAP%!SPACE!", CTX);
// otLogInfoCoap{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_COAP}(CTX, MSG, ...);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogInfoCoapErr, "[%p]COAP%!SPACE!", CTX);
// otLogInfoCoapErr{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=OT_COAP}(CTX, EXP, MSG, ...);
// USESUFFIX(otLogInfoCoapErr, ", %!otError!", EXP);
// end_wpp
// begin_wpp config
// USEPREFIX (otLogDebgCoap, "[%p]COAP%!SPACE!", CTX);
// otLogDebgCoap{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=OT_COAP}(CTX, MSG, ...);
// end_wpp
// ==FUNC==
// begin_wpp config
+1
View File
@@ -91,6 +91,7 @@ typedef enum otLogRegion
kLogRegionMeshCoP = 10, ///< Mesh Commissioning Protocol
kLogRegionNetDiag = 11, ///< Network Diagnostic
kLogRegionPlatform = 12, ///< Platform
kLogRegionCoap = 13, ///< CoAP
} otLogRegion;
/**
+4 -4
View File
@@ -903,10 +903,10 @@ typedef struct otBufferInfo
uint16_t mMleBuffers; ///< The number of buffers in the MLE send queue.
uint16_t mArpMessages; ///< The number of messages in the ARP send queue.
uint16_t mArpBuffers; ///< The number of buffers in the ARP send queue.
uint16_t mCoapClientMessages; ///< The number of messages in the CoAP client send queue.
uint16_t mCoapClientBuffers; ///< The number of buffers in the CoAP client send queue.
uint16_t mCoapServerMessages; ///< The number of messages in the CoAP server responses queue.
uint16_t mCoapServerBuffers; ///< The number of buffers in the CoAP server responses queue.
uint16_t mCoapMessages; ///< The number of messages in the CoAP send queue.
uint16_t mCoapBuffers; ///< The number of buffers in the CoAP send queue.
uint16_t mCoapSecureMessages; ///< The number of messages in the CoAP secure send queue.
uint16_t mCoapSecureBuffers; ///< The number of buffers in the CoAP secure send queue.
} otBufferInfo;
/**