from machine import Pin
import bluetooth
from BLE import BLEUART
LED = Pin(2, Pin.OUT)
#LED.on()
name = 'ESP'
ble = bluetooth.BLE()
uart = BLEUART(ble, name)
def on_rx():
rx_buffer = uart.read().decode().strip()
uart.write('ESP32 says: ' + str(rx_buffer) + '\n')
if rx_buffer == '0':
LED.on()
if rx_buffer == 'F':
LED.off()
uart.irq(handler=on_rx)