三木社区

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 410|回复: 0
打印 上一主题 下一主题

user_post_event

[复制链接]

1657

主题

1684

帖子

5684

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
5684
跳转到指定楼层
楼主
发表于 2019-6-17 16:10:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
用户提交事件:
  1. void user_post_event(void)
  2. {
  3.     static int example_index = 0;
  4.     int res = 0;
  5.     user_example_ctx_t *user_example_ctx = user_example_get_ctx();
  6.     char *event_id = "Error";
  7.     char *event_payload = "NULL";

  8.     if (example_index == 0) {
  9.         /* Normal Example */
  10.         event_payload = "{"ErrorCode":0}";
  11.         example_index++;
  12.     } else if (example_index == 1) {
  13.         /* Wrong Property ID */
  14.         event_payload = "{"ErrorCodexxx":0}";
  15.         example_index++;
  16.     } else if (example_index == 2) {
  17.         /* Wrong Value Format */
  18.         event_payload = "{"ErrorCode":"test"}";
  19.         example_index++;
  20.     } else if (example_index == 3) {
  21.         /* Wrong Value Range */
  22.         event_payload = "{"ErrorCode":10}";
  23.         example_index++;
  24.     } else if (example_index == 4) {
  25.         /* Wrong Value Range */
  26.         event_payload = ""hello world"";
  27.         example_index++;
  28.     } else if (example_index == 5) {
  29.         /* Wrong Json Format */
  30.         event_payload = "hello world";
  31.         example_index = 0;
  32.     }

  33.     res = IOT_Linkkit_TriggerEvent(user_example_ctx->master_devid, event_id, strlen(event_id),
  34.                                    event_payload, strlen(event_payload));
  35.     EXAMPLE_TRACE("Post Event Message ID: %d", res);
  36. }
复制代码



回复

使用道具 举报

Archiver|手机版|小黑屋|三木电子社区 ( 辽ICP备11000133号-4 )

辽公网安备 21021702000620号

GMT+8, 2026-3-19 00:35 , Processed in 0.046452 second(s), 23 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表