Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ The Basics™ Station protocol enables the LoRa gateways with a reliable and sec

### Hardware

* Raspberry Pi 3/4 or [balenaFin](https://www.balena.io/fin/)
* SD card in case of the RPi 4
* Raspberry Pi 0, 3/4 or [balenaFin](https://www.balena.io/fin/)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to discussion at https://twitter.com/U8dEngineer/status/1484876878926209032 maybe specifically state which Pi Zeros are supported?

* SD card in case of the RPi 0/3/4

#### LoRa Concentrators (SPI)

Expand Down Expand Up @@ -146,6 +146,8 @@ Variable Name | Value | Description | Default
**`TC_TRUST`** | `STRING` | Certificate for the server | Automatically retrieved from LetsEncryt based on the `TTN_STACK_VERSION` value
**`MODEL`** | `STRING` | ```SX1301``` or ```SX1302``` | ```SX1301```
**`TC_URI`** | `STRING` | basics station TC URI to get connected. |
**`EUI_ADDRESS`** | `STRING` | In case you use Raspberry Pi Zero without `eth0` you can use this to generate the `EUI` from `wlan0` instead of another network interface. You will need to add `wlan0` |


#### The Things Stack (TTS) Specific Variables (V3)

Expand Down
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: 2

services:

basicstation:
build: .
container_name: basicstation
restart: unless-stopped
privileged: true
network_mode: host # required to read main interface MAC instead of virtual one
environment:
MODEL: "SX1301"
GW_GPS: "false"
GW_RESET_GPIO: 17
GW_ENABLE_GPIO: 0
TTN_STACK_VERSION: 3
TTN_REGION: "eu1"
#TC_URI: # uses TTN server by default, based on the TTN_STACK_VERSION and TTN_REGION variables
#TC_TRUST: # uses TTN certificates by default
TC_KEY:
#EUI_ADDRESS: # required if you use a Pi Zero W or Pi Zero 2 W
2 changes: 2 additions & 0 deletions setup.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ ARCH.linux.default = x86_64-linux-gnu
ARCH.linuxV2.default = x86_64-linux-gnu
ARCH.linuxpico.default = x86_64-linux-gnu
ARCH.corecell.default = arm-linux-gnueabihf
ARCH.corecell.rpi = arm-linux-gnueabihf
ARCH.corecell.armv7hf = arm-linux-gnueabihf
ARCH.corecell.aarch64 = aarch64-linux-gnu
ARCH.rpi.default = arm-linux-gnueabihf
ARCH.rpi.rpi = arm-linux-gnueabihf
ARCH.rpi.armv7hf = arm-linux-gnueabihf
ARCH.rpi.aarch64 = aarch64-linux-gnu
ARCH.kerlink.default = arm-klk-linux-gnueabi
Expand Down
8 changes: 6 additions & 2 deletions src-linux/sys_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,12 @@ static void findDefaultEui () {
if( ifc[0] != 0 ) {
if( strncmp(ifc, "eth", 3) == 0 && strncmp(dname, "eth", 3) != 0 )
continue; // eth trumps other devices
// in case there is no eth0
if( strncmp(ifc, "wla", 3) == 0 && strncmp(dname, "wla", 3) != 0 )
continue; // wlan trumps other devices
// Otherwie choose alphabetically lowest - unless eth replaces something else
if( !((strncmp(ifc, "eth", 3) == 0) ^ (strncmp(dname, "eth", 3) == 0))
&& strcmp(ifc, dname) <= 0 )
&& strcmp(ifc, dname) > 0 )
continue; // not lower
}
strcpy(ifc, dname);
Expand All @@ -219,6 +222,7 @@ static void findDefaultEui () {
protoEUI = eui;
rt_free((void*)protoEuiSrc);
protoEuiSrc = rt_strdup(path);
LOG(MOD_SYS|INFO, "findDefaultEui -> protoEuiSrc %s - protoEUI %lu", protoEuiSrc, protoEUI);
}
}

Expand Down Expand Up @@ -366,7 +370,7 @@ void sys_ini () {
logfile.path==NULL ? "stderr" : logfile.path, logfile.size, logfile.rotate);
LOG(MOD_SYS|INFO, "Station Ver : %s", CFG_version " " CFG_bdate);
LOG(MOD_SYS|INFO, "Package Ver : %s", sys_version());
LOG(MOD_SYS|INFO, "proto EUI : %:E\t(%s)", protoEUI, protoEuiSrc);
LOG(MOD_SYS|INFO, "proto EUI(x) : %:E\t(%s)", protoEUI, protoEuiSrc);
LOG(MOD_SYS|INFO, "prefix EUI : %:E\t(%s)", prefixEUI, prefixEuiSrc);
LOG(MOD_SYS|INFO, "Station EUI : %:E", sys_eui());
LOG(MOD_SYS|INFO, "Station home: %s\t(%s)", homeDir, homeDirSrc);
Expand Down
10 changes: 9 additions & 1 deletion start.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#!/usr/bin/env bash

TAG_KEY="EUI"
TTN_EUI=$(cat /sys/class/net/eth0/address | sed -r 's/[:]+//g' | sed -e 's#\(.\{6\}\)\(.*\)#\1fffe\2#g')

if [ -z ${EUI_ADDRESS} ] ;
then
TTN_EUI=$(cat /sys/class/net/eth0/address | sed -r 's/[:]+//g' | sed -e 's#\(.\{6\}\)\(.*\)#\1fffe\2#g')
else
echo "Using DEVICE: $EUI_ADDRESS"
TTN_EUI=$(cat /sys/class/net/wlan0/address | sed -r 's/[:]+//g' | sed -e 's#\(.\{6\}\)\(.*\)#\1fffe\2#g')
fi


echo "Gateway EUI: $TTN_EUI"

Expand Down