[arm-allstar] Door Alarm

Dave Petrie wa2kjc at gmail.com
Wed Jul 5 08:35:11 EDT 2023


Can someone edit the attached script so as to make it real simple, it works
nicely as is but I have another use for GPIO bit 21, I want to play a cw T
as soon as bit 21 goes low, one time play and no wait, play everytime bit
21 goes low. Reset to high within a second or two so a retrigger will be
heard. I understand play location.
This will only be on my node.
Thank You
Dave


WA2KJC - Dave

315-415-0541

Retired and still enjoying technical challenges:

HP ASE, MCSE, CompTIA A+, NABER,CETma, CETsr, Motorola R56,

Radio Network Manager, Alcatel Level 3, Certified Computer System Technician

Certified Network System Technician, Certified Two Way Radio Technician

Certified Journeyman CETa, Certified Wireless Technician,

Certified Line Sweeping Technician
-------------- next part --------------
#!/bin/bash
sudo /usr/bin/asterisk -vvvvr -x "rpt playback 40039 /var/lib/asterisk/sounds/custom/dooron" 
# Door security check - Allstar Repeater Controller
# 

# Read Pi GPIO bit using interrupt
# Bit to use for door security
# GPIO bit 21 - physical pin 29
Bit=21

function wait_open {
#while [ 1=1 ]
#do
# Wait for pin 29 to open
 while [ 1=1 ]
 # wait for rising edge interrupt
   /usr/local/bin/gpio wfi $Bit rising
   do
   while [ $(/usr/local/bin/gpio read $Bit) -eq "1" ];
    do
      sleep 1
      let TIME1+=1
      if [ $TIME1 -gt 3 ]; then
         break 2;
      fi
   done
   TIME1=1
   continue
done
}

function open_message {
 # pin 29 is high - say message 
 echo "$(date) - pin 29 is high"
 /usr/bin/asterisk -vvvvr -x "rpt playback 40039 /var/lib/asterisk/sounds/custom/dooropen" 
}

function wait_close {
 TIME1=1
 while [ $(/usr/local/bin/gpio read $Bit) -eq "1" ];
  do 
    sleep 5
    let TIME1+=1
    if [ $TIME1 -gt 12 ]
       then
	   # Repeat message every 1 minutes
	   echo "$(date) - pin 29 is high"
	   /usr/bin/asterisk -vvvvr -x "rpt playback 40039 /var/lib/asterisk/sounds/custom/dooropen"
	TIME1=1	
    fi
  done
}

function close_message {
  # Door is locked - say message
  echo "$(date) - pin 29 is low"
  /usr/bin/asterisk -vvvvr -x "rpt playback 40039 /var/lib/asterisk/sounds/custom/doorsecure"
}

sleep 10
if [ $(/usr/local/bin/gpio read $Bit) -eq "1" ]
   then
     sleep 1
     open_message
     while [ 1=1 ]
     do
       wait_close
       close_message
       wait_open
       open_message
     done
   else
     sleep 1
     close_message
     while [ 1=1 ]
     do
       wait_open
       open_message
       wait_close
       close_message
     done
fi



More information about the ARM-allstar mailing list