Skip to content

Commit

Permalink
Don't overwrite the modified Flipper page
Browse files Browse the repository at this point in the history
  • Loading branch information
AbandonedCart committed May 9, 2024
1 parent ce887ae commit cdc00b0
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions app/src/main/java/com/hiddenramblings/tagmo/nfctech/Flipper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,24 @@ object Flipper {
.append(Debug.separator).append("Tearing 2: 00")
.append(Debug.separator).append("Pages total: 135")
pages.forEachIndexed{ index, bytes ->
if (index == 133) {
pages[1]?.let { pages[0]?.copyOf(3)?.plus(it) }?.let { uid ->
"Page $index: ${byteArrayOf(
uid[1] xor uid[3] xor 0xAA.toByte(),
uid[2] xor uid[4] xor 0x55,
uid[3] xor uid[5] xor 0xAA.toByte(),
uid[4] xor uid[6] xor 0x55).toHex().hexFormat}"
when (index) {
133 -> {
pages[1]?.let { pages[0]?.copyOf(3)?.plus(it) }?.let { uid ->
"Page $index: ${byteArrayOf(
uid[1] xor uid[3] xor 0xAA.toByte(),
uid[2] xor uid[4] xor 0x55,
uid[3] xor uid[5] xor 0xAA.toByte(),
uid[4] xor uid[6] xor 0x55).toHex().hexFormat}"
}
}
134 -> {
"Page $index: ${byteArrayOf(0x80.toByte(), 0x80.toByte(), 0, 0).toHex().hexFormat}"
}
else -> {
bytes?.let {
contents.append(Debug.separator).append("Page $index: ${it.toHex().hexFormat}")
}
}
}
if (index == 134) {
"Page $index: ${byteArrayOf(0x80.toByte(), 0x80.toByte(), 0, 0).toHex().hexFormat}"
}
bytes?.let {
contents.append(Debug.separator).append("Page $index: ${it.toHex().hexFormat}")
}
}
val nfcFile = File(directory, "$filename.nfc")
Expand Down

0 comments on commit cdc00b0

Please sign in to comment.