from machine import UART, Pin, Timer
from time import sleep, time
from math import floor

# The list of SSIDs
ssidlist = ["Hello world", "I like your smile", "You look good today", "Today is a happy day", "You are lovely", "The world loves you" ]

# Open the UART
uart = UART(1, baudrate=115200, tx=Pin(4), rx=Pin(5))
print(uart.read())

# Redet the WifFi360
uart.write('AT+RST\r\n')
sleep(1)
print(uart.read())

# Swap to SoftAP mode
uart.write('AT+CWMODE_CUR=2\r\n')
sleep(0.5)
print(uart.read())

# Function to change the SSID from ssidlist
def update_ssid(timerobj=None) :
    counter = ( time() // 10 )
    ssid = ssidlist[counter % len(ssidlist)];
    uart.write('AT+CWSAP_CUR="' + ssid+ '","12345678",1,3\r\n')
    sleep(0.5)
    print(uart.read())

# Start the first SSID
update_ssid()

# Change the SSID every 10 seconds
Timer(period=10000, callback=update_ssid)
