Skip to content

Commit

Permalink
🎉Alpha 1.3,优化代码结构,完善串口日志全部获取功能
Browse files Browse the repository at this point in the history
  • Loading branch information
Hny0305Lin committed Jul 4, 2024
1 parent c10721e commit 8e5b650
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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; // 控制是否启用剪贴板功能
//这里设置的是数据库相关
Expand All @@ -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; }

Expand All @@ -23,33 +31,63 @@ 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;
}

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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
// 处理配对完成日志
}
Expand All @@ -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);
// 处理启用回调日志
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<resources>
<string name="app_name">NLChat</string>
<string name="app_package">com.haohanyh.linmengjia.nearlink.nlchat.fun</string>
<string name="app_version">1.3.20.2024.0704</string>
<string name="app_version">1.3.26.2024.0704</string>

<string name="appwarn">NLChat,浩瀚银河宗旨为用爱和魔法创造Android APP。</string>
<string name="thanks3q">友情感谢</string>
Expand Down

0 comments on commit 8e5b650

Please sign in to comment.