Explorar o código

增加串口控制

vothin hai 1 ano
pai
achega
82a34d7554

+ 69 - 0
jni/include/utils/ByteUtil.h

@@ -0,0 +1,69 @@
+
+
+#ifndef _UTILS_TIME_BYTE_UTIL_H_
+#define _UTILS_TIME_BYTE_UTIL_H_
+
+#include <string>
+#include <iostream>
+#include <sstream>
+
+
+/**
+ * @brief 字节操作类
+ */
+class ByteUtil {
+public:
+	static void copyUnsignedCharArray(unsigned char* source, unsigned char destination[], size_t size) {
+	    std::copy(source, source + size, destination);
+	}
+
+//	std::string byteToString(const unsigned char* bytes, unsigned long int length) {
+//	    return std::string(reinterpret_cast<const char*>(bytes), length);
+//	}
+
+	static std::string byteToString(const unsigned char* data, size_t size) {
+	    std::string result;
+
+	    // 将每个 unsigned char 转换为 char 并添加到结果字符串中
+	    for (size_t i = 0; i < size; ++i) {
+	        result += static_cast<char>(data[i]);
+	    }
+
+	    return result;
+	}
+
+	static std::string convertToString(const unsigned char* data, size_t size) {
+        std::string dataStr = "";
+		for (int i = 0; i < size; ++i) {
+            char buf[1024];
+			sprintf(buf, "%02x", data[i]);
+			dataStr += buf;
+		}
+	    return dataStr;
+	}
+
+	static unsigned char stringToByte(const std::string& str) {
+	    std::stringstream ss;
+	    ss << std::hex << str;
+	    unsigned int intValue;
+	    ss >> intValue;
+	    return static_cast<unsigned char>(intValue);
+	}
+
+
+	static std::string timestampToHex(int timestamp) {
+	    std::stringstream ss;
+	    ss << std::hex << timestamp;
+	    return ss.str();
+	}
+
+
+	static std::string timestampToHex(time_t timestamp) {
+	    std::stringstream ss;
+	    ss << std::hex << timestamp;
+	    return ss.str();
+	}
+
+};
+
+#endif /* _UTILS_TIME_BYTE_UTIL_H_ */

+ 7 - 0
jni/logic/mainLogic.cc

@@ -350,6 +350,9 @@ static void getPartSetting(string partId){
 		partSetting.screenLight = root["screen_light"].asInt();
 		partSetting.roomCallBed = root["room_call_bed"].asInt();
 		partSetting.customerAgeHiddenOnDoor = root["customer_age_hidden_on_door"].asInt();
+        partSetting.linuxSerial1 = root["linux_serial1"].asString();
+        partSetting.linuxSerial2 = root["linux_serial2"].asString();
+        partSetting.linuxSerial3 = root["linux_serial3"].asString();
 
 		if (root["linux_door_volume_native"].size() != 0) {
 			partSetting.linuxDoorVolumeNative = root["linux_door_volume_native"].asInt();
@@ -385,6 +388,10 @@ static void getPartSetting(string partId){
 		StoragePreferences::putInt(STORE_SCREEN_LIGHT, partSetting.screenLight);
 		StoragePreferences::putInt(STORE_ROOM_CALL_BED, partSetting.roomCallBed);
 
+        StoragePreferences::putString(STORE_LINUX_SERIAL1, partSetting.linuxSerial1);
+        StoragePreferences::putString(STORE_LINUX_SERIAL2, partSetting.linuxSerial2);
+        StoragePreferences::putString(STORE_LINUX_SERIAL3, partSetting.linuxSerial3);
+
 		setRightTitle(root);
 		callBedButtonSetVisible();
 		setDirectorAndHeadNurse();

+ 1 - 1
jni/logic/startLogic.cc

@@ -802,7 +802,7 @@ static void onProtocolDataUpdate(const SProtocolData &data) {
 //	if (data.msg != ""){
 //		LOGD("msg = %s", data.msg.c_str());
 //	}
-	if(UartContext::Uart3IsOpen()) {	// 如果是true,表示串口打开了
+    if(UartContext::Uart2IsOpen()) {    // 如果是true,表示串口打开了
 		string heartStr;
 
 		//按下

+ 24 - 0
jni/net/tcp_client.cpp

@@ -146,6 +146,30 @@ public:
 
 static MyThread my_thread;
 
+long ts = 0;
+std::string deviceMac = "";
+void TcpClient::dataParse(std::string data) {
+    long _ts = time(NULL);
+    //如果与上次数据相同,1500毫秒内不再重复发
+
+    if (deviceMac == data && (_ts - ts) < 15) {
+        return;
+    }
+    ts = _ts;
+    deviceMac = data;
+
+//    ffcc020006d2c711#END#
+    //ffcc 固定开头,02对应报警
+    std::string signal = "ffcc02";
+    int size = data.size();
+    signal += base::format("%04x", size);
+    signal += data;
+    const char* req = signal.c_str();
+    LOGD("ui %s",req);
+    TcpClient::instance()->sendMsg(req);
+}
+
+
 void TcpClient::startTcp(){
 	//调用线程类的run函数启动线程, 参数为线程名,可以任意指定。
 	my_thread.run("tcp thread");

+ 1 - 0
jni/net/tcp_client.h

@@ -24,6 +24,7 @@ public:
   void closeTcp();
   void sendMsg(const char* msg);
   void sendMsgWithCb(const char* msg, TcpCallback callback);
+  void dataParse(std::string data);
 
   static bool connected();
   static bool busy();

+ 326 - 0
jni/net/tcp_client5084.cpp

@@ -0,0 +1,326 @@
+/*
+ * tcp_client.cpp
+ *
+ *  Created on: 2022年10月5日
+ *      Author: Allen
+ */
+
+
+#include "tcp_client5084.h"
+
+#include "entry/EasyuiContext.h"
+#include "utils/Log.h"
+#include "utils/ByteUtil.h"
+#include "base/os.hpp"
+#include "base/strings.hpp"
+#include <system/Thread.h>
+#include <string>
+#include "net/NetManager.h"
+#include "service/BusinessConfig.h"
+
+static std::string sn = "";
+static byte code[4] = {0};
+static int dataConut = 0;
+
+#define ETHERNETMANAGER		NETMANAGER->getEthernetManager()
+
+//异或校验 返回一个字节
+unsigned char CheckXor(const char *strData, int len)
+{
+    char checksum = 0;
+    for (int i = 0;i < len;i++)
+    {
+        checksum = checksum ^ strData[i];
+    }
+    return (unsigned char)checksum;
+}
+
+void handleMsg(byte* msg);
+
+TcpClient5084::TcpClient5084() {
+	busy_ = false;
+}
+
+TcpClient5084::~TcpClient5084() {
+}
+
+TcpClient5084* TcpClient5084::instance() {
+	static TcpClient5084 singleton;
+	return &singleton;
+}
+
+static net::Conn* conn;
+void TcpClient5084::sendMsg(byte* msg, int size){
+	instance()->internalSendMsg(msg, size);
+}
+
+
+void TcpClient5084::internalSendMsg(byte* msg, int size){
+	if (busy_) {
+		LOGD("TcpClient5084 client is busy");
+		return;
+	}
+	busy_ = true;
+	if (conn){
+		conn->Write(msg, size);
+
+//		char _buf[1024];
+//	    std::string msgStr = "";
+//		for (int i = 0; i < size; ++i) {
+//	        sprintf(_buf, "%02x", msg[i]);
+//	        msgStr += _buf;
+//		}
+//
+//		LOGD("TcpClient5084 sended msg : %s", msgStr.c_str());
+	} else {
+		LOGD("tcp disconnect");
+	}
+	busy_ = false;
+}
+
+static bool isLogin = false;
+static bool isWhile = true;
+class SleepThread: public Thread {
+public:
+	/**
+	 * 线程创建成功后会调用该函数,可以在该函数中做一些初始化操作
+	 * return true   继续线程
+	 *        false  退出线程
+	 */
+	virtual bool readyToRun() {
+		LOGD("Thread 已经创建完成");
+		return true;
+	}
+
+	/**
+	 * 线程循环函数
+	 *
+	 * return true  继续线程循环
+	 *        false 推出线程
+	 */
+	virtual bool threadLoop() {
+		LOGD("线程循环函数");
+
+		//检查是否有退出线程的请求,如果有,则返回false,立即退出线程
+		if (exitPending()) {
+			return false;
+		}
+
+		conn = net::Dial("tcp", "192.168.1.199:5084");
+		if (conn) {
+			byte buf[1024] = {0};
+
+			int v0;
+			std::string _dataCount = std::to_string(dataConut);
+			sscanf(_dataCount.c_str(), "%2X", &v0);
+
+			byte loginData[12] = {0};
+			loginData[0] = 0x82;
+			loginData[1] = 0x0A;
+			loginData[2] = 0x01;
+			loginData[3] = v0;
+			loginData[4] = 0x03;
+
+			for (int i = 0; i < sn.size(); i += 2) {
+				std::string snStr = sn.substr(i, 2);
+				sscanf(snStr.c_str(), "%2X", &v0);
+				loginData[5 + i/2] = v0;
+			}
+			loginData[11] = CheckXor((char*) loginData, 11);
+			TcpClient5084::instance()->sendMsg(loginData, 12);
+			isWhile = true;
+			dataConut += 1;
+
+			while (isWhile && !exitPending()) {
+				//读取,超时1000毫秒
+				int n = conn->Read(buf, sizeof(buf) - 1, 1000);
+				if (n > 0) {
+					buf[n] = 0;
+					char _buf[1024];
+
+					if (buf[4] == 0x03) {
+						code[0] = buf[5];
+						code[1] = buf[6];
+						code[2] = buf[7];
+						code[3] = buf[8];
+						isLogin = true;
+					}
+				} else if (n == 0) {
+					LOGD("连接正常断开");
+					isLogin = false;
+					isWhile = false;
+					break;
+				} else if (n == net::E_TIMEOUT) {
+//					LOGD("读取超时");
+				} else {
+					LOGD("出错");
+					isLogin = false;
+					isWhile = false;
+					break;
+				}
+			}
+			//关闭连接
+			conn->Close();
+			//释放内存
+			delete conn;
+			conn = NULL;
+		}
+
+		//休眠5s
+		usleep(5000 * 1000);
+		//返回真,继续下次线程循环
+		return isLogin;
+	}
+};
+
+static SleepThread sleep_thread;
+
+void TcpClient5084::dataParse(std::string data) {
+//	LOGD("data =================> %s", data.c_str());
+	if (data.substr(2, 2) == "0f") {
+		// cd0f0076000004643320504168100064e401a601e301a501df01a501e601a601e101a501e101a401e401a601e301a401e401a301e401a401e101a601e201a501e301a301e401a401e101a401df01a401e301a501e301a501e201a401e401a401e101a401e101a501e201a301e201a501e201a3015631303032dc
+
+		sn = data.substr(16, 12);
+		if (!isLogin) {
+			TcpClient5084::instance()->startTcp();
+		}
+
+		if (!isLogin) {
+			return;
+		}
+//		int v0;
+//		std::string _dataCount = std::to_string(dataConut);
+//		sscanf(_dataCount.c_str(), "%2X", &v0);
+
+		byte secondData[2048] = {0};
+		secondData[0] = 0x82;
+		secondData[1] = 0x16;
+		secondData[2] = 0x01;
+		secondData[3] = ByteUtil::stringToByte(std::to_string(dataConut));
+		secondData[4] = 0x0E;
+
+		time_t date = time(NULL);
+		std::string dateStr = ByteUtil::timestampToHex(date - (8 * 3600));
+		for (int i = 0; i < dateStr.size(); i += 2) {
+			std::string _dateStr = dateStr.substr(i, 2);
+			secondData[5 + i/2] = ByteUtil::stringToByte(_dateStr);
+		}
+
+		std::string healthyData = "";
+		// 心率
+		healthyData = data.substr(8, 2);
+		secondData[9] = ByteUtil::stringToByte(healthyData);
+		// 呼吸
+		healthyData = data.substr(10, 2);
+		secondData[10] = ByteUtil::stringToByte(healthyData);
+		// 状态
+		healthyData = data.substr(12, 2);
+		secondData[11] = ByteUtil::stringToByte(healthyData);
+		// 电量
+		healthyData = data.substr(14, 2);
+		secondData[12] = ByteUtil::stringToByte(healthyData);
+
+		for (int i = 0; i < sn.size(); i += 2) {
+			std::string snStr = sn.substr(i, 2);
+			secondData[13 + i/2] = ByteUtil::stringToByte(snStr);
+		}
+
+		secondData[19] = code[0];
+		secondData[20] = code[1];
+		secondData[21] = code[2];
+		secondData[22] = code[3];
+
+		secondData[23] = CheckXor((char*) secondData, 23);
+
+		TcpClient5084::instance()->sendMsg(secondData, 24);
+	}
+	else if (data.substr(2, 2) == "3e") {
+		//cd3e000c620b0664013320504168108f
+//		LOGD("=========================> 每分钟传输");
+
+		sn = data.substr(18, 12);
+		if (!isLogin) {
+			TcpClient5084::instance()->startTcp();
+		}
+
+		if (!isLogin) {
+			return;
+		}
+
+		byte secondData[2048] = {0};
+		secondData[0] = 0x82;
+		secondData[1] = 0x17;
+		secondData[2] = 0x01;
+		secondData[3] = ByteUtil::stringToByte(std::to_string(dataConut));
+		secondData[4] = 0x4E;
+
+		time_t date = time(NULL);
+		std::string dateStr = ByteUtil::timestampToHex(date - (8 * 3600));
+		for (int i = 0; i < dateStr.size(); i += 2) {
+			std::string _dateStr = dateStr.substr(i, 2);
+			secondData[5 + i/2] = ByteUtil::stringToByte(_dateStr);
+		}
+
+		std::string healthyData = "";
+		// 心率
+		healthyData = data.substr(8, 2);
+		secondData[9] = ByteUtil::stringToByte(healthyData);
+		// 呼吸
+		healthyData = data.substr(10, 2);
+		secondData[10] = ByteUtil::stringToByte(healthyData);
+		// 状态
+		healthyData = data.substr(12, 2);
+		secondData[11] = ByteUtil::stringToByte(healthyData);
+		// 电量
+		healthyData = data.substr(14, 2);
+		secondData[12] = ByteUtil::stringToByte(healthyData);
+		// 睡眠分层
+		healthyData = data.substr(16, 2);
+		secondData[13] = ByteUtil::stringToByte(healthyData);
+
+		for (int i = 0; i < sn.size(); i += 2) {
+			std::string snStr = sn.substr(i, 2);
+			secondData[14 + i/2] = ByteUtil::stringToByte(snStr);
+		}
+
+		secondData[20] = code[0];
+		secondData[21] = code[1];
+		secondData[22] = code[2];
+		secondData[23] = code[3];
+
+		secondData[24] = CheckXor((char*) secondData, 24);
+
+		TcpClient5084::instance()->sendMsg(secondData, 25);
+	}
+
+
+	dataConut += 1;
+	if (dataConut >= 255) {
+		dataConut = 0;
+	}
+
+//	std::string sn = data.substr(16, 29);
+}
+
+
+void TcpClient5084::startTcp(){
+	//调用线程类的run函数启动线程, 参数为线程名,可以任意指定。
+	sleep_thread.run("tcp thread");
+}
+
+void TcpClient5084::closeTcp() {
+	bool result = sleep_thread.isRunning();
+	if (result) {
+		sleep_thread.requestExitAndWait();
+		LOGD("my_thread已关闭");
+	}
+//		my_thread.requestExit();
+}
+
+bool TcpClient5084::busy() {
+	return instance()->busy_;
+}
+
+bool TcpClient5084::connected() {
+	return conn != NULL;
+}

+ 38 - 0
jni/net/tcp_client5084.h

@@ -0,0 +1,38 @@
+/*
+ * tcp_client5084.h
+ *
+ *  Created on: 2022年10月5日
+ *      Author: Allen
+ */
+
+#ifndef JNI_NET_TCP_CLIENT5084_H_
+#define JNI_NET_TCP_CLIENT5084_H_
+
+#include <atomic>
+#include <functional>
+#include <thread>
+#include "net.h"
+#include "service/BusinessConfig.h"
+#include "tcp_model.h"
+#include "core/utilities.h"
+
+class TcpClient5084 {
+public:
+  virtual ~TcpClient5084();
+  static TcpClient5084* instance();
+
+  void startTcp();
+  void closeTcp();
+  void sendMsg(byte* msg, int size);
+  void dataParse(std::string data);
+
+  static bool connected();
+  static bool busy();
+private:
+  TcpClient5084();
+  void internalSendMsg(byte* msg, int size);
+private:
+  std::atomic<bool> busy_;
+};
+
+#endif /* JNI_NET_TCP_CLIENT5084_H_ */

+ 17 - 0
jni/service/BusinessConfig.h

@@ -52,6 +52,10 @@
 #define STORE_SCREEN_LIGHT "screen_light"
 #define STORE_ROOM_CALL_BED "room_call_bed"
 
+#define STORE_LINUX_SERIAL1 "linuxSerial1"
+#define STORE_LINUX_SERIAL2 "linuxSerial2"
+#define STORE_LINUX_SERIAL3 "linuxSerial3"
+
 #define STORE_LIGHT "light"
 #define STORE_VOLUME "volume"
 
@@ -265,6 +269,19 @@ public:
     inline static int customerNameHiddenOnDoor;
     inline static int customerAgeHiddenOnDoor;
     inline static int clerkNameHiddenOnDoor;
+    inline static std::string linuxSerial1;
+    inline static std::string linuxSerial2;
+    inline static std::string linuxSerial3;
+};
+
+class SerialType{
+public:
+    inline static std::string ENABLE = "ENABLE";
+    inline static std::string PANEL_BUTTON = "PANEL_BUTTON";
+    inline static std::string S433_BUTTON = "S433_BUTTON";
+    inline static std::string MULTIFUNCTIONAL_BUTTON = "MULTIFUNCTIONAL_BUTTON";
+    inline static std::string SLEEP_MATTRESS = "SLEEP_MATTRESS";
+    inline static std::string NFC = "NFC";
 };
 
 /**

+ 150 - 26
jni/uart/UartContext.cpp

@@ -12,7 +12,11 @@
 
 #include "uart/UartContext.h"
 #include "utils/Log.h"
+#include "utils/ByteUtil.h"
 #include "base/strings.hpp"
+#include "storage/StoragePreferences.h"
+#include "service/BusinessConfig.h"
+#include "net/tcp_client5084.h"
 
 #define UART_DATA_BUF_LEN			16384	// 16KB
 
@@ -62,6 +66,7 @@ UartContext::~UartContext() {
 }
 
 static bool mUart1IsOpen = false;
+static bool mUart2IsOpen = false;
 static bool mUart3IsOpen = false;
 
 // 打开串口,pFileName为串口号,baudRate为波特率
@@ -71,10 +76,13 @@ bool UartContext::openUart(const char *pFileName, UINT baudRate) {
 
 	if (mUartID <= 0) {
 		mIsOpen = false;
-		if(mUartNumber == 1) {
+		if (mUartNumber == 1) {
 			mUart1IsOpen = false;
 		}
-		if(mUartNumber == 2) {
+		if (mUartNumber == 2) {
+			mUart2IsOpen = false;
+		}
+		if (mUartNumber == 3) {
 			mUart3IsOpen = false;
 		}
 		LOGD("uart%d open error", mUartNumber);
@@ -101,10 +109,13 @@ bool UartContext::openUart(const char *pFileName, UINT baudRate) {
 			mUartID = 0;
 		}
 
-		if(mUartNumber == 1) {
+		if (mUartNumber == 1) {
 			mUart1IsOpen = true;
 		}
-		if(mUartNumber == 3) {
+		if (mUartNumber == 2) {
+			mUart2IsOpen = true;
+		}
+		if (mUartNumber == 3) {
 			mUart3IsOpen = true;
 		}
 
@@ -169,6 +180,123 @@ bool UartContext::readyToRun() {
 	return (mDataBufPtr != NULL);
 }
 
+
+static std::string sleepRevStr = "";
+static int sleepRevStrSize = 0;
+static unsigned char s433Buffer[5] = {0};
+static int s433BufferSize = 0;
+void dataProcessing(int ret, unsigned char* buffer, std::string serialType) {
+
+	if (serialType == SerialType::ENABLE) {
+		return;
+	}
+	else if (serialType == SerialType::PANEL_BUTTON) {
+		if (buffer[0]==CMD_HEAD && buffer[ret-2] == CMD_END1 && buffer[ret-1] == CMD_END2){
+			std::string revStr = "";
+			//std::string logInfo = " <<< ";
+			//依次将读取到的数据输出到日志
+			for (int i = 0; i < ret; ++i) {
+				if (i==0 || i==ret-1 || i==ret-2){
+					continue;
+				}
+				revStr += buffer[i];
+			}
+			buildProtocolData(revStr);
+		}
+	}
+	else if (serialType == SerialType::S433_BUTTON) {
+        std::string revStr = "";
+        if (ret < 5) {
+        	for (int i = 0; i < ret; ++i) {
+        		s433Buffer[s433BufferSize + i] = buffer[i];
+        	}
+        	s433BufferSize += ret;
+
+        	if (s433BufferSize < 5) {
+            	return;
+        	}
+        	else {
+        		s433BufferSize = 0;
+        	}
+        }
+        else {
+        	ByteUtil::copyUnsignedCharArray(buffer, s433Buffer, ret);
+        }
+
+        for (int i = 0; i < 5; ++i) {
+			if (i == 0 || i == 4){
+				continue;
+			}
+            char buf[1024];
+            sprintf(buf, "%02x", s433Buffer[i]);
+            revStr += buf;
+        }
+//        LOGD("revStr == %s", revStr.c_str());
+        TcpClient::instance()->dataParse(revStr);
+		return;
+	}
+	else if (serialType == SerialType::MULTIFUNCTIONAL_BUTTON) {
+		return;
+	}
+	else if (serialType == SerialType::SLEEP_MATTRESS) {
+		// cd0f0076000004643320504168100064e401a601e301a501df01a501e601a601e101a501e101a401e401a601e301a401e401a301e401a401e101a601e201a501e301a301e401a401e101a401df01a401e301a501e301a501e201a401e401a401e101a401e101a501e201a301e201a501e201a3015631303032dc
+		char buf[1024] = {0};
+		// 根据进入的数据来判断,如果进入的数据是cd开头
+		if (buffer[0] == 0xcd && sleepRevStr == "") {
+			// 循环拼接解析
+			sleepRevStr = ByteUtil::convertToString(buffer, ret);
+//			LOGD("sleepRevStr1 =======================> %s", sleepRevStr.c_str());
+
+			// 如果进入的数据字节数大于4,就可以判断完整数据长度
+			if (ret >= 4) {
+				sprintf(buf, "%02x", buffer[3]);
+				char *stop;
+				sleepRevStrSize = strtol(buf, &stop, 16);
+			}
+		}
+		else {
+			if (sleepRevStr.substr(0, 2) == "cd") {
+				for (int i = 0; i < ret; ++i) {
+					sprintf(buf, "%02x", buffer[i]);
+					sleepRevStr += buf;
+
+					if (sleepRevStr.size() == 8) {
+						char *stop;
+						sleepRevStrSize = strtol(buf, &stop, 16);
+					}
+				}
+//				LOGD("sleepRevStr2 =======================> %s", sleepRevStr.c_str());
+			}
+		}
+
+		if (sleepRevStr.size() >= (sleepRevStrSize + 4) * 2) {
+			TcpClient5084::instance()->dataParse(sleepRevStr);
+
+			// 然后对数据进行处理
+			sleepRevStr = "";
+			sleepRevStrSize = 0;
+		}
+	}
+	else if (serialType == SerialType::NFC) {
+        if (buffer[0] == 0xfe && buffer[2] == 0x03) {
+            if (buffer[1] == 0x08) {
+                std::string revStr = "";
+                for (int i = 0; i < ret; ++i) {
+                    if (i==0 || i==1 || i==2 || i==3 || i==4 || i==ret-1){
+                        continue;
+                    }
+                    char buf[1024];
+                    sprintf(buf, "%02x", buffer[i]);
+                    revStr += buf;
+                }
+                LOGD("revStr == %s", revStr.c_str());
+            }
+        }
+		return;
+	}
+}
+
+
 bool UartContext::threadLoop() {
 	if (mIsOpen) {
 #if 0
@@ -193,20 +321,14 @@ bool UartContext::threadLoop() {
 		unsigned char buffer[1024] = {0};
 		int ret = read(mUartID, buffer, sizeof(buffer));
 		if (ret > 0) {
-			if (buffer[0]==CMD_HEAD && buffer[ret-2] == CMD_END1 && buffer[ret-1] == CMD_END2){
-				std::string revStr = "";
-				//std::string logInfo = " <<< ";
-				//依次将读取到的数据输出到日志
-				for (int i = 0; i < ret; ++i) {
-					if (i==0 || i==ret-1 || i==ret-2){
-						continue;
-					}
-					//LOGD(" <<< %02x", buffer[i]);
-					revStr += buffer[i];
-					//logInfo += base::format("%02x",buffer[i]);
-				}
-				//LOGD(" %s",logInfo.c_str());
-				buildProtocolData(revStr);
+			if (mUartNumber == 2) {
+				dataProcessing(ret, buffer, StoragePreferences::getString(STORE_LINUX_SERIAL2, "PANEL_BUTTON"));
+			}
+			else if (mUartNumber == 3) {
+				dataProcessing(ret, buffer, StoragePreferences::getString(STORE_LINUX_SERIAL3, "ENABLE"));
+			}
+			else if (mUartNumber == 1) {
+				dataProcessing(ret, buffer, StoragePreferences::getString(STORE_LINUX_SERIAL1, "ENABLE"));
 			}
 		} else {
 		  //没收到数据时,休眠50ms,防止过度消耗cpu
@@ -229,16 +351,17 @@ void UartContext::init() {
 //    uart0 = new UartContext(UART_TTYS0);
 //    uart0->openUart("/dev/ttyS0", B115200);
 
-//    uart1 = new UartContext(UART_TTYS1);
-//    uart1->openUart("/dev/ttyS1", B115200);
+	uart1 = new UartContext(UART_TTYS1);
+	uart1->openUart("/dev/ttyS1", B115200);
+	LOGD("打开串口1");
 
-	// 20221108的板子打开了串口2
-    uart2 = new UartContext(UART_TTYS2);
-    uart2->openUart("/dev/ttyS2", B115200);
+	uart2 = new UartContext(UART_TTYS2);
+	uart2->openUart("/dev/ttyS2", B115200);
+	LOGD("打开串口2");
 
-    uart3 = new UartContext(UART_TTYS3);
-    uart3->openUart("/dev/ttyS3", B115200);
-    LOGD("打开串口");
+	uart3 = new UartContext(UART_TTYS3);
+	uart3->openUart("/dev/ttyS3", B115200);
+	LOGD("打开串口3");
 }
 
 void UartContext::destroy() {
@@ -276,4 +399,5 @@ bool UartContext::sendTo(int uart, const BYTE* pData, UINT len) {
 }
 
 bool UartContext::Uart1IsOpen() {return mUart1IsOpen;}
+bool UartContext::Uart2IsOpen() {return mUart2IsOpen;}
 bool UartContext::Uart3IsOpen() {return mUart3IsOpen;}

+ 1 - 0
jni/uart/UartContext.h

@@ -28,6 +28,7 @@ public:
 	static bool sendTo(int uart, const BYTE *pData, UINT len);
 
 	static bool Uart1IsOpen();
+	static bool Uart2IsOpen();
 	static bool Uart3IsOpen();
 
 	//static UartContext* getInstance();

BIN=BIN
libs/armeabi/libzkgui.so


BIN=BIN
obj/activity/callActivity.o


BIN=BIN
obj/activity/mainActivity.o


BIN=BIN
obj/activity/settingActivity.o


BIN=BIN
obj/activity/sipTestActivity.o


BIN=BIN
obj/activity/startActivity.o


BIN=BIN
obj/activity/statusbar.o


BIN=BIN
obj/activity/ui3Activity.o


BIN=BIN
obj/activity/updateActivity.o


BIN=BIN
obj/activity/warnActivity.o


BIN=BIN
obj/core/update_assistant.o


BIN=BIN
obj/net/tcp_client.o


BIN=BIN
obj/net/tcp_client5084.o


BIN=BIN
obj/server/http_server.o


BIN=BIN
obj/service/BusinessConfig.o


BIN=BIN
obj/service/time.o


BIN=BIN
obj/uart/UartContext.o