Fixed Hello packet scanning.
This commit is contained in:
parent
010361066e
commit
72b9eaa61d
2 changed files with 21 additions and 3 deletions
|
@ -370,7 +370,16 @@ fun parseKTagPacket(data: ByteArray): KTagPacket {
|
|||
0x04 -> ConsolePacket(
|
||||
type = type,
|
||||
eventNumber = eventNumber,
|
||||
consoleString = data.slice(6..26).toByteArray().toString(Charsets.US_ASCII).trim(0.toChar())
|
||||
consoleString = data.slice(6..26).toByteArray().let { bytes ->
|
||||
// Find the position of the first null byte if any
|
||||
val nullPos = bytes.indexOfFirst { it == 0.toByte() }
|
||||
// If there's a null byte, take only up to that position, otherwise take all bytes
|
||||
if (nullPos >= 0) {
|
||||
bytes.slice(0 until nullPos).toByteArray()
|
||||
} else {
|
||||
bytes
|
||||
}.toString(Charsets.US_ASCII).trim()
|
||||
}
|
||||
)
|
||||
|
||||
0x05 -> StatusPacket(
|
||||
|
@ -405,7 +414,16 @@ fun parseKTagPacket(data: ByteArray): KTagPacket {
|
|||
minorVersion = data[7].toInt(),
|
||||
deviceType = bytesToInt(data, 8, 2),
|
||||
teamId = data[10].toInt(),
|
||||
deviceName = data.slice(11..26).toByteArray().toString(Charsets.US_ASCII).trim(0.toChar())
|
||||
deviceName = data.slice(11..26).toByteArray().let { bytes ->
|
||||
// Find the position of the first null byte if any
|
||||
val nullPos = bytes.indexOfFirst { it == 0.toByte() }
|
||||
// If there's a null byte, take only up to that position, otherwise take all bytes
|
||||
if (nullPos >= 0) {
|
||||
bytes.slice(0 until nullPos).toByteArray()
|
||||
} else {
|
||||
bytes
|
||||
}.toString(Charsets.US_ASCII).trim()
|
||||
}
|
||||
)
|
||||
|
||||
else -> StatusPacket(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[versions]
|
||||
agp = "8.8.1"
|
||||
agp = "8.8.2"
|
||||
kotlin = "2.0.0"
|
||||
coreKtx = "1.15.0"
|
||||
junit = "4.13.2"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue