通过UDP API发送8位字节的数组,一直有问题
发布于 6 年前 作者 xiangping 10211 次浏览 最后一次编辑是 5 年前 来自 问答

点击一个按钮,发送3个字节到指定嵌入式中,用下列方式,用wireshark抓包,发现发出去的字节为0,想请教各位大佬,下列代码设计是不是有问题?

clickMe: function () {

if (typeof wx.createUDPSocket === ‘function’) {

let that = this

const udp = wx.createUDPSocket()

var arrayBuffer = new Uint8Array([11, 22, 33])

let myPort = udp.bind()

console.log(‘分配的端口是:’, myPort)

console.log(arrayBuffer)

udp.send({

address: ‘192.168.1.101’,

port: 5001,

data: [0x1,0x2,0x3],

offset:0,

len: 3

})

}

}

1 回复

参数名写错了

回到顶部