node-bacstack
node-bacstack copied to clipboard
How to handle events coming from a notification object?
As the title says, if I setup a bacnet server and set the notification object in my controller to forward the messages to my server, how do I handle those events?
I searched but couldnt see anything in the docs or code. Is it possible?
Hi @cemremengu
I've just started recently to tackle the whole alarming and eventing topic (see here), as I don't have too much experience with it.
I'm not really sure, what BACNET service you mean with that, but I assume you either using eventNotifyConfirmed
or eventNotifyUnconfirmed
. If this is the case, it should (never tested outside of syntactical unit-tests) be supported (see here for confirmed and here for unconfirmed). It should looks something like this (for the unconfirmed type):
var bacnet = require('bacstack');
const client = new bacnet();
client.on('eventNotify', (package) => {
console.log(`Received 'eventNotify' from device: ${package.address} - Payload:`);
console.log(eventData);
});
Let me know if this helps.
Cheers
Sorry for the late reply, I was on holidays
In order to be able to receive event notifications, I need to be able to assign a deviceId
to my client, receive a whoIs
request and reply with an iAm
How to do this is not very obvious from documentation and code (at least for me). Could you please provide some assistance if possible?
Sorry for the late reply, I was on holidays
No worries, me too 😄
In order to be able to receive event notifications, I need to be able to assign a deviceId to my client, receive a whoIs request and reply with an iAm
This doesn't really sounds like "BACNET eventing" at all, but more like you try to implement a BACNET device, wich supports the whoIs
/ iAm
service. Am I right with this assumption?
How to do this is not very obvious from documentation and code (at least for me). Could you please provide some assistance if possible?
There is currently no documentation for the service handling part of most functions (see https://github.com/fh1ch/node-bacstack#features), as there still marked as unstable. However, I've used those functions in one of my other projects (see https://github.com/fh1ch/node-bacstack-device/blob/master/index.js#L30), where I try to implement a BACNET device (server) in JavaScript.
Yes, your assumption is correct. In order to receive event notifications, you need to register a device in automation server (controller). After that, you can select your device to receive events from a notification class. WhoIs/IAm is required at registration step for device discovery.
@cemremengu Did you managed it? It would be awesome if you could share your code and also maybe check if it works with https://github.com/BiancoRoyal/node-bacstack (which is an updated fork of this library). We also started to provide some example scripts ... maybe we could add such an event notify receiver there as example?
Unfortunately, it has been a long time and I no longer work with the project :disappointed: