-
Notifications
You must be signed in to change notification settings - Fork 1.3k
shared-module/usb_hid: allow HID to wake sleeping host computer #8830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
A few |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment request. Thanks for doing this!
@tannewt I added documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! You'll want to merge to get the file size reductions.
@dhalbert Is there any documentation on how to use this new wakeup feature in python? |
It should "just work". If the HID device sends a report (e.g. a key press) to the host, the host should wake up. This is how a keypress on your regular keyboard works. |
I see, thanks! I tested on a Mac and a keypress does in fact wake it up. Side-note: I'm using a Pico W for this project. My current problem is with waking a Linux host. I've tried the solution explained in the SO post:
Unfortunately this doesn't seem to wake up the host. I've confirmed One interesting observation I've made is that when I do put the Linux host to sleep (suspend), the webserver on the Pico is much slower to respond than when I tested it on a Macbook that is in sleep mode. With the macbook it responds in less than a second and wakes up the computer. With the linux laptop it does eventually give a successful HTTP respond after a couple seconds, verifying the keypress was sent. However it doesn't seem to wake up the laptop. When the laptop is already fully awake, the response time is much quicker. I wonder if that has anything to do with it? Perhaps the pico has some kind of low power state that makes it work differently? |
Update: It looks like it was just a matter of getting the devpath correct in the udev rule. I figured out a more rubust way to set the
The |
I see it's possible to use wildcards in udev rules: https://unix.stackexchange.com/questions/752425/writing-udev-rules-wildcards, so you could wildcard the |
Thanks very much to @meesokim for code to enable
usb_hid
to wake a sleeping host computer, and to @hathach for implementing this ability in TinyUSB in the past.Tested successfully with MacroPad RP2040, Feather nRF52840, and Circuit Playground Express on Windows and macOS.
On Linux not all HID devices are automatically enabled to do wakeup. See @hathach's comment. See also https://askubuntu.com/questions/848698/wake-up-from-suspend-using-wireless-usb-keyboard-or-mouse-for-any-linux-distro/874701 for details on how to change these settings. I would have thought there was an easier way, and maybe there is for some Linux distributions.
For example on my Linux box, by default only my primary keyboard is enabled for wakeup. This is a nuisance and will mean that people using, say, a MacroPad on Linux will need to adjust these settings if they want the MacroPad to be able to initiate wakeup.