Loom 4 v4.5
Arduino library for Internet of Things Rapid Prototyping in environmental sensing
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
Loom_MQTT Class Reference

#include <Loom_MQTT.h>

Inheritance diagram for Loom_MQTT:
Inheritance graph
[legend]
Collaboration diagram for Loom_MQTT:
Collaboration graph
[legend]

Public Member Functions

 Loom_MQTT (Manager &man, Client &internet_client, const char *broker_address, int broker_port, const char *database_name, const char *broker_user="", const char *broker_pass="", const char *projectServer="")
 
 Loom_MQTT (Manager &man, Client &internet_client)
 
void publish ()
 
void publish (Loom_BatchSD &batchSD)
 
void setKeepAlive (int time)
 
void setMaxRetries (int retries)
 
void loadConfigFromJSON (char *json)
 
- Public Member Functions inherited from Module
 Module (const char *modName)
 
void setModuleName (const char *modName)
 
virtual const char * getModuleName ()
 
virtual void printModuleName (const char *message)
 
virtual void initialize ()=0
 
virtual void measure ()=0
 
virtual void package ()=0
 
virtual void power_up ()=0
 
virtual void power_down ()=0
 
virtual void display_data ()
 

Protected Member Functions

void measure () override
 
void initialize () override
 
void power_up () override
 
void power_down () override
 
void package () override
 

Additional Inherited Members

- Public Attributes inherited from Module
bool moduleInitialized = true
 
int module_address = -1
 

Detailed Description

Platform for logging data to MQTT for logging to a remote database

Author
Will Richards

Constructor & Destructor Documentation

◆ Loom_MQTT() [1/2]

Loom_MQTT::Loom_MQTT ( Manager man,
Client &  internet_client,
const char *  broker_address,
int  broker_port,
const char *  database_name,
const char *  broker_user = "",
const char *  broker_pass = "",
const char *  projectServer = "" 
)

Construct a new MQTT interface

Parameters
manReference to the manager
internet_clientReference to whatever connectivity platform is being used
broker_addressDomain where the broker is being hosted
broker_portPort that the broker is listening on
database_nameName of the database that will be used by MongoDB

Not Required:

Parameters
broker_userUser name to log into the broker
broker_passPassword to log into the broker

◆ Loom_MQTT() [2/2]

Loom_MQTT::Loom_MQTT ( Manager man,
Client &  internet_client 
)

Construct a new MQTT interface, expects credentials to be loaded from JSON

Parameters
manReference to the manager

Member Function Documentation

◆ initialize()

void Loom_MQTT::initialize ( )
inlineoverrideprotectedvirtual

Implements Module.

◆ loadConfigFromJSON()

void Loom_MQTT::loadConfigFromJSON ( char *  json)

Load the MQTT credentials from a JSON string, used to pull credentials from a file

Parameters
jsonStringJSON formatted string containing the login credentials, this is freed at the end

◆ measure()

void Loom_MQTT::measure ( )
inlineoverrideprotectedvirtual

Implements Module.

◆ package()

void Loom_MQTT::package ( )
inlineoverrideprotectedvirtual

Implements Module.

◆ power_down()

void Loom_MQTT::power_down ( )
inlineoverrideprotectedvirtual

Implements Module.

◆ power_up()

void Loom_MQTT::power_up ( )
inlineoverrideprotectedvirtual

Implements Module.

◆ publish() [1/2]

void Loom_MQTT::publish ( )

Publish the current JSON data over MQTT

◆ publish() [2/2]

void Loom_MQTT::publish ( Loom_BatchSD batchSD)

Publish the current JSON data as a batch

◆ setKeepAlive()

void Loom_MQTT::setKeepAlive ( int  time)
inline

Length of time the broker should keep the connection open for default

Parameters
timeLength of time in MILLISECONDS the connection will be kept open

◆ setMaxRetries()

void Loom_MQTT::setMaxRetries ( int  retries)
inline

Set the maximum number of reconnection attempts to make before failing

Parameters
retriesThe number of retries we want to make

The documentation for this class was generated from the following files: