您好,我这边client.write 的内容,通过你的SDK 怎么实现呢?
const net = require('net');
const iconv = require('iconv-lite');
const client = new net.Socket();
client.connect(8888, '192.168.4.1', () => {
console.log('已连接到服务器');
});
let iiii=0;
client.on('data', (buffer) => {
let utf8String = iconv.decode(buffer, 'GBK');
console.log(utf8String); // 输出转换后的UTF-8编码字符串
if(iiii==0){
var gbkStr = iconv.encode('$WLAN:"MaoJu","88889999";"192.168.205.149",12345;\r\n', 'utf8');
console.log(gbkStr);
client.write(gbkStr);
var gbkStr1 = iconv.encode('$WLAN:"MaoJu","88889999*";"192.168.205.149",12345;\r\n', 'GBK');
console.log(gbkStr1);
client.write(gbkStr1);
iiii=1;
}
});
client.on('close', () => {
console.log('连接已关闭');
});
0 个回复