Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Config
Commits
433e4975
Commit
433e4975
authored
May 31, 2018
by
igorpecovnik
Browse files
Add support for managing LTE modem connection. Only one configuration enabled for now
parent
c15c303a
Changes
3
Show whitespace changes
Inline
Side-by-side
debian-config-functions-network
View file @
433e4975
...
@@ -7,6 +7,8 @@
...
@@ -7,6 +7,8 @@
# warranty of any kind, whether express or implied.
# warranty of any kind, whether express or implied.
# Functions:
# Functions:
# initialize_lte
# function lte
# check_hostapd
# check_hostapd
# check_advanced_modes
# check_advanced_modes
# create_if_config
# create_if_config
...
@@ -27,6 +29,124 @@
...
@@ -27,6 +29,124 @@
# connect_bt_interface
# connect_bt_interface
#
# 3G/4G general stuff
#
function
initialize_lte
()
{
# This file defines udev rules for some 3G/UMTS/LTE modems. It
# addresses the issue that the ttyUSB devices are numbered randomly, and
# their numbering can vary between server reboots. These rules create
# persistent symlinks which can be reliably used in WWAN interface
# startup scripts.
# These rules assume that there is only one WWAN modem in the system. In
# order to address multiple WWAN cards, the rules need to be more
# specific and associate with serial numbers of the modems.
# Copyright (c) 2016 Stanislav Sinyagin <ssinyagin@k-open.com>.
# This content is published under Creative Commons Attribution 4.0
# International (CC BY 4.0) lincense.
# Source repository: https://github.com/ssinyagin/wwan_udev_rules
if
!
check_if_installed ppp
then
;
then
apt-get
-y
-qq
install
ppp
>
/dev/null 2>&1
fi
cat
>
/etc/udev/rules.d/99-wwan.rules
<<
'
EOT
'
# Source repository: https://github.com/ssinyagin/wwan_udev_rules
# Huawei ME909s-120 LTE modem
SUBSYSTEM=="tty", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="15c1", SYMLINK+="ttyWWAN%E{ID_USB_INTERFACE_NUM}"
SUBSYSTEM=="net", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="15c1", NAME="lte0"
# Huawei MU709s-2 UMTS modem
SUBSYSTEM=="tty", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1c25", SYMLINK+="ttyWWAN%E{ID_USB_INTERFACE_NUM}"
SUBSYSTEM=="net", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1c25", NAME="umts0"
# Qualcomm Gobi2000
SUBSYSTEM=="tty", ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="251d", SYMLINK+="ttyWWAN%E{ID_USB_INTERFACE_NUM}"
# Sierra Wireless MC8775
SUBSYSTEM=="tty", ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1e1d", SYMLINK+="ttyWWAN%E{.ID_PORT}"
# Novatel Wireless, Inc. Expedite E371
SUBSYSTEM=="tty", ATTRS{idVendor}=="413c", ATTRS{idProduct}=="819b", SYMLINK+="ttyWWAN%E{ID_USB_INTERFACE_NUM}"
# SIMCom SIM7100
SUBSYSTEM=="tty", ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9001", SYMLINK+="ttyWWAN%E{ID_USB_INTERFACE_NUM}"
SUBSYSTEM=="net", ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9001", NAME="lte0"
EOT
# reload udev rules
udevadm control
--reload-rules
&&
udevadm trigger
}
#
# 3G/4G init scripts add + remove
#
function
lte
()
{
case
$1
in
"12d1:15c1"
)
# Huawei ME909s-120 LTE modem
LTE_MODEM_ID
=
$1
if
[[
$2
==
on
&&
$(
cat
/sys/class/net/lte0/operstate
)
==
"up"
]]
;
then
show_box
"Warning"
"Huawei ME909s-120 LTE modem is up and running"
7
elif
[[
$2
==
on
]]
;
then
show_box
"Info"
"Huawei ME909s-120 LTE modem will try to connect"
7
cat
>
/etc/chatscripts/sunrise.HUAWEI
<<
'
EOT
'
ABORT BUSY
ABORT 'NO CARRIER'
ABORT ERROR
TIMEOUT 10
'' ATZ
OK 'AT+CFUN=1'
OK 'AT+CMEE=1'
OK 'AT
\^
NDISDUP=1,1,"internet"'
OK
EOT
cat
>
/etc/chatscripts/gsm_off.HUAWEI
<<
'
EOT
'
ABORT ERROR
TIMEOUT 5
'' AT+CFUN=0 OK
EOT
cat
>
/etc/network/interfaces.d/lte0
<<
'
EOT
'
allow-hotplug lte0
iface lte0 inet dhcp
pre-up /usr/sbin/chat -v -f /etc/chatscripts/sunrise.HUAWEI >/dev/ttyWWAN02 </dev/ttyWWAN02
post-down /usr/sbin/chat -v -f /etc/chatscripts/gsm_off.HUAWEI >/dev/ttyWWAN02 </dev/ttyWWAN02
EOT
# disable interface
ifup lte0 2> /dev/null
elif
[[
$2
==
off
]]
;
then
show_box
"Warning"
"Huawei ME909s-120 LTE will kill connection"
7
# enable interface
ifdown lte0 2> /dev/null
rm
/etc/chatscripts/sunrise.HUAWEI
rm
/etc/chatscripts/gsm_off.HUAWEI
rm
/etc/network/interfaces.d/lte0
elif
[[
$(
cat
/sys/class/net/lte0/operstate
)
==
"up"
]]
;
then
LTE_MODEM
=
"Huawei ME909s-120 LTE modem is online"
else
LTE_MODEM
=
"Huawei ME909s-120 LTE modem is offline"
fi
;;
esac
}
#
#
# check hostapd configuration. Return error or empty if o.k.
# check hostapd configuration. Return error or empty if o.k.
#
#
...
...
debian-config-jobs
View file @
433e4975
#!/bin/bash
#!/bin/bash
#
#
#
# Copyright (c) 2017 Igor Pecovnik, igor.pecovnik@gma**.com
# Copyright (c) 2017 Igor Pecovnik, igor.pecovnik@gma**.com
#
#
# This file is licensed under the terms of the GNU General Public
# This file is licensed under the terms of the GNU General Public
...
@@ -279,6 +280,19 @@ function jobs ()
...
@@ -279,6 +280,19 @@ function jobs ()
;;
;;
# Connect to 3G/4G network
#
"LTE"
)
if
[[
$LTE_MODEM
==
*
online
*
]]
;
then
dialog
--title
" LTE modem is connected "
--colors
--backtitle
"
$BACKTITLE
"
--yes-label
"Back"
--no-label
"Disconnect"
--yesno
"
\n\Z
1Disconnect:
\Z
0 kill mobile connection
\n\n
"
7 42
[[
$?
=
1
]]
&&
lte
"
$LTE_MODEM_ID
"
"off"
else
dialog
--title
" LTE modem is disconnected "
--colors
--backtitle
"
$BACKTITLE
"
--yes-label
"Back"
--no-label
"Connect"
--yesno
"
\n\Z
1Connect:
\Z
0 dial mobile connection
\n\n
"
7 42
[[
$?
=
1
]]
&&
lte
"
$LTE_MODEM_ID
"
"on"
fi
;;
# Connect to wireless access point
# Connect to wireless access point
#
#
"Clear"
)
"Clear"
)
...
...
debian-config-submenu
View file @
433e4975
...
@@ -141,6 +141,9 @@ while true; do
...
@@ -141,6 +141,9 @@ while true; do
DIALOG_CANCEL
=
1
DIALOG_CANCEL
=
1
DIALOG_ESC
=
255
DIALOG_ESC
=
255
# check if we have some LTE modems
for
i
in
$(
lsusb |
awk
'{print $6}'
)
;
do
lte
"
$i
"
;
done
;
# edit ip
# edit ip
LIST+
=(
"IP"
"Select dynamic or edit static IP address"
)
LIST+
=(
"IP"
"Select dynamic or edit static IP address"
)
...
@@ -171,6 +174,13 @@ while true; do
...
@@ -171,6 +174,13 @@ while true; do
else
else
LIST+
=(
"Clear"
"Clear possible blocked interfaces"
)
LIST+
=(
"Clear"
"Clear possible blocked interfaces"
)
fi
fi
if
[[
-n
$LTE_MODEM
]]
;
then
# apply udev rules
initialize_lte
LIST+
=(
"LTE"
"
$LTE_MODEM
"
)
fi
check_if_installed lirc
&&
LIST+
=(
"Remove IR"
"Remove IR support"
)
||
LIST+
=(
"IR"
"Install IR support"
)
check_if_installed lirc
&&
LIST+
=(
"Remove IR"
"Remove IR support"
)
||
LIST+
=(
"IR"
"Install IR support"
)
if
check_if_installed bluetooth
then
;
then
if
check_if_installed bluetooth
then
;
then
LIST+
=(
"BT remove"
"Remove Bluetooth support"
)
LIST+
=(
"BT remove"
"Remove Bluetooth support"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment