update board enable
This commit is contained in:
parent
20f4f4316b
commit
25d73178a6
|
@ -25,7 +25,8 @@ except ImportError:
|
||||||
|
|
||||||
|
|
||||||
def close_app():
|
def close_app():
|
||||||
orangepi.set_led_off('red')
|
if led_enabled:
|
||||||
|
orangepi.set_led_off('red')
|
||||||
# 获取当前Flask应用程序的进程ID
|
# 获取当前Flask应用程序的进程ID
|
||||||
flask_pid = os.getpid()
|
flask_pid = os.getpid()
|
||||||
|
|
||||||
|
@ -53,7 +54,8 @@ def check_wifi_connection():
|
||||||
columns = line.split()
|
columns = line.split()
|
||||||
print(columns)
|
print(columns)
|
||||||
if len(columns) >= 4 and columns[2] == "connected":
|
if len(columns) >= 4 and columns[2] == "connected":
|
||||||
orangepi.set_led_off('blue')
|
if led_enabled:
|
||||||
|
orangepi.set_led_off('blue')
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -69,7 +71,8 @@ def restart_hotspot():
|
||||||
subprocess.run(['sudo', 'nmcli', 'radio', 'wifi', 'off'], check=True)
|
subprocess.run(['sudo', 'nmcli', 'radio', 'wifi', 'off'], check=True)
|
||||||
subprocess.run(['sudo', 'nmcli', 'radio', 'wifi', 'on'], check=True)
|
subprocess.run(['sudo', 'nmcli', 'radio', 'wifi', 'on'], check=True)
|
||||||
subprocess.Popen('sudo nohup create_ap wlan0 eth0 Takway-Toys --no-virt > create_ap.log 2>&1 &', shell=True)
|
subprocess.Popen('sudo nohup create_ap wlan0 eth0 Takway-Toys --no-virt > create_ap.log 2>&1 &', shell=True)
|
||||||
orangepi.set_led_on('blue')
|
if led_enabled:
|
||||||
|
orangepi.set_led_on('blue')
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print(f"{datetime.datetime.now()} Error stopping create_ap hotspot service: {e}")
|
print(f"{datetime.datetime.now()} Error stopping create_ap hotspot service: {e}")
|
||||||
|
|
||||||
|
@ -165,7 +168,8 @@ def index():
|
||||||
# 提交 Wi-Fi 信息
|
# 提交 Wi-Fi 信息
|
||||||
@app.route('/submit', methods=['POST'])
|
@app.route('/submit', methods=['POST'])
|
||||||
def submit():
|
def submit():
|
||||||
orangepi.set_led_on('red')
|
if led_enabled:
|
||||||
|
orangepi.set_led_on('red')
|
||||||
ssid = request.form['ssid']
|
ssid = request.form['ssid']
|
||||||
password = request.form['password']
|
password = request.form['password']
|
||||||
print(f"{datetime.datetime.now()}: Connecting to Wi-Fi: {ssid} with password {password}")
|
print(f"{datetime.datetime.now()}: Connecting to Wi-Fi: {ssid} with password {password}")
|
||||||
|
@ -187,7 +191,8 @@ def submit():
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
debug_mode = False # 设置为 True 以跳过 Wi-Fi 连接状态检测
|
debug_mode = False # 设置为 True 以跳过 Wi-Fi 连接状态检测
|
||||||
|
|
||||||
orangepi.set_led_on('blue')
|
if led_enabled:
|
||||||
|
orangepi.set_led_on('blue')
|
||||||
if not debug_mode:
|
if not debug_mode:
|
||||||
time.sleep(5) # 等待 Wi-Fi 连接
|
time.sleep(5) # 等待 Wi-Fi 连接
|
||||||
if check_wifi_connection():
|
if check_wifi_connection():
|
||||||
|
|
Loading…
Reference in New Issue