fix: mls LED 명령 Big Endian 파라미터로 변경 (테스터 exe와 동일)
테스터 코드 분석 결과:
exe: mls? + [0x00, 0x05] (16비트 Big Endian) → LED 바뀜
앱: mls? + [0x05, 0x00] (16비트 Little Endian) → LED 안 바뀜
CRC16.buildCommandBE() 추가: 파라미터를 Big Endian으로 직렬화
sendLedMode(): buildCommandBE("mls", [state]) 사용
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -354,7 +354,7 @@ class BleManager private constructor(private val context: Context) {
|
||||
}
|
||||
|
||||
fun sendLedMode(state: Int) {
|
||||
sendRaw(CRC16.buildCommandASCII("mls", " $state"))
|
||||
sendRaw(CRC16.buildCommandBE("mls", intArrayOf(state)))
|
||||
}
|
||||
|
||||
fun sendImuQuery() {
|
||||
|
||||
@@ -54,6 +54,17 @@ object CRC16 {
|
||||
return appendCRC("$cmd?$asciiParams".toByteArray(Charsets.UTF_8))
|
||||
}
|
||||
|
||||
/** 파라미터를 16비트 Big Endian으로 추가 (펌웨어 테스터와 동일 포맷) */
|
||||
fun buildCommandBE(cmd: String, params: IntArray = intArrayOf()): ByteArray {
|
||||
val cmdBytes = "$cmd?".toByteArray(Charsets.UTF_8)
|
||||
val paramBytes = ByteArray(params.size * 2)
|
||||
for (i in params.indices) {
|
||||
paramBytes[i * 2] = ((params[i] shr 8) and 0xFF).toByte() // High byte first
|
||||
paramBytes[i * 2 + 1] = (params[i] and 0xFF).toByte() // Low byte
|
||||
}
|
||||
return appendCRC(cmdBytes + paramBytes)
|
||||
}
|
||||
|
||||
fun buildSimpleCommand(cmd: String): ByteArray {
|
||||
return appendCRC(cmd.toByteArray(Charsets.UTF_8))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user