-
-
Notifications
You must be signed in to change notification settings - Fork 65
/
esp32_btbufs.py
executable file
·47 lines (40 loc) · 1.75 KB
/
esp32_btbufs.py
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
#!/usr/bin/env python3
import sys
try:
target_path = sys.argv[1]
rxbuf_size = 0; rxbuf_minsize = 6144
txbuf_size = 0; txbuf_minsize = 384
line_index = 0
rx_line_index = 0
tx_line_index = 0
with open(target_path) as sf:
for line in sf:
line_index += 1
if line.startswith("#define RX_QUEUE_SIZE"):
ents = line.split(" ")
try:
rxbuf_size = int(ents[2])
rx_line_index = line_index
except Exception as e:
print(f"Could not parse Bluetooth RX_QUEUE_SIZE: {e}")
if line.startswith("#define TX_QUEUE_SIZE"):
ents = line.split(" ")
try:
txbuf_size = int(ents[2])
tx_line_index = line_index
except Exception as e:
print(f"Could not parse Bluetooth RX_QUEUE_SIZE: {e}")
if rxbuf_size != 0 and txbuf_size != 0:
break
if rxbuf_size < rxbuf_minsize:
print(f"Error: The configured ESP32 Bluetooth RX buffer size is too small, please set it to at least {rxbuf_minsize} and try compiling again.")
print(f"The buffer configuration can be modified in line {rx_line_index} of: {target_path}")
exit(1)
if txbuf_size < txbuf_minsize:
print(f"Error: The configured ESP32 Bluetooth TX buffer size is too small, please set it to at least {txbuf_minsize} and try compiling again.")
print(f"The buffer configuration can be modified in line {tx_line_index} of: {target_path}")
exit(1)
exit(0)
except Exception as e:
print(f"Could not determine ESP32 Bluetooth buffer configuration: {e}")
print("Please fix this error and try again")