mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
fix: stop lpp zero tail
ref:
This commit is contained in:
@@ -25,6 +25,14 @@ class CayenneLppParser {
|
||||
|
||||
int fieldCount = 0;
|
||||
while (reader.hasRemaining) {
|
||||
if (fieldCount > 0 && _isZeroPaddedTail(data, reader.remainingBytesCount)) {
|
||||
debugPrint(
|
||||
' Detected zero-padded telemetry tail, stopping parse at position '
|
||||
'${data.length - reader.remainingBytesCount}',
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
fieldCount++;
|
||||
debugPrint(
|
||||
@@ -250,6 +258,14 @@ class CayenneLppParser {
|
||||
return ((voltage - 3.0) / 1.2) * 100.0;
|
||||
}
|
||||
|
||||
static bool _isZeroPaddedTail(Uint8List data, int remainingBytes) {
|
||||
final start = data.length - remainingBytes;
|
||||
for (int i = start; i < data.length; i++) {
|
||||
if (data[i] != 0) return false;
|
||||
}
|
||||
return remainingBytes > 0;
|
||||
}
|
||||
|
||||
/// Create Cayenne LPP data for GPS location
|
||||
/// Standard Cayenne LPP GPS format (type 0x88):
|
||||
/// - Latitude: 3 bytes, signed 24-bit, big-endian, × 10000
|
||||
|
||||
Reference in New Issue
Block a user