示例#1
0
def confirm(ssid, password):
    term.header(True, "WiFi setup")
    nvs = esp32.NVS("system")
    nvs.set_blob("wifi.ssid", ssid)
    nvs.set_blob("wifi.password", password)
    nvs.commit()
    print("New configuration has been saved.")
    print("")
    print("SSID:\t\t" + ssid)
    if len(password) < 1:
        print("No password")
    else:
        print("PASSWORD:\t" + password)
    print("")
    print("Press any key to return to the homescreen")
    sys.stdin.read(1)
    system.home(True)
        rgb.framerate(20)
        rgb.setfont(rgb.FONT_7x5)
        uinterface.skippabletext(message)

def ap_requires_password(ap_type):
        return "OPEN" != ap_type

ap_list = scan_access_point_list()
ssids = [ap[0] for ap in ap_list]
prompt_message("Select network")

choice = uinterface.menu(ssids)
if not (choice is None):
        chosen_ssid, chosen_ap_type = ap_list[choice]

        pw_required = ap_requires_password(chosen_ap_type)
        if pw_required:
                prompt_message("Enter password")

        chosen_pass = uinterface.text_input() if pw_required else ''
        if not pw_required or chosen_pass:
                # For OTA
                nvs = esp32.NVS("system")
                nvs.set_blob("wifi.ssid", chosen_ssid)
                nvs.set_blob("wifi.password", chosen_pass)
                nvs.commit()
                # For apps
                valuestore.save("system", "wifi.ssid", chosen_ssid)
                valuestore.save("system", "wifi.password", chosen_pass)

system.reboot()
示例#3
0
    def getPassword(self):
        password = bytearray(32)
        nvs = esp32.NVS('password')
        nvs.get_blob('password', password)

        return password.decode()
import sys, uos as os, time, ujson, gc, term, deepsleep
import machine, system, term_menu, virtualtimers, tasks.powermanagement as pm, buttons, defines, woezel
import rgb, uinterface, uinstaller
from default_icons import icon_snake, icon_clock, icon_settings, icon_appstore, icon_activities, icon_nickname, \
                            icon_slider, icon_unknown
import esp32
# Application list

apps = []
current_index = 0
current_icon = None
nvs = esp32.NVS("launcher")


def show_text(text):
    rgb.scrolltext(text, (255, 255, 255))


def show_app_name(name):
    rgb.scrolltext(name, (255, 255, 255), (8, 0), rgb.PANEL_WIDTH - 8)


def clear():
    rgb.clear()


def add_app(app, information):
    global apps
    install_path = woezel.get_install_path()
    try:
        title = information["name"]
import network, term, sys, system, machine
import esp32

nvs = esp32.NVS("badge")

system.serialWarning()


def home():
    system.home(True)


def main():
    term.empty_lines()
    term.header(True, "Nickname setup")
    print("Enter your new nickname.")
    nickname = term.prompt("Nickname", 1, 5)
    if (len(nickname) >= 1):
        confirm(nickname)


def confirm(nickname):
    term.header(True, "Nickname setup")
    nvs.set_blob("nickname", nickname)
    nvs.commit()
    print("New configuration has been saved.")
    print("")
    print("Nickname:\t\t" + nickname)
    print("Press any key to return to the homescreen")
    sys.stdin.read(1)
    system.home(True)
示例#6
0
文件: main.py 项目: alanmimms/pyspi
import localconfig
import network
import utime
import esp32

config = esp32.NVS('config')

try:
    essidBA = bytearray(64, 'utf-8')
    len = config.get_blob('essid', essidBA)
    essid = essidBA[0:len].decode()
except:
    while True:
        print(
            'Missing "essid". You must define esp32.NVS("config") blobs for "essid" and "password"'
        )

try:
    passBA = bytearray(64, 'utf-8')
    len = config.get_blob('password', passBA)
    password = passBA[0:len].decode()
except:
    while True:
        print(
            'Missing "password". You must define esp32.NVS("config") blobs for "essid" and "password"'
        )

nic = network.WLAN(network.STA_IF)
nic.active(True)

utime.sleep(1)