def main(): esp_wifi.set_op_mode(esp_wifi.OP_MODE_STATION) esp_wifi.station_init(SSID, PASSWORD) esp_wifi.station_connect() while esp_wifi.station_get_status() != 'got-ip': print('Waiting for WiFi connection...') time.sleep(2) # The certificate must be in a file. with open('server.crt', 'w') as f: f.write(CERTIFICATE) # The key must be in a file. with open('server.key', 'w') as f: f.write(KEY) context = ssl.SSLContext(ssl.PROTOCOL_TLS) context.load_cert_chain("server.crt", keyfile="server.key") routes = [('/index.html', on_index)] http_server = HttpServer(IP, PORT, routes, on_no_route) http_server.wrap_ssl(context) http_server.start() while True: print(os.system('kernel/thrd/list')) time.sleep(5)
def main(): esp_wifi.set_op_mode(esp_wifi.OP_MODE_STATION) esp_wifi.station_init(SSID, PASSWORD) esp_wifi.station_connect() routes = [("/index.html", on_request_index), ("/websocket_echo.html", on_request_websocket_echo)] http_server = HttpServer(IP, PORT, routes, on_no_route) http_server.start() kernel.thrd_suspend()
def main(): esp_wifi.set_op_mode(esp_wifi.OP_MODE_STATION) esp_wifi.station_init(SSID, PASSWORD) esp_wifi.station_connect() while esp_wifi.station_get_status() != 'got-ip': print('Waiting for WiFi connection...') time.sleep(2) routes = [('/index.html', on_index), ('/websocket/echo', on_websocket_echo)] http_server = HttpServer(IP, PORT, routes, on_no_route) http_server.start() while True: print(os.system('kernel/thrd/list')) time.sleep(5)
# SOFTWARE. # # This file is part of the Pumbaa project. # import time import socket from drivers import esp_wifi SSID = 'Qvist2' PASSWORD = '******' IP = '192.168.0.7' PORT = 9000 esp_wifi.set_op_mode(esp_wifi.OP_MODE_STATION) esp_wifi.station_init(SSID, PASSWORD) esp_wifi.station_connect() while esp_wifi.station_get_status() != 'got-ip': print('Waiting for WiFi connection...') time.sleep(2) listener = socket.socket() listener.bind((IP, PORT)) listener.listen(1) while True: print('Listening for a client to connect.') client, address = listener.accept() print('Accepted client with address', address)