mqtt_gateways.dummy package

Module contents

A dummy gateway to test the installation setup, the loading of the configuration files, and the basic operation of the core application.

There are 2 modules:

  • dummy_interface.py defines the class dummyInterface;
  • dummy2mqtt.py which is the application launcher.

Submodules

mqtt_gateways.dummy.dummy2mqtt module

Launcher script for the dummy gateway.

Use this as a template. If the name conventions have been respected, just change all occurrences of dummy into the name of your gateway.

mqtt_gateways.dummy.dummy_interface module

The dummy interface class definition. Use it as a template.

This module defines the class dummyInterface that will be instantiated by the main gateway module. Any other code needed for the interface can be placed here or in other modules, as long as the necessary imports are included of course.

class mqtt_gateways.dummy.dummy_interface.dummyInterface(params, msgls, path)

Bases: object

Doesn’t do anything but provides a template.

The minimum requirement for the interface class is to define 2 public methods:

  • the constructor __init__ which takes 4 arguments,
  • the loop method.
Parameters:
  • params (dictionary of strings) – contains all the options from the configuration file This dictionary is initialised by the [INTERFACE] section in the configuration file. All the options in that section generate an entry in the dictionary. Use this to pass parameters from the configuration file to the interface, for example the name of a port, or the speed of a serial communication.
  • msgls (pair of lists of internalMsg objects) – these lists represent the communication bus with the core of the application. The first list should contain the incoming messages to process by this interface, and the second list can be used to send messages from this interface to the core application (and subsequently to the MQTT network). The elements of these lists should be instantiations of the internalMsg class. Use the method pop(0) to read the lists on a FIFO basis and the method append(msg) to fill the lists. The constructor should assign these lists to a local attribute that the other methods of this class can use when needed. It is strongly advised to empty the incoming list at the beginning of the process. The gateway will empty all messages of the outgoing list and attempt to send them to the MQTT system. The main reason to keep 2 lists instead of one is to simplify sending statuses while processing incoming commands one by one.
  • path (string) – the full absolute path of the launcher script This path can be used to extract the name of the application or the directory where it is located. It can be useful to the logging library to allow proper hierarchical logging or to other functions that need to find data files relative to the launcher script location.
loop()

The method called periodically by the main loop.

Place here your code to interact with your system.