更新时间:2019-05-08 19:14
设备影子是指通过特别的Topic在云端构建一个设备的影子,设备同步状态至云端。当设备离线时,云端仍可以快速通过影子获取到设备的状态。
注:对于使用物模型在物联网平台进行定义的产品,其属性会保存在云端,无需使用设备影子来告知物联网平台保存其数据
/**
* @brief Construct the Device Shadow.
* This function initialize the data structures, establish MQTT connection.
* and subscribe the topic: "/shadow/get/${YourProduct_key}/${YourDevice_name}".
*
* @param [in] pparam: The specific initial parameter.
* @retval NULL : Construct shadow failed.
* @retval NOT_NULL : Construct success.
* @see None.
*/
void *IOT_Shadow_Construct(iotx_shadow_para_pt pparam);
/**
* @brief Create a data type registered to the server.
*
* @param [in] handle: The handle of device shaodw.
* @param [in] pattr: The parameter which registered to the server.
* @retval SUCCESS_RETURN : Success.
* @retval other : See iotx_err_t.
* @see None.
*/
iotx_err_t IOT_Shadow_RegisterAttribute(void *handle, iotx_shadow_attr_pt pattr);
/**
* @brief Synchronize device shadow data from cloud.
* It is a synchronous interface.
* @param [in] handle: The handle of device shaodw.
* @retval SUCCESS_RETURN : Success.
* @retval other : See iotx_err_t.
* @see None.
*/
iotx_err_t IOT_Shadow_Pull(void *handle);
/**
* @brief Start a process the structure of the data type format.
*
* @param [in] handle: The handle of device shaodw.
* @param [out] pformat: The format struct of device shadow.
* @param [in] buf: The buf which store device shadow.
* @param [in] size: Maximum length of device shadow attribute.
* @retval SUCCESS_RETURN : Success.
* @retval other : See iotx_err_t.
* @see None.
*/
iotx_err_t IOT_Shadow_PushFormat_Init(
void *handle,
format_data_pt pformat,
char *buf,
uint16_t size);
/**
* @brief Format the attribute name and value for update.
*
* @param [in] handle: The handle of device shaodw.
* @param [in] pformat: The format struct of device shadow.
* @param [in] pattr: To have created the data type of the format in the add member attributes.
* @retval SUCCESS_RETURN : Success.
* @retval other : See iotx_err_t.
* @see None.
*/
iotx_err_t IOT_Shadow_PushFormat_Add(
void *handle,
format_data_pt pformat,
iotx_shadow_attr_pt pattr);
/**
* @brief Complete a process the structure of the data type format.
*
* @param [in] handle: The handle of device shaodw.
* @param [in] pformat: The format struct of device shadow.
* @retval SUCCESS_RETURN : Success.
* @retval other : See iotx_err_t.
* @see None.
*/
iotx_err_t IOT_Shadow_PushFormat_Finalize(void *handle, format_data_pt pformat);
/**
* @brief Deconstruct the specific device shadow.
*
* @param [in] handle: The handle of device shaodw.
* @retval SUCCESS_RETURN : Success.
* @retval other : See iotx_err_t.
* @see None.
*/
iotx_err_t IOT_Shadow_Destroy(void *handle);
在文档使用中是否遇到以下问题
更多建议
匿名提交