Link Kit C-SDK  4.1.0
aiot_shadow_api.h
浏览该文件的文档.
1 
24 #ifndef __AIOT_SHADOW_API_H__
25 #define __AIOT_SHADOW_API_H__
26 
27 #if defined(__cplusplus)
28 extern "C" {
29 #endif
30 
31 #include <stdint.h>
32 
36 #define STATE_SHADOW_BASE (-0x1300)
37 
41 #define STATE_SHADOW_MQTT_HANDLE_IS_NULL (-0x1301)
42 
47 #define STATE_SHADOW_REPORTED_DATA_IS_NULL (-0x1302)
48 
52 #define STATE_SHADOW_INTERNAL_TOPIC_ERROR (-0x1303)
53 
57 #define STATE_SHADOW_LOG_RECV (-0x1304)
58 
62 #define SATAE_SHADOW_LOG_PARSE_RECV_MSG_FAILED (-0x1305)
63 
64 
71 typedef enum {
80 
85 
92 
98 
107 typedef enum {
113 
119 
125 
131 
137 
141 typedef struct {
145  char *reported;
146 
150  int64_t version;
152 
156 typedef struct {
160  int64_t version;
162 
166 typedef struct {
170  uint32_t resevered;
172 
176 typedef struct {
182  char *reported;
183 
187  int64_t version;
189 
193 typedef struct {
198  char *product_key;
203  char *device_name;
207  aiot_shadow_msg_type_t type;
211  union {
216  } data;
218 
219 
223 typedef enum {
229 
234 
240 
244 typedef struct {
248  char *payload;
249 
253  uint32_t payload_len;
254 
258  char *status;
259 
263  uint64_t timestamp;
265 
269 typedef struct {
273  char *payload;
274 
278  uint32_t payload_len;
279 
283  uint64_t version;
285 
289 typedef struct {
293  char *payload;
294 
298  uint32_t payload_len;
299 
303  uint64_t version;
305 
309 typedef struct {
313  char *product_key;
317  char *device_name;
321  aiot_shadow_recv_type_t type;
325  union {
329  } data;
331 
332 
342 typedef void (* aiot_shadow_recv_handler_t)(void *handle,
343  const aiot_shadow_recv_t *recv, void *userdata);
344 
353 void *aiot_shadow_init(void);
354 
369 int32_t aiot_shadow_setopt(void *handle, aiot_shadow_option_t option, void *data);
370 
386 int32_t aiot_shadow_send(void *handle, aiot_shadow_msg_t *msg);
387 
398 int32_t aiot_shadow_deinit(void **handle);
399 
400 
401 #if defined(__cplusplus)
402 }
403 #endif
404 
405 #endif /* __AIOT_SHADOW_API_H__ */
406 
uint32_t payload_len
应答数据长度
Definition: aiot_shadow_api.h:253
设备发送 AIOT_SHADOWMSG_GET 类型消息后, 云端返回的设备影子数据
Definition: aiot_shadow_api.h:289
用于获取设备影子的消息结构体,
Definition: aiot_shadow_api.h:166
设备发送 AIOT_SHADOWMSG_UPDATE, AIOT_SHADOWMSG_CLEAN_DESIRED 或 AIOT_SHADOWMSG_DELETE_REPORTED 这3这...
Definition: aiot_shadow_api.h:228
删除设备影子的部分或全部reported值, 消息结构体参考aiot_shadow_msg_delete_reported_t ...
Definition: aiot_shadow_api.h:130
void(* aiot_shadow_recv_handler_t)(void *handle, const aiot_shadow_recv_t *recv, void *userdata)
shadow模块收到从网络上来的报文时, 通知用户所调用的数据回调函数
Definition: aiot_shadow_api.h:342
用于清除设备影子中的desired数据的消息结构体
Definition: aiot_shadow_api.h:156
uint64_t version
设备影子版本
Definition: aiot_shadow_api.h:283
模块依赖的MQTT句柄
Definition: aiot_shadow_api.h:79
uint32_t resevered
保留字段
Definition: aiot_shadow_api.h:170
设备发送 AIOT_SHADOWMSG_UPDATE, AIOT_SHADOWMSG_CLEAN_DESIRED 或 AIOT_SHADOWMSG_DELETE_REPORTED 类型消...
Definition: aiot_shadow_api.h:244
aiot_shadow_recv_type_t
shadow模块收到从网络上来的报文时, 通知用户的报文类型
Definition: aiot_shadow_api.h:223
int64_t version
设备影子的目标版本, 必须大于设备影子的当前版本
Definition: aiot_shadow_api.h:187
int32_t aiot_shadow_deinit(void **handle)
结束shadow会话, 销毁实例并回收资源
Definition: aiot_shadow_api.c:413
aiot_shadow_recv_control_t control
Definition: aiot_shadow_api.h:327
aiot_shadow_msg_type_t type
消息类型, 可参考aiot_shadow_msg_type_t
Definition: aiot_shadow_api.h:207
aiot_shadow_msg_clean_desired_t clean_desired
Definition: aiot_shadow_api.h:213
uint64_t timestamp
应答报文对应的时间戳
Definition: aiot_shadow_api.h:263
用于删除设备影子中的reported数据的消息结构体
Definition: aiot_shadow_api.h:176
char * product_key
消息所属设备的product_key, 若为NULL则使用通过aiot_shadow_setopt配置的product_key 在网关子设备场景下...
Definition: aiot_shadow_api.h:198
aiot_shadow_msg_delete_reported_t delete_reporte
Definition: aiot_shadow_api.h:215
uint64_t version
设备影子版本号
Definition: aiot_shadow_api.h:303
shadow模块收到从网络上来的报文时, 通知用户的报文内容
Definition: aiot_shadow_api.h:309
aiot_shadow_recv_get_reply_t get_reply
Definition: aiot_shadow_api.h:328
清空设备影子的desired值, 消息结构体参考aiot_shadow_msg_clean_desired_t
Definition: aiot_shadow_api.h:118
char * payload
指向设备影子数据的指针
Definition: aiot_shadow_api.h:273
char * payload
指向设备影子数据的指针
Definition: aiot_shadow_api.h:293
int32_t aiot_shadow_setopt(void *handle, aiot_shadow_option_t option, void *data)
配置shadow会话
Definition: aiot_shadow_api.c:243
用户需要SDK暂存的上下文, 数据类型为(void *)
Definition: aiot_shadow_api.h:91
配置选项数量最大值, 不可用作配置参数
Definition: aiot_shadow_api.h:96
data-model模块发送消息的消息结构体
Definition: aiot_shadow_api.h:193
获取设备影子, 消息结构体参考aiot_shadow_msg_get_t
Definition: aiot_shadow_api.h:124
如果设备在线, 用户应用调用云端APIUpdateDeviceShadow后云端下推的消息
Definition: aiot_shadow_api.h:269
int32_t aiot_shadow_send(void *handle, aiot_shadow_msg_t *msg)
向服务器发送shadow消息请求
Definition: aiot_shadow_api.c:288
aiot_shadow_recv_type_t type
报文内容所对应的报文类型, 更多信息请参考aiot_shadow_recv_type_t
Definition: aiot_shadow_api.h:321
设置回调, 它在SDK收到网络报文的时候被调用, 告知用户, 数据类型为(aiot_shadow_recv_handler_t) ...
Definition: aiot_shadow_api.h:84
更新设备影子中的reported值, 消息结构体参考aiot_shadow_msg_update_t
Definition: aiot_shadow_api.h:112
uint32_t payload_len
设备影子数据长度
Definition: aiot_shadow_api.h:278
int64_t version
设备影子的目标版本, 必须大于设备影子的当前版本, 若设置为-1将清空设备影子数据, 并将设备影子版本更新为0...
Definition: aiot_shadow_api.h:150
char * device_name
消息所属设备的device_name
Definition: aiot_shadow_api.h:317
char * device_name
消息所属设备的device_name, 若为NULL则使用通过aiot_shadow_setopt配置的device_name 在网关子设备场景下...
Definition: aiot_shadow_api.h:203
aiot_shadow_recv_generic_reply_t generic_reply
Definition: aiot_shadow_api.h:326
aiot_shadow_msg_type_t
shadow模块发送消息类型
Definition: aiot_shadow_api.h:107
char * reported
设备影子reported object字符串, 必须为以结束符&#39;\0&#39;结尾的字符串, 如"{\"LightSwitch": 1}" ...
Definition: aiot_shadow_api.h:145
uint32_t payload_len
设备影子数据长度
Definition: aiot_shadow_api.h:298
char * payload
指向应答数据的指针
Definition: aiot_shadow_api.h:248
设备在线时, 云端自动下发的影子内容, 消息数据结构体参考 aiot_shadow_recv_control_t ...
Definition: aiot_shadow_api.h:233
用于更新设备影子中的reported数据的消息结构体
Definition: aiot_shadow_api.h:141
消息数量最大值, 不可用作消息类型
Definition: aiot_shadow_api.h:135
aiot_shadow_option_t
aiot_shadow_setopt 接口的option参数可选值.
Definition: aiot_shadow_api.h:71
int64_t version
设备影子的目标版本, 必须大于设备影子的当前版本
Definition: aiot_shadow_api.h:160
char * status
应答状态字符串, 云端处理成功则为success, 发送消息错误则为error, 错误信息和错误码放在在payload中 ...
Definition: aiot_shadow_api.h:258
void * aiot_shadow_init(void)
创建shadow会话实例, 并以默认值配置会话参数
Definition: aiot_shadow_api.c:223
char * product_key
消息所属设备的product_key
Definition: aiot_shadow_api.h:313
char * reported
用户将要删除的reported数据, 必须为以结束符&#39;\0&#39;结尾的字符串. 若要删除全部reported数据, 则应填写"\"null""字符串 \n 若要删除部分reported数据, 则将对应的值定义为null, 如只清除LightSwitch的值应填写"{"LightSwitch":"null"}"
Definition: aiot_shadow_api.h:182
aiot_shadow_msg_update_t update
Definition: aiot_shadow_api.h:212
主动获取设备影子内容云端返回的影子内容, 消息数据结构体参考 aiot_shadow_recv_get_reply_t ...
Definition: aiot_shadow_api.h:238