23 #ifndef __AIOT_COAP_API_H__ 24 #define __AIOT_COAP_API_H__ 26 #if defined(__cplusplus) 35 #define STATE_COAP_BASE (-0x0800) 41 #define STATE_COAP_LOG_HEXDUMP (-0x0801) 47 #define STATE_COAP_HEADER_TYPE_ERROR (-0x0802) 53 #define STATE_COAP_HEADER_CODE_ERROR (-0x0802) 59 #define STATE_COAP_MSG_LEN_ERROR (-0x0803) 65 #define STATE_COAP_MSG_TOKEN_LEN_TOO_SHORT (-0x0804) 71 #define STATE_COAP_RX_OPTION_CNT_EXCEED_LIMIT (-0x0805) 77 #define STATE_COAP_OPT_DELTA_THIRTEEN_OPT_LEN_ERROR (-0x0806) 83 #define STATE_COAP_OPTION_END_NOT_FOUND (-0x0807) 89 #define STATE_COAP_TX_URI_OPTION_CNT_EXCEED_LIMIT (-0x0808) 95 #define STATE_COAP_MALLOC_MSG_FAILED (-0x0809) 101 #define STATE_COAP_MALLOC_MSG_BUFFER_FAILED (-0x080A) 107 #define STATE_COAP_REQUEST_IS_NULL (-0x080B) 113 #define STATE_COAP_OPT_DELTA_FOURTEEN_OPT_LEN_ERROR (-0x080C) 119 #define STATE_COAP_EMPTY_MSG_PARAM_ERROR (-0x080D) 125 #define STATE_COAP_EMPTY_MSG_MALLOC_FAILED (-0x080E) 131 #define STATE_COAP_OPTION_NOT_IN_ORDER (-0x080F) 137 #define STATE_COAP_HEADER_FORMAT_ERROR (-0x0810) 143 #define STATE_COAP_OPTION_BUFFER_TOO_SHORT (-0x081A) 149 #define STATE_COAP_SEND_MESSAGE_IS_NULL (-0x081B) 155 #define STATE_COAP_HEADER_BUFFER_IS_TOO_SHORT (-0x081C) 161 #define STATE_COAP_OPT_LEN_THIRTEEN_OPT_LEN_ERROR (-0x081D) 167 #define STATE_COAP_CREATE_PSK_FAILED (-0x081E) 175 #define STATE_COAP_SET_NWK_PARMS_FAILED (-0x081F) 181 #define STATE_COAP_SEND_HANDLE_IS_NULL (-0x0820) 187 #define STATE_COAP_SEND_TOPIC_IS_NULL (-0x0821) 193 #define STATE_COAP_SEND_REQUEST_IS_NULL (-0x0822) 199 #define STATE_COAP_SEND_PAYLOAD_IS_NULL (-0x0823) 205 #define STATE_COAP_SET_PSK_FAILED (-0x0824) 211 #define STATE_COAP_NWK_ESTABLISH_FAILED (-0x0825) 217 #define STATE_COAP_RECV_HANDLE_IS_NULL (-0x0826) 223 #define STATE_COAP_AUTH_HANDLE_IS_NULL (-0x0827) 229 #define STATE_COAP_AUTH_DEVICE_INFO_MISSING (-0x0828) 235 #define STATE_COAP_SIGN_SRC_MALLOC_FAILED (-0x0829) 241 #define STATE_COAP_TX_TOTAL_OPTION_CNT_EXCEED_LIMIT (-0x082A) 247 #define STATE_COAP_RECV_WITHOUT_AUTHORIZATION (-0x082B) 253 #define STATE_COAP_AUTH_TIMEOUT (-0x082C) 259 #define STATE_COAP_AUTH_RSP_TOKEN_IS_NULL (-0x082D) 265 #define STATE_COAP_AUTH_DEBUG (-0x082E) 271 #define STATE_COAP_AUTH_TOKEN_MALLOC_FAILED (-0x082F) 280 #define STATE_COAP_SEND_INVALID_MSG_TYPE (-0x0830) 286 #define STATE_COAP_NWK_HANDLE_IS_NULL (-0x0831) 292 #define AIOT_COAP_OPT_PARAMS_INVALID (-0x0832) 298 #define STATE_COAP_INVALID_OPTION (-0x0833) 304 #define STATE_COAP_UNSUPPORTED_CONTENT_FORMAT (-0x0834) 310 #define STATE_COAP_SEND_WITHOUT_AUTHORIZATION (-0x0835) 316 #define STATE_COAP_OPT_LEN_FOURTEEN_OPT_LEN_ERROR (-0x0836) 322 #define STATE_COAP_PAYLOAD_BUFFER_IS_TOO_SHORT (-0x0837) 328 #define STATE_COAP_OPTION_LEN_ERROR (-0x0838) 334 #define STATE_COAP_LOG_AUTH_TOKEN (-0x0839) 340 #define STATE_COAP_LOG_CONTENT (-0x083A) 346 #define STATE_COAP_INPUT_OUT_RANGE (-0x083B) 352 #define STATE_COAP_DYNREG_SECRET_TOO_LONG (-0x0840) 358 #define STATE_COAP_DYNREG_HANDLE_IS_NULL (-0x0841) 364 #define STATE_COAP_DYNREG_DEVICE_INFO_MISSING (-0x0842) 370 #define STATE_COAP_DYNREG_TIMEOUT (-0x0843) 376 #define STATE_COAP_AUTH_FAILED (-0x0844) 776 int32_t
aiot_coap_setopt(
void *handle, aiot_coap_option_t option,
void *data);
854 int32_t
aiot_coap_dynreg(
void *handle,
const char *product_secret,
char *out_secret, uint32_t out_secret_maxlen);
870 #if defined(__cplusplus) aiot_coap_msg_type_t msg_type
aiot_coap_msg_type_t 中所定义的消息类型
Definition: aiot_coap_api.h:716
Definition: aiot_coap_api.h:391
aiot_coap_msg_type_t
aiot_coap_send 函数的aiot_coap_request_t参数中的msg_type字段.
Definition: aiot_coap_api.h:661
uint8_t * payload
用户要上传的数据, 其格式要和字段content_format一致.
Definition: aiot_coap_api.h:702
uint32_t * msg_token
用户传入一个指针. 在coap模块发送该请求的时候, 会对该请求生成一个独一无二的token 该指针用以存这个token...
Definition: aiot_coap_api.h:728
Definition: aiot_coap_api.h:687
void(* aiot_coap_event_handler_t)(void *handle, aiot_coap_event_t *event, void *userdata)
COAP事件回调函数
Definition: aiot_coap_api.h:456
int32_t aiot_coap_dynreg(void *handle, const char *product_secret, char *out_secret, uint32_t out_secret_maxlen)
设备动态注册,返回设备密钥
Definition: aiot_coap_api.c:1291
当COAP实例所用的auth token过期(当前有效期为7天)时, 触发此事件
Definition: aiot_coap_api.h:437
Definition: aiot_coap_api.h:619
应用层数据PAYLOAD使用AES加密啊
Definition: aiot_coap_api.h:618
设备的device secret, 可从阿里云物联网平台控制台获取
Definition: aiot_coap_api.h:535
Definition: aiot_coap_api.h:641
aiot_coap_event_type_t
COAP内部事件类型
Definition: aiot_coap_api.h:427
confirmable消息类型
Definition: aiot_coap_api.h:667
COAP连云时, 获取auth_token的超时时间
Definition: aiot_coap_api.h:557
Definition: aiot_coap_api.h:388
not confirmable消息类型
Definition: aiot_coap_api.h:673
Definition: aiot_coap_api.h:638
int32_t aiot_coap_deinit(void **handle)
释放COAP实例句柄的资源
Definition: aiot_coap_api.c:1130
int32_t aiot_coap_send(void *handle, const char *topic, aiot_coap_request_t *message)
发送COAP报文
Definition: aiot_coap_api.c:996
aiot_coap_send 函数的aiot_coap_request_t参数
Definition: aiot_coap_api.h:696
Definition: aiot_coap_api.h:639
reset消息类型
Definition: aiot_coap_api.h:685
uint8_t * payload
Definition: aiot_coap_api.h:403
Definition: aiot_coap_api.h:642
uint32_t payload_len
用户要上传的数据, 其格式要和字段content_format一致.
Definition: aiot_coap_api.h:707
int32_t aiot_coap_request_message(void *handle, int32_t counter)
设备主动请求下拉消息
Definition: aiot_coap_api.c:1170
ack消息类型
Definition: aiot_coap_api.h:679
aiot_coap_recv_type_t type
COAP报文类型, 更多信息请参考aiot_coap_recv_type_t.
Definition: aiot_coap_api.h:397
int32_t aiot_coap_setopt(void *handle, aiot_coap_option_t option, void *data)
设置coap参数
Definition: aiot_coap_api.c:788
aiot_coap_event_type_t type
COAP事件类型, 更多信息请参考aiot_coap_event_type_t.
Definition: aiot_coap_api.h:445
aiot_coap_recv_type_t
COAP报文类型
Definition: aiot_coap_api.h:387
设备的product key, 可从阿里云物联网平台控制台获取
Definition: aiot_coap_api.h:517
COAP建联时, 网络使用的安全凭据
Definition: aiot_coap_api.h:549
COAP接收数据时, 在协议栈花费的最长时间
Definition: aiot_coap_api.h:566
int32_t aiot_coap_auth(void *handle)
让coap模块与服务器通信, 并且获取auth token
Definition: aiot_coap_api.c:930
void * aiot_coap_init(void)
初始化coap实例并设置默认参数
Definition: aiot_coap_api.c:749
uint32_t msg_token
Definition: aiot_coap_api.h:406
COAP客户端内部发生的事件会从此回调函数进行通知, 如获取到token等
Definition: aiot_coap_api.h:598
从COAP服务器收取的数据从此回调函数通知用户
Definition: aiot_coap_api.h:589
aiot_coap_option_t
aiot_coap_setopt 函数的option参数. 对于下文每一个选项中的数据类型, 指的是aiot_coap_setopt 中的data参...
Definition: aiot_coap_api.h:479
Definition: aiot_coap_api.h:640
Definition: aiot_coap_api.h:643
当COAP实例从云端获取到连云需要的auth_token时, 触发此事件
Definition: aiot_coap_api.h:432
Definition: aiot_coap_api.h:637
COAP发送数据时, 在协议栈花费的最长时间
Definition: aiot_coap_api.h:576
Definition: aiot_coap_api.h:636
int32_t aiot_coap_recv(void *handle)
从网络收取COAP报文
Definition: aiot_coap_api.c:1116
uint8_t rsp_code
Definition: aiot_coap_api.h:405
aiot_coap_content_format_t content_format
aiot_coap_content_format_t 中所定义的payload的格式
Definition: aiot_coap_api.h:722
COAP 服务器的端口号
Definition: aiot_coap_api.h:508
COAP 服务器的域名地址或者ip地址
Definition: aiot_coap_api.h:495
void(* aiot_coap_recv_handler_t)(void *handle, aiot_coap_recv_t *packet, void *userdata)
COAP报文接收回调函数原型
Definition: aiot_coap_api.h:420
aiot_coap_content_format_t
aiot_coap_send 函数的aiot_coap_request_t参数中的content_format字段.
Definition: aiot_coap_api.h:635
设备的device name, 可从阿里云物联网平台控制台获取
Definition: aiot_coap_api.h:526
用户需要SDK暂存的上下文
Definition: aiot_coap_api.h:609
uint16_t msg_id
Definition: aiot_coap_api.h:407
uint32_t payload_len
Definition: aiot_coap_api.h:404
Definition: aiot_coap_api.h:440