通过UDP API发送8位字节的数组,一直有问题

发布于 7 年前作者 xiangping10349 次浏览最后编辑 7 年前来自 ask

点击一个按钮,发送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 回复
tanjie
tanjie1 楼5 年前

参数名写错了