ble_const.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*****************************************************************************
  2. * @file ble_const.h
  3. * @author MDG
  4. * @brief This file contains the definitions which are compiler dependent.
  5. *****************************************************************************
  6. * @attention
  7. *
  8. * Copyright (c) 2018-2022 STMicroelectronics.
  9. * All rights reserved.
  10. *
  11. * This software is licensed under terms that can be found in the LICENSE file
  12. * in the root directory of this software component.
  13. * If no LICENSE file comes with this software, it is provided AS-IS.
  14. *
  15. *****************************************************************************
  16. */
  17. #ifndef BLE_CONST_H__
  18. #define BLE_CONST_H__
  19. #include <stdint.h>
  20. #include <string.h>
  21. #include <ble/core/ble_std.h>
  22. #include <ble/core/ble_defs.h>
  23. #include "osal.h"
  24. /* Default BLE variant */
  25. #ifndef BASIC_FEATURES
  26. #define BASIC_FEATURES 0
  27. #endif
  28. #ifndef SLAVE_ONLY
  29. #define SLAVE_ONLY 0
  30. #endif
  31. #ifndef LL_ONLY
  32. #define LL_ONLY 0
  33. #endif
  34. #ifndef BEACON_ONLY
  35. #define BEACON_ONLY 0
  36. #endif
  37. /* Size of command/events buffers:
  38. *
  39. * To change the size of commands and events parameters used in the
  40. * auto-generated files, you need to update 2 defines:
  41. *
  42. * - BLE_CMD_MAX_PARAM_LEN
  43. * - BLE_EVT_MAX_PARAM_LEN
  44. *
  45. * These 2 defines are set below with default values and can be changed.
  46. *
  47. * To compute the value to support a characteristic of 512 bytes for a specific
  48. * command or an event, you need to look in "ble_types.h".
  49. *
  50. * Here are 2 examples, one with a command and one with an event:
  51. *
  52. * - aci_gatt_update_char_value_ext_cp0
  53. * ----------------------------------
  54. *
  55. * we have in the structure:
  56. *
  57. * uint8_t Value[(BLE_CMD_MAX_PARAM_LEN- 12)/sizeof(uint8_t)];
  58. *
  59. * so to support a 512 byte value, we need to have
  60. *
  61. * BLE_CMD_MAX_PARAM_LEN at least equal to: 512 + 12 = 524
  62. *
  63. * - aci_gatt_read_handle_value_rp0
  64. * ------------------------------
  65. *
  66. * we have in the structure:
  67. *
  68. * uint8_t Value[((BLE_EVT_MAX_PARAM_LEN - 3) - 5)/sizeof(uint8_t)];
  69. *
  70. * so to support a 512 byte value, we need to have
  71. *
  72. * BLE_EVT_MAX_PARAM_LEN at least equal to: 512 + 3 + 5 = 520
  73. *
  74. * If you need several events or commands with 512-size values, you need to
  75. * take the maximum values for BLE_EVT_MAX_PARAM_LEN and BLE_CMD_MAX_PARAM_LEN.
  76. *
  77. */
  78. /* Maximum parameter size of BLE commands.
  79. * Change this value if needed. */
  80. #define BLE_CMD_MAX_PARAM_LEN HCI_COMMAND_MAX_PARAM_LEN
  81. /* Maximum parameter size of BLE responses/events.
  82. * Change this value if needed. */
  83. #define BLE_EVT_MAX_PARAM_LEN HCI_EVENT_MAX_PARAM_LEN
  84. /* Callback function to send command and receive response */
  85. struct hci_request {
  86. uint16_t ogf;
  87. uint16_t ocf;
  88. int event;
  89. void* cparam;
  90. int clen;
  91. void* rparam;
  92. int rlen;
  93. };
  94. extern int hci_send_req(struct hci_request* req, uint8_t async);
  95. #ifndef FALSE
  96. #define FALSE 0
  97. #endif
  98. #ifndef MIN
  99. #define MIN(a, b) (((a) < (b)) ? (a) : (b))
  100. #endif
  101. #ifndef MAX
  102. #define MAX(a, b) (((a) > (b)) ? (a) : (b))
  103. #endif
  104. #endif /* BLE_CONST_H__ */