mirror of
https://github.com/espressif/openthread.git
synced 2026-08-26 12:11:17 +00:00
[coap] make CoAP start and stop reentrant (#5539)
This commit is contained in:
@@ -835,7 +835,8 @@ static inline otError otCoapSendRequest(otInstance * aInstance,
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aPort The local UDP port to bind to.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started the CoAP server.
|
||||
* @retval OT_ERROR_NONE Successfully started the CoAP server.
|
||||
* @retval OT_ERROR_FAILED Failed to start the CoAP server.
|
||||
*
|
||||
*/
|
||||
otError otCoapStart(otInstance *aInstance, uint16_t aPort);
|
||||
|
||||
@@ -64,10 +64,10 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* This method starts the TMF agent.
|
||||
* This method starts the Backbone TMF agent.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started the CoAP service.
|
||||
* @retval OT_ERROR_ALREADY Already started.
|
||||
* @retval OT_ERROR_FAILED Failed to start the Backbone TMF agent.
|
||||
*
|
||||
*/
|
||||
otError Start(void);
|
||||
|
||||
@@ -1017,10 +1017,10 @@ Coap::Coap(Instance &aInstance)
|
||||
|
||||
otError Coap::Start(uint16_t aPort, otNetifIdentifier aNetifIdentifier)
|
||||
{
|
||||
otError error;
|
||||
otError error = OT_ERROR_NONE;
|
||||
bool socketOpened = false;
|
||||
|
||||
VerifyOrExit(!mSocket.IsBound(), error = OT_ERROR_ALREADY);
|
||||
VerifyOrExit(!mSocket.IsBound(), OT_NOOP);
|
||||
|
||||
SuccessOrExit(error = mSocket.Open(&Coap::HandleUdpReceive, this));
|
||||
socketOpened = true;
|
||||
@@ -1039,7 +1039,9 @@ exit:
|
||||
|
||||
otError Coap::Stop(void)
|
||||
{
|
||||
otError error;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
VerifyOrExit(mSocket.IsBound(), OT_NOOP);
|
||||
|
||||
SuccessOrExit(error = mSocket.Close());
|
||||
ClearRequestsAndResponses();
|
||||
|
||||
@@ -610,7 +610,7 @@ public:
|
||||
* @param[in] aNetifIdentifier The network interface identifier to bind.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started the CoAP service.
|
||||
* @retval OT_ERROR_ALREADY Already started.
|
||||
* @retval OT_ERROR_FAILED Failed to start CoAP agent.
|
||||
*
|
||||
*/
|
||||
otError Start(uint16_t aPort, otNetifIdentifier aNetifIdentifier = OT_NETIF_UNSPECIFIED);
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
* This method starts the TMF agent.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started the CoAP service.
|
||||
* @retval OT_ERROR_ALREADY Already started.
|
||||
* @retval OT_ERROR_FAILED Failed to start the TMF agent.
|
||||
*
|
||||
*/
|
||||
otError Start(void);
|
||||
|
||||
Reference in New Issue
Block a user