Skip to content

Commit

Permalink
Merge branch 'release/1.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
darmbrust committed Jan 14, 2021
2 parents f874298 + 3cb5635 commit 6160835
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ There are lots of TODOs.... useful things I may add (pull requests welcome)

Change version in WeatherLinkLiveGUI.java too
```
mvn -B gitflow:release-start gitflow:release-finish -DreleaseVersion=1.09 -DdevelopmentVersion=1.10
mvn -B gitflow:release-start gitflow:release-finish -DreleaseVersion=1.10 -DdevelopmentVersion=1.11
```
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>net.sagebits.weatherlink</groupId>
<artifactId>weatherlink</artifactId>
<version>1.09</version>
<version>1.10</version>
<packaging>jar</packaging>

<name>WeatherLink Logger and GUI</name>
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/net/sagebits/weatherlink/data/DataReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*/
public class DataReader
{
private final Logger log = LogManager.getLogger(DataReader.class);
private static final Logger log = LogManager.getLogger(DataReader.class);
private final String address;
private final int port;

Expand Down Expand Up @@ -130,6 +130,7 @@ public Thread newThread(Runnable r)
log.debug("Requesting Live Data Stream");
String response = readBytes(new URL("http://" + address + ":" + port + "/v1/real_time?duration=10800"));
log.trace("Live request response: {}", response);
response = stripHeaders(response);

JsonNode rootNode = mapper.readTree(response);
if (!"null".equals(rootNode.get("error").asText()))
Expand Down Expand Up @@ -175,6 +176,7 @@ private void readData()
Platform.runLater(() -> lastReadAttemptTime.set(System.currentTimeMillis()));
String data = readBytes(new URL("http://" + address + ":" + port + "/v1/current_conditions"));
log.trace("Periodic Data: {}", data);
data = stripHeaders(data);

JsonNode rootNode = mapper.readTree(data);
if (!"null".equals(rootNode.get("error").asText()))
Expand Down Expand Up @@ -257,6 +259,20 @@ public static String readBytes(URL url) throws IOException
}
}

public static String stripHeaders(String input)
{
//There seems to be a bug, either with some WLL devices sending malformed headers, which the URL InputStream isn't removing, or, with
//certain versions of java, which aren't properly removing headers.
int endOfHeaderMarker = input.indexOf("\\r\\n\\r\\n");
if (endOfHeaderMarker > 0)
{
String result = input.substring(endOfHeaderMarker + 4);
log.debug("Removed '{}' from the beginning of the input, as it appears headers were still present", input.substring(0, (endOfHeaderMarker + 4)));
return result;
}
return input;
}

public static void main(String[] args) throws IOException, InterruptedException, SQLException
{
DataReader dr = new DataReader(Optional.empty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void finishSetUp()
wllc_ = loader.getController();
wllc_.finishInit(mainStage_);
// mainStage_.getIcons().add(Images.APPLICATION.getImage());
mainStage_.setTitle("Weather Link Live GUI 1.09");
mainStage_.setTitle("Weather Link Live GUI 1.10");
mainStage_.setOnCloseRequest(event ->
{
wllc_.shutdown();
Expand Down

0 comments on commit 6160835

Please sign in to comment.