mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[bluegiga] Improved illegal frame receiving handling (#9442)
Signed-off-by: Pauli Anttila <pauli.anttila@gmail.com>
This commit is contained in:
parent
46bf375db4
commit
9fb476f24e
@ -280,14 +280,22 @@ public class BlueGigaSerialHandler {
|
|||||||
inputLength = inputBuffer[1] + (inputBuffer[0] & 0x02 << 8) + 4;
|
inputLength = inputBuffer[1] + (inputBuffer[0] & 0x02 << 8) + 4;
|
||||||
if (inputLength > 64) {
|
if (inputLength > 64) {
|
||||||
logger.debug("BLE length larger than 64 bytes ({})", inputLength);
|
logger.debug("BLE length larger than 64 bytes ({})", inputLength);
|
||||||
|
if (inputStream.markSupported()) {
|
||||||
|
inputStream.reset();
|
||||||
|
}
|
||||||
|
inputCount = 0;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (inputCount == inputLength) {
|
if (inputCount == inputLength) {
|
||||||
|
if (logger.isTraceEnabled()) {
|
||||||
|
logger.trace("BLE RX: {}", printHex(inputBuffer, inputLength));
|
||||||
|
}
|
||||||
|
|
||||||
// End of packet reached - process
|
// End of packet reached - process
|
||||||
BlueGigaResponse responsePacket = BlueGigaResponsePackets.getPacket(inputBuffer);
|
BlueGigaResponse responsePacket = BlueGigaResponsePackets.getPacket(inputBuffer);
|
||||||
|
|
||||||
if (logger.isTraceEnabled()) {
|
if (logger.isTraceEnabled()) {
|
||||||
logger.trace("BLE RX: {}", printHex(inputBuffer, inputLength));
|
|
||||||
logger.trace("BLE RX: {}", responsePacket);
|
logger.trace("BLE RX: {}", responsePacket);
|
||||||
}
|
}
|
||||||
if (responsePacket != null) {
|
if (responsePacket != null) {
|
||||||
@ -298,7 +306,7 @@ public class BlueGigaSerialHandler {
|
|||||||
exceptionCnt = 0;
|
exceptionCnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (final IOException e) {
|
} catch (IOException e) {
|
||||||
logger.debug("BlueGiga BLE IOException: ", e);
|
logger.debug("BlueGiga BLE IOException: ", e);
|
||||||
|
|
||||||
if (exceptionCnt++ > 10) {
|
if (exceptionCnt++ > 10) {
|
||||||
@ -306,6 +314,10 @@ public class BlueGigaSerialHandler {
|
|||||||
close = true;
|
close = true;
|
||||||
notifyEventListeners(e);
|
notifyEventListeners(e);
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.debug("BlueGiga BLE Exception, closing handler", e);
|
||||||
|
close = true;
|
||||||
|
notifyEventListeners(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.debug("BlueGiga BLE exited.");
|
logger.debug("BlueGiga BLE exited.");
|
||||||
|
Loading…
Reference in New Issue
Block a user