Adafruit IO Arduino Library
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
AdafruitIO Class Referenceabstract

Class for interacting with Adafruit IO. More...

#include <AdafruitIO.h>

Inheritance diagram for AdafruitIO:
AdafruitIO_Ethernet AdafruitIO_FONA

Public Member Functions

 AdafruitIO (const char *user, const char *key)
 Instantiate the AIO object. More...
 
virtual ~AdafruitIO ()
 Destructor to end the AIO object.
 
void connect ()
 Connects to AIO, setting up using parameters set when the class is instantiated.
 
void wifi_disconnect ()
 Disconnects from WiFi.
 
aio_status_t run (uint16_t busywait_ms=0, bool fail_fast=false)
 Must be called frequently to keep AIO connections alive. When called with no arguments run() will try to repair MQTT and WiFi connections before returning. To avoid potentially long timeout delays, sketches can use the busywait_ms and fail_fast arguments to return an imperfect status quickly. The calling sketch will then need to respond appropriately to that status. More...
 
AdafruitIO_Feedfeed (const char *name)
 Create a new AIO feed. More...
 
AdafruitIO_Feedfeed (const char *name, const char *owner)
 Create a new AIO feed. More...
 
AdafruitIO_Groupgroup (const char *name)
 Create a new AIO group. More...
 
AdafruitIO_Dashboarddashboard (const char *name)
 Create a new AIO dashboard. More...
 
AdafruitIO_Timetime (aio_time_format_t format)
 Create a new AIO time. More...
 
const __FlashStringHelper * statusText ()
 Provide status explanation strings. More...
 
aio_status_t status ()
 Status check. More...
 
virtual aio_status_t networkStatus ()=0
 Returns network module status. More...
 
aio_status_t mqttStatus (bool fail_fast=false)
 Returns MQTT connection status. More...
 
char * boardID ()
 Identify the board. More...
 
const char * boardType ()
 Identify the board type. More...
 
char * version ()
 Identify the software version. More...
 
char * userAgent ()
 Identify the user agent. More...
 
virtual const char * connectionType ()=0
 Returns the Adafruit IO network module connection type. More...
 

Protected Member Functions

virtual void _connect ()=0
 Establishes a connection with the Adafruit IO MQTT broker. More...
 
virtual void _disconnect ()=0
 Disconnects from the Adafruit IO MQTT broker. More...
 

Protected Attributes

aio_status_t _status = AIO_IDLE
 
uint32_t _last_ping
 
uint32_t _last_mqtt_connect = 0
 
Adafruit_MQTT * _mqtt
 
HttpClient * _http
 
char _version [10]
 
const char * _host = "io.adafruit.com"
 
uint16_t _mqtt_port = 8883
 
uint16_t _mqtt_eth_port
 
uint16_t _http_port = 443
 
uint16_t _packetread_timeout
 
const char * _username
 
const char * _key
 
char * _err_topic
 
char * _throttle_topic
 
char * _user_agent
 
Adafruit_MQTT_Subscribe * _err_sub
 
Adafruit_MQTT_Subscribe * _throttle_sub
 

Friends

class AdafruitIO_Block
 AdafruitIO_Block addition.
 

Detailed Description

Class for interacting with Adafruit IO.

Constructor & Destructor Documentation

◆ AdafruitIO()

AdafruitIO::AdafruitIO ( const char *  user,
const char *  key 
)

Instantiate the AIO object.

Parameters
userA pointer to a constant AIO user name.
keyA pointer to a constant key for the user name.

Member Function Documentation

◆ run()

aio_status_t AdafruitIO::run ( uint16_t  busywait_ms = 0,
bool  fail_fast = false 
)

Must be called frequently to keep AIO connections alive. When called with no arguments run() will try to repair MQTT and WiFi connections before returning. To avoid potentially long timeout delays, sketches can use the busywait_ms and fail_fast arguments to return an imperfect status quickly. The calling sketch will then need to respond appropriately to that status.

Parameters
busywait_msThe packet read timeout, optional.
fail_fastSet true to skip retries and return with status immediately, optional.
Returns
AIO status value

◆ feed() [1/2]

AdafruitIO_Feed * AdafruitIO::feed ( const char *  name)

Create a new AIO feed.

Parameters
nameThe AIO name of the feed.
Returns
A pointer to the feed.

◆ feed() [2/2]

AdafruitIO_Feed * AdafruitIO::feed ( const char *  name,
const char *  owner 
)

Create a new AIO feed.

Parameters
nameThe AIO name of the feed.
ownerThe AIO name of the user that owns the feed, if not the current user.
Returns
A pointer to the feed.

◆ group()

AdafruitIO_Group * AdafruitIO::group ( const char *  name)

Create a new AIO group.

Parameters
nameThe AIO name of the group.
Returns
A pointer to the group.

◆ dashboard()

AdafruitIO_Dashboard * AdafruitIO::dashboard ( const char *  name)

Create a new AIO dashboard.

Parameters
nameThe AIO name of the dashboard.
Returns
A pointer to the dashboard.

◆ time()

AdafruitIO_Time * AdafruitIO::time ( aio_time_format_t  format)

Create a new AIO time.

Parameters
formatA format specifier.
Returns
A pointer to the time.

◆ statusText()

const __FlashStringHelper * AdafruitIO::statusText ( )

Provide status explanation strings.

Returns
A pointer to the status string, _status. _status is the AIO status value

◆ status()

aio_status_t AdafruitIO::status ( )

Status check.

Returns
An AIO status value. Lower values represent poorer connection status.

◆ networkStatus()

virtual aio_status_t AdafruitIO::networkStatus ( )
pure virtual

Returns network module status.

Returns
0

Implemented in AdafruitIO_FONA, and AdafruitIO_Ethernet.

◆ mqttStatus()

aio_status_t AdafruitIO::mqttStatus ( bool  fail_fast = false)

Returns MQTT connection status.

Checks connection status with Adafruit IO's MQTT broker.

Parameters
fail_fastSet true to skip retries and return with status immediately.
Returns
True if connected, otherwise False.

◆ boardID()

char * AdafruitIO::boardID ( )

Identify the board.

Returns
A board ID

◆ boardType()

const char * AdafruitIO::boardType ( )

Identify the board type.

Returns
A board type

◆ version()

char * AdafruitIO::version ( )

Identify the software version.

Returns
A pointer to a version number string.

◆ userAgent()

char * AdafruitIO::userAgent ( )

Identify the user agent.

Returns
A pointer to a user agent string.

◆ connectionType()

virtual const char* AdafruitIO::connectionType ( )
pure virtual

Returns the Adafruit IO network module connection type.

Returns
0

Implemented in AdafruitIO_FONA, and AdafruitIO_Ethernet.

◆ _connect()

virtual void AdafruitIO::_connect ( )
protectedpure virtual

Establishes a connection with the Adafruit IO MQTT broker.

Returns
0

Implemented in AdafruitIO_FONA, and AdafruitIO_Ethernet.

◆ _disconnect()

virtual void AdafruitIO::_disconnect ( )
protectedpure virtual

Disconnects from the Adafruit IO MQTT broker.

Returns
0

Implemented in AdafruitIO_FONA, and AdafruitIO_Ethernet.

Member Data Documentation

◆ _status

aio_status_t AdafruitIO::_status = AIO_IDLE
protected

Adafruit IO Connection Status

◆ _last_ping

uint32_t AdafruitIO::_last_ping
protected
Initial value:
=
0

Previous time when client pinged Adafruit IO, in milliseconds

◆ _last_mqtt_connect

uint32_t AdafruitIO::_last_mqtt_connect = 0
protected

Previous time when client connected to Adafruit IO, in milliseconds

◆ _mqtt

Adafruit_MQTT* AdafruitIO::_mqtt
protected

Reference to Adafruit_MQTT, _mqtt.

◆ _http

HttpClient* AdafruitIO::_http
protected

Reference to HTTPClient, _http

◆ _version

char AdafruitIO::_version[10]
protected

Adafruit IO Arduino library version

◆ _host

const char* AdafruitIO::_host = "io.adafruit.com"
protected

Adafruit IO URL

◆ _mqtt_port

uint16_t AdafruitIO::_mqtt_port = 8883
protected

Adafruit IO MQTT SSL port

◆ _mqtt_eth_port

uint16_t AdafruitIO::_mqtt_eth_port
protected
Initial value:
=
1883

Adafruit IO MQTT insecure port, used by ethernet clients.

◆ _http_port

uint16_t AdafruitIO::_http_port = 443
protected

Adafruit IO HTTP SSL port

◆ _packetread_timeout

uint16_t AdafruitIO::_packetread_timeout
protected

Maximum amount of time to wait before processing packets.

◆ _username

const char* AdafruitIO::_username
protected

Adafruit IO Username.

◆ _key

const char* AdafruitIO::_key
protected

Adafruit IO Key.

◆ _err_topic

char* AdafruitIO::_err_topic
protected

Adafruit IO MQTT error message topic.

◆ _throttle_topic

char* AdafruitIO::_throttle_topic
protected

Adafruit IO MQTT throttle message topic.

◆ _user_agent

char* AdafruitIO::_user_agent
protected

Identifies the Adafruit IO client.

◆ _err_sub

Adafruit_MQTT_Subscribe* AdafruitIO::_err_sub
protected

Subscription to Adafruit IO Error topic.

◆ _throttle_sub

Adafruit_MQTT_Subscribe* AdafruitIO::_throttle_sub
protected

Subscription to Adafruit IO Throttle topic.


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