From 34e326f30365d1785804545b08e463d796cf6269 Mon Sep 17 00:00:00 2001 From: Zehka Date: Tue, 16 Jan 2024 00:32:56 +0100 Subject: [PATCH 1/4] Remove trailing .0 from iw reported frequency Signed-off-by: Zehka --- lnxrouter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lnxrouter b/lnxrouter index 3a3663f..e17e31f 100755 --- a/lnxrouter +++ b/lnxrouter @@ -1700,7 +1700,7 @@ prepare_wifi_interface() { # TODO move this to check_wifi_settings() ? if is_interface_wifi_connected "${WIFI_IFACE}"; then - WIFI_IFACE_FREQ=$(iw dev "${WIFI_IFACE}" link | grep -i freq | awk '{print $2}') + WIFI_IFACE_FREQ=$(iw dev "${WIFI_IFACE}" link | grep -i freq | awk '{print $2}' | sed 's/\.00*//g') WIFI_IFACE_CHANNEL=$(ieee80211_frequency_to_channel "${WIFI_IFACE_FREQ}") echo "${WIFI_IFACE} already working in channel ${WIFI_IFACE_CHANNEL} (${WIFI_IFACE_FREQ} MHz)" From 78d481d0838d2918530ed1c1d39b5e5d32f9bdde Mon Sep 17 00:00:00 2001 From: Zehka Date: Tue, 16 Jan 2024 00:59:41 +0100 Subject: [PATCH 2/4] also ignore trailing \.0+ for iw phy info --- lnxrouter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lnxrouter b/lnxrouter index e17e31f..16c0061 100755 --- a/lnxrouter +++ b/lnxrouter @@ -631,7 +631,7 @@ can_transmit_to_channel() { if [[ $USE_IWCONFIG -eq 0 ]]; then if [[ $FREQ_BAND == 2.4 ]]; then - CHANNEL_INFO=$(get_adapter_info "${IFACE}" | grep " 24[0-9][0-9] MHz \[${CHANNEL_NUM}\]") + CHANNEL_INFO=$(get_adapter_info "${IFACE}" | grep -E " 24[0-9][0-9](.0+){0,1} MHz \[${CHANNEL_NUM}\]") else CHANNEL_INFO=$(get_adapter_info "${IFACE}" | grep " \(49[0-9][0-9]\|5[0-9]\{3\}\) MHz \[${CHANNEL_NUM}\]") fi From f42dc4314d346a9a4d93cbb8ada901f97cee1343 Mon Sep 17 00:00:00 2001 From: Zehka Date: Tue, 16 Jan 2024 13:26:52 +0100 Subject: [PATCH 3/4] regex fixes --- lnxrouter | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lnxrouter b/lnxrouter index 16c0061..c53c0ae 100755 --- a/lnxrouter +++ b/lnxrouter @@ -631,7 +631,7 @@ can_transmit_to_channel() { if [[ $USE_IWCONFIG -eq 0 ]]; then if [[ $FREQ_BAND == 2.4 ]]; then - CHANNEL_INFO=$(get_adapter_info "${IFACE}" | grep -E " 24[0-9][0-9](.0+){0,1} MHz \[${CHANNEL_NUM}\]") + CHANNEL_INFO=$(get_adapter_info "${IFACE}" | grep -E " 24[0-9][0-9](\.0+){0,1} MHz \[${CHANNEL_NUM}\]") else CHANNEL_INFO=$(get_adapter_info "${IFACE}" | grep " \(49[0-9][0-9]\|5[0-9]\{3\}\) MHz \[${CHANNEL_NUM}\]") fi @@ -1700,7 +1700,7 @@ prepare_wifi_interface() { # TODO move this to check_wifi_settings() ? if is_interface_wifi_connected "${WIFI_IFACE}"; then - WIFI_IFACE_FREQ=$(iw dev "${WIFI_IFACE}" link | grep -i freq | awk '{print $2}' | sed 's/\.00*//g') + WIFI_IFACE_FREQ=$(iw dev "${WIFI_IFACE}" link | grep -i freq | awk '{print $2}' | sed 's/\.00*$//g') WIFI_IFACE_CHANNEL=$(ieee80211_frequency_to_channel "${WIFI_IFACE_FREQ}") echo "${WIFI_IFACE} already working in channel ${WIFI_IFACE_CHANNEL} (${WIFI_IFACE_FREQ} MHz)" From 32f168ec8c9a69e022ae97d3bfd113fe088626d6 Mon Sep 17 00:00:00 2001 From: garywill Date: Fri, 19 Jan 2024 13:50:34 +0800 Subject: [PATCH 4/4] can_transmit_to_channel() ignores freq value just focus on channel number --- lnxrouter | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lnxrouter b/lnxrouter index c53c0ae..037e5cf 100755 --- a/lnxrouter +++ b/lnxrouter @@ -630,11 +630,7 @@ can_transmit_to_channel() { CHANNEL_NUM=$2 if [[ $USE_IWCONFIG -eq 0 ]]; then - if [[ $FREQ_BAND == 2.4 ]]; then - CHANNEL_INFO=$(get_adapter_info "${IFACE}" | grep -E " 24[0-9][0-9](\.0+){0,1} MHz \[${CHANNEL_NUM}\]") - else - CHANNEL_INFO=$(get_adapter_info "${IFACE}" | grep " \(49[0-9][0-9]\|5[0-9]\{3\}\) MHz \[${CHANNEL_NUM}\]") - fi + CHANNEL_INFO=$(get_adapter_info "${IFACE}" | grep -E " [0-9]+(\.[0-9]+){0,1} MHz \[${CHANNEL_NUM}\]") [[ -z "${CHANNEL_INFO}" ]] && return 1 [[ "${CHANNEL_INFO}" == *no\ IR* ]] && return 1 [[ "${CHANNEL_INFO}" == *disabled* ]] && return 1 @@ -665,9 +661,6 @@ ieee80211_frequency_to_channel() { fi } -is_5ghz_frequency() { - [[ $1 =~ ^(49[0-9]{2})|(5[0-9]{3})$ ]] -} is_interface_wifi_connected() { if [[ $USE_IWCONFIG -eq 0 ]]; then @@ -1700,7 +1693,7 @@ prepare_wifi_interface() { # TODO move this to check_wifi_settings() ? if is_interface_wifi_connected "${WIFI_IFACE}"; then - WIFI_IFACE_FREQ=$(iw dev "${WIFI_IFACE}" link | grep -i freq | awk '{print $2}' | sed 's/\.00*$//g') + WIFI_IFACE_FREQ=$(iw dev "${WIFI_IFACE}" link | grep -i freq | awk '{print $2}' | sed 's/\.00*$//g') # NOTE we assume integer currently, which can be right, or wrong in the future WIFI_IFACE_CHANNEL=$(ieee80211_frequency_to_channel "${WIFI_IFACE_FREQ}") echo "${WIFI_IFACE} already working in channel ${WIFI_IFACE_CHANNEL} (${WIFI_IFACE_FREQ} MHz)"