Link Kit C-SDK  5.0.0
aiot_linkconfig_api.h
浏览该文件的文档.
1 
11 #ifndef _AIOT_LINK_CONFIG_H_
12 #define _AIOT_LINK_CONFIG_H_
13 
14 #if defined(__cplusplus)
15 extern "C" {
16 #endif
17 
18 #include <stdint.h>
19 #include "aiot_message_api.h"
20 #include "aiot_sysdep_api.h"
21 
22 typedef enum {
26 
30 typedef struct {
34  void *(*init)(void *proto_config);
38  int32_t (*connect)(void *handle);
42  int32_t (*send_message)(void *handle, const aiot_msg_t *message);
46  int32_t (*sub_topic)(void *handle, char *topic, uint8_t qos);
50  int32_t (*unsub_topic)(void *handle, char *topic, uint8_t qos);
54  int32_t (*disconnect)(void *handle);
58  void (*deinit)(void **handle);
60 
64 typedef struct {
65  /* 协议处理的方法实现 */
67  /* 对应协议的配置 */
68  void *proto_config;
69  /* 多连接配置, 起始connect_id */
70  int32_t start_cid;
71  /* 多连接配置,通道的个数 */
72  int32_t channel_num;
74 
84 
94 
105 int32_t aiot_linkconfig_host(aiot_linkconfig_t *config, char *host, uint16_t port);
106 
120 
133 int32_t aiot_linkconfig_root_cert(aiot_linkconfig_t *config, const char *cert, uint32_t len);
134 
147 int32_t aiot_linkconfig_client_cert_privkey(aiot_linkconfig_t *config, char *client_cert, uint32_t cert_len, char *client_privkey, uint32_t key_len);
148 
158 int32_t aiot_linkconfig_connect_timeout(aiot_linkconfig_t *config, uint32_t timeout_ms);
159 
169 int32_t aiot_linkconfig_recv_timeout(aiot_linkconfig_t *config, uint32_t timeout_ms);
170 
180 int32_t aiot_linkconfig_send_timeout(aiot_linkconfig_t *config, uint32_t timeout_ms);
181 
192 int32_t aiot_linkconfig_reconnect_enable(aiot_linkconfig_t *config, uint8_t enable);
193 
204 int32_t aiot_linkconfig_multi_channel(aiot_linkconfig_t *config, uint32_t start_cid, uint32_t num);
205 
215 int32_t aiot_linkconfig_mqtt_extclientid(aiot_linkconfig_t *config, char *extern_clientid);
216 
226 int32_t aiot_linkconfig_mqtt_keepalive(aiot_linkconfig_t *config, uint16_t keep_alive_s);
227 
239 int32_t aiot_linkconfig_mqtt_cleansession(aiot_linkconfig_t *config, uint8_t clean_session);
240 
251 int32_t aiot_linkconfig_mqtt_heartbeat_interval(aiot_linkconfig_t *config, uint32_t interval_ms);
252 
264 int32_t aiot_linkconfig_dynamic_register(aiot_linkconfig_t *config, char *product_secret, char *instance_id);
265 
281 int32_t aiot_linkconfig_mqtt_auth(aiot_linkconfig_t *config, char *username, char *password, char *clientid);
282 
283 #if defined(__cplusplus)
284 }
285 #endif
286 
287 #endif
设备消息模块,包含:构建自定义消息、构建rrpc消息、消息拷贝、消息删除等功能
aiot_linkconfig_t * aiot_linkconfig_init(aiot_protocol_t *protocol)
初始化默认的连接配置参数,生成配置参数句柄
int32_t aiot_linkconfig_dynamic_register(aiot_linkconfig_t *config, char *product_secret, char *instance_id)
动态注册参数配置,设置产品密钥及实例id
int32_t aiot_linkconfig_mqtt_heartbeat_interval(aiot_linkconfig_t *config, uint32_t interval_ms)
配置设备主动发送PINGREQ报文发送时间间隔. (心跳发送间隔)
int32_t aiot_linkconfig_recv_timeout(aiot_linkconfig_t *config, uint32_t timeout_ms)
设置接收超时的时间
int32_t aiot_linkconfig_mqtt_extclientid(aiot_linkconfig_t *config, char *extern_clientid)
设备连接阿里云物联网平台时的扩展clientid
sdk系统依赖头文件, 所有系统依赖均在此文件中列出
aiot_protocol_t * protocol
Definition: aiot_linkconfig_api.h:66
描述消息传输协议实现方法的结构体
Definition: aiot_linkconfig_api.h:30
int32_t aiot_linkconfig_root_cert(aiot_linkconfig_t *config, const char *cert, uint32_t len)
设置服务器的根证书
aiot_sysdep_network_cred_option_t
Definition: aiot_sysdep_api.h:19
int32_t aiot_linkconfig_cred_option(aiot_linkconfig_t *config, aiot_sysdep_network_cred_option_t option)
设备网络连接的类型
int32_t aiot_linkconfig_mqtt_cleansession(aiot_linkconfig_t *config, uint8_t clean_session)
MQTT建联时, CONNECT报文中的clean session参数
int32_t aiot_linkconfig_send_timeout(aiot_linkconfig_t *config, uint32_t timeout_ms)
设置发送超时的时间
void * proto_config
Definition: aiot_linkconfig_api.h:68
描述设备建连所需参数的结构体
Definition: aiot_linkconfig_api.h:64
int32_t start_cid
Definition: aiot_linkconfig_api.h:70
int32_t channel_num
Definition: aiot_linkconfig_api.h:72
int32_t aiot_linkconfig_multi_channel(aiot_linkconfig_t *config, uint32_t start_cid, uint32_t num)
设置多连接:允许建连多个与云平台的连接
int32_t aiot_linkconfig_mqtt_auth(aiot_linkconfig_t *config, char *username, char *password, char *clientid)
透传给mqtt的建连认证信息, 免白动态注册后需要使用
int32_t aiot_linkconfig_connect_timeout(aiot_linkconfig_t *config, uint32_t timeout_ms)
设置建连超时的时间
int32_t aiot_linkconfig_reconnect_enable(aiot_linkconfig_t *config, uint8_t enable)
设置是否自动重连, 默认为开启自动重连
aiot_protocol_type_t
Definition: aiot_linkconfig_api.h:22
int32_t aiot_linkconfig_deinit(aiot_linkconfig_t **config)
删除连接配置句柄,回收资源
int32_t aiot_linkconfig_host(aiot_linkconfig_t *config, char *host, uint16_t port)
设置连接的host, port
int32_t aiot_linkconfig_mqtt_keepalive(aiot_linkconfig_t *config, uint16_t keep_alive_s)
MQTT建联时, CONNECT报文中的最长心跳间隔
int32_t aiot_linkconfig_client_cert_privkey(aiot_linkconfig_t *config, char *client_cert, uint32_t cert_len, char *client_privkey, uint32_t key_len)
X509认证,设置客户端证书和私钥
Definition: aiot_linkconfig_api.h:24
描述消息的数据结构
Definition: aiot_message_api.h:24
Definition: aiot_linkconfig_api.h:23