35
35
#include < lib/support/BufferReader.h>
36
36
#include < lib/support/CodeUtils.h>
37
37
#include < lib/support/SafeInt.h>
38
+ #include < lib/support/Span.h>
38
39
#include < lib/support/logging/CHIPLogging.h>
39
40
#include < system/SystemPacketBuffer.h>
40
41
45
46
46
47
#ifdef CHIP_BTP_PROTOCOL_ENGINE_DEBUG_LOGGING_ENABLED
47
48
#define ChipLogDebugBtpEngine (MOD, MSG, ...) ChipLogError(MOD, MSG, ##__VA_ARGS__)
49
+ #define ChipLogDebugBufferBtpEngine (MOD, BUF ) ChipLogByteSpan(MOD, ByteSpan((BUF)->Start (), (BUF)->DataLength()))
48
50
#else
49
51
#define ChipLogDebugBtpEngine (MOD, MSG, ...)
52
+ #define ChipLogDebugBufferBtpEngine (MOD, BUF )
50
53
#endif
51
54
52
55
namespace chip {
@@ -63,18 +66,6 @@ static inline bool DidReceiveData(BitFlags<BtpEngine::HeaderFlags> rx_flags)
63
66
BtpEngine::HeaderFlags::kEndMessage );
64
67
}
65
68
66
- static void PrintBufDebug (const System::PacketBufferHandle & buf)
67
- {
68
- #ifdef CHIP_BTP_PROTOCOL_ENGINE_DEBUG_LOGGING_ENABLED
69
- uint8_t * b = buf->Start ();
70
-
71
- for (int i = 0 ; i < buf->DataLength (); i++)
72
- {
73
- ChipLogError (Ble, " \t %02x" , b[i]);
74
- }
75
- #endif
76
- }
77
-
78
69
const uint16_t BtpEngine::sDefaultFragmentSize = 20 ; // 23-byte minimum ATT_MTU - 3 bytes for ATT operation header
79
70
const uint16_t BtpEngine::sMaxFragmentSize = 244 ; // Maximum size of BTP segment
80
71
@@ -289,7 +280,7 @@ CHIP_ERROR BtpEngine::HandleCharacteristicReceived(System::PacketBufferHandle &&
289
280
data->ConsumeHead (static_cast <uint16_t >(reader.OctetsRead ()));
290
281
291
282
ChipLogDebugBtpEngine (Ble, " >>> BTP reassembler received data:" );
292
- PrintBufDebug ( data);
283
+ ChipLogDebugBufferBtpEngine (Ble, data);
293
284
}
294
285
295
286
if (mRxState == kState_Idle )
@@ -434,7 +425,7 @@ bool BtpEngine::HandleCharacteristicSend(System::PacketBufferHandle data, bool s
434
425
mTxLength = static_cast <uint16_t >(mTxBuf ->DataLength ());
435
426
436
427
ChipLogDebugBtpEngine (Ble, " >>> CHIPoBle preparing to send whole message:" );
437
- PrintBufDebug ( mTxBuf );
428
+ ChipLogDebugBufferBtpEngine (Ble, mTxBuf );
438
429
439
430
// Determine fragment header size.
440
431
uint8_t header_size =
@@ -485,7 +476,7 @@ bool BtpEngine::HandleCharacteristicSend(System::PacketBufferHandle data, bool s
485
476
486
477
characteristic[0 ] = headerFlags.Raw ();
487
478
ChipLogDebugBtpEngine (Ble, " >>> CHIPoBle preparing to send first fragment:" );
488
- PrintBufDebug ( mTxBuf );
479
+ ChipLogDebugBufferBtpEngine (Ble, mTxBuf );
489
480
}
490
481
else if (mTxState == kState_InProgress )
491
482
{
@@ -531,7 +522,7 @@ bool BtpEngine::HandleCharacteristicSend(System::PacketBufferHandle data, bool s
531
522
532
523
characteristic[0 ] = headerFlags.Raw ();
533
524
ChipLogDebugBtpEngine (Ble, " >>> CHIPoBle preparing to send additional fragment:" );
534
- PrintBufDebug ( mTxBuf );
525
+ ChipLogDebugBufferBtpEngine (Ble, mTxBuf );
535
526
}
536
527
else
537
528
{
0 commit comments