Increase Packet timeout from 1 to 2 sec (increase reliability over slow Bluetooth LE connections)

This commit is contained in:
Gordon Williams 2025-04-15 15:06:43 +01:00
parent 909f8696ab
commit 1350a5522d
3 changed files with 7 additions and 1 deletions

View File

@ -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)

View File

@ -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:

View File

@ -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();
}