contrib: Add owhw-event-script.sh for osmo-remsim-client

This is a sample event-script that can be used in conjunction
with osmo-resim-client to trigger certain board-specific functions
such as modem reset on the OWHW.

Change-Id: I69f7f9b0c09421b8c14b909627ffe7b9f1acec77
diff --git a/contrib/owhw-event-script.sh b/contrib/owhw-event-script.sh
new file mode 100755
index 0000000..8d4a33f
--- /dev/null
+++ b/contrib/owhw-event-script.sh
@@ -0,0 +1,64 @@
+#!/bin/bash -e
+
+# Helper script for osmo-remsim-client-st2 on OWHW hardware. It performs the hardware-specific
+# functions required by remsim-client.
+
+# environment variables available:
+#	REMSIM_CLIENT_VERSION
+#	REMSIM_SERVER_ADDR
+#	REMSIM_SERVER_STATE
+#	REMSIM_BANKD_ADDR
+#	REMSIM_BANKD_STATE
+#	REMSIM_CLIENT_SLOT
+#	REMSIM_BANKD_SLOT
+#	REMSIM_SIM_VCC
+#	REMSIM_SIM_RST
+#	REMSIM_CAUSE
+#	REMSIM_USB_PATH
+#	REMSIM_USB_INTERFACE
+
+CAUSE="$1"
+
+# derive the modem (1/2) from the USB interface of the SIMTRACE2 firmware (0/1)
+case "${REMSIM_USB_INTERFACE}" in
+	0)
+		MODEM=1
+		;;
+	1)
+		MODEM=2
+		;;
+	*)
+		echo "Unknown REMSIM_USB_INTERFACE ${REMSIM_USB_INTERFACE}"
+		exit 1
+		;;
+esac
+
+
+
+case "${CAUSE}" in
+	event-server-connect)
+		;;
+	event-bankd-connect)
+		;;
+	event-config-bankd)
+		;;
+	event-modem-status)
+		;;
+	request-card-insert)
+		echo "Enabling Remote SIM for ${MODEM}"
+		echo "1" > "/dev/gpio/connect_st_usim${MODEM}/value"
+		;;
+	request-card-remove)
+		echo "Disabling Remote SIM for ${MODEM}"
+		echo "0" > "/dev/gpio/connect_st_usim${MODEM}/value"
+		;;
+	request-modem-reset)
+		echo "Resetting Modem ${MODEM}"
+		echo "1" > "/dev/gpio/mdm${MODEM}_rst/value"
+		sleep 1
+		echo "0" > "/dev/gpio/mdm${MODEM}_rst/value"
+		;;
+	*)
+		echo "Unknown CAUSE ${CAUSE}: ignoring"
+		;;
+esac