Quantcast
Viewing all articles
Browse latest Browse all 5127

Python • PicoW - Cell Phone/Windows prompt for PassWord after selecting SSID

I am trying to figure out how I can have a cell phone and or the windows 11 prompt me for my Pico AP's "Password" when I select the SSID and not either load it automatically with in the code or enter the password from within the webpage running on the Pico. Right now, I get the SSID on both my phone SSID list and the Windows SSID's available list and connect to the Pico W without entering the password, that has to change.

When I click on the SSID "BackYardGarden" it gives me access to the Pico. I need to have the phone and Windows prompt me for the password "WeedPuller", both are only used for developing this code. Here is the current working code, it probably is only a line or two but I am not that great at figuring these things out anymore and looking at samples just confuses the heck out of me. I have tried many sample script samples, but none do the trick.

The Pico W is a stand alone AP/Webserver and will have various sensors added to it.

Thanks in advance for any assistance.

Code:

# Welcome to Brian's Garden - workingimport networkimport socketssid = 'BackYardGarden'password = 'WeedPuller'ap = network.WLAN(network.AP_IF)ap.config(essid=ssid, password=password)ap.active(True)welcome_page = """\<!DOCTYPE html><html><head><title>Welcome</title></head><body>  <h2>Welcome to Brian's Garden!</h2></body></html>"""def serve_welcome_page(conn):    conn.send('HTTP/1.1 200 OK\n')    conn.send('Content-Type: text/html\n')    conn.send('Connection: close\n\n')    conn.sendall(welcome_page)def handle_connections():    addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]    s = socket.socket()    s.bind(addr)    s.listen(1)    print('Listening on', addr)    while True:        conn, addr = s.accept()        print('Got a connection from %s' % str(addr))        request = conn.recv(1024)        request = str(request)        # Always serve the welcome page        serve_welcome_page(conn)        conn.close()# Run the serverhandle_connections()

Statistics: Posted by ElectronicsNut — Wed May 01, 2024 11:59 pm



Viewing all articles
Browse latest Browse all 5127

Trending Articles