#ifndef _COAPHandle_H_
#define _COAPHandle_H_
#include "stm32f10x.h"

#define AUTH_MID 50000 //认证messageID
#define PUSH_MID 2 //上传messageID
#define SUC_ACK_CODE 0x45 //返回成功COAP.code 2.05
#define UNAUTH_ACK_CODE 0x81 //返回未授权的请求COAP.code 4.01
#define AUTHERR_ACK_CODE 0xA0 //返回auth服务器超时或错误COAP.code 5.00
#define BADREQ_ACK_CODE 0x80 //请求发送的payload非法COAP.code 4.00

typedef struct
{
	uint8_t flag; //'Y':认证成功
	uint32_t seqOffset;
	char random[20];
	char token[40];
	uint8_t key[20];
} auth_token_t;

enum coap_status_en
{
	AUTH_FAILURE, //认证失败
	AUTH_SUCCESS, //认证成功
	AUTH_HANDLING //正在认证
};

void CoapConnect(void);

void CoapPublish(uint8_t* payload,int len);

void CoapHandle(void);

void ModelRegister(void);

int16_t GetModeldBm(void);

int16_t GetModelCSQ(void);

void GetSignalDetail(char* backdata1,int len1,char* backdata2,int len2);

void freshSignal(char* signData,int signDataLen);

#endif

