From 27f4d529a12549854bad8157beac3ccb082b18c6 Mon Sep 17 00:00:00 2001 From: Lennart Sauerbeck Date: Fri, 11 Nov 2022 18:50:39 +0100 Subject: [PATCH] OnTel: Allow retrieval of call list 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. --- fritzBoxShell.sh | 23 +++++++++++++++++++++++ fritzBoxShellTest.sh | 6 +++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/fritzBoxShell.sh b/fritzBoxShell.sh index 9cf1372..02a998a 100755 --- a/fritzBoxShell.sh +++ b/fritzBoxShell.sh @@ -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 "" | grep "" '{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 ----- ### @@ -734,6 +751,8 @@ DisplayArguments() { echo "| TAM | and ON or OFF | e.g. TAM 0 ON (switches ON the answering machine) |" echo "| TAM | and GetMsgs | e.g. TAM 0 GetMsgs (gives XML formatted list of messages) |" echo "|----------------|------------------------|-------------------------------------------------------------------------|" + echo "| OnTel | GetCallList and | 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) |" @@ -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"; diff --git a/fritzBoxShellTest.sh b/fritzBoxShellTest.sh index 0166153..eba9028 100755 --- a/fritzBoxShellTest.sh +++ b/fritzBoxShellTest.sh @@ -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