mirror of
https://github.com/sixfab/Sixfab_PPP_Installer
synced 2025-12-06 10:23:20 +00:00
changed all folder structure
This commit is contained in:
17
src/chat-connect
Normal file
17
src/chat-connect
Normal file
@@ -0,0 +1,17 @@
|
||||
# /etc/chatscripts/chat-connect
|
||||
ABORT "BUSY"
|
||||
ABORT "NO CARRIER"
|
||||
ABORT "NO DIALTONE"
|
||||
ABORT "ERROR"
|
||||
ABORT "NO ANSWER"
|
||||
TIMEOUT 30
|
||||
"" AT
|
||||
OK ATE0
|
||||
OK AT+CPIN?
|
||||
READY AT+CSQ
|
||||
OK AT+CREG?
|
||||
OK AT+CGREG?
|
||||
OK AT+COPS?
|
||||
OK AT+CGDCONT=1,"IP","\T",,0,0
|
||||
OK ATD*99#
|
||||
CONNECT
|
||||
8
src/chat-disconnect
Normal file
8
src/chat-disconnect
Normal file
@@ -0,0 +1,8 @@
|
||||
# /etc/chatscripts/chat-disconnect
|
||||
ABORT "ERROR"
|
||||
ABORT "NO DIALTONE"
|
||||
SAY "\nSending break to the modem\n"
|
||||
"" +++
|
||||
"" +++
|
||||
"" +++
|
||||
SAY "\nGoodbye\n"
|
||||
6
src/configs.sh
Normal file
6
src/configs.sh
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/bin/env bash
|
||||
|
||||
INTERVAL=60 # Seconds, Interval between two connection check of internet
|
||||
DOUBLE_CHECK_WAIT=10 # Seconds, wait time for double check when the connection is down
|
||||
PING_TIMEOUT=9 # Seconds, Timeout of ping command
|
||||
NETWORK_CHECK_TIMEOUT=300 # Count, Check network for ($NETWORK_TIMEOUT x 2 Seconds)
|
||||
43
src/functions.sh
Normal file
43
src/functions.sh
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
source configs.sh
|
||||
|
||||
function debug()
|
||||
{
|
||||
echo $(date "+%Y/%m/%d - %H:%M:%S :") "$1"
|
||||
}
|
||||
|
||||
function check_network()
|
||||
{
|
||||
# Check the network is ready
|
||||
debug "Checking the network is ready..."
|
||||
|
||||
for i in {1..$NETWORK_CHECK_TIMEOUT}; do
|
||||
NETWORK_OK=0
|
||||
|
||||
debug "SIM Status:"
|
||||
atcom AT+CPIN? OK ERROR 10 | grep "CPIN: READY"
|
||||
SIM_READY=$?
|
||||
|
||||
debug "Network Registeration Status:"
|
||||
# For super SIM
|
||||
atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,5"
|
||||
NETWORK_REG=$?
|
||||
# For native SIM
|
||||
atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,1"
|
||||
NETWORK_REG_2=$?
|
||||
# Combined network registeration status
|
||||
NETWORK_REG=$((NETWORK_REG+NETWORK_REG_2))
|
||||
|
||||
if [[ $SIM_READY -eq 0 ]] && [[ $NETWORK_REG -le 1 ]]; then
|
||||
debug "Network is ready."
|
||||
NETWORK_OK=1
|
||||
return 0
|
||||
break
|
||||
else
|
||||
printf "?"
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
return 1
|
||||
}
|
||||
36
src/provider
Normal file
36
src/provider
Normal file
@@ -0,0 +1,36 @@
|
||||
# /etc/ppp/peers/provider
|
||||
/dev/#DEVICE 115200
|
||||
# The chat script, customize your APN in this file
|
||||
connect 'chat -s -v -f /etc/chatscripts/chat-connect -T #APN'
|
||||
# The close script
|
||||
disconnect 'chat -s -v -f /etc/chatscripts/chat-disconnect'
|
||||
# Hide password in debug messages
|
||||
hide-password
|
||||
# The phone is not required to authenticate
|
||||
noauth
|
||||
persist
|
||||
# Debug info from pppd
|
||||
debug
|
||||
# If you want to use the HSDPA link as your gateway
|
||||
defaultroute
|
||||
# pppd must not propose any IP address to the peer
|
||||
noipdefault
|
||||
# No ppp compression
|
||||
novj
|
||||
novjccomp
|
||||
noccp
|
||||
ipcp-accept-local
|
||||
ipcp-accept-remote
|
||||
local
|
||||
# For sanity, keep a lock on the serial line
|
||||
lock
|
||||
modem
|
||||
dump
|
||||
updetach
|
||||
# Hardware flow control
|
||||
nocrtscts
|
||||
remotename 3gppp
|
||||
ipparam 3gppp
|
||||
ipcp-max-failure 30
|
||||
# Ask the peer for up to 2 DNS server addresses
|
||||
usepeerdns
|
||||
48
src/reconnect_scripts/reconnect_basehat
Normal file
48
src/reconnect_scripts/reconnect_basehat
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
source functions.sh
|
||||
source configs.sh
|
||||
|
||||
# Pinout for base hat
|
||||
POWER_OFF=26
|
||||
W_DISABLE=19
|
||||
|
||||
# Control pins
|
||||
gpio -g mode $POWER_OFF out #HAT_POWER_OFF
|
||||
gpio -g mode $W_DISABLE out #W_DISABLE
|
||||
|
||||
gpio -g write $POWER_OFF 0
|
||||
gpio -g write $W_DISABLE 0
|
||||
|
||||
|
||||
if check_network -eq 0; then
|
||||
debug "PPP chatscript is starting...";
|
||||
sudo pon;
|
||||
else
|
||||
debug "Network registeration is failed!";
|
||||
fi
|
||||
|
||||
while true; do
|
||||
# Checking cellular internet connection
|
||||
ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1
|
||||
PINGG=$?
|
||||
|
||||
if [[ $PINGG -eq 0 ]]; then
|
||||
printf "."
|
||||
else
|
||||
printf "/"
|
||||
sleep $DOUBLE_CHECK_WAIT
|
||||
# Checking cellular internet connection
|
||||
ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1
|
||||
PINGG=$?
|
||||
|
||||
if [[ $PINGG -eq 0 ]]; then
|
||||
printf "+"
|
||||
else
|
||||
debug "Connection is down, reconnecting..."
|
||||
if check_network -eq 0; then sleep 0.1; else debug "Network registeration is failed!"; fi
|
||||
sudo pon
|
||||
fi
|
||||
fi
|
||||
sleep $INTERVAL
|
||||
done
|
||||
36
src/reconnect_scripts/reconnect_baseshield
Executable file
36
src/reconnect_scripts/reconnect_baseshield
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
source functions.sh
|
||||
source configs.sh
|
||||
|
||||
if check_network -eq 0; then
|
||||
debug "PPP chatscript is starting...";
|
||||
sudo pon;
|
||||
else
|
||||
debug "Network registeration is failed!";
|
||||
fi
|
||||
|
||||
while true; do
|
||||
# Checking cellular internet connection
|
||||
ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1
|
||||
PINGG=$?
|
||||
|
||||
if [[ $PINGG -eq 0 ]]; then
|
||||
printf "."
|
||||
else
|
||||
printf "/"
|
||||
sleep $DOUBLE_CHECK_WAIT
|
||||
# Checking cellular internet connection
|
||||
ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1
|
||||
PINGG=$?
|
||||
|
||||
if [[ $PINGG -eq 0 ]]; then
|
||||
printf "+"
|
||||
else
|
||||
debug "Connection is down, reconnecting..."
|
||||
if check_network -eq 0; then sleep 0.1; else debug "Network registeration is failed!"; fi
|
||||
sudo pon
|
||||
fi
|
||||
fi
|
||||
sleep $INTERVAL
|
||||
done
|
||||
88
src/reconnect_scripts/reconnect_cellulariot
Normal file
88
src/reconnect_scripts/reconnect_cellulariot
Normal file
@@ -0,0 +1,88 @@
|
||||
#!/bin/bash
|
||||
|
||||
source functions.sh
|
||||
source configs.sh
|
||||
|
||||
# Pinout for cellulariot hat
|
||||
STATUS=23
|
||||
POWERKEY=24
|
||||
ENABLE=17
|
||||
|
||||
# Configure pins
|
||||
gpio -g mode $STATUS in
|
||||
gpio -g mode $POWERKEY out
|
||||
gpio -g mode $ENABLE out
|
||||
|
||||
|
||||
function power_up_module()
|
||||
{
|
||||
for i in {1..20}; do
|
||||
if [[ $(gpio -g read $STATUS) -eq 1 ]]; then
|
||||
debug "Module is powering up..."
|
||||
|
||||
gpio -g write $POWERKEY 1
|
||||
sleep 2
|
||||
gpio -g write $POWERKEY 0
|
||||
sleep 2
|
||||
|
||||
if [[ $(gpio -g read $STATUS) -eq 0 ]]; then
|
||||
debug "Module is powered up."
|
||||
return 0
|
||||
break
|
||||
else
|
||||
debug "Module couldn't be powered up!"
|
||||
sleep 2
|
||||
else
|
||||
debug "Module is just powered up."
|
||||
return 0
|
||||
break
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
function restart_power()
|
||||
{
|
||||
debug "Power of the module is restarting..."
|
||||
# Restart power
|
||||
gpio -g write $ENABLE 1 # power is disabled
|
||||
sleep 2
|
||||
gpio -g write $ENABLE 0 # power is enabled
|
||||
}
|
||||
|
||||
restart_power # Restart power
|
||||
|
||||
# Modem power up
|
||||
if power_up_module -eq 0 ; then sleep 0.1; else debug "Module couldn't be powered up! Check the hardware setup!"; fi
|
||||
|
||||
if check_network -eq 0; then
|
||||
debug "PPP chatscript is starting...";
|
||||
sudo pon;
|
||||
else
|
||||
debug "Network registeration is failed!";
|
||||
fi
|
||||
|
||||
while true; do
|
||||
# Checking cellular internet connection
|
||||
ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1
|
||||
PINGG=$?
|
||||
|
||||
if [[ $PINGG -eq 0 ]]; then
|
||||
printf "."
|
||||
else
|
||||
printf "/"
|
||||
sleep $DOUBLE_CHECK_WAIT
|
||||
# Checking cellular internet connection
|
||||
ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1
|
||||
PINGG=$?
|
||||
|
||||
if [[ $PINGG -eq 0 ]]; then
|
||||
printf "+"
|
||||
else
|
||||
debug "Connection is down, reconnecting..."
|
||||
if check_network -eq 0; then sleep 0.1; else debug "Network registeration is failed!"; fi
|
||||
sudo pon
|
||||
fi
|
||||
fi
|
||||
sleep $INTERVAL
|
||||
done
|
||||
89
src/reconnect_scripts/reconnect_cellulariot_app
Normal file
89
src/reconnect_scripts/reconnect_cellulariot_app
Normal file
@@ -0,0 +1,89 @@
|
||||
#!/bin/bash
|
||||
|
||||
source functions.sh
|
||||
source configs.sh
|
||||
|
||||
# Pinout for cellulariot app shield
|
||||
STATUS=20
|
||||
POWERKEY=11
|
||||
DISABLE=26
|
||||
|
||||
# Configure pins
|
||||
gpio -g mode $STATUS in
|
||||
gpio -g mode $POWERKEY out
|
||||
gpio -g mode $DISABLE out
|
||||
|
||||
|
||||
function power_up_module()
|
||||
{
|
||||
for i in {1..20}; do
|
||||
if [[ $(gpio -g read $STATUS) -eq 1 ]]; then
|
||||
debug "Module is powering up..."
|
||||
|
||||
gpio -g write $POWERKEY 0
|
||||
gpio -g write $POWERKEY 1
|
||||
sleep 2
|
||||
gpio -g write $POWERKEY 0
|
||||
sleep 2
|
||||
|
||||
if [[ $(gpio -g read $STATUS) -eq 0 ]]; then
|
||||
debug "Module is powered up."
|
||||
return 0
|
||||
break
|
||||
else
|
||||
debug "Module couldn't be powered up!"
|
||||
sleep 2
|
||||
else
|
||||
debug "Module is just powered up."
|
||||
return 0
|
||||
break
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
function restart_power()
|
||||
{
|
||||
debug "Power of the module is restarting..."
|
||||
# Restart power
|
||||
gpio -g write $DISABLE 0 # power is disabled
|
||||
sleep 2
|
||||
gpio -g write $DISABLE 1 # power is enabled
|
||||
}
|
||||
|
||||
restart_power # Restart power
|
||||
|
||||
# Modem power up
|
||||
if power_up_module -eq 0 ; then sleep 0.1; else debug "Module couldn't be powered up! Check the hardware setup!"; fi
|
||||
|
||||
if check_network -eq 0; then
|
||||
debug "PPP chatscript is starting...";
|
||||
sudo pon;
|
||||
else
|
||||
debug "Network registeration is failed!";
|
||||
fi
|
||||
|
||||
while true; do
|
||||
# Checking cellular internet connection
|
||||
ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1
|
||||
PINGG=$?
|
||||
|
||||
if [[ $PINGG -eq 0 ]]; then
|
||||
printf "."
|
||||
else
|
||||
printf "/"
|
||||
sleep $DOUBLE_CHECK_WAIT
|
||||
# Checking cellular internet connection
|
||||
ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1
|
||||
PINGG=$?
|
||||
|
||||
if [[ $PINGG -eq 0 ]]; then
|
||||
printf "+"
|
||||
else
|
||||
debug "Connection is down, reconnecting..."
|
||||
if check_network -eq 0; then sleep 0.1; else debug "Network registeration is failed!"; fi
|
||||
sudo pon
|
||||
fi
|
||||
fi
|
||||
sleep $INTERVAL
|
||||
done
|
||||
79
src/reconnect_scripts/reconnect_gprsshield
Normal file
79
src/reconnect_scripts/reconnect_gprsshield
Normal file
@@ -0,0 +1,79 @@
|
||||
#!/bin/bash
|
||||
|
||||
source functions.sh
|
||||
source configs.sh
|
||||
|
||||
# Pinout for cellulariot hat
|
||||
STATUS=19
|
||||
POWERKEY=26
|
||||
|
||||
|
||||
# Configure pins
|
||||
gpio -g mode $STATUS in
|
||||
gpio -g mode $POWERKEY out
|
||||
gpio -g mode $ENABLE out
|
||||
|
||||
|
||||
function power_up_module()
|
||||
{
|
||||
for i in {1..20}; do
|
||||
if [[ $(gpio -g read $STATUS) -eq 1 ]]; then
|
||||
debug "Module is powering up..."
|
||||
|
||||
gpio -g write $POWERKEY 0
|
||||
gpio -g write $POWERKEY 1
|
||||
sleep 2
|
||||
gpio -g write $POWERKEY 0
|
||||
sleep 2
|
||||
|
||||
if [[ $(gpio -g read $STATUS) -eq 0 ]]; then
|
||||
debug "Module is powered up."
|
||||
return 0
|
||||
break
|
||||
else
|
||||
debug "Module couldn't be powered up!"
|
||||
sleep 2
|
||||
else
|
||||
debug "Module is just powered up."
|
||||
return 0
|
||||
break
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
# Modem power up
|
||||
if power_up_module -eq 0 ; then sleep 0.1; else debug "Module couldn't be powered up! Check the hardware setup!"; fi
|
||||
|
||||
if check_network -eq 0; then
|
||||
debug "PPP chatscript is starting...";
|
||||
sudo pon;
|
||||
else
|
||||
debug "Network registeration is failed!";
|
||||
fi
|
||||
|
||||
while true; do
|
||||
# Checking cellular internet connection
|
||||
ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1
|
||||
PINGG=$?
|
||||
|
||||
if [[ $PINGG -eq 0 ]]; then
|
||||
printf "."
|
||||
else
|
||||
printf "/"
|
||||
sleep $DOUBLE_CHECK_WAIT
|
||||
# Checking cellular internet connection
|
||||
ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1
|
||||
PINGG=$?
|
||||
|
||||
if [[ $PINGG -eq 0 ]]; then
|
||||
printf "+"
|
||||
else
|
||||
debug "Connection is down, reconnecting..."
|
||||
if check_network -eq 0; then sleep 0.1; else debug "Network registeration is failed!"; fi
|
||||
sudo pon
|
||||
fi
|
||||
fi
|
||||
sleep $INTERVAL
|
||||
done
|
||||
37
src/reconnect_scripts/reconnect_test.sh
Normal file
37
src/reconnect_scripts/reconnect_test.sh
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
source functions.sh
|
||||
source configs.sh
|
||||
|
||||
|
||||
if check_network -eq 0; then
|
||||
debug "PPP chatscript is starting...";
|
||||
sudo pon;
|
||||
else
|
||||
debug "Network registeration is failed!";
|
||||
fi
|
||||
|
||||
while true; do
|
||||
# Checking cellular internet connection
|
||||
ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1
|
||||
PINGG=$?
|
||||
|
||||
if [[ $PINGG -eq 0 ]]; then
|
||||
printf "."
|
||||
else
|
||||
printf "/"
|
||||
sleep $DOUBLE_CHECK_WAIT
|
||||
# Checking cellular internet connection
|
||||
ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1
|
||||
PINGG=$?
|
||||
|
||||
if [[ $PINGG -eq 0 ]]; then
|
||||
printf "+"
|
||||
else
|
||||
debug "Connection is down, reconnecting..."
|
||||
if check_network -eq 0; then sleep 0.1; else debug "Network registeration is failed!"; fi
|
||||
sudo pon
|
||||
fi
|
||||
fi
|
||||
sleep $INTERVAL
|
||||
done
|
||||
90
src/reconnect_scripts/reconnect_tracker
Normal file
90
src/reconnect_scripts/reconnect_tracker
Normal file
@@ -0,0 +1,90 @@
|
||||
#!/bin/bash
|
||||
|
||||
source functions.sh
|
||||
source configs.sh
|
||||
|
||||
# Pinout for cellulariot app shield
|
||||
STATUS=23
|
||||
POWERKEY=24
|
||||
DISABLE=17
|
||||
|
||||
# Configure pins
|
||||
gpio -g mode $STATUS in
|
||||
gpio -g mode $POWERKEY out
|
||||
gpio -g mode $DISABLE out
|
||||
|
||||
|
||||
function power_up_module()
|
||||
{
|
||||
for i in {1..20}; do
|
||||
if [[ $(gpio -g read $STATUS) -eq 1 ]]; then
|
||||
debug "Module is powering up..."
|
||||
|
||||
gpio -g write $POWERKEY 0
|
||||
gpio -g write $POWERKEY 1
|
||||
sleep 2
|
||||
gpio -g write $POWERKEY 0
|
||||
sleep 2
|
||||
|
||||
if [[ $(gpio -g read $STATUS) -eq 0 ]]; then
|
||||
debug "Module is powered up."
|
||||
return 0
|
||||
break
|
||||
else
|
||||
debug "Module couldn't be powered up!"
|
||||
sleep 2
|
||||
else
|
||||
debug "Module is just powered up."
|
||||
return 0
|
||||
break
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
function restart_power()
|
||||
{
|
||||
debug "Power of the module is restarting..."
|
||||
# Restart power
|
||||
gpio -g write $DISABLE 0 # power is disabled
|
||||
sleep 2
|
||||
gpio -g write $DISABLE 1 # power is enabled
|
||||
}
|
||||
|
||||
restart_power # Restart power
|
||||
|
||||
# Modem power up
|
||||
if power_up_module -eq 0 ; then sleep 0.1; else debug "Module couldn't be powered up! Check the hardware setup!"; fi
|
||||
|
||||
if check_network -eq 0; then
|
||||
debug "PPP chatscript is starting...";
|
||||
sudo pon;
|
||||
else
|
||||
debug "Network registeration is failed!";
|
||||
fi
|
||||
|
||||
while true; do
|
||||
# Checking cellular internet connection
|
||||
ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1
|
||||
PINGG=$?
|
||||
|
||||
if [[ $PINGG -eq 0 ]]; then
|
||||
printf "."
|
||||
else
|
||||
printf "/"
|
||||
sleep $DOUBLE_CHECK_WAIT
|
||||
# Checking cellular internet connection
|
||||
ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1
|
||||
PINGG=$?
|
||||
|
||||
if [[ $PINGG -eq 0 ]]; then
|
||||
printf "+"
|
||||
else
|
||||
debug "Connection is down, reconnecting..."
|
||||
if check_network -eq 0; then sleep 0.1; else debug "Network registeration is failed!"; fi
|
||||
sudo pon
|
||||
fi
|
||||
fi
|
||||
sleep $INTERVAL
|
||||
done
|
||||
|
||||
13
src/reconnect_service
Normal file
13
src/reconnect_service
Normal file
@@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=PPP Auto Connection
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/bash reconnect.sh
|
||||
WorkingDirectory=/opt/sixfab/ppp_connection_manager
|
||||
StandardOutput=inherit
|
||||
StandardError=inherit
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user