三木社区

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

user_property_set_event_handler

[复制链接]

1657

主题

1684

帖子

5684

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
5684
跳转到指定楼层
楼主
发表于 2019-6-17 15:47:08 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
用户属性设置事件处理程序:
  1. static int user_property_set_event_handler(const int devid, const char *request, const int request_len)
  2. {
  3.     int res = 0;
  4.     cJSON *root = NULL, *item_PowerSwitch = NULL;
  5.     user_example_ctx_t *user_example_ctx = user_example_get_ctx();
  6.     EXAMPLE_TRACE("Property Set Received, Devid: %d, Request: %s", devid, request);

  7.     root = cJSON_Parse(request);
  8.     item_PowerSwitch = cJSON_GetObjectItem(root, "LightSwitch");
  9.     if (item_PowerSwitch != NULL)
  10.     {
  11.         EXAMPLE_TRACE("item_PowerSwitch: %d", item_PowerSwitch);
  12.         EXAMPLE_TRACE("valueint: %d", item_PowerSwitch->valueint);
  13.         if(item_PowerSwitch->valueint)
  14.         {
  15.             EXAMPLE_TRACE("\r\n Turn on power \r\n");
  16.             app_trigger_high_action();
  17.         }
  18.         else
  19.         {
  20.             EXAMPLE_TRACE("\r\n Turn off power \r\n");
  21.             app_trigger_low_action();
  22.         }
  23.     }

  24.     res = IOT_Linkkit_Report(user_example_ctx->master_devid, ITM_MSG_POST_PROPERTY,
  25.                              (unsigned char *)request, request_len);
  26.     EXAMPLE_TRACE("Post Property Message ID: %d", res);

  27.     return 0;
  28. }
复制代码
属性设置请求在user_property_set_event_handler()中,默认代码是把下发到属性设置请求原样上报


回复

使用道具 举报

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

辽公网安备 21021702000620号

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

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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