The IoT interface for Python resembles its underlying C API layer. It consists of 3 classes: IoTCommunicator, IoTReplicator and IoTConnection which are described in detail in the pages linked to the table below.
For an overview see page ARF Applications
To enable IoT support in the eXtremeDB core and Python wrapper, use parameter
iot=True
for theexdb.init_runtime
() method:exdb.init_runtime(disk=is_disk, tmgr=tmgr, shm=False, iot=True, debug=is_debug)Then open the database specifying an
iot_agent_id
parameter:db = exdb.open_database(dbname=db_name, dictionary=dbdict, is_disk=is_disk, db_segment_size=ROUTER_DATABASE_SIZE, iot_agent_id=agent_id, iot_level=2)An IoT server application typically instantiates an IoTCommunicator and IoTReplicator, then calls the IoTCommunicator method
listen()
to wait for and manage communications from the device(s). To terminate operations, call thestop()
anddestroy()
methods of both IoTCommunicator and IoTReplicator . For example:with db.connect() as con: comm = exdb.IoTCommunicator() repl = exdb.IoTReplicator(con=con, comm=comm) print "Start listening on the port 15000" comm.listen("15000") ... repl.stop() comm.stop() repl.destroy() comm.destroy()IoT device applications typically instantiate an IoTReplicator and call its
connect()
andsync()
methods to synchronize with the server database. To terminate operations the IoTReplicator calls methodsstop()
anddestroy()
. For example:with db.connect() as con: repl = exdb.IoTReplicator(con) repl.connect(conn_string, 2*1000) ... repl.sync(exdb.IoT.SERVER_AGENT_ID, exdb.IoT.SYNC_PUSH | exdb.IoT.SYNC_PULL | exdb.IoT.SYNC_WAIT) ... repl.stop() repl.destroy()IoT support classes:
IoTCommunicator Manage the communications between IoT server and devices
IoTReplicator Manages the replication process, interfacing with the IoTCommunicator on one side and with the database on the other IoTConnection Create a connection between an IoT device and server