m
This commit is contained in:
parent
f91f6dd837
commit
37b773d08a
156
run.sh
156
run.sh
@ -3,8 +3,8 @@
|
|||||||
# Exit if we're debugging and haven't yet built the gateway
|
# Exit if we're debugging and haven't yet built the gateway
|
||||||
|
|
||||||
if [ ! -f "ttn-gateway" ]; then
|
if [ ! -f "ttn-gateway" ]; then
|
||||||
echo "ERROR: gateway executable not yet built"
|
echo "ERROR: gateway executable not yet built"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $HALT != "" ]]; then
|
if [[ $HALT != "" ]]; then
|
||||||
@ -37,17 +37,17 @@ echo "*** Arch: '$RESIN_ARCH'"
|
|||||||
#####
|
#####
|
||||||
|
|
||||||
if [[ $GW_TYPE == "" ]]; then
|
if [[ $GW_TYPE == "" ]]; then
|
||||||
echo "ERROR: GW_TYPE required"
|
echo "ERROR: GW_TYPE required"
|
||||||
echo "See https://github.com/rayozzie/ttn-resin-gateway-rpi/blob/master/README.md"
|
echo "See https://github.com/rayozzie/ttn-resin-gateway-rpi/blob/master/README.md"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# We need to be online, wait if needed.
|
# We need to be online, wait if needed.
|
||||||
|
|
||||||
until $(curl --output /dev/null --silent --head --fail http://www.google.com); do
|
until $(curl --output /dev/null --silent --head --fail http://www.google.com); do
|
||||||
echo "[TTN Gateway]: Waiting for internet connection..."
|
echo "[TTN Gateway]: Waiting for internet connection..."
|
||||||
sleep 30
|
sleep 30
|
||||||
done
|
done
|
||||||
|
|
||||||
# Ensure that we've got the required env vars
|
# Ensure that we've got the required env vars
|
||||||
|
|
||||||
@ -57,20 +57,20 @@ echo "*******************"
|
|||||||
|
|
||||||
if [[ $GW_REGION == "" ]]; then
|
if [[ $GW_REGION == "" ]]; then
|
||||||
echo "ERROR: GW_REGION required"
|
echo "ERROR: GW_REGION required"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo GW_REGION: $GW_REGION
|
echo GW_REGION: $GW_REGION
|
||||||
|
|
||||||
if [[ $GW_DESCRIPTION == "" ]]; then
|
if [[ $GW_DESCRIPTION == "" ]]; then
|
||||||
echo "ERROR: GW_DESCRIPTION required"
|
echo "ERROR: GW_DESCRIPTION required"
|
||||||
echo "See https://github.com/rayozzie/ttn-resin-gateway-rpi/blob/master/README.md"
|
echo "See https://github.com/rayozzie/ttn-resin-gateway-rpi/blob/master/README.md"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $GW_CONTACT_EMAIL == "" ]]; then
|
if [[ $GW_CONTACT_EMAIL == "" ]]; then
|
||||||
echo "ERROR: GW_CONTACT_EMAIL required"
|
echo "ERROR: GW_CONTACT_EMAIL required"
|
||||||
echo "See https://github.com/rayozzie/ttn-resin-gateway-rpi/blob/master/README.md"
|
echo "See https://github.com/rayozzie/ttn-resin-gateway-rpi/blob/master/README.md"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "******************"
|
echo "******************"
|
||||||
@ -80,11 +80,11 @@ echo ""
|
|||||||
|
|
||||||
if curl -sS --fail https://raw.githubusercontent.com/TheThingsNetwork/gateway-conf/master/$GW_REGION-global_conf.json --output ./global_conf.json
|
if curl -sS --fail https://raw.githubusercontent.com/TheThingsNetwork/gateway-conf/master/$GW_REGION-global_conf.json --output ./global_conf.json
|
||||||
then
|
then
|
||||||
echo Successfully loaded $GW_REGION-global_conf.json from TTN repo
|
echo Successfully loaded $GW_REGION-global_conf.json from TTN repo
|
||||||
else
|
else
|
||||||
echo "******************"
|
echo "******************"
|
||||||
echo "ERROR: GW_REGION not found"
|
echo "ERROR: GW_REGION not found"
|
||||||
echo "******************"
|
echo "******************"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -92,12 +92,12 @@ fi
|
|||||||
|
|
||||||
if curl -sS --fail ipinfo.io --output ./ipinfo.json
|
if curl -sS --fail ipinfo.io --output ./ipinfo.json
|
||||||
then
|
then
|
||||||
echo "Actual gateway location:"
|
echo "Actual gateway location:"
|
||||||
IPINFO=$(cat ./ipinfo.json)
|
IPINFO=$(cat ./ipinfo.json)
|
||||||
echo $IPINFO
|
echo $IPINFO
|
||||||
else
|
else
|
||||||
echo "Unable to determine gateway location"
|
echo "Unable to determine gateway location"
|
||||||
IPINFO="\"\""
|
IPINFO="\"\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set up environmental defaults for local.conf
|
# Set up environmental defaults for local.conf
|
||||||
@ -125,12 +125,12 @@ if [[ $GW_FORWARD_CRC_DISABLED == "" ]]; then GW_FORWARD_CRC_DISABLED="false"; f
|
|||||||
|
|
||||||
if [[ $GW_GPS_TTY_PATH == "" ]]
|
if [[ $GW_GPS_TTY_PATH == "" ]]
|
||||||
then
|
then
|
||||||
# Default to AMA0 unless this is an RPi3 with core frequency set in fleet config vars
|
# Default to AMA0 unless this is an RPi3 with core frequency set in fleet config vars
|
||||||
GW_GPS_TTY_PATH="/dev/ttyAMA0"
|
GW_GPS_TTY_PATH="/dev/ttyAMA0"
|
||||||
if [[ "$RESIN_MACHINE_NAME" == "raspberrypi3" && "$RESIN_HOST_CONFIG_core_freq" != "" ]]
|
if [[ "$RESIN_MACHINE_NAME" == "raspberrypi3" && "$RESIN_HOST_CONFIG_core_freq" != "" ]]
|
||||||
then
|
then
|
||||||
GW_GPS_TTY_PATH="/dev/ttyS0"
|
GW_GPS_TTY_PATH="/dev/ttyS0"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $GW_FAKE_GPS == "" ]]; then GW_FAKE_GPS="false"; fi
|
if [[ $GW_FAKE_GPS == "" ]]; then GW_FAKE_GPS="false"; fi
|
||||||
@ -199,60 +199,64 @@ echo "******************"
|
|||||||
echo "******************"
|
echo "******************"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Reset the board to a known state prior to launching the forwarder
|
|
||||||
|
|
||||||
if [[ $GW_TYPE == "imst-ic880a-spi" ]]; then
|
|
||||||
echo "Toggling reset pin on IMST iC880A-SPI Board"
|
|
||||||
gpio -1 mode 22 out
|
|
||||||
gpio -1 write 22 0
|
|
||||||
sleep 0.1
|
|
||||||
gpio -1 write 22 1
|
|
||||||
sleep 0.1
|
|
||||||
gpio -1 write 22 0
|
|
||||||
sleep 0.1
|
|
||||||
elif [[ $GW_TYPE == "linklabs-dev" ]]; then
|
|
||||||
echo "Toggling reset pin on LinkLabs Raspberry Pi Development Board"
|
|
||||||
gpio -1 mode 29 out
|
|
||||||
gpio -1 write 29 0
|
|
||||||
sleep 0.1
|
|
||||||
gpio -1 write 29 1
|
|
||||||
sleep 0.1
|
|
||||||
gpio -1 write 29 0
|
|
||||||
sleep 0.1
|
|
||||||
elif [[ $GW_TYPE == "risinghf" ]]; then
|
|
||||||
## found this info via gwrst.sh in the risinghf loriot concentrator install package
|
|
||||||
## that info toggled pin 2, which I must assume to be Wiring's GPIO02 and thus
|
|
||||||
## pin BCM27/RPI13 on Raspberry Pi. It couldn't be RPi pin 2 because that's 5VDC.
|
|
||||||
echo "Toggling reset pin on Rising HF Board"
|
|
||||||
gpio -1 mode 13 out
|
|
||||||
gpio -1 write 13 0
|
|
||||||
sleep 0.1
|
|
||||||
gpio -1 write 13 1
|
|
||||||
sleep 0.1
|
|
||||||
gpio -1 write 13 0
|
|
||||||
sleep 0.1
|
|
||||||
elif [[ $GW_TYPE == "custom" ]]; then
|
|
||||||
gpio -1 mode $CUSTOM_RESET_PIN out
|
|
||||||
gpio -1 write $CUSTOM_RESET_PIN 0
|
|
||||||
sleep 0.1
|
|
||||||
gpio -1 write $CUSTOM_RESET_PIN 1
|
|
||||||
sleep 0.1
|
|
||||||
gpio -1 write $CUSTOM_RESET_PIN 0
|
|
||||||
sleep 0.1
|
|
||||||
else
|
|
||||||
echo "ERROR: unrecognized GW_TYPE=$GW_TYPE"
|
|
||||||
echo "See https://github.com/rayozzie/ttn-resin-gateway-rpi/blob/master/README.md"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Fire up the forwarder.
|
# Fire up the forwarder.
|
||||||
|
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
|
|
||||||
|
# Reset the board to a known state prior to launching the forwarder
|
||||||
|
|
||||||
|
if [[ $GW_TYPE == "imst-ic880a-spi" ]]; then
|
||||||
|
echo "[TTN Gateway]: Toggling reset pin on IMST iC880A-SPI Board"
|
||||||
|
gpio -1 mode 22 out
|
||||||
|
gpio -1 write 22 0
|
||||||
|
sleep 0.1
|
||||||
|
gpio -1 write 22 1
|
||||||
|
sleep 0.1
|
||||||
|
gpio -1 write 22 0
|
||||||
|
sleep 0.1
|
||||||
|
elif [[ $GW_TYPE == "linklabs-dev" ]]; then
|
||||||
|
echo "[TTN Gateway]: Toggling reset pin on LinkLabs Raspberry Pi Development Board"
|
||||||
|
gpio -1 mode 29 out
|
||||||
|
gpio -1 write 29 0
|
||||||
|
sleep 0.1
|
||||||
|
gpio -1 write 29 1
|
||||||
|
sleep 0.1
|
||||||
|
gpio -1 write 29 0
|
||||||
|
sleep 0.1
|
||||||
|
elif [[ $GW_TYPE == "risinghf" ]]; then
|
||||||
|
## found this info via gwrst.sh in the risinghf loriot concentrator install package
|
||||||
|
## that info toggled pin 2, which I must assume to be Wiring's GPIO02 and thus
|
||||||
|
## pin BCM27/RPI13 on Raspberry Pi. It couldn't be RPi pin 2 because that's 5VDC.
|
||||||
|
echo "[TTN Gateway]: Toggling reset pin on Rising HF Board"
|
||||||
|
gpio -1 mode 13 out
|
||||||
|
gpio -1 write 13 0
|
||||||
|
sleep 0.1
|
||||||
|
gpio -1 write 13 1
|
||||||
|
sleep 0.1
|
||||||
|
gpio -1 write 13 0
|
||||||
|
sleep 0.1
|
||||||
|
elif [[ $GW_TYPE == "custom" ]]; then
|
||||||
|
echo "[TTN Gateway]: Toggling custom reset pin $CUSTOM_RESET_PIN"
|
||||||
|
gpio -1 mode $CUSTOM_RESET_PIN out
|
||||||
|
gpio -1 write $CUSTOM_RESET_PIN 0
|
||||||
|
sleep 0.1
|
||||||
|
gpio -1 write $CUSTOM_RESET_PIN 1
|
||||||
|
sleep 0.1
|
||||||
|
gpio -1 write $CUSTOM_RESET_PIN 0
|
||||||
|
sleep 0.1
|
||||||
|
else
|
||||||
|
echo "ERROR: unrecognized GW_TYPE=$GW_TYPE"
|
||||||
|
echo "See https://github.com/rayozzie/ttn-resin-gateway-rpi/blob/master/README.md"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "[TTN Gateway]: Starting packet forwarder..."
|
echo "[TTN Gateway]: Starting packet forwarder..."
|
||||||
./ttn-gateway
|
./ttn-gateway
|
||||||
echo "******************"
|
echo "******************"
|
||||||
echo "*** [TTN Gateway]: EXIT (retrying in 15s)"
|
echo "*** [TTN Gateway]: EXIT (retrying in 15s)"
|
||||||
echo "******************"
|
echo "******************"
|
||||||
sleep 15
|
sleep 15
|
||||||
done
|
|
||||||
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user