ble_uart_echo_test.py
1 """ 2 Used with ble_uart_echo_client.py. Receives characters from the UARTService and transmits them back. 3 """ 4 5 from adafruit_ble import BLERadio 6 from adafruit_ble.advertising.standard import ProvideServicesAdvertisement 7 from adafruit_ble.services.nordic import UARTService 8 9 ble = BLERadio() 10 uart = UARTService() 11 advertisement = ProvideServicesAdvertisement(uart) 12 13 while True: 14 ble.start_advertising(advertisement) 15 while not ble.connected: 16 pass 17 while ble.connected: 18 # Returns b'' if nothing was read. 19 one_byte = uart.read(1) 20 if one_byte: 21 print(one_byte) 22 uart.write(one_byte)