[bluetooth.am43] null annotations (#13972)
* null annotations forbidden package * improve createChecksum * spotless + typo Signed-off-by: lsiepel <leosiepel@gmail.com>
This commit is contained in:
parent
8b1d0fccef
commit
1df693a6e9
@ -12,14 +12,17 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.binding.bluetooth.am43.internal;
|
package org.openhab.binding.bluetooth.am43.internal;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration class for AM43 Binding.
|
* Configuration class for AM43 Binding.
|
||||||
*
|
*
|
||||||
* @author Connor Petty - Initial contribution
|
* @author Connor Petty - Initial contribution
|
||||||
*/
|
*/
|
||||||
|
@NonNullByDefault
|
||||||
public class AM43Configuration {
|
public class AM43Configuration {
|
||||||
|
|
||||||
public String address;
|
public String address = "";
|
||||||
public int refreshInterval;
|
public int refreshInterval;
|
||||||
public boolean invertPosition;
|
public boolean invertPosition;
|
||||||
public int commandTimeout;
|
public int commandTimeout;
|
||||||
|
|||||||
@ -18,7 +18,6 @@ import java.util.concurrent.locks.Condition;
|
|||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
@ -121,19 +120,27 @@ public abstract class AM43Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getRequest() {
|
public byte[] getRequest() {
|
||||||
byte[] value = ArrayUtils.EMPTY_BYTE_ARRAY;
|
byte[] value = new byte[4 + data.length + REQUEST_PREFIX.length];
|
||||||
value = ArrayUtils.add(value, HEADER_PREFIX);
|
System.arraycopy(REQUEST_PREFIX, 0, value, 0, REQUEST_PREFIX.length);
|
||||||
value = ArrayUtils.add(value, header);
|
value[REQUEST_PREFIX.length] = HEADER_PREFIX;
|
||||||
value = ArrayUtils.add(value, (byte) data.length);
|
value[REQUEST_PREFIX.length + 1] = header;
|
||||||
value = ArrayUtils.addAll(value, data);
|
value[REQUEST_PREFIX.length + 2] = (byte) data.length;
|
||||||
value = ArrayUtils.add(value, createChecksum(value));
|
System.arraycopy(data, 0, value, REQUEST_PREFIX.length + 3, data.length);
|
||||||
return ArrayUtils.addAll(REQUEST_PREFIX, value);
|
value[value.length - 1] = createChecksum(value, REQUEST_PREFIX.length, 3 + data.length);
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected byte createChecksum(byte[] data) {
|
/**
|
||||||
// this is a basic checksum
|
* A basic method to calculate the checksum
|
||||||
byte crc = data[0];
|
*
|
||||||
for (int i = 1; i < data.length; i++) {
|
* @param data source for the checksum calculation
|
||||||
|
* @param startIndex the zero-based start index to include in the calculation
|
||||||
|
* @param length the length of the range to include in the calculation
|
||||||
|
* @return the CRC-checksum result in {@link byte}
|
||||||
|
*/
|
||||||
|
protected byte createChecksum(byte[] data, int startIndex, int length) {
|
||||||
|
byte crc = data[startIndex];
|
||||||
|
for (int i = startIndex + 1; i < startIndex + length; i++) {
|
||||||
crc ^= data[i];
|
crc ^= data[i];
|
||||||
}
|
}
|
||||||
return crc;
|
return crc;
|
||||||
|
|||||||
@ -12,12 +12,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.binding.bluetooth.am43.internal.data;
|
package org.openhab.binding.bluetooth.am43.internal.data;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link ControlAction} list possible controls actions that can be sent through
|
* The {@link ControlAction} list possible controls actions that can be sent through
|
||||||
* {@link org.openhab.binding.bluetooth.am43.internal.command.ControlCommand}
|
* {@link org.openhab.binding.bluetooth.am43.internal.command.ControlCommand}
|
||||||
*
|
*
|
||||||
* @author Connor Petty - Initial contribution
|
* @author Connor Petty - Initial contribution
|
||||||
*/
|
*/
|
||||||
|
@NonNullByDefault
|
||||||
public enum ControlAction {
|
public enum ControlAction {
|
||||||
CLOSE(0xee),
|
CLOSE(0xee),
|
||||||
OPEN(0xdd),
|
OPEN(0xdd),
|
||||||
|
|||||||
@ -12,11 +12,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.binding.bluetooth.am43.internal.data;
|
package org.openhab.binding.bluetooth.am43.internal.data;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is an enum representing possible motor direction settings
|
* This is an enum representing possible motor direction settings
|
||||||
*
|
*
|
||||||
* @author Connor Petty - Initial contribution
|
* @author Connor Petty - Initial contribution
|
||||||
*/
|
*/
|
||||||
|
@NonNullByDefault
|
||||||
public enum Direction {
|
public enum Direction {
|
||||||
Forward(0x1),
|
Forward(0x1),
|
||||||
Reverse(0x0);
|
Reverse(0x0);
|
||||||
|
|||||||
@ -12,11 +12,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.binding.bluetooth.am43.internal.data;
|
package org.openhab.binding.bluetooth.am43.internal.data;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is an enum representing possible motor modes settings
|
* This is an enum representing possible motor modes settings
|
||||||
*
|
*
|
||||||
* @author Connor Petty - Initial contribution
|
* @author Connor Petty - Initial contribution
|
||||||
*/
|
*/
|
||||||
|
@NonNullByDefault
|
||||||
public enum OperationMode {
|
public enum OperationMode {
|
||||||
Inching(0x1),
|
Inching(0x1),
|
||||||
Continuous(0x0);
|
Continuous(0x0);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user