ota.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef _OTA_H_
  7. #define _OTA_H_
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. typedef struct ota_ctrl_handlers {
  12. /**
  13. * Handler function called when ota sending file is requested. Status
  14. * is given the parameters :
  15. *
  16. * file (input) - file received through OTA
  17. *
  18. * length (input) - length of file received
  19. */
  20. esp_err_t (*ota_send_file)(uint8_t *file, size_t length);
  21. /**
  22. * Handler function called when ota start is requested. Status
  23. * is given the parameters :
  24. *
  25. * file_size (input) - total size of the file
  26. *
  27. * block_size (input) - size of one block
  28. *
  29. * partition_name (input) - custom partition where data is to be written
  30. */
  31. esp_err_t (*ota_start_cmd)(size_t file_size, size_t block_size, char *partition_name);
  32. /**
  33. * Handler function called when ota is completed.
  34. */
  35. esp_err_t (*ota_finish_cmd)();
  36. } ota_handlers_t;
  37. /**
  38. * @brief Handler for ota requests
  39. *
  40. * This is to be registered as the `recv-fw`, 'ota-bar', 'ota-command',
  41. * 'ota-customer' endpoint handler (protocomm `protocomm_req_handler_t`)
  42. * using `protocomm_add_endpoint()`
  43. */
  44. esp_err_t ota_handler(uint32_t session_id, const uint8_t *inbuf, ssize_t inlen,
  45. uint8_t **outbuf, ssize_t *outlen, void *priv_data);
  46. #ifdef __cplusplus
  47. }
  48. #endif
  49. #endif