summaryrefslogtreecommitdiff
path: root/recipes-connectivity
diff options
context:
space:
mode:
authorMykyta Dorokhin <mykyta.dorokhin@globallogic.com>2017-05-26 13:46:04 -0500
committerJohn Klug <john.klug@multitech.com>2017-05-31 09:09:55 -0500
commitf5ed95a4341428467a08402c66cff9c757c7a1fa (patch)
tree9f93ba35ff20b77c3d6cd55636860162d93907d5 /recipes-connectivity
parent538a395e1754c31ecff6888a4a22aee29b5eea50 (diff)
downloadmeta-mlinux-f5ed95a4341428467a08402c66cff9c757c7a1fa.tar.gz
meta-mlinux-f5ed95a4341428467a08402c66cff9c757c7a1fa.tar.bz2
meta-mlinux-f5ed95a4341428467a08402c66cff9c757c7a1fa.zip
merge lora-packet-forwarder mtcdt and mtcap init scripts into one
Diffstat (limited to 'recipes-connectivity')
-rw-r--r--recipes-connectivity/lora/lora-packet-forwarder/global_conf.json.3.1.0.MTCAP-LORA-1-5.US915.basic20
-rwxr-xr-xrecipes-connectivity/lora/lora-packet-forwarder/lora-packet-forwarder.init (renamed from recipes-connectivity/lora/lora-packet-forwarder/mtcap/lora-packet-forwarder.init)77
-rwxr-xr-xrecipes-connectivity/lora/lora-packet-forwarder/mtcdt/lora-packet-forwarder.init121
3 files changed, 58 insertions, 160 deletions
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
index 6d56f3b..c357414 100644
--- 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
@@ -1,7 +1,7 @@
{
"SX1301_conf" :
{
- "antenna_gain" : 0, /* antenna gain, in dBi */
+ "antenna_gain" : 0,
"chan_FSK" :
{
"bandwidth" : 125000,
@@ -71,7 +71,7 @@
{
"enable" : false,
"nb_channel" : 1,
- "rssi_target" : 160, /* rssi in dBm = -lbt_rssi_target/2 */
+ "rssi_target" : 160,
"scan_time_us" : 5000,
"start_freq" : 869525000,
"tx_delay_1ch_us" : 4000000,
@@ -100,7 +100,6 @@
{
"dig_gain" : 0,
"mix_gain" : 11,
- /* TX gain table, index 0 */
"pa_gain" : 0,
"rf_power" : -6
},
@@ -108,7 +107,6 @@
{
"dig_gain" : 0,
"mix_gain" : 13,
- /* TX gain table, index 1 */
"pa_gain" : 0,
"rf_power" : -3
},
@@ -116,7 +114,6 @@
{
"dig_gain" : 0,
"mix_gain" : 15,
- /* TX gain table, index 10 */
"pa_gain" : 2,
"rf_power" : 16
},
@@ -124,7 +121,6 @@
{
"dig_gain" : 0,
"mix_gain" : 10,
- /* TX gain table, index 11 */
"pa_gain" : 3,
"rf_power" : 20
},
@@ -132,7 +128,6 @@
{
"dig_gain" : 0,
"mix_gain" : 12,
- /* TX gain table, index 12 */
"pa_gain" : 3,
"rf_power" : 23
},
@@ -140,7 +135,6 @@
{
"dig_gain" : 0,
"mix_gain" : 13,
- /* TX gain table, index 13 */
"pa_gain" : 3,
"rf_power" : 25
},
@@ -148,7 +142,6 @@
{
"dig_gain" : 0,
"mix_gain" : 15,
- /* TX gain table, index 14 */
"pa_gain" : 3,
"rf_power" : 26
},
@@ -156,7 +149,6 @@
{
"dig_gain" : 0,
"mix_gain" : 15,
- /* TX gain table, index 15 */
"pa_gain" : 3,
"rf_power" : 27
},
@@ -164,7 +156,6 @@
{
"dig_gain" : 0,
"mix_gain" : 9,
- /* TX gain table, index 2 */
"pa_gain" : 1,
"rf_power" : 0
},
@@ -172,7 +163,6 @@
{
"dig_gain" : 0,
"mix_gain" : 10,
- /* TX gain table, index 3 */
"pa_gain" : 1,
"rf_power" : 3
},
@@ -180,7 +170,6 @@
{
"dig_gain" : 0,
"mix_gain" : 12,
- /* TX gain table, index 4 */
"pa_gain" : 1,
"rf_power" : 6
},
@@ -188,7 +177,6 @@
{
"dig_gain" : 0,
"mix_gain" : 10,
- /* TX gain table, index 5 */
"pa_gain" : 2,
"rf_power" : 10
},
@@ -196,7 +184,6 @@
{
"dig_gain" : 0,
"mix_gain" : 11,
- /* TX gain table, index 6 */
"pa_gain" : 2,
"rf_power" : 11
},
@@ -204,7 +191,6 @@
{
"dig_gain" : 0,
"mix_gain" : 11,
- /* TX gain table, index 7 */
"pa_gain" : 2,
"rf_power" : 12
},
@@ -212,7 +198,6 @@
{
"dig_gain" : 0,
"mix_gain" : 12,
- /* TX gain table, index 8 */
"pa_gain" : 2,
"rf_power" : 13
},
@@ -220,7 +205,6 @@
{
"dig_gain" : 0,
"mix_gain" : 13,
- /* TX gain table, index 9 */
"pa_gain" : 2,
"rf_power" : 14
}
diff --git a/recipes-connectivity/lora/lora-packet-forwarder/mtcap/lora-packet-forwarder.init b/recipes-connectivity/lora/lora-packet-forwarder/lora-packet-forwarder.init
index b17a3d8..ec81b9d 100755
--- a/recipes-connectivity/lora/lora-packet-forwarder/mtcap/lora-packet-forwarder.init
+++ b/recipes-connectivity/lora/lora-packet-forwarder/lora-packet-forwarder.init
@@ -1,21 +1,29 @@
#!/bin/bash
+
NAME="lora-packet-forwarder"
ENABLED="yes"
+
[ -f /etc/default/$NAME ] && source /etc/default/$NAME
run_dir=/var/run/lora
-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
+opt_conf_dir=/opt/lora
+conf_dir=/var/config/lora
+conf_file=$conf_dir/global_conf.json
+conf_file_local=$conf_dir/local_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
+port1=/sys/devices/platform/mts-io/ap1
+port2=/sys/devices/platform/mts-io/ap2
+
+lora_mtac_id="MTAC-LORA"
+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"
@@ -30,9 +38,28 @@ read_lora_hw_info() {
}
hardware_found() {
- if [[ "$lora_id" =~ "$lora_mtcap_id" ]]; then
+ if [ -d $port1 ] && [[ $(cat $port1/hw-version) = $lora_hw ]]; then
+ ln -sf /dev/spidev32766.2 /dev/spidev0.0
+ elif [ -d $port2 ] && [[ $(cat $port2/hw-version) = $lora_hw ]]; then
+ ln -sf /dev/spidev32765.2 /dev/spidev0.0
+ fi
+
+ if [[ "$lora_id" =~ "$lora_mtac_id" ]]; then
#
- # create /opt/lora/global_conf.json based on detected LORA card
+ # MTCDT
+ #
+ if [ "$lora_hw" = "$lora_1_0_hw" ] && [[ ! "$lora_id" =~ .*-SPI ]]; then
+ ln -sf /opt/lora/basic_pkt_fwd-usb $pkt_fwd
+ else
+ ln -sf /opt/lora/lora_pkt_fwd $pkt_fwd
+ fi
+
+ return 0
+ elif [[ "$lora_id" =~ "$lora_mtcap_id" ]]; then
+ #
+ # MTCAP
+ #
+ # Generate default forwarder configuration based on detected LORA hardware
#
if [ "$lora_id" = "$lora_mtcap_id868" ]; then
GLOBAL_CONF=/opt/lora/global_conf.json.MTCAP_LORA_1_5.EU868
@@ -42,13 +69,12 @@ hardware_found() {
return 1
fi
+ opt_conf_file=$opt_conf_dir/global_conf.json
+ opt_conf_file_local=$opt_conf_dir/local_conf.json
+
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
@@ -56,14 +82,16 @@ hardware_found() {
fi
ln -sf /opt/lora/lora_pkt_fwd $pkt_fwd
- else
- return 1
+
+ return 0
fi
+ return 1
}
+
do_start() {
- # create run directory
+
mkdir -p $run_dir/1
rm -rf $run_dir/1/*
@@ -72,23 +100,30 @@ do_start() {
if hardware_found; then
echo "Found $lora_id with $lora_hw hardware"
else
- echo "$0: LORA not detected"
+ echo "$0: LORA card not detected"
exit 1
fi
- # copy conf files to the run directory
- if [ -f $conf_file ]; then
- cp $conf_file $run_dir/1/
+ if ! [ -f $conf_file ]; then
+ echo "$0: $conf_file missing"
+ exit 1
fi
+ echo -n "Starting $NAME: "
+
+ #
+ # copy conf files to the run directory
+ #
+ cp $conf_file $run_dir/1/
if [ -f $conf_file_local ]; then
cp $conf_file_local $run_dir/1/
fi
+ #
# start packet forwarder
- 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"
+ --pidfile $pkt_fwd_pidfile --startas /bin/bash -- -c "exec $pkt_fwd"
renice -n -20 -p $(pgrep $(basename $pkt_fwd))
@@ -118,7 +153,7 @@ case "$1" in
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
diff --git a/recipes-connectivity/lora/lora-packet-forwarder/mtcdt/lora-packet-forwarder.init b/recipes-connectivity/lora/lora-packet-forwarder/mtcdt/lora-packet-forwarder.init
deleted file mode 100755
index fa4e1b4..0000000
--- a/recipes-connectivity/lora/lora-packet-forwarder/mtcdt/lora-packet-forwarder.init
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/bin/bash
-
-
-NAME="lora-packet-forwarder"
-ENABLED="yes"
-
-
-[ -f /etc/default/$NAME ] && source /etc/default/$NAME
-
-run_dir=/var/run/lora
-conf_dir=/var/config/lora
-conf_file=$conf_dir/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
-
-
-port1=/sys/devices/platform/mts-io/ap1
-port2=/sys/devices/platform/mts-io/ap2
-
-
-lora_mtac_id="MTAC-LORA"
-lora_1_0_hw="MTAC-LORA-1.0"
-lora_1_5_h_hw="MTAC-LORA-1.5"
-
-
-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//:/}
- lora_hw=$(mts-io-sysfs show lora/hw-version 2> /dev/null)
-}
-
-card_found() {
- if [ -d $port1 ] && [[ $(cat $port1/hw-version) = $lora_hw ]]; then
- ln -sf /dev/spidev32766.2 /dev/spidev0.0
- elif [ -d $port2 ] && [[ $(cat $port2/hw-version) = $lora_hw ]]; then
- ln -sf /dev/spidev32765.2 /dev/spidev0.0
- fi
-
- if [[ "$lora_id" =~ "$lora_mtac_id" ]]; then
- if [ "$lora_hw" = "$lora_1_0_hw" ] && [[ ! "$lora_id" =~ .*-SPI ]]; then
- ln -sf /opt/lora/basic_pkt_fwd-usb $pkt_fwd
- else
- ln -sf /opt/lora/lora_pkt_fwd $pkt_fwd
- fi
-
- return 0
- else
- return 1
- fi
-}
-
-
-do_start() {
-
- mkdir -p $run_dir/1
- read_card_info
-
- if ! [ -f $conf_file ]; then
- echo "$0: $conf_file missing"
- exit 1
- fi
-
-
- if card_found; then
- echo "Found $lora_id with $lora_hw hardware"
- else
- echo "$0: MTAC-LORA not detected"
- exit 1
- fi
- echo -n "Starting $NAME: "
- # start packet forwarder
- cp $conf_dir/global_conf.json $run_dir/1/global_conf.json
- /usr/sbin/start-stop-daemon --chdir $run_dir/1 --background --start --make-pidfile \
- --pidfile $pkt_fwd_pidfile --startas /bin/bash -- -c "exec $pkt_fwd"
-
- 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
- rm -f $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
-