Commit c764b413 authored by Andreas Müller's avatar Andreas Müller
Browse files

Initial commit

parents
FROM balenalib/%%BALENA_MACHINE_NAME%%-debian:buster-build as builder
RUN apt -y install build-essential make git curl
WORKDIR /build
COPY . .
RUN chmod +x ./build.sh
RUN ./build.sh
FROM balenalib/%%BALENA_MACHINE_NAME%%-debian:buster
LABEL version="2021.02.11" maintainer="webmaster@am-wd.de"
WORKDIR /lora-gateway
COPY --from=builder /build/result/ ./
CMD ["bash", "./entrypoint.sh"]
#!/usr/bin/env bash
# TODO
# - run multiple services
# - add monitoring (prometheus node_exporter)
# - add wstunnel as optional proxy
git clone "https://github.com/lorabasics/basicstation"
pushd basicstation
for file in $(ls deps/lgw/*.patch); do
echo -n "https://raw.githubusercontent.com/balenalabs/basicstation/master/$file"
curl -sSLf "https://raw.githubusercontent.com/balenalabs/basicstation/master/$file" > /tmp/bs-tmp
if [ $? -eq 0 ]; then
echo " OK"
cat /tmp/bs-tmp > $file
else
echo " FAIL"
fi
done
for file in $(ls deps/lgw1302/*.patch); do
echo -n "https://raw.githubusercontent.com/balenalabs/basicstation/master/$file"
curl -sSLf "https://raw.githubusercontent.com/balenalabs/basicstation/master/$file" > /tmp/bs-tmp
if [ $? -eq 0 ]; then
echo " OK"
cat /tmp/bs-tmp > $file
else
echo " FAIL"
fi
done
make platform=rpi variant=std deps s-clean s-all
popd
mkdir result
pushd result
mv ../basicstation/build-rpi-std ./basicstation
mv ../station.conf ./
mv ../entrypoint.sh ./
curl -sSL "https://raw.githubusercontent.com/Lora-net/lora_gateway/master/reset_lgw.sh" > reset_lgw.sh
chmod +x reset_lgw.sh entrypoint.sh
popd
exit 0
#!/usr/bin/env bash
EUI_IFACE=${EUI_IFACE:-"eth0"}
TAG_KEY="EUI"
TTN_EUI=$(cat /sys/class/net/$EUI_IFACE/address | sed -r 's/[:]+//g' | sed -e 's#\(.\{6\}\)\(.*\)#\1fffe\2#g')
TTN_EUI=${TTN_EUI^^}
echo "EUI: $TTN_EUI"
ID=$(curl -sX GET -H "Content-Type: application/json" -H "Authorization: Bearer $BALENA_API_KEY" "https://api.balena-cloud.com/v5/device?\$filter=uuid%20eq%20'$BALENA_DEVICE_UUID'" | jq ".d | .[0] | .id")
curl -sX POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $BALENA_API_KEY" \
"https://api.balena-cloud.com/v5/device_tag" \
--data "{ \"device\": \"$ID\", \"tag_key\": \"$TAG_KEY\", \"value\": \"$TTN_EUI\" }" \
&> /dev/null
TC_URI=${TC_URI:-"wss://eu1.cloud.thethings.network:8887"}
TC_TRUST_LINK=${TC_TRUST_LINK:-"https://letsencrypt.org/certs/isrg-root-x1-cross-signed.pem"}
TC_TRUST=${TC_TRUST:-$(curl -sSL "$TC_TRUST_LINK")}
echo "$TC_URI" > tc.uri
echo "$TC_TRUST" > tc.trust
if [ ! -z "$TC_KEY" ]; then
echo "Authorization: Bearer $TC_KEY" | perl -p -e 's/\r\n|\n|\r/\r\n/g' > tc.key
fi
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]}}
LOG_LEVEL=${LOG_LEVEL:-"WARNING"}
sed "s/\"log_level\": \"LEVEL\"/\"log_level\": \"$LOG_LEVEL\"/g" station.conf.template > station.conf
sed -i "s/lgw.sh start GPIOPIN/lgw.sh start $GW_RESET_GPIO/g" station.conf
./basicstation/bin/station
balena-idle
{
"SX1301_conf": {
"lorawan_public": true,
"clksrc": 1,
"device": "/dev/spidev0.0", /* if disabled here, provide it via environment RADIODEV=/device/path */
"radio_0": {
"type": "SX1257",
"rssi_offset": -166.0,
"tx_enable": true,
"antenna_gain": 0
},
"radio_1": {
"type": "SX1257",
"rssi_offset": -166.0,
"tx_enable": true
}
},
"station_conf": {
"log_file": "stderr",
"log_level": "LEVEL", /* XDEBUG, DEBUG, VERBOSE, INFO, NOTICE, WARNING, ERROR, CRITICAL */
"log_size": 5000000,
"log_rotate": 3,
"CUPS_RESYNC_INTV": "1s",
"radio_init": "./reset_lgw.sh start GPIOPIN",
"RADIO_INIT_WAIT": "2s"
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment