This project will demonstrate how two Bluetooth dongles can be paired together and share data between them. We already have a Python script that sends data back and forth between dongles.
- One dongle will take on the Central role and the other will take on the Peripheral role.
- Then they will connect to each other.
- The Central dongle will then start off sending a message; "Echo".
- The Peripheral dongle will then receive the message and send it back to the Central dongle which in turn will receive it and send it back and so forth until the script is stopped.
Step 2: Change the COM-port
Change the COM-port in the script on both computers to match the ones your dongles is actually connected to.You can find com port details on device manager.
For the one that will be set up as the Central dongle you will also need to change the target_dongle_mac_address variable in the script to the MAC address of your Peripheral dongle. There are several ways of getting MAC address of a target dongle. Here we will obtain it from device manager.
Select your device. go to properties > Details. Select Device Instance Path. And the last value is the dongle MAC address. 40:48:XX:XX:XX:XX
Step 3: Send, Receive Data
Open up the command prompt, on both computers, in the directory where the script is located. Start the script by typing python sps_example.py and press Enter.
You should now be prompted to enter 1 or 2 depending on what role the dongle should have. Set one as Peripheral and the other as Central. It is advisable to setup the Peripheral first as the Central will need someone to connect to.
You should now see in the terminal how the dongles send and receive data to and from each other. The script will run until you stop it.
And that is an example of how we can send data between two dongles. If you want to stop the script, you can simply press control C.
Full source also available on GitHub.
Follow the project video for better understanding.