Skip to content

Commit

Permalink
OnTel: Allow retrieval of call list
Browse files Browse the repository at this point in the history
The call list is a rather large XML document. Parsing the list seems
quite tedious, so it's not as nice an output as the other functions.

For an actual script though parsing is very much possible, when the
use case is known.
  • Loading branch information
lennartS committed Nov 11, 2022
1 parent c278f47 commit 27f4d52
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
23 changes: 23 additions & 0 deletions fritzBoxShell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,23 @@ TAM() {
fi
}

### ----------------------------------------------------------------------------------------------------- ###
### -------------------------------- FUNCTION OnTel - TR-064 Protocol ----------------------------------- ###
### ---------------------- Function to get the call list for a given number of days --------------------- ###
### ----------------------------------------------------------------------------------------------------- ###

OnTel() {
location="/upnp/control/x_contact"
uri="urn:dslforum-org:service:X_AVM-DE_OnTel:1"

if [ "$option2" = "GetCallList" ]; then
action='GetCallList'
listurl=$(curl -s -k -m 5 --anyauth -u "$BoxUSER:$BoxPW" "http://$BoxIP:49000$location" -H 'Content-Type: text/xml; charset="utf-8"' -H "SoapAction:$uri#$action" -d "<?xml version='1.0' encoding='utf-8'?><s:Envelope s:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'><s:Body><u:$action xmlns:u='$uri'></u:$action></s:Body></s:Envelope>" | grep "<New" | awk -F"</" '{print $1}' | awk -F"URL>" '{print $2}')
curl -s -k -m 5 --anyauth -u "$BoxUSER:$BoxPW" "$listurl&days=$option3"
fi

}

### ----------------------------------------------------------------------------------------------------- ###
### ------------------------------ FUNCTION WLANstate - TR-064 Protocol --------------------------------- ###
### ----- Function to switch ON or OFF 2.4 and/or 5 Ghz WiFi and also getting the state of the WiFi ----- ###
Expand Down Expand Up @@ -734,6 +751,8 @@ DisplayArguments() {
echo "| TAM | <index> and ON or OFF | e.g. TAM 0 ON (switches ON the answering machine) |"
echo "| TAM | <index> and GetMsgs | e.g. TAM 0 GetMsgs (gives XML formatted list of messages) |"
echo "|----------------|------------------------|-------------------------------------------------------------------------|"
echo "| OnTel | GetCallList and <days> | e.g. OnTel GetCallList 7 for all calls of the last seven days |"
echo "|----------------|------------------------|-------------------------------------------------------------------------|"
echo "| LED | 0 or 1 | Switching ON (1) or OFF (0) the LEDs in front of the Fritz!Box |"
echo "| LED_BRIGHTNESS | 1 or 2 or 3 | Setting the brightness of the LEDs in front of the Fritz!Box |"
echo "| KEYLOCK | 0 or 1 | Activate (1) or deactivate (0) the Keylock (buttons de- or activated) |"
Expand Down Expand Up @@ -831,6 +850,10 @@ else
if [[ $option2 =~ ^[+-]?[0-9]+$ ]] && { [ "$option3" = "GetInfo" ] || [ "$option3" = "ON" ] || [ "$option3" = "OFF" ] || [ "$option3" = "GetMsgs" ];}; then TAM
else DisplayArguments
fi
elif [ "$option1" = "OnTel" ]; then
if [ "$option2" = "GetCallList" ]; then OnTel
else DisplayArguments
fi
elif [ "$option1" = "REPEATER" ]; then
if [ "$option2" = "1" ]; then RepeaterWLANstate "ON"; # Usually this will not work because there is no connection possible to the Fritz!Repeater as long as WiFi is OFF
elif [ "$option2" = "0" ]; then RepeaterWLANstate "OFF";
Expand Down
6 changes: 3 additions & 3 deletions fritzBoxShellTest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ DIRECTORY=$(cd "$dir" && pwd)
source "$DIRECTORY/fritzBoxShellConfig.sh"

## declare an array variable
declare -a services=("WLAN_2G" "WLAN_2G" "WLAN_5G" "WLAN_2G" "WLAN" "LAN" "DSL" "WAN" "LINK" "IGDWAN" "IGDDSL" "IGDIP" "TAM")
declare -a actions=("STATISTICS" "STATE" "STATISTICS" "STATE" "STATE" "STATE" "STATE" "STATE" "STATE" "STATE" "STATE" "STATE" "0 GetInfo")
declare -a minwords=(3 5 3 5 9 1 1 1 1 1 1 1 5 )
declare -a services=("WLAN_2G" "WLAN_2G" "WLAN_5G" "WLAN_2G" "WLAN" "LAN" "DSL" "WAN" "LINK" "IGDWAN" "IGDDSL" "IGDIP" "TAM" "OnTel")
declare -a actions=("STATISTICS" "STATE" "STATISTICS" "STATE" "STATE" "STATE" "STATE" "STATE" "STATE" "STATE" "STATE" "STATE" "0 GetInfo" "GetCallList 1")
declare -a minwords=(3 5 3 5 9 1 1 1 1 1 1 1 5 1)

## now loop through the above array
counter=0
Expand Down

0 comments on commit 27f4d52

Please sign in to comment.