Created
October 26, 2023 05:29
-
-
Save tomasinouk/f66d05c4d3a3efbca56c79684f9e27aa to your computer and use it in GitHub Desktop.
Implementing SMS commands from multiple phone numbers and notifications to multiple phone numbers for Advantech cellular routers such as ICR-3232, ICR-2432, etc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PHONE1=+61423207744 | |
PHONE2=+6141038##### | |
BIN0_TEXT_OUT_OFF="OUT_0 is set to 1" | |
BIN0_TEXT_OUT_ON="OUT_0 is set to 0" | |
for i in $PHONE1 $PHONE2; do | |
logger -t "SMS_COMMAND" "Have these phone no $i" | |
done | |
GO="no" | |
case $2 in | |
$PHONE1 | $PHONE2) | |
echo yes | |
GO="yes" | |
;; | |
*) | |
echo no | |
;; | |
esac | |
logger -t "SMS_COMMAND" "GO var is $GO" | |
echo $GO | |
logger -t "SMS_COMMAND" "Got sms from $2 with text:$3" | |
# for i in $PHONE1 $PHONE2; | |
# do | |
# echo $i | |
# logger -t "SMS_COMMAND" "doing $i" | |
if [ "$1" = "1" ] || [ "$GO" = "yes" ]; then | |
logger -t "SMS_COMMAND" "passed 1st if" | |
# this if statement pulses the out0 to a 1 for 5 seconds then back to a 0 | |
if [ "$3" = "IMPULSE" ]; then | |
logger -t "SMS_COMMAND" "Set out0 to 1" | |
/usr/bin/io set out0 1 | |
for i in $PHONE1 $PHONE2 | |
do | |
/usr/bin/sms "$i" "$BIN0_TEXT_OUT_ON" | |
done | |
# /usr/bin/sms "io st to 1" | |
logger -t "SMS_COMMAND" "Sleeping for 5 sec" | |
sleep 5 | |
/usr/bin/io set out0 0 | |
for i in $PHONE1 $PHONE2 | |
do | |
sms "$i" "$BIN0_TEXT_OUT_OFF" | |
done | |
# /usr/bin/sms "io st to 0" | |
logger -t "SMS_COMMAND" "Done sleeping for 5 sec out0 to 0" | |
elif [ "$3" = "ON" ]; then | |
logger -t "SMS_COMMAND" "ALARM TURNING ON" | |
/usr/bin/io set out0 0 | |
for i in $PHONE1 $PHONE2 | |
do | |
/usr/bin/sms "$i" "PIR ALARM TURNED ON - out0 = 0" | |
done | |
# /usr/bin/sms $i "PIR ALARM TURNED ON - out0 = 0" | |
logger -t "SMS_COMMAND" "ALARM TURNED ON" | |
# this statement sets the output to a 1 | |
elif [ "$3" = "OFF" ]; then | |
/usr/bin/io set out0 1 | |
for i in $PHONE1 $PHONE2 | |
do | |
/usr/bin/sms "$i" "PIR ALARM TURNED OFF - out0 = 1" | |
done | |
# /usr/bin/sms $i "PIR ALARM TURNED OFF - out0 = 1" | |
logger -t "SMS_COMMAND" "ALARM TURNED OFF" | |
# gets system voltage | |
elif [ "$3" = "VOLT" ]; then | |
svolt=$(status -v sys | grep Supply) | |
volt=$(status -v sys | grep Supply | grep -Eo '[+-]?[0-9]+([.][0-9]+)?') | |
pvolt=$(printf “%f” $volt) | |
# /usr/bin/sms $i “\${volt}” | |
for i in $PHONE1 $PHONE2 | |
do | |
/usr/bin/sms "$i" "${svolt}" | |
done | |
logger -t "SMS_COMMAND" "System Voltage ${svolt}" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment