Merge remote-tracking branch 'origin/dev_tcp2byte' into dev_tcp2byte
# Conflicts: # entry/src/main/ets/tcp2byte/index.ts
This commit is contained in:
commit
aab38515ed
@ -4,13 +4,13 @@
|
|||||||
{
|
{
|
||||||
"name": "default",
|
"name": "default",
|
||||||
"material": {
|
"material": {
|
||||||
"certpath": "/Users/surenjun/.ohos/config/openharmony/auto_ohos_default_subject-two_com.oh.dts.cer",
|
"certpath": "/Users/wangzhongjie/.ohos/config/openharmony/default_subject-two_Kl4t-ZSvZeuUm9s8O-e6FIH2VFR_OaNyhDP8kPjIWgU=.cer",
|
||||||
"storePassword": "0000001BE4BBADDF656A884E7A7BB5FD51F64FBB61DD24A944FEA969482DD693210ED5FF3D29F13642E3A3",
|
"storePassword": "0000001B1A6C605B348CE1F76970E037662E7240FC9A88762FF9CC0FBF41CD85BB9F44F66A7002A0A4226D",
|
||||||
"keyAlias": "debugKey",
|
"keyAlias": "debugKey",
|
||||||
"keyPassword": "0000001BDEFFDC280B45617E7FC447CB21F2D133540301F543454643D3F5E9F6E5ED2A583A7FA92B260433",
|
"keyPassword": "0000001B0C7AC8946180EE4BBCB5880D04DF499C741EBA9485672DD1C6902D3944018F866199FFD1B10B30",
|
||||||
"profile": "/Users/surenjun/.ohos/config/openharmony/auto_ohos_default_subject-two_com.oh.dts.p7b",
|
"profile": "/Users/wangzhongjie/.ohos/config/openharmony/default_subject-two_Kl4t-ZSvZeuUm9s8O-e6FIH2VFR_OaNyhDP8kPjIWgU=.p7b",
|
||||||
"signAlg": "SHA256withECDSA",
|
"signAlg": "SHA256withECDSA",
|
||||||
"storeFile": "/Users/surenjun/.ohos/config/openharmony/auto_ohos_default_subject-two_com.oh.dts.p12"
|
"storeFile": "/Users/wangzhongjie/.ohos/config/openharmony/default_subject-two_Kl4t-ZSvZeuUm9s8O-e6FIH2VFR_OaNyhDP8kPjIWgU=.p12"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@ -2,6 +2,11 @@
|
|||||||
"apiType": 'stageMode',
|
"apiType": 'stageMode',
|
||||||
"buildOption": {
|
"buildOption": {
|
||||||
"externalNativeOptions": {
|
"externalNativeOptions": {
|
||||||
|
"abiFilters": [
|
||||||
|
"arm64-v8a",
|
||||||
|
"armeabi-v7a",
|
||||||
|
"x86_64"
|
||||||
|
],
|
||||||
"path": "./src/main/cpp/CMakeLists.txt",
|
"path": "./src/main/cpp/CMakeLists.txt",
|
||||||
"arguments": "",
|
"arguments": "",
|
||||||
"cppFlags": "",
|
"cppFlags": "",
|
||||||
|
|||||||
@ -1,13 +1,15 @@
|
|||||||
{
|
{
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 2,
|
||||||
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
|
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
|
||||||
"specifiers": {
|
"specifiers": {
|
||||||
"@ohos/hypium@1.0.6": "@ohos/hypium@1.0.6"
|
"@ohos/hypium@1.0.6": "@ohos/hypium@1.0.6"
|
||||||
},
|
},
|
||||||
"packages": {
|
"packages": {
|
||||||
"@ohos/hypium@1.0.6": {
|
"@ohos/hypium@1.0.6": {
|
||||||
"resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.6.tgz",
|
"resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.6.tgz",
|
||||||
"integrity": "sha512-bb3DWeWhYrFqj9mPFV3yZQpkm36kbcK+YYaeY9g292QKSjOdmhEIQR2ULPvyMsgSR4usOBf5nnYrDmaCCXirgQ=="
|
"integrity": "sha512-bb3DWeWhYrFqj9mPFV3yZQpkm36kbcK+YYaeY9g292QKSjOdmhEIQR2ULPvyMsgSR4usOBf5nnYrDmaCCXirgQ==",
|
||||||
|
"registryType": "ohpm",
|
||||||
|
"shasum": "3f5fed65372633233264b3447705b0831dfe7ea1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3,6 +3,7 @@ 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]'
|
||||||
|
|
||||||
|
|
||||||
@ -12,8 +13,8 @@ interface RES {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
address: '114.55.125.222',
|
address: '172.37.55.191',
|
||||||
port: 50189
|
port: 40000
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function tcp2ByteRequest(data): Promise<RES> {
|
export default async function tcp2ByteRequest(data): Promise<RES> {
|
||||||
@ -27,7 +28,11 @@ 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({address: {address, port}})
|
await tcpClient.connect({
|
||||||
|
address: {
|
||||||
|
address, port
|
||||||
|
}
|
||||||
|
})
|
||||||
//发送消息
|
//发送消息
|
||||||
handSendMessage(tcpClient, data.sjbs, sendData)
|
handSendMessage(tcpClient, data.sjbs, sendData)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -83,7 +88,8 @@ function handSendMessage(client: socket.TCPSocket, type, data) {
|
|||||||
client.send({ data: new Uint8Array(data).buffer })
|
client.send({ data: new Uint8Array(data).buffer })
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:break;
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,15 +105,15 @@ function handReceiveMessage(client: socket.TCPSocket, sendData, rData:ArrayBuffe
|
|||||||
//开始补包
|
//开始补包
|
||||||
if (messageType === 0xF0) {
|
if (messageType === 0xF0) {
|
||||||
//获取消息体长度
|
//获取消息体长度
|
||||||
const messageLength = receiveData[13]
|
const messageLength = receiveData[12]
|
||||||
//分包总数
|
//分包总数
|
||||||
const packages = receiveData.slice(14, 14 + messageLength * 2);
|
const packages = bytesToDecimal(receiveData.slice(13, 13 + messageLength * 2));
|
||||||
const forArr = new Array(messageLength).fill(1)
|
const forArr = new Array(packages).fill(1)
|
||||||
|
|
||||||
forArr.forEach((item, index) => {
|
forArr.forEach((item, index) => {
|
||||||
const start = index * 2;
|
const start = index * 2;
|
||||||
const end = start + 1;
|
const end = start + 2;
|
||||||
const packageIndex = bytesToDecimal([packages[start],packages[end]]);
|
const packageIndex = bytesToDecimal([start, end]);
|
||||||
console.info(TAG, '补包内容' + JSON.stringify(new Uint8Array(sendData[packageIndex])))
|
console.info(TAG, '补包内容' + JSON.stringify(new Uint8Array(sendData[packageIndex])))
|
||||||
client.send({ data: new Uint8Array(sendData[packageIndex]).buffer });
|
client.send({ data: new Uint8Array(sendData[packageIndex]).buffer });
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"hvigorVersion": "3.0.9",
|
"hvigorVersion": "3.2.4",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ohos/hvigor-ohos-plugin": "3.0.9"
|
"@ohos/hvigor-ohos-plugin": "3.2.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,13 +1,15 @@
|
|||||||
{
|
{
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 2,
|
||||||
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
|
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
|
||||||
"specifiers": {
|
"specifiers": {
|
||||||
"@ohos/hypium@1.0.6": "@ohos/hypium@1.0.6"
|
"@ohos/hypium@1.0.6": "@ohos/hypium@1.0.6"
|
||||||
},
|
},
|
||||||
"packages": {
|
"packages": {
|
||||||
"@ohos/hypium@1.0.6": {
|
"@ohos/hypium@1.0.6": {
|
||||||
"resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.6.tgz",
|
"resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.6.tgz",
|
||||||
"integrity": "sha512-bb3DWeWhYrFqj9mPFV3yZQpkm36kbcK+YYaeY9g292QKSjOdmhEIQR2ULPvyMsgSR4usOBf5nnYrDmaCCXirgQ=="
|
"integrity": "sha512-bb3DWeWhYrFqj9mPFV3yZQpkm36kbcK+YYaeY9g292QKSjOdmhEIQR2ULPvyMsgSR4usOBf5nnYrDmaCCXirgQ==",
|
||||||
|
"registryType": "ohpm",
|
||||||
|
"shasum": "3f5fed65372633233264b3447705b0831dfe7ea1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user