Skip to content

Commit

Permalink
Merge pull request #203 from dhalbert/nus-buffers-at-least-mtu
Browse files Browse the repository at this point in the history
Make UARTService characteristics be at least as large as max MTU-3
  • Loading branch information
tannewt authored Oct 21, 2024
2 parents 3ee63d2 + d1d3fea commit 6afb85a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pycqa/pylint
rev: v3.3.0
rev: v3.3.1
hooks:
- id: pylint
name: pylint (library code)
Expand Down
7 changes: 6 additions & 1 deletion adafruit_ble/characteristics/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ def __init__(
self._timeout = timeout
self._buffer_size = buffer_size
super().__init__(
uuid=uuid, properties=properties, read_perm=read_perm, write_perm=write_perm
uuid=uuid,
properties=properties,
read_perm=read_perm,
write_perm=write_perm,
max_length=buffer_size,
)

def bind(
Expand Down Expand Up @@ -104,6 +108,7 @@ def __init__(
properties=properties,
read_perm=Attribute.NO_ACCESS,
write_perm=write_perm,
max_length=buffer_size,
)

def bind(
Expand Down
6 changes: 4 additions & 2 deletions adafruit_ble/services/nordic.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ class UARTService(Service):
_server_tx = StreamOut(
uuid=VendorUUID("6E400003-B5A3-F393-E0A9-E50E24DCCA9E"),
timeout=1.0,
buffer_size=64,
# 512 is the largest negotiated MTU-3 value for all CircuitPython ports.
buffer_size=512,
)
_server_rx = StreamIn(
uuid=VendorUUID("6E400002-B5A3-F393-E0A9-E50E24DCCA9E"),
timeout=1.0,
buffer_size=64,
# 512 is the largest negotiated MTU-3 value for all CircuitPython ports.
buffer_size=512,
)

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

0 comments on commit 6afb85a

Please sign in to comment.