diff --git a/examples/ble_uart_printmessage_test b/examples/ble_uart_printmessage_test new file mode 100644 index 0000000..2f79365 --- /dev/null +++ b/examples/ble_uart_printmessage_test @@ -0,0 +1,26 @@ +import board +from adafruit_ble.uart import UARTServer + +# Adapted from "Getting Started with CircuitPython and Bluetooth Low Energy" by Kattni Rembor +# from https://learn.adafruit.com/circuitpython-nrf52840/overview + +uart_server = UARTServer() + + +while True: + uart_server.start_advertising() + while not uart_server.connected: + pass + + # Now we're connected + + while uart_server.connected: + if uart_server.in_waiting: + uartread = str(uart_server.readline()) + # Remove the start indicator and the ending return /n + message = uartread[2:-3] + print(message) + + + # If we got here, we lost the connection. Go up to the top and start + # advertising again and waiting for a connection.