1

I have a problem with RPi and WiFi channel changing. As I discovered these days - RPi determines channel only during boot procces. And this is an issue. If I log in to my AP (mikrotik) and change frequency to any another - RPi always disapear and does not appear anymore untill one of bellow items becomes true:

  1. Restoring frequency/channel that was actual on RPi boot time
  2. RPi reboot.

Details:

RPi: 2 model B

OS: Raspbian Jessie

WiFi: 2.4Ghz 801.11n with SSID hidden

I want to fix this issue and make able autoreestablishing WiFi connection without rebooting RPi, because I use "Channel: auto" on my AP and don't want to disable the feature.

Please help me to fix.

---------------- Additional info ---------------------

cat /etc/network/interfaces | egrep -v "^\#"


source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

cat /etc/wpa_supplicant/wpa_supplicant.conf
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
   ssid="SSID"
   psk="PWD"

   bssid=XX:XX:XX:XX:XX:XX

   scan_ssid=1
   proto=WPA2          # can be RSN (for WPA2) or WPA (for WPA1)
   key_mgmt=WPA-PSK    # can be WPA-PSK or WPA_EAP (for enterprise networks)
   pairwise=CCMP       # can be CCMP( for WPA2) or TKIP (for WPA1), or both
   auth_alg=OPEN       # can be OPEN, LEAP and SHARED
}
Hitchman
  • 11
  • 1
  • 4
  • In my experience on Raspbian Stretch the RPi follows the AP fine on a frequency change with some delay depending on the scanning interval configured. To me it sounds like this could be related to the fact that the SSID is hidden. Could you post the content of the files /etc/network/interfaces and /etc/wpa_supplicant/wpa_supplicant.conf? – oh.dae.su Jul 11 '18 at 09:59
  • *not including passwords! – Wilf Jul 11 '18 at 12:46
  • Sure, added to initial message – Hitchman Jul 11 '18 at 17:58
  • Thanks for the update. I don't see anything suspicious in those files. Would be interesting to see, if you have the same problem with a not hidden AP. – oh.dae.su Jul 11 '18 at 19:08

3 Answers3

0

Looks like the Pi is having re-connection issues. There is a similar thread on automatically reconnecting to wifi here which should solve the problem by forcing the wifi adapter to reconnect to the router if it looses a connection

karan
  • 454
  • 2
  • 7
0

"RPi determines channel only during boot procces" is not true!

Any problem is due to the network configuration (which you have not specified). If connection is lost the OS should attempt to re-connect if correctly configured.

You are using a doubly obsolete unsupported OS. The current Raspbian have much improved networking, which avoid most of the difficulties Wheezy had.

Install Stretch - this has vastly more robust networking!

Milliways
  • 59,890
  • 31
  • 101
  • 209
  • Reconnection works for me only when channel is unchanged. As I wrote before - RPi appears again after channel changings when frequency restored. So this is reconnection too and it works. But my problem happened only when WiFi channel is changed. What details regarding network config would you like? Hidden SSID + DHCP. Nothing interesting. – Hitchman Jul 11 '18 at 07:46
  • And sorry - Debian Jessie installed, not Wheezy – Hitchman Jul 11 '18 at 08:00
  • Can you gibe some pointers to understand the available network configurations? – ffleandro Aug 21 '19 at 21:16
0

So.. I wasted a couple of hours to troubleshoot an issue.

I definitely see that raspbian does not "see" new frequency when it changes.

At the moment when AP switched to the new frequency I see that RPi seats on old one yet.

I checked it several times with iwconfig and wpa_cli -i wlan0 status.

I did some kind of workaround.

Wrote a script and added it to cron. Now RPi successfully reconnects even if channel switched.

Hope this will be helpful for somebody

#!/bin/bash

IP=x.x.x.x

PACKETS=4

LOGFILE=/home/username/wifimon.log

count=$(ping -c $PACKETS -W 2 -n -B -s 0 -i 1 -l 1 -q $IP | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')

if [ $count == 0 ]; then
  echo "Connectivity test failed. Let's try to reconnect to WiFi AP."

  echo "[$(date)] Connectivity test failed. Let's try to reconnect to WiFi AP." >> $LOGFILE

  /sbin/wpa_cli -i wlan0 reconfigure
else
  echo "Connectivity test passed. Packet(s) received: $count."
fi

Hitchman
  • 11
  • 1
  • 4