remove duplicated code

This commit is contained in:
Milos Kozak 2017-09-23 10:56:00 +02:00
parent 1eeb1c6f7a
commit 4ed2896f76
2 changed files with 2 additions and 14 deletions

View file

@ -137,18 +137,6 @@ public class DanaRS_Packet {
return sb.toString();
}
final private static char[] hexArray = "0123456789ABCDEF".toCharArray();
public static String bytesToHex(byte[] bytes) {
char[] hexChars = new char[bytes.length * 2];
for (int j = 0; j < bytes.length; j++) {
int v = bytes[j] & 0xFF;
hexChars[j * 2] = hexArray[v >>> 4];
hexChars[j * 2 + 1] = hexArray[v & 0x0F];
}
return new String(hexChars);
}
public static byte[] hexToBytes(String s) {
int len = s.length();
byte[] data = new byte[len / 2];

View file

@ -782,8 +782,8 @@ public class DanaRSService extends Service {
SendTimeInfo();
byte[] pairingKey = {inputBuffer[2], inputBuffer[3]};
// store pairing key to preferences
SP.putString(R.string.key_danars_pairingkey, DanaRS_Packet.bytesToHex(pairingKey));
log.debug("Got pairing key: " + DanaRS_Packet.bytesToHex(pairingKey));
SP.putString(R.string.key_danars_pairingkey, DanaRS_Packet.toHexString(pairingKey));
log.debug("Got pairing key: " + DanaRS_Packet.toHexString(pairingKey));
break;
// time and user password information. last packet in handshake
case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION: