Skip to content

Commit

Permalink
- Release connection after communicating SOAP to FritzBox
Browse files Browse the repository at this point in the history
- Decrease "no TR064 service found" to warning
- Set Timeouts for SOAP response to 4 seconds
  • Loading branch information
gitbock committed Apr 21, 2016
1 parent 6e35ca5 commit 537e171
Show file tree
Hide file tree
Showing 32 changed files with 2,151 additions and 2,043 deletions.
3 changes: 2 additions & 1 deletion META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Bundle-ManifestVersion: 2
Bundle-Description: This is the FritzboxTr064 binding of the open Home Aut
omation Bus (openHAB)
Import-Package: javax.net.ssl,
org.apache.commons.httpclient.params;version="3.1.0",
org.apache.commons.lang,
org.openhab.core.binding,
org.openhab.core.events,
Expand All @@ -27,7 +28,7 @@ Import-Package: javax.net.ssl,
org.slf4j
Export-Package: org.openhab.binding.fritzboxtr064
Bundle-DocURL: http://www.openhab.org
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Service-Component: OSGI-INF/binding.xml, OSGI-INF/genericbindingprovider.xml
Bundle-ClassPath: lib/httpclient-4.4.1.jar,
lib/httpcore-4.4.1.jar,
Expand Down
2 changes: 1 addition & 1 deletion OSGI-INF/binding.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2010-2015, openHAB.org and others.
Copyright (c) 2010-2016, openHAB.org and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
Expand Down
2 changes: 1 addition & 1 deletion OSGI-INF/genericbindingprovider.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2010-2015, openHAB.org and others.
Copyright (c) 2010-2016, openHAB.org and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
Expand Down
Binary file added lib/xercesImpl.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.openhab.bundles</groupId>
<artifactId>binding</artifactId>
<version>1.8.0-SNAPSHOT</version>
<version>1.9.0-SNAPSHOT</version>
</parent>

<properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2015, openHAB.org and others.
* Copyright (c) 2010-2016, openHAB.org and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -16,7 +16,7 @@
* @since 0.1.0
*/
public interface FritzboxTr064BindingProvider extends BindingProvider {
public FritzboxTr064BindingConfig getBindingConfigByItemName(String itemName);

public FritzboxTr064BindingConfig getBindingConfigByItemName(String itemName);

}
255 changes: 129 additions & 126 deletions src/main/java/org/openhab/binding/fritzboxtr064/internal/CallEvent.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2015, openHAB.org and others.
* Copyright (c) 2010-2016, openHAB.org and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -12,137 +12,140 @@
import org.slf4j.LoggerFactory;

/***
*
*
* Call Events received from fbox.
* Objects of this class represent parsed lines from fbox
* call events
*
* 12.10.15 20:24:22;RING;0;01715478654;6547841;SIP2;
* 12.10.15 20:24:24;DISCONNECT;0;0;
*
*
* 12.10.15 20:24:22;RING;0;01715478654;6547841;SIP2;
* 12.10.15 20:24:24;DISCONNECT;0;0;
*
* @author gitbock
* @since 1.8.0
*
*/
public class CallEvent {
private String _timestamp;
private String _callType;
private String _id;
private String _externalNo;
private String _internalNo;
private String _connectionType;
private String _raw;
private String _line;

//default logger
private static final Logger logger = LoggerFactory.getLogger(FritzboxTr064Binding.class);

public CallEvent(String rawEvent) {
this._raw = rawEvent;

}


public String getLine() {
return _line;
}


public void setLine(String _line) {
this._line = _line;
}


public String getTimestamp() {
return _timestamp;
}
public void setTimestamp(String _timestamp) {
this._timestamp = _timestamp;
}
public String getCallType() {
return _callType;
}
public void setCallType(String _callType) {
this._callType = _callType;
}
public String getId() {
return _id;
}
public void setId(String _id) {
this._id = _id;
}
public String getExternalNo() {
return _externalNo;
}
public void setExternalNo(String _externalNo) {
this._externalNo = _externalNo;
}
public String getInternalNo() {
return _internalNo;
}
public void setInternalNo(String _internalNo) {
this._internalNo = _internalNo;
}
public String getConnectionType() {
return _connectionType;
}
public void setConnectionType(String _connectionType) {
this._connectionType = _connectionType;
}
public String getRaw() {
return _raw;
}
public void setRaw(String _raw) {
this._raw = _raw;
}


/***
* parses the raw event string/line from fbox into fields of object
* @return true if parsing was successful
*/
public boolean parseRawEvent() {
if(_raw == null){ //check if we have something to parse
logger.error("Cannot parse call event. No input provided!");
return false;
}
String[] fields = _raw.split(";");
if(fields.length < 4){
logger.error("Cannot parse call event. Unexpected line received {}",_raw);
return false;
}
this._timestamp = fields[0];
this._callType = fields[1];
this._id = fields[2];
if (this._callType.equals("RING")) {
this._externalNo = fields[3];
this._internalNo = fields[4];
this._connectionType = fields[5];
} else if (this._callType.equals("CONNECT")) {
this._line = fields[3];
this._externalNo = fields[4];
} else if (this._callType.equals("CALL")) {
this._line = fields[3];
this._internalNo = fields[4];
this._externalNo = fields[5];
this._connectionType = fields[6];
}
logger.debug("Successfully parsed Call Event: {}",this.toString());
return true;
}


@Override
public String toString() {
return "CallEvent [_timestamp=" + _timestamp + ", _callType="
+ _callType + ", _id=" + _id + ", _externalNo=" + _externalNo
+ ", _internalNo=" + _internalNo + ", _connectionType="
+ _connectionType + ", _line=" + _line + "]";
}






private String _timestamp;
private String _callType;
private String _id;
private String _externalNo;
private String _internalNo;
private String _connectionType;
private String _raw;
private String _line;

// default logger
private static final Logger logger = LoggerFactory.getLogger(FritzboxTr064Binding.class);

public CallEvent(String rawEvent) {
this._raw = rawEvent;

}

public String getLine() {
return _line;
}

public void setLine(String _line) {
this._line = _line;
}

public String getTimestamp() {
return _timestamp;
}

public void setTimestamp(String _timestamp) {
this._timestamp = _timestamp;
}

public String getCallType() {
return _callType;
}

public void setCallType(String _callType) {
this._callType = _callType;
}

public String getId() {
return _id;
}

public void setId(String _id) {
this._id = _id;
}

public String getExternalNo() {
return _externalNo;
}

public void setExternalNo(String _externalNo) {
this._externalNo = _externalNo;
}

public String getInternalNo() {
return _internalNo;
}

public void setInternalNo(String _internalNo) {
this._internalNo = _internalNo;
}

public String getConnectionType() {
return _connectionType;
}

public void setConnectionType(String _connectionType) {
this._connectionType = _connectionType;
}

public String getRaw() {
return _raw;
}

public void setRaw(String _raw) {
this._raw = _raw;
}

/***
* parses the raw event string/line from fbox into fields of object
*
* @return true if parsing was successful
*/
public boolean parseRawEvent() {
if (_raw == null) { // check if we have something to parse
logger.error("Cannot parse call event. No input provided!");
return false;
}
String[] fields = _raw.split(";");
if (fields.length < 4) {
logger.error("Cannot parse call event. Unexpected line received {}", _raw);
return false;
}
this._timestamp = fields[0];
this._callType = fields[1];
this._id = fields[2];
if (this._callType.equals("RING")) {
this._externalNo = fields[3];
this._internalNo = fields[4];
this._connectionType = fields[5];
} else if (this._callType.equals("CONNECT")) {
this._line = fields[3];
this._externalNo = fields[4];
} else if (this._callType.equals("CALL")) {
this._line = fields[3];
this._internalNo = fields[4];
this._externalNo = fields[5];
this._connectionType = fields[6];
}
logger.debug("Successfully parsed Call Event: {}", this.toString());
return true;
}

@Override
public String toString() {
return "CallEvent [_timestamp=" + _timestamp + ", _callType=" + _callType + ", _id=" + _id + ", _externalNo="
+ _externalNo + ", _internalNo=" + _internalNo + ", _connectionType=" + _connectionType + ", _line="
+ _line + "]";
}

}
Loading

0 comments on commit 537e171

Please sign in to comment.