6

This question is very much related to How to turn off Wireless power management permanently, albeit when using systemd-networkd to manage hardware.

I have a headless Raspberry Pi Model 3 connected to a printer whose only job it is to collect print jobs (CUPS) and forward them to the printer (using the AirPrint protocol mostly). Sometimes I cannot ping it. I suspect that the wireless card powers down after awhile. I can rule out connectivity issues because it is near an access point. Is there any way to influence this in my unit configuration? I could not find it documented anywhere.

wlan0.network 
[Match]
Name=wlan0

[Network]
DHCP=yes
#Domains=local

[DHCP]
RouteMetric=20

And yes, I know I can do iwconfig wlan0 power off to disable power management on the device. I just like having static configuration files:

So I am looking for an equivalent to NetworkManager's

/etc/NetworkManager/conf.d/default-wifi-powersave-on.conf

[connection]
wifi.powersave = 2
Jonathan Komar
  • 5,974
  • 7
  • 33
  • 52

1 Answers1

5

I ended up writing a parameterized unit configuration to do it.

/etc/systemd/system/[email protected]

[Unit]
Description=Keep wireless device %i from sleeping.
After=network.target

[Service]
ExecStart=/usr/sbin/iw %i set power_save off

[Install]
WantedBy=default.target

Usage

systemctl enable --now wlan-always-on@wlan0
Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
Jonathan Komar
  • 5,974
  • 7
  • 33
  • 52
  • The above answer by Jonathan Komar is right, just be sure to place the service file in the [right directory](https://www.intel.com/content/www/us/en/support/articles/000006168/boards-and-kits.html). – Zachary Puthoff Jan 02 '23 at 02:11
  • 1
    Upvoted, with a mild "yuck" aimed at systemd-networkd for not yet having a better, simpler way to do this. – hackerb9 Jul 11 '23 at 16:41
  • 1
    @ZacharyPuthoff: UNIX systems that follow the FHS (Fillesystem Hierarchy Standard) discourage local configuration changes to /lib as those files can be overwritten during system upgrades or may be mounted read-only. On Debian GNU/Linux, one would put the file in `/etc/systemd/system/[email protected]`. – hackerb9 Jul 11 '23 at 16:59