From 1350a5522dc3169511bef8c7228808718ca7a6f9 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Tue, 15 Apr 2025 15:06:43 +0100 Subject: [PATCH] Increase Packet timeout from 1 to 2 sec (increase reliability over slow Bluetooth LE connections) --- ChangeLog | 1 + README_Protocol.md | 5 +++++ src/jsinteractive.c | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 249625cf3..26630b74a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -29,6 +29,7 @@ Bangle.js: setUI/etc now don't draw a 'back' icon if there is no widget bar (or it's hidden) ESP32: Remove FlashFS, adjust partitions to increase available Storage from 256kB to 896kB Storage: Don't attempt to compact if it's obvious that we don't have space for the file even when compacted + Increase Packet timeout from 1 to 2 sec (increase reliability over slow Bluetooth LE connections) 2v25 : ESP32C3: Get analogRead working correctly Graphics: Adjust image alignment when rotating images to avoid cropping (fix #2535) diff --git a/README_Protocol.md b/README_Protocol.md index c3766c81f..825625d2d 100644 --- a/README_Protocol.md +++ b/README_Protocol.md @@ -56,6 +56,11 @@ Following transmission of a packet (or after timeout of 1 second), there will be | `ACK` | 6 | Acknowledged successful receipt. | | `NACK` | 21 | Negative acknowledgement, unsuccessful. | +### Timeouts + +* If a single packet takes more than 2 sec to transmit (1 sec on 2v25) Espruino will send `NAK` and will return to normal REPL mode. +* If there's more than a 10 sec gap between DATA transfers for a file, Espruino will automatically close the transfer and the file. Subsequent DATA packets will be `NAK`ed as no file is open. + ### Example As an example, to create a file named `hello.txt` with the content `Hello World`, the packet is constructed as follows: diff --git a/src/jsinteractive.c b/src/jsinteractive.c index 5d5558e10..8161df2e8 100644 --- a/src/jsinteractive.c +++ b/src/jsinteractive.c @@ -1644,7 +1644,7 @@ static void jsiPacketStart() { inputState = IPS_PACKET_TRANSFER_BYTE0; jsiInputLineCursorMoved(); // unlock iterator jsvObjectSetChildAndUnLock(execInfo.hiddenRoot, "PK_IL", inputLine); // back up old inputline - jsvObjectSetChildAndUnLock(execInfo.hiddenRoot, "PK_TIMEOUT", jsiSetTimeout(jsiPacketTimeoutHandler, 1000)); + jsvObjectSetChildAndUnLock(execInfo.hiddenRoot, "PK_TIMEOUT", jsiSetTimeout(jsiPacketTimeoutHandler, 2000)); inputLine = jsvNewFromEmptyString(); }