Link Kit C-SDK  4.1.0
aiot_subdev_api.h
浏览该文件的文档.
1 
8 #ifndef __AIOT_SUBDEV_API_H__
9 #define __AIOT_SUBDEV_API_H__
10 
11 #if defined(__cplusplus)
12 extern "C" {
13 #endif
14 
15 #include <stdint.h>
16 
20 #define STATE_SUBDEV_BASE (-0x0C00)
21 
25 typedef enum {
35 
36 typedef struct {
37  uint32_t msg_id;
38  uint32_t code;
39  char* data;
40  char* message;
41  char* product_key;
42  char* device_name;
44 
45 typedef struct {
46  uint32_t msg_id;
47  char* params;
48  char* product_key;
49  char* device_name;
51 
55 typedef struct {
59  aiot_subdev_recv_type_t type;
60  union {
65 
70  } data;
72 
82 typedef void (* aiot_subdev_recv_handler_t)(void *handle,
83  const aiot_subdev_recv_t *packet, void *user_data);
84 
85 
86 /* TODO: 列举 SUBDEV 可能发生的所有内部状态变更(可选), 如MQTT重连, OTA收到通知, CoAP的token过期, 与上一段之间有2个空行 */
87 /* TODO: 填上 doxygen 的注释说明 */
88 /* TODO: 由于面向用户, 模块名字符串长度 > 6个字符的时候, 改成缩写, 例如: DYNREG_HTTP_EVT -> DRHTTPEVT */
89 
93 typedef enum {
107 
111 typedef struct {
115  aiot_subdev_event_type_t type;
117 
127 typedef void (*aiot_subdev_event_handler_t)(void *handle,
128  const aiot_subdev_event_t *event, void *userdata);
129 
134 typedef struct {
135  char *product_key;
136  char *device_name;
140 
151 typedef enum {
160 
169 
178 
189 
198 void *aiot_subdev_init(void);
199 
212 int32_t aiot_subdev_setopt(void *handle, aiot_subdev_option_t option, void *data);
213 
224 int32_t aiot_subdev_deinit(void **handle);
225 
241 int32_t aiot_subdev_send_topo_add(void *handle, aiot_subdev_dev_t dev[], uint32_t dev_num);
242 
258 int32_t aiot_subdev_send_topo_delete(void *handle, aiot_subdev_dev_t dev[], uint32_t dev_num);
259 
273 int32_t aiot_subdev_send_topo_get(void *handle);
274 
290 int32_t aiot_subdev_send_batch_login(void *handle, aiot_subdev_dev_t dev[], uint32_t dev_num);
291 
307 int32_t aiot_subdev_send_batch_logout(void *handle, aiot_subdev_dev_t dev[], uint32_t dev_num);
308 
324 int32_t aiot_subdev_send_sub_register(void *handle, aiot_subdev_dev_t dev[], uint32_t dev_num);
325 
341 int32_t aiot_subdev_send_product_register(void *handle, aiot_subdev_dev_t dev[], uint32_t dev_num);
342 
343 #if defined(__cplusplus)
344 }
345 #endif
346 
347 #endif /* __AIOT_SUBDEV_API_H__ */
348 
char * params
Definition: aiot_subdev_api.h:47
aiot_subdev_generic_notify_t generic_notify
收到的云端的通知
Definition: aiot_subdev_api.h:69
Definition: aiot_subdev_api.h:45
Definition: aiot_subdev_api.h:134
char * device_name
Definition: aiot_subdev_api.h:136
设置回调, 它在SDK收到网络报文的时候被调用, 告知用户, 数据类型为(aiot_subdev_recv_handler_t) ...
Definition: aiot_subdev_api.h:168
void(* aiot_subdev_event_handler_t)(void *handle, const aiot_subdev_event_t *event, void *userdata)
subdev模块内部发生值得用户关注的状态变化时, 通知用户所调用的事件回调函数
Definition: aiot_subdev_api.h:127
Definition: aiot_subdev_api.h:32
Definition: aiot_subdev_api.h:29
uint32_t msg_id
Definition: aiot_subdev_api.h:46
aiot_subdev_recv_type_t
subdev模块收到从网络上来的报文时, 通知用户的报文类型
Definition: aiot_subdev_api.h:25
char * device_secret
Definition: aiot_subdev_api.h:137
设置回调, 它在SDK发生内部状态变更时被调用, 告知用户, 数据类型为(aiot_subdev_event_handler_t) ...
Definition: aiot_subdev_api.h:177
Definition: aiot_subdev_api.h:36
非法的应答报文
Definition: aiot_subdev_api.h:97
char * product_key
Definition: aiot_subdev_api.h:41
void(* aiot_subdev_recv_handler_t)(void *handle, const aiot_subdev_recv_t *packet, void *user_data)
subdev模块收到从网络上来的报文时, 通知用户所调用的数据回调函数
Definition: aiot_subdev_api.h:82
void * aiot_subdev_init(void)
创建subdev会话实例, 并以默认值配置会话参数
Definition: aiot_subdev_api.c:474
uint32_t code
Definition: aiot_subdev_api.h:38
char * product_key
Definition: aiot_subdev_api.h:48
char * device_name
Definition: aiot_subdev_api.h:42
Definition: aiot_subdev_api.h:26
subdev会话 需要的MQTT句柄, 需要先建立MQTT连接,再设置MQTT句柄
Definition: aiot_subdev_api.h:159
int32_t aiot_subdev_send_topo_add(void *handle, aiot_subdev_dev_t dev[], uint32_t dev_num)
向物联网平台发送添加子设备与网关topo关系的请求
Definition: aiot_subdev_api.c:564
Definition: aiot_subdev_api.h:31
Definition: aiot_subdev_api.h:27
subdev模块收到从网络上来的报文时, 通知用户的报文内容
Definition: aiot_subdev_api.h:55
char * product_key
Definition: aiot_subdev_api.h:135
Definition: aiot_subdev_api.h:33
subdev模块内部发生值得用户关注的状态变化时, 通知用户的事件内容
Definition: aiot_subdev_api.h:111
用户需要SDK暂存的上下文, 数据类型为(void *)
Definition: aiot_subdev_api.h:186
char * product_secret
Definition: aiot_subdev_api.h:138
aiot_subdev_event_type_t
subdev模块内部发生值得用户关注的状态变化时, 通知用户的事件类型
Definition: aiot_subdev_api.h:93
int32_t aiot_subdev_send_topo_get(void *handle)
向物联网平台发送查询子设备与网关topo关系的请求
Definition: aiot_subdev_api.c:697
int32_t aiot_subdev_send_topo_delete(void *handle, aiot_subdev_dev_t dev[], uint32_t dev_num)
向物联网平台发送删除子设备与网关topo关系的请求
Definition: aiot_subdev_api.c:634
aiot_subdev_option_t
aiot_subdev_setopt 接口的option参数可选值.
Definition: aiot_subdev_api.h:151
aiot_subdev_generic_reply_t generic_reply
从设备发起请求消息后,收到的云端的应答
Definition: aiot_subdev_api.h:64
char * device_name
Definition: aiot_subdev_api.h:49
应答报文的id字段非法
Definition: aiot_subdev_api.h:101
char * data
Definition: aiot_subdev_api.h:39
Definition: aiot_subdev_api.h:30
int32_t aiot_subdev_deinit(void **handle)
结束subdev会话, 销毁实例并回收资源
Definition: aiot_subdev_api.c:543
Definition: aiot_subdev_api.h:28
Definition: aiot_subdev_api.h:187
aiot_subdev_event_type_t type
事件内容所对应的事件类型, 更多信息请参考aiot_subdev_event_type_t
Definition: aiot_subdev_api.h:115
int32_t aiot_subdev_send_batch_login(void *handle, aiot_subdev_dev_t dev[], uint32_t dev_num)
向物联网平台发送子设备上线请求
Definition: aiot_subdev_api.c:735
应答报文的code字段非法
Definition: aiot_subdev_api.h:105
uint32_t msg_id
Definition: aiot_subdev_api.h:37
int32_t aiot_subdev_setopt(void *handle, aiot_subdev_option_t option, void *data)
配置subdev会话
Definition: aiot_subdev_api.c:501
int32_t aiot_subdev_send_product_register(void *handle, aiot_subdev_dev_t dev[], uint32_t dev_num)
向物联网平台发送子设备动态注册请求(可从其他网关抢绑子设备)
Definition: aiot_subdev_api.c:941
int32_t aiot_subdev_send_sub_register(void *handle, aiot_subdev_dev_t dev[], uint32_t dev_num)
向物联网平台发送子设备动态注册请求
Definition: aiot_subdev_api.c:878
aiot_subdev_recv_type_t type
报文内容所对应的报文类型, 更多信息请参考aiot_subdev_recv_type_t
Definition: aiot_subdev_api.h:59
int32_t aiot_subdev_send_batch_logout(void *handle, aiot_subdev_dev_t dev[], uint32_t dev_num)
向物联网平台发送子设备下线请求
Definition: aiot_subdev_api.c:815
char * message
Definition: aiot_subdev_api.h:40