Skip to content
Snippets Groups Projects
Commit cdf21ebe authored by Joren Van Onder's avatar Joren Van Onder
Browse files

[FIX] point_of_sale: make POSBox print only one ticket when losing wifi

The POSBox attempts to maintain whatever Wi-Fi connection it has as best
it can. When it loses it's current Wi-Fi connection it will attempt
to recreate it every 30 seconds. This works well, but a side-effect of
this is that it'll also print a 'Could not connect to LAN' ticket every
time it fails. If you where to leave the POSBox with Wi-Fi on for an
extended period of time you could return to a lot of 'Could not connect
to LAN' tickets.

This makes it so that the 'Could not connect to LAN' ticket only gets
printed once upon connection loss. Although it would be simpler to just
not print this ticket at all when losing connection, it is very useful
to know when the POSBox has lost connection. Otherwise when it loses
connection it would stop working and noone would know why.
parent 3266d433
Branches
Tags
No related merge requests found
......@@ -7,6 +7,7 @@ function connect () {
WPA_PASS_FILE="/tmp/wpa_pass.txt"
PERSISTENT_WIFI_NETWORK_FILE="/home/pi/wifi_network.txt"
CURRENT_WIFI_NETWORK_FILE="/tmp/current_wifi_network.txt" # used to repair connection when we lose it
LOST_WIFI_FILE="/tmp/lost_wifi.txt"
ESSID="${1}"
PASSWORD="${2}"
PERSIST="${3}"
......@@ -15,6 +16,7 @@ function connect () {
sleep 3
sudo pkill -f keep_wifi_alive.sh
WIFI_WAS_LOST=$?
# make network choice persistent
if [ -n "${ESSID}" ] ; then
......@@ -54,13 +56,24 @@ function connect () {
# give dhcp some time
timeout 30 sh -c 'until ifconfig wlan0 | grep "inet addr:" ; do sleep 0.1 ; done'
TIMEOUT_RETURN=$?
if [ $? -eq 124 ] && [ -z "${NO_AP}" ] ; then
if [ ${TIMEOUT_RETURN} -eq 124 ] && [ -z "${NO_AP}" ] ; then
logger -t posbox_connect_to_wifi "Failed to connect, forcing Posbox AP"
sudo /home/pi/odoo/addons/point_of_sale/tools/posbox/configuration/wireless_ap.sh "force" &
else
logger -t posbox_connect_to_wifi "Restarting odoo"
sudo service odoo restart
if [ ${TIMEOUT_RETURN} -ne 124 ] ; then
rm -f "${LOST_WIFI_FILE}"
fi
if [ ! -f "${LOST_WIFI_FILE}" ] ; then
logger -t posbox_connect_to_wifi "Restarting odoo"
sudo service odoo restart
fi
if [ ${WIFI_WAS_LOST} -eq 0 ] ; then
touch "${LOST_WIFI_FILE}"
fi
logger -t posbox_connect_to_wifi "Starting wifi keep alive script"
/home/pi/odoo/addons/point_of_sale/tools/posbox/configuration/keep_wifi_alive.sh &
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment