-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
I am writing a program that will allow you to send telegrams from one network to another and back, it works, but unfortunately not with all types of telegrams. I can't understand why the telegram receiving event doesn't have a data type, so that I can specify it in the justification. Need help!
const KNX = require('knx');
const knxConfig1 = {
ipAddr: '192.168.31.12',
ipPort: 3671,
// physAddr: '1.1.112'
};
const knxConfig2 = {
ipAddr: '192.168.31.11',
ipPort: 3671,
// physAddr: '0.0.253'
};
const knxConnection1 = new KNX.Connection(knxConfig1);
const knxConnection2 = new KNX.Connection(knxConfig2);
knxConnection1.on('connected', () => {
console.log('Connected to KNX network 1');
});
knxConnection2.on('connected', () => {
console.log('Connected to KNX network 2');
});
knxConnection1.on('event', (evt, src, dest, value) => {
debugger;
knxConnection2.writeRaw(dest, value, (err) => {
if (err) {
console.error('Error forwarding telegram to network 2:', err);
} else {
console.log(`Forwarded telegram to network 2: ${dest} with value ${value}`);
}
});
});
knxConnection2.on('event', (evt, src, dest, value) => {
knxConnection1.writeRaw(dest, value, (err) => {
if (err) {
console.error('Error forwarding telegram to network 1:', err);
} else {
console.log(`Forwarded telegram to network 1: ${dest} with value ${value}`);
}
});
});
knxConnection1.on('error', (err) => {
console.error('Error in KNX connection 1:', err);
});
knxConnection2.on('error', (err) => {
console.error('Error in KNX connection 2:', err);
});Metadata
Metadata
Assignees
Labels
No labels