#File Set_OC06_name.py
# Date 9/4/2021
# just getting communication....
# not sure what b'text\r\n' means but it works


"""   Notes from http://docs.micropython.org/en/v1.9.3/pyboard/library/pyb.UART.html
uart.read(10)       # read 10 characters, returns a bytes object
uart.read()         # read all available characters
uart.readline()     # read a line
uart.readinto(buf)  # read and store into the given buffer
uart.write('abc')   # write the 3 characters
uart.readchar()     # read 1 character and returns it as an integer
uart.writechar(42)  # write 1 character
uart.any()          # returns the number of characters waiting

"""


from machine import UART
import time, utime

# should be run before the OC06 has paired with anything

uart = UART(0, 9600)                         # init with given baudrate 0 = TX/RX pins

#print("Setting Name ...")

print("Sending AT ...")
uart.write(b'AT+NAMEUKM3')


time.sleep(0.01)
while True:
    reply = uart.read(1)
    print("Received = ",reply)
    
