davethomaspilot
Posts: 124
Joined: Tue Apr 29, 2014 6:18 pm

Restore WiFi by editing file on SD Card?

Fri Aug 05, 2022 4:42 pm

I have a headless setup. The wireless radio is configured to be BOTH a wifi hotspot and to connect to a wifi router.

The RPI is embedded in an enclosure so that its HDMI port is not accessible. Furthermore, an application auto-starts on boot which disables ethernet (to save battery power).

I made the mistake of using the GUI to disable Wifi, thinking it would disable connecting to a router but that the hotspot (hostapd) would still be available for connection.

Is there a file that I can edit to "undo" what I did by disabling Wifi? Is it accessible if the SD card is put in a USB adapter for editing on a Windows machine? Or, a VM running Ubuntu?

Or, (thinking outside the box), is there something I can do (editing the SD card) to prevent the application from running after boot? If the app doesn't run, maybe I can to ethernet connect.

I can disassemble the enclosure, and plug a monitor into the HDMI port, a keyboard/mouse in a USB port, and get it done that way. But, I can see other users doing this and I either need a simple recovery scheme, or prevent the wifi from being disabled from the desktop.

davethomaspilot
Posts: 124
Joined: Tue Apr 29, 2014 6:18 pm

Re: Restore WiFi by editing file on SD Card?

Fri Aug 05, 2022 6:28 pm

Actually, the app also disables HDMI. So I can't plug in a display to enable WiFi.

I used a USB adapter for the SD card and plugged it into another RPI running Buster. The RPI auto-mounted the SD, file manager came up, and I was able to edit the start-up script to prevent ethernet and HDMI being disable.

Then, I plugged in a display and mouse and clicked to enable WiFi.

I'd still like to know where the state for WiFi enabled/disabled is stored.

User avatar
rpdom
Posts: 20380
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Restore WiFi by editing file on SD Card?

Fri Aug 05, 2022 6:50 pm

Check in /var/lib/systemd/rfkill. There should be a file with a name ending in ":wlan". If that file contains a "1" it disables that interface. If it has a "0", then the interface is enabled.
Unreadable squiggle

epoch1970
Posts: 7994
Joined: Thu May 05, 2016 9:33 am
Location: France

Re: Restore WiFi by editing file on SD Card?

Fri Aug 05, 2022 10:03 pm

Or add “rfkill unblock wifi” in /etc/rc.local?
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

klricks
Posts: 8429
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA

Re: Restore WiFi by editing file on SD Card?

Sat Aug 06, 2022 12:22 am

epoch1970 wrote:
Fri Aug 05, 2022 10:03 pm
Or add “rfkill unblock wifi” in /etc/rc.local?
Not needed as the rfkill settings are persistent.
Unless specified otherwise my response is based on the latest and fully updated RPi OS Bullseye w/ Desktop OS.

epoch1970
Posts: 7994
Joined: Thu May 05, 2016 9:33 am
Location: France

Re: Restore WiFi by editing file on SD Card?

Sat Aug 06, 2022 10:33 am

I meant as a one-time measure. Add the line, boot, login, remove the line, reboot.
davethomaspilot wrote:
Fri Aug 05, 2022 4:42 pm
I made the mistake of using the GUI to disable Wifi, thinking it would disable connecting to a router but that the hotspot (hostapd) would still be available for connection.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

User avatar
rpdom
Posts: 20380
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Restore WiFi by editing file on SD Card?

Sat Aug 06, 2022 10:36 am

epoch1970 wrote:
Sat Aug 06, 2022 10:33 am
I meant as a one-time measure. Add the line, boot, login, remove the line, reboot.
That's two edits and two reboots, while my option is just one of each.
Unreadable squiggle

epoch1970
Posts: 7994
Joined: Thu May 05, 2016 9:33 am
Location: France

Re: Restore WiFi by editing file on SD Card?

Sat Aug 06, 2022 10:40 am

Ok you win.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “Advanced users”