Skip to content

Commit

Permalink
Merge pull request #474 from onlaj/hotfix_network
Browse files Browse the repository at this point in the history
Hotfix network
  • Loading branch information
onlaj authored Sep 26, 2023
2 parents 01e9acb + be7a316 commit e192940
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 19 deletions.
4 changes: 2 additions & 2 deletions disable_ap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sudo cp config/wpa_disable_ap.conf /etc/wpa_supplicant/wpa_supplicant.conf
sleep 1
sudo wpa_cli -i wlan0 reconfigure
sudo wpa_cli -i p2p-dev-wlan0
sleep 5
sleep 2
sudo ifconfig wlan0 down
sleep 5
sleep 2
sudo ifconfig wlan0 up
6 changes: 3 additions & 3 deletions enable_ap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ sudo cp config/wpa_enable_ap.conf /etc/wpa_supplicant/wpa_supplicant.conf
sleep 1
sudo wpa_cli -i wlan0 reconfigure
sudo wpa_cli -i p2p-dev-wlan0 reconfigure
sleep 5
sleep 2
sudo ifconfig wlan0 down
sleep 5
sleep 3
sudo ifconfig wlan0 up
sleep 8
sleep 2

# Check if hostapd is masked, and unmask it if needed
if [[ $(sudo systemctl is-enabled hostapd) == "masked" ]]; then
Expand Down
6 changes: 4 additions & 2 deletions lib/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,10 @@ def gammacurve(x, p):

def check_if_led_can_be_overwrite(i, ledstrip, ledsettings):
if ledsettings.adjacent_mode == "Off":
if ledstrip.keylist_status[i] == 0 and ledstrip.keylist[i] == 0:
return True
if i < len(ledstrip.keylist_status) and i < len(ledstrip.keylist):
if ledstrip.keylist_status[i] == 0 and ledstrip.keylist[i] == 0:
return True
return False
else:
if 1 < i < (ledstrip.led_number - 1):
if ledstrip.keylist[i + 1] == ledstrip.keylist[i - 1] == ledstrip.keylist[i] \
Expand Down
9 changes: 9 additions & 0 deletions lib/hotspot.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ def manage_hotspot(hotspot, usersettings, midiports, first_run=False):
if is_hotspot_active(usersettings):
disconnect_from_wifi(hotspot, usersettings)
return
else:
try:
print("Running disable_ap.sh")
subprocess.Popen(['sudo', './disable_ap.sh'], stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL)
except Exception as error:
# handle the exception
print("An exception occurred while shutting down a hotspot:", error)

# Calculate time passed without Wi-fi
current_time = time.time()
Expand Down Expand Up @@ -139,6 +147,7 @@ def connect_to_wifi(ssid, password, hotspot, usersettings):
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
scan_ssid=1
ssid="%s"
%s
}"""
Expand Down
2 changes: 1 addition & 1 deletion webinterface/static/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ let ticker = new AdjustingInterval(play_tick_sound, 60000 / beats_per_minute);


function loadAjax(subpage) {
if (!subpage) {
if (!subpage || subpage === "/") {
subpage = "home"
}
document.getElementById("main").classList.remove("show");
Expand Down
16 changes: 8 additions & 8 deletions webinterface/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</div>
<div class="grid grid-cols-12 gap-6 mt-5">
<a class="transform hover:scale-105 transition duration-300 shadow-xl rounded-lg col-span-12
sm:col-span-6 xl:col-span-3 intro-y bg-gray-200 dark:bg-gray-700" href="#/">
sm:col-span-6 xl:col-span-3 intro-y bg-gray-200 dark:bg-gray-700">
<div class="p-5">
<div class="flex justify-between">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none"
Expand Down Expand Up @@ -63,7 +63,7 @@
</div>
</a>
<a class="transform hover:scale-105 transition duration-300 shadow-xl rounded-lg col-span-12
sm:col-span-6 xl:col-span-3 intro-y bg-gray-200 dark:bg-gray-700" href="#/">
sm:col-span-6 xl:col-span-3 intro-y bg-gray-200 dark:bg-gray-700">
<div class="p-5">
<div class="flex justify-between">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none"
Expand All @@ -87,7 +87,7 @@
</div>
</a>
<a class="transform hover:scale-105 transition duration-300 shadow-xl rounded-lg col-span-12
sm:col-span-6 xl:col-span-3 intro-y bg-gray-200 dark:bg-gray-700" href="#/">
sm:col-span-6 xl:col-span-3 intro-y bg-gray-200 dark:bg-gray-700">
<div class="p-5">
<div class="flex justify-between">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none"
Expand All @@ -111,7 +111,7 @@
</div>
</a>
<a class="transform hover:scale-105 transition duration-300 shadow-xl rounded-lg col-span-12
sm:col-span-6 xl:col-span-3 intro-y bg-gray-200 dark:bg-gray-700" href="#/">
sm:col-span-6 xl:col-span-3 intro-y bg-gray-200 dark:bg-gray-700">
<div class="p-5">
<div class="flex justify-between">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 " fill="none"
Expand Down Expand Up @@ -148,7 +148,7 @@
</div>
</a>
<a class="transform hover:scale-105 transition duration-300 shadow-xl rounded-lg col-span-12
sm:col-span-6 xl:col-span-3 intro-y bg-gray-200 dark:bg-gray-700" href="#/">
sm:col-span-6 xl:col-span-3 intro-y bg-gray-200 dark:bg-gray-700">
<div class="p-5">
<div class="flex justify-between">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
Expand All @@ -166,7 +166,7 @@
</div>
</a>
<a class="advanced-content transform hover:scale-105 transition duration-300 shadow-xl rounded-lg col-span-12
sm:col-span-6 xl:col-span-3 intro-y bg-gray-200 dark:bg-gray-700" href="#/">
sm:col-span-6 xl:col-span-3 intro-y bg-gray-200 dark:bg-gray-700">
<div class="p-5">
<div class="flex justify-between">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none"
Expand Down Expand Up @@ -195,7 +195,7 @@
</a>

<a class="cursor-default transition duration-300 shadow-xl rounded-lg col-span-12 sm:col-span-12 xl:col-span-12 intro-y
bg-gray-200 dark:bg-gray-700" href="#/">
bg-gray-200 dark:bg-gray-700">
<div class="grid grid-cols-2 sm:grid-cols-2 md:grid-cols-4 lg:grid-cols-7 xl:grid-cols-7">
<div class="p-5">
<label data-translate="screen" class="h-8 block uppercase tracking-wide text-xs font-bold mt-2 text-gray-600 dark:text-gray-400">
Expand Down Expand Up @@ -354,7 +354,7 @@
</a>

<a class="transition duration-300 shadow-xl rounded-lg col-span-12 sm:col-span-12 xl:col-span-12 intro-y
bg-gray-200 dark:bg-gray-700" href="#/">
bg-gray-200 dark:bg-gray-700">
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6">
<div class="p-5">
<div class="text-base text-gray-600 dark:text-gray-400" data-translate="color_mode">
Expand Down
6 changes: 3 additions & 3 deletions webinterface/templates/ledsettings.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
</svg>
<input id="shift" name="field_name" type="number" value="176" min="-255" max="255"
class="h-10 block appearance-none w-full bg-gray-100 dark:bg-gray-600
py-2 px-2 rounded-2xl leading-tight focus:outline-none focus:bg-white focus:border-gray-500">
text-center rounded-2xl leading-tight focus:outline-none focus:bg-white focus:border-gray-500">
<svg onclick="document.getElementById('shift').stepUp();
document.getElementById('shift').dispatchEvent(new Event('change'));
temporary_show_chords_animation();" xmlns="http://www.w3.org/2000/svg"
Expand Down Expand Up @@ -197,7 +197,7 @@
</svg>
<input id="led_count" name="field_name" type="number" value="176" min="0" max="255"
class="h-10 block appearance-none w-full bg-gray-100 dark:bg-gray-600
py-2 px-2 rounded-2xl leading-tight focus:outline-none focus:bg-white focus:border-gray-500">
text-center rounded-2xl leading-tight focus:outline-none focus:bg-white focus:border-gray-500">
<svg onclick="document.getElementById('led_count').stepUp();
document.getElementById('led_count').dispatchEvent(new Event('change'));
temporary_show_chords_animation(true);" xmlns="http://www.w3.org/2000/svg"
Expand Down Expand Up @@ -225,7 +225,7 @@
</svg>
<input id="leds_per_meter" name="field_name" type="number" value="144" min="1" max="255"
class="h-10 block appearance-none w-full bg-gray-100 dark:bg-gray-600
py-2 px-2 rounded-2xl leading-tight focus:outline-none focus:bg-white focus:border-gray-500">
text-center rounded-2xl leading-tight focus:outline-none focus:bg-white focus:border-gray-500">
<svg onclick="document.getElementById('leds_per_meter').stepUp();
document.getElementById('leds_per_meter').dispatchEvent(new Event('change'));
temporary_show_chords_animation();" xmlns="http://www.w3.org/2000/svg"
Expand Down

0 comments on commit e192940

Please sign in to comment.