MQTTPublishTable()
==================
The instruction is inserted between the DataTable and EndTable instructions to publish the contents of a data table.
.. note::
If you are sending data to CampbellCloud with MQTTAutoPublish enabled, do not use MQTTPublishTable().
See ``MQTT Auto-Publish Data`` details in :doc:`Settings `.
.. admonition:: Syntax
``MQTTPublishTable(QoS, NumRecs/TimeIntoInterval, Interval, Units, OutputFormat, Longitude, Latitude, Altitude)``
- ``QoS`` (*Constant Integer*)
Specifies the MQTT *Quality of Service* (QoS) level.
- ``0`` — At most once (fire-and-forget)
- ``1`` — At least once
- ``2`` — Not supported
- ``NumRecs/TimeIntoInterval`` (*Constant Integer*)
Controls record count and record-driven publishing behavior.
See the behavior matrix for details.
- ``Interval`` (*Constant*)
Controls whether publishing is record-driven or interval-driven.
See the behavior matrix for details.
.. list-table:: Interval - NumRecs/TII - Behavior Matrix
:header-rows: 1
:stub-columns: 1
:widths: 18 18 12 70
* - Trigger
- NumRecs / TII
- Interval
- Behavior
* - Record-driven
- n > 0
- n = 0
- Specifies the number of new records to accumulate before publishing.
* - Record-driven
- n < 0
- n = 0
- Specifies a data window width (number of records to always publish). After the initial wait for the specified number of new records, each new record shifts the window forward by replacing the oldest record with the newest record (sliding window behavior).
* - Record-driven
- n = 0
- n = 0
- Publishes the most recent records each time the table is called.
* - Interval-driven
- n > 0
- n > 0
- Publishes previously unsent records at the specified time within the interval.
* - Note
- —
- —
- The datalogger includes handling for intermittent communications. See **MQTTBackfillMode** details in :doc:`Settings `.
- ``Units`` (*Constant*)
Specifies the units on which the ``TimeIntoInterval`` and ``Interval`` parameters are based.
Valid options are:
- ``Seconds``
- ``Minutes``
- ``Hours``
- ``Days``
- ``OutputFormat`` (*Constant Integer*)
Specifies the format used for published data and affects the topic structure.
- ``1`` — CSIJSON (``/cj`` is appended to the topic)
- ``2`` — GeoJSON
- ``3`` — BASICJSON
- ``Longitude`` (*Constant or Variable*) *(Optional)*
- 0 to −180 west of the Greenwich meridian
- 0 to 180 east of the Greenwich meridian
- ``Latitude`` (*Constant or Variable*) *(Optional)*
- 0 to 90 Northern Hemisphere
- 0 to −90 Southern Hemisphere
- ``Altitude`` (*Constant or Variable*) *(Optional)*
Station altitude value (unitless; interpreted as meters by CampbellCloud).
.. note::
The Longitude, Latitude, and Altitude parameters apply only when using the GeoJSON output format.
If using GeoJSON and the values are unknown, enter a null string ``" "``.
Topic Structures
----------------
CSIJSON: ``/data///cj``
GeoJSON: ``/data//``
BASICJSON: ``/data//``
CRBasic Examples
----------------
- Most recent record every 30 seconds (CSIJSON)
.. code-block:: basic
DataTable (loggerBattery, True, -1)
DataInterval (0, 30, Sec, 10)
Sample (1, batteryVolt, FP2)
MQTTPublishTable (1, -1, 0, Sec, 1)
EndTable
- Most recent record every 30 seconds (GeoJSON)
.. code-block:: basic
Const LONGITUDE = -111.8549
Const LATITUDE = 41.7666
Const ALTITUDE = 1357 ' meters
DataTable (loggerBattery, True, -1)
DataInterval (0, 30, Sec, 10)
Sample (1, batteryVolt, FP2)
MQTTPublishTable (1, -1, 0, Sec, 2, LONGITUDE, LATITUDE, ALTITUDE)
EndTable
- Most recent record every 30 seconds (BASICJSON)
.. code-block:: basic
DataTable (loggerBattery, True, -1)
DataInterval (0, 30, Sec, 10)
Sample (1, batteryVolt, FP2)
MQTTPublishTable (1, -1, 0, Sec, 3)
EndTable