microdot: First working example. We observe wifi instabilities/detectability issues.
All checks were successful
All checks were successful
This commit is contained in:
@@ -1,18 +1,38 @@
|
|||||||
import rp2
|
import rp2
|
||||||
import network
|
import network
|
||||||
|
import ubinascii
|
||||||
from microdot import Microdot
|
from microdot import Microdot
|
||||||
|
|
||||||
rp2.country('DE')
|
rp2.country('DE')
|
||||||
|
|
||||||
wlan = network.WLAN(network.AP_IF)
|
wlan = network.WLAN(network.AP_IF)
|
||||||
wlan.config(ssid='TonberryPico', security=network.WLAN.SEC_OPEN)
|
wlan.config(ssid='TonberryPico', security=network.WLAN.SEC_OPEN)
|
||||||
wlan.ipconfig(addr4='10.0.0.1')
|
# Important: we cannot change the ip in station mode, otherwise dhcp won't work!
|
||||||
|
# wlan.ipconfig(addr4='10.0.0.1')
|
||||||
wlan.active(True) # loads the firmware
|
wlan.active(True) # loads the firmware
|
||||||
|
while wlan.active() is False:
|
||||||
|
pass
|
||||||
wlan.config(pm=network.WLAN.PM_NONE)
|
wlan.config(pm=network.WLAN.PM_NONE)
|
||||||
|
|
||||||
#app = Microdot()
|
mac = ubinascii.hexlify(network.WLAN().config('mac'), ':').decode()
|
||||||
#@app.route('/')
|
print(f" mac: {mac}")
|
||||||
#async def index(request):
|
print(f" channel: {wlan.config('channel')}")
|
||||||
# return "TonberryPico says 'Hello World!'"
|
print(f" essid: {wlan.config('essid')}")
|
||||||
#
|
print(f" txpower: {wlan.config('txpower')}")
|
||||||
#app.run()
|
print(f"ifconfig: {wlan.ifconfig()}")
|
||||||
|
|
||||||
|
app = Microdot()
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
async def index(request):
|
||||||
|
print("wohoo, a guest :)")
|
||||||
|
print(f" app: {request.app}")
|
||||||
|
print(f" client: {request.client_addr}")
|
||||||
|
print(f" method: {request.method}")
|
||||||
|
print(f" url: {request.url}")
|
||||||
|
print(f" headers: {request.headers}")
|
||||||
|
print(f" cookies: {request.cookies}")
|
||||||
|
return "TonberryPico says 'Hello World!'"
|
||||||
|
|
||||||
|
app.run(port=80)
|
||||||
|
|||||||
Reference in New Issue
Block a user