fotax.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (C) 2019-2020 Alibaba Group Holding Limited
  3. */
  4. #ifndef __FOTAX_H__
  5. #define __FOTAX_H__
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. typedef enum {
  10. FOTAX_EVENT_VERSION = 0, /*!< Check version from server ok */
  11. FOTAX_EVENT_DOWNLOAD, /*!< Downloading the fota data */
  12. FOTAX_EVENT_END, /*!< This event occurs when there are any errors during execution */
  13. FOTAX_EVENT_RESTART /*!< real want to restart */
  14. } fotax_event_e;
  15. typedef enum {
  16. FOTAX_INIT = 1, /*!< create fota task, wait for version check */
  17. FOTAX_DOWNLOAD = 2, /*!< start to download fota data */
  18. FOTAX_ABORT = 3, /*!< read or write exception */
  19. FOTAX_FINISH = 4, /*!< download finish */
  20. } fotax_status_e;
  21. typedef struct {
  22. void *cert;
  23. int (*fota_register_cloud)(void);
  24. int (*netio_register_from)(const char *cert);
  25. int (*netio_register_to)(void);
  26. } fota_register_ops_t;
  27. typedef struct fotax fotax_t;
  28. typedef void (*fotax_event_cb_t)(fotax_t *fotax, fotax_event_e event, const char *json); ///< fota Event call back.
  29. struct fotax {
  30. void *fota_handle;
  31. fotax_status_e state;
  32. fotax_event_cb_t fotax_event_cb;
  33. fota_register_ops_t *register_ops;
  34. void *private;
  35. };
  36. int fotax_start(fotax_t *fotax);
  37. int fotax_stop(fotax_t *fotax);
  38. int fotax_get_state(fotax_t *fotax);
  39. int fotax_version_check(fotax_t *fotax);
  40. int fotax_download(fotax_t *fotax);
  41. int fotax_restart(fotax_t *fotax, int delay_ms);
  42. int64_t fotax_get_size(fotax_t *fotax, const char *name);
  43. #ifdef __cplusplus
  44. }
  45. #endif
  46. #endif