forked from DGNum/liminix
add hacky wwan service with hardcoding all over
This commit is contained in:
parent
0f520ceee2
commit
fa7fde87db
2 changed files with 36 additions and 11 deletions
|
@ -31,12 +31,10 @@ in rec {
|
||||||
];
|
];
|
||||||
hostname = "thing";
|
hostname = "thing";
|
||||||
|
|
||||||
services.dhcpc =
|
services.dhcpc = svc.network.dhcp.client.build {
|
||||||
let iface = config.hardware.networkInterfaces.lan;
|
interface = config.services.wwan;
|
||||||
in svc.network.dhcp.client.build {
|
dependencies = [ config.services.hostname ];
|
||||||
interface = iface;
|
};
|
||||||
dependencies = [ config.services.hostname ];
|
|
||||||
};
|
|
||||||
|
|
||||||
services.sshd = svc.ssh.build { };
|
services.sshd = svc.ssh.build { };
|
||||||
|
|
||||||
|
@ -85,6 +83,4 @@ in rec {
|
||||||
passwd = lib.mkForce secrets.root.passwd;
|
passwd = lib.mkForce secrets.root.passwd;
|
||||||
openssh.authorizedKeys.keys = secrets.root.keys;
|
openssh.authorizedKeys.keys = secrets.root.keys;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
{ config, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
{
|
let
|
||||||
|
inherit (pkgs.liminix.services) oneshot;
|
||||||
|
svc = config.system.service;
|
||||||
|
in {
|
||||||
config = {
|
config = {
|
||||||
kernel.config = {
|
kernel.config = {
|
||||||
USB_NET_HUAWEI_CDC_NCM = "y";
|
USB_NET_HUAWEI_CDC_NCM = "y";
|
||||||
|
@ -8,6 +11,33 @@
|
||||||
USB_SERIAL_OPTION = "y";
|
USB_SERIAL_OPTION = "y";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# https://www.0xf8.org/2017/01/flashing-a-huawei-e3372h-4g-lte-stick-from-hilink-to-stick-mode/
|
||||||
|
|
||||||
|
services.wwan = let
|
||||||
|
chat = lib.escapeShellArgs [
|
||||||
|
"" "AT"
|
||||||
|
"OK" "ATZ"
|
||||||
|
"OK" "AT+CGDCONT=1,\"IP\",\"data.uk\""
|
||||||
|
"OK" "AT+CGACT=1,1"
|
||||||
|
# caret is special to chat, so needs escaping in AT commands
|
||||||
|
"OK" "AT\\^AUTHDATA=1,2,\"1p\",\"one2one\",\"user\""
|
||||||
|
"OK" "AT\\^NDISDUP=1,1" # ,\"data.uk\",\"user\",\"one2one\",2"
|
||||||
|
];
|
||||||
|
modemConfig = oneshot {
|
||||||
|
name = "modem-configure";
|
||||||
|
up = ''
|
||||||
|
sleep 2
|
||||||
|
${pkgs.usb-modeswitch}/bin/usb_modeswitch -v 12d1 -p 14fe --huawei-new-mode
|
||||||
|
sleep 5
|
||||||
|
${pkgs.ppp}/bin/chat -s -v ${chat} 0<>/dev/ttyUSB0 1>&0
|
||||||
|
'';
|
||||||
|
down = "chat -v '' ATZ OK </dev/ttyUSB0 >&0";
|
||||||
|
};
|
||||||
|
in svc.network.link.build {
|
||||||
|
ifname = "wwan0";
|
||||||
|
dependencies = [ modemConfig ];
|
||||||
|
};
|
||||||
|
|
||||||
# an ncm ethernet adaptor does
|
# an ncm ethernet adaptor does
|
||||||
# * usb modeswitch
|
# * usb modeswitch
|
||||||
# * AT commands
|
# * AT commands
|
||||||
|
@ -19,4 +49,3 @@
|
||||||
# https://stackoverflow.com/questions/5477882/how-to-i-detect-whether-a-tty-belonging-to-a-gsm-3g-modem-is-a-data-or-control-p
|
# https://stackoverflow.com/questions/5477882/how-to-i-detect-whether-a-tty-belonging-to-a-gsm-3g-modem-is-a-data-or-control-p
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue