fh1ch / node-bacstack

A BACnet protocol stack written in pure JavaScript
MIT License
174 stars 98 forks source link

Structuring objects for readPropertyResponse #142

Closed JDSlimz closed 4 years ago

JDSlimz commented 5 years ago

Node Version: 8.10.0

Node BACstack Version: 6.11.3

Feature Request / Question

I have been putzing around with this library for a little bit and I have whoIs and iAm working in my node project and YABE. I am, however, struggling to respond to readProperty requests. I have tried creating an object locally and I have tried replying directly using:

client.readPropertyResponse(request.address, request.invokeId, request.request.objectId, request.request.property, []);

I have tried putting data into the [ ] but no matter what I try i get various crashes such as:

TypeError: Cannot read property 'bitsUsed' of undefined

My question is, how do I structure an object to send in these replies? Is there a pre-made function or class I can use, or do I have to do something else? The documentation does not detail this. (I understand that work and life take priority!)

Thank you for any guidance and I will provide any missing info to help you help me!

fh1ch commented 4 years ago

I did exactly the same thing a while ago 😄 While the whole documentation aspect is still in a build-up phase and the missing type-safety makes the current use quite hard, I was able to simulate a BACNET device when scanning my network with YABE. My PoC code is here: https://github.com/fh1ch/node-bacstack-device/blob/master/index.js#L37

Feel free to re-open this issue, if something is not clear.