远程配置
主动获取远程配置
// 定义两个字符串指针,保存需要上传的 json 字符串地址。
char* application_string = NULL;
char* system_string = NULL;
// 设置需要上传的信息,并把地址保存到对应的指针中。
xiot_add_int_to_payload(&application_string, "version", xxx);
xiot_add_int_to_payload(&system_string, "version", xxx);
// 上报主动获取配置的事件到云端。
xiot_upload_obtain_remote_config(application_string, system_string);
订阅获取远程配置
设备在每次开机后或者收到远程配置后,上报自己的配置状态。云端一有新的配置后便会及时下发。
// 定义两个字符串指针,保存需要上传的 json 字符串地址。
char* application_string = NULL;
char* system_string = NULL;
// 设置需要上传的信息,并把地址保存到对应的指针中。
// 设置应用配置。
xiot_add_int_to_payload(&application_string, "status", xxx);
xiot_add_int_to_payload(&application_string, "version", xxx);
xiot_add_string_to_payload(&application_string, "msg", "xxx");
// 设置系统配置。
xiot_add_int_to_payload(&system_string, "status", xxx);
xiot_add_int_to_payload(&system_string, "version", xxx);
xiot_add_string_to_payload(&system_string, "msg", "xxx");
// 上报本地配置状态的事件到云端,云端有新的配置便会及时下发。
xiot_upload_remote_config_status(application_string, system_string);
设备回应云端下发的远程配置
云端下发远程配置后,设备端需要及时给出回复。
// 处理云端下发的远程配置信息
.....
// 定义一个字符串指针,保存需要上传的 json 字符串地址。
char* data_string = NULL;
// 设置需要回复的信息,并把地址保存到对应的指针中。
xiot_add_int_to_payload(&data_string, "ret", xxx);
xiot_add_string_to_payload(&data_string, "msg", "xxx");
// 回应云端下发远程配置的服务
xiot_cloud_remote_config_notice_reply(data_string, mid);