You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2022/06/22 08:04:32 UTC

[mynewt-nimble] 01/03: tools/hci_throughput: fix supported octets info

This is an automated email from the ASF dual-hosted git repository.

janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit b2d682bf51b2bba97f0abc321aecb7be076f3a85
Author: Jakub <ja...@codecoup.pl>
AuthorDate: Mon Jun 13 14:18:29 2022 +0200

    tools/hci_throughput: fix supported octets info
---
 tools/hci_throughput/hci.py          | 2 ++
 tools/hci_throughput/hci_commands.py | 9 +++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/tools/hci_throughput/hci.py b/tools/hci_throughput/hci.py
index 072e395e..69b36374 100644
--- a/tools/hci_throughput/hci.py
+++ b/tools/hci_throughput/hci.py
@@ -31,6 +31,8 @@ HCI_COMMAND_PACKET = 0x01
 HCI_ACL_DATA_PACKET = 0x02
 HCI_EVENT_PACKET = 0x04
 
+L2CAP_HDR_BYTES = 4
+
 HCI_EV_CODE_DISCONN_CMP = 0x05
 HCI_EV_CODE_CMD_CMP = 0x0e
 HCI_EV_CODE_CMD_STATUS = 0x0f
diff --git a/tools/hci_throughput/hci_commands.py b/tools/hci_throughput/hci_commands.py
index 2978ab85..286f4506 100644
--- a/tools/hci_throughput/hci_commands.py
+++ b/tools/hci_throughput/hci_commands.py
@@ -422,10 +422,11 @@ class HCI_Commands():
                 hci.max_data_len.set(*struct.unpack("<BHHHH",
                                      current_ev.return_parameters))
                 logging.info(f"Suggested Max Data Len: {hci.max_data_len}")
-                if (hci.num_of_bytes_to_send > hci.max_data_len.supported_max_tx_octets - 4):
-                    logging.critical(f"Number of bytes to send: {hci.num_of_bytes_to_send}\
-                                     not supported. Closing.")
-                    raise SystemExit("Number of bytes to send not supported. Closing.")
+                if (hci.num_of_bytes_to_send > hci.max_data_len.supported_max_tx_octets - hci.L2CAP_HDR_BYTES):
+                    logging.critical(f"Number of data bytes to send + 4 bytes of L2CAP header: {hci.num_of_bytes_to_send + 4} "
+                                     f"exceeds allowed value of: {hci.max_data_len.supported_max_tx_octets}. Closing.")
+                    raise SystemExit(f"Number of data bytes to send + 4 bytes of L2CAP header: {hci.num_of_bytes_to_send + 4} "
+                                     f"exceeds allowed value of: {hci.max_data_len.supported_max_tx_octets}. Closing.")
 
                 return status()
             elif ocf == hci.OCF_LE_READ_PHY: