mirror of
https://github.com/espressif/openthread.git
synced 2026-08-11 05:07:47 +00:00
CoAP API cleanup.
This commit is contained in:
@@ -1083,6 +1083,7 @@ include/cli/Makefile
|
||||
include/commissioning/Makefile
|
||||
include/dhcp6/Makefile
|
||||
include/ncp/Makefile
|
||||
include/openthread/Makefile
|
||||
include/platform/Makefile
|
||||
src/Makefile
|
||||
src/cli/Makefile
|
||||
|
||||
+3
-1
@@ -35,6 +35,7 @@ DIST_SUBDIRS = \
|
||||
commissioning \
|
||||
dhcp6 \
|
||||
ncp \
|
||||
openthread \
|
||||
platform \
|
||||
$(NULL)
|
||||
|
||||
@@ -45,6 +46,7 @@ SUBDIRS = \
|
||||
commissioning \
|
||||
dhcp6 \
|
||||
ncp \
|
||||
openthread \
|
||||
platform \
|
||||
$(NULL)
|
||||
|
||||
@@ -55,13 +57,13 @@ PRETTY_SUBDIRS = \
|
||||
commissioning \
|
||||
dhcp6 \
|
||||
ncp \
|
||||
openthread \
|
||||
platform \
|
||||
$(NULL)
|
||||
|
||||
include_HEADERS = \
|
||||
openthread/link_raw.h \
|
||||
openthread.h \
|
||||
openthread-coap.h \
|
||||
openthread-crypto.h \
|
||||
openthread-diag.h \
|
||||
openthread-icmp6.h \
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#
|
||||
# Copyright (c) 2016, The OpenThread Authors.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
|
||||
|
||||
openthread_headers = \
|
||||
coap.h \
|
||||
$(NULL)
|
||||
|
||||
openthreaddir = $(includedir)/openthread
|
||||
dist_openthread_HEADERS = $(openthread_headers)
|
||||
|
||||
include_HEADERS = \
|
||||
$(NULL)
|
||||
|
||||
install-headers: install-includeHEADERS
|
||||
|
||||
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
|
||||
@@ -35,9 +35,15 @@
|
||||
#ifndef OPENTHREAD_COAP_H_
|
||||
#define OPENTHREAD_COAP_H_
|
||||
|
||||
#ifdef OPENTHREAD_CONFIG_FILE
|
||||
#include OPENTHREAD_CONFIG_FILE
|
||||
#else
|
||||
#include <openthread-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread-types.h>
|
||||
#include "openthread-types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -121,23 +127,23 @@ typedef struct otCoapHeader
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint8_t mVersionTypeToken;
|
||||
uint8_t mCode;
|
||||
uint16_t mMessageId;
|
||||
} mFields;
|
||||
uint8_t mBytes[OT_COAP_HEADER_MAX_LENGTH];
|
||||
} mHeader;
|
||||
uint8_t mHeaderLength;
|
||||
uint16_t mOptionLast;
|
||||
uint16_t mNextOptionOffset;
|
||||
otCoapOption mOption;
|
||||
uint8_t mVersionTypeToken; ///< The CoAP Version, Type, and Token Length
|
||||
uint8_t mCode; ///< The CoAP Code
|
||||
uint16_t mMessageId; ///< The CoAP Message ID
|
||||
} mFields; ///< Structure representing a CoAP base header
|
||||
uint8_t mBytes[OT_COAP_HEADER_MAX_LENGTH]; ///< The raw byte encoding for the CoAP header
|
||||
} mHeader; ///< The CoAP header encoding
|
||||
uint8_t mHeaderLength; ///< The CoAP header length (bytes)
|
||||
uint16_t mOptionLast; ///< The last CoAP Option Number value
|
||||
uint16_t mNextOptionOffset; ///< The byte offset for the next CoAP Option
|
||||
otCoapOption mOption; ///< A structure representing the current CoAP Option.
|
||||
} otCoapHeader;
|
||||
|
||||
/**
|
||||
* This function pointer is called when a CoAP response is received or on the request timeout.
|
||||
*
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
* @param[in[ aHeader A pointer to the received CoAP header. NULL if no response was received.
|
||||
* @param[in] aHeader A pointer to the received CoAP header. NULL if no response was received.
|
||||
* @param[in] aMessage A pointer to the message buffer containing the response. NULL if no response was received.
|
||||
* @param[in] aMessageInfo A pointer to the message info for @p aMessage. NULL if no response was received.
|
||||
* @param[in] aResult A result of the CoAP transaction.
|
||||
@@ -168,10 +174,10 @@ typedef void (*otCoapRequestHandler)(void *aContext, otCoapHeader *aHeader, otMe
|
||||
*/
|
||||
typedef struct otCoapResource
|
||||
{
|
||||
const char *mUriPath;
|
||||
otCoapRequestHandler mHandler;
|
||||
void *mContext;
|
||||
struct otCoapResource *mNext;
|
||||
const char *mUriPath; ///< The URI Path string
|
||||
otCoapRequestHandler mHandler; ///< The callback for handling a received request
|
||||
void *mContext; ///< Application-specific context
|
||||
struct otCoapResource *mNext; ///< The next CoAP resource in the list
|
||||
} otCoapResource;
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
@@ -85,6 +85,12 @@ SOURCES_COMMON = \
|
||||
utils/slaac_address.cpp \
|
||||
$(NULL)
|
||||
|
||||
if OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
SOURCES_COMMON += \
|
||||
api/coap_api.cpp \
|
||||
$(NULL)
|
||||
endif # OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
|
||||
if OPENTHREAD_ENABLE_MAC_WHITELIST
|
||||
SOURCES_COMMON += \
|
||||
mac/mac_blacklist.cpp \
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* Copyright (c) 2016, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file implements the OpenThread CoAP API.
|
||||
*/
|
||||
|
||||
#include "openthread/coap.h"
|
||||
|
||||
#include "openthread-instance.h"
|
||||
#include "coap/coap_header.hpp"
|
||||
|
||||
using namespace Thread;
|
||||
|
||||
extern "C" {
|
||||
|
||||
void otCoapHeaderInit(otCoapHeader *aHeader, otCoapType aType, otCoapCode aCode)
|
||||
{
|
||||
Coap::Header *header = static_cast<Coap::Header *>(aHeader);
|
||||
header->Init(aType, aCode);
|
||||
}
|
||||
|
||||
void otCoapHeaderSetToken(otCoapHeader *aHeader, const uint8_t *aToken, uint8_t aTokenLength)
|
||||
{
|
||||
static_cast<Coap::Header *>(aHeader)->SetToken(aToken, aTokenLength);
|
||||
}
|
||||
|
||||
void otCoapHeaderGenerateToken(otCoapHeader *aHeader, uint8_t aTokenLength)
|
||||
{
|
||||
static_cast<Coap::Header *>(aHeader)->SetToken(aTokenLength);
|
||||
}
|
||||
|
||||
ThreadError otCoapHeaderAppendOption(otCoapHeader *aHeader, const otCoapOption *aOption)
|
||||
{
|
||||
return static_cast<Coap::Header *>(aHeader)->AppendOption(*static_cast<const Coap::Header::Option *>(aOption));
|
||||
}
|
||||
|
||||
ThreadError otCoapHeaderAppendObserveOption(otCoapHeader *aHeader, uint32_t aObserve)
|
||||
{
|
||||
return static_cast<Coap::Header *>(aHeader)->AppendObserveOption(aObserve);
|
||||
}
|
||||
|
||||
ThreadError otCoapHeaderAppendUriPathOptions(otCoapHeader *aHeader, const char *aUriPath)
|
||||
{
|
||||
return static_cast<Coap::Header *>(aHeader)->AppendUriPathOptions(aUriPath);
|
||||
}
|
||||
|
||||
ThreadError otCoapHeaderAppendMaxAgeOption(otCoapHeader *aHeader, uint32_t aMaxAge)
|
||||
{
|
||||
return static_cast<Coap::Header *>(aHeader)->AppendMaxAgeOption(aMaxAge);
|
||||
}
|
||||
|
||||
ThreadError otCoapHeaderAppendUriQueryOption(otCoapHeader *aHeader, const char *aUriQuery)
|
||||
{
|
||||
return static_cast<Coap::Header *>(aHeader)->AppendUriQueryOption(aUriQuery);
|
||||
}
|
||||
|
||||
void otCoapHeaderSetPayloadMarker(otCoapHeader *aHeader)
|
||||
{
|
||||
static_cast<Coap::Header *>(aHeader)->SetPayloadMarker();
|
||||
}
|
||||
|
||||
void otCoapHeaderSetMessageId(otCoapHeader *aHeader, uint16_t aMessageId)
|
||||
{
|
||||
return static_cast<Coap::Header *>(aHeader)->SetMessageId(aMessageId);
|
||||
}
|
||||
|
||||
otCoapType otCoapHeaderGetType(const otCoapHeader *aHeader)
|
||||
{
|
||||
return static_cast<const Coap::Header *>(aHeader)->GetType();
|
||||
}
|
||||
|
||||
otCoapCode otCoapHeaderGetCode(const otCoapHeader *aHeader)
|
||||
{
|
||||
return static_cast<const Coap::Header *>(aHeader)->GetCode();
|
||||
}
|
||||
|
||||
uint16_t otCoapHeaderGetMessageId(const otCoapHeader *aHeader)
|
||||
{
|
||||
return static_cast<const Coap::Header *>(aHeader)->GetMessageId();
|
||||
}
|
||||
|
||||
uint8_t otCoapHeaderGetTokenLength(const otCoapHeader *aHeader)
|
||||
{
|
||||
return static_cast<const Coap::Header *>(aHeader)->GetTokenLength();
|
||||
}
|
||||
|
||||
const uint8_t *otCoapHeaderGetToken(const otCoapHeader *aHeader)
|
||||
{
|
||||
return static_cast<const Coap::Header *>(aHeader)->GetToken();
|
||||
}
|
||||
|
||||
const otCoapOption *otCoapHeaderGetCurrentOption(const otCoapHeader *aHeader)
|
||||
{
|
||||
return static_cast<const otCoapOption *>(static_cast<const Coap::Header *>(aHeader)->GetCurrentOption());
|
||||
}
|
||||
|
||||
const otCoapOption *otCoapHeaderGetNextOption(otCoapHeader *aHeader)
|
||||
{
|
||||
return static_cast<const otCoapOption *>(static_cast<Coap::Header *>(aHeader)->GetNextOption());
|
||||
}
|
||||
|
||||
otMessage otCoapNewMessage(otInstance *aInstance, const otCoapHeader *aHeader)
|
||||
{
|
||||
return aInstance->mThreadNetif.GetCoapClient().NewMessage(*(static_cast<const Coap::Header *>(aHeader)));
|
||||
}
|
||||
|
||||
ThreadError otCoapSendRequest(otInstance *aInstance, otMessage aMessage, const otMessageInfo *aMessageInfo,
|
||||
otCoapResponseHandler aHandler, void *aContext)
|
||||
{
|
||||
return aInstance->mThreadNetif.GetCoapClient().SendMessage(
|
||||
*static_cast<Message *>(aMessage),
|
||||
*static_cast<const Ip6::MessageInfo *>(aMessageInfo),
|
||||
aHandler, aContext);
|
||||
}
|
||||
|
||||
ThreadError otCoapServerStart(otInstance *aInstance)
|
||||
{
|
||||
return aInstance->mApplicationCoapServer.Start();
|
||||
}
|
||||
|
||||
ThreadError otCoapServerStop(otInstance *aInstance)
|
||||
{
|
||||
return aInstance->mApplicationCoapServer.Stop();
|
||||
}
|
||||
|
||||
ThreadError otCoapServerSetPort(otInstance *aInstance, uint16_t aPort)
|
||||
{
|
||||
return aInstance->mApplicationCoapServer.SetPort(aPort);
|
||||
}
|
||||
|
||||
ThreadError otCoapServerAddResource(otInstance *aInstance, otCoapResource *aResource)
|
||||
{
|
||||
return aInstance->mApplicationCoapServer.AddResource(*static_cast<Coap::Resource *>(aResource));
|
||||
}
|
||||
|
||||
void otCoapServerRemoveResource(otInstance *aInstance, otCoapResource *aResource)
|
||||
{
|
||||
aInstance->mApplicationCoapServer.RemoveResource(*static_cast<Coap::Resource *>(aResource));
|
||||
}
|
||||
|
||||
ThreadError otCoapSendResponse(otInstance *aInstance, otMessage aMessage, const otMessageInfo *aMessageInfo)
|
||||
{
|
||||
return aInstance->mApplicationCoapServer.SendMessage(
|
||||
*static_cast<Message *>(aMessage), *static_cast<const Ip6::MessageInfo *>(aMessageInfo));
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
@@ -30,7 +30,8 @@
|
||||
#define COAP_CLIENT_HPP_
|
||||
|
||||
#include <openthread-types.h>
|
||||
#include <openthread-coap.h>
|
||||
#include "openthread/coap.h"
|
||||
|
||||
#include <coap/coap_base.hpp>
|
||||
#include <coap/coap_header.hpp>
|
||||
#include <common/message.hpp>
|
||||
|
||||
@@ -37,7 +37,8 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <openthread-types.h>
|
||||
#include <openthread-coap.h>
|
||||
#include "openthread/coap.h"
|
||||
|
||||
#include <common/encoding.hpp>
|
||||
#include <common/message.hpp>
|
||||
|
||||
|
||||
@@ -34,7 +34,8 @@
|
||||
#ifndef COAP_SERVER_HPP_
|
||||
#define COAP_SERVER_HPP_
|
||||
|
||||
#include <openthread-coap.h>
|
||||
#include "openthread/coap.h"
|
||||
|
||||
#include <coap/coap_base.hpp>
|
||||
#include <coap/coap_header.hpp>
|
||||
#include <common/message.hpp>
|
||||
|
||||
+1
-136
@@ -40,6 +40,7 @@
|
||||
#endif
|
||||
|
||||
#include <openthread.h>
|
||||
|
||||
#if OPENTHREAD_ENABLE_JAM_DETECTION
|
||||
#include <openthread-jam-detection.h>
|
||||
#endif
|
||||
@@ -63,9 +64,6 @@
|
||||
#include <thread/thread_uris.hpp>
|
||||
#include <utils/slaac_address.hpp>
|
||||
#include <openthread-instance.h>
|
||||
#include <openthread-coap.h>
|
||||
#include <coap/coap_header.hpp>
|
||||
#include <coap/coap_client.hpp>
|
||||
#include <coap/coap_server.hpp>
|
||||
|
||||
using namespace Thread;
|
||||
@@ -1965,139 +1963,6 @@ ThreadError otJoinerStop(otInstance *aInstance)
|
||||
}
|
||||
#endif // OPENTHREAD_ENABLE_JOINER
|
||||
|
||||
#if OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
void otCoapHeaderInit(otCoapHeader *aHeader, otCoapType aType, otCoapCode aCode)
|
||||
{
|
||||
Coap::Header *header = static_cast<Coap::Header *>(aHeader);
|
||||
header->Init(aType, aCode);
|
||||
}
|
||||
|
||||
void otCoapHeaderSetToken(otCoapHeader *aHeader, const uint8_t *aToken, uint8_t aTokenLength)
|
||||
{
|
||||
static_cast<Coap::Header *>(aHeader)->SetToken(aToken, aTokenLength);
|
||||
}
|
||||
|
||||
void otCoapHeaderGenerateToken(otCoapHeader *aHeader, uint8_t aTokenLength)
|
||||
{
|
||||
static_cast<Coap::Header *>(aHeader)->SetToken(aTokenLength);
|
||||
}
|
||||
|
||||
ThreadError otCoapHeaderAppendOption(otCoapHeader *aHeader, const otCoapOption *aOption)
|
||||
{
|
||||
return static_cast<Coap::Header *>(aHeader)->AppendOption(*static_cast<const Coap::Header::Option *>(aOption));
|
||||
}
|
||||
|
||||
ThreadError otCoapHeaderAppendObserveOption(otCoapHeader *aHeader, uint32_t aObserve)
|
||||
{
|
||||
return static_cast<Coap::Header *>(aHeader)->AppendObserveOption(aObserve);
|
||||
}
|
||||
|
||||
ThreadError otCoapHeaderAppendUriPathOptions(otCoapHeader *aHeader, const char *aUriPath)
|
||||
{
|
||||
return static_cast<Coap::Header *>(aHeader)->AppendUriPathOptions(aUriPath);
|
||||
}
|
||||
|
||||
ThreadError otCoapHeaderAppendMaxAgeOption(otCoapHeader *aHeader, uint32_t aMaxAge)
|
||||
{
|
||||
return static_cast<Coap::Header *>(aHeader)->AppendMaxAgeOption(aMaxAge);
|
||||
}
|
||||
|
||||
ThreadError otCoapHeaderAppendUriQueryOption(otCoapHeader *aHeader, const char *aUriQuery)
|
||||
{
|
||||
return static_cast<Coap::Header *>(aHeader)->AppendUriQueryOption(aUriQuery);
|
||||
}
|
||||
|
||||
void otCoapHeaderSetPayloadMarker(otCoapHeader *aHeader)
|
||||
{
|
||||
static_cast<Coap::Header *>(aHeader)->SetPayloadMarker();
|
||||
}
|
||||
|
||||
void otCoapHeaderSetMessageId(otCoapHeader *aHeader, uint16_t aMessageId)
|
||||
{
|
||||
return static_cast<Coap::Header *>(aHeader)->SetMessageId(aMessageId);
|
||||
}
|
||||
|
||||
otCoapType otCoapHeaderGetType(const otCoapHeader *aHeader)
|
||||
{
|
||||
return static_cast<const Coap::Header *>(aHeader)->GetType();
|
||||
}
|
||||
|
||||
otCoapCode otCoapHeaderGetCode(const otCoapHeader *aHeader)
|
||||
{
|
||||
return static_cast<const Coap::Header *>(aHeader)->GetCode();
|
||||
}
|
||||
|
||||
uint16_t otCoapHeaderGetMessageId(const otCoapHeader *aHeader)
|
||||
{
|
||||
return static_cast<const Coap::Header *>(aHeader)->GetMessageId();
|
||||
}
|
||||
|
||||
uint8_t otCoapHeaderGetTokenLength(const otCoapHeader *aHeader)
|
||||
{
|
||||
return static_cast<const Coap::Header *>(aHeader)->GetTokenLength();
|
||||
}
|
||||
|
||||
const uint8_t *otCoapHeaderGetToken(const otCoapHeader *aHeader)
|
||||
{
|
||||
return static_cast<const Coap::Header *>(aHeader)->GetToken();
|
||||
}
|
||||
|
||||
const otCoapOption *otCoapHeaderGetCurrentOption(const otCoapHeader *aHeader)
|
||||
{
|
||||
return static_cast<const otCoapOption *>(static_cast<const Coap::Header *>(aHeader)->GetCurrentOption());
|
||||
}
|
||||
|
||||
const otCoapOption *otCoapHeaderGetNextOption(otCoapHeader *aHeader)
|
||||
{
|
||||
return static_cast<const otCoapOption *>(static_cast<Coap::Header *>(aHeader)->GetNextOption());
|
||||
}
|
||||
|
||||
otMessage otCoapNewMessage(otInstance *aInstance, const otCoapHeader *aHeader)
|
||||
{
|
||||
return aInstance->mThreadNetif.GetCoapClient().NewMessage(*(static_cast<const Coap::Header *>(aHeader)));
|
||||
}
|
||||
|
||||
ThreadError otCoapSendRequest(otInstance *aInstance, otMessage aMessage, const otMessageInfo *aMessageInfo,
|
||||
otCoapResponseHandler aHandler, void *aContext)
|
||||
{
|
||||
return aInstance->mThreadNetif.GetCoapClient().SendMessage(
|
||||
*static_cast<Message *>(aMessage),
|
||||
*static_cast<const Ip6::MessageInfo *>(aMessageInfo),
|
||||
aHandler, aContext);
|
||||
}
|
||||
|
||||
ThreadError otCoapServerStart(otInstance *aInstance)
|
||||
{
|
||||
return aInstance->mApplicationCoapServer.Start();
|
||||
}
|
||||
|
||||
ThreadError otCoapServerStop(otInstance *aInstance)
|
||||
{
|
||||
return aInstance->mApplicationCoapServer.Stop();
|
||||
}
|
||||
|
||||
ThreadError otCoapServerSetPort(otInstance *aInstance, uint16_t aPort)
|
||||
{
|
||||
return aInstance->mApplicationCoapServer.SetPort(aPort);
|
||||
}
|
||||
|
||||
ThreadError otCoapServerAddResource(otInstance *aInstance, otCoapResource *aResource)
|
||||
{
|
||||
return aInstance->mApplicationCoapServer.AddResource(*static_cast<Coap::Resource *>(aResource));
|
||||
}
|
||||
|
||||
void otCoapServerRemoveResource(otInstance *aInstance, otCoapResource *aResource)
|
||||
{
|
||||
aInstance->mApplicationCoapServer.RemoveResource(*static_cast<Coap::Resource *>(aResource));
|
||||
}
|
||||
|
||||
ThreadError otCoapSendResponse(otInstance *aInstance, otMessage aMessage, const otMessageInfo *aMessageInfo)
|
||||
{
|
||||
return aInstance->mApplicationCoapServer.SendMessage(
|
||||
*static_cast<Message *>(aMessage), *static_cast<const Ip6::MessageInfo *>(aMessageInfo));
|
||||
}
|
||||
#endif // OPENTHREAD_ENABLE_APPLICATION_COAP
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user