Report comment

Graeme! UPDATE! Progress, getting closer now to 100%! I did email you yesterday, but last night tried a couple new things and here's what we've got-

After editing crontab as shown, the command not found errors are gone and now we're down to what's probably the final step of this- connectivity problems.

# For more information ...
#

SHELL=/bin/sh
PATH=/usr/local/sbin:usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow command
*/3 * * * * /usr/bin/autohotspot > /home/pi/cron.log 2>&1


In network/interfaces, when wpa-conf is commented, home router connectivity is unreliable upon boot. It is uncommented per your suggestion to Susan on May 28, yielding quicker results in connecting to the home router at time of boot.

Cold boot with home router available, after waiting for cron to execute autohotspot, cron.log indicates "Selected interface 'p2p-dev-wlan0'" and "Wifi already connected to network." Pings to the home router via root console result "connect: Network is unreachable". dnsmasq and hostapd are stopped. Manually running autohotspot echoes same two lines as is in cron.log.

While still booted, when power is removed from home router and after waiting for cron to run autohotspot, the Pi3 successfully starts the hotspot (this is a substantial improvement). It issues an ip within the range specified, is open to ssh and seems to work fine, dnsmasq and hostapd are running. cron.log reads "Cleaninf wifi files and Activating hotspot", "Selected interface 'p2p-dev-wlan0'" and "OK". Manually running autohotspot echoes "Hotspot already active"

While still booted, yet, when power is applied to the home router and after waiting for cron to run autohotspot, the Pi3 successfully stops the hotspot. cron.log reads "Hotspot already active" even though it is no longer transmitting. Suspecting this anomaly to be due to two factors -- the router's boot time and the cron timer cycle -- I waited longer, and after manually running autohotspot it echoed:
Active: active (running) since ..
Shutting Down Hotspot
Hotspot Deactivated, Bringing Wifi Up
Failed to connect to non-global ctrl_ifname: (nil) error: No such file or directory
Wifi failed to connect, Creating Hotspot again
Failed to connect to non-global ctrl_ifname: (nil) error: No such file or directory

But the hotspot was not active, wlan0 not connected to anything either, indicated by no hotspot and failed pings to the home router via root console.


At this point it seems the Pi hung, because when power is again removed from the home router (Pi has remained booted), after a 10-minute wait the hotspot is not automatically started. Manually running autohotspot echoes:
command failed: Device or resource busy (-16)
Failed to connect to non-global ctrl_ifname: (nil) error: No such file or directory
RTNETLINK answers: File exists

Rebooting the Pi, while home router remains unavailable, results in a fully-functional hotspot.

While the Pi remains booted with working hotspot and power is re-applied to the home router, the hotspot is stopped and cron.log reads "command failed: Invalid exchange (-52)" and "Hotspot already active". Manually running autohotspot echoes:
Active: active (running) since ..
Shutting Down Hotspot
Hotspot Deactivated, Bringing Wifi Up
Wifi connection ok
Wifi connection established...

Yet I cannot ping the home router or google via root console, nor is ssh available.

Having said all this, the environment and/or permissions seem to have been resolved by the edit to crontab. Maybe there's a more appropriate way to have fixed it?

Additionally, and the current problem: no network connection while connected to the home router, and connection(s) to the home router seem to cause problems for the script. How can we fix that? Once fixed, for improving upon your script, I recommend modifying autohotspot to do this:

- Known SSID available?
- Wait 60 seconds # this will give time for the router to reboot or for the Pi to be carried out of fringe reception and closer to the router, as would be in the case of coming home with it
- Verify known SSID remains available
- Kill hotspot
- Connect to home router
- Wait 10 seconds #maybe a little longer?
- Determine gateway (router) ip
- Ping the router
- Success? Ok. No success? Loop once or fallback to hotspot for x minutes before retrying,