Select one of the symbols to view example projects that use it.
 
Outline
#include "common/bt_defs.h"
#include "osi/allocator.h"
#include "stack/bt_types.h"
#include "stack/hcidefs.h"
#include "stack/hcimsgs.h"
#include "hci/hci_internals.h"
#include "hci/hci_layer.h"
#include "hci/hci_packet_factory.h"
make_reset()
make_read_buffer_size()
make_set_c2h_flow_control(uint8_t)
make_set_adv_report_flow_control(uint8_t, uint16_t, uint16_t)
make_host_buffer_size(uint16_t, uint8_t, uint16_t, uint16_t)
make_read_local_version_info()
make_read_bd_addr()
make_read_local_supported_commands()
make_read_local_supported_features()
make_read_local_extended_features(uint8_t)
make_write_simple_pairing_mode(uint8_t)
make_write_secure_connections_host_support(uint8_t)
make_set_event_mask(const bt_event_mask_t *)
make_ble_write_host_support(uint8_t, uint8_t)
make_ble_read_white_list_size()
make_ble_read_buffer_size()
make_ble_read_supported_states()
make_ble_read_local_supported_features()
make_ble_read_resolving_list_size()
make_ble_read_suggested_default_data_length()
make_ble_write_suggested_default_data_length(uint16_t, uint16_t)
make_ble_set_event_mask(const bt_event_mask_t *)
make_write_sync_flow_control_enable(uint8_t)
make_write_default_erroneous_data_report(uint8_t)
make_command_no_params(uint16_t)
make_command(uint16_t, size_t, uint8_t **)
interface
hci_packet_factory_get_interface()
Files
ESP-IDF
components
app_trace
app_update
bootloader_support
bt
common
controller
esp_ble_mesh
host
bluedroid
api
bta
btc
common
config
device
external
hci
include
main
stack
nimble
include
porting
cmock
console
cxx
driver
efuse
esp_adc
esp_app_format
esp_bootloader_format
esp_coex
esp_common
esp_driver_ana_cmpr
esp_driver_cam
esp_driver_dac
esp_driver_gpio
esp_driver_gptimer
esp_driver_i2c
esp_driver_i2s
esp_driver_jpeg
esp_driver_ledc
esp_driver_mcpwm
esp_driver_parlio
esp_driver_pcnt
esp_driver_rmt
esp_driver_sdio
esp_driver_sdm
esp_driver_sdmmc
esp_driver_sdspi
esp_driver_spi
esp_driver_tsens
esp_driver_uart
esp_driver_usb_serial_jtag
esp_eth
esp_event
esp_gdbstub
esp_hid
esp_http_client
esp_http_server
esp_https_ota
esp_https_server
esp_hw_support
esp_lcd
esp_local_ctrl
esp_mm
esp_netif
esp_partition
esp_phy
esp_pm
esp_psram
esp_ringbuf
esp_rom
esp_security
esp_system
esp_timer
esp_vfs_console
esp_wifi
esp-tls
espcoredump
hal
heap
http_parser
ieee802154
log
mqtt
newlib
nvs_flash
nvs_sec_provider
openthread
perfmon
protobuf-c
protocomm
pthread
rt
sdmmc
soc
spi_flash
spiffs
tcp_transport
ulp
unity
vfs
wear_levelling
wifi_provisioning
wpa_supplicant
xtensa
examples
lwIP
FreeRTOS
cJSON
mbedTLS
SourceVuESP-IDF Framework and ExamplesESP-IDFcomponents/bt/host/bluedroid/hci/hci_packet_factory.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/****************************************************************************** * * Copyright (C) 2014 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ******************************************************************************//* ... */ #include "common/bt_defs.h" #include "osi/allocator.h" #include "stack/bt_types.h" #include "stack/hcidefs.h" #include "stack/hcimsgs.h" #include "hci/hci_internals.h" #include "hci/hci_layer.h" #include "hci/hci_packet_factory.h"8 includes static BT_HDR *make_command_no_params(uint16_t opcode); static BT_HDR *make_command(uint16_t opcode, size_t parameter_size, uint8_t **stream_out); // Interface functions static BT_HDR *make_reset(void) { return make_command_no_params(HCI_RESET); }{ ... } static BT_HDR *make_read_buffer_size(void) { return make_command_no_params(HCI_READ_BUFFER_SIZE); }{ ... } static BT_HDR *make_set_c2h_flow_control(uint8_t enable) { uint8_t *stream; const uint8_t parameter_size = 1; BT_HDR *packet = make_command(HCI_SET_HC_TO_HOST_FLOW_CTRL, parameter_size, &stream); UINT8_TO_STREAM(stream, enable); return packet; }{ ... } static BT_HDR *make_set_adv_report_flow_control(uint8_t enable, uint16_t num, uint16_t lost_threshold) { uint8_t *stream; const uint8_t parameter_size = 1 + 2 + 2; BT_HDR *packet = make_command(HCI_VENDOR_BLE_SET_ADV_FLOW_CONTROL, parameter_size, &stream); UINT8_TO_STREAM(stream, enable); UINT16_TO_STREAM(stream, num); UINT16_TO_STREAM(stream, lost_threshold); return packet; }{ ... } static BT_HDR *make_host_buffer_size(uint16_t acl_size, uint8_t sco_size, uint16_t acl_count, uint16_t sco_count) { uint8_t *stream; const uint8_t parameter_size = 2 + 1 + 2 + 2; // from each of the parameters BT_HDR *packet = make_command(HCI_HOST_BUFFER_SIZE, parameter_size, &stream); UINT16_TO_STREAM(stream, acl_size); UINT8_TO_STREAM(stream, sco_size); UINT16_TO_STREAM(stream, acl_count); UINT16_TO_STREAM(stream, sco_count); return packet; }{ ... } static BT_HDR *make_read_local_version_info(void) { return make_command_no_params(HCI_READ_LOCAL_VERSION_INFO); }{ ... } static BT_HDR *make_read_bd_addr(void) { return make_command_no_params(HCI_READ_BD_ADDR); }{ ... } static BT_HDR *make_read_local_supported_commands(void) { return make_command_no_params(HCI_READ_LOCAL_SUPPORTED_CMDS); }{ ... } static BT_HDR *make_read_local_supported_features(void) { return make_command_no_params(HCI_READ_LOCAL_FEATURES); }{ ... } static BT_HDR *make_read_local_extended_features(uint8_t page_number) { uint8_t *stream; const uint8_t parameter_size = 1; BT_HDR *packet = make_command(HCI_READ_LOCAL_EXT_FEATURES, parameter_size, &stream); UINT8_TO_STREAM(stream, page_number); return packet; }{ ... } static BT_HDR *make_write_simple_pairing_mode(uint8_t mode) { uint8_t *stream; const uint8_t parameter_size = 1; BT_HDR *packet = make_command(HCI_WRITE_SIMPLE_PAIRING_MODE, parameter_size, &stream); UINT8_TO_STREAM(stream, mode); return packet; }{ ... } static BT_HDR *make_write_secure_connections_host_support(uint8_t mode) { uint8_t *stream; const uint8_t parameter_size = 1; BT_HDR *packet = make_command(HCI_WRITE_SECURE_CONNS_SUPPORT, parameter_size, &stream); UINT8_TO_STREAM(stream, mode); return packet; }{ ... } static BT_HDR *make_set_event_mask(const bt_event_mask_t *event_mask) { uint8_t *stream; uint8_t parameter_size = sizeof(bt_event_mask_t); BT_HDR *packet = make_command(HCI_SET_EVENT_MASK, parameter_size, &stream); ARRAY8_TO_STREAM(stream, event_mask->as_array); return packet; }{ ... } static BT_HDR *make_ble_write_host_support(uint8_t supported_host, uint8_t simultaneous_host) { uint8_t *stream; const uint8_t parameter_size = 1 + 1; BT_HDR *packet = make_command(HCI_WRITE_LE_HOST_SUPPORT, parameter_size, &stream); UINT8_TO_STREAM(stream, supported_host); UINT8_TO_STREAM(stream, simultaneous_host); return packet; }{ ... } static BT_HDR *make_ble_read_white_list_size(void) { return make_command_no_params(HCI_BLE_READ_WHITE_LIST_SIZE); }{ ... } static BT_HDR *make_ble_read_buffer_size(void) { return make_command_no_params(HCI_BLE_READ_BUFFER_SIZE); }{ ... } static BT_HDR *make_ble_read_supported_states(void) { return make_command_no_params(HCI_BLE_READ_SUPPORTED_STATES); }{ ... } static BT_HDR *make_ble_read_local_supported_features(void) { return make_command_no_params(HCI_BLE_READ_LOCAL_SPT_FEAT); }{ ... } static BT_HDR *make_ble_read_resolving_list_size(void) { return make_command_no_params(HCI_BLE_READ_RESOLVING_LIST_SIZE); }{ ... } static BT_HDR *make_ble_read_suggested_default_data_length(void) { return make_command_no_params(HCI_BLE_READ_DEFAULT_DATA_LENGTH); }{ ... } static BT_HDR *make_ble_write_suggested_default_data_length(uint16_t SuggestedMaxTxOctets, uint16_t SuggestedMaxTxTime) { uint8_t *stream; uint8_t parameter_size = sizeof(uint16_t) + sizeof(uint16_t); BT_HDR *packet = make_command(HCI_BLE_WRITE_DEFAULT_DATA_LENGTH, parameter_size, &stream); UINT16_TO_STREAM(stream, SuggestedMaxTxOctets); UINT16_TO_STREAM(stream, SuggestedMaxTxTime); return packet; }{ ... } static BT_HDR *make_ble_set_event_mask(const bt_event_mask_t *event_mask) { uint8_t *stream; uint8_t parameter_size = sizeof(bt_event_mask_t); BT_HDR *packet = make_command(HCI_BLE_SET_EVENT_MASK, parameter_size, &stream); ARRAY8_TO_STREAM(stream, event_mask->as_array); return packet; }{ ... } static BT_HDR *make_write_sync_flow_control_enable(uint8_t enable) { uint8_t *stream; const uint8_t parameter_size = 1; BT_HDR *packet = make_command(HCI_WRITE_SCO_FLOW_CTRL_ENABLE, parameter_size, &stream); UINT8_TO_STREAM(stream, enable); return packet; }{ ... } static BT_HDR *make_write_default_erroneous_data_report(uint8_t enable) { uint8_t *stream; const uint8_t parameter_size = 1; BT_HDR *packet = make_command(HCI_WRITE_ERRONEOUS_DATA_RPT, parameter_size, &stream); UINT8_TO_STREAM(stream, enable); return packet; }{ ... } #if (BLE_50_FEATURE_SUPPORT == TRUE) static BT_HDR *make_read_max_adv_data_len(void) { return make_command_no_params(HCI_BLE_RD_MAX_ADV_DATA_LEN); }{...} /* ... */#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) // Internal functions static BT_HDR *make_command_no_params(uint16_t opcode) { return make_command(opcode, 0, NULL); }{ ... } static BT_HDR *make_command(uint16_t opcode, size_t parameter_size, uint8_t **stream_out) { BT_HDR *packet = HCI_GET_CMD_BUF(parameter_size); hci_cmd_metadata_t *metadata = HCI_GET_CMD_METAMSG(packet); metadata->opcode = opcode; uint8_t *stream = packet->data; UINT16_TO_STREAM(stream, opcode); UINT8_TO_STREAM(stream, parameter_size); if (stream_out != NULL) { *stream_out = stream; }{...} return packet; }{ ... } static const hci_packet_factory_t interface = { make_reset, make_read_buffer_size, make_set_c2h_flow_control, make_set_adv_report_flow_control, make_host_buffer_size, make_read_local_version_info, make_read_bd_addr, make_read_local_supported_commands, make_read_local_supported_features, make_read_local_extended_features, make_write_simple_pairing_mode, make_write_secure_connections_host_support, make_set_event_mask, make_ble_write_host_support, make_ble_read_white_list_size, make_ble_read_buffer_size, make_ble_read_supported_states, make_ble_read_local_supported_features, make_ble_read_resolving_list_size, #if (BLE_50_FEATURE_SUPPORT == TRUE) make_read_max_adv_data_len, #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) make_ble_read_suggested_default_data_length, make_ble_write_suggested_default_data_length, make_ble_set_event_mask, make_write_sync_flow_control_enable, make_write_default_erroneous_data_report, }{...}; const hci_packet_factory_t *hci_packet_factory_get_interface(void) { return &interface; }{ ... }
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.