Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Problem: Losing wifi at power glitch
#12
I suppose we could simply bump the number of retries. Under normal circumstances bumping it to lets say 10 it won't have any effect because Routers usually hand out an IP address almost immediately.

Anyway here's the function.

Code:
function waitForIpAddr($iface, $maxloops = 3, $sleeptime = 3000000) {
    for ($i = 0; $i < $maxloops; $i++) {
        $ipaddr = sysCmd('ip addr list ' . $iface . " | grep \"inet \" |cut -d' ' -f6|cut -d/ -f1");
        if (!empty($ipaddr[0])) {
            break;
        }
        else {
            workerLog('worker: ' . $iface .' wait '. $i . ' for IP address');
            usleep($sleeptime);
        }
    }

    return $ipaddr;
}
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply


Messages In This Thread
Losing wifi at power glitch - by malcolmwa - 09-26-2021, 11:41 PM
RE: Losing wifi at power glitch - by DRONE7 - 09-27-2021, 12:34 AM
RE: Losing wifi at power glitch - by malcolmwa - 09-27-2021, 03:46 AM
RE: Losing wifi at power glitch - by DRONE7 - 09-27-2021, 08:31 AM
RE: Losing wifi at power glitch - by malcolmwa - 09-27-2021, 03:31 PM
RE: Losing wifi at power glitch - by DRONE7 - 09-27-2021, 06:08 PM
RE: Losing wifi at power glitch - by malcolmwa - 09-27-2021, 06:33 PM
RE: Losing wifi at power glitch - by DRONE7 - 09-27-2021, 09:03 PM
RE: Losing wifi at power glitch - by Tim Curtis - 09-27-2021, 11:18 PM
RE: Losing wifi at power glitch - by Tim Curtis - 09-27-2021, 11:41 PM
RE: Losing wifi at power glitch - by malcolmwa - 09-28-2021, 04:58 AM
RE: Losing wifi at power glitch - by Tim Curtis - 09-28-2021, 10:30 AM
RE: Losing wifi at power glitch - by Tim Curtis - 09-28-2021, 12:26 PM
RE: Losing wifi at power glitch - by malcolmwa - 09-28-2021, 03:43 PM

Forum Jump: