ch-9 clean

This commit is contained in:
Danny Staple
2022-03-20 22:30:03 +00:00
parent 530f67856d
commit c632222255
13 changed files with 147 additions and 143 deletions
+6 -7
View File
@@ -5,18 +5,17 @@ from adafruit_wsgi.wsgi_app import WSGIApp
app = WSGIApp()
@app.route("/")
def index(request):
with open("hello.html") as fd:
hello_html = fd.read()
return 200, [('Content-Type',"text/html")], hello_html
with open("hello.html") as fd:
hello_html = fd.read()
return 200, [("Content-Type", "text/html")], hello_html
print("Setting up wifi.")
wifi, esp = robot_wifi.connect_to_wifi()
server = adafruit_esp32spi_wsgiserver.WSGIServer(
80,
application=app
)
server = adafruit_esp32spi_wsgiserver.WSGIServer(80, application=app)
adafruit_esp32spi_wsgiserver.set_interface(esp)
print("Starting server")
+4 -5
View File
@@ -5,16 +5,15 @@ from adafruit_wsgi.wsgi_app import WSGIApp
app = WSGIApp()
@app.route("/")
def index(request):
return 200, [], "Hello world!"
return 200, [], "Hello world!"
print("Setting up wifi.")
wifi, esp = robot_wifi.connect_to_wifi()
server = adafruit_esp32spi_wsgiserver.WSGIServer(
80,
application=app
)
server = adafruit_esp32spi_wsgiserver.WSGIServer(80, application=app)
adafruit_esp32spi_wsgiserver.set_interface(esp)
print("Starting server")
+12 -12
View File
@@ -5,21 +5,21 @@ from adafruit_esp32spi import adafruit_esp32spi
from adafruit_esp32spi import adafruit_esp32spi_wifimanager
try:
from secrets import secrets
from secrets import secrets
except ImportError:
print("WiFi secrets are kept in secrets.py, please add them there!")
raise
print("WiFi secrets are kept in secrets.py, please add them there!")
raise
def connect_to_wifi():
esp32_cs = DigitalInOut(board.GP10)
esp32_ready = DigitalInOut(board.GP9)
esp32_reset = DigitalInOut(board.GP8)
esp32_cs = DigitalInOut(board.GP10)
esp32_ready = DigitalInOut(board.GP9)
esp32_reset = DigitalInOut(board.GP8)
spi = busio.SPI(board.GP14, MOSI=board.GP11, MISO=board.GP12)
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
esp.reset()
wifi = adafruit_esp32spi_wifimanager.ESPSPI_WiFiManager(esp, secrets)
wifi.connect()
spi = busio.SPI(board.GP14, MOSI=board.GP11, MISO=board.GP12)
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
esp.reset()
wifi = adafruit_esp32spi_wifimanager.ESPSPI_WiFiManager(esp, secrets)
wifi.connect()
return wifi, esp
return wifi, esp