Auto-reconnect OSMC RaspBi to wireless

My OSMC is connected to WiFi with a fixed IP. It happens that if I reset the router (i.e.: for a firmware upgrade), the RasPi doesn’t reconnect to the WiFi. In that case, as I have no keyboard connection, the only thing I can do is to brutally power-off the device.

How can I set it in order to automatically re-connect when the router is back available?

You’ve given us very little information about your WiFi keyboard.

Given that this kind of situation will occur quite rarely, you can still reboot the Pi from the Kodi interface, via the Chorus 2 Web interface, or via an SSH session from another PC.

Pulling the power cable can cause data corruption and is not recommended.

I know that pulling the cable is a last resort, but I am afraid you didn’t fully get my question. The wifi keyboard is not the problem (it is the Kore App), the problem is that after a router interruption, my OSMC RasPi is not able to auto-reconnect. And with the OSMC disconnected, I cannot ssh to it, nor use the Web interface. It is disconnected from the network.

Is there some edit I need to do in the OSMC in oder to get it auto-reconnect to the wifi after a router interruption?

Are you using a fixed WiFi channel or is it set to “automatic” on the router? If the channel changes the Pi won’t reconnect because it’s using the old channel.

If you’re only using WifF, also ensure that /etc/connman.conf contains the line

PreferredTechnologies=wifi,ethernet

Otherwise, AFAIK it should try to reconnect. Here’s a quick test:

Mar 06 19:57:19 osmc-pi3 wpa_supplicant[424]: wlan0: CTRL-EVENT-DISCONNECTED bssid=xx:xx:xx:xx:xx reason=0 locally_generated=1
<snip>
Mar 06 19:57:50 osmc-pi3 wpa_supplicant[424]: wlan0: CTRL-EVENT-CONNECTED - Connection to xx:xx:xx:xx:xx completed [id=0 id_str=]

The channel on the wifi access point is fixed, and this is /etc/connman.conf:

[General]
PreferredTechnologies=ethernet,wifi
SingleConnectedTechnology=false
AllowHostnameUpdates=false
TetheringTechnologies=ethernet,wifi
PersistentTetheringMode=true
NetworkInterfaceBlacklist=vmnet,vboxnet,virbr,ifb,docker,veth

But if I switch off the Access Point, osmc won’t reconnect. I have to recycle it.

Well, you can change the line in /etc/connman.conf and see if that helps.

What does running connmanctl services wifi_xxxx_yyyy_managed_psk show? (substiude correct values for xxxx and yyyy)

I guess it could still be an issue with the configuration of your access point, since I’ve shown that it does automatically reconnect to my router.

/net/connman/service/wifi_b827eb5c7551_53616c7479646f675f31657874_managed_psk
  Type = wifi
  Security = [ psk, wps ]
  State = online
  Strength = 79
  Favorite = True
  Immutable = False
  AutoConnect = True
  Name = Saltydog_1ext
  Ethernet = [ Method=auto, Interface=wlan0, Address=B8:27:EB:5C:75:51, MTU=1500 ]
  IPv4 = [ Method=dhcp, Address=192.168.1.53, Netmask=255.255.255.0, Gateway=192.168.1.1 ]
  IPv4.Configuration = [ Method=dhcp ]
  IPv6 = [  ]
  IPv6.Configuration = [ Method=off ]
  Nameservers = [ 192.168.1.1 ]
  Nameservers.Configuration = [  ]
  Timeservers = [  ]
  Timeservers.Configuration = [  ]
  Domains = [ station ]
  Domains.Configuration = [  ]
  Proxy = [ Method=direct ]
  Proxy.Configuration = [  ]
  Provider = [  ]

It looks very similar to what I see, except for the line Domains = [ station ], which is empty for me.

Is there any chance you could try a substitude AP?

I am still struggling with this problem… Any time I reset the router, there is no way for my osmc to automatically reconnect to the LAN. The only option is to unplug it (very bad). I was trying to write a cronjob with ifup/ifdown, but the two commands are not installed in osmc

It might be an issue with the router itself. You’ve already said that you’re using a fixed channel, so it should normally just work.

We’ve seen issues with Orange routers in the past, though you seem to be on Vodafone.

Take a look at this post. You should probably be able to modify the proposed script to meet your needs, without requiring ifupdown. Run it under root (sudo crontab -e) and don’t run it from /etc/rc.local, since that only works at at OSMC startup

Hi dillthedog,

thank you for your assistance. I have just realized that my Raspi OSMC does reconnect after a router reset! It was just a matter to wait 5 or more minutes! :slight_smile: Sorry…

Is there any way to accelerate the reconnecting process?
Thanks again.

It might be that your router takes 5 minutes to start up.

You could try to shorten the delay a bit with a cron job that tries to reconnect every minute, such as the one I linked to, but TBH it doesn’t seem worth it to me. Router resets don’t happen very often, do they?

You’re right. I think I will keep things as they are.

Thank you!