1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-06 05:16:41 +02:00

Bangle.js - fix issue where a newline right at the beginning of a received string could cause "String index out of range: -1" errors for all subsequent received data

This commit is contained in:
Gordon Williams 2024-03-13 09:52:03 +00:00
parent fe2a760891
commit f91156cd3e

View File

@ -1025,7 +1025,7 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
receivedLine += packetStr;
while (receivedLine.contains("\n")) {
int p = receivedLine.indexOf("\n");
String line = receivedLine.substring(0,p-1);
String line = receivedLine.substring(0,(p>0) ? (p-1) : 0);
receivedLine = receivedLine.substring(p+1);
handleUartRxLine(line);
}