You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.4 KiB
64 lines
1.4 KiB
6 years ago
|
package Sense4;
|
||
|
|
||
|
/**
|
||
|
* @author Lanlan
|
||
|
* @date 2018/11/25
|
||
|
*/
|
||
|
public class Elite4 {
|
||
|
|
||
|
public static byte[] readElite4Serial() {
|
||
|
EliteLockIO eliteLockIO = LockUtils.getEliteLockIOInstance();
|
||
|
eliteLockIO.initS4(false);
|
||
|
byte[] serial = eliteLockIO.readEliteSerial();
|
||
|
eliteLockIO.closeS4();
|
||
|
|
||
|
return serial;
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
* Write byte[] to elite4
|
||
|
*/
|
||
|
public static boolean writeBytes2ToElite4(byte[] bytes) {
|
||
|
EliteLockIO eliteLockIO = LockUtils.getEliteLockIOInstance();
|
||
|
eliteLockIO.initS4(true);
|
||
|
|
||
|
byte[] write_len_bytes = LockUtils.intToByteArray1(bytes.length + 4);
|
||
|
if (!eliteLockIO.write_internal_file(0, 4, write_len_bytes)) {
|
||
|
eliteLockIO.closeS4();
|
||
|
return false;
|
||
|
}
|
||
|
if (!eliteLockIO.write_internal_file(4, bytes.length, bytes)) {
|
||
|
eliteLockIO.closeS4();
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
eliteLockIO.closeS4();
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
* Read byte[] from elite4
|
||
|
*/
|
||
|
public static byte[] readBytesFromElitee4() {
|
||
|
EliteLockIO eliteLockIO = LockUtils.getEliteLockIOInstance();
|
||
|
eliteLockIO.initS4(true);
|
||
|
|
||
|
byte[] len_out = eliteLockIO.read_internal_file(0, 4);
|
||
|
int read_len = LockUtils.byteArray2Int(len_out) - 4;
|
||
|
|
||
|
if (read_len < 0) {
|
||
|
eliteLockIO.closeS4();
|
||
|
return new byte[0];
|
||
|
}
|
||
|
|
||
|
byte read_bytes[] = eliteLockIO.read_internal_file(4, read_len);
|
||
|
eliteLockIO.closeS4();
|
||
|
|
||
|
return read_bytes;
|
||
|
}
|
||
|
|
||
|
public static String toHexString(byte[] b) {
|
||
|
return LockUtils.toHexString(b);
|
||
|
}
|
||
|
}
|