For _Secure tunneling_ with a Secure IP Interface (or a router in tunneling mode), more parameters are required.
A unique device authentication key, and a specific tunnel identifier and password need to be available.
-- All information can be looked up in ETS and provided separately: `tunnelDeviceAuthentication`, `tunnelUserPassword`.
-`tunnelUserId` is a number which is not directly visible in ETS, but can be looked up in keyring export or deduced (typically 2 for the first tunnel of a device, 3 for the second one, ...).
-`tunnelUserPasswort` is set in ETS in the properties of the tunnel (below the IP interface you will see the different tunnels listed) denoted as "Password". `tunnelDeviceAuthentication` is set in the properties of the IP interface itself, check for a tab "IP" and a description "Authentication Code".
+- All information can be looked up in ETS and provided separately: `tunnelDeviceAuthentication`, `tunnelUserPassword`. `tunnelUserId` is a number which is not directly visible in ETS, but can be looked up in keyring export or deduced (typically 2 for the first tunnel of a device, 3 for the second one, ...). `tunnelUserPasswort` is set in ETS in the properties of the tunnel (below the IP interface you will see the different tunnels listed) denoted as "Password". `tunnelDeviceAuthentication` is set in the properties of the IP interface itself, check for a tab "IP" and a description "Authentication Code".
### KNX Data Secure
*/
package org.openhab.binding.knx.internal.channel;
+import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.knx.internal.client.OutboundSpec;
import org.openhab.core.types.Type;
* @author Simon Kaufmann - initial contribution and API.
*
*/
+@NonNullByDefault
public class WriteSpecImpl extends AbstractSpec implements OutboundSpec {
private final Type type;
*/
package org.openhab.binding.knx.internal.client;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+
import tuwien.auto.calimero.datapoint.Datapoint;
/**
*
* @author Karel Goderis - Initial contribution
*/
+@NonNullByDefault
public class ReadDatapoint {
private final Datapoint datapoint;
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (getClass() != obj.getClass()) {
return false;
}
+ @Nullable
ReadDatapoint other = (ReadDatapoint) obj;
- if (datapoint == null) {
- if (other.datapoint != null) {
- return false;
- }
- } else if (!datapoint.getMainAddress().equals(other.datapoint.getMainAddress())) {
- return false;
- }
- return true;
+ return datapoint.getMainAddress().equals(other.datapoint.getMainAddress());
}
}
import java.util.Locale;
import java.util.Map;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.knx.internal.KNXTypeMapper;
import org.openhab.core.library.types.DateTimeType;
import org.openhab.core.library.types.DecimalType;
* If for a 'MainType' there is currently no specific mapping registered,
* you can find a commented example line, with it's correct 'DPTXlator' class.
*
- * @author Kai Kreuzer
- * @author Volker Daube
- * @author Jan N. Klug
+ * @author Kai Kreuzer - initial contribution
+ * @author Volker Daube - improvements
+ * @author Jan N. Klug - improvements
* @author Helmut Lehmeyer - Java8, generic DPT Mapper
*/
+@NonNullByDefault
@Component
public class KNXCoreTypeMapper implements KNXTypeMapper {
}
@Override
- public String toDPTValue(Type type, String dptID) {
+ public @Nullable String toDPTValue(Type type, @Nullable String dptID) {
DPT dpt;
int mainNumber = getMainNumber(dptID);
if (mainNumber == -1) {
}
@Override
- public Type toType(Datapoint datapoint, byte[] data) {
+ public @Nullable Type toType(Datapoint datapoint, byte[] data) {
try {
DPTXlator translator = TranslatorTypes.createTranslator(datapoint.getMainNumber(), datapoint.getDPT());
translator.setData(data);
if (typeClass.equals(DateTimeType.class)) {
String date = formatDateTime(value, datapoint.getDPT());
- if ((date == null) || (date.isEmpty())) {
+ if (date.isEmpty()) {
logger.debug("toType: KNX clock msg ignored: date object null or empty {}.", date);
return null;
} else {
* @return the openHAB type (command or state) class or {@code null} if the datapoint type id is not supported.
*/
@Override
- public Class<? extends Type> toTypeClass(String dptId) {
+ public @Nullable Class<? extends Type> toTypeClass(@Nullable String dptId) {
+ @Nullable
Class<? extends Type> ohClass = dptTypeMap.get(dptId);
if (ohClass == null) {
int mainNumber = getMainNumber(dptId);
* @param typeClass the openHAB type class
* @return the datapoint type id
*/
- public String toDPTid(Class<? extends Type> typeClass) {
+ public @Nullable String toDPTid(Class<? extends Type> typeClass) {
return defaultDptMap.get(typeClass);
}
* @throws IllegalArgumentException if none of the datapoint types DPT_DATE or
* DPT_TIMEOFDAY has been used.
*/
- private static String formatDateTime(DateTimeType dateType, String dpt) {
+ private static String formatDateTime(DateTimeType dateType, @Nullable String dpt) {
if (DPTXlatorDate.DPT_DATE.getID().equals(dpt)) {
return dateType.format("%tF");
} else if (DPTXlatorTime.DPT_TIMEOFDAY.getID().equals(dpt)) {
* @param dptID String with DPT ID
* @return sub number or -1
*/
- private int getSubNumber(String dptID) {
+ private int getSubNumber(@Nullable String dptID) {
int result = -1;
if (dptID == null) {
throw new IllegalArgumentException("Parameter dptID cannot be null");
* @param dptID String with DPT ID
* @return main number or -1
*/
- private int getMainNumber(String dptID) {
+ private int getMainNumber(@Nullable String dptID) {
int result = -1;
if (dptID == null) {
throw new IllegalArgumentException("Parameter dptID cannot be null");
import java.util.Arrays;
import java.util.Collection;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.knx.internal.handler.DeviceThingHandler;
import org.openhab.binding.knx.internal.handler.IPBridgeThingHandler;
import org.openhab.binding.knx.internal.handler.SerialBridgeThingHandler;
*
* @author Simon Kaufmann - Initial contribution and API
*/
+@NonNullByDefault
@Component(service = ThingHandlerFactory.class, configurationPid = "binding.knx")
public class KNXHandlerFactory extends BaseThingHandlerFactory {
public static final Collection<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Arrays.asList(THING_TYPE_DEVICE,
THING_TYPE_IP_BRIDGE, THING_TYPE_SERIAL_BRIDGE);
+ @Nullable
private NetworkAddressService networkAddressService;
@Activate
}
@Override
- public Thing createThing(ThingTypeUID thingTypeUID, Configuration configuration, ThingUID thingUID,
- ThingUID bridgeUID) {
+ public @Nullable Thing createThing(ThingTypeUID thingTypeUID, Configuration configuration,
+ @Nullable ThingUID thingUID, @Nullable ThingUID bridgeUID) {
if (THING_TYPE_IP_BRIDGE.equals(thingTypeUID)) {
ThingUID ipBridgeUID = getIPBridgeThingUID(thingTypeUID, thingUID, configuration);
return super.createThing(thingTypeUID, configuration, ipBridgeUID, null);
}
@Override
- protected ThingHandler createHandler(Thing thing) {
+ protected @Nullable ThingHandler createHandler(Thing thing) {
if (thing.getThingTypeUID().equals(THING_TYPE_IP_BRIDGE)) {
return new IPBridgeThingHandler((Bridge) thing, networkAddressService);
} else if (thing.getThingTypeUID().equals(THING_TYPE_SERIAL_BRIDGE)) {
return null;
}
- private ThingUID getIPBridgeThingUID(ThingTypeUID thingTypeUID, ThingUID thingUID, Configuration configuration) {
+ private ThingUID getIPBridgeThingUID(ThingTypeUID thingTypeUID, @Nullable ThingUID thingUID,
+ Configuration configuration) {
if (thingUID != null) {
return thingUID;
}
return new ThingUID(thingTypeUID, ipAddress);
}
- private ThingUID getSerialBridgeThingUID(ThingTypeUID thingTypeUID, ThingUID thingUID,
+ private ThingUID getSerialBridgeThingUID(ThingTypeUID thingTypeUID, @Nullable ThingUID thingUID,
Configuration configuration) {
if (thingUID != null) {
return thingUID;
private final Logger logger = LoggerFactory.getLogger(IPBridgeThingHandler.class);
private @Nullable IPClient client = null;
- private final NetworkAddressService networkAddressService;
+ private @Nullable final NetworkAddressService networkAddressService;
- public IPBridgeThingHandler(Bridge bridge, NetworkAddressService networkAddressService) {
+ public IPBridgeThingHandler(Bridge bridge, @Nullable NetworkAddressService networkAddressService) {
super(bridge);
this.networkAddressService = networkAddressService;
}
if (!config.getLocalIp().isEmpty()) {
localEndPoint = new InetSocketAddress(config.getLocalIp(), 0);
} else {
+ if (networkAddressService == null) {
+ logger.debug("NetworkAddressService not available, cannot create bridge {}", thing.getUID());
+ updateStatus(ThingStatus.OFFLINE);
+ return;
+ }
localEndPoint = new InetSocketAddress(networkAddressService.getPrimaryIpv4HostAddress(), 0);
}