Skip to content

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

@paloky

Description

@paloky

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 !!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions