#ifndef CLI_COAP_SECURE_HPP_
#define CLI_COAP_SECURE_HPP_
#include "openthread-core-config.h"
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
#include "coap/coap_message.hpp"
#include "coap/coap_secure.hpp"
#ifndef CLI_COAP_SECURE_USE_COAP_DEFAULT_HANDLER
#define CLI_COAP_SECURE_USE_COAP_DEFAULT_HANDLER 0
#endif
namespace ot {
namespace Cli {
class Interpreter;
class CoapSecure
{
public:
explicit CoapSecure(Interpreter &aInterpreter);
otError Process(uint8_t aArgsLength, char *aArgs[]);
private:
enum
{
kMaxUriLength = 32,
kMaxBufferSize = 16,
kPskMaxLength = 32,
kPskIdMaxLength = 32
};
struct Command
{
const char *mName;
otError (CoapSecure::*mCommand)(uint8_t aArgsLength, char *aArgs[]);
};
void PrintPayload(otMessage *aMessage) const;
otError ProcessHelp(uint8_t aArgsLength, char *aArgs[]);
otError ProcessConnect(uint8_t aArgsLength, char *aArgs[]);
otError ProcessDisconnect(uint8_t aArgsLength, char *aArgs[]);
otError ProcessPsk(uint8_t aArgsLength, char *aArgs[]);
otError ProcessRequest(uint8_t aArgsLength, char *aArgs[]);
otError ProcessResource(uint8_t aArgsLength, char *aArgs[]);
otError ProcessStart(uint8_t aArgsLength, char *aArgs[]);
otError ProcessStop(uint8_t aArgsLength, char *aArgs[]);
otError ProcessX509(uint8_t aArgsLength, char *aArgs[]);
void Stop(void);
static void HandleRequest(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo);
void HandleRequest(otMessage *aMessage, const otMessageInfo *aMessageInfo);
static void HandleResponse(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, otError aError);
void HandleResponse(otMessage *aMessage, const otMessageInfo *aMessageInfo, otError aError);
#if CLI_COAP_SECURE_USE_COAP_DEFAULT_HANDLER
static void DefaultHandler(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo);
void DefaultHandler(otMessage *aMessage, const otMessageInfo *aMessageInfo);
#endif
static void HandleConnected(bool aConnected, void *aContext);
void HandleConnected(bool aConnected);
static const Command sCommands[];
Interpreter & mInterpreter;
otCoapResource mResource;
char mUriPath[kMaxUriLength];
bool mShutdownFlag;
bool mUseCertificate;
uint8_t mPsk[kPskMaxLength];
uint8_t mPskLength;
uint8_t mPskId[kPskIdMaxLength];
uint8_t mPskIdLength;
};
} }
#endif
#endif