summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2020-10-03 12:22:44 +0200
committertv <tv@krebsco.de>2020-10-03 13:14:11 +0200
commit3f6a68eab4b49f16daf8373ee5d99b8ffd55a119 (patch)
tree1ab7a2df03775957bec439a7c08ddd9343396ee8
parent64a9aeed2298295d204efd05b321dea271ecdb2a (diff)
tv ppp: add modem-send script
-rw-r--r--tv/2configs/ppp.nix12
1 files changed, 12 insertions, 0 deletions
diff --git a/tv/2configs/ppp.nix b/tv/2configs/ppp.nix
index 0c74e164..8c1dc65b 100644
--- a/tv/2configs/ppp.nix
+++ b/tv/2configs/ppp.nix
@@ -3,6 +3,7 @@
cfg = {
pin = "@${toString <secrets/o2.pin>}";
ttys.ppp = "/dev/ttyACM0";
+ ttys.com = "/dev/ttyACM1";
};
in {
environment.etc."ppp/peers/o2".text = /* sh */ ''
@@ -56,5 +57,16 @@ in {
exit 1
esac
'')
+ (pkgs.writeDashBin "modem-send" ''
+ # usage: modem-send ATCOMMAND
+ set -efu
+ tty=${lib.shell.escape cfg.ttys.com}
+ exec <"$tty"
+ printf '%s\r\n' "$1" >"$tty"
+ ${pkgs.gnused}/bin/sed -E '
+ /^OK\r?$/q
+ /^ERROR\r?$/q
+ '
+ '')
];
}