|
|
用户属性设置事件处理程序:
- static int user_property_set_event_handler(const int devid, const char *request, const int request_len)
- {
- int res = 0;
- cJSON *root = NULL, *item_PowerSwitch = NULL;
- user_example_ctx_t *user_example_ctx = user_example_get_ctx();
- EXAMPLE_TRACE("Property Set Received, Devid: %d, Request: %s", devid, request);
- root = cJSON_Parse(request);
- item_PowerSwitch = cJSON_GetObjectItem(root, "LightSwitch");
- if (item_PowerSwitch != NULL)
- {
- EXAMPLE_TRACE("item_PowerSwitch: %d", item_PowerSwitch);
- EXAMPLE_TRACE("valueint: %d", item_PowerSwitch->valueint);
- if(item_PowerSwitch->valueint)
- {
- EXAMPLE_TRACE("\r\n Turn on power \r\n");
- app_trigger_high_action();
- }
- else
- {
- EXAMPLE_TRACE("\r\n Turn off power \r\n");
- app_trigger_low_action();
- }
- }
- res = IOT_Linkkit_Report(user_example_ctx->master_devid, ITM_MSG_POST_PROPERTY,
- (unsigned char *)request, request_len);
- EXAMPLE_TRACE("Post Property Message ID: %d", res);
- return 0;
- }
复制代码 属性设置请求在user_property_set_event_handler()中,默认代码是把下发到属性设置请求原样上报
|
|