fh1ch / node-bacstack

A BACnet protocol stack written in pure JavaScript
MIT License
170 stars 97 forks source link

fix tag encoding for object identifier #179

Closed cdriks closed 1 year ago

cdriks commented 1 year ago

Hi,

Trying to add a list item to the recipient-list of a notification class, it doesn't work.

I'm using it like this:


        let validDays = { value: { "value": [127], "bitsUsed": 7 }, type: bacstack.enum.ApplicationTags.BIT_STRING }; //every days true
        let fromTime = { value: new Date(1, 1, 1, 0, 0, 0), type: bacstack.enum.ApplicationTags.TIME };
        let toTime = { value: new Date(1, 1, 1, 23, 59, 59, 990), type: bacstack.enum.ApplicationTags.TIME };
        let deviceIdentifier = { value: { type: bacstack.enum.ObjectType.DEVICE, instance: clientDOI }, type: bacstack.enum.ApplicationTags.OBJECTIDENTIFIER };
        let processIdentifier = { value: clientDOI, type: bacstack.enum.ApplicationTags.UNSIGNED_INTEGER };
        let issueConfirmedNotifications = { value: true, type: bacstack.enum.ApplicationTags.BOOLEAN };
        let transitions = { value: { "value": [7], "bitsUsed": 3 }, type: bacstack.enum.ApplicationTags.BIT_STRING };

        this.bacstack.addListElement(ip, { type: bacstack.enum.ObjectType.NOTIFICATION_CLASS, instance: instance }, { id: 102, index: bacstack.enum.ASN1_ARRAY_ALL },
            [
                validDays,
                fromTime,
                toTime,
                deviceIdentifier,
                processIdentifier,
                issueConfirmedNotifications,
                transitions,
            ], err => {
                if (err) {
                    console.error(err);
                }
                callback();
            });

Using Wireshark, I can see, that the tags are correct expect for the line :

let deviceIdentifier = { value: { type: bacstack.enum.ObjectType.DEVICE, instance: clientDOI }, type: bacstack.enum.ApplicationTags.OBJECTIDENTIFIER };

Where the tag is "c4" in place of "0c".

The encoded tags are correct for the other types, so I changed the encoded tags for tagNumber in [12,14]. In my case, the problem is fixed.

No idea, if it can bring to other bugs...

Thanks in advance,

Cédric

cdriks commented 1 year ago

PR not to use! iAm Telegrams are not functional anymore. No idea, on how to correct it... I opened an issue therefore : https://github.com/fh1ch/node-bacstack/issues/180

Cédric