xref: /btstack/port/stm32-wb55xx-nucleo-freertos/Middlewares/STM32_WPAN/ble/core/ble_legacy.h (revision 0561b2d8d5dba972c7daa57d5e677f7a1327edfd)
1 /*****************************************************************************
2  * @file    ble_legacy.h
3  * @author  MCD Application Team
4  * @brief   This file contains legacy definitions used for BLE.
5  *****************************************************************************
6  * @attention
7  *
8  * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
9  * All rights reserved.</center></h2>
10  *
11  * This software component is licensed by ST under Ultimate Liberty license
12  * SLA0044, the "License"; You may not use this file except in compliance with
13  * the License. You may obtain a copy of the License at:
14  *                             www.st.com/SLA0044
15  *
16  ******************************************************************************
17  */
18 
19 #ifndef BLE_LEGACY_H__
20 #define BLE_LEGACY_H__
21 
22 
23 /* ------------------------------------------------------------------------- */
24 
25 
26 /*
27  * The event code in the @ref hci_event_pckt structure.
28  * If event code is EVT_VENDOR,  application can use @ref evt_blue_aci
29  * structure to parse the packet.
30  */
31 #define EVT_VENDOR                      0xFF
32 
33 #define EVT_CONN_COMPLETE               0x03
34 #define EVT_DISCONN_COMPLETE            0x05
35 #define EVT_LE_META_EVENT               0x3E
36 #define EVT_LE_CONN_UPDATE_COMPLETE     0x03
37 #define EVT_LE_CONN_COMPLETE            0x01
38 #define EVT_LE_ADVERTISING_REPORT       0x02
39 #define EVT_LE_PHY_UPDATE_COMPLETE      0x0C
40 #define EVT_LE_ENHANCED_CONN_COMPLETE   0x0A
41 
42 typedef PACKED(struct) _hci_uart_pckt
43 {
44   uint8_t type;
45   uint8_t data[1];
46 } hci_uart_pckt;
47 
48 typedef PACKED(struct) _hci_event_pckt
49 {
50   uint8_t         evt;
51   uint8_t         plen;
52   uint8_t         data[1];
53 } hci_event_pckt;
54 
55 typedef PACKED(struct) _evt_le_meta_event
56 {
57   uint8_t         subevent;
58   uint8_t         data[1];
59 } evt_le_meta_event;
60 
61 /**
62  * Vendor specific event for BLE core.
63  */
64 typedef PACKED(struct) _evt_blue_aci
65 {
66   uint16_t ecode; /**< One of the BLE core event codes. */
67   uint8_t  data[1];
68 } evt_blue_aci;
69 
70 
71 /* BLE core event codes */
72 #define EVT_BLUE_GATT_ATTRIBUTE_MODIFIED          (0x0C01)
73 #define EVT_BLUE_GATT_PROCEDURE_TIMEOUT           (0x0C02)
74 #define EVT_BLUE_ATT_EXCHANGE_MTU_RESP            (0x0C03)
75 #define EVT_BLUE_ATT_FIND_INFORMATION_RESP        (0x0C04)
76 #define EVT_BLUE_ATT_FIND_BY_TYPE_VAL_RESP        (0x0C05)
77 #define EVT_BLUE_ATT_READ_BY_TYPE_RESP            (0x0C06)
78 #define EVT_BLUE_ATT_READ_RESP                    (0x0C07)
79 #define EVT_BLUE_ATT_READ_BLOB_RESP               (0x0C08)
80 #define EVT_BLUE_ATT_READ_MULTIPLE_RESP           (0x0C09)
81 #define EVT_BLUE_ATT_READ_BY_GROUP_TYPE_RESP      (0x0C0A)
82 #define EVT_BLUE_ATT_PREPARE_WRITE_RESP           (0x0C0C)
83 #define EVT_BLUE_ATT_EXEC_WRITE_RESP              (0x0C0D)
84 #define EVT_BLUE_GATT_INDICATION                  (0x0C0E)
85 #define EVT_BLUE_GATT_NOTIFICATION                (0x0C0F)
86 #define EVT_BLUE_GATT_PROCEDURE_COMPLETE          (0x0C10)
87 #define EVT_BLUE_GATT_ERROR_RESP                  (0x0C11)
88 #define EVT_BLUE_GATT_DISC_READ_CHAR_BY_UUID_RESP (0x0C12)
89 #define EVT_BLUE_GATT_WRITE_PERMIT_REQ            (0x0C13)
90 #define EVT_BLUE_GATT_READ_PERMIT_REQ             (0x0C14)
91 #define EVT_BLUE_GATT_READ_MULTI_PERMIT_REQ       (0x0C15)
92 #define EVT_BLUE_GATT_TX_POOL_AVAILABLE           (0x0C16)
93 #define EVT_BLUE_GATT_SERVER_CONFIRMATION_EVENT   (0x0C17)
94 #define EVT_BLUE_GATT_PREPARE_WRITE_PERMIT_REQ    (0x0C18)
95 #define EVT_BLUE_GAP_LIMITED_DISCOVERABLE         (0x0400)
96 #define EVT_BLUE_GAP_PAIRING_CMPLT                (0x0401)
97 #define EVT_BLUE_GAP_PASS_KEY_REQUEST             (0x0402)
98 #define EVT_BLUE_GAP_AUTHORIZATION_REQUEST        (0x0403)
99 #define EVT_BLUE_GAP_SLAVE_SECURITY_INITIATED     (0X0404)
100 #define EVT_BLUE_GAP_BOND_LOST                    (0X0405)
101 #define EVT_BLUE_GAP_DEVICE_FOUND                 (0x0406)
102 #define EVT_BLUE_GAP_PROCEDURE_COMPLETE           (0x0407)
103 #define EVT_BLUE_GAP_ADDR_NOT_RESOLVED            (0x0408)
104 #define EVT_BLUE_GAP_NUMERIC_COMPARISON_VALUE     (0x0409)
105 #define EVT_BLUE_GAP_KEYPRESS_NOTIFICATION        (0x040A)
106 #define EVT_BLUE_L2CAP_CONNECTION_UPDATE_REQ      (0x0802)
107 #define EVT_BLUE_L2CAP_CONNECTION_UPDATE_RESP     (0x0800)
108 
109 
110 /* ------------------------------------------------------------------------- */
111 
112 
113 /* Bluetooth 48 bit address (in little-endian order).
114  */
115 typedef	uint8_t	tBDAddr[6];
116 
117 
118 /* ------------------------------------------------------------------------- */
119 
120 
121 /* Min. ATT MTU size
122  */
123 #define ATT_MTU                               23
124 
125 
126 /* ------------------------------------------------------------------------- */
127 
128 
129 /* Error Codes as specified by the specification
130  */
131 #define ERR_CMD_SUCCESS                              0x00
132 #define ERR_UNKNOWN_HCI_COMMAND	                     0x01
133 #define ERR_UNKNOWN_CONN_IDENTIFIER                  0x02
134 #define ERR_AUTH_FAILURE                             0x05
135 #define ERR_PIN_OR_KEY_MISSING                       0x06
136 #define ERR_MEM_CAPACITY_EXCEEDED                    0x07
137 #define ERR_CONNECTION_TIMEOUT                       0x08
138 #define ERR_COMMAND_DISALLOWED                       0x0C
139 #define ERR_UNSUPPORTED_FEATURE                      0x11
140 #define ERR_INVALID_HCI_CMD_PARAMS                   0x12
141 #define ERR_RMT_USR_TERM_CONN                        0x13
142 #define ERR_RMT_DEV_TERM_CONN_LOW_RESRCES            0x14
143 #define ERR_RMT_DEV_TERM_CONN_POWER_OFF              0x15
144 #define ERR_LOCAL_HOST_TERM_CONN                     0x16
145 #define ERR_UNSUPP_RMT_FEATURE                       0x1A
146 #define ERR_INVALID_LMP_PARAM                        0x1E
147 #define ERR_UNSPECIFIED_ERROR                        0x1F
148 #define ERR_LL_RESP_TIMEOUT                          0x22
149 #define ERR_LMP_PDU_NOT_ALLOWED                      0x24
150 #define ERR_INSTANT_PASSED                           0x28
151 #define ERR_PAIR_UNIT_KEY_NOT_SUPP                   0x29
152 #define ERR_CONTROLLER_BUSY                          0x3A
153 #define ERR_DIRECTED_ADV_TIMEOUT                     0x3C
154 #define ERR_CONN_END_WITH_MIC_FAILURE                0x3D
155 #define ERR_CONN_FAILED_TO_ESTABLISH                 0x3E
156 
157 
158 /* ------------------------------------------------------------------------- */
159 
160 
161 #define FLASH_READ_FAILED                            0x49
162 #define FLASH_WRITE_FAILED                           0x4A
163 #define FLASH_ERASE_FAILED                           0x4B
164 
165 
166 /* ------------------------------------------------------------------------- */
167 
168 
169 #endif /* BLE_LEGACY_H__ */
170