Page 1 of 1

Detect a Bluetooth connection attempt by a previously paired device and cancel it before it occurs

Posted: Tue May 06, 2025 8:36 am
by diego09310
Hi,

I'm working on a device that detects when a previously paired controller to another device (like a raspberry pi or jetson nano) is turned on, so I can turn the other device on (similar to how video games consoles turn on with the controller).

I thought about two ways to detect this:
- First I thought about having a list of paired devices and detect all devices around, but I'm not sure how to capture packets who aren't destined to my MAC or aren't pairing requests.
- Then I found you can spoof the MAC and the device will automatically connect to the ESP32 (by spoofing the other device's MAC, which is the one the controller is paired to), but I can't find how to prevent the connection to happen. I tried turning the bt off on `ESP_BT_GAP_ACL_CONN_CMPL_STAT_EVT`, but at that point the controller has already connected and will turn off.

I think I need to use the hci layer, but most of espressif examples for hci are for ble and I need this to work both with bt classic and BLE. Any hints?

Thanks in advance