From a916038dddf5a4c5b1c35aa5a3ffb13cdf37c822 Mon Sep 17 00:00:00 2001 From: RAKwireless Date: Thu, 15 Aug 2019 11:42:07 +0800 Subject: [PATCH] 2.9.2 loraserver add enable_uplink_channel;Eth0 does not exist will use wlan0 to get gwid --- lora/set_eui.sh | 6 +++++- lora/update_gwid.sh | 21 ++++++++++++++++--- .../loraserver_conf/loraserver.as_923.toml | 2 +- .../loraserver.au_915_928.toml | 2 +- .../loraserver.cn_470_510.toml | 2 +- .../loraserver_conf/loraserver.eu_433.toml | 2 +- .../loraserver.eu_863_870.toml | 2 +- .../loraserver.in_865_867.toml | 2 +- .../loraserver.kr_920_923.toml | 2 +- .../loraserver.ru_864_870.toml | 2 +- loraserver/loraserver_conf/loraserver.toml | 2 +- .../loraserver.us_902_928.toml | 2 +- sysconf/config.txt | 2 +- sysconf/install.sh | 4 ++-- 14 files changed, 36 insertions(+), 17 deletions(-) diff --git a/lora/set_eui.sh b/lora/set_eui.sh index 1c7c115..85c35db 100755 --- a/lora/set_eui.sh +++ b/lora/set_eui.sh @@ -5,10 +5,14 @@ if [ ! -e "/opt/ttn-gateway/packet_forwarder/lora_pkt_fwd/local_conf.json" ]; th if [[ `grep "$GATEWAY_EUI_NIC" /proc/net/dev` == "" ]]; then GATEWAY_EUI_NIC="wlan0" fi + + if [[ `grep "$GATEWAY_EUI_NIC" /proc/net/dev` == "" ]]; then + GATEWAY_EUI_NIC="usb0" + fi if [[ `grep "$GATEWAY_EUI_NIC" /proc/net/dev` == "" ]]; then echo "ERROR: No network interface found. Cannot set gateway ID." -# exit 1 + exit 1 fi GATEWAY_EUI=$(ip link show $GATEWAY_EUI_NIC | awk '/ether/ {print $2}' | awk -F\: '{print $1$2$3"FFFE"$4$5$6}') GATEWAY_EUI=${GATEWAY_EUI^^} diff --git a/lora/update_gwid.sh b/lora/update_gwid.sh index 5b0bed6..cbf251b 100755 --- a/lora/update_gwid.sh +++ b/lora/update_gwid.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # This script is a helper to update the Gateway_ID field of given # JSON configuration file, as a EUI-64 address generated from the 48-bits MAC @@ -9,9 +9,23 @@ iot_sk_update_gwid() { # get gateway ID from its MAC address to generate an EUI-64 address + GATEWAY_EUI_NIC="eth0" + if [[ `grep "$GATEWAY_EUI_NIC" /proc/net/dev` == "" ]]; then + GATEWAY_EUI_NIC="wlan0" + fi + + if [[ `grep "$GATEWAY_EUI_NIC" /proc/net/dev` == "" ]]; then + GATEWAY_EUI_NIC="usb0" + fi + + if [[ `grep "$GATEWAY_EUI_NIC" /proc/net/dev` == "" ]]; then + echo "ERROR: No network interface found. Cannot set gateway ID." + exit 1 + fi + GWID_MIDFIX="fffe" - GWID_BEGIN=$(ip link show eth0 | awk '/ether/ {print $2}' | awk -F\: '{print $1$2$3}') - GWID_END=$(ip link show eth0 | awk '/ether/ {print $2}' | awk -F\: '{print $4$5$6}') + GWID_BEGIN=$(ip link show $GATEWAY_EUI_NIC | awk '/ether/ {print $2}' | awk -F\: '{print $1$2$3}') + GWID_END=$(ip link show $GATEWAY_EUI_NIC | awk '/ether/ {print $2}' | awk -F\: '{print $4$5$6}') # replace last 8 digits of default gateway ID by actual GWID, in given JSON configuration file sed -i 's/\(^\s*"gateway_ID":\s*"\).\{16\}"\s*\(,\?\).*$/\1'${GWID_BEGIN}${GWID_MIDFIX}${GWID_END}'"\2/' $1 @@ -29,3 +43,4 @@ fi iot_sk_update_gwid $1 exit 0 + diff --git a/loraserver/loraserver_conf/loraserver.as_923.toml b/loraserver/loraserver_conf/loraserver.as_923.toml index ba06f15..fe79c70 100644 --- a/loraserver/loraserver_conf/loraserver.as_923.toml +++ b/loraserver/loraserver_conf/loraserver.as_923.toml @@ -67,7 +67,7 @@ net_id="000000" # LoRaWAN network related settings. [network_server.network_settings] - + enabled_uplink_channels=[0, 1, 2, 3, 4, 5, 6, 7] # Extra channel configuration. # # Use this for LoRaWAN regions where it is possible to extend the by default diff --git a/loraserver/loraserver_conf/loraserver.au_915_928.toml b/loraserver/loraserver_conf/loraserver.au_915_928.toml index 9587716..c9e68e2 100644 --- a/loraserver/loraserver_conf/loraserver.au_915_928.toml +++ b/loraserver/loraserver_conf/loraserver.au_915_928.toml @@ -67,7 +67,7 @@ net_id="000000" # LoRaWAN network related settings. [network_server.network_settings] - + enabled_uplink_channels=[8, 9, 10, 11, 12, 13, 14, 15] # Extra channel configuration. # # Use this for LoRaWAN regions where it is possible to extend the by default diff --git a/loraserver/loraserver_conf/loraserver.cn_470_510.toml b/loraserver/loraserver_conf/loraserver.cn_470_510.toml index 9cb297d..90926a3 100644 --- a/loraserver/loraserver_conf/loraserver.cn_470_510.toml +++ b/loraserver/loraserver_conf/loraserver.cn_470_510.toml @@ -67,7 +67,7 @@ net_id="000000" # LoRaWAN network related settings. [network_server.network_settings] - + enabled_uplink_channels=[80, 81, 82, 83, 84, 85, 86, 87] # Extra channel configuration. # # Use this for LoRaWAN regions where it is possible to extend the by default diff --git a/loraserver/loraserver_conf/loraserver.eu_433.toml b/loraserver/loraserver_conf/loraserver.eu_433.toml index d4b5801..7c73972 100644 --- a/loraserver/loraserver_conf/loraserver.eu_433.toml +++ b/loraserver/loraserver_conf/loraserver.eu_433.toml @@ -67,7 +67,7 @@ net_id="000000" # LoRaWAN network related settings. [network_server.network_settings] - + enabled_uplink_channels=[0, 1, 2, 3, 4, 5, 6, 7] # Extra channel configuration. # # Use this for LoRaWAN regions where it is possible to extend the by default diff --git a/loraserver/loraserver_conf/loraserver.eu_863_870.toml b/loraserver/loraserver_conf/loraserver.eu_863_870.toml index d968009..bd9ef74 100644 --- a/loraserver/loraserver_conf/loraserver.eu_863_870.toml +++ b/loraserver/loraserver_conf/loraserver.eu_863_870.toml @@ -67,7 +67,7 @@ net_id="000000" # LoRaWAN network related settings. [network_server.network_settings] - + enabled_uplink_channels=[0, 1, 2, 3, 4, 5, 6, 7] # Extra channel configuration. # # Use this for LoRaWAN regions where it is possible to extend the by default diff --git a/loraserver/loraserver_conf/loraserver.in_865_867.toml b/loraserver/loraserver_conf/loraserver.in_865_867.toml index af3567d..84d9ff7 100644 --- a/loraserver/loraserver_conf/loraserver.in_865_867.toml +++ b/loraserver/loraserver_conf/loraserver.in_865_867.toml @@ -67,7 +67,7 @@ net_id="000000" # LoRaWAN network related settings. [network_server.network_settings] - + enabled_uplink_channels=[0, 1, 2] # Extra channel configuration. # # Use this for LoRaWAN regions where it is possible to extend the by default diff --git a/loraserver/loraserver_conf/loraserver.kr_920_923.toml b/loraserver/loraserver_conf/loraserver.kr_920_923.toml index 3e3a704..1815b49 100644 --- a/loraserver/loraserver_conf/loraserver.kr_920_923.toml +++ b/loraserver/loraserver_conf/loraserver.kr_920_923.toml @@ -67,7 +67,7 @@ net_id="000000" # LoRaWAN network related settings. [network_server.network_settings] - + enabled_uplink_channels=[0, 1, 2, 3, 4, 5, 6, 7] # Extra channel configuration. # # Use this for LoRaWAN regions where it is possible to extend the by default diff --git a/loraserver/loraserver_conf/loraserver.ru_864_870.toml b/loraserver/loraserver_conf/loraserver.ru_864_870.toml index 90d70e6..3b25ef9 100644 --- a/loraserver/loraserver_conf/loraserver.ru_864_870.toml +++ b/loraserver/loraserver_conf/loraserver.ru_864_870.toml @@ -67,7 +67,7 @@ net_id="000000" # LoRaWAN network related settings. [network_server.network_settings] - + enabled_uplink_channels=[0, 1] # Extra channel configuration. # # Use this for LoRaWAN regions where it is possible to extend the by default diff --git a/loraserver/loraserver_conf/loraserver.toml b/loraserver/loraserver_conf/loraserver.toml index d968009..bd9ef74 100644 --- a/loraserver/loraserver_conf/loraserver.toml +++ b/loraserver/loraserver_conf/loraserver.toml @@ -67,7 +67,7 @@ net_id="000000" # LoRaWAN network related settings. [network_server.network_settings] - + enabled_uplink_channels=[0, 1, 2, 3, 4, 5, 6, 7] # Extra channel configuration. # # Use this for LoRaWAN regions where it is possible to extend the by default diff --git a/loraserver/loraserver_conf/loraserver.us_902_928.toml b/loraserver/loraserver_conf/loraserver.us_902_928.toml index 4702477..4abbddb 100644 --- a/loraserver/loraserver_conf/loraserver.us_902_928.toml +++ b/loraserver/loraserver_conf/loraserver.us_902_928.toml @@ -67,7 +67,7 @@ net_id="000000" # LoRaWAN network related settings. [network_server.network_settings] - + enabled_uplink_channels=[8, 9, 10, 11, 12, 13, 14, 15] # Extra channel configuration. # # Use this for LoRaWAN regions where it is possible to extend the by default diff --git a/sysconf/config.txt b/sysconf/config.txt index c889c1d..46864bc 100644 --- a/sysconf/config.txt +++ b/sysconf/config.txt @@ -57,4 +57,4 @@ dtparam=i2c_arm_baudrate=10000 # Enable audio (loads snd_bcm2835) dtparam=audio=on dtoverlay=pi3-disable-bt -#dtoverlay=dwc2 +dtoverlay=dwc2 diff --git a/sysconf/install.sh b/sysconf/install.sh index c4ae810..a5947ab 100755 --- a/sysconf/install.sh +++ b/sysconf/install.sh @@ -22,8 +22,8 @@ fi cp config.txt /boot/config.txt -#CMD_STR=`cat /boot/cmdline.txt` -#echo "$CMD_STR modules-load=dwc2,g_ether" > /boot/cmdline.txt +CMD_STR=`cat /boot/cmdline.txt` +echo "$CMD_STR modules-load=dwc2,g_ether" > /boot/cmdline.txt ./set_ip.sh