Upload files to ''
This commit is contained in:
parent
34be3f78c0
commit
504a07b580
|
@ -0,0 +1,45 @@
|
|||
# This file is executed on every boot (including wake-boot from deepsleep)
|
||||
#import esp
|
||||
#esp.osdebug(None)
|
||||
|
||||
import network
|
||||
from network import WLAN as wlan, STA_IF as staif, AP_IF as apif
|
||||
import time
|
||||
|
||||
time.sleep_ms(100)
|
||||
#make sure AP mode is off and station mode is on
|
||||
if wlan(apif).active() == True:
|
||||
wlan(apif).active(False)
|
||||
if wlan(staif).active() != True:
|
||||
wlan(staif).active(True)
|
||||
|
||||
#we don't want to go through all this crap if stored network details are available
|
||||
#this is inside an if statement because this file gets executed after deepsleep
|
||||
# so we may still be connected(?)
|
||||
if wlan(staif).isconnected() != True:
|
||||
nets=wlan(staif).scan()
|
||||
found_net=False
|
||||
for net in nets:
|
||||
if net[0] == b'WiFiNetworkName':
|
||||
wlan(staif).connect("WiFiNetworkName","WiFiNetworkPSK")
|
||||
found_net=True
|
||||
break
|
||||
elif net[0] == b'WiFiNetworkName':
|
||||
wlan(staif).connect("WiFiNetworkName","WiFiNetworkPSK")
|
||||
found_net=True
|
||||
break
|
||||
if found_net == False:
|
||||
print("couldn't connect to wifi, nets found: %s" % nets)
|
||||
print("to fix temporarily, run: from network import STA_IF,WLAN as wlan;wlan(STA_IF).connect('yournet','yourpass'), followed shortly after by wlan(STA_IF).ifconfig()")
|
||||
#exit
|
||||
else:
|
||||
#Loop until wifi is connected and passes DHCP, or until 30 seconds have elapsed.
|
||||
slept=0
|
||||
while wlan(staif).ifconfig()[0] == '0.0.0.0' or wlan(staif).isconnected() == False:
|
||||
if slept > 300:
|
||||
break
|
||||
time.sleep_ms(100)
|
||||
slept+=1
|
||||
|
||||
import webrepl
|
||||
webrepl.start()
|
|
@ -0,0 +1,17 @@
|
|||
class init_sample:
|
||||
def __init__(self, hw):
|
||||
#Basic script to print module family, variant, and IP address
|
||||
from network import WLAN as wlan, STA_IF as staif
|
||||
from time import sleep_ms
|
||||
if hw.features.display.oled:
|
||||
oled = hw.oled.handle
|
||||
oled.text("hey",0,0)
|
||||
oled.text(hw.family,0,8)
|
||||
oled.text(hw.variant,0,16)
|
||||
oled.text(wlan(staif).ifconfig()[0],0,24)
|
||||
oled.show()
|
||||
else:
|
||||
print(hw.family)
|
||||
print(hw.variant)
|
||||
print(wlan(staif).ifconfig()[0])
|
||||
sleep_ms(1000)
|
Loading…
Reference in New Issue