ble-reticulum/src
torlando-tech 88bb2fc3fa fix(ble): Restore identity handshake detection for peripheral connections
## Problem

After the driver refactor (commit d1d94e5), peripheral devices were dropping
the identity handshake sent by central devices. The logs showed:

```
[Warning] BLEInterface[BLE Interface] no identity for dev:B8:27:EB:A8:A7:22, cannot create fragmenter
[Warning] BLEInterface[BLE Interface] no identity for peer dev:B8:27:EB:A8:A7:22, dropping data
```

Root cause: When the central sends its 16-byte identity handshake, the
peripheral's `_data_received_callback` passed it to `_handle_ble_data`,
which immediately dropped it (chicken-and-egg: no identity = drop data,
but the dropped data IS the identity).

The handshake detection logic existed in commit babb237 but was lost
during the driver architecture refactor.

## Solution

Added `_handle_identity_handshake()` method that:

1. Detects identity handshakes (exactly 16 bytes, no existing identity)
2. Stores the central's identity in bidirectional mappings
3. Creates fragmenter/reassembler with negotiated MTU
4. Spawns peer interface for the central
5. Returns True to prevent normal data processing

Updated `_data_received_callback()` to check for handshakes before
passing data to normal reassembly logic.

## Benefits

-  Restores bidirectional communication for peripheral connections
-  Peripheral can learn central's identity without scanning
-  Clean separation of handshake vs. data processing
-  Proper error handling with informative logging

## Testing

Should resolve the asymmetric identity exchange seen in Pi1/Pi2 logs where
central successfully connected but peripheral couldn't create fragmenter.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-04 00:58:56 -05:00
..
RNS fix(ble): Restore identity handshake detection for peripheral connections 2025-11-04 00:58:56 -05:00