summaryrefslogtreecommitdiff
path: root/reset_lgw.sh
diff options
context:
space:
mode:
authorHarsh Sharma <92harshsharma@gmail.com>2018-06-13 13:24:54 -0500
committerHarsh Sharma <92harshsharma@gmail.com>2018-06-13 13:24:54 -0500
commit7c383be1542368f2601015d9fc2a417197677677 (patch)
treebc06453f879cbadf65fd88123c506956403c5684 /reset_lgw.sh
downloadlora_gateway_mtac_full-7c383be1542368f2601015d9fc2a417197677677.tar.gz
lora_gateway_mtac_full-7c383be1542368f2601015d9fc2a417197677677.tar.bz2
lora_gateway_mtac_full-7c383be1542368f2601015d9fc2a417197677677.zip
Initial Commit
Diffstat (limited to 'reset_lgw.sh')
-rwxr-xr-xreset_lgw.sh62
1 files changed, 62 insertions, 0 deletions
diff --git a/reset_lgw.sh b/reset_lgw.sh
new file mode 100755
index 0000000..77de63e
--- /dev/null
+++ b/reset_lgw.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+# This script is intended to be used on IoT Starter Kit platform, it performs
+# the following actions:
+# - export/unpexort GPIO7 used to reset the SX1301 chip
+#
+# Usage examples:
+# ./reset_lgw.sh stop
+# ./reset_lgw.sh start
+
+# The reset pin of SX1301 is wired with RPi GPIO7
+# If used on another platform, the GPIO number can be given as parameter.
+if [ -z "$2" ]; then
+ IOT_SK_SX1301_RESET_PIN=7
+else
+ IOT_SK_SX1301_RESET_PIN=$2
+fi
+
+echo "Accessing concentrator reset pin through GPIO$IOT_SK_SX1301_RESET_PIN..."
+
+WAIT_GPIO() {
+ sleep 0.1
+}
+
+iot_sk_init() {
+ # setup GPIO 7
+ echo "$IOT_SK_SX1301_RESET_PIN" > /sys/class/gpio/export; WAIT_GPIO
+
+ # set GPIO 7 as output
+ echo "out" > /sys/class/gpio/gpio$IOT_SK_SX1301_RESET_PIN/direction; WAIT_GPIO
+
+ # write output for SX1301 reset
+ echo "1" > /sys/class/gpio/gpio$IOT_SK_SX1301_RESET_PIN/value; WAIT_GPIO
+ echo "0" > /sys/class/gpio/gpio$IOT_SK_SX1301_RESET_PIN/value; WAIT_GPIO
+
+ # set GPIO 7 as input
+ echo "in" > /sys/class/gpio/gpio$IOT_SK_SX1301_RESET_PIN/direction; WAIT_GPIO
+}
+
+iot_sk_term() {
+ # cleanup GPIO 7
+ if [ -d /sys/class/gpio/gpio$IOT_SK_SX1301_RESET_PIN ]
+ then
+ echo "$IOT_SK_SX1301_RESET_PIN" > /sys/class/gpio/unexport; WAIT_GPIO
+ fi
+}
+
+case "$1" in
+ start)
+ iot_sk_term
+ iot_sk_init
+ ;;
+ stop)
+ iot_sk_term
+ ;;
+ *)
+ echo "Usage: $0 {start|stop} [<gpio number>]"
+ exit 1
+ ;;
+esac
+
+exit 0