Commit 79da48c3176e71c90d71da1504e43ab8eb743a3f
1 parent
35756df0
fix:parse content length error
Showing
2 changed files
with
9 additions
and
1 deletions
HDFwear/Tools/BluetoothManager+Function.swift
... | ... | @@ -868,7 +868,7 @@ extension BluetoothManager { |
868 | 868 | } |
869 | 869 | |
870 | 870 | private func parseContentFromBytes(_ bytes: [UInt8]) -> [UInt8] { |
871 | - let contentLength = Int(bytes[9]) // 获取内容长度 | |
871 | + let contentLength = Int(UInt16(bytes[8]) << 8 | UInt16(bytes[9])) // 获取内容长度 | |
872 | 872 | guard bytes.count >= 10 + contentLength else { |
873 | 873 | return [] // 如果字节数组长度不足以包含内容,返回空数组 |
874 | 874 | } | ... | ... |