Skip to content

Commit

Permalink
Increase max MTU
Browse files Browse the repository at this point in the history
  • Loading branch information
shermp committed Aug 18, 2024
1 parent 9bc79ca commit cbe6d99
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
34 changes: 34 additions & 0 deletions scripts/conv_asha_hci.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python3

import argparse
import re
from pathlib import Path

def ms_to_ts(ms: str) -> str:
millis = int(ms)
seconds, milliseconds = divmod(millis, 1000)
minutes, seconds = divmod(seconds, 60)
hours, minutes = divmod(minutes, 60)
return (f'{hours:02}:{minutes:02}:{seconds:02}.{milliseconds:03}')

if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('hci_dump', type=Path)
parser.add_argument('output', type=Path)

args = parser.parse_args()

with open(args.hci_dump, 'r') as hci:
lines = hci.readlines()

out_lines: list[str] = []
for line in lines:
m = re.match(r'\[ASHA\s+(ERROR|INFO|AUDIO|SCAN)\s+:\s+(\d+) ms\] (.+)', line)
if m:
out_lines.append(f'[{ms_to_ts(m.group(2))}] LOG -- ASHA {m.group(1)}: {m.group(3)}\n')
else:
out_lines.append(line)

with open(args.output, 'w') as out:
out.writelines(out_lines)

2 changes: 1 addition & 1 deletion src/asha_bt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ extern "C" void bt_main()
/* L2CAP init required for basic btstack functionality */
LOG_INFO("L2CAP Init.\n");
l2cap_init();
l2cap_set_max_le_mtu(buff_size_sdu);
l2cap_set_max_le_mtu(max_mtu);

/* Init the security manager. This takes care of pairing
with hearing aids, and also allows reconnecting to already
Expand Down
4 changes: 3 additions & 1 deletion src/hearing_aid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ constexpr uint32_t ha_cache_size = 4ul;

constexpr uint32_t ha_cache_mask = ha_cache_size - 1ul;

constexpr uint16_t max_mtu = 512;

class HA
{
public:
Expand Down Expand Up @@ -148,7 +150,7 @@ class HA

// Creating an L2CAP channel requires a receive buffer
// This is unused, as we only ever send data
std::array<uint8_t, sdu_size_bytes> recv_buff = {};
std::array<uint8_t, max_mtu> recv_buff = {};

btstack_packet_handler_t l2cap_packet_handler = nullptr;
btstack_packet_handler_t gatt_packet_handler = nullptr;
Expand Down

0 comments on commit cbe6d99

Please sign in to comment.