[wifi] passwd file
This commit is contained in:
parent
a13591b2be
commit
61275fd77f
|
@ -18,6 +18,8 @@ logging.basicConfig(
|
|||
format='%(asctime)s - %(levelname)s - %(message)s' # 日志的格式
|
||||
)
|
||||
|
||||
wifi_credential_file = '~/.config/wifi_credentials.json'
|
||||
|
||||
try:
|
||||
from takway.board import OrangePi
|
||||
led_enabled = True
|
||||
|
@ -292,7 +294,7 @@ def connect_saved_wifi(scaned_wifi_list):
|
|||
|
||||
def load_saved_wifi():
|
||||
try:
|
||||
with open('wifi_list.json', 'r') as f:
|
||||
with open(wifi_credential_file, 'r') as f:
|
||||
wifi_list = json.load(f)
|
||||
return wifi_list
|
||||
except:
|
||||
|
@ -302,7 +304,7 @@ def save_wifi(ssid, password):
|
|||
wifi_list = load_saved_wifi()
|
||||
if ssid not in [item['ssid'] for item in wifi_list]:
|
||||
wifi_list.append({'ssid': ssid, 'password': password})
|
||||
with open('wifi_list.json', 'w') as f:
|
||||
with open(wifi_credential_file, 'w') as f:
|
||||
json.dump(wifi_list, f)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue