强制退出

This commit is contained in:
844143714@qq,com 2026-04-28 21:19:01 +08:00
parent 8a2f418831
commit 5dc924baf3
4 changed files with 55 additions and 5 deletions

View File

@ -171,6 +171,15 @@
<input type="text" id="ptt-gid" class="ws-input" value="00000001"> <input type="text" id="ptt-gid" class="ws-input" value="00000001">
</div> </div>
</div> </div>
<div style="display: flex; gap: 8px;">
<div style="flex: 4;">
<span class="ptt-label">AT 指令 (十六进制):</span>
<input type="text" id="ptt-at-cmd" class="ws-input" placeholder="e.g. 0D0000">
</div>
<div style="flex: 1; display: flex; align-items: flex-end;">
<button class="btn ptt-btn ptt-action-btn" style="background: #475569; height: 35px;" onclick="pttSendAtCmd()">发送</button>
</div>
</div>
</div> </div>
<!-- PTT 核心对讲按钮 --> <!-- PTT 核心对讲按钮 -->
@ -767,6 +776,18 @@
showPttResult("已触发模拟账号冲突"); showPttResult("已触发模拟账号冲突");
} }
} }
function pttSendAtCmd() {
var cmd = document.getElementById('ptt-at-cmd').value.trim();
if (!cmd) {
showPttResult("请输入 AT 指令");
return;
}
if (window.android && window.android.pttSendAtCmd) {
window.android.pttSendAtCmd(cmd);
showPttResult("已发送 AT 指令: " + cmd);
}
}
</script> </script>
</body> </body>
</html> </html>

View File

@ -7,11 +7,22 @@ import timber.log.Timber;
* */ * */
public class SendAtUtil { public class SendAtUtil {
private static void send(String cmd) { public static void sendRawCmd(String cmd) {
Timber.tag("PTT_TX").i("CMD: %s", cmd); Timber.tag("PTT_TX").i("CMD: %s", cmd);
MyApplication.getAppInstance().getpNative().pttNativeSendAtCmd(cmd); MyApplication.getAppInstance().getpNative().pttNativeSendAtCmd(cmd);
} }
private static void send(String cmd) {
sendRawCmd(cmd);
}
/**
* 账号注销接口
*/
public static void toLogout() {
send("040000\r\n");
}
/** /**
* 账号登录接口 * 账号登录接口
* account 账号 * account 账号

View File

@ -101,6 +101,14 @@ class AndroidInterface(private val activity: MainActivity) {
} }
} }
/**
* 发送原始 AT 指令 (调试用)
*/
@JavascriptInterface
fun pttSendAtCmd(cmd: String) {
SendAtUtil.sendRawCmd(cmd)
}
/** /**
* PTT 切换群组 * PTT 切换群组
*/ */

View File

@ -131,15 +131,25 @@ class LoginActivity : AppCompatActivity() {
Toast.makeText(this@LoginActivity, "登录成功", Toast.LENGTH_SHORT).show() Toast.makeText(this@LoginActivity, "登录成功", Toast.LENGTH_SHORT).show()
// 1. 确保 PTT 引擎初始化并登录 // 1. PTT 引擎初始化并异步登录 (避免阻塞 UI)
try { try {
// 确保 PTT 引擎已初始化
com.example.kingway.ptt.MyApplication.init(this@LoginActivity) com.example.kingway.ptt.MyApplication.init(this@LoginActivity)
// 异步初始化 PTT 登录 (区分 Android 业务登录) com.example.kingway.ptt.SendAtUtil.toLogout()
com.example.kingway.ptt.SendAtUtil.toLogin("gzzdweb01", "123456", "61.243.1.123", 1, 1)
} catch (e: Exception) { } catch (e: Exception) {
Timber.tag("PTT").e(e, "PTT init error") Timber.tag("PTT").e(e, "PTT init error")
} }
Thread {
try {
Thread.sleep(500)
runOnUiThread {
Toast.makeText(this@LoginActivity, "PTT初始化中", Toast.LENGTH_SHORT).show()
}
Thread.sleep(1500)
com.example.kingway.ptt.SendAtUtil.toLogin("gzzdweb01", "123456", "61.243.1.123", 1, 1)
} catch (e: Exception) {
Timber.tag("PTT").e(e, "PTT login error")
}
}.start()
// 2. 启动硬件 GPIO 监听 // 2. 启动硬件 GPIO 监听
try { try {