mirror of
https://github.com/sixfab/Sixfab_PPP_Installer
synced 2024-12-23 09:47:36 +00:00
Merge branch 'feat/change-branch-name'
This commit is contained in:
commit
b0d4262d0f
34
README.md
34
README.md
@ -19,6 +19,24 @@ Each of these shield can be connected to Internet via PPP(Point to Point Protoco
|
||||
|
||||
Without further ado let us jump into the installation process:
|
||||
|
||||
There are two method to installation.
|
||||
1. Standalone installation
|
||||
2. Installation by using repository
|
||||
|
||||
You can choose one of them and go on the installation.
|
||||
|
||||
## Standalone Installation
|
||||
|
||||
All source files are downloded from internet in this method. It is enough to download **ppp_install_standalone.sh** and run it.
|
||||
|
||||
```
|
||||
wget https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_install_standalone.sh
|
||||
sudo chmod +x ppp_install_standalone.sh
|
||||
sudo ./ppp_install_standalone.sh
|
||||
```
|
||||
|
||||
## Installation by using repository
|
||||
|
||||
Clone the repository
|
||||
|
||||
`git clone https://github.com/sixfab/Sixfab_PPP_Installer.git`
|
||||
@ -26,14 +44,16 @@ Clone the repository
|
||||
Now change the permission of the downloaded script.
|
||||
|
||||
```
|
||||
cd Sixfab_PPP_Installer/ppp_installer
|
||||
chmod +x install.sh
|
||||
cd Sixfab_PPP_Installer
|
||||
chmod +x ppp_install.sh
|
||||
```
|
||||
|
||||
Now install the script
|
||||
|
||||
`sudo ./install.sh`
|
||||
|
||||
`sudo ./ppp_install.sh`
|
||||
|
||||
|
||||
## After running installation script
|
||||
It will ask several questions, just answer them accordingly to complete the installation process. The questions are:
|
||||
`Please choose your Sixfab Shield/HAT`
|
||||
|
||||
@ -43,7 +63,7 @@ Then it installs ppp.
|
||||
|
||||
`What is your carrier APN?`
|
||||
|
||||
Here, it asks for your carrier's APN. For me it is hologram.
|
||||
Here, it asks for your carrier's APN. For me it is `super`. Because I use Sixfab SIM. Please search it on documentations of your SIM provider . You can reach the information by using `WHAT IS [YOUR PROVIDER NAME]'s APN` keywords probably.
|
||||
|
||||
`Does your carrier need username and password? [Y/n]`
|
||||
|
||||
@ -55,11 +75,9 @@ If yes then it will ask for user name.
|
||||
`Enter password`
|
||||
Then it will ask for password.
|
||||
|
||||
Once you type the username asks for password.
|
||||
|
||||
`What is your device communication PORT? (ttyS0/ttyUSB3/etc.`
|
||||
|
||||
In this step you will enter your PORT. e.g For 3G, 4G/LTE Base Shield it will be ttyUSB3.
|
||||
In this step you will enter your PORT. e.g For 3G, 4G/LTE Base Shield it will be ttyUSB3.
|
||||
|
||||
`Do you want to activate auto connect/reconnect service at R.Pi boot up?`
|
||||
|
||||
|
305
ppp_install.sh
Executable file
305
ppp_install.sh
Executable file
@ -0,0 +1,305 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Created on November 27, 2020 by Yasin Kaya (selengalp)
|
||||
|
||||
SIXFAB_PATH="/opt/sixfab"
|
||||
PPP_PATH="/opt/sixfab/ppp_connection_manager"
|
||||
|
||||
REPO_PATH="https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer"
|
||||
BRANCH=master
|
||||
SOURCE_PATH="./src"
|
||||
SCRIPT_PATH="./src/reconnect_scripts"
|
||||
RECONNECT_SCRIPT_NAME="ppp_reconnect.sh"
|
||||
MANAGER_SCRIPT_NAME="ppp_connection_manager.sh"
|
||||
SERVICE_NAME="ppp_connection_manager.service"
|
||||
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
BLUE='\033[1;34m'
|
||||
GREEN='\033[0;32m'
|
||||
SET='\033[0m'
|
||||
|
||||
# Global Varibales
|
||||
POWERUP_REQ=1
|
||||
POWERUP_NOT_REQ=0
|
||||
|
||||
STATUS_GPRS=19
|
||||
STATUS_CELL_IOT_APP=20
|
||||
STATUS_CELL_IOT=23
|
||||
STATUS_TRACKER=23
|
||||
|
||||
POWERKEY_GPRS=26
|
||||
POWERKEY_CELL_IOT_APP=11
|
||||
POWERKEY_CELL_IOT=24
|
||||
POWERKEY_TRACKER=24
|
||||
|
||||
|
||||
function colored_echo
|
||||
{
|
||||
COLOR=${2:-$YELLOW}
|
||||
echo -e "$COLOR$1 ${SET}"
|
||||
}
|
||||
|
||||
|
||||
# Check Sixfab path
|
||||
if [[ -e $SIXFAB_PATH ]]; then
|
||||
colored_echo "Sixfab path already exist!" ${SET}
|
||||
else
|
||||
sudo mkdir $SIXFAB_PATH
|
||||
colored_echo "Sixfab path is created." ${SET}
|
||||
fi
|
||||
|
||||
# Check PPP path
|
||||
if [[ -e $PPP_PATH ]]; then
|
||||
colored_echo "PPP path already exist!" ${SET}
|
||||
else
|
||||
sudo mkdir $PPP_PATH
|
||||
colored_echo "PPP path is created." ${SET}
|
||||
fi
|
||||
|
||||
|
||||
colored_echo "Please choose your Sixfab Shield/HAT:"
|
||||
colored_echo "1: GSM/GPRS Shield"
|
||||
colored_echo "2: 3G, 4G/LTE Base Shield"
|
||||
colored_echo "3: Cellular IoT App Shield"
|
||||
colored_echo "4: Cellular IoT HAT"
|
||||
colored_echo "5: Tracker HAT"
|
||||
colored_echo "6: 3G/4G Base HAT"
|
||||
|
||||
|
||||
read shield_hat
|
||||
case $shield_hat in
|
||||
1) colored_echo "You chose GSM/GPRS Shield" ${GREEN};;
|
||||
2) colored_echo "You chose Base Shield" ${GREEN};;
|
||||
3) colored_echo "You chose CellularIoT Shield" ${GREEN};;
|
||||
4) colored_echo "You chose CellularIoT HAT" ${GREEN};;
|
||||
5) colored_echo "You chose Tracker HAT" ${GREEN};;
|
||||
6) colored_echo "You chose 3G/4G Base HAT" ${GREEN};;
|
||||
*) colored_echo "Wrong Selection, exiting" ${RED}; exit 1;
|
||||
esac
|
||||
|
||||
colored_echo "Checking requirements..."
|
||||
|
||||
colored_echo "Updating headers..."
|
||||
sudo apt-get update
|
||||
|
||||
colored_echo "Installing python3 if it is required..."
|
||||
if ! [ -x "$(command -v python3)" ]; then
|
||||
sudo apt-get install python3 -y
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi
|
||||
fi
|
||||
|
||||
colored_echo "Installing pip3 if it is required..."
|
||||
if ! [ -x "$(command -v pip3)" ]; then
|
||||
sudo apt-get install python3-pip -y
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi
|
||||
fi
|
||||
|
||||
colored_echo "Installing or upgrading atcom if it is required..."
|
||||
|
||||
pip3 install -U atcom
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi
|
||||
|
||||
source ~/.profile
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi
|
||||
|
||||
|
||||
colored_echo "Copying setup files..."
|
||||
|
||||
cp $SOURCE_PATH/chat-connect chat-connect
|
||||
cp $SOURCE_PATH/chat-disconnect chat-disconnect
|
||||
cp $SOURCE_PATH/provider provider
|
||||
|
||||
colored_echo "ppp and wiringpi (gpio tool) installing..."
|
||||
apt-get install ppp wiringpi -y
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi
|
||||
|
||||
# test wiringpi and fix if there is any issue
|
||||
gpio readall | grep Oops > /dev/null
|
||||
if [[ $? -ne 1 ]]; then
|
||||
colored_echo "Known wiringpi issue is detected! Wiringpi is updating..."
|
||||
wget https://project-downloads.drogon.net/wiringpi-latest.deb
|
||||
sudo dpkg -i wiringpi-latest.deb
|
||||
fi
|
||||
|
||||
colored_echo "What is your carrier APN?"
|
||||
read carrierapn
|
||||
|
||||
colored_echo "Your Input is : $carrierapn" ${GREEN}
|
||||
|
||||
while [ 1 ]
|
||||
do
|
||||
colored_echo "Does your carrier need username and password? [Y/n]"
|
||||
read usernpass
|
||||
|
||||
colored_echo "You chose $usernpass" ${GREEN}
|
||||
|
||||
case $usernpass in
|
||||
[Yy]* )
|
||||
|
||||
while [ 1 ]
|
||||
do
|
||||
|
||||
colored_echo "Enter username"
|
||||
read username
|
||||
|
||||
colored_echo "Your Input is : $username" ${GREEN}
|
||||
|
||||
colored_echo "Enter password"
|
||||
read password
|
||||
|
||||
colored_echo "Your Input is : $password" ${GREEN}
|
||||
|
||||
sed -i "s/noauth/#noauth\nuser \"$username\"\npassword \"$password\"/" provider
|
||||
break
|
||||
done
|
||||
|
||||
break;;
|
||||
|
||||
[Nn]* ) break;;
|
||||
*) colored_echo "Wrong Selection, Select among Y or n" ${RED};;
|
||||
esac
|
||||
done
|
||||
|
||||
colored_echo "What is your device communication PORT? (ttyS0/ttyUSB3/etc.)"
|
||||
read devicename
|
||||
|
||||
colored_echo "Your input is: $devicename" ${GREEN}
|
||||
|
||||
if grep -q "ttyS0" <<<"$devicename"; then
|
||||
colored_echo "*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-" ${BLUE}
|
||||
colored_echo "REMINDER!" ${BLUE}
|
||||
colored_echo "- Disable serial console and enable miniuart to use ttyS0 as the serial interface." ${SET}
|
||||
colored_echo "✔ If your ttyS0 (miniuart) port is enabled, press ENTER and continue to installation." ${SET}
|
||||
colored_echo "✘ If not, please follow the instructions to enable ttyS0 interface on Raspberry Pi" ${SET}
|
||||
echo -e "
|
||||
1. Start raspi-config: ${BLUE}sudo raspi-config${SET}.
|
||||
2. Select option 3 - ${BLUE}Interface Options${SET}.
|
||||
3. Select option P6 - ${BLUE}Serial Port${SET}.
|
||||
4. ${BLUE}At the prompt Would you like a login shell to be accessible over serial?${SET} answer ${BLUE}'No'${SET}
|
||||
5. ${BLUE}At the prompt Would you like the serial port hardware to be enabled?${SET} answer ${BLUE}'Yes'${SET}
|
||||
6. Exit raspi-config and ${BLUE}reboot${SET} the Pi for changes to take effect.
|
||||
"
|
||||
colored_echo "*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-" ${BLUE}
|
||||
echo
|
||||
echo -e "Press ${BLUE}ENTER${SET} key to continue to installation or press ${BLUE}CTRL^C${SET} to abort installation and enable ttyS0 serial interface."
|
||||
read -p "" ENTER
|
||||
|
||||
colored_echo "Doing atcom configuration for ttyS0 serial..."
|
||||
# create atcom config
|
||||
echo port: "/dev/ttyS0" > configs.yml
|
||||
mv configs.yml $PPP_PATH
|
||||
else
|
||||
# delete atcom config
|
||||
ls $PPP_PATH | grep configs.yml > /dev/null
|
||||
if [[ $? -eq 0 ]]; then rm $PPP_PATH/configs.yml; fi
|
||||
fi
|
||||
|
||||
mkdir -p /etc/chatscripts
|
||||
|
||||
mv chat-connect /etc/chatscripts/
|
||||
mv chat-disconnect /etc/chatscripts/
|
||||
|
||||
mkdir -p /etc/ppp/peers
|
||||
sed -i "s/#APN/$carrierapn/" provider
|
||||
sed -i "s/#DEVICE/$devicename/" provider
|
||||
mv provider /etc/ppp/peers/provider
|
||||
|
||||
if ! (grep -q 'sudo route' /etc/ppp/ip-up ); then
|
||||
echo "sudo route add default ppp0" >> /etc/ppp/ip-up
|
||||
fi
|
||||
|
||||
if [[ $shield_hat -eq 2 ]] || [[ $shield_hat -eq 6 ]]; then
|
||||
if ! (grep -q 'max_usb_current' /boot/config.txt ); then
|
||||
echo "max_usb_current=1" >> /boot/config.txt
|
||||
fi
|
||||
fi
|
||||
|
||||
while [ 1 ]
|
||||
do
|
||||
colored_echo "Do you want to activate auto connect/reconnect service at R.Pi boot up? [Y/n]"
|
||||
read auto_reconnect
|
||||
|
||||
colored_echo "You chose $auto_reconnect" ${GREEN}
|
||||
|
||||
case $auto_reconnect in
|
||||
[Yy]* ) colored_echo "Copying setup file..."
|
||||
|
||||
cp $SOURCE_PATH/$SERVICE_NAME $SERVICE_NAME
|
||||
cp $SOURCE_PATH/functions.sh functions.sh
|
||||
cp $SOURCE_PATH/configs.sh configs.sh
|
||||
cp $SOURCE_PATH/configure_modem.sh configure_modem.sh
|
||||
cp $SOURCE_PATH/$MANAGER_SCRIPT_NAME $MANAGER_SCRIPT_NAME
|
||||
|
||||
# APN Configuration
|
||||
sed -i "s/SIM_APN/$carrierapn/" configure_modem.sh
|
||||
|
||||
if [ $shield_hat -eq 1 ]; then
|
||||
|
||||
cp $SCRIPT_PATH/reconnect_gprsshield $RECONNECT_SCRIPT_NAME
|
||||
|
||||
sed -i "s/STATUS_PIN/$STATUS_GPRS/" configure_modem.sh
|
||||
sed -i "s/POWERKEY_PIN/$POWERKEY_GPRS/" configure_modem.sh
|
||||
sed -i "s/POWERUP_FLAG/$POWERUP_REQ/" configure_modem.sh
|
||||
|
||||
|
||||
elif [ $shield_hat -eq 2 ]; then
|
||||
|
||||
cp $SCRIPT_PATH/reconnect_baseshield $RECONNECT_SCRIPT_NAME
|
||||
|
||||
sed -i "s/POWERUP_FLAG/$POWERUP_NOT_REQ/" configure_modem.sh
|
||||
|
||||
elif [ $shield_hat -eq 3 ]; then
|
||||
|
||||
cp $SCRIPT_PATH/reconnect_cellulariot_app $RECONNECT_SCRIPT_NAME
|
||||
|
||||
sed -i "s/STATUS_PIN/$STATUS_CELL_IOT_APP/" configure_modem.sh
|
||||
sed -i "s/POWERKEY_PIN/$POWERKEY_CELL_IOT_APP/" configure_modem.sh
|
||||
sed -i "s/POWERUP_FLAG/$POWERUP_REQ/" configure_modem.sh
|
||||
|
||||
elif [ $shield_hat -eq 4 ]; then
|
||||
|
||||
cp $SCRIPT_PATH/reconnect_cellulariot $RECONNECT_SCRIPT_NAME
|
||||
|
||||
sed -i "s/STATUS_PIN/$STATUS_CELL_IOT/" configure_modem.sh
|
||||
sed -i "s/POWERKEY_PIN/$POWERKEY_CELL_IOT/" configure_modem.sh
|
||||
sed -i "s/POWERUP_FLAG/$POWERUP_REQ/" configure_modem.sh
|
||||
|
||||
elif [ $shield_hat -eq 5 ]; then
|
||||
|
||||
cp $SCRIPT_PATH/reconnect_tracker $RECONNECT_SCRIPT_NAME
|
||||
|
||||
sed -i "s/STATUS_PIN/$STATUS_TRACKER/" configure_modem.sh
|
||||
sed -i "s/POWERKEY_PIN/$POWERKEY_TRACKER/" configure_modem.sh
|
||||
sed -i "s/POWERUP_FLAG/$POWERUP_REQ/" configure_modem.sh
|
||||
|
||||
elif [ $shield_hat -eq 6 ]; then
|
||||
|
||||
cp $SCRIPT_PATH/reconnect_basehat $RECONNECT_SCRIPT_NAME
|
||||
|
||||
sed -i "s/POWERUP_FLAG/$POWERUP_NOT_REQ/" configure_modem.sh
|
||||
|
||||
fi
|
||||
|
||||
mv functions.sh $PPP_PATH
|
||||
mv configs.sh $PPP_PATH
|
||||
mv configure_modem.sh $PPP_PATH
|
||||
mv $RECONNECT_SCRIPT_NAME $PPP_PATH
|
||||
mv $MANAGER_SCRIPT_NAME $PPP_PATH
|
||||
mv $SERVICE_NAME /etc/systemd/system/
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable $SERVICE_NAME
|
||||
|
||||
break;;
|
||||
|
||||
[Nn]* ) echo -e "${YELLOW}To connect to internet run ${BLUE}\"sudo pon\"${YELLOW} and to disconnect run ${BLUE}\"sudo poff\" ${SET}"
|
||||
break;;
|
||||
*) colored_echo "Wrong Selection, Select among Y or n" ${RED};;
|
||||
esac
|
||||
done
|
||||
|
||||
read -p "Press ENTER key to reboot" ENTER
|
||||
|
||||
colored_echo "Rebooting..." ${GREEN}
|
||||
reboot
|
140
ppp_install_jetson.sh
Executable file
140
ppp_install_jetson.sh
Executable file
@ -0,0 +1,140 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Created on July 12, 2019 by Saeed Johar (saeedjohar)
|
||||
# Revised on November 19, 2020 by Yasin Kaya (selengalp)
|
||||
|
||||
SIXFAB_PATH="/opt/sixfab"
|
||||
PPP_PATH="/opt/sixfab/ppp_connection_manager"
|
||||
|
||||
REPO_PATH="https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer"
|
||||
BRANCH=master
|
||||
SOURCE_PATH="$REPO_PATH/$BRANCH/src"
|
||||
SCRIPT_PATH="$REPO_PATH/$BRANCH/src/reconnect_scripts"
|
||||
RECONNECT_SCRIPT_NAME="ppp_reconnect.sh"
|
||||
MANAGER_SCRIPT_NAME="ppp_connection_manager.sh"
|
||||
SERVICE_NAME="ppp_connection_manager.service"
|
||||
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
BLUE='\033[1;34m'
|
||||
SET='\033[0m'
|
||||
|
||||
|
||||
function colored_echo
|
||||
{
|
||||
COLOR=${2:-$YELLOW}
|
||||
echo -e "$COLOR$1 ${SET}"
|
||||
}
|
||||
|
||||
|
||||
# Check Sixfab path
|
||||
if [[ -e $SIXFAB_PATH ]]; then
|
||||
colored_echo "Sixfab path already exist!" ${SET}
|
||||
else
|
||||
sudo mkdir $SIXFAB_PATH
|
||||
colored_echo "Sixfab path is created." ${SET}
|
||||
fi
|
||||
|
||||
# Check PPP path
|
||||
if [[ -e $PPP_PATH ]]; then
|
||||
colored_echo "PPP path already exist!" ${SET}
|
||||
else
|
||||
sudo mkdir $PPP_PATH
|
||||
colored_echo "PPP path is created." ${SET}
|
||||
fi
|
||||
|
||||
colored_echo "Please choose your Sixfab Shield/HAT:"
|
||||
colored_echo "1: GSM/GPRS Shield"
|
||||
colored_echo "2: 3G, 4G/LTE Base Shield"
|
||||
colored_echo "3: Cellular IoT App Shield"
|
||||
colored_echo "4: Cellular IoT HAT"
|
||||
colored_echo "5: Tracker HAT"
|
||||
colored_echo "6: 3G/4G Base HAT"
|
||||
|
||||
read shield_hat
|
||||
case $shield_hat in
|
||||
1) colored_echo "You chose GSM/GPRS Shield";;
|
||||
2) colored_echo "You chose Base Shield";;
|
||||
3) colored_echo "You chose CellularIoT Shield";;
|
||||
4) colored_echo "You chose CellularIoT HAT";;
|
||||
5) colored_echo "You chose Tracker HAT";;
|
||||
6) colored_echo "You chose 3G/4G Base HAT";;
|
||||
*) colored_echo "Wrong Selection, exiting" ${RED}; exit 1;
|
||||
esac
|
||||
|
||||
colored_echo "Checking requiremments..."
|
||||
|
||||
colored_echo "Installing python3 if it is required..."
|
||||
if ! [ -x "$(command -v python3)" ]; then
|
||||
sudo apt-get install python3 -y >/dev/null
|
||||
fi
|
||||
|
||||
colored_echo "Installing pip3 if it is required..."
|
||||
if ! [ -x "$(command -v pip3)" ]; then
|
||||
sudo apt-get install python3-pip -y >/dev/null
|
||||
fi
|
||||
|
||||
colored_echo "Installing or upgrading atcom if it is required..."
|
||||
pip3 install -U atcom && source ~/.profile
|
||||
|
||||
|
||||
colored_echo "Downloading setup files..."
|
||||
wget --no-check-certificate $SOURCE_PATH/chat-connect -O chat-connect
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi
|
||||
|
||||
wget --no-check-certificate $SOURCE_PATH/chat-disconnect -O chat-disconnect
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi
|
||||
|
||||
wget --no-check-certificate $SOURCE_PATH/provider -O provider
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi
|
||||
|
||||
colored_echo "ppp installing"
|
||||
apt-get install ppp -y
|
||||
|
||||
colored_echo "What is your carrier APN?"
|
||||
read carrierapn
|
||||
|
||||
while [ 1 ]
|
||||
do
|
||||
colored_echo "Does your carrier need username and password? [Y/n]"
|
||||
read usernpass
|
||||
|
||||
case $usernpass in
|
||||
[Yy]* ) while [ 1 ]
|
||||
do
|
||||
|
||||
colored_echo "Enter username"
|
||||
read username
|
||||
|
||||
colored_echo "Enter password"
|
||||
read password
|
||||
sed -i "s/noauth/#noauth\nuser \"$username\"\npassword \"$password\"/" provider
|
||||
break
|
||||
done
|
||||
|
||||
break;;
|
||||
|
||||
[Nn]* ) break;;
|
||||
*) colored_echo "Wrong Selection, Select among Y or n" ${RED};;
|
||||
esac
|
||||
done
|
||||
|
||||
colored_echo "What is your device communication PORT? (ttyS0/ttyUSB3/etc.)"
|
||||
read devicename
|
||||
|
||||
mkdir -p /etc/chatscripts
|
||||
|
||||
mv chat-connect /etc/chatscripts/
|
||||
mv chat-disconnect /etc/chatscripts/
|
||||
|
||||
mkdir -p /etc/ppp/peers
|
||||
sed -i "s/#APN/$carrierapn/" provider
|
||||
sed -i "s/#DEVICE/$devicename/" provider
|
||||
mv provider /etc/ppp/peers/provider
|
||||
|
||||
if ! (grep -q 'sudo route' /etc/ppp/ip-up ); then
|
||||
echo "sudo route add default ppp0" >> /etc/ppp/ip-up
|
||||
fi
|
||||
|
||||
read -p "Press ENTER key to reboot" ENTER
|
||||
reboot
|
325
ppp_install_standalone.sh
Executable file
325
ppp_install_standalone.sh
Executable file
@ -0,0 +1,325 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Re-created on November 27, 2020 by Yasin Kaya (selengalp)
|
||||
|
||||
SIXFAB_PATH="/opt/sixfab"
|
||||
PPP_PATH="/opt/sixfab/ppp_connection_manager"
|
||||
|
||||
REPO_PATH="https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer"
|
||||
BRANCH=master
|
||||
SOURCE_PATH="$REPO_PATH/$BRANCH/src"
|
||||
SCRIPT_PATH="$REPO_PATH/$BRANCH/src/reconnect_scripts"
|
||||
RECONNECT_SCRIPT_NAME="ppp_reconnect.sh"
|
||||
MANAGER_SCRIPT_NAME="ppp_connection_manager.sh"
|
||||
SERVICE_NAME="ppp_connection_manager.service"
|
||||
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
BLUE='\033[1;34m'
|
||||
GREEN='\033[0;32m'
|
||||
SET='\033[0m'
|
||||
|
||||
# Global Varibales
|
||||
POWERUP_REQ=1
|
||||
POWERUP_NOT_REQ=0
|
||||
|
||||
STATUS_GPRS=19
|
||||
STATUS_CELL_IOT_APP=20
|
||||
STATUS_CELL_IOT=23
|
||||
STATUS_TRACKER=23
|
||||
|
||||
POWERKEY_GPRS=26
|
||||
POWERKEY_CELL_IOT_APP=11
|
||||
POWERKEY_CELL_IOT=24
|
||||
POWERKEY_TRACKER=24
|
||||
|
||||
|
||||
function colored_echo
|
||||
{
|
||||
COLOR=${2:-$YELLOW}
|
||||
echo -e "$COLOR$1 ${SET}"
|
||||
}
|
||||
|
||||
|
||||
# Check Sixfab path
|
||||
if [[ -e $SIXFAB_PATH ]]; then
|
||||
colored_echo "Sixfab path already exist!" ${SET}
|
||||
else
|
||||
sudo mkdir $SIXFAB_PATH
|
||||
colored_echo "Sixfab path is created." ${SET}
|
||||
fi
|
||||
|
||||
# Check PPP path
|
||||
if [[ -e $PPP_PATH ]]; then
|
||||
colored_echo "PPP path already exist!" ${SET}
|
||||
else
|
||||
sudo mkdir $PPP_PATH
|
||||
colored_echo "PPP path is created." ${SET}
|
||||
fi
|
||||
|
||||
|
||||
colored_echo "Please choose your Sixfab Shield/HAT:"
|
||||
colored_echo "1: GSM/GPRS Shield"
|
||||
colored_echo "2: 3G, 4G/LTE Base Shield"
|
||||
colored_echo "3: Cellular IoT App Shield"
|
||||
colored_echo "4: Cellular IoT HAT"
|
||||
colored_echo "5: Tracker HAT"
|
||||
colored_echo "6: 3G/4G Base HAT"
|
||||
|
||||
|
||||
read shield_hat
|
||||
case $shield_hat in
|
||||
1) colored_echo "You chose GSM/GPRS Shield" ${GREEN};;
|
||||
2) colored_echo "You chose Base Shield" ${GREEN};;
|
||||
3) colored_echo "You chose CellularIoT Shield" ${GREEN};;
|
||||
4) colored_echo "You chose CellularIoT HAT" ${GREEN};;
|
||||
5) colored_echo "You chose Tracker HAT" ${GREEN};;
|
||||
6) colored_echo "You chose 3G/4G Base HAT" ${GREEN};;
|
||||
*) colored_echo "Wrong Selection, exiting" ${RED}; exit 1;
|
||||
esac
|
||||
|
||||
colored_echo "Checking requirements..."
|
||||
|
||||
colored_echo "Updating headers..."
|
||||
sudo apt-get update
|
||||
|
||||
colored_echo "Installing python3 if it is required..."
|
||||
if ! [ -x "$(command -v python3)" ]; then
|
||||
sudo apt-get install python3 -y
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi
|
||||
fi
|
||||
|
||||
colored_echo "Installing pip3 if it is required..."
|
||||
if ! [ -x "$(command -v pip3)" ]; then
|
||||
sudo apt-get install python3-pip -y
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi
|
||||
fi
|
||||
|
||||
colored_echo "Installing or upgrading atcom if it is required..."
|
||||
|
||||
pip3 install -U atcom
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi
|
||||
|
||||
source ~/.profile
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi
|
||||
|
||||
|
||||
colored_echo "Downloading setup files..."
|
||||
|
||||
wget --no-check-certificate $SOURCE_PATH/chat-connect -O chat-connect
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi
|
||||
|
||||
wget --no-check-certificate $SOURCE_PATH/chat-disconnect -O chat-disconnect
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi
|
||||
|
||||
wget --no-check-certificate $SOURCE_PATH/provider -O provider
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi
|
||||
|
||||
colored_echo "ppp and wiringpi (gpio tool) installing..."
|
||||
apt-get install ppp wiringpi -y
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi
|
||||
|
||||
# test wiringpi and fix if there is any issue
|
||||
gpio readall | grep Oops > /dev/null
|
||||
if [[ $? -ne 1 ]]; then
|
||||
colored_echo "Known wiringpi issue is detected! Wiringpi is updating..."
|
||||
wget https://project-downloads.drogon.net/wiringpi-latest.deb
|
||||
sudo dpkg -i wiringpi-latest.deb
|
||||
fi
|
||||
|
||||
colored_echo "What is your carrier APN?"
|
||||
read carrierapn
|
||||
|
||||
colored_echo "Your Input is : $carrierapn" ${GREEN}
|
||||
|
||||
while [ 1 ]
|
||||
do
|
||||
colored_echo "Does your carrier need username and password? [Y/n]"
|
||||
read usernpass
|
||||
|
||||
colored_echo "You chose $usernpass" ${GREEN}
|
||||
|
||||
case $usernpass in
|
||||
[Yy]* )
|
||||
|
||||
while [ 1 ]
|
||||
do
|
||||
|
||||
colored_echo "Enter username"
|
||||
read username
|
||||
|
||||
colored_echo "Your Input is : $username" ${GREEN}
|
||||
|
||||
colored_echo "Enter password"
|
||||
read password
|
||||
|
||||
colored_echo "Your Input is : $password" ${GREEN}
|
||||
|
||||
sed -i "s/noauth/#noauth\nuser \"$username\"\npassword \"$password\"/" provider
|
||||
break
|
||||
done
|
||||
|
||||
break;;
|
||||
|
||||
[Nn]* ) break;;
|
||||
*) colored_echo "Wrong Selection, Select among Y or n" ${RED};;
|
||||
esac
|
||||
done
|
||||
|
||||
colored_echo "What is your device communication PORT? (ttyS0/ttyUSB3/etc.)"
|
||||
read devicename
|
||||
|
||||
colored_echo "Your input is: $devicename" ${GREEN}
|
||||
|
||||
if grep -q "ttyS0" <<<"$devicename"; then
|
||||
colored_echo "*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-" ${BLUE}
|
||||
colored_echo "REMINDER!" ${BLUE}
|
||||
colored_echo "- Disable serial console and enable miniuart to use ttyS0 as the serial interface." ${SET}
|
||||
colored_echo "✔ If your ttyS0 (miniuart) port is enabled, press ENTER and continue to installation." ${SET}
|
||||
colored_echo "✘ If not, please follow the instructions to enable ttyS0 interface on Raspberry Pi" ${SET}
|
||||
echo -e "
|
||||
1. Start raspi-config: ${BLUE}sudo raspi-config${SET}.
|
||||
2. Select option 3 - ${BLUE}Interface Options${SET}.
|
||||
3. Select option P6 - ${BLUE}Serial Port${SET}.
|
||||
4. ${BLUE}At the prompt Would you like a login shell to be accessible over serial?${SET} answer ${BLUE}'No'${SET}
|
||||
5. ${BLUE}At the prompt Would you like the serial port hardware to be enabled?${SET} answer ${BLUE}'Yes'${SET}
|
||||
6. Exit raspi-config and ${BLUE}reboot${SET} the Pi for changes to take effect.
|
||||
"
|
||||
colored_echo "*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-" ${BLUE}
|
||||
echo
|
||||
echo -e "Press ${BLUE}ENTER${SET} key to continue to installation or press ${BLUE}CTRL^C${SET} to abort installation and enable ttyS0 serial interface."
|
||||
read -p "" ENTER
|
||||
|
||||
colored_echo "Doing atcom configuration for ttyS0 serial..."
|
||||
# create atcom config
|
||||
echo port: "/dev/ttyS0" > configs.yml
|
||||
mv configs.yml $PPP_PATH
|
||||
else
|
||||
# delete atcom config
|
||||
ls $PPP_PATH | grep configs.yml > /dev/null
|
||||
if [[ $? -eq 0 ]]; then rm $PPP_PATH/configs.yml; fi
|
||||
fi
|
||||
|
||||
mkdir -p /etc/chatscripts
|
||||
|
||||
mv chat-connect /etc/chatscripts/
|
||||
mv chat-disconnect /etc/chatscripts/
|
||||
|
||||
mkdir -p /etc/ppp/peers
|
||||
sed -i "s/#APN/$carrierapn/" provider
|
||||
sed -i "s/#DEVICE/$devicename/" provider
|
||||
mv provider /etc/ppp/peers/provider
|
||||
|
||||
if ! (grep -q 'sudo route' /etc/ppp/ip-up ); then
|
||||
echo "sudo route add default ppp0" >> /etc/ppp/ip-up
|
||||
fi
|
||||
|
||||
if [[ $shield_hat -eq 2 ]] || [[ $shield_hat -eq 6 ]]; then
|
||||
if ! (grep -q 'max_usb_current' /boot/config.txt ); then
|
||||
echo "max_usb_current=1" >> /boot/config.txt
|
||||
fi
|
||||
fi
|
||||
|
||||
while [ 1 ]
|
||||
do
|
||||
colored_echo "Do you want to activate auto connect/reconnect service at R.Pi boot up? [Y/n]"
|
||||
read auto_reconnect
|
||||
|
||||
colored_echo "You chose $auto_reconnect" ${GREEN}
|
||||
|
||||
case $auto_reconnect in
|
||||
[Yy]* ) colored_echo "Downloading setup file..."
|
||||
|
||||
wget --no-check-certificate $SOURCE_PATH/$SERVICE_NAME
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi
|
||||
|
||||
wget --no-check-certificate $SOURCE_PATH/functions.sh
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi
|
||||
|
||||
wget --no-check-certificate $SOURCE_PATH/configs.sh
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi
|
||||
|
||||
wget --no-check-certificate $SOURCE_PATH/configure_modem.sh
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi
|
||||
|
||||
wget --no-check-certificate $SOURCE_PATH/$MANAGER_SCRIPT_NAME
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi
|
||||
|
||||
# APN Configuration
|
||||
sed -i "s/SIM_APN/$carrierapn/" configure_modem.sh
|
||||
|
||||
if [ $shield_hat -eq 1 ]; then
|
||||
|
||||
wget --no-check-certificate $SCRIPT_PATH/reconnect_gprsshield -O $RECONNECT_SCRIPT_NAME
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi
|
||||
|
||||
sed -i "s/STATUS_PIN/$STATUS_GPRS/" configure_modem.sh
|
||||
sed -i "s/POWERKEY_PIN/$POWERKEY_GPRS/" configure_modem.sh
|
||||
sed -i "s/POWERUP_FLAG/$POWERUP_REQ/" configure_modem.sh
|
||||
|
||||
|
||||
elif [ $shield_hat -eq 2 ]; then
|
||||
|
||||
wget --no-check-certificate $SCRIPT_PATH/reconnect_baseshield -O $RECONNECT_SCRIPT_NAME
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi
|
||||
|
||||
sed -i "s/POWERUP_FLAG/$POWERUP_NOT_REQ/" configure_modem.sh
|
||||
|
||||
elif [ $shield_hat -eq 3 ]; then
|
||||
|
||||
wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot_app -O $RECONNECT_SCRIPT_NAME
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi
|
||||
|
||||
sed -i "s/STATUS_PIN/$STATUS_CELL_IOT_APP/" configure_modem.sh
|
||||
sed -i "s/POWERKEY_PIN/$POWERKEY_CELL_IOT_APP/" configure_modem.sh
|
||||
sed -i "s/POWERUP_FLAG/$POWERUP_REQ/" configure_modem.sh
|
||||
|
||||
elif [ $shield_hat -eq 4 ]; then
|
||||
|
||||
wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot -O $RECONNECT_SCRIPT_NAME
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi
|
||||
|
||||
sed -i "s/STATUS_PIN/$STATUS_CELL_IOT/" configure_modem.sh
|
||||
sed -i "s/POWERKEY_PIN/$POWERKEY_CELL_IOT/" configure_modem.sh
|
||||
sed -i "s/POWERUP_FLAG/$POWERUP_REQ/" configure_modem.sh
|
||||
|
||||
elif [ $shield_hat -eq 5 ]; then
|
||||
|
||||
wget --no-check-certificate $SCRIPT_PATH/reconnect_tracker -O $RECONNECT_SCRIPT_NAME
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi
|
||||
|
||||
sed -i "s/STATUS_PIN/$STATUS_TRACKER/" configure_modem.sh
|
||||
sed -i "s/POWERKEY_PIN/$POWERKEY_TRACKER/" configure_modem.sh
|
||||
sed -i "s/POWERUP_FLAG/$POWERUP_REQ/" configure_modem.sh
|
||||
|
||||
elif [ $shield_hat -eq 6 ]; then
|
||||
|
||||
wget --no-check-certificate $SCRIPT_PATH/reconnect_basehat -O $RECONNECT_SCRIPT_NAME
|
||||
if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi
|
||||
|
||||
sed -i "s/POWERUP_FLAG/$POWERUP_NOT_REQ/" configure_modem.sh
|
||||
|
||||
fi
|
||||
|
||||
mv functions.sh $PPP_PATH
|
||||
mv configs.sh $PPP_PATH
|
||||
mv configure_modem.sh $PPP_PATH
|
||||
mv $RECONNECT_SCRIPT_NAME $PPP_PATH
|
||||
mv $MANAGER_SCRIPT_NAME $PPP_PATH
|
||||
mv $SERVICE_NAME /etc/systemd/system/
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable $SERVICE_NAME
|
||||
|
||||
break;;
|
||||
|
||||
[Nn]* ) echo -e "${YELLOW}To connect to internet run ${BLUE}\"sudo pon\"${YELLOW} and to disconnect run ${BLUE}\"sudo poff\" ${SET}"
|
||||
break;;
|
||||
*) colored_echo "Wrong Selection, Select among Y or n" ${RED};;
|
||||
esac
|
||||
done
|
||||
|
||||
read -p "Press ENTER key to reboot" ENTER
|
||||
|
||||
colored_echo "Rebooting..." ${GREEN}
|
||||
reboot
|
@ -1,155 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
BLUE='\033[1;34m'
|
||||
SET='\033[0m'
|
||||
|
||||
echo "${YELLOW}Please choose your Sixfab Shield/HAT:${SET}"
|
||||
echo "${YELLOW}1: GSM/GPRS Shield${SET}"
|
||||
echo "${YELLOW}2: 3G, 4G/LTE Base Shield${SET}"
|
||||
echo "${YELLOW}3: Cellular IoT App Shield${SET}"
|
||||
echo "${YELLOW}4: Cellular IoT HAT${SET}"
|
||||
echo "${YELLOW}5: Tracker HAT${SET}"
|
||||
echo "${YELLOW}6: 3G/4G Base HAT${SET}"
|
||||
|
||||
|
||||
read shield_hat
|
||||
case $shield_hat in
|
||||
1) echo "${YELLOW}You chose GSM/GPRS Shield${SET}";;
|
||||
2) echo "${YELLOW}You chose Base Shield${SET}";;
|
||||
3) echo "${YELLOW}You chose CellularIoT Shield${SET}";;
|
||||
4) echo "${YELLOW}You chose CellularIoT HAT${SET}";;
|
||||
5) echo "${YELLOW}You chose Tracker HAT${SET}";;
|
||||
6) echo "${YELLOW}You chose 3G/4G Base HAT${SET}";;
|
||||
*) echo "${RED}Wrong Selection, exiting${SET}"; exit 1;
|
||||
esac
|
||||
|
||||
echo "${YELLOW}Downloading setup files${SET}"
|
||||
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/chat-connect -O chat-connect
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "${RED}Download failed${SET}"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/chat-disconnect -O chat-disconnect
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "${RED}Download failed${SET}"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/provider -O provider
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "${RED}Download failed${SET}"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
echo "${YELLOW}ppp and wiringpi (gpio tool) install${SET}"
|
||||
apt install ppp wiringpi -y
|
||||
|
||||
echo "${YELLOW}What is your carrier APN?${SET}"
|
||||
read carrierapn
|
||||
|
||||
while [ 1 ]
|
||||
do
|
||||
echo "${YELLOW}Does your carrier need username and password? [Y/n]${SET}"
|
||||
read usernpass
|
||||
|
||||
case $usernpass in
|
||||
[Yy]* ) while [ 1 ]
|
||||
do
|
||||
|
||||
echo "${YELLOW}Enter username${SET}"
|
||||
read username
|
||||
|
||||
echo "${YELLOW}Enter password${SET}"
|
||||
read password
|
||||
sed -i "s/noauth/#noauth\nuser \"$username\"\npassword \"$password\"/" provider
|
||||
break
|
||||
done
|
||||
|
||||
break;;
|
||||
|
||||
[Nn]* ) break;;
|
||||
*) echo "${RED}Wrong Selection, Select among Y or n${SET}";;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "${YELLOW}What is your device communication PORT? (ttyS0/ttyUSB3/etc.)${SET}"
|
||||
read devicename
|
||||
|
||||
mkdir -p /etc/chatscripts
|
||||
|
||||
mv chat-connect /etc/chatscripts/
|
||||
mv chat-disconnect /etc/chatscripts/
|
||||
|
||||
mkdir -p /etc/ppp/peers
|
||||
sed -i "s/#APN/$carrierapn/" provider
|
||||
sed -i "s/#DEVICE/$devicename/" provider
|
||||
mv provider /etc/ppp/peers/provider
|
||||
|
||||
if ! (grep -q 'sudo route' /etc/ppp/ip-up ); then
|
||||
echo "sudo route add default ppp0" >> /etc/ppp/ip-up
|
||||
fi
|
||||
|
||||
if [ $shield_hat -eq 2 ]; then
|
||||
if ! (grep -q 'max_usb_current' /boot/config.txt ); then
|
||||
echo "max_usb_current=1" >> /boot/config.txt
|
||||
fi
|
||||
fi
|
||||
|
||||
while [ 1 ]
|
||||
do
|
||||
echo "${YELLOW}Do you want to activate auto connect/reconnect service at R.Pi boot up? [Y/n] ${SET}"
|
||||
read auto_reconnect
|
||||
|
||||
case $auto_reconnect in
|
||||
[Yy]* ) echo "${YELLOW}Downloading setup file${SET}"
|
||||
|
||||
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_service -O reconnect.service
|
||||
|
||||
if [ $shield_hat -eq 1 ]; then
|
||||
|
||||
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_gprsshield -O reconnect.sh
|
||||
|
||||
elif [ $shield_hat -eq 2 ]; then
|
||||
|
||||
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_baseshield -O reconnect.sh
|
||||
|
||||
elif [ $shield_hat -eq 3 ]; then
|
||||
|
||||
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_cellulariot_app -O reconnect.sh
|
||||
|
||||
elif [ $shield_hat -eq 4 ]; then
|
||||
|
||||
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_cellulariot -O reconnect.sh
|
||||
|
||||
elif [ $shield_hat -eq 5 ]; then
|
||||
|
||||
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_tracker -O reconnect.sh
|
||||
|
||||
elif [ $shield_hat -eq 6 ]; then
|
||||
|
||||
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_basehat -O reconnect.sh
|
||||
|
||||
fi
|
||||
|
||||
mv reconnect.sh /usr/src/
|
||||
mv reconnect.service /etc/systemd/system/
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable reconnect.service
|
||||
|
||||
break;;
|
||||
|
||||
[Nn]* ) echo "${YELLOW}To connect to internet run ${BLUE}\"sudo pon\"${YELLOW} and to disconnect run ${BLUE}\"sudo poff\" ${SET}"
|
||||
break;;
|
||||
*) echo "${RED}Wrong Selection, Select among Y or n${SET}";;
|
||||
esac
|
||||
done
|
||||
|
||||
read -p "Press ENTER key to reboot" ENTER
|
||||
reboot
|
@ -1,101 +0,0 @@
|
||||
#!/bin/sh
|
||||
'
|
||||
Created on July 12, 2019 by Saeed Johar (saeedjohar)
|
||||
'
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
BLUE='\033[1;34m'
|
||||
SET='\033[0m'
|
||||
|
||||
echo "${YELLOW}Please choose your Sixfab Shield/HAT:${SET}"
|
||||
echo "${YELLOW}1: GSM/GPRS Shield${SET}"
|
||||
echo "${YELLOW}2: 3G, 4G/LTE Base Shield${SET}"
|
||||
echo "${YELLOW}3: Cellular IoT App Shield${SET}"
|
||||
echo "${YELLOW}4: Cellular IoT HAT${SET}"
|
||||
echo "${YELLOW}5: Tracker HAT${SET}"
|
||||
echo "${YELLOW}6: 3G/4G Base HAT${SET}"
|
||||
|
||||
read shield_hat
|
||||
case $shield_hat in
|
||||
1) echo "${YELLOW}You chose GSM/GPRS Shield${SET}";;
|
||||
2) echo "${YELLOW}You chose Base Shield${SET}";;
|
||||
3) echo "${YELLOW}You chose CellularIoT Shield${SET}";;
|
||||
4) echo "${YELLOW}You chose CellularIoT HAT${SET}";;
|
||||
5) echo "${YELLOW}You chose Tracker HAT${SET}";;
|
||||
6) echo "${YELLOW}You chose 3G/4G Base HAT${SET}";;
|
||||
*) echo "${RED}Wrong Selection, exiting${SET}"; exit 1;
|
||||
esac
|
||||
|
||||
echo "${YELLOW}Downloading setup files${SET}"
|
||||
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/chat-connect -O chat-connect
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "${RED}Download failed${SET}"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/chat-disconnect -O chat-disconnect
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "${RED}Download failed${SET}"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/provider -O provider
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "${RED}Download failed${SET}"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
echo "${YELLOW}ppp install${SET}"
|
||||
apt-get install ppp -y
|
||||
|
||||
echo "${YELLOW}What is your carrier APN?${SET}"
|
||||
read carrierapn
|
||||
|
||||
while [ 1 ]
|
||||
do
|
||||
echo "${YELLOW}Does your carrier need username and password? [Y/n]${SET}"
|
||||
read usernpass
|
||||
|
||||
case $usernpass in
|
||||
[Yy]* ) while [ 1 ]
|
||||
do
|
||||
|
||||
echo "${YELLOW}Enter username${SET}"
|
||||
read username
|
||||
|
||||
echo "${YELLOW}Enter password${SET}"
|
||||
read password
|
||||
sed -i "s/noauth/#noauth\nuser \"$username\"\npassword \"$password\"/" provider
|
||||
break
|
||||
done
|
||||
|
||||
break;;
|
||||
|
||||
[Nn]* ) break;;
|
||||
*) echo "${RED}Wrong Selection, Select among Y or n${SET}";;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "${YELLOW}What is your device communication PORT? (ttyS0/ttyUSB3/etc.)${SET}"
|
||||
read devicename
|
||||
|
||||
mkdir -p /etc/chatscripts
|
||||
|
||||
mv chat-connect /etc/chatscripts/
|
||||
mv chat-disconnect /etc/chatscripts/
|
||||
|
||||
mkdir -p /etc/ppp/peers
|
||||
sed -i "s/#APN/$carrierapn/" provider
|
||||
sed -i "s/#DEVICE/$devicename/" provider
|
||||
mv provider /etc/ppp/peers/provider
|
||||
|
||||
if ! (grep -q 'sudo route' /etc/ppp/ip-up ); then
|
||||
echo "sudo route del default" >> /etc/ppp/ip-up
|
||||
echo "sudo route add default ppp0" >> /etc/ppp/ip-up
|
||||
fi
|
||||
|
||||
read -p "Press ENTER key to reboot" ENTER
|
||||
reboot
|
@ -1,77 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
BLUE='\033[1;34m'
|
||||
SET='\033[0m'
|
||||
|
||||
echo "${YELLOW}Installing PPP for Sixfab Cellular IoT Shield/HAT with Twilio Super SIM${SET}"
|
||||
|
||||
echo "${YELLOW}Downloading setup files${SET}"
|
||||
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/chat-connect -O chat-connect
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "${RED}Download failed${SET}"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/chat-disconnect -O chat-disconnect
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "${RED}Download failed${SET}"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/provider -O provider
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "${RED}Download failed${SET}"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
echo "${YELLOW}ppp and wiringpi (gpio tool) install${SET}"
|
||||
apt install ppp wiringpi -y
|
||||
|
||||
mkdir -p /etc/chatscripts
|
||||
|
||||
mv chat-connect /etc/chatscripts/
|
||||
mv chat-disconnect /etc/chatscripts/
|
||||
|
||||
mkdir -p /etc/ppp/peers
|
||||
sed -i "s/#APN/super/" provider
|
||||
sed -i "s/#DEVICE/ttyUSB3/" provider
|
||||
mv provider /etc/ppp/peers/provider
|
||||
|
||||
if ! (grep -q 'sudo route' /etc/ppp/ip-up ); then
|
||||
echo "sudo route del default" >> /etc/ppp/ip-up
|
||||
echo "sudo route add default ppp0" >> /etc/ppp/ip-up
|
||||
fi
|
||||
|
||||
while [ 1 ]
|
||||
do
|
||||
echo "${YELLOW}Do you want to activate auto connect/reconnect service at R.Pi boot up? [Y/n] ${SET}"
|
||||
read auto_reconnect
|
||||
|
||||
case $auto_reconnect in
|
||||
[Yy]* ) echo "${YELLOW}Downloading setup file${SET}"
|
||||
|
||||
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_service -O reconnect.service
|
||||
|
||||
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_cellulariot -O reconnect.sh
|
||||
|
||||
mv reconnect.sh /usr/src/
|
||||
mv reconnect.service /etc/systemd/system/
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable reconnect.service
|
||||
|
||||
break;;
|
||||
|
||||
[Nn]* ) echo "${YELLOW}To connect to internet run ${BLUE}\"sudo pon\"${YELLOW} and to disconnect run ${BLUE}\"sudo poff\" ${SET}"
|
||||
break;;
|
||||
*) echo "${RED}Wrong Selection, Select among Y or n${SET}";;
|
||||
esac
|
||||
done
|
||||
|
||||
read -p "Press ENTER key to reboot" ENTER
|
||||
reboot
|
@ -1,21 +0,0 @@
|
||||
#!/bin/sh
|
||||
# /usr/src/reconnect
|
||||
# for Base HAT
|
||||
|
||||
gpio -g mode 26 out #HAT_POWER_OFF
|
||||
gpio -g mode 19 out #W_DISABLE
|
||||
|
||||
gpio -g write 26 0
|
||||
gpio -g write 19 0
|
||||
|
||||
while true; do
|
||||
|
||||
ping -q -I ppp0 -c 1 8.8.8.8 -s 0 >/dev/null
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Connection down, reconnecting..."
|
||||
sudo pon
|
||||
fi
|
||||
|
||||
sleep 10
|
||||
done
|
@ -1,13 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
while true; do
|
||||
|
||||
ping -q -I ppp0 -c 1 8.8.8.8 -s 0 >/dev/null
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Connection down, reconnecting..."
|
||||
sudo pon
|
||||
fi
|
||||
|
||||
sleep 10
|
||||
done
|
@ -1,31 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
gpio -g mode 23 in #status
|
||||
gpio -g mode 24 out #powerkey
|
||||
gpio -g mode 17 out #enable
|
||||
|
||||
gpio -g write 17 1
|
||||
sleep 1
|
||||
gpio -g write 17 0
|
||||
|
||||
while true; do
|
||||
|
||||
if [ $(gpio -g read 23) = "1" ]; then
|
||||
echo "Power up"
|
||||
|
||||
#gpio -g write 24 0
|
||||
gpio -g write 24 1
|
||||
sleep 2
|
||||
gpio -g write 24 0
|
||||
sleep 2
|
||||
else
|
||||
ping -q -I ppp0 -c 1 8.8.8.8 -s 0 >/dev/null
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Connection down, reconnecting..."
|
||||
sudo pon
|
||||
fi
|
||||
fi
|
||||
|
||||
sleep 10
|
||||
done
|
@ -1,31 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
gpio -g mode 20 in
|
||||
gpio -g mode 11 out
|
||||
gpio -g mode 26 out
|
||||
|
||||
gpio -g write 26 0
|
||||
sleep 1
|
||||
gpio -g write 26 1
|
||||
|
||||
while true; do
|
||||
|
||||
if [ $(gpio -g read 20) = "1" ]; then
|
||||
echo "Power up"
|
||||
|
||||
gpio -g write 11 0
|
||||
gpio -g write 11 1
|
||||
sleep 2
|
||||
gpio -g write 11 0
|
||||
sleep 2
|
||||
else
|
||||
ping -q -I ppp0 -c 1 8.8.8.8 -s 0 >/dev/null
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Connection down, reconnecting..."
|
||||
sudo pon
|
||||
fi
|
||||
fi
|
||||
|
||||
sleep 10
|
||||
done
|
@ -1,26 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
gpio -g mode 19 in
|
||||
gpio -g mode 26 out
|
||||
|
||||
while true; do
|
||||
|
||||
if [ $(gpio -g read 19) = "0" ]; then
|
||||
echo "Power up"
|
||||
|
||||
gpio -g write 26 0
|
||||
gpio -g write 26 1
|
||||
sleep 2
|
||||
gpio -g write 26 0
|
||||
sleep 2
|
||||
else
|
||||
ping -q -I ppp0 -c 1 8.8.8.8 -s 0 >/dev/null
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Connection down, reconnecting..."
|
||||
sudo pon
|
||||
fi
|
||||
fi
|
||||
|
||||
sleep 10
|
||||
done
|
@ -1,30 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
gpio -g mode 23 in #status
|
||||
gpio -g mode 24 out #powerkey
|
||||
gpio -g mode 17 out #disable
|
||||
# enabling the power of the HAT
|
||||
gpio -g write 17 1
|
||||
sleep 1
|
||||
gpio -g write 17 0
|
||||
|
||||
while true; do
|
||||
|
||||
if [ $(gpio -g read 23) = "0" ]; then
|
||||
echo "Power up"
|
||||
|
||||
gpio -g write 24 1
|
||||
sleep 2
|
||||
gpio -g write 24 0
|
||||
sleep 2
|
||||
else
|
||||
ping -q -I ppp0 -c 1 8.8.8.8 -s 0 >/dev/null
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Connection down, reconnecting..."
|
||||
sudo pon
|
||||
fi
|
||||
fi
|
||||
|
||||
sleep 10
|
||||
done
|
@ -7,7 +7,15 @@ ABORT "NO ANSWER"
|
||||
TIMEOUT 30
|
||||
"" AT
|
||||
OK ATE0
|
||||
<<<<<<< HEAD:src/chat-connect
|
||||
OK AT+CPIN?
|
||||
OK AT+CSQ
|
||||
OK AT+CREG?
|
||||
OK AT+CGREG?
|
||||
OK AT+COPS?
|
||||
=======
|
||||
OK ATI;+CSQ;+COPS?;+CGREG?;&D2
|
||||
>>>>>>> master:ppp_installer/chat-connect
|
||||
OK AT+CGDCONT=1,"IP","\T",,0,0
|
||||
OK ATD*99#
|
||||
CONNECT
|
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=150 # Count, Check network for ($NETWORK_TIMEOUT x 2 Seconds)
|
181
src/configure_modem.sh
Normal file
181
src/configure_modem.sh
Normal file
@ -0,0 +1,181 @@
|
||||
#!/bin/bash
|
||||
|
||||
source functions.sh
|
||||
|
||||
# default pins set for cellulariot hat
|
||||
STATUS=${STATUS_PIN:-23}
|
||||
POWERKEY=${POWERKEY_PIN:-24}
|
||||
POWER_UP_REQUIRED=${POWERUP_FLAG:-1}
|
||||
|
||||
# default arguments
|
||||
APN=${SIM_APN:-super}
|
||||
|
||||
# 1 : STATUS
|
||||
# 2 : POWERKEY
|
||||
function power_up_module
|
||||
{
|
||||
# Configure pins
|
||||
gpio -g mode $STATUS in
|
||||
gpio -g mode $POWERKEY out
|
||||
|
||||
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 5
|
||||
|
||||
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
|
||||
fi
|
||||
else
|
||||
debug "Module is just powered up."
|
||||
return 0
|
||||
break
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
if [[ $POWER_UP_REQUIRED -eq 1 ]]; then
|
||||
if power_up_module -eq 0 ; then sleep 0.1; else debug "Module couldn't be powered up! Check the hardware setup!"; fi
|
||||
else
|
||||
debug "Power up is not required."
|
||||
fi
|
||||
|
||||
### Modem configuration for RMNET/PPP mode ##################################
|
||||
debug "Checking APN and Modem Modem..."
|
||||
|
||||
# APN Configuration
|
||||
# -----------------
|
||||
atcom "AT+CGDCONT?" | grep $APN > /dev/null
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
atcom "AT+CGDCONT=1,\"IPV4V6\",\"$APN\""
|
||||
debug "APN is updated."
|
||||
fi
|
||||
|
||||
# Check the vendor
|
||||
lsusb | grep Quectel >> /dev/null
|
||||
IS_QUECTEL=$?
|
||||
|
||||
lsusb | grep Telit >> /dev/null
|
||||
IS_TELIT=$?
|
||||
|
||||
# Modem Mode Configuration
|
||||
# ------------------------
|
||||
# For Quectel
|
||||
if [[ $IS_QUECTEL -eq 0 ]]; then
|
||||
|
||||
lsusb | grep BG9 > /dev/null
|
||||
MODEL_BG9X=$?
|
||||
|
||||
if [[ $MODEL_BG9X -eq 0 ]]; then
|
||||
# BG95 and BG96
|
||||
|
||||
# RAT Searching Sequence
|
||||
atcom "AT+QCFG=\"nwscanseq\"" | grep 020301 > /dev/null
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
atcom "AT+QCFG=\"nwscanseq\",00"
|
||||
debug "Configure RAT Searching Sequence is updated."
|
||||
fi
|
||||
|
||||
# RAT(s) to be Searched
|
||||
atcom "AT+QCFG=\"nwscanmode\"" | grep 0 > /dev/null
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
atcom "AT+QCFG=\"nwscanmode\",0"
|
||||
debug "RAT(s) to be Searched is updated."
|
||||
fi
|
||||
|
||||
# Network Category to be Searched under LTE RAT
|
||||
atcom "AT+QCFG=\"iotopmode\"" | grep 0 > /dev/null
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
atcom "AT+QCFG=\"iotopmode\",0"
|
||||
debug "Network Category to be Searched under LTE RAT is updated."
|
||||
fi
|
||||
|
||||
# end of configuraiton for BG95/6
|
||||
else
|
||||
# EC25 or derives.
|
||||
atcom "AT+QCFG=\"usbnet\"" | grep 0 > /dev/null
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
atcom "AT+QCFG=\"usbnet\",0"
|
||||
debug "PPP mode is activated."
|
||||
debug "Modem restarting..."
|
||||
|
||||
sleep 20
|
||||
|
||||
# Check modem is started
|
||||
route -n | grep wwan0 >> /dev/null
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo
|
||||
else
|
||||
# If modem don't reboot automatically, reset manually
|
||||
atcom "AT+CFUN=1,1" # rebooting modem
|
||||
sleep 20
|
||||
fi
|
||||
|
||||
# Check modem is started!
|
||||
for i in {1..120}; do
|
||||
route -n | grep wwan0 >> /dev/null
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo
|
||||
debug "Modem is restarted."
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
printf "*"
|
||||
done
|
||||
sleep 5 # wait until modem is ready
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Telit
|
||||
elif [[ $IS_TELIT -eq 0 ]]; then
|
||||
atcom "AT#USBCFG?" | grep 0 >> /dev/null
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
atcom "AT#USBCFG=0"
|
||||
debug "PPP mode is activated."
|
||||
debug "Modem restarting..."
|
||||
|
||||
sleep 20
|
||||
|
||||
# Check modem is started!
|
||||
for i in {1..120}; do
|
||||
route -n | grep wwan0 >> /dev/null
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo
|
||||
debug "Modem is restarted."
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
printf "*"
|
||||
done
|
||||
sleep 5 # wait until modem is ready
|
||||
fi
|
||||
|
||||
# Unknown
|
||||
else
|
||||
debug "The cellular module couldn't be detected!"
|
||||
exit 1
|
||||
fi
|
||||
### End of Modem configuration for RMNET/PPP mode ############################
|
||||
|
||||
|
||||
# Check the network is ready
|
||||
# --------------------------
|
||||
if check_network -eq 0; then exit 0; else debug "Network registeration is failed!. Modem configuration is unsuccesfully ended!"; exit 1; fi
|
||||
|
59
src/functions.sh
Normal file
59
src/functions.sh
Normal file
@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
|
||||
source configs.sh
|
||||
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
BLUE='\033[1;34m'
|
||||
GREEN='\033[0;32m'
|
||||
CYAN='\033[0;36m'
|
||||
PURPLE='\033[0;35m'
|
||||
SET='\033[0m'
|
||||
|
||||
function debug
|
||||
{
|
||||
ECHO_PARAM=${2:-''}
|
||||
echo -e $ECHO_PARAM ${GREEN}$(date "+%Y/%m/%d->${BLUE}%H:%M:%S") ${SET} "$1"
|
||||
}
|
||||
|
||||
function check_network()
|
||||
{
|
||||
# Check the network is ready
|
||||
debug "Checking the network is ready..."
|
||||
|
||||
for n in $(seq 1 $NETWORK_CHECK_TIMEOUT); do
|
||||
NETWORK_OK=0
|
||||
|
||||
debug "SIM Status: " "-n" # no line break
|
||||
atcom AT+CPIN? | grep "CPIN: READY"
|
||||
SIM_READY=$?
|
||||
|
||||
if [[ $SIM_READY -ne 0 ]]; then atcom AT+CPIN? | grep "CPIN:"; fi
|
||||
|
||||
|
||||
debug "Network Registeration Status: " "-n" # no line break
|
||||
NR_TEXT=`atcom AT+CREG? | grep "CREG:"`
|
||||
echo $NR_TEXT
|
||||
|
||||
# For super SIM
|
||||
echo $NR_TEXT | grep "CREG: 0,5" > /dev/null
|
||||
NETWORK_REG=$?
|
||||
# For native SIM
|
||||
echo $NR_TEXT | grep "CREG: 0,1" > /dev/null
|
||||
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
|
||||
debug "Retrying network registeration..."
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
debug "Network registeration is failed! Please check SIM card, data plan, antennas etc."
|
||||
return 1
|
||||
}
|
@ -1,14 +1,13 @@
|
||||
[Unit]
|
||||
Description=PPP Auto Connection
|
||||
Description=PPP Connection Manager
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/sh /usr/src/reconnect.sh
|
||||
WorkingDirectory=/usr/src/
|
||||
ExecStart=/bin/bash ppp_connection_manager.sh
|
||||
WorkingDirectory=/opt/sixfab/ppp_connection_manager
|
||||
StandardOutput=inherit
|
||||
StandardError=inherit
|
||||
Restart=always
|
||||
User=pi
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
31
src/ppp_connection_manager.sh
Normal file
31
src/ppp_connection_manager.sh
Normal file
@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
|
||||
source functions.sh
|
||||
|
||||
LOG_FOLDER="./logs"
|
||||
LOG_FILE_NAME=$(date "+%Y_%m_%d_%H:%M:%S")
|
||||
|
||||
if [[ -e $LOG_FOLDER ]]; then
|
||||
debug "Log folder already exist!"
|
||||
else
|
||||
sudo mkdir $LOG_FOLDER
|
||||
debug "Log folder is created."
|
||||
fi
|
||||
|
||||
for i in {1..4}; do
|
||||
bash configure_modem.sh |& sudo tee -a ./logs/$LOG_FILE_NAME.log
|
||||
MODEM_CONFIG=${PIPESTATUS[0]} # compatible with only bash
|
||||
|
||||
if [[ $MODEM_CONFIG -eq 0 ]]; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if [[ $MODEM_CONFIG -eq 0 ]]; then
|
||||
bash ppp_reconnect.sh |& sudo tee -a ./logs/$LOG_FILE_NAME.log
|
||||
else
|
||||
debug "Modem configuration is failed multiple times!"
|
||||
debug "Checkout other troubleshooting steps on docs.sixfab.com."
|
||||
exit 1
|
||||
fi
|
58
src/reconnect_scripts/reconnect_basehat
Normal file
58
src/reconnect_scripts/reconnect_basehat
Normal file
@ -0,0 +1,58 @@
|
||||
#!/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;
|
||||
|
||||
# check default interface
|
||||
route | grep ppp | grep default > /dev/null
|
||||
PPP_IS_DEFAULT=$?
|
||||
if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi
|
||||
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
|
||||
|
||||
# check default interface
|
||||
route | grep ppp | grep default > /dev/null
|
||||
PPP_IS_DEFAULT=$?
|
||||
if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi
|
||||
fi
|
||||
fi
|
||||
sleep $INTERVAL
|
||||
done
|
46
src/reconnect_scripts/reconnect_baseshield
Executable file
46
src/reconnect_scripts/reconnect_baseshield
Executable file
@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
|
||||
source functions.sh
|
||||
source configs.sh
|
||||
|
||||
if check_network -eq 0; then
|
||||
debug "PPP chatscript is starting...";
|
||||
sudo pon;
|
||||
|
||||
# check default interface
|
||||
route | grep ppp | grep default > /dev/null
|
||||
PPP_IS_DEFAULT=$?
|
||||
if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi
|
||||
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
|
||||
|
||||
# check default interface
|
||||
route | grep ppp | grep default > /dev/null
|
||||
PPP_IS_DEFAULT=$?
|
||||
if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi
|
||||
fi
|
||||
fi
|
||||
sleep $INTERVAL
|
||||
done
|
102
src/reconnect_scripts/reconnect_cellulariot
Normal file
102
src/reconnect_scripts/reconnect_cellulariot
Normal file
@ -0,0 +1,102 @@
|
||||
#!/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 5
|
||||
|
||||
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
|
||||
fi
|
||||
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
|
||||
|
||||
# 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;
|
||||
|
||||
# check default interface
|
||||
route | grep ppp | grep default > /dev/null
|
||||
PPP_IS_DEFAULT=$?
|
||||
if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi
|
||||
|
||||
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..."
|
||||
restart_power
|
||||
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 sleep 0.1; else debug "Network registeration is failed!"; fi
|
||||
sudo pon
|
||||
|
||||
# check default interface
|
||||
route | grep ppp | grep default > /dev/null
|
||||
PPP_IS_DEFAULT=$?
|
||||
if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi
|
||||
fi
|
||||
fi
|
||||
sleep $INTERVAL
|
||||
done
|
102
src/reconnect_scripts/reconnect_cellulariot_app
Normal file
102
src/reconnect_scripts/reconnect_cellulariot_app
Normal file
@ -0,0 +1,102 @@
|
||||
#!/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 5
|
||||
|
||||
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
|
||||
fi
|
||||
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
|
||||
|
||||
# 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;
|
||||
|
||||
# check default interface
|
||||
route | grep ppp | grep default > /dev/null
|
||||
PPP_IS_DEFAULT=$?
|
||||
if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi
|
||||
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..."
|
||||
restart_power
|
||||
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 sleep 0.1; else debug "Network registeration is failed!"; fi
|
||||
sudo pon
|
||||
|
||||
# check default interface
|
||||
route | grep ppp | grep default > /dev/null
|
||||
PPP_IS_DEFAULT=$?
|
||||
if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi
|
||||
fi
|
||||
fi
|
||||
sleep $INTERVAL
|
||||
done
|
89
src/reconnect_scripts/reconnect_gprsshield
Normal file
89
src/reconnect_scripts/reconnect_gprsshield
Normal file
@ -0,0 +1,89 @@
|
||||
#!/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 5
|
||||
|
||||
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
|
||||
fi
|
||||
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;
|
||||
|
||||
# check default interface
|
||||
route | grep ppp | grep default > /dev/null
|
||||
PPP_IS_DEFAULT=$?
|
||||
if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi
|
||||
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
|
||||
|
||||
# check default interface
|
||||
route | grep ppp | grep default > /dev/null
|
||||
PPP_IS_DEFAULT=$?
|
||||
if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi
|
||||
fi
|
||||
fi
|
||||
sleep $INTERVAL
|
||||
done
|
103
src/reconnect_scripts/reconnect_tracker
Normal file
103
src/reconnect_scripts/reconnect_tracker
Normal file
@ -0,0 +1,103 @@
|
||||
#!/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 5
|
||||
|
||||
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
|
||||
fi
|
||||
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
|
||||
|
||||
# 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;
|
||||
|
||||
# check default interface
|
||||
route | grep ppp | grep default > /dev/null
|
||||
PPP_IS_DEFAULT=$?
|
||||
if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi
|
||||
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..."
|
||||
restart_power
|
||||
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 sleep 0.1; else debug "Network registeration is failed!"; fi
|
||||
sudo pon
|
||||
|
||||
# check default interface
|
||||
route | grep ppp | grep default > /dev/null
|
||||
PPP_IS_DEFAULT=$?
|
||||
if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi
|
||||
fi
|
||||
fi
|
||||
sleep $INTERVAL
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user