-
-
Notifications
You must be signed in to change notification settings - Fork 347
fix: attempt to use channel of $WIFI_IFACE if default channel fails #466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: attempt to use channel of $WIFI_IFACE if default channel fails #466
Conversation
This patch attempts to fallback to an existing $WIFI_IFACE_CHANNEL if current $CHANNEL does not work. In cases, hardware reports as multiple channels available to transmit, hence the script uses channel 1 as default. But it fails when trying to transmit on channel 1. This patch modifies can_transmit_to_channel function to check if $CHANNEL is equal to $WIFI_IFACE_CHANNEL. If not, it sets $CHANNEL to be the same as $WIFI_IFACE_CHANNEL and checks can_transmit_to_channel. If passed, ap is created on the same channel as $WIFI_IFACE_CHANNEL. Else, it safely fails.
@jfly please check if this works for you. |
okay no this fails magnificently when using a config file. I still have to work on it. |
This commit is an addition to f0f68e9 where it fails when using config file. This patch allows `default` option for the FREQ_BAND config option. It also creates changes the `--mkconfig` option to detect whether or not one is using a specific frequency band.
yup should work nice now. Please test |
If someone can test and let me know whether it works, I'll merge, right now i don't have a way to test it. Thanks |
Any updates? In any case, it works for me (my wifi adapter is weird, thats why i wrote the patch), and maybe 1 ACK from me. |
In my device, the |
Are you able to manually set a channel using the |
@sudoAlphaX Yeah, you are right. |
please give me the output of this, with the diff --git a/src/scripts/create_ap b/src/scripts/create_ap
index be781c1..bcb17fa 100755
--- a/src/scripts/create_ap
+++ b/src/scripts/create_ap
@@ -1702,15 +1702,30 @@ if [[ -n "$COUNTRY" && $USE_IWCONFIG -eq 0 ]]; then
fi
# Fallback to currently connected channel if the adapter can not transmit to the default channel (1)
+echo -e "[DEBUG] Initial channel check: WIFI_IFACE='${WIFI_IFACE}', CHANNEL='${CHANNEL}', FREQ_BAND='${FREQ_BAND}', USING_DEFAULT_CHANNEL='${USING_DEFAULT_CHANNEL}', WIFI_IFACE_CHANNEL='${WIFI_IFACE_CHANNEL}'" >&2
if can_transmit_to_channel "${WIFI_IFACE}" "${CHANNEL}"; then
+ echo -e "[DEBUG] can_transmit_to_channel '${WIFI_IFACE}' '${CHANNEL}' (Freq: ${FREQ_BAND}GHz) succeeded." >&2
echo "Transmitting to channel ${CHANNEL}..."
else
+ echo -e "[DEBUG] can_transmit_to_channel '${WIFI_IFACE}' '${CHANNEL}' (Freq: ${FREQ_BAND}GHz) failed. Checking fallback conditions." >&2
+ echo -e "[DEBUG] Fallback check values: USING_DEFAULT_CHANNEL='${USING_DEFAULT_CHANNEL}', WIFI_IFACE_CHANNEL='${WIFI_IFACE_CHANNEL}', CHANNEL='${CHANNEL}', FREQ_BAND='${FREQ_BAND}'" >&2
+ echo -e "[DEBUG] Condition 1: USING_DEFAULT_CHANNEL -eq 1 -> $(($USING_DEFAULT_CHANNEL == 1))" >&2
+ echo -e "[DEBUG] Condition 2: WIFI_IFACE_CHANNEL -ne CHANNEL (${WIFI_IFACE_CHANNEL} != ${CHANNEL}) -> $(($WIFI_IFACE_CHANNEL != $CHANNEL))" >&2
if [[ $USING_DEFAULT_CHANNEL -eq 1 && $WIFI_IFACE_CHANNEL -ne $CHANNEL ]]; then
- echo -e "Your adapter can not transmit to channel ${CHANNEL}" >&2
+ echo -e "[DEBUG] Fallback condition met (USING_DEFAULT_CHANNEL=1 AND WIFI_IFACE_CHANNEL != CHANNEL)." >&2
+ echo -e "Your adapter can not transmit to channel ${CHANNEL} (Freq: ${FREQ_BAND}GHz)" >&2
CHANNEL=$WIFI_IFACE_CHANNEL
+ echo -e "[DEBUG] Set CHANNEL to WIFI_IFACE_CHANNEL: '${CHANNEL}'" >&2
echo -e "Falling back to channel ${CHANNEL}"
- can_transmit_to_channel "${WIFI_IFACE}" "${CHANNEL}" || die "Your adapter can not transmit to channel ${CHANNEL}, frequency band ${FREQ_BAND}GHz."
+ echo -e "[DEBUG] Re-checking can_transmit_to_channel '${WIFI_IFACE}' '${CHANNEL}' (Freq: ${FREQ_BAND}GHz)..." >&2
+ if can_transmit_to_channel "${WIFI_IFACE}" "${CHANNEL}"; then
+ echo -e "[DEBUG] can_transmit_to_channel '${WIFI_IFACE}' '${CHANNEL}' (Freq: ${FREQ_BAND}GHz) succeeded after fallback." >&2
+ else
+ echo -e "[DEBUG] can_transmit_to_channel '${WIFI_IFACE}' '${CHANNEL}' (Freq: ${FREQ_BAND}GHz) FAILED even after fallback." >&2
+ die "Your adapter can not transmit to channel ${CHANNEL}, frequency band ${FREQ_BAND}GHz."
+ fi
else
+ echo -e "[DEBUG] Fallback condition NOT met (USING_DEFAULT_CHANNEL != 1 OR WIFI_IFACE_CHANNEL == CHANNEL). Cannot proceed with initial channel ${CHANNEL}." >&2
die "Your adapter can not transmit to channel ${CHANNEL}, frequency band ${FREQ_BAND}GHz."
fi
fi also
Ill try to find the problem. |
The log after applying your patch:
Output of
Result of
|
So probably I need to revert, I didn't have a device to test it |
This patch attempts to fallback to an existing $WIFI_IFACE_CHANNEL if
current $CHANNEL does not work. In cases, hardware reports as multiple
channels available to transmit, hence the script uses channel 1 as
default. But it fails when trying to transmit on channel 1.
This patch modifies can_transmit_to_channel function checking to check if
$CHANNEL is equal to $WIFI_IFACE_CHANNEL. If not, it sets $CHANNEL to be
the same as $WIFI_IFACE_CHANNEL and checks can_transmit_to_channel. If
passed, ap is created on the same channel as $WIFI_IFACE_CHANNEL. Else,
it safely fails.
This is a rewrite of PR #450
Fixes #344