}
@Override
- protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
+ protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, @Nullable String lastEvent,
Configuration config) {
switch (channelId) {
case CHANNEL_STATUS_REQUEST_EVENT:
}
@Override
- protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
+ protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, @Nullable String lastEvent,
Configuration config) {
switch (channelId) {
case CHANNEL_PUSHBUTTON:
* battery channels may be not supported by the physical device (depending on the actual model). If a channel is not
* supported by a device it will transmit a 'not supported' message which is ignored by this implementation.
* Consequently channels that are not supported by the physical device will never send updates to linked items.
- *
+ *
* @author Thomas Lauterbach - Initial contribution
*/
@NonNullByDefault
}
protected State getTemperature() {
- double unscaledTemp = (double) (bytes[5] & 0xFF);
+ double unscaledTemp = bytes[5] & 0xFF;
if (unscaledTemp <= 250) {
double scaledTemp = unscaledTemp * 0.32 - 20;
return new QuantityType<>(scaledTemp, SIUnits.CELSIUS);
}
@Override
- protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
+ protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, @Nullable String lastEvent,
Configuration config) {
// Sensor values
if (bytes[0] == MessageType.SENSORVALUES.getIntValue()) {
}
@Override
- protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
+ protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, @Nullable String lastEvent,
Configuration config) {
// Alarm
if (bytes[0] == 0x02) {
return convertToStateImpl(channelId, channelTypeId, getCurrentStateFunc, config);
}
- public @Nullable String convertToEvent(String channelId, String channelTypeId, String lastEvent,
+ public @Nullable String convertToEvent(String channelId, String channelTypeId, @Nullable String lastEvent,
Configuration config) {
if (!getEEPType().isChannelSupported(channelId, channelTypeId)) {
throw new IllegalArgumentException(
return UnDefType.UNDEF;
}
- protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
+ protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, @Nullable String lastEvent,
Configuration config) {
return null;
}
}
@Override
- protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
+ protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, @Nullable String lastEvent,
Configuration config) {
return getBit(bytes[0], 4) ? CommonTriggerEvents.PRESSED : CommonTriggerEvents.RELEASED;
}
}
@Override
- protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
+ protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, @Nullable String lastEvent,
Configuration config) {
if (t21 && nu) {
if (CHANNEL_ROCKERSWITCH_ACTION.equals(channelTypeId)) {
} else if (t21 && !nu) {
if (CHANNEL_ROCKERSWITCH_ACTION.equals(channelTypeId)) {
return CommonTriggerEvents.RELEASED;
- } else {
+ } else if (lastEvent != null) {
if (lastEvent.equals(CommonTriggerEvents.DIR1_PRESSED)) {
return CommonTriggerEvents.DIR1_RELEASED;
} else if (lastEvent.equals(CommonTriggerEvents.DIR2_PRESSED)) {
}
@Override
- protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, String lastEvent,
+ protected @Nullable String convertToEventImpl(String channelId, String channelTypeId, @Nullable String lastEvent,
Configuration config) {
if (t21 && nu) {
if (CHANNEL_ROCKERSWITCH_ACTION.equals(channelTypeId)) {
} else if (t21 && !nu) {
if (CHANNEL_ROCKERSWITCH_ACTION.equals(channelTypeId)) {
return CommonTriggerEvents.RELEASED;
- } else {
+ } else if (lastEvent != null) {
if (lastEvent.equals(CommonTriggerEvents.DIR1_PRESSED)) {
return CommonTriggerEvents.DIR1_RELEASED;
} else if (lastEvent.equals(CommonTriggerEvents.DIR2_PRESSED)) {
break;
case TRIGGER:
String lastEvent = lastEvents.get(channelId);
- if (lastEvent != null) {
- String event = eep.convertToEvent(channelId, channelTypeId, lastEvent,
- channelConfig);
- if (event != null) {
- triggerChannel(channel.getUID(), event);
- lastEvents.put(channelId, event);
- }
+ String event = eep.convertToEvent(channelId, channelTypeId, lastEvent, channelConfig);
+ if (event != null) {
+ triggerChannel(channel.getUID(), event);
+ lastEvents.put(channelId, event);
}
break;
}
}
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_PENDING, "opening serial port...");
- localTransceiver.initilize();
+ localTransceiver.initialize();
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_PENDING, "starting rx thread...");
localTransceiver.startReceiving(scheduler);
+++ /dev/null
-/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.enocean.internal.messages.responses;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.openhab.binding.enocean.internal.Helper;
-import org.openhab.binding.enocean.internal.messages.Response;
-
-/**
- *
- * @author Daniel Weber - Initial contribution
- */
-@NonNullByDefault
-public class BaseResponse extends Response {
-
- public BaseResponse(Response response) {
- super(response.getPayload().length + response.getOptionalPayload().length, 0,
- Helper.concatAll(response.getPayload(), response.getOptionalPayload()));
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.enocean.internal.messages.responses;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.openhab.binding.enocean.internal.Helper;
-import org.openhab.binding.enocean.internal.messages.Response;
-
-/**
- *
- * @author Daniel Weber - Initial contribution
- */
-@NonNullByDefault
-public class RDBaseIdResponse extends Response {
-
- private byte[] baseId = new byte[0];
- private int remainingWriteCycles = 0;
-
- public RDBaseIdResponse(Response response) {
- this(response.getPayload().length, response.getOptionalPayload().length,
- Helper.concatAll(response.getPayload(), response.getOptionalPayload()));
- }
-
- RDBaseIdResponse(int dataLength, int optionalDataLength, byte[] payload) {
- super(dataLength, optionalDataLength, payload);
-
- if (this.data.length != 5 || this.optionalData.length != 1) {
- return;
- }
-
- baseId = getPayload(1, 4);
- remainingWriteCycles = optionalData[0] & 0xFF;
-
- isValid = true;
- }
-
- public final byte[] getBaseId() {
- return baseId;
- }
-
- public int getRemainingWriteCycles() {
- return remainingWriteCycles;
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.enocean.internal.messages.responses;
-
-import java.util.Arrays;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.openhab.binding.enocean.internal.Helper;
-import org.openhab.binding.enocean.internal.messages.Response;
-
-/**
- *
- * @author Daniel Weber - Initial contribution
- */
-@NonNullByDefault
-public class RDLearnedClientsResponse extends Response {
-
- public class LearnedClient {
- public byte[] clientId = new byte[0];
- public byte[] controllerId = new byte[0];
- public int mailboxIndex;
- }
-
- LearnedClient[] learnedClients = new LearnedClient[0];
-
- public RDLearnedClientsResponse(Response response) {
- this(response.getPayload().length, response.getOptionalPayload().length,
- Helper.concatAll(response.getPayload(), response.getOptionalPayload()));
- }
-
- RDLearnedClientsResponse(int dataLength, int optionalDataLength, byte[] payload) {
- super(dataLength, optionalDataLength, payload);
-
- if (payload.length == 0 || (payload.length - 1) % 9 != 0) {
- return;
- } else {
- isValid = true;
- }
-
- learnedClients = new LearnedClient[(payload.length - 1) / 9];
- for (int i = 0; i < learnedClients.length; i++) {
- LearnedClient client = new LearnedClient();
- client.clientId = Arrays.copyOfRange(payload, 1 + i * 9, 1 + i * 9 + 4);
- client.controllerId = Arrays.copyOfRange(payload, 5 + i * 9, 5 + i * 9 + 4);
- client.mailboxIndex = payload[9 + i * 9] & 0xFF;
- learnedClients[i] = client;
- }
- }
-
- public LearnedClient[] getLearnedClients() {
- return learnedClients;
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.enocean.internal.messages.responses;
-
-import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.openhab.binding.enocean.internal.messages.Response;
-import org.openhab.core.library.types.StringType;
-
-/**
- *
- * @author Daniel Weber - Initial contribution
- */
-@NonNullByDefault
-public class RDRepeaterResponse extends Response {
-
- protected String repeaterLevel = "";
-
- public RDRepeaterResponse(Response response) {
- this(response.getPayload().length, 0, response.getPayload());
- }
-
- RDRepeaterResponse(int dataLength, int optionalDataLength, byte[] payload) {
- super(dataLength, optionalDataLength, payload);
-
- if (payload.length < 3) {
- return;
- }
-
- if (payload[1] == 0) {
- repeaterLevel = REPEATERMODE_OFF;
- } else if (payload[1] == 1 || payload[1] == 2) {
- switch (payload[2]) {
- case 1:
- repeaterLevel = REPEATERMODE_LEVEL_1;
- break;
- case 2:
- repeaterLevel = REPEATERMODE_LEVEL_2;
- break;
- case 0:
- repeaterLevel = REPEATERMODE_OFF;
- break;
- default:
- return;
- }
-
- isValid = true;
- }
- }
-
- public StringType getRepeaterLevel() {
- return StringType.valueOf(repeaterLevel);
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.enocean.internal.messages.responses;
-
-import java.util.Arrays;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.openhab.binding.enocean.internal.messages.Response;
-import org.openhab.core.util.HexUtils;
-
-/**
- *
- * @author Daniel Weber - Initial contribution
- */
-@NonNullByDefault
-public class RDVersionResponse extends Response {
-
- protected String appVersion = "";
- protected String apiVersion = "";
- protected String chipId = "";
- protected String description = "";
-
- public RDVersionResponse(Response response) {
- this(response.getPayload().length, 0, response.getPayload());
- }
-
- RDVersionResponse(int dataLength, int optionalDataLength, byte[] payload) {
- super(dataLength, optionalDataLength, payload);
-
- if (payload.length < 33) {
- return;
- }
-
- try {
- appVersion = String.format("%d.%d.%d.%d", payload[1] & 0xff, payload[2] & 0xff, payload[3] & 0xff,
- payload[4] & 0xff);
- apiVersion = String.format("%d.%d.%d.%d", payload[5] & 0xff, payload[6] & 0xff, payload[7] & 0xff,
- payload[8] & 0xff);
-
- chipId = HexUtils.bytesToHex(Arrays.copyOfRange(payload, 9, 13));
-
- StringBuffer sb = new StringBuffer();
- for (int i = 17; i < payload.length; i++) {
- sb.append((char) (payload[i] & 0xff));
- }
- description = sb.toString();
- isValid = true;
-
- } catch (Exception e) {
- responseType = ResponseType.RET_ERROR;
- }
- }
-
- public String getAPPVersion() {
- return appVersion;
- }
-
- public String getAPIVersion() {
- return apiVersion;
- }
-
- public String getChipID() {
- return chipId;
- }
-
- public String getDescription() {
- return description;
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2010-2023 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.enocean.internal.messages.responses;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.openhab.binding.enocean.internal.messages.Response;
-
-/**
- *
- * @author Daniel Weber - Initial contribution
- */
-@NonNullByDefault
-public class SMACKTeachInResponse extends Response {
-
- // set response time to 250ms
- static final byte RESPONSE_TIME_HVALUE = 0;
- static final byte RESPONSE_TIME_LVALUE = (byte) 0xFA;
-
- static final byte TEACH_IN = 0x00;
- static final byte TEACH_OUT = 0x20;
- static final byte REPEATED_TEACH_IN = 0x01;
- static final byte NOPLACE_FOR_MAILBOX = 0x12;
- static final byte BAD_RSSI = 0x14;
-
- public SMACKTeachInResponse() {
- super(4, 0, new byte[] { Response.ResponseType.RET_OK.getValue(), RESPONSE_TIME_HVALUE, RESPONSE_TIME_LVALUE,
- TEACH_IN });
- }
-
- public void setTeachOutResponse() {
- data[3] = TEACH_OUT;
- }
-
- public boolean isTeachOut() {
- return data[3] == TEACH_OUT;
- }
-
- public void setRepeatedTeachInResponse() {
- data[3] = REPEATED_TEACH_IN;
- }
-
- public void setNoPlaceForFurtherMailbox() {
- data[3] = NOPLACE_FOR_MAILBOX;
- }
-
- public void setBadRSSI() {
- data[3] = BAD_RSSI;
- }
-
- public void setTeachIn() {
- data[3] = TEACH_IN;
- }
-
- public boolean isTeachIn() {
- return data[3] == TEACH_IN;
- }
-}
--- /dev/null
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.enocean.internal.messages.responses;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.binding.enocean.internal.Helper;
+import org.openhab.binding.enocean.internal.messages.Response;
+
+/**
+ *
+ * @author Daniel Weber - Initial contribution
+ */
+@NonNullByDefault
+public class BaseResponse extends Response {
+
+ public BaseResponse(Response response) {
+ super(response.getPayload().length + response.getOptionalPayload().length, 0,
+ Helper.concatAll(response.getPayload(), response.getOptionalPayload()));
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.enocean.internal.messages.responses;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.binding.enocean.internal.Helper;
+import org.openhab.binding.enocean.internal.messages.Response;
+
+/**
+ *
+ * @author Daniel Weber - Initial contribution
+ */
+@NonNullByDefault
+public class RDBaseIdResponse extends Response {
+
+ private byte[] baseId = new byte[0];
+ private int remainingWriteCycles = 0;
+
+ public RDBaseIdResponse(Response response) {
+ this(response.getPayload().length, response.getOptionalPayload().length,
+ Helper.concatAll(response.getPayload(), response.getOptionalPayload()));
+ }
+
+ RDBaseIdResponse(int dataLength, int optionalDataLength, byte[] payload) {
+ super(dataLength, optionalDataLength, payload);
+
+ if (this.data.length != 5 || this.optionalData.length != 1) {
+ return;
+ }
+
+ baseId = getPayload(1, 4);
+ remainingWriteCycles = optionalData[0] & 0xFF;
+
+ isValid = true;
+ }
+
+ public final byte[] getBaseId() {
+ return baseId;
+ }
+
+ public int getRemainingWriteCycles() {
+ return remainingWriteCycles;
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.enocean.internal.messages.responses;
+
+import java.util.Arrays;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.binding.enocean.internal.Helper;
+import org.openhab.binding.enocean.internal.messages.Response;
+
+/**
+ *
+ * @author Daniel Weber - Initial contribution
+ */
+@NonNullByDefault
+public class RDLearnedClientsResponse extends Response {
+
+ public class LearnedClient {
+ public byte[] clientId = new byte[0];
+ public byte[] controllerId = new byte[0];
+ public int mailboxIndex;
+ }
+
+ LearnedClient[] learnedClients = new LearnedClient[0];
+
+ public RDLearnedClientsResponse(Response response) {
+ this(response.getPayload().length, response.getOptionalPayload().length,
+ Helper.concatAll(response.getPayload(), response.getOptionalPayload()));
+ }
+
+ RDLearnedClientsResponse(int dataLength, int optionalDataLength, byte[] payload) {
+ super(dataLength, optionalDataLength, payload);
+
+ if (payload.length == 0 || (payload.length - 1) % 9 != 0) {
+ return;
+ } else {
+ isValid = true;
+ }
+
+ learnedClients = new LearnedClient[(payload.length - 1) / 9];
+ for (int i = 0; i < learnedClients.length; i++) {
+ LearnedClient client = new LearnedClient();
+ client.clientId = Arrays.copyOfRange(payload, 1 + i * 9, 1 + i * 9 + 4);
+ client.controllerId = Arrays.copyOfRange(payload, 5 + i * 9, 5 + i * 9 + 4);
+ client.mailboxIndex = payload[9 + i * 9] & 0xFF;
+ learnedClients[i] = client;
+ }
+ }
+
+ public LearnedClient[] getLearnedClients() {
+ return learnedClients;
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.enocean.internal.messages.responses;
+
+import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.binding.enocean.internal.messages.Response;
+import org.openhab.core.library.types.StringType;
+
+/**
+ *
+ * @author Daniel Weber - Initial contribution
+ */
+@NonNullByDefault
+public class RDRepeaterResponse extends Response {
+
+ protected String repeaterLevel = "";
+
+ public RDRepeaterResponse(Response response) {
+ this(response.getPayload().length, 0, response.getPayload());
+ }
+
+ RDRepeaterResponse(int dataLength, int optionalDataLength, byte[] payload) {
+ super(dataLength, optionalDataLength, payload);
+
+ if (payload.length < 3) {
+ return;
+ }
+
+ if (payload[1] == 0) {
+ repeaterLevel = REPEATERMODE_OFF;
+ } else if (payload[1] == 1 || payload[1] == 2) {
+ switch (payload[2]) {
+ case 1:
+ repeaterLevel = REPEATERMODE_LEVEL_1;
+ break;
+ case 2:
+ repeaterLevel = REPEATERMODE_LEVEL_2;
+ break;
+ case 0:
+ repeaterLevel = REPEATERMODE_OFF;
+ break;
+ default:
+ return;
+ }
+
+ isValid = true;
+ }
+ }
+
+ public StringType getRepeaterLevel() {
+ return StringType.valueOf(repeaterLevel);
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.enocean.internal.messages.responses;
+
+import java.util.Arrays;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.binding.enocean.internal.messages.Response;
+import org.openhab.core.util.HexUtils;
+
+/**
+ *
+ * @author Daniel Weber - Initial contribution
+ */
+@NonNullByDefault
+public class RDVersionResponse extends Response {
+
+ protected String appVersion = "";
+ protected String apiVersion = "";
+ protected String chipId = "";
+ protected String description = "";
+
+ public RDVersionResponse(Response response) {
+ this(response.getPayload().length, 0, response.getPayload());
+ }
+
+ RDVersionResponse(int dataLength, int optionalDataLength, byte[] payload) {
+ super(dataLength, optionalDataLength, payload);
+
+ if (payload.length < 33) {
+ return;
+ }
+
+ try {
+ appVersion = String.format("%d.%d.%d.%d", payload[1] & 0xff, payload[2] & 0xff, payload[3] & 0xff,
+ payload[4] & 0xff);
+ apiVersion = String.format("%d.%d.%d.%d", payload[5] & 0xff, payload[6] & 0xff, payload[7] & 0xff,
+ payload[8] & 0xff);
+
+ chipId = HexUtils.bytesToHex(Arrays.copyOfRange(payload, 9, 13));
+
+ StringBuffer sb = new StringBuffer();
+ for (int i = 17; i < payload.length; i++) {
+ sb.append((char) (payload[i] & 0xff));
+ }
+ description = sb.toString();
+ isValid = true;
+
+ } catch (Exception e) {
+ responseType = ResponseType.RET_ERROR;
+ }
+ }
+
+ public String getAPPVersion() {
+ return appVersion;
+ }
+
+ public String getAPIVersion() {
+ return apiVersion;
+ }
+
+ public String getChipID() {
+ return chipId;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2010-2023 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.enocean.internal.messages.responses;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.binding.enocean.internal.messages.Response;
+
+/**
+ *
+ * @author Daniel Weber - Initial contribution
+ */
+@NonNullByDefault
+public class SMACKTeachInResponse extends Response {
+
+ // set response time to 250ms
+ static final byte RESPONSE_TIME_HVALUE = 0;
+ static final byte RESPONSE_TIME_LVALUE = (byte) 0xFA;
+
+ static final byte TEACH_IN = 0x00;
+ static final byte TEACH_OUT = 0x20;
+ static final byte REPEATED_TEACH_IN = 0x01;
+ static final byte NOPLACE_FOR_MAILBOX = 0x12;
+ static final byte BAD_RSSI = 0x14;
+
+ public SMACKTeachInResponse() {
+ super(4, 0, new byte[] { Response.ResponseType.RET_OK.getValue(), RESPONSE_TIME_HVALUE, RESPONSE_TIME_LVALUE,
+ TEACH_IN });
+ }
+
+ public void setTeachOutResponse() {
+ data[3] = TEACH_OUT;
+ }
+
+ public boolean isTeachOut() {
+ return data[3] == TEACH_OUT;
+ }
+
+ public void setRepeatedTeachInResponse() {
+ data[3] = REPEATED_TEACH_IN;
+ }
+
+ public void setNoPlaceForFurtherMailbox() {
+ data[3] = NOPLACE_FOR_MAILBOX;
+ }
+
+ public void setBadRSSI() {
+ data[3] = BAD_RSSI;
+ }
+
+ public void setTeachIn() {
+ data[3] = TEACH_IN;
+ }
+
+ public boolean isTeachIn() {
+ return data[3] == TEACH_IN;
+ }
+}
this.path = path;
}
- public void initilize()
+ public void initialize()
throws UnsupportedCommOperationException, PortInUseException, IOException, TooManyListenersException {
SerialPortManager localSerialPortManager = serialPortManager;
if (localSerialPortManager == null) {
@Nullable
Future<?> localReadingTask = readingTask;
if (localReadingTask == null || localReadingTask.isCancelled()) {
- localReadingTask = scheduler.submit(new Runnable() {
+ readingTask = scheduler.submit(new Runnable() {
@Override
public void run() {
receivePackets();
InputStream localInputStream = inputStream;
if (localInputStream != null) {
try {
- localInputStream.read(buffer, 0, length);
+ return localInputStream.read(buffer, 0, length);
} catch (IOException e) {
logger.debug("IOException occured while reading the input stream", e);
return 0;
}
+ } else {
+ logger.warn("Cannot read from null stream");
+ Future<?> localReadingTask = readingTask;
+ if (localReadingTask != null) {
+ localReadingTask.cancel(true);
+ readingTask = null;
+ }
+ TransceiverErrorListener localListener = errorListener;
+ if (localListener != null) {
+ localListener.errorOccured(new IOException("Cannot read from null stream"));
+ }
+ return 0;
}
- return 0;
}
protected void informListeners(BasePacket packet) {