long stamp = System.currentTimeMillis();
if (!isKebaReachable()) {
logger.debug("isKebaReachable() timed out after '{}' milliseconds", System.currentTimeMillis() - stamp);
- transceiver.unRegisterHandler(getHandler());
+ updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
+ "An timeout occurred while polling the charging station");
} else {
- if (getThing().getStatus() == ThingStatus.ONLINE) {
- ByteBuffer response = cache.get(CACHE_REPORT_1);
- if (response != null) {
- onData(response);
- }
+ ByteBuffer response = cache.get(CACHE_REPORT_1);
+ if (response == null) {
+ logger.debug("Missing response from Keba station for 'report 1'");
+ } else {
+ onData(response);
+ }
- Thread.sleep(REPORT_INTERVAL);
+ Thread.sleep(REPORT_INTERVAL);
- response = cache.get(CACHE_REPORT_2);
- if (response != null) {
- onData(response);
- }
+ response = cache.get(CACHE_REPORT_2);
+ if (response == null) {
+ logger.debug("Missing response from Keba station for 'report 2'");
+ } else {
+ onData(response);
+ }
- Thread.sleep(REPORT_INTERVAL);
+ Thread.sleep(REPORT_INTERVAL);
- response = cache.get(CACHE_REPORT_3);
- if (response != null) {
- onData(response);
- }
+ response = cache.get(CACHE_REPORT_3);
+ if (response == null) {
+ logger.debug("Missing response from Keba station for 'report 3'");
+ } else {
+ onData(response);
+ }
- if (isReport100needed) {
- Thread.sleep(REPORT_INTERVAL);
+ if (isReport100needed) {
+ Thread.sleep(REPORT_INTERVAL);
- response = cache.get(CACHE_REPORT_100);
- if (response != null) {
- onData(response);
- }
- isReport100needed = false;
+ response = cache.get(CACHE_REPORT_100);
+ if (response == null) {
+ logger.debug("Missing response from Keba station for 'report 100'");
+ } else {
+ onData(response);
}
+ isReport100needed = false;
}
}
- } catch (NumberFormatException | IOException e) {
- logger.debug("An exception occurred while polling the KEBA KeContact '{}': {}", getThing().getUID(),
+ } catch (IOException e) {
+ logger.debug("An error occurred while polling the KEBA KeContact '{}': {}", getThing().getUID(),
e.getMessage(), e);
- Thread.currentThread().interrupt();
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
- "An exception occurred while while polling the charging station");
+ "An error occurred while polling the charging station");
} catch (InterruptedException e) {
logger.debug("Polling job has been interrupted for handler of thing '{}'.", getThing().getUID());
}
}
protected void onData(ByteBuffer byteBuffer) {
+ if (getThing().getStatus() != ThingStatus.ONLINE) {
+ updateStatus(ThingStatus.ONLINE);
+ }
+
String response = new String(byteBuffer.array(), 0, byteBuffer.limit());
response = StringUtils.chomp(response);