Python API reference Guide¶

The name of the Python module required to write DA app in python is pyziotc. An instance of the Ziotc class must be created and methods can be accessed using the Ziotc class. Howrver, A parameter may be passed to the class object during creation to set the data source as described below.

  • class pyziotc.Ziotc

    • __init__()

      The pyziotc.Ziotc consists of a parameterized constructor. The parameter sets the DA Application’s Data Source.

      zObject = pyziotc.Ziotc(pyziotc.CONNECT_FOR_RADIO_DATA)
      
      data_source_type:

      Type: constructor parameter

      Description: A parameter defining the data source. Accepted types 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 (in the absence of a parameter)

    • reg_pass_through_callback

      reg_pass_through_callback(<callback_func>)
      

      Registers the passthrough callback function with the ziotc module.

      callback_func:

      Type: def callback_func(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 by returning a string from the callback method.

    • reg_new_msg_callback

      reg_new_msg_callback(<callback_func>)
      

      Registers a callback function with the ziotc module that gets called on every new message from radio control.

      callback_func:

      Type: def callback_func(msg_type, msg):

      Description: callback function that gets called when an event has occured. the event can be either a data event or a GPI event. The function is passed two arguments msg_type that contains the information on the type of event and msg contains the event data.

      The msg_type parameter can have values 0 for data events and 6 for GPI events.

    • send_next_msg

      send_next_msg(msg_type, msg)
      

      Sends a message to the Reader Gateway. The msg_type parameter indicates what kind of message is being sent out. The following values for type are supported. The msg field is the actual message that is sent out.

      MSG_OUT_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. MSG_OUT_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). MSG_OUT_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 MSG_OUT_GPO, then the message can contain an object to control GPO/LED as below.

      {
          "type": "LED",
          "led": 3,
          "color": "AMBER",
          "postActionColor": "AMBER"
      }
      
      {
          "type": "GPO",
          "pin": 1,
          "state": "HIGH",
          "postActionState": "LOW"
      }
      
    • enableGPIEvents

      enableGPIEvents()
      

      Registers with the IoT Connector that the DA app is interested in receiving GPI events. If GPI events are enabled, whenever GPI events occur the new_msg_callback is called with the msg_type set to MSG_IN_GPI and the msg contains the details of the GPI event.

    • disableGPIEvents

      disableGPIEvents()
      

      Registers with the IoT Connector that the DA app is NOT interested in receiving GPI events. If GPI events are disabled, then no GPI events are sent to the DA app.