通过UDP API发送8位字节的数组,一直有问题
点击一个按钮,发送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
})
}
}