Access AVM FRITZ!Box 7390 PhoneCall In/Out Information from Java
AVM Fritz!Box provides a phone call monitor. To access the information, you have to activate Port 1012 in the Box. The setting is not available from the GUI, but you can use your phone to switch the feature on and off.
Dial #96*5* to enable the call monitor ( #96*5* to disable ).
To access the information via telnet for example, you also have to enable telnetd in your FRITZ!Box . Dial #96*7* to enable the telnetd ( #96*8* to disable ).
Here is some simple code that monitors the phone call manager via telnet on port 1012
package de.eknori.test;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.Socket;
public class CallMonitor {
public static void main(String[] argv) {
new CallMonitor().getCall("192.168.178.1", 1012);
}
private void getCall(String host, int portNum) {
System.out.println("Host " + host + "; port " + portNum);
try {
Socket s = new Socket(host, portNum);
new Pipe(s.getInputStream(), System.out).start();
new Pipe(System.in, s.getOutputStream()).start();
} catch (IOException e) {
System.out.println(e);
return;
}
System.out.println("Connected OK");
}
/**
* This class handles one half of a full-duplex connection.
*/
class Pipe extends Thread {
BufferedReader is;
PrintStream os;
Pipe(InputStream is, OutputStream os) {
this.is = new BufferedReader(new InputStreamReader(is));
this.os = new PrintStream(os);
}
}
}
When you run the code, you will see something like this as an output
* 14.10.12 10:56:19;CALL;1;10;XXX5670;XXX8506;SIP0;
* 14.10.12 10:56:19;RING;2;02104XXX5670;XXX8506;SIP2;
* 14.10.12 10:56:21;DISCONNECT;2;0;
* 14.10.12 10:56:21;CONNECT;1;10;XXX8506;
* 14.10.12 10:56:24;DISCONNECT;1;4;
* 14.10.12 10:56:21;RING;0;02104XXX5670;XXX8506;SIP2;
* 14.10.12 10:56:21;CONNECT;0;5;02104XXX5670;
* 14.10.12 10:56:24;DISCONNECT;0;4;
I have tested with AVM Fritz!Box 7390