summaryrefslogtreecommitdiff
path: root/recipes-connectivity/lora/lora-packet-forwarder
diff options
context:
space:
mode:
authorMykyta Dorokhin <mykyta.dorokhin@globallogic.com>2017-05-25 10:13:35 -0500
committerJohn Klug <john.klug@multitech.com>2017-05-25 11:21:10 -0500
commit30945f752514a91c8563238e31d34e7c574b13d2 (patch)
tree428c2dec953742dab80b2194a60574884b1523fc /recipes-connectivity/lora/lora-packet-forwarder
parent81745d07f262be466b286aa3a32d4c2f0c34e016 (diff)
downloadmeta-mlinux-30945f752514a91c8563238e31d34e7c574b13d2.tar.gz
meta-mlinux-30945f752514a91c8563238e31d34e7c574b13d2.tar.bz2
meta-mlinux-30945f752514a91c8563238e31d34e7c574b13d2.zip
mtcap: initial support for MTCAP-LORA-US915 card
Diffstat (limited to 'recipes-connectivity/lora/lora-packet-forwarder')
-rw-r--r--recipes-connectivity/lora/lora-packet-forwarder/global_conf.json.3.1.0.MTCAP-LORA-1-5.EU868.basic (renamed from recipes-connectivity/lora/lora-packet-forwarder/global_conf.json.3.0.0.MTCAP-LORA-1-5.EU868.basic)0
-rw-r--r--recipes-connectivity/lora/lora-packet-forwarder/global_conf.json.3.1.0.MTCAP-LORA-1-5.US915.basic240
-rwxr-xr-xrecipes-connectivity/lora/lora-packet-forwarder/mtcap/lora-packet-forwarder.init107
3 files changed, 325 insertions, 22 deletions
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.1.0.MTCAP-LORA-1-5.EU868.basic
index e29b1f1..e29b1f1 100644
--- 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.1.0.MTCAP-LORA-1-5.EU868.basic
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": "<WILL-BE-AUTO-REPLACED-WITH-LORA-EUI>",
+ "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
-