forked from yudi_xiao/expo-ble-app-demo
expo-ble模块测试demo 联调BLE模块 take 12 减少无用的log
This commit is contained in:
@@ -5,7 +5,7 @@ export class ProtocolManager {
|
||||
|
||||
static calculateChecksum(frameData: Uint8Array): number {
|
||||
let sum = 0;
|
||||
console.debug(`[ProtocolManager] Calculating checksum for frame count: ${frameData.length}`);
|
||||
// console.debug(`[ProtocolManager] Calculating checksum for frame count: ${frameData.length}`);
|
||||
// Checksum is calculated on all bytes except the last one (which is the checksum itself)
|
||||
// Example: 0xA0 03 00 01 01 5B
|
||||
// 0xA0 + 0x03 + 0x00 + 0x01 + 0x01 = 0xA5
|
||||
@@ -14,7 +14,7 @@ export class ProtocolManager {
|
||||
sum += frameData[i];
|
||||
}
|
||||
const checksum = (~sum + 1) & 0xff
|
||||
console.debug(`[ProtocolManager] Checksum calculated: 0 - ${sum} = ${checksum.toString(16).padStart(2, '0')}`);
|
||||
// console.debug(`[ProtocolManager] Checksum calculated: 0 - ${sum} = ${checksum.toString(16).padStart(2, '0')}`);
|
||||
return checksum;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ export class ProtocolManager {
|
||||
buffer[offset++] = (data.length >> 8) & 0xff;
|
||||
buffer[offset++] = data.length & 0xff;
|
||||
const hexHeader = Array.from(buffer.slice(0, offset)).map(b => b.toString(16).padStart(2, '0')).join(' ');
|
||||
console.debug(`chunk length = ${data.length}, buffer 8 header = ${hexHeader}`)
|
||||
// console.debug(`chunk length = ${data.length}, buffer 8 header = ${hexHeader}`)
|
||||
|
||||
// data
|
||||
buffer.set(data, offset);
|
||||
@@ -104,8 +104,9 @@ export class ProtocolManager {
|
||||
// dataLen
|
||||
buffer[offset++] = (chunk.length >> 8) & 0xff;
|
||||
buffer[offset++] = chunk.length & 0xff;
|
||||
const hexHeader = Array.from(buffer.slice(0, offset)).map(b => b.toString(16).padStart(2, '0')).join(' ');
|
||||
console.debug(`chunk length = ${chunk.length}, buffer 8 header = ${hexHeader}`)
|
||||
// const hexHeader = Array.from(buffer.slice(0, offset)).map(b => b.toString(16).padStart(2, '0')).join(' ');
|
||||
// console.debug(`chunk length = ${chunk.length}, buffer 8 header = ${hexHeader}`)
|
||||
|
||||
// data
|
||||
buffer.set(chunk, offset);
|
||||
offset += chunk.length;
|
||||
|
||||
Reference in New Issue
Block a user