Guest User

Untitled

a guest
Nov 12th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. # This is script that run when device boot up (or wake from sleep.)
  2. from secrets import * # Load credentials
  3. import network # Import WLAN library
  4. import webrepl
  5. from time import sleep
  6.  
  7. sta_if = network.WLAN(network.STA_IF) # Initialize STA mode (to connect to a network)
  8. ap_if = network.WLAN(network.AP_IF) # Initialize AP mode (to turn it off)
  9. ap_if.active(False) # Turn off AP mode
  10. if not sta_if.isconnected():
  11. print('Connecting to network: %s' % (WIFI_SSID))
  12. sta_if.active(True)
  13. sta_if.connect(WIFI_SSID, WIFI_PSK) # Connect to predefined Wi-Fi network
  14. while not sta_if.isconnected():
  15. pass
  16. sleep(3) # I don't totally recall why I put this sleep here
  17. print('Network Configuration:', sta_if.ifconfig())
Add Comment
Please, Sign In to add comment