Command and Control =================== The data logger can be controlled over MQTT by publishing commands to a Command and Control (``cc``) topic. The API allows for remote configuration and data collection. This documentation is written from the perspective of the data logger. MQTT topic structures are case-sensitive and must be specified exactly as documented. :guilabel:`Publish` - The data logger publishes to the specified topic. :guilabel:`Subscribe` - The data logger subscribes to the specified topic. CC Topic -------- To send a command to a data logger, a specific JSON message must be published. The data logger will automatically subscribe to the ``cc`` topics when connecting to a broker. Generic Topic Structure ~~~~~~~~~~~~~~~~~~~~~~~ :guilabel:`Topic Structure` ``/cc///`` .. admonition:: Properties - **** Configured in the data logger settings. **Default**: ``cs/v2`` - **** ``cc`` Command and Control - **** A unique identifier for the data logger. - ```` (e.g., A1b2-C3d4-E5f6) - ``/`` when a UID is not configured - **** A keyword indicating the specific action to be executed. - **** (*Optional*) This field is used to correlate command-and-control responses. - **If Present** in the command payload, the ```` is included in the response topic. - **If Absent** the response omits the ```` from the topic. - Length: 39 ASCII character max. Generic Command Format ~~~~~~~~~~~~~~~~~~~~~~ All commands must be sent in JSON format. Typically, a command is invoked by publishing a JSON payload to an MQTT topic that includes the command in the topic structure. **Example (OS Command) [Preferred Method]** :guilabel:`Subscribe` ``/cc//OS <---'OS' command included in topic`` .. code-block:: json { "url":"https://DataThings.com/Operating_Systems/CR6.14.2.0.obj" } The data logger also supports commands published to the generic ``cc`` topic **without** specifying the command in the topic path. In this case, the command must be explicitly stated in the JSON payload using the command key:value pair. ``"cmd":"string"`` **Example (OS Command) [Optional Method]** :guilabel:`Subscribe` ``/cc// <---'OS' command excluded from topic [ ends with '/']`` .. code-block:: json { "cmd":"OS", "url":"https://DataThings.com/Operating_Systems/CR6.14.2.0.obj" } CR Topic -------- After the data logger has received a message on the ``cc`` topic, it publishes a response on the Command Response ``cr`` topic. The ``cr`` topic follows a structure similar to the ``cc`` topic, with specific differences outlined. .. code-block:: text /cr/// .. admonition:: Properties - **** Configured in the data logger settings. Default - ``cs/v2`` - **** ``cr`` Command Response - **** A unique identifier for the data logger. - ```` (e.g., A1b2-C3d4-E5f6) - ``/`` when a UID is not configured - **** A keyword indicating the specific action to be executed. - **** (*Optional*) This field is used to correlate command-and-control responses. - **If Present** in the command payload, the ```` is included in the response topic. - **If Absent** the response omits the ```` from the topic. Command Set ----------- The data logger supports the following set of commands. .. toctree:: :maxdepth: 1 commands/commands_variables.rst commands/commands_const_table.rst commands/commands_public_table.rst commands/commands_settings.rst commands/commands_file_control.rst commands/commands_historic_data.rst commands/commands_crbasic_program.rst commands/commands_operating_system.rst commands/commands_recipe.rst commands/commands_status.rst commands/commands_metadata.rst commands/commands_system.rst