//16进制字符串转ASCII字符
var hexstr = this.transCodeToStr("0613735672291F00FFEE31");
const udp = wx.createUDPSocket();
udp.bind();
if (udp === null) {
console.log('暂不支持')
return;
} else {
wx.showToast({
title: "" + udp,
icon: 'success',
duration: 2000
})
}
udp.send({
address: '192.168.6.116',
port: 60000,
//发送的ascii字符
message: hexstr,
});
},
//16进制字符串转ASCII字符
transCodeToStr: function (codes) {
var asiiresult = '';
for (var i = 0; i < codes.length; i++ , i++) {
var num = "0x" + codes.substring(i, i + 2);
console.log(num);
console.log(String.fromCharCode(num));
console.log(asiiresult);
asiiresult += String.fromCharCode(num);
}
console.log(asiiresult);
return asiiresult;
},
服务端收到的数据
微信开发工具本地抓包抓到的数据:
请问什么原因导致的?我想发送16进制对应的ASCII字符,该怎么发?请多多指点......不胜感激
请勿重复发帖,此贴先隐藏