src.bluetooth_sig.gatt.characteristics.utils.parse_trace

Parse trace utility for debugging characteristic parsing.

Classes

Name

Description

ParseTrace

Manages parse traces with built-in enable/disable logic.

Module Contents

class src.bluetooth_sig.gatt.characteristics.utils.parse_trace.ParseTrace(enabled: bool = True)

Manages parse traces with built-in enable/disable logic.

This class encapsulates the trace collection logic to avoid manual if checks throughout the parsing code, improving performance when tracing is disabled.

Example

trace = ParseTrace(enabled=True) trace.append(“Starting parse”) trace.append(“Validation complete”) result = trace.get_trace() # Returns list of strings

append(message: str) None

Append a message to the trace if tracing is enabled.

Parameters:

message – Trace message to append

get_trace() list[str]

Get the collected trace messages.

Returns:

List of trace messages if enabled, empty list otherwise

property enabled: bool

Check if tracing is enabled.

Returns:

True if tracing is enabled, False otherwise