diff --git a/README.md b/README.md index d68db6e..04e8ef1 100644 --- a/README.md +++ b/README.md @@ -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/) +* SD card in case of the RPi 0/3/4 #### LoRa Concentrators (SPI) @@ -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) diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..65905ae --- /dev/null +++ b/docker-compose.yml @@ -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 diff --git a/setup.gmk b/setup.gmk index c0c7e42..a25e74d 100644 --- a/setup.gmk +++ b/setup.gmk @@ -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 diff --git a/src-linux/sys_linux.c b/src-linux/sys_linux.c index 5b637c9..019095f 100644 --- a/src-linux/sys_linux.c +++ b/src-linux/sys_linux.c @@ -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); @@ -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); } } @@ -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); diff --git a/start.sh b/start.sh index 25ebada..dd5c832 100644 --- a/start.sh +++ b/start.sh @@ -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"