Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions examples/ble_uart_echo_test.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
from adafruit_ble.uart import UARTServer

uart = UARTServer()
uart.start_advertising()

# Wait for a connection
while not uart.connected:
pass

# When the client disconnects, the program will exit.
while uart.connected:
# Returns b'' if nothing was read.
one_byte = uart.read(1)
if one_byte:
uart.write(one_byte)

while True:
uart.start_advertising()

# Wait for a connection
while not uart.connected:
pass

while uart.connected:
# Returns b'' if nothing was read.
one_byte = uart.read(1)
if one_byte:
uart.write(one_byte)

# When disconnected, arrive here. Go back to the top
# and start advertising again.