Add our custom scripts
This commit is contained in:
parent
399d238ffb
commit
8b7c1ec8ef
6 changed files with 80 additions and 0 deletions
14
files/etc/init.d/wwan_loop
Executable file
14
files/etc/init.d/wwan_loop
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
USE_PROCD=1
|
||||
START=99
|
||||
STOP=01
|
||||
|
||||
start_service() {
|
||||
procd_open_instance
|
||||
procd_set_param command /usr/sbin/wwan_loop.sh
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
procd_close_instance
|
||||
}
|
||||
|
13
files/usr/sbin/get_lcid
Executable file
13
files/usr/sbin/get_lcid
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
rm -f /tmp/logread.txt
|
||||
|
||||
logread -f > /tmp/logread.txt &
|
||||
LOGREAD_PID=$!
|
||||
|
||||
mmcli -m 0 --command="AT+CREG?" > /dev/null
|
||||
kill -9 ${LOGREAD_PID}
|
||||
|
||||
ATRES=$(grep -Eo '\+CREG: [0-9],[0-9],"[0-9A-F]+","[0-9A-F]+"' /tmp/logread.txt)
|
||||
rm -f /tmp/logread.txt
|
||||
|
||||
echo $ATRES | cut -d, -f4 | grep -Eo '[0-9A-F]+'
|
23
files/usr/sbin/promsignal
Executable file
23
files/usr/sbin/promsignal
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Global Configuration
|
||||
mmcli -m 0 --signal-setup=10 2>&1 1>/dev/null
|
||||
|
||||
# Fetch & parse signal from MM
|
||||
RES=$(mmcli -m 0 --signal-get -K)
|
||||
RSRQ=$(echo -en "$RES" | grep modem.signal.lte.rsrq | grep -Eo "\-?[0-9]*.[0-9]*$")
|
||||
RSRP=$(echo -en "$RES" | grep modem.signal.lte.rsrp | grep -Eo "\-?[0-9]*.[0-9]*$")
|
||||
SNR=$(echo -en "$RES" | grep modem.signal.lte.snr | grep -Eo "\-?[0-9]*.[0-9]*$")
|
||||
|
||||
# Run AT Command to get LCID not reported by MM
|
||||
rm -f /tmp/logread.txt
|
||||
logread -f > /tmp/logread.txt &
|
||||
LOGREAD_PID=$!
|
||||
mmcli -m 0 --command="AT+CREG?" > /dev/null
|
||||
kill -9 ${LOGREAD_PID}
|
||||
ATRES=$(grep -Eo '\+CREG: [0-9],[0-9],"[0-9A-F]+","[0-9A-F]+"' /tmp/logread.txt)
|
||||
rm -f /tmp/logread.txt
|
||||
LCID=$(echo $ATRES | cut -d, -f4 | grep -Eo '[0-9A-F]+')
|
||||
|
||||
# Display parsed data
|
||||
echo "rsrq=$RSRQ, rsrp=$RSRP, snr=$SNR, lcid=$LCID"
|
3
files/usr/sbin/wwan_loop
Executable file
3
files/usr/sbin/wwan_loop
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
mmcli --modem 0 --monitor-state | while read r ; do /usr/sbin/wwan0_reconnect ; done
|
14
files/usr/sbin/wwan_reconnect
Executable file
14
files/usr/sbin/wwan_reconnect
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh
|
||||
|
||||
MODEM_STATE=$(mmcli --modem 0 --output-keyvalue|grep "modem.generic.state"|grep -o "\w*$")
|
||||
BEARER=$(mmcli --modem 0 --output-keyvalue|grep 'modem.generic.bearers.value\[1\]'|grep -o '\d*$')
|
||||
BEARER_CONNECTED=$(mmcli -b $BEARER --output-keyvalue|grep bearer.status.connected|grep -o "\w*$")
|
||||
echo "(modem state: $MODEM_STATE, bearer connected: $BEARER_CONNECTED, bearer id: $BEARER)"
|
||||
|
||||
if [[ $MODEM_STATE == 'registered' ]] ; then
|
||||
echo "trigger simple-connect"
|
||||
ifup broadband
|
||||
sleep 600 # prevent loops
|
||||
else
|
||||
echo "do nothing"
|
||||
fi
|
13
files/usr/sbin/wwan_traffic
Executable file
13
files/usr/sbin/wwan_traffic
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/lua
|
||||
|
||||
local filesize = require "filesize"
|
||||
local rxfile = io.open("/sys/class/net/wwan0/statistics/rx_bytes", "r")
|
||||
local txfile = io.open("/sys/class/net/wwan0/statistics/tx_bytes", "r")
|
||||
|
||||
local rx = filesize(tonumber(rxfile:read("*all")))
|
||||
local tx = filesize(tonumber(txfile:read("*all")))
|
||||
|
||||
print("RX:", rx, "TX:",tx)
|
||||
|
||||
rxfile:close()
|
||||
txfile:close()
|
Loading…
Reference in a new issue