DECT: Send a location request to a set

Everything about the PWT, IBS, RBS, DECT..
Post Reply
Eliott_DUP

DECT: Send a location request to a set

Post by Eliott_DUP »

The command works for Mobile Reflexes only.
It makes it possible to establish a link and see if a handset is on or off.

tool dectlocreq d <directory>

It sends mm_info_suggest(locate_req) to the specified handset.

Option n followed by the neqt is also supported.

With dectview com you can check the status.

I made a small and easy script to check all sets in a list.

Installation:
Copy the script to /usr2/mtcl/
Set execution rights: chmod 777 /usr2/mtcl/DectPhone.sh
Start with ./DectPhone.sh
The script creates logfiles DectPhone.* in /tmpd/

DAT_FILE with all sets to check
ON_FILE result - all sets which seems to be on
OFF_FILE result - all sets which seems to be off
LOG_FILE just a log
PID_FILE pid of the script

Code: Select all

#!/bin/sh
#set -x
#
# Read Status of DECT Phones
# (C) Woersty 11:51 09.02.2007
#

VERSION="2.0"
DAT_FILE="/usr4/tmp/DectPhone.dat"
ON_FILE="/usr4/tmp/DectPhone.on"
OFF_FILE="/usr4/tmp/DectPhone.off"
LOG_FILE="/usr4/tmp/DectPhone.log"
PID_FILE="/usr4/tmp/DectPhone.pid"

decho()
{ 
	/bin/echo "`date +'[%d/%m/%Y %H:%M:%S]'` ${1}" >>${LOG_FILE}
	/bin/echo "`date +'[%d/%m/%Y %H:%M:%S]'` ${1}" 
}
dnecho()
{ 
	/bin/echo -n "${1}" >>${LOG_FILE}
	/bin/echo -n "${1}" 
}
dnlecho()
{ 
	/bin/echo "">>${LOG_FILE}
	/bin/echo ""
}
_key()
{
    IFS= read -r -s -n1 -d '' "${@:-_KEY}"
}

#
# Hauptprogramm
#
if [ -f ${PID_FILE} ] ; then
	decho "--> Script still running, aborting."
	decho "--> Please delete the file ${PID_FILE} if necessary."
	exit 0
fi
/bin/echo $$ >${PID_FILE}

decho "*** Starting DectPhone - Version ${VERSION} ***"
decho "*** This script checks, if GAP+ are switched on ***"
MAIN="`/usr2/oneshot/mtcl/role`"
if [ "${MAIN}" = "MAIN" ] ; then
	decho "CPU is MAIN, ok."
else
	decho "CPU is ${MAIN} -> not MAIN, aborting."
	/bin/rm -f ${PID_FILE}
	decho "*** Exiting DectPhone ***"
	exit 0
fi

cd /usr3/mao
decho "Reading DECT GAP+ sets into $DAT_FILE ..."
/usr2/oneshot/mtcl/tool dectsets |grep "Nbr=" |egrep "AGAP" | /usr/bin/cut -d" " -f4 |/usr/bin/cut -d"=" -f2 >$DAT_FILE
decho "`cat ${DAT_FILE} | wc -l ` DECT sets found"

		if [ -f ${OFF_FILE} ] ; then
			decho "Saving old DectPhone OFF log file to ${OFF_FILE}.bak "
			/bin/mv ${OFF_FILE} ${OFF_FILE}.bak
		fi
		if [ -f ${ON_FILE} ] ; then
			decho "Saving old DectPhone ON log file to ${ON_FILE}.bak "
			/bin/mv ${ON_FILE} ${ON_FILE}.bak
		fi

/bin/echo -n >> ${ON_FILE}
/bin/echo -n >> ${OFF_FILE}
/bin/cat ${DAT_FILE} | while read nstNbr ; do
	dnecho "`date +'[%d/%m/%Y %H:%M:%S]'` Checking DECT ${nstNbr}:"
	NULOG=`echo "select nulog,numan from poste where numan='${nstNbr}';" | /usr2/fab/cuser . m | /bin/grep -v "select" | /bin/grep ${nstNbr} | /usr/bin/cut -d" " -f2`
 	if [ -z "${NULOG}" ] ; then
    	decho "--> ${nstNbr}: No user."	
	else
		dnecho " check communication "
		STAT="`/usr2/oneshot/mtcl/tool dectview com |/bin/grep ${nstNbr} |/usr/bin/cut -d"/" -f3  |/usr/bin/cut -d" " -f1`"
		dnecho ${STAT}
		if [ "${STAT}" = "STABLE" ] ; then
			OUTSERV="false"
			dnecho " -> Link established ->ON"
			PORT="`echo ${COMMI} |egrep 'PAGIN|STAB|PART_REL' |/usr/bin/cut -d":" -f4  |/usr/bin/cut -d"/" -f2  |/usr/bin/cut -d" " -f1`"
			CPL="`echo ${COMMI} |egrep 'PAGIN|STAB|PART_REL' |/usr/bin/cut -d":" -f5  |/usr/bin/cut -d"/" -f2`"
			CRY="`echo ${COMMI} |egrep 'PAGIN|STAB|PART_REL' |/usr/bin/cut -d":" -f5  |/usr/bin/cut -d"/" -f1`"
			POSITION=$CRY"-"$CPL"-"$PORT
			dnlecho 
		else
			OUTSERV="true"
			dnecho "-> No conversation -> resetting phone "
			/usr2/oneshot/mtcl/tool dectlocreq d ${nstNbr} >/dev/null 2>/dev/null
		fi
			TIMEDIFF=0
			TIMESTART=`date +%s`
		while [ "${OUTSERV}" = "true" -a ${TIMEDIFF} -lt 7 ]
		do
				COMMI="`/usr2/oneshot/mtcl/tool dectview com |/bin/grep  ${nstNbr} `"
				STAT="`echo ${COMMI} |egrep 'PAGIN|STAB|PART_REL' |/usr/bin/cut -d"/" -f3  |/usr/bin/cut -d" " -f1`"
				if [ "${STAT}" = "PAGING" ] ; then
					STAT=":"
				fi
				dnecho ".${STAT}"
				if [ "${STAT}" = "STABLE" -o  "${STAT}" = "PART_REL" ] ; then
				 dnecho "->ON"
				 dnlecho 
 				 OUTSERV="false"
				PORT="`echo ${COMMI} |egrep 'PAGIN|STAB|PART_REL' |/usr/bin/cut -d":" -f4  |/usr/bin/cut -d"/" -f2  |/usr/bin/cut -d" " -f1`"
				CPL="`echo ${COMMI} |egrep 'PAGIN|STAB|PART_REL' |/usr/bin/cut -d":" -f5  |/usr/bin/cut -d"/" -f2`"
				CRY="`echo ${COMMI} |egrep 'PAGIN|STAB|PART_REL' |/usr/bin/cut -d":" -f5  |/usr/bin/cut -d"/" -f1`"
				POSITION=$CRY"-"$CPL"-"$PORT
 				fi
				/bin/usleep 250000
				TIME=`date +%s`
				TIMEDIFF=`expr ${TIME} - ${TIMESTART}`
		done
			if [ "${OUTSERV}" = "false" ] ; then
				echo "${nstNbr}-${POSITION}-${STAT}" >> ${ON_FILE}
			else
				echo ${nstNbr} >> ${OFF_FILE}
				dnecho "NO REPLY->OFF"	
				dnlecho 
			fi
	fi
done
#
/bin/rm -f ${PID_FILE}
decho "Active sets: "
/bin/cat ${ON_FILE}
/bin/cat ${ON_FILE} >>${LOG_FILE}
decho "Sets without paging reply:"
/bin/cat ${OFF_FILE}
/bin/cat ${OFF_FILE} >>${LOG_FILE}
decho "*** Exiting of DectPhone normally ***"
#
exit 0
Post Reply

Return to “Wireless configuration and sets”