@NonNullByDefault
public class BluetoothUtils {
- public static final Logger logger = LoggerFactory.getLogger(BluetoothUtils.class);
+ public static final Logger LOGGER = LoggerFactory.getLogger(BluetoothUtils.class);
public static final int FORMAT_UINT8 = 0x11;
public static final int FORMAT_UINT16 = 0x12;
*/
public static int[] toIntArray(byte[] value) {
int[] ret = new int[value.length];
- for (int i = 0; i < value.length; i++) {
- ret[i] = value[i];
- }
+ System.arraycopy(value, 0, ret, 0, value.length);
return ret;
}
return unsignedToSigned(
unsignedBytesToInt(value[offset], value[offset + 1], value[offset + 2], value[offset + 3]), 32);
default:
- logger.error("Unknown format type {} - no int value can be provided for it.", formatType);
+ LOGGER.error("Unknown format type {} - no int value can be provided for it.", formatType);
}
return null;
case FORMAT_FLOAT:
return bytesToFloat(value[offset], value[offset + 1], value[offset + 2], value[offset + 3]);
default:
- logger.error("Unknown format type {} - no float value can be provided for it.", formatType);
+ LOGGER.error("Unknown format type {} - no float value can be provided for it.", formatType);
}
return null;
logger.debug("Discovered bluetooth device '{}': {}", device.getName(), device);
DiscoveryCache cache = discoveryCaches.computeIfAbsent(device.getAddress(), addr -> new DiscoveryCache());
- cache.handleDiscovery(device);
+ if (cache != null) {
+ cache.handleDiscovery(device);
+ }
}
private static ThingUID createThingUIDWithBridge(DiscoveryResult result, BluetoothAdapter adapter) {