You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

Prerequisites:

 

Overview:

Sparkplug is an open source project developed by Cirrus Link Solutions which shows how devices or projects can be enabled to communicate with MQTT Engine and Ignition.  This example will show how data can be published via MQTT from an emulated device running on a development machine.  In addition, it will show how devices or projects can be controlled by writing to tags in Ignition.  It will also show the caveats associated with establishing/ending an MQTT session and ensuring that the tag values in Ignition are valid.

 

Example C Client:

This tutorial assumes:

  • Ignition is running and in active trial mode or using a purchased license.
  • MQTT Distributor is installed and running, using the default configuration, and in active trial mode or using a purchased license.
  • MQTT Engine is installed and running, using the default configuration, and in active trial mode or using a purchased license.

With the standalone Sparkplug example downloaded onto your development machine, change into the directory and build the application.  In order for this to work you must have a C compiler installed for your development system.  Also, this example assumes the MQTT Server running is MQTT Distributor running with it's default configuration.  If you are using a different MQTT Server, edit the following file to reflect your MQTT Server configuration:

  • sparkplug_b/stand_alone_examples/c/example.c

The most likely candidates for change are the host, username, and password.  For simplicity this example does not use or support TLS over MQTT without modifications.

 

Mosquitto is the only dependency of the sample application. It must be installed on your development machine before building the sample application.

  • Mosqutto
    • Can be downloaded here.  Included in the link are instructions for various platforms.  Make sure in the end of installation the development libraries are available on your build path.
    • This is how one would do it in Ubuntu Linux 16.04

 

 

With the above steps completed, run the following commands to get the sparkplug library and sample application:
cd ~/dev

git clone https://github.com/Cirrus-Link/Sparkplug.git
cd Sparkplug/client_libraries/c/
make
cd ~/dev/Sparkplug/sparkplug_b/stand_alone_examples/c/udt_example/


At this point the example.c file should be edited to properly reflect your MQTT server URL, port, credentials, etc.  Finally, build the application:
make





  • No labels