Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server example of "readProperty". I get "Couldn,t read 'Object List' count", on Client. #50

Open
1 of 3 tasks
paloky opened this issue Oct 28, 2024 · 2 comments
Open
1 of 3 tasks

Comments

@paloky
Copy link

paloky commented Oct 28, 2024

Node Version: 18.19.0

Node BACstack Version: 0.2.4

  • Bug Report
  • Feature Request
  • Question

Note: Make sure you have read the FAQs
before logging this issue.

Feature Request / Question

Hi. I try to use this library as a Server.

I have problems returning data to client inside callback"readProperty".

I using YABE as a client. I can detect my server, but when I try to obtain the instances object the YABE show me the error "Couldn,t read 'Object List' count".

How can I return the Object List of instances ??
Can you help me with an example.

This is my test code

    server.on('readProperty', (request) => {    
    
      console.log('\r\n\r\nReceived "readProperty" !!! ');
      console.log(request);
            
      const objectId = request.payload.objectId;
      const propertyId = request.payload.property.id;
      const remote_address= request.header.sender.address;
      const invokeId = request.invokeId;
      const arrayIndex = request.payload.property.index;
                
     if (request.payload.property.id === bacnet.enum.PropertyIdentifier.OBJECT_LIST) 
     {     
           console.log("'DEVICE' request....   return array object of instancias");
    
          const objectsTable = {
             '0': { type: bacnet.enum.ObjectType.ANALOG_INPUT },
             '1': { type: bacnet.enum.ObjectType.ANALOG_OUTPUT },
             // Add more object if necessari.
           };
          console.log("ObjectTable: ", objectsTable);          
       
        const objectList = [
            { type: bacnet.enum.ApplicationTag.UNSIGNED_INTEGER, value: Object.keys(objectsTable).length }, // Number of Instances
            ...Object.keys(objectsTable).map(key => ({
                type: bacnet.enum.ApplicationTag.OBJECTIDENTIFIER,
                value: { type: objectsTable[key].type, instance: parseInt(key, 10) }
            }))
        ];
        console.log("ObjectList: ", objectsList);  

          server.readPropertyResponse(remote_address, invokeId, objectId, propertyId, objectList); 
     }             
  });

Thank's a lot !!

@DemoWearing
Copy link

DemoWearing commented Jan 21, 2025

Hello, did you get anywhere with this? I'm running into the same issue

edit: the issue was passing the propertyId instead of the full request.payload.property object

@biancode
Copy link
Collaborator

I'm sorry, we will work on this later this year. BACnet is in plan for Q3/Q4 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants