fix: 暂存

This commit is contained in:
wangzhongjie 2025-03-05 10:16:46 +08:00
commit d4188fb3d7

View File

@ -3,7 +3,6 @@ import util from '@ohos.util'
import promptAction from '@ohos.promptAction' import promptAction from '@ohos.promptAction'
import TcpToByte from './utils/tcp2byte' import TcpToByte from './utils/tcp2byte'
import {bytesToDecimal} from './utils/tools' import {bytesToDecimal} from './utils/tools'
const TAG = '[TCP2BYTE]' const TAG = '[TCP2BYTE]'
@ -13,8 +12,8 @@ interface RES {
} }
const config = { const config = {
address: '172.37.55.191', address: '114.55.125.222',
port: 40000 port: 50189
} }
export default async function tcp2ByteRequest(data): Promise<RES> { export default async function tcp2ByteRequest(data): Promise<RES> {
@ -28,11 +27,7 @@ export default async function tcp2ByteRequest(data): Promise<RES> {
console.info(TAG, 'sendData=>' + JSON.stringify(sendData)) console.info(TAG, 'sendData=>' + JSON.stringify(sendData))
try { try {
await tcpClient.connect({ await tcpClient.connect({address: {address, port}})
address: {
address, port
}
})
//发送消息 //发送消息
handSendMessage(tcpClient, data.sjbs, sendData) handSendMessage(tcpClient, data.sjbs, sendData)
} catch (e) { } catch (e) {
@ -88,18 +83,13 @@ function handSendMessage(client: socket.TCPSocket, type, data) {
client.send({ data: new Uint8Array(data).buffer }) client.send({ data: new Uint8Array(data).buffer })
break; break;
default: default:break;
break;
} }
} }
//处理接收的数据 //处理接收的数据
function handReceiveMessage(client: socket.TCPSocket, sendData, rData): RES { function handReceiveMessage(client: socket.TCPSocket, sendData, receiveData):RES {
console.info(TAG, 'receiveData=>' + rData)
let receiveData = []
for (let i = 0; i < rData.length; i++) {
receiveData.push(rData[i]);
}
//返回的消息类型 //返回的消息类型
const messageType = receiveData[1]; const messageType = receiveData[1];
//流水号 //流水号