Adafruit IO Arduino Library
AdafruitIO_Feed.h
Go to the documentation of this file.
1 
15 #ifndef ADAFRUITIO_FEED_H
16 #define ADAFRUITIO_FEED_H
17 
18 #include "AdafruitIO_Data.h"
19 #include "AdafruitIO_Definitions.h"
20 #include "AdafruitIO_MQTT.h"
21 #include "Adafruit_MQTT.h"
22 #include "Arduino.h"
23 
24 // forward declaration
25 class AdafruitIO;
26 
27 /**************************************************************************/
33 /**************************************************************************/
35 
36 public:
37  AdafruitIO_Feed(AdafruitIO *io, const char *name);
38  AdafruitIO_Feed(AdafruitIO *io, const char *name, const char *owner);
39 
41 
42  bool save(char *value, double lat = 0, double lon = 0, double ele = 0);
43  bool save(bool value, double lat = 0, double lon = 0, double ele = 0);
44  bool save(String value, double lat = 0, double lon = 0, double ele = 0);
45  bool save(int value, double lat = 0, double lon = 0, double ele = 0);
46  bool save(unsigned int value, double lat = 0, double lon = 0, double ele = 0);
47  bool save(long value, double lat = 0, double lon = 0, double ele = 0);
48  bool save(unsigned long value, double lat = 0, double lon = 0,
49  double ele = 0);
50  bool save(float value, double lat = 0, double lon = 0, double ele = 0,
51  int precision = 6);
52  bool save(double value, double lat = 0, double lon = 0, double ele = 0,
53  int precision = 6);
54 
55  bool get();
56 
57  bool exists();
58  bool create();
59 
60  void setLocation(double lat, double lon, double ele = 0);
61 
63  void subCallback(char *val, uint16_t len);
64 
65  const char *name;
66  const char *owner;
71 private:
73  _dataCallback;
75  void _init();
76 
77  char *_topic;
78  char *_get_topic;
79  char *_create_url;
80  char *_feed_url;
82  Adafruit_MQTT_Subscribe *_sub;
83  Adafruit_MQTT_Publish *_pub;
84  Adafruit_MQTT_Publish *_get_pub;
86  AdafruitIO *_io;
87  AdafruitIO_Data *_data;
88 };
89 
90 #endif // ADAFRUITIO_FEED_H
Class for interacting with Adafruit IO.
Definition: AdafruitIO.h:45
~AdafruitIO_Feed()
Adafruit IO Feed destructor.
Definition: AdafruitIO_Feed.cpp:62
bool create()
Creates a new Adafruit IO Feed https://io.adafruit.com/api/docs/#create-feed.
Definition: AdafruitIO_Feed.cpp:313
Class that provides methods for interfacing with Adafruit IO feed topics. https://io.adafruit.com/api/docs/mqtt.html#mqtt-topics.
Definition: AdafruitIO_Feed.h:34
friend class AdafruitIO_Feed
AdafruitIO_Feed addition.
Definition: AdafruitIO.h:50
void subCallback(char *val, uint16_t len)
Calls _datacallback if new data is avaliable on feed.
Definition: AdafruitIO_Feed.cpp:408
Class that contains MQTT subscription callbacks.
Definition: AdafruitIO_MQTT.h:25
bool save(char *value, double lat=0, double lon=0, double ele=0)
Updates Adafruit IO Feed.
Definition: AdafruitIO_Feed.cpp:113
void(* AdafruitIODataCallbackType)(AdafruitIO_Data *data)
Definition: AdafruitIO_Definitions.h:26
const char * owner
Definition: AdafruitIO_Feed.h:66
bool exists()
Checks if Adafruit IO Feed exists and belongs to username. https://io.adafruit.com/api/docs/#get-feed...
Definition: AdafruitIO_Feed.cpp:294
AdafruitIO_Data * data
Definition: AdafruitIO_Feed.h:69
AdafruitIO_Data * lastValue()
Retrieves the most recent value published to a feed. https://io.adafruit.com/api/docs/mqtt.html#using-the-get-topic.
Definition: AdafruitIO_Feed.cpp:346
const char * name
Definition: AdafruitIO_Feed.h:65
void onMessage(AdafruitIODataCallbackType cb)
Creates a new onMessage callback.
Definition: AdafruitIO_Feed.cpp:95
void setLocation(double lat, double lon, double ele=0)
Sets Adafruit IO feed location metadata.
Definition: AdafruitIO_Feed.cpp:395
Class for interacting with Adafruit IO Data Records. https://io.adafruit.com/api/docs/#data.
Definition: AdafruitIO_Data.h:30