#!/bin/sh

###############################################################################
# capi20wrapper - Collection of functions and data structures for accessing
#                 a shared library which implements the interface as described
#                 in section 'Linux' in part two of CAPI 2.0
# 
# Written in 2014 by Swen Lünig.
# 
# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain
# worldwide. This software is distributed without any warranty.
# 
# You should have received a copy of the CC0 Public Domain Dedication along
# with this software. If not, see
# <http://creativecommons.org/publicdomain/zero/1.0/>.
###############################################################################

# little implementation of a ping to a phone number
# It counts tries and successful tries.
#
# Call the script like this (with the real phone number):
# CAPI20_Called_party_number=0123 ./capi20Ping
	
count_tries=0;
count_successful_tries=0;

while true; do

  count_tries=$(( count_tries + 1 ))
  LD_LIBRARY_PATH=./:$HOME/lib/ CAPI20_Controller=0x00000005 ./capi20CONNECT_REQ
  if test $? -eq 0; then
    count_successful_tries=$(( count_successful_tries + 1 ))
  fi

  echo "###########################################################################"
  echo "${count_successful_tries} successful tries of ${count_tries} tries"
  echo ""
  echo ""

  sleep 3
  
done

exit 0
