* mandatory config options:
* trm\_enabled => main switch to enable/disable the travelmate service (default: '0', disabled)
* trm\_loop => loop timeout in seconds for wlan monitoring (default: '30')
- * trm\_maxretry => how many times should travelmate try to connect to a certain uplink (default: '3')
+ * trm\_maxretry => how many times should travelmate try to connect to a certain uplink, to disable this check at all set it to '0' (default: '3')
* optional config options:
* trm\_debug => enable/disable debug logging (default: '0', disabled)
- * trm\_device => limit travelmate to a dedicated radio, i.e 'radio0' (default: '', use all radios)
- * trm\_iw => force travelmate to use iwinfo (even if iw is installed) set this option to 'none' (default: '', use iw if found)
+ * trm\_device => limit travelmate to a dedicated radio, i.e 'radio0' (default: use all radios)
+ * trm\_iw => set this option to '0' to use iwinfo for wlan scanning (default: '1', use iw)
## Setup
**1. configure a wwan interface in /etc/config/network:**
#
LC_ALL=C
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
-trm_debug="0"
trm_pid="${$}"
-trm_ver="0.2.3"
+trm_ver="0.2.4"
+trm_debug=0
trm_loop=30
trm_maxretry=3
+trm_iw=1
trm_device=""
-trm_iw="$(which iw)"
# function to prepare all relevant AP and STA interfaces
#
json_get_var trm_status up
if [ "${trm_status}" = "1" ] || [ -n "${trm_uplink}" ]
then
- trm_log "debug" "check::: interface: ${interface}, status: ${trm_status}, uplink: ${trm_uplink}, ssid: ${trm_ssid} count: ${cnt}"
+ trm_log "debug" "check::: interface: ${interface}, status: ${trm_status}, uplink-sta: ${trm_uplink}, uplink-ssid: ${trm_ssid} count: ${cnt}"
json_cleanup
break
fi
local class="${1}"
local log_msg="${2}"
- if [ -n "${log_msg}" ] && ([ "${class}" != "debug" ] || ([ "${class}" = "debug" ] && [ "${trm_debug}" = "1" ]))
+ if [ -n "${log_msg}" ] && ([ "${class}" != "debug" ] || ([ "${class}" = "debug" ] && [ $((trm_debug)) -eq 1 ]))
then
logger -t "travelmate-${trm_ver}[${trm_pid}] ${class}" "${log_msg}" 2>&1
fi
# check for preferred wireless tool
#
-if [ ! -f "${trm_iw}" ]
+if [ $((trm_iw)) -eq 1 ]
then
- trm_iwinfo="$(which iwinfo)"
- if [ ! -f "${trm_iwinfo}" ]
- then
- trm_log "error" "no wireless tool for wlan scanning found, please install 'iw' or 'iwinfo'"
- exit 255
- fi
+ trm_scanner="$(which iw)"
+else
+ trm_scanner="$(which iwinfo)"
+fi
+
+if [ -z "${trm_scanner}" ]
+then
+ trm_log "error" "no wireless tool for wlan scanning found, please install 'iw' or 'iwinfo'"
+ exit 255
fi
# infinitive loop to establish and track STA uplink connections
for ap in ${trm_aplist}
do
ubus -t 10 wait_for hostapd."${ap}"
- if [ -f "${trm_iw}" ]
+ if [ $((trm_iw)) -eq 1 ]
then
- trm_ssidlist="$(${trm_iw} dev "${ap}" scan 2>/dev/null | awk '/SSID: /{if(!seen[$0]++){printf "\"";for(i=2; i<=NF; i++)if(i==2)printf $i;else printf " "$i;printf "\" "}}')"
+ trm_ssidlist="$(${trm_scanner} dev "${ap}" scan 2>/dev/null | awk '/SSID: /{if(!seen[$0]++){printf "\"";for(i=2; i<=NF; i++)if(i==2)printf $i;else printf " "$i;printf "\" "}}')"
else
- trm_ssidlist="$(${trm_iwinfo} "${ap}" scan | awk '/ESSID: ".*"/{ORS=" ";if (!seen[$0]++) for(i=2; i<=NF; i++) print $i}')"
+ trm_ssidlist="$(${trm_scanner} "${ap}" scan | awk '/ESSID: ".*"/{ORS=" ";if (!seen[$0]++) for(i=2; i<=NF; i++) print $i}')"
fi
- trm_log "debug" "main ::: iw: ${trm_iw}, iwinfo: ${trm_iwinfo}, ssidlist: ${trm_ssidlist}"
+ trm_log "debug" "main ::: scan-tool: ${trm_scanner}, ssidlist: ${trm_ssidlist}"
if [ -n "${trm_ssidlist}" ]
then
for sta in ${trm_stalist}
trm_network="${sta##*_}"
trm_ifname="$(uci -q get wireless."${trm_config}".ifname)"
trm_ssid="\"$(uci -q get wireless."${trm_config}".ssid)\""
- if [ $((trm_count_${trm_config}_${trm_network})) -lt $((trm_maxretry)) ]
+ if [ $((trm_count_${trm_config}_${trm_network})) -lt $((trm_maxretry)) ] || [ $((trm_maxretry)) -eq 0 ]
then
if [ -n "$(printf "${trm_ssidlist}" | grep -Fo "${trm_ssid}")" ]
then
eval "trm_count_${trm_config}_${trm_network}=\$((trm_count_${trm_config}_${trm_network}+1))"
fi
fi
- elif [ $((trm_count_${trm_config}_${trm_network})) -eq $((trm_maxretry)) ]
+ elif [ $((trm_count_${trm_config}_${trm_network})) -eq $((trm_maxretry)) ] && [ $((trm_maxretry)) -ne 0 ]
then
eval "trm_count_${trm_config}_${trm_network}=\$((trm_count_${trm_config}_${trm_network}+1))"
trm_log "info" "uplink ${trm_ssid} disabled due to permanent connection failures"