I know the on_connection function is a placeholder and should be overridden like in CLIConnectionSniffer anyway, but I think the interface should be the same. So I would add the timeout argument here:
I assume that this behavior also occurs with other from_bytes implementations in the same module like ExchangeMtuResponse, ExchangeMtuRequest and ErrorResponse, but I am not 100% sure. Maybe some can confirm that?
Hi,
first of all thank you for this great tool! I used it in one of my projects and it helps me to find a bug in a BLE smart lock.
While using your tool as a library and wrapping it with my code, I found two small bugs:
The first can be validated by looking at the implementation of
ConnectionSniffer
. In the methodon_packet_received
the methodon_connection
is called with a given timeout (packet.timeout
): https://github.com/virtualabs/btlejack/blob/c487859888450f6a33f618180bac5358f104e367/btlejack/supervisors.py#L501-L511I know the
on_connection
function is a placeholder and should be overridden like inCLIConnectionSniffer
anyway, but I think the interface should be the same. So I would add the timeout argument here:https://github.com/virtualabs/btlejack/blob/c487859888450f6a33f618180bac5358f104e367/btlejack/supervisors.py#L528-L530
The second is an error during unpacking. Unpacking with
unpack('<H', raw[1:])[0]
of more than 2 bytes leads tostruct.error: unpack requires a buffer of 2 bytes
: https://github.com/virtualabs/btlejack/blob/c487859888450f6a33f618180bac5358f104e367/btlejack/dissect/att.py#L205-L210For the
WriteCommand
it was sliced correctly: https://github.com/virtualabs/btlejack/blob/c487859888450f6a33f618180bac5358f104e367/btlejack/dissect/att.py#L221-L226I assume that this behavior also occurs with other
from_bytes
implementations in the same module likeExchangeMtuResponse
,ExchangeMtuRequest
andErrorResponse
, but I am not 100% sure. Maybe some can confirm that?