mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-24 16:47:32 +01: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:
parent
fe2a760891
commit
f91156cd3e
@ -1025,7 +1025,7 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
receivedLine += packetStr;
|
receivedLine += packetStr;
|
||||||
while (receivedLine.contains("\n")) {
|
while (receivedLine.contains("\n")) {
|
||||||
int p = receivedLine.indexOf("\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);
|
receivedLine = receivedLine.substring(p+1);
|
||||||
handleUartRxLine(line);
|
handleUartRxLine(line);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user