This project provides a Python script to clone the services, characteristics, and advertising data of a BLE device. It then generates an Arduino sketch that, when flashed to an ESP32, emulates the original BLE device using the NimBLE library.
Before running the script, ensure you have the bleak
library installed:
pip install bleak
To run the script, execute the following command in your terminal:
python ble.py
-
Scan for BLE Devices:
- The script will scan for BLE devices for 10 seconds and display a list of found devices.
-
Select a Device:
- Choose the device you want to clone by entering its index from the displayed list.
-
Generate Arduino Sketch:
- After selecting the device, an Arduino sketch will be created with the same services, characteristics, and advertising data as the original device.
-
Open Arduino IDE:
- Open the generated Arduino sketch in the Arduino IDE.
-
Connect ESP32:
- Connect your ESP32 to your computer.
-
Select Board and Port:
- In the Arduino IDE, select the appropriate board (e.g., ESP32 Dev Module) and port.
-
Upload Sketch:
- Upload the sketch to your ESP32.
This will create a BLE device on the ESP32 with similar services, characteristics, and advertising data as the cloned device.
After running the script and selecting a device, you will see the cloned services, characteristics, and advertising data printed in the console. An Arduino sketch file will be generated that you can use with the ESP32.