You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
560 B
24 lines
560 B
module.exports = app => {
|
|
return {
|
|
async handle(udp) {
|
|
udp.on('error', (err) => {
|
|
console.log(`udp error:\n${err.stack}`);
|
|
});
|
|
|
|
udp.on('message', (msg, rinfo) => {
|
|
//cantest接口
|
|
if (app.cantest1) {
|
|
app.mqttServe.publish(`/cantest1`, msg.toString(), {
|
|
qos: 2,
|
|
retain: false,
|
|
})
|
|
}
|
|
});
|
|
|
|
udp.on('listening', () => {
|
|
let address = udp.address();
|
|
console.log(`udp listening ${address.address}:${address.port}`);
|
|
});
|
|
},
|
|
};
|
|
};
|