Skip to content

Commit

Permalink
Merge branch 'release/1.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
darmbrust committed Jan 14, 2021
2 parents 6160835 + 6dc7466 commit 2da0708
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 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.10 -DdevelopmentVersion=1.11
mvn -B gitflow:release-start gitflow:release-finish -DreleaseVersion=1.11 -DdevelopmentVersion=1.12
```
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.10</version>
<version>1.11</version>
<packaging>jar</packaging>

<name>WeatherLink Logger and GUI</name>
Expand Down
26 changes: 18 additions & 8 deletions src/main/java/net/sagebits/weatherlink/data/DataReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,11 @@ public Thread newThread(Runnable r)
ldl = new LiveDataListener(22222);
timed.scheduleAtFixedRate(() ->
{
String response = null;
try
{
log.debug("Requesting Live Data Stream");
String response = readBytes(new URL("http://" + address + ":" + port + "/v1/real_time?duration=10800"));
response = readBytes(new URL("http://" + address + ":" + port + "/v1/real_time?duration=10800"));
log.trace("Live request response: {}", response);
response = stripHeaders(response);

Expand Down Expand Up @@ -156,6 +157,10 @@ public Thread newThread(Runnable r)
catch (Exception e)
{
log.error("Request for live data failed:" + e);
if (response != null)
{
log.debug("Live data request that caused an exception was: {}", response);
}
}

}, 0, 1 ,TimeUnit.HOURS);
Expand All @@ -171,10 +176,11 @@ public Thread newThread(Runnable r)

private void readData()
{
String data = null;
try
{
Platform.runLater(() -> lastReadAttemptTime.set(System.currentTimeMillis()));
String data = readBytes(new URL("http://" + address + ":" + port + "/v1/current_conditions"));
data = readBytes(new URL("http://" + address + ":" + port + "/v1/current_conditions"));
log.trace("Periodic Data: {}", data);
data = stripHeaders(data);

Expand All @@ -191,6 +197,10 @@ private void readData()
{
//Don't need a stack trace here
log.warn("Error during periodic data read, delaying and rescheduling: {}", e.toString());
if (data != null)
{
log.debug("Periodic Data that caused an exception was: {}", data);
}
//Its probably busy. Lets sleep for a bit, and give it time to recover.
//Will do this by canceling our current task, and rescheduling after a delay.
ScheduledExecutorService localRef = timed;
Expand Down Expand Up @@ -261,13 +271,13 @@ 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)
//There seems to be a bug, either with some WLL devices sending malformed headers - instead of ending in \r\n\r\n like they are supposed to,
//they are sending \n\n in older firmware releases. So, the headers aren't detected / removed by the URL library.
int endOfHeaderMarker = input.indexOf("\\n\\n");
if (endOfHeaderMarker > 0 && endOfHeaderMarker < 40)
{
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)));
String result = input.substring(endOfHeaderMarker + 2);
log.debug("Removed '{}' from the beginning of the input, as it appears headers were still present", input.substring(0, (endOfHeaderMarker + 2)));
return result;
}
return input;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class WeatherLinkLiveGUI extends Application
private WeatherLinkLiveGUIController wllc_;

public static Logger logger = LogManager.getLogger(WeatherLinkLiveGUI.class);
public static final String version = "1.11";

@Override
public void start(Stage primaryStage) throws Exception
Expand All @@ -45,7 +46,8 @@ public void finishSetUp()
wllc_ = loader.getController();
wllc_.finishInit(mainStage_);
// mainStage_.getIcons().add(Images.APPLICATION.getImage());
mainStage_.setTitle("Weather Link Live GUI 1.10");
mainStage_.setTitle("Weather Link Live GUI " + version);
logger.info("Running version is " + version);
mainStage_.setOnCloseRequest(event ->
{
wllc_.shutdown();
Expand Down

0 comments on commit 2da0708

Please sign in to comment.