NodeJS API reference Guide¶

The name of the NodeJS module required to write DA app in Java script is ziotc

  • ziotc

    • ziotc.run

      Run(onErrorCallback, onOkCallback, onNewMessageCallback, onPassthruCallback)
      

      Registers the callback functions with the ziotc module and starts the background worker.

      onErrorCallback:

      Type: const onErrorCallback = (msg) =>{}

      Description: callback function that gets called when an error is encountered. The function gets a string argument msg that contains the description of the error.

      onOkCallback:

      Type: const onOkCallback = (msg) =>{}

      Description: callback function that gets called when the module ends. The function gets a string argument msg that contains the description of the error.

      onNewMessageCallback:

      Type: const onNewMessageCallback = (msg) =>{}

      Description: callback function that gets called when an event has occured. the event can be either a data event or a GPI event, depending on whether the GPI events are enabled. refer to EnableGPIEvents for more information. The function is passed a json object in argument msg that contains the information on the type of event and the event data.

      The JSON object has the below schema

      {
          "type": <int>,
          "msg": <object>
      }
      

      The type field in the above message can have value 0 for data events and 6 for GPI events.

      onPassthruCallback:

      Type: const onPassthruCallback = (msg) =>{}

      Description: callback function that gets called when a message intended to the userapp is sent via the ZIOTC management interface using the set_reqToUserapp command. The function gets a string argument msg that contains the message sent to the application using set_reqToUserapp command. The application can respond back to the command using SendResponse method described below.

    • ziotc.stop

      Stop()
      

      Stops the ziotc module.

    • ziotc.SendNextMessage

      SendNextMessage(msg)
      

      Sends a message to the Reader Gateway. The msg argument must contain type and message fields. The type field indicates what kind of message is being sent out. The following values for type are supported.

      ZIOTC_MSG_TYPE_DATA = 3 indicates the message is a data event and must be sent to the data interface. This is used to send data out of the reader after processing on the DA app is complete. ZIOTC_MSG_TYPE_CTRL = 4 indicates the message is a management event and must be sent on the management event interface. This can be used to send asynchronous events originating from the app (Ex: heartbeats for app). ZIOTC_MSG_TYPE_GPO = 5 indicates the message is a GPO/LED control message to be processed by the reader to control the GPO/LED as specified in the message field.

      In case the type field is set to ZIOTC_MSG_TYPE_GPO, then the message can contain an object to control GPO/LED as below.

      {
          "type": "LED",
          "led": 3,
          "color": "AMBER",
          "postActionColor": "AMBER"
      }
      
    • ziotc.SendResponse

      SendResponse(msg)
      

      Sends a response to the passthrough message received.

      msg:

      Type: string

      Description: A string response to the passthough message.

    • ziotc.EnableGPIEvents

      EnableGPIEvents()
      

      Enables the GPI events. On each GPI event the app will be notified via the onNewMessageCallback registered using the ziotc.run method.

    • ziotc.DisableGPIEvents

      DisableGPIEvents()
      

      Disables the GPI events. The App will not be notified of the GPI transitions.

    • ziotc.SetDataSource

      SetDataSource(data_source_type)
      

      Sets the DA Application’s Data Source.

      data_source_type:

      Type: string

      Description: A string defining the data source. Accepted strings include:

      • CONNECT_TO_NOTHING When used, the DA app will not receive callbacks on tag read events. This is ideal for apps that do not want to process tag data on the reader.

      • CONNECT_FOR_RADIO_DATA When used the DA app will receive callback on tag read events and the data format will be as documented in Tag Data Events. This is to be used, when the DA app does not intend to process directionality data.

      • CONNECT_FOR_DIRECTIONALITY_DATA This is supported only on ATR7000. When used the DA app will receive callbacks on tag data events and the data format will be as documented in the directionality data schema. This is to be used when the DA app intends to process the directionality data on an ATR7000.

      Important

      The Data source is set to CONNECT_FOR_RADIO_DATA by default