summaryrefslogtreecommitdiffstats
path: root/tv/2configs/ppp.nix
blob: ecb17c3f860ed5178f0c5ffbd596125a32f16d0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{ pkgs, ... }: let
  lib = import <stockholm/lib>;
  cfg = {
    pin = "@${toString <secrets/o2.pin>}";
    ttys.ppp = "/dev/ttyACM0";
  };
in {
  environment.etc."ppp/peers/o2".text = /* sh */ ''
    ${cfg.ttys.ppp}
    921600
    crtscts
    defaultroute
    holdoff 10
    lock
    maxfail 0
    noauth
    nodetach
    noipdefault
    passive
    persist
    usepeerdns
    connect "${pkgs.ppp}/bin/chat ''${DEBUG+-v} -Ss -f ${pkgs.writeText "o2.chat" /* sh */ ''
      ABORT "BUSY"
      ABORT "NO CARRIER"
      REPORT CONNECT
      "*EMRDY: 1"
      ATZ OK
      AT+CFUN=1 OK
      ${cfg.pin} TIMEOUT 2 ERROR-AT-OK
      AT+CGDCONT=1,\042IP\042,\042internet\042 OK
      ATDT*99***1# CONNECT
    ''}"
  '';
}