Skip to content

Data Connectors

Name Input Params Return Data Description
resiot_dc_push String, String, String String

resiot_dc_push(String, String, String)

ResIOT allows you to push custom data over your pusher connectors. Unless you know what you're doing, you should avoid using this function as ResIOT takes care of pushing node transmissions and gateway data to your connectors automatically (except for SQL pushers).
Please notice currently, you can push custom data only to Mosquitto servers, Http pushers, Websockets, MongoDB, SQL databases and Amazon AWS IOT. There is no support for Microsoft Azure yet.

This function requires the Hex ID of your connector and a varying number of parameters depending on the nature of the connector.

Here's how to push data to your connectors.

Mosquitto Brokers, Amazon AWS IOT

You need to pass two additional parameters to the function: a Topic and a Data string parameters.

Websockets and HTTP pushers

These connectors only need a Data string parameter.

MongoDB

This connector needs only one serializable (JSON) string parameter. An error will be thrown if the string is not a valid JSON.

SQL Database Pushers

This connector accepts an unlimited number of parameters, where the first one is the query you wish to run, and the others are the query parameters which will replace the query placeholders. Due to the different nature of the database drivers used by the ResIOT engine, each type of database has different placeholders to be used in their queries. Please refer to the SQL Database Pusher.

Your public websocket

If you want to push data to your public websocket, leave the HexId field empty ( "" ) and pass an additional Data string parameter.
The data pushed will be wrapped in a JSON inside a "data" field, along with a "CommType" field with value "comm_push" and the "DT" current time.

Example
AllWorked = resiot_dc_push(HexId, Topic, Payload)
Input Parameters
 - HexId(string): The HexId of the Data Connector. If left empty, a CommType "comm_push" message will be sent to your public websocket connector.
 - Topic(string): The payload of the message (if needed).
 - Payload(string): The message body sent to the Data Connector.
Returns
 - Value (String): The function returns an empty string if no error occurred. If an error occurred, the string will contain a description of what went wrong.

HexId = "636f6e323732"          -- The HexId of the Data Connector. If left empty, a CommType "comm_push" message will be sent to your public websocket connector
Topic = "resiot/test"           -- The payload of the message (if needed)
Payload = '{"payload":"test"}'  -- The message body sent to the Data Connector
err = resiot_dc_push(HexId, Topic, Payload) --this works for amazon aws / mqtt pushers, fails for http pushers as no topic is required
resiot_debug(err) --if the string is not empty, a description of the error will be printed

err = resiot_dc_push(HexId, Payload) -- this works for http pushers, and returns an error for mqtt connecotrs
resiot_debug(err) --if the string is not empty, a description of the error will be printed

Return to index