Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Commit

Permalink
TCP/UDP Binding : fix .cfg issues, improve exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kgoderis committed Aug 16, 2014
1 parent 76e85fd commit 1ac5526
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,24 @@ public void updated(Dictionary config) throws ConfigurationException {

String preambleString = (String) config.get("preamble");
if (StringUtils.isNotBlank(preambleString)) {
preAmble = preambleString.replaceAll("\\\\", "\\");
try {
preAmble = preambleString.replaceAll("\\\\", "\\");
}
catch(Exception e) {
preAmble = preambleString;
}
} else {
logger.info("The preamble for all write operations will be set to the default vaulue of {}",preAmble);
}

String postambleString = (String) config.get("postamble");
if (StringUtils.isNotBlank(postambleString)) {
postAmble = postambleString.replaceAll("\\\\", "\\");;
try {
postAmble = postambleString.replaceAll("\\\\", "\\");
}
catch(Exception e) {
postAmble = postambleString;
}
} else {
logger.info("The postamble for all write operations will be set to the default vaulue of {}",postAmble);
}
Expand Down Expand Up @@ -253,7 +263,7 @@ protected String transformResponse(String transformation, String response) {
logger.warn("couldn't transform response because transformationService of type '{}' is unavailable", transformationType);
}
}
catch (TransformationException te) {
catch (Exception te) {
logger.error("transformation throws exception [transformation="
+ transformation + ", response=" + response + "]", te);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,24 @@ public void updated(Dictionary config) throws ConfigurationException {

String preambleString = (String) config.get("preamble");
if (StringUtils.isNotBlank(preambleString)) {
preAmble = preambleString.replaceAll("\\\\", "\\");
try {
preAmble = preambleString.replaceAll("\\\\", "\\");
}
catch(Exception e) {
preAmble = preambleString;
}
} else {
logger.info("The preamble for all write operations will be set to the default vaulue of {}",preAmble);
}

String postambleString = (String) config.get("postamble");
if (StringUtils.isNotBlank(postambleString)) {
postAmble = postambleString.replaceAll("\\\\", "\\");;
try {
postAmble = postambleString.replaceAll("\\\\", "\\");
}
catch(Exception e) {
postAmble = postambleString;
}
} else {
logger.info("The postamble for all write operations will be set to the default vaulue of {}",postAmble);
}
Expand Down Expand Up @@ -254,7 +264,7 @@ protected String transformResponse(String transformation, String response) {
logger.warn("couldn't transform response because transformationService of type '{}' is unavailable", transformationType);
}
}
catch (TransformationException te) {
catch (Exception te) {
logger.error("transformation throws exception [transformation="
+ transformation + ", response=" + response + "]", te);

Expand Down
6 changes: 3 additions & 3 deletions distribution/openhabhome/configurations/openhab_default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ hue:secret=openHABRuntime
#tcp:port=25001

# Cron-like string to reconnect remote ends, e.g for unstable connection or remote ends
#tcp:reconnectron='0 0 0 * * ?'
#tcp:reconnectcron=0 0 0 * * ?

# Interval between reconnection attempts when recovering from a communication error,
# in seconds
Expand All @@ -990,10 +990,10 @@ hue:secret=openHABRuntime
#tcp:addressmask=true

# Pre-amble that will be put in front of data being sent
#tcp:preamble=''
#tcp:preamble=

# Post-amble that will be appended to data being sent
#tcp:postamble='\r\n'
#tcp:postamble=\r\n

# Perform all write/read (send/receive) operations in a blocking mode, e.g. the binding
# will wait for a reply from the remote end after data has been sent
Expand Down

0 comments on commit 1ac5526

Please sign in to comment.