A LoRa packet forwarder running on the host of a LoRa Picocell Gateway that forwards RF packets receive by the concentrator to a server through a IP/UDP link, and emits RF packets that are sent by the server.
daemon/run_pkt_fwd.sh@0:9002b89157da, 2018-04-11 (annotated)
- Committer:
- dgabino
- Date:
- Wed Apr 11 14:47:16 2018 +0000
- Revision:
- 0:9002b89157da
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dgabino | 0:9002b89157da | 1 | #!/bin/bash |
dgabino | 0:9002b89157da | 2 | |
dgabino | 0:9002b89157da | 3 | usage() { |
dgabino | 0:9002b89157da | 4 | echo missing working root directory path |
dgabino | 0:9002b89157da | 5 | echo usage: $0 [start/restart/check/stop] PATH |
dgabino | 0:9002b89157da | 6 | echo example: $0 check /home/pi/lora-net/ |
dgabino | 0:9002b89157da | 7 | exit |
dgabino | 0:9002b89157da | 8 | } |
dgabino | 0:9002b89157da | 9 | |
dgabino | 0:9002b89157da | 10 | # |
dgabino | 0:9002b89157da | 11 | # Check input parameters |
dgabino | 0:9002b89157da | 12 | # |
dgabino | 0:9002b89157da | 13 | if [ -z "$2" ]; then |
dgabino | 0:9002b89157da | 14 | usage |
dgabino | 0:9002b89157da | 15 | fi |
dgabino | 0:9002b89157da | 16 | |
dgabino | 0:9002b89157da | 17 | # |
dgabino | 0:9002b89157da | 18 | # Global variables |
dgabino | 0:9002b89157da | 19 | # |
dgabino | 0:9002b89157da | 20 | DIR=$2 |
dgabino | 0:9002b89157da | 21 | |
dgabino | 0:9002b89157da | 22 | # |
dgabino | 0:9002b89157da | 23 | # Functions |
dgabino | 0:9002b89157da | 24 | # |
dgabino | 0:9002b89157da | 25 | start() { |
dgabino | 0:9002b89157da | 26 | echo "Start packet forwarder..." |
dgabino | 0:9002b89157da | 27 | cd $DIR/lora_gateway |
dgabino | 0:9002b89157da | 28 | ./reset_lgw.sh start |
dgabino | 0:9002b89157da | 29 | cd $DIR/packet_forwarder/lora_pkt_fwd |
dgabino | 0:9002b89157da | 30 | ./lora_pkt_fwd |
dgabino | 0:9002b89157da | 31 | } |
dgabino | 0:9002b89157da | 32 | |
dgabino | 0:9002b89157da | 33 | stop() { |
dgabino | 0:9002b89157da | 34 | echo "Stop packet forwarder" |
dgabino | 0:9002b89157da | 35 | sudo killall lora_pkt_fwd |
dgabino | 0:9002b89157da | 36 | } |
dgabino | 0:9002b89157da | 37 | |
dgabino | 0:9002b89157da | 38 | check() { |
dgabino | 0:9002b89157da | 39 | ps -ef | grep -v grep | grep -w 'lora_pkt_fwd' > /dev/null |
dgabino | 0:9002b89157da | 40 | result=$? |
dgabino | 0:9002b89157da | 41 | if [ "${result}" -eq "0" ] ; then |
dgabino | 0:9002b89157da | 42 | echo "`date`: lora_pkt_fwd is already running" |
dgabino | 0:9002b89157da | 43 | exit 0 |
dgabino | 0:9002b89157da | 44 | fi |
dgabino | 0:9002b89157da | 45 | start |
dgabino | 0:9002b89157da | 46 | } |
dgabino | 0:9002b89157da | 47 | |
dgabino | 0:9002b89157da | 48 | # |
dgabino | 0:9002b89157da | 49 | # Main |
dgabino | 0:9002b89157da | 50 | # |
dgabino | 0:9002b89157da | 51 | |
dgabino | 0:9002b89157da | 52 | case "$1" in |
dgabino | 0:9002b89157da | 53 | start) |
dgabino | 0:9002b89157da | 54 | start |
dgabino | 0:9002b89157da | 55 | ;; |
dgabino | 0:9002b89157da | 56 | stop) |
dgabino | 0:9002b89157da | 57 | stop |
dgabino | 0:9002b89157da | 58 | ;; |
dgabino | 0:9002b89157da | 59 | restart) |
dgabino | 0:9002b89157da | 60 | stop |
dgabino | 0:9002b89157da | 61 | start |
dgabino | 0:9002b89157da | 62 | ;; |
dgabino | 0:9002b89157da | 63 | check) |
dgabino | 0:9002b89157da | 64 | check |
dgabino | 0:9002b89157da | 65 | ;; |
dgabino | 0:9002b89157da | 66 | *) |
dgabino | 0:9002b89157da | 67 | usage |
dgabino | 0:9002b89157da | 68 | exit 1 |
dgabino | 0:9002b89157da | 69 | ;; |
dgabino | 0:9002b89157da | 70 | esac |
dgabino | 0:9002b89157da | 71 | |
dgabino | 0:9002b89157da | 72 | exit 0 |
dgabino | 0:9002b89157da | 73 | |
dgabino | 0:9002b89157da | 74 |