forked from mpous/basicstation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_common.sh
More file actions
30 lines (27 loc) · 1.23 KB
/
start_common.sh
File metadata and controls
30 lines (27 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Defaults to TTN server v2, EU region
TTN_STACK_VERSION=${TTN_STACK_VERSION:-2}
if [ $TTN_STACK_VERSION -eq 2 ]; then
TTN_REGION=${TTN_REGION:-"eu"}
TC_URI=${TC_URI:-"wss://lns.${TTN_REGION}.thethings.network:443"}
TC_TRUST=${TC_TRUST:-$(curl --silent "https://letsencrypt.org/certs/trustid-x3-root.pem.txt"))}
elif [ $TTN_STACK_VERSION -eq 3 ]; then
TTN_REGION=${TTN_REGION:-"eu1"}
TC_URI=${TC_URI:-"wss://${TTN_REGION}.cloud.thethings.network:8887"}
TC_TRUST=${TC_TRUST:-$(curl --silent "https://letsencrypt.org/certs/{trustid-x3-root.pem.txt,isrgrootx1.pem}"))}
else
echo -e "\033[91mERROR: Wrong TTN_STACK_VERSION value, should be either 2 o 3.\033[0m"
balena-idle
fi
# Check configuration
if [ "$TC_URI" == "" ] || [ "$TC_TRUST" == "" ]
then
echo -e "\033[91mERROR: Missing configuration, define either TTN_STACK_VERSION or TC_URI and TC_TRUST.\033[0m"
balena-idle
fi
echo "Server: $TC_URI"
# declare map of hardware pins to GPIO on Raspberry Pi
declare -a pinToGPIO
pinToGPIO=( -1 -1 -1 2 -1 3 -1 4 14 -1 15 17 18 27 -1 22 23 -1 24 10 -1 9 25 11 8 -1 7 0 1 5 -1 6 12 13 -1 19 16 26 20 -1 21)
GW_RESET_PIN=${GW_RESET_PIN:-11}
GW_RESET_GPIO=${GW_RESET_GPIO:-${pinToGPIO[$GW_RESET_PIN]}}
LORAGW_SPI=${LORAGW_SPI:-"/dev/spidev0.0"}