ModularSensors > Classes > dataPublisher > DreamHostPublisher
ModularSensors > Modules > Supported Data Endpoints > DreamHostPublisher


DreamHostPublisher class

The DreamHostPublisher subclass of dataPublisher is for publishing data to the Stroud Center's now-deprecated DreamHost based live sensor data system.

Base classes

class dataPublisher
The dataPublisher class is a virtual class used by other publishers to distribute data online.

Constructors, destructors, conversion operators

DreamHostPublisher()
Construct a new DreamHost Publisher object with no members set.
DreamHostPublisher(Logger& baseLogger, uint8_t sendEveryX = 1, uint8_t sendOffset = 0) explicit
Construct a new DreamHost Publisher object.
DreamHostPublisher(Logger& baseLogger, Client* inClient, uint8_t sendEveryX = 1, uint8_t sendOffset = 0)
Construct a new DreamHost Publisher object.
DreamHostPublisher(Logger& baseLogger, const char* dhUrl, uint8_t sendEveryX = 1, uint8_t sendOffset = 0)
Construct a new DreamHost Publisher object.
DreamHostPublisher(Logger& baseLogger, Client* inClient, const char* dhUrl, uint8_t sendEveryX = 1, uint8_t sendOffset = 0)
Construct a new DreamHost Publisher object.
~DreamHostPublisher() virtual
Destroy the DreamHost Publisher object.

Public functions

String getEndpoint(void ) override
Get the destination for published data - generally the host name of the data receiver.
void setDreamHostPortalRX(const char* dhUrl)
Set the url of the DreamHost data receiver.
void printSensorDataDreamHost(Stream* stream)
This creates all of the URL parameter tags and values and writes the result to an Arduino stream.
void printDreamHostRequest(Stream* stream)
This prints a fully structured GET request for DreamHost to the specified stream.
void begin(Logger& baseLogger, Client* inClient, const char* dhUrl)
Begin the publisher - linking it to the client and logger.
void begin(Logger& baseLogger, const char* dhUrl)
Begin the publisher - linking it to the logger but not attaching a client.
int16_t publishData(Client* outClient) override
Utilizes an attached modem to make a TCP connection to the DreamHost URL and then stream out a get request over that connection.

Portions of the GET request to DreamHost

static const char* dreamhostHost protected
The host name.
static const int dreamhostPort protected
The host port.
static const char* loggerTag protected
The Stroud logger number.
static const char* timestampTagDH protected
The timestamp.

Function documentation

DreamHostPublisher(Logger& baseLogger, uint8_t sendEveryX = 1, uint8_t sendOffset = 0) explicit

Construct a new DreamHost Publisher object.

Parameters
baseLogger The logger supplying the data to be published
sendEveryX Currently unimplemented, intended for future use to enable caching and bulk publishing
sendOffset Currently unimplemented, intended for future use to enable publishing data at a time slightly delayed from when it is collected

DreamHostPublisher(Logger& baseLogger, Client* inClient, uint8_t sendEveryX = 1, uint8_t sendOffset = 0)

Construct a new DreamHost Publisher object.

Parameters
baseLogger The logger supplying the data to be published
inClient An Arduino client instance to use to print data to. Allows the use of any type of client and multiple clients tied to a single TinyGSM modem instance
sendEveryX Currently unimplemented, intended for future use to enable caching and bulk publishing
sendOffset Currently unimplemented, intended for future use to enable publishing data at a time slightly delayed from when it is collected

DreamHostPublisher(Logger& baseLogger, const char* dhUrl, uint8_t sendEveryX = 1, uint8_t sendOffset = 0)

Construct a new DreamHost Publisher object.

Parameters
baseLogger The logger supplying the data to be published
dhUrl The URL for sending data to DreamHost
sendEveryX Currently unimplemented, intended for future use to enable caching and bulk publishing
sendOffset Currently unimplemented, intended for future use to enable publishing data at a time slightly delayed from when it is collected

DreamHostPublisher(Logger& baseLogger, Client* inClient, const char* dhUrl, uint8_t sendEveryX = 1, uint8_t sendOffset = 0)

Construct a new DreamHost Publisher object.

Parameters
baseLogger The logger supplying the data to be published
inClient An Arduino client instance to use to print data to. Allows the use of any type of client and multiple clients tied to a single TinyGSM modem instance
dhUrl The URL for sending data to DreamHost
sendEveryX Currently unimplemented, intended for future use to enable caching and bulk publishing
sendOffset Currently unimplemented, intended for future use to enable publishing data at a time slightly delayed from when it is collected

String getEndpoint(void ) override

Get the destination for published data - generally the host name of the data receiver.

Returns String The URL or HOST to receive published data

void setDreamHostPortalRX(const char* dhUrl)

Set the url of the DreamHost data receiver.

Parameters
dhUrl The URL for sending data to DreamHost

void printSensorDataDreamHost(Stream* stream)

This creates all of the URL parameter tags and values and writes the result to an Arduino stream.

Parameters
stream The Arduino stream to write out the URL and parameters to.

HTML headers are not included.


void printDreamHostRequest(Stream* stream)

This prints a fully structured GET request for DreamHost to the specified stream.

Parameters
stream The Arduino stream to write out the URL and parameters to.

This includes the HTML headers.


void begin(Logger& baseLogger, Client* inClient, const char* dhUrl)

Begin the publisher - linking it to the client and logger.

Parameters
baseLogger The logger supplying the data to be published
inClient An Arduino client instance to use to print data to. Allows the use of any type of client and multiple clients tied to a single TinyGSM modem instance
dhUrl The URL for sending data to DreamHost

This can be used as an alternative to adding the logger and client in the constructor. This is slightly "safer" because we expect the publishers to be created in the "global scope" and we cannot control the order in which objects in that global scope will be created. That is, we cannot guarantee that the logger will actually be created before the publisher that wants to attach to it unless we wait to attach the publisher until in the setup or loop function of the main program. In reality, it is very unlikely that this is necessary.


void begin(Logger& baseLogger, const char* dhUrl)

Begin the publisher - linking it to the logger but not attaching a client.

Parameters
baseLogger The logger supplying the data to be published
dhUrl The URL for sending data to DreamHost

This can be used as an alternative to adding the logger and client in the constructor. This is slightly "safer" because we expect the publishers to be created in the "global scope" and we cannot control the order in which objects in that global scope will be created. That is, we cannot guarantee that the logger will actually be created before the publisher that wants to attach to it unless we wait to attach the publisher until in the setup or loop function of the main program. In reality, it is very unlikely that this is necessary.


int16_t publishData(Client* outClient) override

Utilizes an attached modem to make a TCP connection to the DreamHost URL and then stream out a get request over that connection.

Parameters
outClient An Arduino client instance to use to print data to. Allows the use of any type of client and multiple clients tied to a single TinyGSM modem instance
Returns int16_t The http status code of the response.

This depends on an internet connection already having been made and a client being available.