|
@@ -31,16 +31,17 @@ class DeviceBean(var idx: Byte?, var type: Byte?, var status: ByteArray?) {
|
|
|
return status!![4] and 0x01.toByte() == 0x01.toByte() == leftHasKey
|
|
return status!![4] and 0x01.toByte() == 0x01.toByte() == leftHasKey
|
|
|
}
|
|
}
|
|
|
0x01.toByte() -> {
|
|
0x01.toByte() -> {
|
|
|
- // TODO 判断有问题
|
|
|
|
|
- val is1HasLock = byteArray[3] and 0x01.toByte() == 0x01.toByte()
|
|
|
|
|
- val is2HasLock = byteArray[3] and 0x02.toByte() == 0x01.toByte()
|
|
|
|
|
- val is3HasLock = byteArray[3] and 0x03.toByte() == 0x01.toByte()
|
|
|
|
|
- val is4HasLock = byteArray[3] and 0x04.toByte() == 0x01.toByte()
|
|
|
|
|
- val is5HasLock = byteArray[3] and 0x05.toByte() == 0x01.toByte()
|
|
|
|
|
- val is6HasLock = byteArray[3] and 0x06.toByte() == 0x01.toByte()
|
|
|
|
|
- val is7HasLock = byteArray[3] and 0x07.toByte() == 0x01.toByte()
|
|
|
|
|
- val is8HasLock = byteArray[4] and 0x01.toByte() == 0x01.toByte()
|
|
|
|
|
- val is9HasLock = byteArray[4] and 0x02.toByte() == 0x01.toByte()
|
|
|
|
|
|
|
+ val is1HasLock = (byteArray[4].toInt() shr 0) and 0x1 == 1
|
|
|
|
|
+ val is2HasLock = (byteArray[4].toInt() shr 1) and 0x1 == 1
|
|
|
|
|
+ val is3HasLock = (byteArray[4].toInt() shr 2) and 0x1 == 1
|
|
|
|
|
+ val is4HasLock = (byteArray[4].toInt() shr 3) and 0x1 == 1
|
|
|
|
|
+ val is5HasLock = (byteArray[4].toInt() shr 4) and 0x1 == 1
|
|
|
|
|
+ val is6HasLock = (byteArray[4].toInt() shr 5) and 0x1 == 1
|
|
|
|
|
+ val is7HasLock = (byteArray[4].toInt() shr 6) and 0x1 == 1
|
|
|
|
|
+ val is8HasLock = (byteArray[4].toInt() shr 7) and 0x1 == 1
|
|
|
|
|
+ // TODO 9号未验证
|
|
|
|
|
+ val is9HasLock = (byteArray[3].toInt() shr 0) and 0x1 == 1
|
|
|
|
|
+
|
|
|
LogUtil.i("锁具刷新状态 : $is1HasLock - $is2HasLock - $is3HasLock - $is4HasLock - $is5HasLock - $is6HasLock - $is7HasLock - $is8HasLock - $is9HasLock")
|
|
LogUtil.i("锁具刷新状态 : $is1HasLock - $is2HasLock - $is3HasLock - $is4HasLock - $is5HasLock - $is6HasLock - $is7HasLock - $is8HasLock - $is9HasLock")
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
@@ -52,4 +53,17 @@ class DeviceBean(var idx: Byte?, var type: Byte?, var status: ByteArray?) {
|
|
|
}
|
|
}
|
|
|
} ?: return false
|
|
} ?: return false
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ fun getBit(by: Byte): String {
|
|
|
|
|
+ val sb = StringBuffer()
|
|
|
|
|
+ sb.append((by.toInt() shr 7) and 0x1)
|
|
|
|
|
+ .append((by.toInt() shr 6) and 0x1)
|
|
|
|
|
+ .append((by.toInt() shr 5) and 0x1)
|
|
|
|
|
+ .append((by.toInt() shr 4) and 0x1)
|
|
|
|
|
+ .append((by.toInt() shr 3) and 0x1)
|
|
|
|
|
+ .append((by.toInt() shr 2) and 0x1)
|
|
|
|
|
+ .append((by.toInt() shr 1) and 0x1)
|
|
|
|
|
+ .append((by.toInt() shr 0) and 0x1)
|
|
|
|
|
+ return sb.toString()
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|