Skip to content

Commit 6afb85a

Browse files
authored
Merge pull request #203 from dhalbert/nus-buffers-at-least-mtu
Make UARTService characteristics be at least as large as max MTU-3
2 parents 3ee63d2 + d1d3fea commit 6afb85a

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ repos:
1818
- id: end-of-file-fixer
1919
- id: trailing-whitespace
2020
- repo: https://github.com/pycqa/pylint
21-
rev: v3.3.0
21+
rev: v3.3.1
2222
hooks:
2323
- id: pylint
2424
name: pylint (library code)

adafruit_ble/characteristics/stream.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ def __init__(
6666
self._timeout = timeout
6767
self._buffer_size = buffer_size
6868
super().__init__(
69-
uuid=uuid, properties=properties, read_perm=read_perm, write_perm=write_perm
69+
uuid=uuid,
70+
properties=properties,
71+
read_perm=read_perm,
72+
write_perm=write_perm,
73+
max_length=buffer_size,
7074
)
7175

7276
def bind(
@@ -104,6 +108,7 @@ def __init__(
104108
properties=properties,
105109
read_perm=Attribute.NO_ACCESS,
106110
write_perm=write_perm,
111+
max_length=buffer_size,
107112
)
108113

109114
def bind(

adafruit_ble/services/nordic.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ class UARTService(Service):
4343
_server_tx = StreamOut(
4444
uuid=VendorUUID("6E400003-B5A3-F393-E0A9-E50E24DCCA9E"),
4545
timeout=1.0,
46-
buffer_size=64,
46+
# 512 is the largest negotiated MTU-3 value for all CircuitPython ports.
47+
buffer_size=512,
4748
)
4849
_server_rx = StreamIn(
4950
uuid=VendorUUID("6E400002-B5A3-F393-E0A9-E50E24DCCA9E"),
5051
timeout=1.0,
51-
buffer_size=64,
52+
# 512 is the largest negotiated MTU-3 value for all CircuitPython ports.
53+
buffer_size=512,
5254
)
5355

5456
def __init__(self, service: Optional[_bleio.Service] = None) -> None:

0 commit comments

Comments
 (0)