
SPS Script
SPS Echo example
In this tutorial, we're going to set up two dongles a using Python script to send data back and
forth between them.
In short:
1. One dongle will take on the Central role and the other will take on the Peripheral role.
2. Then they will connect to each other.
3. The Central dongle will then start off sending a message; "Echo".
4. 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.
For a quick setup, copy the following script and save it on your local directory. You can also get
the source code from our
. page.
1.
import serial
2.
import time
3.
4.
target_dongle_mac_address = "[
0
]
40
:
48
:FD:E5:2D:
05
" # Change this
to
the peripheral's mac address.
5.
your_com_port =
'COM14'
# Change this
to
the com port your dongle
is
connected
to
.
6.
7.
# Global
8.
connecting_to_dongle = True
9.
counter =
0
10.
msg = ""
11.
latest_msg = ""
12.
error_counter =
0
13.
14.
print("Connecting
to
dongle...")
15.
# Trying
to
connect
to
dongle
until
connected. Make sure the port
and
baudrate
is
the same
as
your
dongle.
16.
# You can check
in
the device manager
to
see what port
then
right-
click
and
choose properties
then
the Port Settings
17.
# tab
to
see the other settings
18.
while
connecting_to_dongle:
19.
try
:
20.
console = serial
.
Serial(
21.
port=your_com_port,
22.
baudrate=
57600
,
23.
parity="N",
24.
stopbits=
1
,
25.
bytesize=
8
,
26.
timeout=
0
27.
)
28.
if
console
.
is_open
.
__bool__():
29.
connecting_to_dongle = False
30.
except
:
31.
print("Dongle
not
connected. Please reconnect Dongle.")
32.
time
.
sleep(
5
)
33.
34.
# This script will send data from one dongle
to
another which
in
turn will echo it back
and
forth
between the dongles.
35.
print("\n\nConnected
to
Dongle.\n")
Содержание BleuIO
Страница 1: ......
Страница 4: ...How to use Windows Step 1 Figure 1 Connect the dongle to your computer ...
Страница 7: ...Linux Raspberry Pi Step 1 Figure 1 Connect the dongle to your Linux RaspberryPi ...
Страница 14: ...Issues Showing advertising and or response data either when setting or querying has been temporarily disabled ...
Страница 32: ...Youtube Tutorial Follow the Youtube tutorial https www youtube com watch v CixqMR3leGs ...