widesky / node-bacstack

The BACnet protocol library written in pure JavaScript
https://www.npmjs.com/package/@widesky/node-bacnet
MIT License
0 stars 1 forks source link

[Feat] Disclose decoded network details of the source device. #2

Open SamuelToh opened 4 years ago

SamuelToh commented 4 years ago

Node Version: 12.4.0

Node BACstack Version: 0.2.4

Feature Request / Question

In order to reach out to a specific device, commands like the read property will have to be explicit. Unicasting to an address is not sufficient as there can be more than 1 devices responding to the call. Hence to narrow down to a specific target device the parametersnet and adr must be set. At the moment whoIs does not disclose this.

We will need to decode these information and make it available.

Current Behaviour (Bug Report)

N/A

Expected Behaviour (Bug Report)

"header": {
    "func": 10,
    "sender": {
      "address": "10.1.201.53",
      "forwardedFrom": null,
      "type": 0,
      "net": 7778,
      "adr": [
        127,
        0,
        0,
        1,
        180,
        196
      ]
    },

The structure is recommended as this will make things easier for the lib user. All they need to do here would be to pass on the 'sender' object into the api like readProp and not care about the details.

Steps to reproduce Issue (Bug Report)

-

eabinga commented 4 years ago

Seems to work:

bacnetClient.on('listening', () => {
    bacnetClient.whoIs({address: '192.168.1.255', net: 65535}); // broadcast & global whois

    setTimeout(() => {
        bacnetClient.close();
    }, 5000);

Results in:

{
   "len":2,
   "type":16,
   "service":0,
   "header":{
      "func":10,
      "sender":{
         "address":"192.168.1.10:64359",
         "forwardedFrom":null,
         "type":0,
         "net":20,
         "adr":[
            192,
            168,
            1,
            200,
            186,
            192
         ]
      },
      "apduType":16,
      "expectingReply":false,
      "confirmedService":false
   },
   "payload":{
      "len":0,
      "deviceId":1000,
      "maxApdu":1440,
      "segmentation":0,
      "vendorId":35
   }
}

Where this device is not on the local network