mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 20:45:19 +00:00
Log incomplete BLE frames for debugging
This commit is contained in:
@@ -65,12 +65,14 @@ struct NotificationStreamAssembler {
|
|||||||
if hasSignature { frameLength += BinaryProtocol.signatureSize }
|
if hasSignature { frameLength += BinaryProtocol.signatureSize }
|
||||||
|
|
||||||
guard frameLength > 0, frameLength <= maxFrameLength else {
|
guard frameLength > 0, frameLength <= maxFrameLength else {
|
||||||
|
SecureLogger.error("❌ Notification frame length \(frameLength) invalid (cap=\(maxFrameLength)); resetting stream", category: .session)
|
||||||
buffer.removeAll()
|
buffer.removeAll()
|
||||||
reset = true
|
reset = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if buffer.count < frameLength {
|
if buffer.count < frameLength {
|
||||||
|
SecureLogger.warning("⚠️ Incomplete BLE frame: have \(buffer.count)B need \(frameLength)B; scanning for next header", category: .session)
|
||||||
if let nextStart = buffer.dropFirst().firstIndex(where: { $0 == 1 || $0 == 2 }) {
|
if let nextStart = buffer.dropFirst().firstIndex(where: { $0 == 1 || $0 == 2 }) {
|
||||||
let dropCount = buffer.distance(from: buffer.startIndex, to: nextStart)
|
let dropCount = buffer.distance(from: buffer.startIndex, to: nextStart)
|
||||||
if dropCount > 0 {
|
if dropCount > 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user