Sending data to a Data Source (Senaps JSON Msg API)

Once you have set up the Data Source, you can now begin to send data to the platform. For this tutorial we will use the 'Senaps JSON Msg API' Parser. This is a very flexible parser which can create many object types. This example will deonstration the ingestion of Observation objects only.

Step 1: Initialise your connection

You will need to configure your device or service to send data to your configured Data Source. Information to aid you can be found in the information page for the Data Source under Configuration Tips. If you have set up a broker type Data Source, the Data Source service will connect to your broker, thus, configuration isn't required as you will have had to input the required information when building the Data Source .

MQTT Client Example

Username: data-source-readable-id:[email protected]
Password: (provided by you during configuration)
Hostname: messaging.senaps.eratos.com
Port: 8883 (encrypted) or 1883 (not encrypted)
SSL: enable TLS 1.2 if available, and using port 8883, or leave off if using port 1883

AMQP Client Example

Username: data-source-readable-id:[email protected]
Password: (provided by you during configuration)
Hostname: messaging.senaps.eratos.com
Virtual Host (vhost): your-group-id-here
Exchange: amq.topic
Port: 5671 (encrypted) or 5672 (not encrypted)
SSL: enable TLS 1.2 if available, and using port 5671, or leave off if using port 5672

Step 2: Send data

Loop through all variables that need to pushed and send of these payloads. Alternate results payloads can be sent if your data stream accepts them. These forms can be found here: Data Stream Data Types.

Note, the schema is specific for the default JSON decoder.

{
    "$schema": "https://csiro.au/senaps/msg-api-draft-01.json",
    "payload": {
        "pkt_type": "scalar_observation",
        "sid": "dsapi-edna.senseright.water_sensors.{unique_platform_id}.{var_name}",
        "results": [
            {
                "t": "2020-07-15T09:00:00.000Z",
                "v": 3.142
            },
            {
                "t": "2020-07-15T09:00:00.000Z",
                "v": 2.718
            }
        ]
    }
}