ble_const.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. #include "compiler.h"
  25. /* Default BLE variant */
  26. #ifndef BASIC_FEATURES
  27. #define BASIC_FEATURES 0
  28. #endif
  29. #ifndef SLAVE_ONLY
  30. #define SLAVE_ONLY 0
  31. #endif
  32. #ifndef LL_ONLY
  33. #define LL_ONLY 0
  34. #endif
  35. #ifndef LL_ONLY_BASIC
  36. #define LL_ONLY_BASIC 0
  37. #endif
  38. #ifndef BEACON_ONLY
  39. #define BEACON_ONLY 0
  40. #endif
  41. /* Size of command/events buffers:
  42. *
  43. * To change the size of commands and events parameters used in the
  44. * auto-generated files, you need to update 2 defines:
  45. *
  46. * - BLE_CMD_MAX_PARAM_LEN
  47. * - BLE_EVT_MAX_PARAM_LEN
  48. *
  49. * These 2 defines are set below with default values and can be changed.
  50. *
  51. * To compute the value to support a characteristic of 512 bytes for a specific
  52. * command or an event, you need to look in "ble_types.h".
  53. *
  54. * Here are 2 examples, one with a command and one with an event:
  55. *
  56. * - aci_gatt_update_char_value_ext_cp0
  57. * ----------------------------------
  58. *
  59. * we have in the structure:
  60. *
  61. * uint8_t Value[(BLE_CMD_MAX_PARAM_LEN- 12)/sizeof(uint8_t)];
  62. *
  63. * so to support a 512 byte value, we need to have
  64. *
  65. * BLE_CMD_MAX_PARAM_LEN at least equal to: 512 + 12 = 524
  66. *
  67. * - aci_gatt_read_handle_value_rp0
  68. * ------------------------------
  69. *
  70. * we have in the structure:
  71. *
  72. * uint8_t Value[((BLE_EVT_MAX_PARAM_LEN - 3) - 5)/sizeof(uint8_t)];
  73. *
  74. * so to support a 512 byte value, we need to have
  75. *
  76. * BLE_EVT_MAX_PARAM_LEN at least equal to: 512 + 3 + 5 = 520
  77. *
  78. * If you need several events or commands with 512-size values, you need to
  79. * take the maximum values for BLE_EVT_MAX_PARAM_LEN and BLE_CMD_MAX_PARAM_LEN.
  80. *
  81. */
  82. /* Maximum parameter size of BLE commands.
  83. * Change this value if needed. */
  84. #define BLE_CMD_MAX_PARAM_LEN HCI_COMMAND_MAX_PARAM_LEN
  85. /* Maximum parameter size of BLE responses/events.
  86. * Change this value if needed. */
  87. #define BLE_EVT_MAX_PARAM_LEN HCI_EVENT_MAX_PARAM_LEN
  88. /* Callback function to send command and receive response */
  89. struct hci_request {
  90. uint16_t ogf;
  91. uint16_t ocf;
  92. int event;
  93. void* cparam;
  94. int clen;
  95. void* rparam;
  96. int rlen;
  97. };
  98. extern int hci_send_req(struct hci_request* req, uint8_t async);
  99. #ifndef FALSE
  100. #define FALSE 0
  101. #endif
  102. #ifndef MIN
  103. #define MIN(a, b) (((a) < (b)) ? (a) : (b))
  104. #endif
  105. #ifndef MAX
  106. #define MAX(a, b) (((a) > (b)) ? (a) : (b))
  107. #endif
  108. #endif /* BLE_CONST_H__ */