scheme_ble.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #ifndef _SCHEME_BLE_H_
  8. #define _SCHEME_BLE_H_
  9. #ifdef CONFIG_OTA_WITH_PROTOCOMM
  10. #include <protocomm.h>
  11. #include <protocomm_ble.h>
  12. #include "manager.h"
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. /**
  17. * @brief Scheme that can be used by manager for ota
  18. * over BLE transport with GATT server
  19. */
  20. extern const esp_ble_ota_scheme_t esp_ble_ota_scheme_ble;
  21. /* This scheme specific event handler is to be used when application
  22. * doesn't require BT and BLE after ota has finished */
  23. #define ESP_BLE_OTA_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM { \
  24. .event_cb = esp_ble_ota_scheme_ble_event_cb_free_btdm, \
  25. .user_data = NULL \
  26. }
  27. /* This scheme specific event handler is to be used when application
  28. * doesn't require BLE to be active after ota has finished */
  29. #define ESP_BLE_OTA_SCHEME_BLE_EVENT_HANDLER_FREE_BLE { \
  30. .event_cb = esp_ble_ota_scheme_ble_event_cb_free_ble, \
  31. .user_data = NULL \
  32. }
  33. /* This scheme specific event handler is to be used when application
  34. * doesn't require BT to be active after ota has finished */
  35. #define ESP_BLE_OTA_SCHEME_BLE_EVENT_HANDLER_FREE_BT { \
  36. .event_cb = esp_ble_ota_scheme_ble_event_cb_free_bt, \
  37. .user_data = NULL \
  38. }
  39. void esp_ble_ota_scheme_ble_event_cb_free_btdm(void *user_data, esp_ble_ota_cb_event_t event, void *event_data);
  40. void esp_ble_ota_scheme_ble_event_cb_free_ble (void *user_data, esp_ble_ota_cb_event_t event, void *event_data);
  41. void esp_ble_ota_scheme_ble_event_cb_free_bt (void *user_data, esp_ble_ota_cb_event_t event, void *event_data);
  42. /**
  43. * @brief Set the 128 bit GATT service UUID used for ota
  44. *
  45. * This API is used to override the default 128 bit ota
  46. * service UUID, which is 0000ffff-0000-1000-8000-00805f9b34fb.
  47. *
  48. * This must be called before starting ota, i.e. before
  49. * making a call to esp_ble_ota_start(), otherwise
  50. * the default UUID will be used.
  51. *
  52. * @note The data being pointed to by the argument must be valid
  53. * atleast till ota is started. Upon start, the
  54. * manager will store an internal copy of this UUID, and
  55. * this data can be freed or invalidated afterwords.
  56. *
  57. * @param[in] uuid128 A custom 128 bit UUID
  58. *
  59. * @return
  60. * - ESP_OK : Success
  61. * - ESP_ERR_INVALID_ARG : Null argument
  62. */
  63. esp_err_t esp_ble_ota_scheme_ble_set_service_uuid(uint8_t *uuid128);
  64. /**
  65. * @brief Set manufacturer specific data in scan response
  66. *
  67. * This must be called before starting ota, i.e. before
  68. * making a call to esp_ble_ota_start().
  69. *
  70. * @note It is important to understand that length of custom manufacturer
  71. * data should be within limits. The manufacturer data goes into scan
  72. * response along with BLE device name. By default, BLE device name
  73. * length is of 11 Bytes, however it can vary as per application use
  74. * case. So, one has to honour the scan response data size limits i.e.
  75. * (mfg_data_len + 2) < 31 - (device_name_length + 2 ). If the
  76. * mfg_data length exceeds this limit, the length will be truncated.
  77. *
  78. * @param[in] mfg_data Custom manufacturer data
  79. * @param[in] mfg_data_len Manufacturer data length
  80. *
  81. * @return
  82. * - ESP_OK : Success
  83. * - ESP_ERR_INVALID_ARG : Null argument
  84. */
  85. esp_err_t esp_ble_ota_scheme_ble_set_mfg_data(uint8_t *mfg_data, ssize_t mfg_data_len);
  86. #ifdef __cplusplus
  87. }
  88. #endif
  89. #endif /* CONFIG_OTA_WITH_PROTOCOMM */
  90. #endif