shadow_client_common.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright (C) 2012-2019 UCloud. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License").
  5. * You may not use this file except in compliance with the License.
  6. * A copy of the License is located at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * or in the "license" file accompanying this file. This file is distributed
  11. * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12. * express or implied. See the License for the specific language governing
  13. * permissions and limitations under the License.
  14. */
  15. #ifndef IOT_SHADOW_CLIENT_COMMON_H_
  16. #define IOT_SHADOW_CLIENT_COMMON_H_
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #include "shadow_client.h"
  21. //设备影子相关topic
  22. #define SHADOW_PUBLISH_REQUEST_TEMPLATE "/$system/%s/%s/shadow/upstream"
  23. #define SHADOW_SUBSCRIBE_REQUEST_TEMPLATE "/$system/%s/%s/shadow/downstream"
  24. #define SHADOW_PUBLISH_SYNC_TEMPLATE "/$system/%s/%s/shadow/get"
  25. #define SHADOW_SUBSCRIBE_SYNC_TEMPLATE "/$system/%s/%s/shadow/get_reply"
  26. #define SHADOW_DOC_TEMPLATE "/$system/%s/%s/shadow/document"
  27. /**
  28. * @brief 如果没有订阅delta主题, 则进行订阅, 并注册相应设备属性
  29. *
  30. * @param pShadow shadow client
  31. * @param pProperty 设备属性
  32. * @param callback 相应设备属性处理回调函数
  33. * @return 返回SUCCESS, 表示成功
  34. */
  35. int shadow_common_register_property_on_delta(UIoT_Shadow *pShadow, DeviceProperty *pProperty, OnPropRegCallback callback);
  36. /**
  37. * @brief 更新属性值
  38. *
  39. * @param pShadow shadow client
  40. * @param pProperty 设备属性
  41. * @return 返回SUCCESS, 表示成功
  42. */
  43. int shadow_common_update_property(UIoT_Shadow *pshadow, DeviceProperty *pProperty, Method method);
  44. /**
  45. * @brief 移除注册过的设备属性
  46. *
  47. * @param pShadow shadow client
  48. * @param pProperty 设备属性
  49. * @return 返回SUCCESS, 表示成功
  50. */
  51. int shadow_common_remove_property(UIoT_Shadow *pshadow, DeviceProperty *pProperty);
  52. /**
  53. * @brief 检查注册属性是否已经存在
  54. *
  55. * @param pShadow shadow client
  56. * @param pProperty 设备属性
  57. * @return 返回 0, 表示属性不存在
  58. */
  59. int shadow_common_check_property_existence(UIoT_Shadow *pshadow, DeviceProperty *pProperty);
  60. /**
  61. * @brief 检查注册属性是否已经存在
  62. *
  63. * @param pParams RequestParams
  64. * @param pProperty 设备属性
  65. * @return 返回 0, 表示修改属性添加成功
  66. */
  67. int request_common_add_delta_property(RequestParams *pParams, DeviceProperty *pProperty);
  68. /**
  69. * @brief 检查注册属性是否已经存在
  70. *
  71. * @param property_handle PropertyHandler
  72. * @param pProperty 设备属性
  73. * @return 返回 0, 表示匹配
  74. */
  75. int shadow_common_check_property_match(void *property_handle, void *pProperty);
  76. #ifdef __cplusplus
  77. }
  78. #endif
  79. #endif //IOT_SHADOW_CLIENT_COMMON_H_