You are here

Triggering Zoneminder from Hi3518C SoC IP Cameras

#!/bin/sh
CAM1IPHEX="0x0A01A8C0"    # Camera IP address in hex. The cameras send the ip address in hex as part of it's identification
CAM2IPHEX="0x0C01A8C0"    # Camera IP address in hex. The cameras send the ip address in hex as part of it's identification
RUNNINGPROGS="Stop"

while true; do
    ALARMCALL=`nc -l -p 15002`                               # waits for a message on ALARMPORT

    if [ -z "${ALARMCALL##*$CAM1IPHEX*}" ] && ! [ -z "${ALARMCALL##*$RUNNINGPROGS*}" ]; then
    echo -e "\007" > /dev/tty10
       echo -n "1|on+15|1|motion" | nc 127.0.0.1 6802 # MonitorNumber|on+seconds|Avg.Score|reason for alarm
#          echo $ALARMCALL  # Use for debugging
    fi

    if [ -z "${ALARMCALL##*$CAM2IPHEX*}" ] && ! [ -z "${ALARMCALL##*$RUNNINGPROGS*}" ]; then
    echo -e "\007" > /dev/tty10
       echo -n "2|on+15|1|motion" | nc 127.0.0.1 6802 # MonitorNumber|on+seconds|Avg.Score|reason for alarm
#          echo $ALARMCALL  # Use for debugging
    fi
done

# echo -n "1|on+15|1|motion" | nc 127.0.0.1 6802 # use for testing
# sudo stop zoneminder-trigger # use to stop
# sudo start zoneminder-trigger # use to start