fix: critical bug in PiezoPacketCollector processEndPacket
CRITICAL: In multi-channel mode, "ree:" packets between channels were silently dropped instead of saving the current channel data. This caused channel data loss when channels are separated by "ree:". Fixed: Added missing isMultiChannel + ree: branch that calls saveCurrentChannel() — matching Swift behavior exactly. Found via line-by-line Swift vs Kotlin verification. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -130,12 +130,19 @@ class PiezoPacketCollector {
|
|||||||
|
|
||||||
private fun processEndPacket(prefix: String, bytes: ByteArray) {
|
private fun processEndPacket(prefix: String, bytes: ByteArray) {
|
||||||
if (isMultiChannel && prefix == "raa:") {
|
if (isMultiChannel && prefix == "raa:") {
|
||||||
|
// Final completion marker — save last channel and finish
|
||||||
if (hasFirstPacket && rawData.isNotEmpty()) saveCurrentChannel()
|
if (hasFirstPacket && rawData.isNotEmpty()) saveCurrentChannel()
|
||||||
isComplete = true
|
isComplete = true
|
||||||
val validChannels = channelResults.filterNotNull()
|
val validChannels = channelResults.filterNotNull()
|
||||||
onLog?.invoke("raa: multi-channel complete — ${validChannels.size} channels")
|
onLog?.invoke("raa: multi-channel complete — ${validChannels.size} channels")
|
||||||
onMultiChannelComplete?.invoke(validChannels)
|
onMultiChannelComplete?.invoke(validChannels)
|
||||||
} else if (!isMultiChannel) {
|
} else if (isMultiChannel) {
|
||||||
|
// ree: in multi-channel = channel separator, save and continue
|
||||||
|
if (hasFirstPacket && rawData.isNotEmpty()) {
|
||||||
|
saveCurrentChannel()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Single-channel complete (ree:)
|
||||||
finishSingleChannel()
|
finishSingleChannel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user