Skip to content

Commit 0f38679

Browse files
committed
Lower MAX_PAYLOAD_LENGTH to 1440 and move it to const.py
1 parent 6e90296 commit 0f38679

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

tinytuya/core/const.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
TCPTIMEOUT = 0.4 # Seconds to wait for socket open for scanning
1313
DEFAULT_NETWORK = '192.168.0.0/24'
1414

15+
# Heuristic ceiling used to reject corrupt/desynced streams. Most devices only
16+
# have ~256 KiB of RAM and need 2x-3x the payload size for buffers, plus packets
17+
# over ~1440 bytes tend to fragment, so keep the default conservative. Override
18+
# at runtime if a particular device needs larger frames.
19+
MAX_PAYLOAD_LENGTH = 1440
20+
1521
# Configuration Files
1622
CONFIGFILE = 'tinytuya.json'
1723
DEVICEFILE = 'devices.json'

tinytuya/core/message_helper.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@
1010

1111
from .crypto_helper import AESCipher
1212
from .exceptions import DecodeError
13+
from .const import MAX_PAYLOAD_LENGTH
1314
from . import header as H
1415

1516
log = logging.getLogger(__name__)
1617

1718

18-
# Heuristic ceiling to reject corrupt/desynced streams. Large IR learn frames
19-
# (e.g. air-conditioner codes) exceed 1 KB, so cap generously rather than at 1 KB.
20-
MAX_PAYLOAD_LENGTH = 65535
21-
2219
# Tuya Packet Format
2320
TuyaHeader = namedtuple('TuyaHeader', 'prefix seqno cmd length total_length')
2421
MessagePayload = namedtuple("MessagePayload", "cmd payload")

0 commit comments

Comments
 (0)