Skip to content

Commit

Permalink
Revert "[caddx] Add new channels and support for ignoring zone status…
Browse files Browse the repository at this point in the history
… transitions (openhab#10923)"

This reverts commit c13366f.

Signed-off-by: dw-8 <[email protected]>
  • Loading branch information
dw-8 committed Jul 25, 2021
1 parent c26966e commit 3f80d75
Show file tree
Hide file tree
Showing 20 changed files with 153 additions and 434 deletions.
3 changes: 0 additions & 3 deletions bundles/org.openhab.binding.caddx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ Caddx Alarm things support a variety of channels as seen below in the following
| panel_primary_keypad_function_without_pin | Switch | Configuration | Primary Keypad Function without PIN |
| panel_secondary_keypad_function | Switch | Configuration | Secondary Keypad Function |
| panel_zone_bypass_toggle | Switch | Configuration | Zone Bypass Toggle |
| panel_ac_fail | Switch | Configuration | AC fail |
| panel_ac_power_on | Switch | Configuration | AC Power on |
| panel_low_battery_memory | Switch | Configuration | Low Battery Memory |
| partition_bypass_code_required | Switch | Partition Condition | Bypass code required |
| partition_fire_trouble | Switch | Partition Condition | Fire trouble |
| partition_fire | Switch | Partition Condition | Fire |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,17 @@ public void stop() {

@SuppressWarnings("null")
private void messageDispatchLoop() {
int[] expectedMessageNumbers = null;
int @Nullable [] expectedMessageNumbers = null;

@Nullable
CaddxMessage outgoingMessage = null;
boolean skipTransmit = true;
CaddxMessageContext context = null;

try {
// loop until the thread is interrupted, sending out messages
while (!Thread.currentThread().isInterrupted()) {
// Initialize the state
outgoingMessage = null;
context = null;
expectedMessageNumbers = null;

if (!skipTransmit) {
Expand All @@ -203,7 +203,6 @@ private void messageDispatchLoop() {
out.flush();

expectedMessageNumbers = outgoingMessage.getReplyMessageNumbers();
context = outgoingMessage.getContext();

// Log message
if (logger.isDebugEnabled()) {
Expand Down Expand Up @@ -249,12 +248,10 @@ private void messageDispatchLoop() {
if (incomingMessage.hasAcknowledgementFlag()) {
if (incomingMessage.isChecksumCorrect()) {
// send ACK
transmitFirst(new CaddxMessage(CaddxMessageContext.NONE,
CaddxMessageType.POSITIVE_ACKNOWLEDGE, ""));
transmitFirst(new CaddxMessage(CaddxMessageType.POSITIVE_ACKNOWLEDGE, ""));
} else {
// Send NAK
transmitFirst(new CaddxMessage(CaddxMessageContext.NONE,
CaddxMessageType.NEGATIVE_ACKNOWLEDGE, ""));
transmitFirst(new CaddxMessage(CaddxMessageType.NEGATIVE_ACKNOWLEDGE, ""));
}
}
}
Expand Down Expand Up @@ -292,10 +289,7 @@ private void messageDispatchLoop() {
if (incomingMessage != null) {
if (incomingMessage.isChecksumCorrect()) {
for (CaddxPanelListener listener : listenerQueue) {
if (context != null) {
incomingMessage.setContext(context);
}
listener.caddxMessage(incomingMessage);
listener.caddxMessage(this, incomingMessage);
}
} else {
logger.warn(
Expand Down Expand Up @@ -373,7 +367,7 @@ private void offerCaddxMessage() throws InterruptedException {
logger.trace("Offering received message");

// Full message received in data byte array
CaddxMessage caddxMessage = new CaddxMessage(CaddxMessageContext.NONE, message, true);
CaddxMessage caddxMessage = new CaddxMessage(message, true);
if (!exchanger.offer(caddxMessage, 3, TimeUnit.SECONDS)) {
logger.debug("Offered message was not received");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,4 @@ public CaddxMessage getCaddxMessage() {
public @Nullable Integer getKeypad() {
return keypad;
}

/**
* Returns a string representation of a CaddxEvent.
*
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();

sb.append(String.format("partition: %d, zone: %d, keypad: %d\r\n", partition, zone, keypad));
sb.append(caddxMessage.toString());

return sb.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ public class CaddxMessage {
private final byte checksum2In;
private final byte checksum1Calc;
private final byte checksum2Calc;
private CaddxMessageContext context;

public CaddxMessage(CaddxMessageContext context, byte[] message, boolean withChecksum) {
public CaddxMessage(byte[] message, boolean withChecksum) {
if (withChecksum && message.length < 3) {
logger.debug("CaddxMessage: The message should be at least 3 bytes long.");
throw new IllegalArgumentException("The message should be at least 3 bytes long");
Expand All @@ -53,7 +52,6 @@ public CaddxMessage(CaddxMessageContext context, byte[] message, boolean withChe
}

// Received data
this.context = context;
byte[] msg = message;

// Fill in the checksum
Expand Down Expand Up @@ -96,15 +94,14 @@ public CaddxMessage(CaddxMessageContext context, byte[] message, boolean withChe
processCaddxMessage();
}

public CaddxMessage(CaddxMessageContext context, CaddxMessageType type, String data) {
public CaddxMessage(CaddxMessageType type, String data) {
int length = type.length;
String[] tokens = data.split("\\,");
if (length != 1 && tokens.length != length - 1) {
logger.debug("token.length should be length-1. token.length={}, length={}", tokens.length, length);
throw new IllegalArgumentException("CaddxMessage: data has not the correct format.");
}

this.context = context;
byte[] msg = new byte[length];
msg[0] = (byte) type.number;
for (int i = 0; i < length - 1; i++) {
Expand Down Expand Up @@ -136,14 +133,6 @@ public CaddxMessage(CaddxMessageContext context, CaddxMessageType type, String d
processCaddxMessage();
}

public CaddxMessageContext getContext() {
return context;
}

public void setContext(CaddxMessageContext context) {
this.context = context;
}

public byte getChecksum1In() {
return checksum1In;
}
Expand Down Expand Up @@ -270,9 +259,6 @@ public String toString() {
return "Unknown message type";
}

sb.append(String.format("Context: %s", context.toString()));
sb.append(System.lineSeparator());

sb.append("Message: ");
sb.append(String.format("%2s", Integer.toHexString(message[0])));
sb.append(" ");
Expand Down

This file was deleted.

Loading

0 comments on commit 3f80d75

Please sign in to comment.