mobile-linux-push-notifications: formatting fixes

This commit is contained in:
Colin 2023-12-09 13:57:41 +00:00
parent ac0314672e
commit 9c41d1dacb
1 changed files with 7 additions and 3 deletions

View File

@ -36,11 +36,15 @@ for that, things diverge quickly from any sort of standard.
but `wol` actually just sends out an ordinary UDP packet with a specific payload, so getting from there to "wake on TCP traffic sent to port 22", or "wake on TCP traffic sent from IP foo" shouldn't be _technically_ difficult.
the Pinephone's Realtek WiFi chip exposes a programmable pattern-matching facility. just give it a byte string and a mask, and it'll wake on any packet whose bytes within the masked regions match those within the byte string.
for example, [IPv4][ipv4-header] [TCP][tcp-header] packets specify their destination port at bytes 37-38. it's easy to tell the WiFi chip to "wake on any TCP packet sent to port 22": `sudo iwpriv wlan0 wow_set_pattern pattern=-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:00:16` (fields are hexadecimal, `:` indicates byte boundaries, `-` indicates "i don't care what value this byte is set to").
for example, [IPv4][ipv4-header] [TCP][tcp-header] packets specify their destination port at bytes 37-38. it's easy to tell the WiFi chip to "wake on any TCP packet sent to port 22". run this command before the `rtcwake` call, then try `ssh`ing into your phone while it's asleep:
do this before the `rtcwake` call, then try `ssh`ing into your phone while it's asleep: with any luck it should wake!
```sh
sudo iwpriv wlan0 wow_set_pattern pattern=-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:00:16
```
figuring out the byte pattern which achieves what you want is painful, so i've got a script for that [here][wowlan-script] ([mirrored][wowlan-script-mirror]). equivalent to the above is `rtl8723cs-wowlan tcp --dest-port 22`. if you have a chat application which is talking over https, you might try `rtl8723cs-wowlan tcp --source-port 443` and see that the phone wakes every time you get a message. but then you'll get spurious wakes if you leave a web browser open, etc. you could use `lsof -i4` to locate the local port(s) your IM app is using and wake more specifically on those. but you'll still hit limits with this approach, especially if you're using a chatty protocol like Matrix, or if you idle in a bunch of channels configured to notify you only on @mention.
with any luck, it should wake!
the fields there are hexadecimal, `:` indicates byte boundaries, `-` indicates "i don't care what value this byte is set to". but figuring out the byte pattern which achieves what you want is painful, so i've got a script for that [here][wowlan-script] ([mirrored][wowlan-script-mirror]). equivalent to the above is `rtl8723cs-wowlan tcp --dest-port 22`. if you have a chat application which is talking over https, you might try `rtl8723cs-wowlan tcp --source-port 443` and see that the phone wakes every time you get a message. but then you'll get spurious wakes if you leave a web browser open, etc. you could use `lsof -i4` to locate the local port(s) your IM app is using and wake more specifically on those. but you'll still hit limits with this approach, especially if you're using a chatty protocol like Matrix, or if you idle in a bunch of channels configured to notify you only on @mention.
enter... notification servers!