#include <src/publishers/UbidotsPublisher.h>
UbidotsPublisher
class
The UbidotsPublisher subclass of dataPublisher for publishing data to the Ubidots data portal at https:/
Base classes
- class dataPublisher
- The dataPublisher class is a virtual class used by other publishers to distribute data online.
Constructors, destructors, conversion operators
- UbidotsPublisher()
- Construct a new Ubidots Publisher object with no members set.
- UbidotsPublisher(Logger& baseLogger, int sendEveryX = 1) explicit
- Construct a new Ubidots Publisher object.
- UbidotsPublisher(Logger& baseLogger, Client* inClient, int sendEveryX = 1)
- Construct a new Ubidots Publisher object.
- UbidotsPublisher(Logger& baseLogger, const char* authentificationToken, const char* deviceID, int sendEveryX = 1)
- Construct a new Ubidots Publisher object.
- UbidotsPublisher(Logger& baseLogger, Client* inClient, const char* authentificationToken, const char* deviceID, int sendEveryX = 1)
- Construct a new Ubidots Publisher object.
- ~UbidotsPublisher() virtual
- Destroy the EnviroDIY Publisher object.
Public functions
- String getEndpoint(void) -> String override
- Get the destination for published data - generally the host name of the data receiver.
- void setToken(const char* authentificationToken)
- Set the device authentication token.
- uint16_t calculateJsonSize() -> uint16_t
- Calculates how long the outgoing JSON will be.
- void begin(Logger& baseLogger, Client* inClient, const char* authentificationToken, const char* deviceID)
- Begin the publisher - linking it to the client and logger.
- void begin(Logger& baseLogger, const char* authentificationToken, const char* deviceID)
- Begin the publisher - linking it to the logger but not attaching a client.
- int16_t publishData(Client* outClient) -> int16_t override
- Utilize an attached modem to open a a TCP connection to the Ubidots API and then stream out a post request over that connection.
Portions of the POST request to Ubidots
- static const char* postEndpoint protected
- The endpoint.
- static const char* ubidotsHost protected
- The host name.
- static const int ubidotsPort protected
- The host port.
- static const char* tokenHeader protected
- The token header text.
- static const char* contentLengthHeader protected
- The content length header text.
- static const char* contentTypeHeader protected
- The content type header text.
The begining of the JSON object for Ubidots
- static const char* payload protected
- The JSON initial characters.
Function documentation
UbidotsPublisher:: UbidotsPublisher(Logger& baseLogger,
int sendEveryX = 1) explicit
Construct a new Ubidots Publisher object.
Parameters | |
---|---|
baseLogger | The logger supplying the data to be published |
sendEveryX | Interval (in units of the logging interval) between attempted data transmissions. NOTE: not implemented by this publisher! |
UbidotsPublisher:: UbidotsPublisher(Logger& baseLogger,
Client* inClient,
int sendEveryX = 1)
Construct a new Ubidots 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 | Interval (in units of the logging interval) between attempted data transmissions. NOTE: not implemented by this publisher! |
UbidotsPublisher:: UbidotsPublisher(Logger& baseLogger,
const char* authentificationToken,
const char* deviceID,
int sendEveryX = 1)
Construct a new Ubidots Publisher object.
Parameters | |
---|---|
baseLogger | The logger supplying the data to be published |
authentificationToken | The authentication token from Ubdots, either the Organization's Integration Token (under Users > Organization menu, visible by Admin only) OR the STEM User's Device Token (under the specific device's setup panel). |
deviceID | The device API Label from Ubidots, derived from the user-specified device name. |
sendEveryX | Interval (in units of the logging interval) between attempted data transmissions. NOTE: not implemented by this publisher! |
UbidotsPublisher:: UbidotsPublisher(Logger& baseLogger,
Client* inClient,
const char* authentificationToken,
const char* deviceID,
int sendEveryX = 1)
Construct a new Ubidots 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 |
authentificationToken | The authentication token from Ubdots, either the Organization's Integration Token (under Users > Organization menu, visible by Admin only) OR the STEM User's Device Token (under the specific device's setup panel). |
deviceID | The device API Label from Ubidots, derived from the user-specified device name. |
sendEveryX | Interval (in units of the logging interval) between attempted data transmissions. NOTE: not implemented by this publisher! |
String UbidotsPublisher:: 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 UbidotsPublisher:: setToken(const char* authentificationToken)
Set the device authentication token.
Parameters | |
---|---|
authentificationToken | The authentication token from Ubdots, either the Organization's Integration Token (under Users > Organization menu, visible by Admin only) OR the STEM User's Device Token (under the specific device's setup panel). |
uint16_t UbidotsPublisher:: calculateJsonSize()
Calculates how long the outgoing JSON will be.
Returns | uint16_t The number of characters in the JSON object. |
---|
void UbidotsPublisher:: begin(Logger& baseLogger,
Client* inClient,
const char* authentificationToken,
const char* deviceID)
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 |
authentificationToken | The authentication token from Ubdots, either the Organization's Integration Token (under Users > Organization menu, visible by Admin only) OR the STEM User's Device Token (under the specific device's setup panel). |
deviceID | The device API Label from Ubidots, derived from the user-specified device name. |
This can be used as an alternative to adding the logger and client in the constructor.
void UbidotsPublisher:: begin(Logger& baseLogger,
const char* authentificationToken,
const char* deviceID)
Begin the publisher - linking it to the logger but not attaching a client.
Parameters | |
---|---|
baseLogger | The logger supplying the data to be published |
authentificationToken | The authentication token from Ubdots, either the Organization's Integration Token (under Users > Organization menu, visible by Admin only) OR the STEM User's Device Token (under the specific device's setup panel). |
deviceID | The device API Label from Ubidots, derived from the user-specified device name. |
This can be used as an alternative to adding the logger and client in the constructor.
int16_t UbidotsPublisher:: publishData(Client* outClient) override
Utilize an attached modem to open a a TCP connection to the Ubidots API and then stream out a post 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.