ota_backend_bt.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright (c) 2019 Actions Semiconductor Co., Ltd
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @file
  8. * @brief OTA bluetooth backend interface
  9. */
  10. #ifndef __OTA_BACKEND_BT_H__
  11. #define __OTA_BACKEND_BT_H__
  12. #include <stream.h>
  13. #include <ota_backend.h>
  14. typedef io_stream_t stream_cb(void *);
  15. typedef int (*ota_backend_type_cb_t)(int);
  16. /** enum, ota type*/
  17. enum OTA_TYPE_FOR_DEVICE{
  18. PROT_OTA_PHONE_APP = 0,
  19. PROT_OTA_FACTORY_OFFLINE = 1,
  20. PROT_OTA_DONGLE_PC_CONDIF = 2,
  21. };
  22. /** structure of ota backend bt init param, Initialized by the user*/
  23. struct ota_backend_bt_init_param {
  24. const uint8_t *spp_uuid;/**spp uuid*/
  25. void *gatt_attr;
  26. uint8_t attr_size;
  27. void *tx_chrc_attr;
  28. void *tx_attr;
  29. void *tx_ccc_attr;
  30. void *rx_attr;
  31. s32_t read_timeout;/** read data from bt time out*/
  32. s32_t write_timeout;/** send data to bt time out*/
  33. };
  34. /**
  35. * @brief ota backend bt init.
  36. *
  37. * This routine init backend bt,calls by ota app.
  38. *
  39. * @param cb call back function,to tell ota app start stop upgrade,and upgrade progress.
  40. * @param param backend bt init param.
  41. *
  42. *return backend if init success.
  43. *return NULL if init fail.
  44. */
  45. struct ota_backend *ota_backend_bt_init(ota_backend_notify_cb_t cb,
  46. struct ota_backend_bt_init_param *param);
  47. struct ota_backend *ota_backend_zble_init(ota_backend_notify_cb_t cb);
  48. /**
  49. * @brief ota backend bt exit.
  50. *
  51. * This routine free backend bt.
  52. *
  53. * @param backend pointer to backend
  54. *
  55. */
  56. void ota_backend_bt_exit(struct ota_backend *backend);
  57. /**
  58. * @brief ota backend load bt init.
  59. *
  60. * This routine init backend load bt,calls by ota app.
  61. *
  62. * @param cb call back function,to tell ota app start stop upgrade,and upgrade progress.
  63. * @param param backend bt init param.
  64. * @param scb stream call back function.
  65. * @param *pexist_stream get steam address.
  66. *
  67. *return backend if init success.
  68. *return NULL if init fail.
  69. */
  70. struct ota_backend *ota_backend_load_bt_init(ota_backend_notify_cb_t cb,
  71. struct ota_backend_bt_init_param *param, stream_cb scb, io_stream_t *pexist_stream);
  72. /**
  73. * @brief ota backend stream set.
  74. *
  75. * This routine provides set dest stream to origin stream,calls by ota app.
  76. *
  77. * @param exist_stream handle of dest stream
  78. *
  79. */
  80. void ota_backend_stream_set(io_stream_t exist_stream);
  81. /**
  82. * @brief ota backend set callback for ota type.
  83. *
  84. * This routine provides set ota type callback to backend,calls by ota app.
  85. *
  86. * @param tcb pointer of callback
  87. *
  88. */
  89. void ota_backend_ota_type_cb_set(ota_backend_type_cb_t tcb);
  90. #endif /* __OTA_BACKEND_BT_H__ */