~mil/sxmo-utils

d4fd25e3e9f1602f2a5112bfbeb9ee6a5443bbdc — Stacy Harper 3 months ago 0d528ff
Prevent some error states cause of dangling event files

Some event file stay present in some case (ex: .initiated) and this can
lead to issues in futures calls.

We remove dedicated cleanup and now we remove all event file related to
the finish call in once. We do it in incoming call cause sometime
modemnager fail to detect terminated calls.

Signed-off-by: Stacy Harper <contact@stacyharper.net>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
1 files changed, 1 insertions(+), 5 deletions(-)

M scripts/modem/sxmo_modemmonitor.sh
M scripts/modem/sxmo_modemmonitor.sh => scripts/modem/sxmo_modemmonitor.sh +1 -5
@@ 95,29 95,24 @@ checkforfinishedcalls() {
		if [ -f "$CACHEDIR/${FINISHEDCALLID}.discardedcall" ]; then
			#this call was discarded
			echo "sxmo_modemmonitor: Discarded call from $FINISHEDNUMBER">&2
			rm -f "$CACHEDIR/${FINISHEDCALLID}.discardedcall"
			printf %b "$TIME\tcall_discarded\t$FINISHEDNUMBER\n" >> "$LOGDIR/modemlog.tsv"
		elif [ -f "$CACHEDIR/${FINISHEDCALLID}.pickedupcall" ]; then
			#this call was picked up
			pkill -f sxmo_modemcall.sh
			echo "sxmo_modemmonitor: Finished call from $FINISHEDNUMBER">&2
			rm -f "$CACHEDIR/${FINISHEDCALLID}.pickedupcall"
			printf %b "$TIME\tcall_finished\t$FINISHEDNUMBER\n" >> "$LOGDIR/modemlog.tsv"
		elif [ -f "$CACHEDIR/${FINISHEDCALLID}.hangedupcall" ]; then
			#this call was hung up by the user
			echo "sxmo_modemmonitor: Finished call from $FINISHEDNUMBER">&2
			rm -f "$CACHEDIR/${FINISHEDCALLID}.hangedupcall"
			printf %b "$TIME\tcall_finished\t$FINISHEDNUMBER\n" >> "$LOGDIR/modemlog.tsv"
		elif [ -f "$CACHEDIR/${FINISHEDCALLID}.initiatedcall" ]; then
			#this call was hung up by the contact
			pkill -f sxmo_modemcall.sh
			echo "sxmo_modemmonitor: Finished call from $FINISHEDNUMBER">&2
			rm -f "$CACHEDIR/${FINISHEDCALLID}.initiatedcall"
			printf %b "$TIME\tcall_finished\t$FINISHEDNUMBER\n" >> "$LOGDIR/modemlog.tsv"
		elif [ -f "$CACHEDIR/${FINISHEDCALLID}.mutedring" ]; then
			#this ring was muted up
			echo "sxmo_modemmonitor: Muted ring from $FINISHEDNUMBER">&2
			rm -f "$CACHEDIR/${FINISHEDCALLID}.mutedring"
			printf %b "$TIME\tring_muted\t$FINISHEDNUMBER\n" >> "$LOGDIR/modemlog.tsv"
		else
			#this is a missed call


@@ 155,6 150,7 @@ checkforincomingcalls() {
	[ -z "$VOICECALLID" ] && return

	[ -f "$CACHEDIR/${VOICECALLID}.monitoredcall" ] && return # prevent multiple rings
	rm -f "$CACHEDIR/${VOICECALLID}.*" # we cleanup all dangling event files
	touch "$CACHEDIR/${VOICECALLID}.monitoredcall" #this signals that we handled the call

	cat "$LASTSTATE" > "$CACHEDIR/${VOICECALLID}.laststate"