diff --git a/app/src/main/java/com/haohanyh/linmengjia/nearlink/nlchat/fun/ChatCore/ChatUtils.java b/app/src/main/java/com/haohanyh/linmengjia/nearlink/nlchat/fun/ChatCore/ChatUtils.java index a8b65f5..fcd47af 100644 --- a/app/src/main/java/com/haohanyh/linmengjia/nearlink/nlchat/fun/ChatCore/ChatUtils.java +++ b/app/src/main/java/com/haohanyh/linmengjia/nearlink/nlchat/fun/ChatCore/ChatUtils.java @@ -3,7 +3,7 @@ public class ChatUtils { //这里设置的是UI相关,是否做到消息滚动展示在UI上,而不是全部展示,全部展示会占用大量UI资源 - private static boolean showUartLog = true; // 控制是否启用显示串口Log,打印在UI上(开发者使用) + private static boolean showUartLog = false; // 控制是否启用显示串口Log,打印在UI上(开发者使用) private static final boolean scrollingMessages = true; // 控制是否启用滚动消息功能 private static final boolean clipMessages = true; // 控制是否启用剪贴板功能 //这里设置的是数据库相关 @@ -14,7 +14,15 @@ public class ChatUtils { private static final String PREFIX_CLIENT = " Let's start chatting, This is the content of the client:"; //这里设置的是跟C代码相关的,黑名单处理串口Log,当这些文本出现在串口通讯里面的时候,提取这String内容 private static final String PREFIX_LOG_NOT_CONNECTED_SERVER = "[sle uart server] sle client is not connected! "; + private static final String PREFIX_LOG_CONNECTED = "[Connected]"; + private static final String PREFIX_LOG_DISCONNECTED = "[Disconnected]"; + private static final String PREFIX_LOG_ACORE = "[ACore]"; + private static final String PREFIX_LOG_SLE_UART_SERVER = "[sle uart server]"; + private static final String PREFIX_LOG_CONNECT_STATE_CHANGED = "[sle uart server] connect state changed"; + private static final String PREFIX_LOG_PAIR_COMPLETE = "[sle uart server] pair complete"; private static final String PREFIX_LOG_NEARLINK_DEVICES_ADDR = "[sle uart server] pair complete addr:"; + private static final String PREFIX_LOG_SSAPS_MTU_CHANGED = "[sle uart server] ssaps ssaps_mtu_changed_cbk"; + private static final String PREFIX_LOG_SLE_ANNOUNCE_ENABLE_CALLBACK = "[sle uart server] sle announce enable callback"; // 控制是否启用显示串口Log,打印在UI上(开发者使用) public static boolean isShowUartLog() { return showUartLog; } @@ -23,28 +31,50 @@ public class ChatUtils { public static boolean isScrollingMessages() { return scrollingMessages; } //控制是否启用剪贴板功能和设置 public static boolean isClipMessages() { return clipMessages; } - - public static void setSqlitehistory(boolean sqlitehistory) { ChatUtils.sqlitehistory = sqlitehistory; } //控制是否启用SQLite功能 public static boolean isSqlitemanager() { return sqlitemanager; } public static void setSqlitemanager(boolean sqlitemanager) { ChatUtils.sqlitemanager = sqlitemanager; } - + //控制是否启用SQLite历史记录功能 public static boolean isSqliteHistory() { return sqlitehistory; } public static void setSqliteHistory(boolean sqlitehistory) { ChatUtils.sqlitehistory = sqlitehistory; } - //对方为星闪服务端 + //对方为星闪服务端(User) public static String getPrefixServer() { return PREFIX_SERVER; } - //对方为星闪客户端 + //对方为星闪客户端(Me) public static String getPrefixClient() { return PREFIX_CLIENT; } //串口Log + public static String getPrefixLogConnected() { + return PREFIX_LOG_CONNECTED; + } + + public static String getPrefixLogDisconnected() { + return PREFIX_LOG_DISCONNECTED; + } + + public static String getPrefixLogAcore() { + return PREFIX_LOG_ACORE; + } + + public static String getPrefixLogSleUartServer() { + return PREFIX_LOG_SLE_UART_SERVER; + } + + public static String getPrefixLogConnectStateChanged() { + return PREFIX_LOG_CONNECT_STATE_CHANGED; + } + + public static String getPrefixLogPairComplete() { + return PREFIX_LOG_PAIR_COMPLETE; + } + public static String getPrefixLogNotConnectedServer() { return PREFIX_LOG_NOT_CONNECTED_SERVER; } @@ -52,4 +82,12 @@ public static String getPrefixLogNotConnectedServer() { public static String getPrefixLogNearlinkDevicesAddr() { return PREFIX_LOG_NEARLINK_DEVICES_ADDR; } + + public static String getPrefixLogSsapsMtuChanged() { + return PREFIX_LOG_SSAPS_MTU_CHANGED; + } + + public static String getPrefixLogSleAnnounceEnableCallback() { + return PREFIX_LOG_SLE_ANNOUNCE_ENABLE_CALLBACK; + } } diff --git a/app/src/main/java/com/haohanyh/linmengjia/nearlink/nlchat/fun/MainActivity.java b/app/src/main/java/com/haohanyh/linmengjia/nearlink/nlchat/fun/MainActivity.java index 5ac5917..bf8220a 100644 --- a/app/src/main/java/com/haohanyh/linmengjia/nearlink/nlchat/fun/MainActivity.java +++ b/app/src/main/java/com/haohanyh/linmengjia/nearlink/nlchat/fun/MainActivity.java @@ -465,27 +465,29 @@ private String CH34xProcessingForReadData(String string) { Log.d(TAG, "忽略的消息内容:" + completeFirstData); // 处理忽略消息内容 } - if (completeFirstData.contains("[Connected]")) { + //连接日志,以下与星闪连接相关 + if (completeFirstData.contains(ChatUtils.getPrefixLogConnected())) { Log.d(TAG, "连接日志:" + completeFirstData); // 处理连接日志 } - if (completeFirstData.contains("[Disconnected]")) { + if (completeFirstData.contains(ChatUtils.getPrefixLogDisconnected())) { Log.d(TAG, "断开连接日志:" + completeFirstData); // 处理断开连接日志 } - if (completeFirstData.contains("[ACore]")) { + if (completeFirstData.contains(ChatUtils.getPrefixLogAcore())) { Log.d(TAG, "ACore日志:" + completeFirstData); // 处理ACore日志 } - if (completeFirstData.contains("[sle uart server]")) { + //UART服务器日志,以下可以读取星闪日志 + if (completeFirstData.contains(ChatUtils.getPrefixLogSleUartServer())) { Log.d(TAG, "UART服务器日志:" + completeFirstData); // 处理UART服务器日志 } - if (completeFirstData.contains("[sle uart server] connect state changed")) { + if (completeFirstData.contains(ChatUtils.getPrefixLogConnectStateChanged())) { Log.d(TAG, "连接状态改变日志:" + completeFirstData); // 处理连接状态改变日志 } - if (completeFirstData.contains("[sle uart server] pair complete")) { + if (completeFirstData.contains(ChatUtils.getPrefixLogPairComplete())) { Log.d(TAG, "配对完成日志:" + completeFirstData); // 处理配对完成日志 } @@ -497,11 +499,11 @@ private String CH34xProcessingForReadData(String string) { ChatProcessorForExtract.processChat(context, completeFirstData); } } - if (completeFirstData.contains("[sle uart server] ssaps ssaps_mtu_changed_cbk")) { + if (completeFirstData.contains(ChatUtils.getPrefixLogSsapsMtuChanged())) { Log.d(TAG, "MTU改变日志:" + completeFirstData); // 处理MTU改变日志 } - if (completeFirstData.contains("[sle uart server] sle announce enable callback")) { + if (completeFirstData.contains(ChatUtils.getPrefixLogSleAnnounceEnableCallback())) { Log.d(TAG, "启用回调日志:" + completeFirstData); // 处理启用回调日志 } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bb10196..ef0112d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,7 +1,7 @@ NLChat com.haohanyh.linmengjia.nearlink.nlchat.fun - 1.3.20.2024.0704 + 1.3.26.2024.0704 NLChat,浩瀚银河宗旨为用爱和魔法创造Android APP。 友情感谢