diff --git a/app/src/main/java/com/casic/app/safetreecontroller/fragments/VoiceSettingsFragment.kt b/app/src/main/java/com/casic/app/safetreecontroller/fragments/VoiceSettingsFragment.kt index 6314ed6..0640400 100644 --- a/app/src/main/java/com/casic/app/safetreecontroller/fragments/VoiceSettingsFragment.kt +++ b/app/src/main/java/com/casic/app/safetreecontroller/fragments/VoiceSettingsFragment.kt @@ -98,9 +98,9 @@ binding.modeRadioGroup.setOnCheckedChangeListener { _, checkedId -> if (isVisibleToUser) { if (checkedId == R.id.localeRadioButton) { - SaveKeyValues.putValue(LocaleConstant.LOCALE_MODE_KEY, true) + SocketConnectionService.weakReferenceHandler?.sendEmptyMessage(LocaleConstant.OPEN_LOCALE_MODE_CODE) } else if (checkedId == R.id.remoteRadioButton) { - SaveKeyValues.putValue(LocaleConstant.LOCALE_MODE_KEY, false) + SocketConnectionService.weakReferenceHandler?.sendEmptyMessage(LocaleConstant.OPEN_REMOTE_MODE_CODE) } } } diff --git a/app/src/main/java/com/casic/app/safetreecontroller/fragments/VoiceSettingsFragment.kt b/app/src/main/java/com/casic/app/safetreecontroller/fragments/VoiceSettingsFragment.kt index 6314ed6..0640400 100644 --- a/app/src/main/java/com/casic/app/safetreecontroller/fragments/VoiceSettingsFragment.kt +++ b/app/src/main/java/com/casic/app/safetreecontroller/fragments/VoiceSettingsFragment.kt @@ -98,9 +98,9 @@ binding.modeRadioGroup.setOnCheckedChangeListener { _, checkedId -> if (isVisibleToUser) { if (checkedId == R.id.localeRadioButton) { - SaveKeyValues.putValue(LocaleConstant.LOCALE_MODE_KEY, true) + SocketConnectionService.weakReferenceHandler?.sendEmptyMessage(LocaleConstant.OPEN_LOCALE_MODE_CODE) } else if (checkedId == R.id.remoteRadioButton) { - SaveKeyValues.putValue(LocaleConstant.LOCALE_MODE_KEY, false) + SocketConnectionService.weakReferenceHandler?.sendEmptyMessage(LocaleConstant.OPEN_REMOTE_MODE_CODE) } } } diff --git a/app/src/main/java/com/casic/app/safetreecontroller/service/SocketConnectionService.kt b/app/src/main/java/com/casic/app/safetreecontroller/service/SocketConnectionService.kt index 03c1e53..dc74dbb 100644 --- a/app/src/main/java/com/casic/app/safetreecontroller/service/SocketConnectionService.kt +++ b/app/src/main/java/com/casic/app/safetreecontroller/service/SocketConnectionService.kt @@ -53,6 +53,14 @@ LocaleConstant.REDUCE_VOICE_CODE -> { tcpClient.sendMessage(CommandCreator.createReduceVoiceCommand()) } + + LocaleConstant.OPEN_LOCALE_MODE_CODE -> { + tcpClient.sendMessage(CommandCreator.createOpenLocaleModeCommand()) + } + + LocaleConstant.OPEN_REMOTE_MODE_CODE -> { + tcpClient.sendMessage(CommandCreator.createOpenRemoteModeCommand()) + } } return true } @@ -64,7 +72,7 @@ override fun run() { tcpClient.sendMessage(CommandCreator.createMethaneCommand()) // 每3s重复一次 - weakReferenceHandler?.postDelayed(this, 3 * 1000L) + weakReferenceHandler?.postDelayed(this, 10 * 1000L) } } @@ -106,6 +114,8 @@ * 激光温度返回:[7, 32, 0, 1, 0, 1, -52, 1, 0, -106, 1, 96, -8] * 音量加返回:[7, 32, 0, 1, 0, 1, -69, 1, 0, -104, 1, 0, -102] * 音量减返回:[7, 32, 0, 1, 0, 1, -69, 1, 0, -104, 0, 0, -103] + * 语音源切换到本地返回:[7, 32, 0, 1, 0, 1, -69, 1, 0, -112, 1, 0, -110] + * 语音源切换到远程返回:[7, 32, 0, 1, 0, 1, -69, 1, 0, -112, 0, 0, -111] * */ if (bytes.size < 6) { Log.d(kTag, "onMessageReceived: 数据异常,长度不够") @@ -142,6 +152,15 @@ "BB" -> { if (bytes.size == 13) { when ((bytes[9].toInt() and 0xFF).toString(16).uppercase()) { + "90" -> { + //语音源模式 + if (bytes[10].toInt() == 1) { + SaveKeyValues.putValue(LocaleConstant.LOCALE_MODE_KEY, false) + } else { + SaveKeyValues.putValue(LocaleConstant.LOCALE_MODE_KEY, true) + } + } + "91" -> { //激光状态 if (bytes[10].toInt() == 1) { diff --git a/app/src/main/java/com/casic/app/safetreecontroller/fragments/VoiceSettingsFragment.kt b/app/src/main/java/com/casic/app/safetreecontroller/fragments/VoiceSettingsFragment.kt index 6314ed6..0640400 100644 --- a/app/src/main/java/com/casic/app/safetreecontroller/fragments/VoiceSettingsFragment.kt +++ b/app/src/main/java/com/casic/app/safetreecontroller/fragments/VoiceSettingsFragment.kt @@ -98,9 +98,9 @@ binding.modeRadioGroup.setOnCheckedChangeListener { _, checkedId -> if (isVisibleToUser) { if (checkedId == R.id.localeRadioButton) { - SaveKeyValues.putValue(LocaleConstant.LOCALE_MODE_KEY, true) + SocketConnectionService.weakReferenceHandler?.sendEmptyMessage(LocaleConstant.OPEN_LOCALE_MODE_CODE) } else if (checkedId == R.id.remoteRadioButton) { - SaveKeyValues.putValue(LocaleConstant.LOCALE_MODE_KEY, false) + SocketConnectionService.weakReferenceHandler?.sendEmptyMessage(LocaleConstant.OPEN_REMOTE_MODE_CODE) } } } diff --git a/app/src/main/java/com/casic/app/safetreecontroller/service/SocketConnectionService.kt b/app/src/main/java/com/casic/app/safetreecontroller/service/SocketConnectionService.kt index 03c1e53..dc74dbb 100644 --- a/app/src/main/java/com/casic/app/safetreecontroller/service/SocketConnectionService.kt +++ b/app/src/main/java/com/casic/app/safetreecontroller/service/SocketConnectionService.kt @@ -53,6 +53,14 @@ LocaleConstant.REDUCE_VOICE_CODE -> { tcpClient.sendMessage(CommandCreator.createReduceVoiceCommand()) } + + LocaleConstant.OPEN_LOCALE_MODE_CODE -> { + tcpClient.sendMessage(CommandCreator.createOpenLocaleModeCommand()) + } + + LocaleConstant.OPEN_REMOTE_MODE_CODE -> { + tcpClient.sendMessage(CommandCreator.createOpenRemoteModeCommand()) + } } return true } @@ -64,7 +72,7 @@ override fun run() { tcpClient.sendMessage(CommandCreator.createMethaneCommand()) // 每3s重复一次 - weakReferenceHandler?.postDelayed(this, 3 * 1000L) + weakReferenceHandler?.postDelayed(this, 10 * 1000L) } } @@ -106,6 +114,8 @@ * 激光温度返回:[7, 32, 0, 1, 0, 1, -52, 1, 0, -106, 1, 96, -8] * 音量加返回:[7, 32, 0, 1, 0, 1, -69, 1, 0, -104, 1, 0, -102] * 音量减返回:[7, 32, 0, 1, 0, 1, -69, 1, 0, -104, 0, 0, -103] + * 语音源切换到本地返回:[7, 32, 0, 1, 0, 1, -69, 1, 0, -112, 1, 0, -110] + * 语音源切换到远程返回:[7, 32, 0, 1, 0, 1, -69, 1, 0, -112, 0, 0, -111] * */ if (bytes.size < 6) { Log.d(kTag, "onMessageReceived: 数据异常,长度不够") @@ -142,6 +152,15 @@ "BB" -> { if (bytes.size == 13) { when ((bytes[9].toInt() and 0xFF).toString(16).uppercase()) { + "90" -> { + //语音源模式 + if (bytes[10].toInt() == 1) { + SaveKeyValues.putValue(LocaleConstant.LOCALE_MODE_KEY, false) + } else { + SaveKeyValues.putValue(LocaleConstant.LOCALE_MODE_KEY, true) + } + } + "91" -> { //激光状态 if (bytes[10].toInt() == 1) { diff --git a/app/src/main/java/com/casic/app/safetreecontroller/utils/CommandCreator.kt b/app/src/main/java/com/casic/app/safetreecontroller/utils/CommandCreator.kt index d2b05c2..6256369 100644 --- a/app/src/main/java/com/casic/app/safetreecontroller/utils/CommandCreator.kt +++ b/app/src/main/java/com/casic/app/safetreecontroller/utils/CommandCreator.kt @@ -79,4 +79,18 @@ fun createReduceVoiceCommand(): ByteArray { return byteArrayOf(0xAA.toByte(), 0x01, 0x00, 0x98.toByte(), 0x00, 0x00, 0x99.toByte()) } + + /** + * 切换本地音源指令 + * */ + fun createOpenLocaleModeCommand(): ByteArray { + return byteArrayOf(0xAA.toByte(), 0x01, 0x00, 0x90.toByte(), 0x00, 0x00, 0x91.toByte()) + } + + /** + * 切换远程音源指令 + * */ + fun createOpenRemoteModeCommand(): ByteArray { + return byteArrayOf(0xAA.toByte(), 0x01, 0x00, 0x90.toByte(), 0x01, 0x00, 0x92.toByte()) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/safetreecontroller/fragments/VoiceSettingsFragment.kt b/app/src/main/java/com/casic/app/safetreecontroller/fragments/VoiceSettingsFragment.kt index 6314ed6..0640400 100644 --- a/app/src/main/java/com/casic/app/safetreecontroller/fragments/VoiceSettingsFragment.kt +++ b/app/src/main/java/com/casic/app/safetreecontroller/fragments/VoiceSettingsFragment.kt @@ -98,9 +98,9 @@ binding.modeRadioGroup.setOnCheckedChangeListener { _, checkedId -> if (isVisibleToUser) { if (checkedId == R.id.localeRadioButton) { - SaveKeyValues.putValue(LocaleConstant.LOCALE_MODE_KEY, true) + SocketConnectionService.weakReferenceHandler?.sendEmptyMessage(LocaleConstant.OPEN_LOCALE_MODE_CODE) } else if (checkedId == R.id.remoteRadioButton) { - SaveKeyValues.putValue(LocaleConstant.LOCALE_MODE_KEY, false) + SocketConnectionService.weakReferenceHandler?.sendEmptyMessage(LocaleConstant.OPEN_REMOTE_MODE_CODE) } } } diff --git a/app/src/main/java/com/casic/app/safetreecontroller/service/SocketConnectionService.kt b/app/src/main/java/com/casic/app/safetreecontroller/service/SocketConnectionService.kt index 03c1e53..dc74dbb 100644 --- a/app/src/main/java/com/casic/app/safetreecontroller/service/SocketConnectionService.kt +++ b/app/src/main/java/com/casic/app/safetreecontroller/service/SocketConnectionService.kt @@ -53,6 +53,14 @@ LocaleConstant.REDUCE_VOICE_CODE -> { tcpClient.sendMessage(CommandCreator.createReduceVoiceCommand()) } + + LocaleConstant.OPEN_LOCALE_MODE_CODE -> { + tcpClient.sendMessage(CommandCreator.createOpenLocaleModeCommand()) + } + + LocaleConstant.OPEN_REMOTE_MODE_CODE -> { + tcpClient.sendMessage(CommandCreator.createOpenRemoteModeCommand()) + } } return true } @@ -64,7 +72,7 @@ override fun run() { tcpClient.sendMessage(CommandCreator.createMethaneCommand()) // 每3s重复一次 - weakReferenceHandler?.postDelayed(this, 3 * 1000L) + weakReferenceHandler?.postDelayed(this, 10 * 1000L) } } @@ -106,6 +114,8 @@ * 激光温度返回:[7, 32, 0, 1, 0, 1, -52, 1, 0, -106, 1, 96, -8] * 音量加返回:[7, 32, 0, 1, 0, 1, -69, 1, 0, -104, 1, 0, -102] * 音量减返回:[7, 32, 0, 1, 0, 1, -69, 1, 0, -104, 0, 0, -103] + * 语音源切换到本地返回:[7, 32, 0, 1, 0, 1, -69, 1, 0, -112, 1, 0, -110] + * 语音源切换到远程返回:[7, 32, 0, 1, 0, 1, -69, 1, 0, -112, 0, 0, -111] * */ if (bytes.size < 6) { Log.d(kTag, "onMessageReceived: 数据异常,长度不够") @@ -142,6 +152,15 @@ "BB" -> { if (bytes.size == 13) { when ((bytes[9].toInt() and 0xFF).toString(16).uppercase()) { + "90" -> { + //语音源模式 + if (bytes[10].toInt() == 1) { + SaveKeyValues.putValue(LocaleConstant.LOCALE_MODE_KEY, false) + } else { + SaveKeyValues.putValue(LocaleConstant.LOCALE_MODE_KEY, true) + } + } + "91" -> { //激光状态 if (bytes[10].toInt() == 1) { diff --git a/app/src/main/java/com/casic/app/safetreecontroller/utils/CommandCreator.kt b/app/src/main/java/com/casic/app/safetreecontroller/utils/CommandCreator.kt index d2b05c2..6256369 100644 --- a/app/src/main/java/com/casic/app/safetreecontroller/utils/CommandCreator.kt +++ b/app/src/main/java/com/casic/app/safetreecontroller/utils/CommandCreator.kt @@ -79,4 +79,18 @@ fun createReduceVoiceCommand(): ByteArray { return byteArrayOf(0xAA.toByte(), 0x01, 0x00, 0x98.toByte(), 0x00, 0x00, 0x99.toByte()) } + + /** + * 切换本地音源指令 + * */ + fun createOpenLocaleModeCommand(): ByteArray { + return byteArrayOf(0xAA.toByte(), 0x01, 0x00, 0x90.toByte(), 0x00, 0x00, 0x91.toByte()) + } + + /** + * 切换远程音源指令 + * */ + fun createOpenRemoteModeCommand(): ByteArray { + return byteArrayOf(0xAA.toByte(), 0x01, 0x00, 0x90.toByte(), 0x01, 0x00, 0x92.toByte()) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/safetreecontroller/utils/LocaleConstant.kt b/app/src/main/java/com/casic/app/safetreecontroller/utils/LocaleConstant.kt index b33f0d0..b27290c 100644 --- a/app/src/main/java/com/casic/app/safetreecontroller/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/app/safetreecontroller/utils/LocaleConstant.kt @@ -20,6 +20,8 @@ const val QUERY_CPU_TEMPERATURE_CODE = 20240004 const val INCREASE_VOICE_CODE = 20240005 const val REDUCE_VOICE_CODE = 20240006 + const val OPEN_LOCALE_MODE_CODE = 20240007 + const val OPEN_REMOTE_MODE_CODE = 20240008 /** * Handler Response Code