From 30945f752514a91c8563238e31d34e7c574b13d2 Mon Sep 17 00:00:00 2001 From: Mykyta Dorokhin Date: Thu, 25 May 2017 10:13:35 -0500 Subject: mtcap: initial support for MTCAP-LORA-US915 card --- .../lora-network-server/lora-network-server.init | 22 +- .../lora-network-server/lora-network-server.init~ | 105 --------- ...obal_conf.json.3.0.0.MTCAP-LORA-1-5.EU868.basic | 195 ----------------- ...obal_conf.json.3.1.0.MTCAP-LORA-1-5.EU868.basic | 195 +++++++++++++++++ ...obal_conf.json.3.1.0.MTCAP-LORA-1-5.US915.basic | 240 +++++++++++++++++++++ .../mtcap/lora-packet-forwarder.init | 107 +++++++-- .../lora/lora-packet-forwarder_3.1.0.bb | 6 +- 7 files changed, 543 insertions(+), 327 deletions(-) delete mode 100755 recipes-connectivity/lora/lora-network-server/lora-network-server.init~ delete mode 100644 recipes-connectivity/lora/lora-packet-forwarder/global_conf.json.3.0.0.MTCAP-LORA-1-5.EU868.basic create mode 100644 recipes-connectivity/lora/lora-packet-forwarder/global_conf.json.3.1.0.MTCAP-LORA-1-5.EU868.basic create mode 100644 recipes-connectivity/lora/lora-packet-forwarder/global_conf.json.3.1.0.MTCAP-LORA-1-5.US915.basic diff --git a/recipes-connectivity/lora/lora-network-server/lora-network-server.init b/recipes-connectivity/lora/lora-network-server/lora-network-server.init index 70cc1f9..9dc8f7a 100755 --- a/recipes-connectivity/lora/lora-network-server/lora-network-server.init +++ b/recipes-connectivity/lora/lora-network-server/lora-network-server.init @@ -33,6 +33,8 @@ lora_1_0_hw="MTAC-LORA-1.0" lora_1_5_h_hw="MTAC-LORA-1.5" lora_mtcap_id="MTCAP-LORA" +lora_mtcap_id868="MTCAP-LORA-868" +lora_mtcap_id915="MTCAP-LORA-915" read_lora_hw_info() { # product-id of first lora card @@ -70,8 +72,21 @@ hardware_found() { return 0 elif [[ "$lora_id" =~ "$lora_mtcap_id" ]]; then - # currently only one valid global_conf.json + if [ "$lora_id" = "$lora_mtcap_id868" ]; then + GLOBAL_CONF=/opt/lora/global_conf.json.MTCAP_LORA_1_5.EU868 + elif [ "$lora_id" = "$lora_mtcap_id915" ]; then + GLOBAL_CONF=/opt/lora/global_conf.json.MTCAP_LORA_1_5.US915 + else + return 1 + fi + ln -sf /opt/lora/lora_pkt_fwd $pkt_fwd + + diff $GLOBAL_CONF /opt/lora/global_conf.json &> /dev/null + if [ $? -ne 0 ]; then + cp $GLOBAL_CONF /opt/lora/global_conf.json + fi + return 0 else echo Lora hardware not detected @@ -81,8 +96,10 @@ hardware_found() { do_start() { - + # create run directory mkdir -p $run_dir/1 + rm -rf $run_dir/1/* + read_lora_hw_info if ! [ -f $conf_file ]; then @@ -90,7 +107,6 @@ do_start() { exit 1 fi - if hardware_found; then echo "Found $lora_id with $lora_hw hardware" else diff --git a/recipes-connectivity/lora/lora-network-server/lora-network-server.init~ b/recipes-connectivity/lora/lora-network-server/lora-network-server.init~ deleted file mode 100755 index 4b80dc7..0000000 --- a/recipes-connectivity/lora/lora-network-server/lora-network-server.init~ +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/bash - -NAME="lora-network-server" -ENABLED="yes" - -[ -f /etc/default/$NAME ] && source /etc/default/$NAME - -run_dir=/var/run/lora -conf_dir=/var/config/lora -conf_file=$conf_dir/lora-network-server.conf -conf_db=$conf_dir/lora-network-server.db - -net_server=/opt/lora/lora-network-server -net_server_log=/var/log/lora-network-server.log -net_server_pidfile=$run_dir/$NAME.pid - -pkt_fwd=/opt/lora/basic_pkt_fwd -pkt_fwd_log=/var/log/lora-pkt-fwd-1.log -pkt_fwd_pidfile=$run_dir/lora-pkt-fwd-1.pid - -lora_us_id="MTAC-LORA-915" -lora_eu_id="MTAC-LORA-868" - -read_card_info() { - # product-id of first lora card - lora_id=$(mts-io-sysfs show lora/product-id 2> /dev/null) - lora_eui=$(mts-io-sysfs show lora/eui 2> /dev/null) - # remove all colons - lora_eui_raw=${lora_eui//:/} -} - -card_found() { - if [ "$lora_id" = "$lora_us_id" ] || [ "$lora_id" = "$lora_eu_id" ]; then - echo "Found lora card $lora_id" - return 0 - else - return 1 - fi -} - -do_start() { - read_card_info - - if ! [ -f $conf_file ]; then - echo "$0: $conf_file missing" - exit 1 - fi - - if ! card_found; then - echo "$0: MTAC-LORA not detected" - exit 1 - fi - - echo -n "Starting $NAME: " - mkdir -p $run_dir/1 - # start network server - start-stop-daemon --start --background --make-pidfile \ - --pidfile $net_server_pidfile --startas /bin/bash -- -c "exec $net_server \ - -c $conf_file --lora-eui $lora_eui --lora-path $run_dir --db $conf_db \ - --noconsole -l $net_server_log >> $net_server_log 2>&1" - sleep 2 - # start packet forwarder - start-stop-daemon --start --background --make-pidfile \ - --pidfile $pkt_fwd_pidfile --exec $pkt_fwd -- \ - -c $run_dir/1 - - renice -n -20 -p $(pgrep lora-network-se) - renice -n -20 -p $(pgrep $(basename $pkt_fwd)) - - echo "OK" -} - -do_stop() { - echo -n "Stopping $NAME: " - start-stop-daemon --stop --quiet --oknodo --pidfile $net_server_pidfile --retry 15 - start-stop-daemon --stop --quiet --oknodo --pidfile $pkt_fwd_pidfile --retry 5 - rm -f $net_server_pidfile $pkt_fwd_pidfile - echo "OK" -} - -if [ "$ENABLED" != "yes" ]; then - echo "$NAME: disabled in /etc/default" - exit -fi - -case "$1" in - "start") - do_start - ;; - "stop") - do_stop - ;; - "restart") - ## Stop the service and regardless of whether it was - ## running or not, start it again. - do_stop - do_start - ;; - *) - ## If no parameters are given, print which are avaiable. - echo "Usage: $0 {start|stop|restart}" - exit 1 - ;; -esac - diff --git a/recipes-connectivity/lora/lora-packet-forwarder/global_conf.json.3.0.0.MTCAP-LORA-1-5.EU868.basic b/recipes-connectivity/lora/lora-packet-forwarder/global_conf.json.3.0.0.MTCAP-LORA-1-5.EU868.basic deleted file mode 100644 index e29b1f1..0000000 --- a/recipes-connectivity/lora/lora-packet-forwarder/global_conf.json.3.0.0.MTCAP-LORA-1-5.EU868.basic +++ /dev/null @@ -1,195 +0,0 @@ -{ - "SX1301_conf": { - "lorawan_public": true, - "clksrc": 0, - "lbt_cfg": { - "enable": false, - "rssi_target": 160, - "nb_channel": 1, - "start_freq": 869525000, - "scan_time_us": 5000, - "tx_delay_1ch_us": 4000000, - "tx_delay_2ch_us": 4000000 - }, - "antenna_gain": 1.4, - "radio_0": { - "enable": true, - "type": "SX1257", - "freq": 867500000, - "rssi_offset": -165.0, - "tx_enable": true, - "tx_freq_min": 863000000, - "tx_freq_max": 870000000 - }, - "radio_1": { - "enable": true, - "type": "SX1257", - "freq": 868500000, - "rssi_offset": -165.0, - "tx_enable": false - }, - "chan_multiSF_0": { - "enable": true, - "radio": 1, - "if": -400000 - }, - "chan_multiSF_1": { - "enable": true, - "radio": 1, - "if": -200000 - }, - "chan_multiSF_2": { - "enable": true, - "radio": 1, - "if": 0 - }, - "chan_multiSF_3": { - "enable": true, - "radio": 0, - "if": -400000 - }, - "chan_multiSF_4": { - "enable": true, - "radio": 0, - "if": -200000 - }, - "chan_multiSF_5": { - "enable": true, - "radio": 0, - "if": 0 - }, - "chan_multiSF_6": { - "enable": true, - "radio": 0, - "if": 200000 - }, - "chan_multiSF_7": { - "enable": true, - "radio": 0, - "if": 400000 - }, - "chan_Lora_std": { - "enable": true, - "radio": 1, - "if": -200000, - "bandwidth": 250000, - "spread_factor": 7 - }, - "chan_FSK": { - "enable": true, - "radio": 1, - "if": 300000, - "bandwidth": 125000, - "datarate": 50000 - }, - "tx_lut_0": { - "pa_gain": 0, - "mix_gain": 9, - "rf_power": -6, - "dig_gain": 1 - }, - "tx_lut_1": { - "pa_gain": 0, - "mix_gain": 12, - "rf_power": -3, - "dig_gain": 1 - }, - "tx_lut_2": { - "pa_gain": 1, - "mix_gain": 8, - "rf_power": 0, - "dig_gain": 2 - }, - "tx_lut_3": { - "pa_gain": 1, - "mix_gain": 11, - "rf_power": 3, - "dig_gain": 3 - }, - "tx_lut_4": { - "pa_gain": 1, - "mix_gain": 10, - "rf_power": 6, - "dig_gain": 0 - }, - "tx_lut_5": { - "pa_gain": 2, - "mix_gain": 11, - "rf_power": 10, - "dig_gain": 3 - }, - "tx_lut_6": { - "pa_gain": 2, - "mix_gain": 9, - "rf_power": 11, - "dig_gain": 1 - }, - "tx_lut_7": { - "pa_gain": 2, - "mix_gain": 9, - "rf_power": 12, - "dig_gain": 0 - }, - "tx_lut_8": { - "pa_gain": 2, - "mix_gain": 11, - "rf_power": 13, - "dig_gain": 2 - }, - "tx_lut_9": { - "pa_gain": 2, - "mix_gain": 11, - "rf_power": 14, - "dig_gain": 1 - }, - "tx_lut_10": { - "pa_gain": 2, - "mix_gain": 12, - "rf_power": 16, - "dig_gain": 0 - }, - "tx_lut_11": { - "pa_gain": 3, - "mix_gain": 10, - "rf_power": 20, - "dig_gain": 3 - }, - "tx_lut_12": { - "pa_gain": 3, - "mix_gain": 9, - "rf_power": 23, - "dig_gain": 0 - }, - "tx_lut_13": { - "pa_gain": 3, - "mix_gain": 12, - "rf_power": 25, - "dig_gain": 2 - }, - "tx_lut_14": { - "pa_gain": 3, - "mix_gain": 13, - "rf_power": 26, - "dig_gain": 0 - }, - "tx_lut_15": { - "pa_gain": 3, - "mix_gain": 15, - "rf_power": 27, - "dig_gain": 0 - } - }, - "gateway_conf": { - "gateway_ID": "", - "server_address": "localhost", - "serv_port_up": 1680, - "serv_port_down": 1680, - "keepalive_interval": 10, - "stat_interval": 30, - "push_timeout_ms": 100, - "forward_crc_valid": true, - "forward_crc_error": false, - "forward_crc_disabled": false - } -} - diff --git a/recipes-connectivity/lora/lora-packet-forwarder/global_conf.json.3.1.0.MTCAP-LORA-1-5.EU868.basic b/recipes-connectivity/lora/lora-packet-forwarder/global_conf.json.3.1.0.MTCAP-LORA-1-5.EU868.basic new file mode 100644 index 0000000..e29b1f1 --- /dev/null +++ b/recipes-connectivity/lora/lora-packet-forwarder/global_conf.json.3.1.0.MTCAP-LORA-1-5.EU868.basic @@ -0,0 +1,195 @@ +{ + "SX1301_conf": { + "lorawan_public": true, + "clksrc": 0, + "lbt_cfg": { + "enable": false, + "rssi_target": 160, + "nb_channel": 1, + "start_freq": 869525000, + "scan_time_us": 5000, + "tx_delay_1ch_us": 4000000, + "tx_delay_2ch_us": 4000000 + }, + "antenna_gain": 1.4, + "radio_0": { + "enable": true, + "type": "SX1257", + "freq": 867500000, + "rssi_offset": -165.0, + "tx_enable": true, + "tx_freq_min": 863000000, + "tx_freq_max": 870000000 + }, + "radio_1": { + "enable": true, + "type": "SX1257", + "freq": 868500000, + "rssi_offset": -165.0, + "tx_enable": false + }, + "chan_multiSF_0": { + "enable": true, + "radio": 1, + "if": -400000 + }, + "chan_multiSF_1": { + "enable": true, + "radio": 1, + "if": -200000 + }, + "chan_multiSF_2": { + "enable": true, + "radio": 1, + "if": 0 + }, + "chan_multiSF_3": { + "enable": true, + "radio": 0, + "if": -400000 + }, + "chan_multiSF_4": { + "enable": true, + "radio": 0, + "if": -200000 + }, + "chan_multiSF_5": { + "enable": true, + "radio": 0, + "if": 0 + }, + "chan_multiSF_6": { + "enable": true, + "radio": 0, + "if": 200000 + }, + "chan_multiSF_7": { + "enable": true, + "radio": 0, + "if": 400000 + }, + "chan_Lora_std": { + "enable": true, + "radio": 1, + "if": -200000, + "bandwidth": 250000, + "spread_factor": 7 + }, + "chan_FSK": { + "enable": true, + "radio": 1, + "if": 300000, + "bandwidth": 125000, + "datarate": 50000 + }, + "tx_lut_0": { + "pa_gain": 0, + "mix_gain": 9, + "rf_power": -6, + "dig_gain": 1 + }, + "tx_lut_1": { + "pa_gain": 0, + "mix_gain": 12, + "rf_power": -3, + "dig_gain": 1 + }, + "tx_lut_2": { + "pa_gain": 1, + "mix_gain": 8, + "rf_power": 0, + "dig_gain": 2 + }, + "tx_lut_3": { + "pa_gain": 1, + "mix_gain": 11, + "rf_power": 3, + "dig_gain": 3 + }, + "tx_lut_4": { + "pa_gain": 1, + "mix_gain": 10, + "rf_power": 6, + "dig_gain": 0 + }, + "tx_lut_5": { + "pa_gain": 2, + "mix_gain": 11, + "rf_power": 10, + "dig_gain": 3 + }, + "tx_lut_6": { + "pa_gain": 2, + "mix_gain": 9, + "rf_power": 11, + "dig_gain": 1 + }, + "tx_lut_7": { + "pa_gain": 2, + "mix_gain": 9, + "rf_power": 12, + "dig_gain": 0 + }, + "tx_lut_8": { + "pa_gain": 2, + "mix_gain": 11, + "rf_power": 13, + "dig_gain": 2 + }, + "tx_lut_9": { + "pa_gain": 2, + "mix_gain": 11, + "rf_power": 14, + "dig_gain": 1 + }, + "tx_lut_10": { + "pa_gain": 2, + "mix_gain": 12, + "rf_power": 16, + "dig_gain": 0 + }, + "tx_lut_11": { + "pa_gain": 3, + "mix_gain": 10, + "rf_power": 20, + "dig_gain": 3 + }, + "tx_lut_12": { + "pa_gain": 3, + "mix_gain": 9, + "rf_power": 23, + "dig_gain": 0 + }, + "tx_lut_13": { + "pa_gain": 3, + "mix_gain": 12, + "rf_power": 25, + "dig_gain": 2 + }, + "tx_lut_14": { + "pa_gain": 3, + "mix_gain": 13, + "rf_power": 26, + "dig_gain": 0 + }, + "tx_lut_15": { + "pa_gain": 3, + "mix_gain": 15, + "rf_power": 27, + "dig_gain": 0 + } + }, + "gateway_conf": { + "gateway_ID": "", + "server_address": "localhost", + "serv_port_up": 1680, + "serv_port_down": 1680, + "keepalive_interval": 10, + "stat_interval": 30, + "push_timeout_ms": 100, + "forward_crc_valid": true, + "forward_crc_error": false, + "forward_crc_disabled": false + } +} + diff --git a/recipes-connectivity/lora/lora-packet-forwarder/global_conf.json.3.1.0.MTCAP-LORA-1-5.US915.basic b/recipes-connectivity/lora/lora-packet-forwarder/global_conf.json.3.1.0.MTCAP-LORA-1-5.US915.basic new file mode 100644 index 0000000..6d56f3b --- /dev/null +++ b/recipes-connectivity/lora/lora-packet-forwarder/global_conf.json.3.1.0.MTCAP-LORA-1-5.US915.basic @@ -0,0 +1,240 @@ +{ + "SX1301_conf" : + { + "antenna_gain" : 0, /* antenna gain, in dBi */ + "chan_FSK" : + { + "bandwidth" : 125000, + "datarate" : 50000, + "enable" : false, + "if" : 300000, + "radio" : 0 + }, + "chan_Lora_std" : + { + "bandwidth" : 500000, + "enable" : true, + "if" : 300000, + "radio" : 0, + "spread_factor" : 8 + }, + "chan_multiSF_0" : + { + "enable" : true, + "if" : -400000, + "radio" : 0 + }, + "chan_multiSF_1" : + { + "enable" : true, + "if" : -200000, + "radio" : 0 + }, + "chan_multiSF_2" : + { + "enable" : true, + "if" : 0, + "radio" : 0 + }, + "chan_multiSF_3" : + { + "enable" : true, + "if" : 200000, + "radio" : 0 + }, + "chan_multiSF_4" : + { + "enable" : true, + "if" : -400000, + "radio" : 1 + }, + "chan_multiSF_5" : + { + "enable" : true, + "if" : -200000, + "radio" : 1 + }, + "chan_multiSF_6" : + { + "enable" : true, + "if" : 0, + "radio" : 1 + }, + "chan_multiSF_7" : + { + "enable" : true, + "if" : 200000, + "radio" : 1 + }, + "clksrc" : 0, + "lbt_cfg" : + { + "enable" : false, + "nb_channel" : 1, + "rssi_target" : 160, /* rssi in dBm = -lbt_rssi_target/2 */ + "scan_time_us" : 5000, + "start_freq" : 869525000, + "tx_delay_1ch_us" : 4000000, + "tx_delay_2ch_us" : 4000000 + }, + "lorawan_public" : true, + "radio_0" : + { + "enable" : true, + "freq" : 902700000, + "rssi_offset" : -162, + "tx_enable" : true, + "tx_freq_max" : 928000000, + "tx_freq_min" : 902000000, + "type" : "SX1257" + }, + "radio_1" : + { + "enable" : true, + "freq" : 903500000, + "rssi_offset" : -162, + "tx_enable" : false, + "type" : "SX1257" + }, + "tx_lut_0" : + { + "dig_gain" : 0, + "mix_gain" : 11, + /* TX gain table, index 0 */ + "pa_gain" : 0, + "rf_power" : -6 + }, + "tx_lut_1" : + { + "dig_gain" : 0, + "mix_gain" : 13, + /* TX gain table, index 1 */ + "pa_gain" : 0, + "rf_power" : -3 + }, + "tx_lut_10" : + { + "dig_gain" : 0, + "mix_gain" : 15, + /* TX gain table, index 10 */ + "pa_gain" : 2, + "rf_power" : 16 + }, + "tx_lut_11" : + { + "dig_gain" : 0, + "mix_gain" : 10, + /* TX gain table, index 11 */ + "pa_gain" : 3, + "rf_power" : 20 + }, + "tx_lut_12" : + { + "dig_gain" : 0, + "mix_gain" : 12, + /* TX gain table, index 12 */ + "pa_gain" : 3, + "rf_power" : 23 + }, + "tx_lut_13" : + { + "dig_gain" : 0, + "mix_gain" : 13, + /* TX gain table, index 13 */ + "pa_gain" : 3, + "rf_power" : 25 + }, + "tx_lut_14" : + { + "dig_gain" : 0, + "mix_gain" : 15, + /* TX gain table, index 14 */ + "pa_gain" : 3, + "rf_power" : 26 + }, + "tx_lut_15" : + { + "dig_gain" : 0, + "mix_gain" : 15, + /* TX gain table, index 15 */ + "pa_gain" : 3, + "rf_power" : 27 + }, + "tx_lut_2" : + { + "dig_gain" : 0, + "mix_gain" : 9, + /* TX gain table, index 2 */ + "pa_gain" : 1, + "rf_power" : 0 + }, + "tx_lut_3" : + { + "dig_gain" : 0, + "mix_gain" : 10, + /* TX gain table, index 3 */ + "pa_gain" : 1, + "rf_power" : 3 + }, + "tx_lut_4" : + { + "dig_gain" : 0, + "mix_gain" : 12, + /* TX gain table, index 4 */ + "pa_gain" : 1, + "rf_power" : 6 + }, + "tx_lut_5" : + { + "dig_gain" : 0, + "mix_gain" : 10, + /* TX gain table, index 5 */ + "pa_gain" : 2, + "rf_power" : 10 + }, + "tx_lut_6" : + { + "dig_gain" : 0, + "mix_gain" : 11, + /* TX gain table, index 6 */ + "pa_gain" : 2, + "rf_power" : 11 + }, + "tx_lut_7" : + { + "dig_gain" : 0, + "mix_gain" : 11, + /* TX gain table, index 7 */ + "pa_gain" : 2, + "rf_power" : 12 + }, + "tx_lut_8" : + { + "dig_gain" : 0, + "mix_gain" : 12, + /* TX gain table, index 8 */ + "pa_gain" : 2, + "rf_power" : 13 + }, + "tx_lut_9" : + { + "dig_gain" : 0, + "mix_gain" : 13, + /* TX gain table, index 9 */ + "pa_gain" : 2, + "rf_power" : 14 + } + }, + "gateway_conf": { + "gateway_ID": "", + "server_address": "localhost", + "serv_port_up": 1680, + "serv_port_down": 1680, + "keepalive_interval": 10, + "stat_interval": 30, + "push_timeout_ms": 100, + "forward_crc_valid": true, + "forward_crc_error": false, + "forward_crc_disabled": false + } +} diff --git a/recipes-connectivity/lora/lora-packet-forwarder/mtcap/lora-packet-forwarder.init b/recipes-connectivity/lora/lora-packet-forwarder/mtcap/lora-packet-forwarder.init index 9ffaf6d..b17a3d8 100755 --- a/recipes-connectivity/lora/lora-packet-forwarder/mtcap/lora-packet-forwarder.init +++ b/recipes-connectivity/lora/lora-packet-forwarder/mtcap/lora-packet-forwarder.init @@ -3,58 +3,122 @@ NAME="lora-packet-forwarder" ENABLED="yes" -START_STOP_DAEMON="/usr/sbin/start-stop-daemon" - [ -f /etc/default/$NAME ] && source /etc/default/$NAME run_dir=/var/run/lora -pkt_fwd=/opt/lora/lora_pkt_fwd -pkt_fwd_pidfile=$run_dir/lora-pkt-fwd-1.pid +conf_file=/var/config/lora/global_conf.json +conf_file_local=/var/config/lora/local_conf.json +opt_conf_file=/opt/lora/global_conf.json +opt_conf_file_local=/opt/lora/local_conf.json log_file=/var/log/lora-pkt-fwd.log -cfg_file=/opt/lora/global_conf.json + +pkt_fwd=$run_dir/1/lora_pkt_fwd +pkt_fwd_log=/var/log/lora-pkt-fwd-1.log +pkt_fwd_pidfile=$run_dir/lora-pkt-fwd-1.pid + +lora_mtcap_id="MTCAP-LORA" +lora_mtcap_id868="MTCAP-LORA-868" +lora_mtcap_id915="MTCAP-LORA-915" + +read_lora_hw_info() { + # product-id of first lora card + lora_id=$(mts-io-sysfs show lora/product-id 2> /dev/null) + lora_eui=$(mts-io-sysfs show lora/eui 2> /dev/null) + # remove all colons + lora_eui_raw=${lora_eui//:/} + lora_hw=$(mts-io-sysfs show lora/hw-version 2> /dev/null) +} + +hardware_found() { + if [[ "$lora_id" =~ "$lora_mtcap_id" ]]; then + # + # create /opt/lora/global_conf.json based on detected LORA card + # + if [ "$lora_id" = "$lora_mtcap_id868" ]; then + GLOBAL_CONF=/opt/lora/global_conf.json.MTCAP_LORA_1_5.EU868 + elif [ "$lora_id" = "$lora_mtcap_id915" ]; then + GLOBAL_CONF=/opt/lora/global_conf.json.MTCAP_LORA_1_5.US915 + else + return 1 + fi + + cp $GLOBAL_CONF $opt_conf_file + echo "Setting gateway_id in $opt_conf_file to $lora_eui_raw" + sed -i "s/\"gateway_ID\": \".*\"/\"gateway_ID\": \"$lora_eui_raw\"/" $opt_conf_file + + # + # copy global_json.conf and local_json.conf files to /var/config/ if it is not there yet + # + if ! [ -f $conf_file ]; then + mkdir -p /var/config/lora/ + cp $opt_conf_file $conf_file + cp $opt_conf_file_local $conf_file_local + fi + + ln -sf /opt/lora/lora_pkt_fwd $pkt_fwd + else + return 1 + fi + +} do_start() { - echo "Starting $NAME: " + # create run directory + mkdir -p $run_dir/1 + rm -rf $run_dir/1/* + + read_lora_hw_info + + if hardware_found; then + echo "Found $lora_id with $lora_hw hardware" + else + echo "$0: LORA not detected" + exit 1 + fi - eui=$(mts-io-sysfs show lora/eui) - # Remove colons - clean_eui="${eui//:/}" - echo "Setting gateway_id in $cfg_file to $clean_eui" - sed -i "s/\"gateway_ID\": \".*\"/\"gateway_ID\": \"$clean_eui\"/" $cfg_file + # copy conf files to the run directory + if [ -f $conf_file ]; then + cp $conf_file $run_dir/1/ + fi - mkdir -p $run_dir + if [ -f $conf_file_local ]; then + cp $conf_file_local $run_dir/1/ + fi # start packet forwarder - $START_STOP_DAEMON --start --background --make-pidfile \ - --pidfile $pkt_fwd_pidfile --startas /bin/bash --chdir "/opt/lora/" \ - -- -c "exec $pkt_fwd > $log_file 2>&1" + echo -n "Starting $NAME: " + /usr/sbin/start-stop-daemon --chdir $run_dir/1 --background --start --make-pidfile \ + --pidfile $pkt_fwd_pidfile --startas /bin/bash -- -c "exec $pkt_fwd > $log_file 2>&1" renice -n -20 -p $(pgrep $(basename $pkt_fwd)) echo "OK" } + do_stop() { echo -n "Stopping $NAME: " - $START_STOP_DAEMON --stop --quiet --oknodo --pidfile $pkt_fwd_pidfile --retry 5 + start-stop-daemon --stop --quiet --oknodo --pidfile $pkt_fwd_pidfile --retry 5 rm -f $pkt_fwd_pidfile echo "OK" } + if [ "$ENABLED" != "yes" ]; then - echo "$NAME: disabled in /etc/default/$NAME" + echo "$NAME: disabled in /etc/default" exit fi + case "$1" in "start") - do_start + do_start ;; "stop") - do_stop + do_stop ;; "restart") - ## Stop the service and regardless of whether it was + ## Stop the service and regardless of whether it was ## running or not, start it again. do_stop do_start @@ -63,7 +127,6 @@ case "$1" in ## If no parameters are given, print which are avaiable. echo "Usage: $0 {start|stop|restart}" exit 1 - ;; + ;; esac - diff --git a/recipes-connectivity/lora/lora-packet-forwarder_3.1.0.bb b/recipes-connectivity/lora/lora-packet-forwarder_3.1.0.bb index 98e1973..880daff 100644 --- a/recipes-connectivity/lora/lora-packet-forwarder_3.1.0.bb +++ b/recipes-connectivity/lora/lora-packet-forwarder_3.1.0.bb @@ -19,7 +19,8 @@ SRC_URI = "git://github.com/Lora-net/packet_forwarder.git;protocol=git \ file://global_conf.json.3.0.0.MTAC_LORA_1_0.US915.basic.clksrc0 \ file://global_conf.json.3.0.0.MTAC_LORA_1_5.EU868.basic.clksrc0 \ file://global_conf.json.3.0.0.MTAC_LORA_1_5.US915.basic.clksrc0 \ - file://global_conf.json.3.0.0.MTCAP-LORA-1-5.EU868.basic \ + file://global_conf.json.3.1.0.MTCAP-LORA-1-5.EU868.basic \ + file://global_conf.json.3.1.0.MTCAP-LORA-1-5.US915.basic \ file://local_conf.json \ file://lora-packet-forwarder-add-spi-dev-path.patch \ file://lora-packet-forwarder-remove-jit-power-check.patch \ @@ -67,7 +68,8 @@ do_install_append_mtcdt() { } do_install_append_mtcap() { - install -m 755 ${WORKDIR}/global_conf.json.3.0.0.MTCAP-LORA-1-5.EU868.basic ${D}${LORA_DIR}/global_conf.json + install -m 755 ${WORKDIR}/global_conf.json.3.1.0.MTCAP-LORA-1-5.EU868.basic ${D}${LORA_DIR}/global_conf.json.MTCAP_LORA_1_5.EU868 + install -m 755 ${WORKDIR}/global_conf.json.3.1.0.MTCAP-LORA-1-5.US915.basic ${D}${LORA_DIR}/global_conf.json.MTCAP_LORA_1_5.US915 } FILES_${PN} += "${LORA_DIR}" -- cgit v1.2.3