fix: 모든 BLE 명령어를 테스터 exe와 동일 포맷으로 통일

테스터(vsbtester) buildPacket() 분석 결과:
- 파라미터 있는 명령: 16비트 Big Endian (buildCommandBE)
- 파라미터 없는 명령: 공백 0x20 추가 (buildCommandASCII " ")

변경:
- mpa, mec, msn, mta, mls → buildCommandBE (BE 파라미터)
- mps, maa, mqq, mag, mcj, mid, msp, mbb → buildCommandASCII " " (공백)
- maa sendChannelsOnly도 공백 방식으로 통일 (기존 LE [0] 제거)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-24 16:42:02 +09:00
parent fdc4047c5c
commit 208de17152
@@ -306,47 +306,51 @@ class BleManager private constructor(private val context: Context) {
// Piezo Commands // Piezo Commands
val piezoCollector = PiezoPacketCollector() val piezoCollector = PiezoPacketCollector()
// ── Piezo Commands (테스터 exe와 동일 포맷: 파라미터=BE, 빈 파라미터=공백) ──
fun sendPiezoPowerOn(freqOption: Int = 2, cycles: Int = 5) { fun sendPiezoPowerOn(freqOption: Int = 2, cycles: Int = 5) {
sendRaw(CRC16.buildCommand("mpa", intArrayOf(freqOption, cycles))) sendRaw(CRC16.buildCommandBE("mpa", intArrayOf(freqOption, cycles)))
} }
fun sendPiezoStop() { fun sendPiezoStop() {
sendRaw(CRC16.buildCommand("mps")) sendRaw(CRC16.buildCommandASCII("mps", " "))
} }
fun sendBurst(freqOption: Int, cycles: Int, delayUs: Int, piezoCh: Int = 0) { fun sendBurst(freqOption: Int, cycles: Int, delayUs: Int, piezoCh: Int = 0) {
sendRaw(CRC16.buildCommand("mec", intArrayOf(freqOption, delayUs, 140, cycles, 1, piezoCh))) sendRaw(CRC16.buildCommandBE("mec", intArrayOf(freqOption, delayUs, 140, cycles, 1, piezoCh)))
} }
/** 6-channel measurement (maa) */
fun sendAllChannels(mode: Int = 0) { fun sendAllChannels(mode: Int = 0) {
piezoCollector.startMultiChannel(6) piezoCollector.startMultiChannel(6)
sendRaw(CRC16.buildCommand("maa", intArrayOf(mode))) sendRaw(CRC16.buildCommandASCII("maa", " "))
} }
// NIRS Commands // ── NIRS Commands ──
fun sendNirsPowerOn() { fun sendNirsPowerOn() {
sendRaw(CRC16.buildCommand("mta", intArrayOf(1))) sendRaw(CRC16.buildCommandBE("mta", intArrayOf(1)))
} }
fun sendNirsPowerOff() { fun sendNirsPowerOff() {
sendRaw(CRC16.buildCommand("mta", intArrayOf(0))) sendRaw(CRC16.buildCommandBE("mta", intArrayOf(0)))
} }
fun sendMqqQuery() { fun sendMqqQuery() {
sendRaw(CRC16.buildCommand("mqq")) sendRaw(CRC16.buildCommandASCII("mqq", " "))
} }
fun sendMagQuery() { fun sendMagQuery() {
sendRaw(CRC16.buildCommand("mag")) sendRaw(CRC16.buildCommandASCII("mag", " "))
} }
fun sendMcjQuery() { fun sendMcjQuery() {
sendRaw(CRC16.buildCommand("mcj")) sendRaw(CRC16.buildCommandASCII("mcj", " "))
} }
// ── Common Commands ──
fun sendBatteryQuery() { fun sendBatteryQuery() {
sendRaw(CRC16.buildCommand("msn", intArrayOf(0))) sendRaw(CRC16.buildCommandBE("msn", intArrayOf(0)))
} }
fun sendDeviceInfoQuery() { fun sendDeviceInfoQuery() {
@@ -367,10 +371,10 @@ class BleManager private constructor(private val context: Context) {
sendRaw(CRC16.buildCommandASCII("mbb", " ")) sendRaw(CRC16.buildCommandASCII("mbb", " "))
} }
/** 6채널 측정만 (maa, rbb 헤더 없이 바로 reb×6→raa) */ /** 6채널 측정만 (maa) */
fun sendChannelsOnly() { fun sendChannelsOnly() {
piezoCollector.startMultiChannel(6) piezoCollector.startMultiChannel(6)
sendRaw(CRC16.buildCommand("maa", intArrayOf(0))) sendRaw(CRC16.buildCommandASCII("maa", " "))
} }
fun startBatteryPolling() { fun startBatteryPolling() {