@@ -410,10 +410,15 @@ class BluetoothConnectionManager(
410410 }
411411
412412 if (characteristic.uuid == CHARACTERISTIC_UUID ) {
413+ Log .d(TAG , " Server: Received packet from ${device.address} , size: ${value.size} bytes" )
413414 val packet = BitchatPacket .fromBinaryData(value)
414415 if (packet != null ) {
415416 val peerID = String (packet.senderID).replace(" \u0000 " , " " )
417+ Log .d(TAG , " Server: Parsed packet type ${packet.type} from $peerID " )
416418 delegate?.onPacketReceived(packet, peerID, device)
419+ } else {
420+ Log .w(TAG , " Server: Failed to parse packet from ${device.address} , size: ${value.size} bytes" )
421+ Log .w(TAG , " Server: Packet data: ${value.joinToString(" " ) { " %02x" .format(it) }} " )
417422 }
418423
419424 if (responseNeeded) {
@@ -835,10 +840,15 @@ class BluetoothConnectionManager(
835840
836841 override fun onCharacteristicChanged (gatt : BluetoothGatt , characteristic : BluetoothGattCharacteristic ) {
837842 val value = characteristic.value
843+ Log .d(TAG , " Client: Received packet from ${gatt.device.address} , size: ${value.size} bytes" )
838844 val packet = BitchatPacket .fromBinaryData(value)
839845 if (packet != null ) {
840846 val peerID = String (packet.senderID).replace(" \u0000 " , " " )
847+ Log .d(TAG , " Client: Parsed packet type ${packet.type} from $peerID " )
841848 delegate?.onPacketReceived(packet, peerID, gatt.device)
849+ } else {
850+ Log .w(TAG , " Client: Failed to parse packet from ${gatt.device.address} , size: ${value.size} bytes" )
851+ Log .w(TAG , " Client: Packet data: ${value.joinToString(" " ) { " %02x" .format(it) }} " )
842852 }
843853 }
844854 }
0 commit comments