Skip to content

Commit

Permalink
mock wifi list
Browse files Browse the repository at this point in the history
  • Loading branch information
ZanSara committed Jan 10, 2025
1 parent 4b977b9 commit c2e4ee9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 33 deletions.
6 changes: 4 additions & 2 deletions zanzocam/web_ui/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from flask import render_template

from zanzocam.web_ui.utils import read_network_data, read_setup_data_file, read_flag_file, read_log_file, clear_logs
from zanzocam.web_ui.utils import read_network_data, read_setup_data_file, read_flag_file, read_log_file, clear_logs, get_available_wifis
from zanzocam.webcam.system import get_wifi_data
from zanzocam.constants import *

Expand All @@ -26,10 +26,12 @@ def home_page():
def network_page():
""" The page with the network forms """
network_data = read_network_data()
wifi_list = get_available_wifis()
return render_template("network.html",
title="Setup Rete",
version=VERSION,
network_data=network_data)
network_data=network_data,
wifi_list=wifi_list)

def server_page():
""" The page with the server data forms """
Expand Down
50 changes: 19 additions & 31 deletions zanzocam/web_ui/templates/network.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,15 @@
<div id="page">

<form id="config" method="POST" action="/configure/network">
<!--div class="row">
<p style="margin-top: 1rem; margin-bottom: 1rem; margin-right:3rem;">Tipo di connessione:</p>
<label class="toggle">
<input type="radio" value="WiFi" name="network_type" {% if network_data.type=="WiFI" %}checked{%endif%} onclick="javascript:toggle_network_type('wifi')" style="display:none;">
<span class="label">WiFI</span>
</label>
<label class="toggle">
<input type="radio" value="Ethernet" name="network_type" {% if network_data.type=="Ethernet" %}checked{%endif%} onclick="javascript:toggle_network_type('ethernet')" style="display:none;">
<span class="label">Ethernet</span>
</label>
<label class="toggle">
<input type="radio" value="SIM" name="network_type" {% if network_data.type=="SIM" %}checked{%endif%} onclick="javascript:toggle_network_type('sim')" style="display:none;">
<span class="label">SIM</span>
</label>
</div>

<div id="wifi-vars" style="display: none; flex-direction:column!important;"-->
<label for="network_ssid">Nome della rete (SSID):</label>
<input type="text" name="network_ssid" value="{{ network_data.ssid }}">

<label for="network_password">Password:</label>
<div class="row">
<input type="password" name="network_password" value="{{ network_data.password }}">
<button onclick="toggle_password(this)" type="button">Mostra</button>
</div>
<!--/div>
<label for="network_ssid">Nome della rete (SSID):</label>
<input type="text" name="network_ssid" value="{{ network_data.ssid }}">

<div id="ethernet-vars" style="display: none;">
<label for="network_password">Password:</label>
<div class="row">
<input type="password" name="network_password" value="{{ network_data.password }}">
<button onclick="toggle_password(this)" type="button">Mostra</button>
</div>
<div id="sim-vars" style="display: none;">
<label for="network_apn">APN:</label>
<input type="text" name="network_apn" value="{{ network_data.apn }}">
</div-->

<div class="center">
<button id="configure-network" class="button setup-button">Configura la rete</button>
Expand All @@ -46,6 +21,19 @@

</form>

<hr />

<div>
<h2>Reti Wifi Visibili</h2>
{% if wifi_list %}
{% for wifi in wifi_list %}
<p style="border: 1px solid gray; border-radius: 2px; padding-bottom: 2px;"> {{ wifi }}</p>
{% endfor %}
{% else %}
<p >Nessun WiFi disponibile</p>
{% endif %}
</div>

</div>


Expand Down
15 changes: 15 additions & 0 deletions zanzocam/web_ui/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ def read_network_data():
return {"type": "WiFi", "ssid": ssid, "password": password}


def get_available_wifis():
return [
'Quality=31/70 Signal level=-79 dBm ESSID:"MEO-4FD250"',
'Quality=33/70 Signal level=-77 dBm ESSID:"MEO-WiFi"',
'Quality=41/70 Signal level=-69 dBm ESSID:"TP-Link_773C"',
'Quality=26/70 Signal level=-84 dBm ESSID:"ROCHA_SANTOS"',
'Quality=26/70 Signal level=-84 dBm ESSID:"MEO-WiFi"',
'Quality=69/70 Signal level=-41 dBm ESSID:"Tarallini"',
'Quality=34/70 Signal level=-76 dBm ESSID:"NOS-3280"',
'Quality=24/70 Signal level=-86 dBm ESSID:"DIRECT-BD-HP DeskJet 2700 series"',
'Quality=18/70 Signal level=-92 dBm ESSID:"Extender-WiFi-8d8f"',
'Quality=26/70 Signal level=-84 dBm ESSID:"NOWO-97E5B"'
]


def _read_data_file(path: Path, default: str, action: Callable, catch_errors: bool=True):
"""
Reads the given file, applies the action lambda and returns the result.
Expand Down

0 comments on commit c2e4ee9

Please sign in to comment.