ota_lib.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Tencent is pleased to support the open source community by making IoT Hub
  3. available.
  4. * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
  5. * Licensed under the MIT License (the "License"); you may not use this file
  6. except in
  7. * compliance with the License. You may obtain a copy of the License at
  8. * http://opensource.org/licenses/MIT
  9. * Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is
  11. * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  12. KIND,
  13. * either express or implied. See the License for the specific language
  14. governing permissions and
  15. * limitations under the License.
  16. *
  17. */
  18. #ifndef IOT_OTA_LIB_H_
  19. #define IOT_OTA_LIB_H_
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. #include <stdint.h>
  24. //#include <sys/types.h>
  25. #include "qcloud_iot_export_ota.h"
  26. void *qcloud_otalib_md5_init(void);
  27. void qcloud_otalib_md5_update(void *md5, const char *buf, size_t buf_len);
  28. void qcloud_otalib_md5_finalize(void *md5, char *output_str);
  29. void qcloud_otalib_md5_deinit(void *md5);
  30. int qcloud_otalib_get_firmware_type(const char *json, char **type);
  31. int qcloud_otalib_get_report_version_result(const char *json);
  32. /**
  33. * @brief Parse firmware info from JSON string
  34. *
  35. * @param json source JSON string
  36. * @param type parsed type
  37. * @param url parsed url
  38. * @param version parsed version
  39. * @param md5 parsed MD5
  40. * @param fileSize parsed file size
  41. * @return QCLOUD_RET_SUCCESS for success, or err code for failure
  42. */
  43. int qcloud_otalib_get_params(const char *json, char **type, char **url, char **version, char *md5, uint32_t *fileSize);
  44. /**
  45. * @brief Generate firmware info from id and version
  46. *
  47. * @param buf output buffer
  48. * @param bufLen size of buffer
  49. * @param id firmware id
  50. * @param version firmware version
  51. * @return QCLOUD_RET_SUCCESS for success, or err code for failure
  52. */
  53. int qcloud_otalib_gen_info_msg(char *buf, size_t bufLen, uint32_t id, const char *version);
  54. /**
  55. * @brief Generate firmware report
  56. *
  57. * @param buf output buffer
  58. * @param bufLen size of buffer
  59. * @param id firmware id
  60. * @param version firmware version
  61. * @param progress download progress
  62. * @param reportType report type
  63. * @return QCLOUD_RET_SUCCESS for success, or err code for failure
  64. */
  65. int qcloud_otalib_gen_report_msg(char *buf, size_t bufLen, uint32_t id, const char *version, int progress,
  66. IOT_OTAReportType reportType);
  67. #ifdef __cplusplus
  68. }
  69. #endif
  70. #endif /* IOT_OTA_LIB_H_ */