xSQL IoT Functions

The xSQL server provides the following functions to control the IoT runtime:

xsql_iot_enable() Turn on the IoT runtime
xsql_iot_disable() Turn off the IoT runtime
xsql_iot_enable_connection() Turn on the IoT connector
xsql_iot_disable_connection() Turn off the IoT connector
xsql_iot_connections() List the configured IoT connectors; i.e. the ways to establish connections for this node, as they are configured in the xsql config file. For server it's usually one or more listen ports, for devices - the connection string to connect the server or router
xsql_iot_list() Returns a list of active connections. i.e. the currently connected IoT nodes. For example, on the server this will be a list of connected routers or devices
xsql_iot_get_level()

Returns the device type:

  • 1 indicates top level server;
  • 65535 indicates end-point device.
  • Values between 1 and 65535 are reserved for routers
xsql_iot_set_level() Changes the level of the router at runtime
xsql_iot_get_agent_id() Returns device or server agent_id

The arguments for the following 5 functions are :

agent_id The device id to/from which the replication is initiated. Zero indicates "all devices"
non_block For "no-blocking" mode (if the send() is impossible, data is buffered in memory)
wait Wait for completion of the operation (until ack is received)
tablename The name of the table (to remove with xsql_iot_clear_class())

Note that non_block and wait cannot both be true at the same time!

xsql_iot_push(agent_id bigint, non_block boolean, wait boolean) Push modifications to a device
xsql_iot_pull(agent_id bigint, non_block boolean, wait boolean); Request modifications from the device
xsql_iot_sync(agent_id bigint, non_block boolean, wait boolean); Call xsql_iot_push() and xsql_iot_pull()
xsql_iot_clear(agent_id bigint) Remove replicated and confirmed data on the device (0 means all devices). Note that this affects only uptable's on the device and downtable's on the server
xsql_iot_clear_class(agent_id bigint, tablename string) Remove replicated and confirmed data from the specified table on the device. Note that this affects only uptable's on the device and downtable's on the server