Link Kit C-SDK  5.0.0
aiot_gateway_api.h
浏览该文件的文档.
1 
10 #ifndef _GATEWAY_MODULE_H_
11 #define _GATEWAY_MODULE_H_
12 
13 #if defined(__cplusplus)
14 extern "C" {
15 #endif
16 
17 #include <stdint.h>
18 
23 #define STATE_GATEWAY_SUBDEV_REPEATED_CONNECT (-0x1301)
24 
29 #define STATE_GATEWAY_SYNC_RECV_TIMEOUT (-0x1302)
30 
35 #define STATE_GATEWAY_SYNC_RECV_ERROR (-0x1303)
36 
40 #define AIOT_PRODUCT_KEY_MAX_LENTH 64
41 
44 #define AIOT_DEVICE_NAME_MAX_LENTH 64
45 
48 #define AIOT_PRODUCT_SECRET_MAX_LENTH 64
49 
52 #define AIOT_DEVICE_SECRET_MAX_LENTH 64
53 
57 typedef struct {
61  char product_key[AIOT_PRODUCT_KEY_MAX_LENTH];
65  char device_name[AIOT_DEVICE_NAME_MAX_LENTH];
69  char product_secret[AIOT_PRODUCT_SECRET_MAX_LENTH];
73  char device_secret[AIOT_DEVICE_SECRET_MAX_LENTH];
75 
83 typedef struct {
84  /*
85  * @brief 消息的最大缓存数,0表示不使用消息数作为触发条件, 1~N表示当消息数达到后触发批量发送
86  *
87  */
88  uint32_t max_msg_buff;
89  /*
90  * @brief 消息的最大延时时间,0表示不使用消息数作为触发条件, 1~N表示当时间Nms后触发批量发送
91  *
92  */
93  uint32_t max_time_delay;
95 
99 typedef enum {
121 
125 typedef struct {
126  char *product_key;
127  char *device_name;
129 } subdev_recv_t;
130 
134 typedef struct {
138  uint32_t id;
142  int32_t code;
146  char *message;
148 
152 typedef struct {
156  int32_t status;
158 
162 typedef struct {
166  aiot_gateway_msg_type_t type;
174  int32_t subdev_num;
175  union {
184  } data;
186 
194 typedef void (*gateway_msg_callback_t)(void *gateway_device, const aiot_gateway_msg_t *msg, void *userdata);
195 
209 int32_t aiot_gateway_set_msg_callback(void *gateway_device, gateway_msg_callback_t msg_callback, void *userdata);
210 
223 int32_t aiot_gateway_set_auto_topo(void *gateway_device, int32_t auto_topo);
224 
244 int32_t aiot_gateway_set_sync_msg_timeout(void *gateway_device, uint32_t timeout_ms);
245 
262 int32_t aiot_gateway_set_batch_pub_policy(void *gateway_device, aiot_batch_pub_policy_t *policy);
263 
275 int32_t aiot_gateway_flush_msg(void *gateway_device);
276 
290 int32_t aiot_gateway_batch_connect_subdev(void *gateway_device, void* subdev_table[], int32_t subdev_num);
291 
305 int32_t aiot_gateway_batch_disconnect_subdev(void *gateway_device, void* subdev_table[], int32_t subdev_num);
306 
320 int32_t aiot_gateway_batch_add_topo(void *gateway_device, aiot_subdev_meta_info_t subdev_table[], int32_t subdev_num);
321 
335 int32_t aiot_gateway_batch_delete_topo(void *gateway_device, aiot_subdev_meta_info_t subdev_table[], int32_t subdev_num);
336 
352 int32_t aiot_gateway_dynamic_secret(void *gateway_device, aiot_subdev_meta_info_t subdev_table[], int32_t subdev_num);
353 
369 int32_t aiot_gateway_dynamic_register(void *gateway_device, aiot_subdev_meta_info_t subdev_table[], int32_t subdev_num);
370 
384 int32_t aiot_gateway_batch_connect_subdev_async(void *gateway_device, void* subdev_table[], int32_t subdev_num);
385 
399 int32_t aiot_gateway_batch_disconnect_subdev_async(void *gateway_device, void* subdev_table[], int32_t subdev_num);
400 
414 int32_t aiot_gateway_batch_add_topo_async(void *gateway_device, aiot_subdev_meta_info_t subdev_table[], int32_t subdev_num);
415 
429 int32_t aiot_gateway_batch_delete_topo_async(void *gateway_device, aiot_subdev_meta_info_t subdev_table[], int32_t subdev_num);
430 #if defined(__cplusplus)
431 }
432 #endif
433 
434 #endif
子设备的元信息
Definition: aiot_gateway_api.h:57
int32_t aiot_gateway_batch_connect_subdev(void *gateway_device, void *subdev_table[], int32_t subdev_num)
网关批量代理子设备建连(同步接口会阻塞), 超时时间设置 aiot_gateway_set_sync_msg_timeout ...
批量断连消息的回复报文
Definition: aiot_gateway_api.h:107
subdev_recv_t * subdev_table
子设备列表 参考subdev_recv_t
Definition: aiot_gateway_api.h:170
批量建连消息的回复报文
Definition: aiot_gateway_api.h:103
int32_t aiot_gateway_set_auto_topo(void *gateway_device, int32_t auto_topo)
设置是否在建连的时候自动添加topo
aiot_gateway_msg_reply_t reply
回复消息的其它字段
Definition: aiot_gateway_api.h:179
char * device_name
Definition: aiot_gateway_api.h:127
void(* gateway_msg_callback_t)(void *gateway_device, const aiot_gateway_msg_t *msg, void *userdata)
设备物模型消息回调函数原型,用户定义回调函数后,可通过 aiot_gateway_set_msg_callback 配置 ...
Definition: aiot_gateway_api.h:194
#define AIOT_DEVICE_SECRET_MAX_LENTH
设备密钥的字符串最长长度
Definition: aiot_gateway_api.h:52
网关接收到的消息的完整数据结构
Definition: aiot_gateway_api.h:162
int32_t aiot_gateway_set_msg_callback(void *gateway_device, gateway_msg_callback_t msg_callback, void *userdata)
设置网关消息的回调
char * product_key
Definition: aiot_gateway_api.h:126
批量添加topo消息的回复报文
Definition: aiot_gateway_api.h:111
int32_t aiot_gateway_set_batch_pub_policy(void *gateway_device, aiot_batch_pub_policy_t *policy)
设置网关批量发布消息规则, 打开/关闭批量发布功能
int32_t code
批量操作的状态,200表示成功
Definition: aiot_gateway_api.h:142
int32_t aiot_gateway_batch_delete_topo(void *gateway_device, aiot_subdev_meta_info_t subdev_table[], int32_t subdev_num)
网关批量删除子设备topo(同步接口会阻塞), 超时时间设置 aiot_gateway_set_sync_msg_timeout ...
int32_t aiot_gateway_set_sync_msg_timeout(void *gateway_device, uint32_t timeout_ms)
设置批量同步接口调用的超时时间
#define AIOT_PRODUCT_KEY_MAX_LENTH
产品key的字符串最长长度
Definition: aiot_gateway_api.h:40
int32_t aiot_gateway_batch_disconnect_subdev_async(void *gateway_device, void *subdev_table[], int32_t subdev_num)
网关批量代理子设备断连(异步接口不阻塞)
int32_t aiot_gateway_batch_add_topo_async(void *gateway_device, aiot_subdev_meta_info_t subdev_table[], int32_t subdev_num)
网关批量增加子设备topo(异步接口不阻塞)
#define AIOT_DEVICE_NAME_MAX_LENTH
设备名称的字符串最长长度
Definition: aiot_gateway_api.h:44
aiot_gateway_msg_type_t
网关设备接收的到消息类型
Definition: aiot_gateway_api.h:99
aiot_gateway_msg_topo_change_t topo_change
topo变更消息的其它字段
Definition: aiot_gateway_api.h:183
aiot_gateway_msg_type_t type
消息类型,具体类型参考aiot_gateway_msg_type_t
Definition: aiot_gateway_api.h:166
int32_t aiot_gateway_batch_add_topo(void *gateway_device, aiot_subdev_meta_info_t subdev_table[], int32_t subdev_num)
网关批量增加子设备topo(同步接口会阻塞), 超时时间设置 aiot_gateway_set_sync_msg_timeout ...
int32_t status
topo状态:0-创建 1-删除 2-恢复禁用 8-禁用
Definition: aiot_gateway_api.h:156
接收消息中表示设备信息的数据结构
Definition: aiot_gateway_api.h:125
int32_t aiot_gateway_batch_connect_subdev_async(void *gateway_device, void *subdev_table[], int32_t subdev_num)
网关批量代理子设备建连(异步接口不阻塞)
int32_t aiot_gateway_batch_disconnect_subdev(void *gateway_device, void *subdev_table[], int32_t subdev_num)
网关批量代理子设备断连(同步接口会阻塞),超时时间设置 aiot_gateway_set_sync_msg_timeout ...
回复消息的关键字段
Definition: aiot_gateway_api.h:134
int32_t subdev_num
子设备个数
Definition: aiot_gateway_api.h:174
int32_t aiot_gateway_flush_msg(void *gateway_device)
清空网关缓存消息,将缓存消息发送
topo变更的状态
Definition: aiot_gateway_api.h:152
#define AIOT_PRODUCT_SECRET_MAX_LENTH
产品密钥的最长字符串长度
Definition: aiot_gateway_api.h:48
int32_t aiot_gateway_dynamic_secret(void *gateway_device, aiot_subdev_meta_info_t subdev_table[], int32_t subdev_num)
网关批量代理子设备动态注册(同步接口会阻塞), 超时时间设置 aiot_gateway_set_sync_msg_timeout ...
char * device_secret
Definition: aiot_gateway_api.h:128
消息批量发布的规则结构体,定义好规则可通过 aiot_gateway_set_batch_pub_policy 配置 ...
Definition: aiot_gateway_api.h:83
int32_t aiot_gateway_dynamic_register(void *gateway_device, aiot_subdev_meta_info_t subdev_table[], int32_t subdev_num)
网关批量代理子设备抢注(同步接口会阻塞), 超时时间设置 aiot_gateway_set_sync_msg_timeout ...
uint32_t id
消息ID,可以与发送的消息ID进行匹配
Definition: aiot_gateway_api.h:138
char * message
如果操作失败,根据message可以查看失败原因
Definition: aiot_gateway_api.h:146
topo变更云端的通知消息
Definition: aiot_gateway_api.h:119
uint32_t max_msg_buff
Definition: aiot_gateway_api.h:88
int32_t aiot_gateway_batch_delete_topo_async(void *gateway_device, aiot_subdev_meta_info_t subdev_table[], int32_t subdev_num)
网关批量删除子设备topo(异步接口不阻塞)
批量删除topo消息的回复报文
Definition: aiot_gateway_api.h:115
uint32_t max_time_delay
Definition: aiot_gateway_api.h:93