Skip to content

Commit ec9188f

Browse files
author
brentru
committed
doxy AdafruitIO_Group
1 parent aea8ba8 commit ec9188f

1 file changed

Lines changed: 178 additions & 8 deletions

File tree

src/AdafruitIO_Group.cpp

Lines changed: 178 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
/**************************************************************************/
2121
/*!
22-
@brief Creates a new instance of an Adafruit IO Feed.
22+
@brief Creates a new instance of an Adafruit IO Group.
2323
@param *io
2424
Reference to AdafruitIO.
2525
@param *n
26-
Valid feed name.
26+
Valid group name.
2727
*/
2828
/**************************************************************************/
2929
AdafruitIO_Group::AdafruitIO_Group(AdafruitIO *io, const char *n)
@@ -35,6 +35,11 @@ AdafruitIO_Group::AdafruitIO_Group(AdafruitIO *io, const char *n)
3535
_init();
3636
}
3737

38+
/**************************************************************************/
39+
/*!
40+
@brief Adafruit IO Group destructor.
41+
*/
42+
/**************************************************************************/
3843
AdafruitIO_Group::~AdafruitIO_Group() {
3944
if (_sub)
4045
delete _sub;
@@ -61,51 +66,140 @@ AdafruitIO_Group::~AdafruitIO_Group() {
6166
free(_create_url);
6267
}
6368

69+
/**************************************************************************/
70+
/*!
71+
@brief Sets value of Adafruit IO Group.
72+
@param feed
73+
Adafruit IO feed name.
74+
@param value
75+
Adafruit IO feed value.
76+
*/
77+
/**************************************************************************/
6478
void AdafruitIO_Group::set(const char *feed, char *value) {
6579
AdafruitIO_Data *f = getFeed(feed);
6680
f->setValue(value);
6781
}
6882

83+
/**************************************************************************/
84+
/*!
85+
@brief Sets value of Adafruit IO Group.
86+
@param feed
87+
Adafruit IO feed name.
88+
@param value
89+
Adafruit IO feed value.
90+
*/
91+
/**************************************************************************/
6992
void AdafruitIO_Group::set(const char *feed, bool value) {
7093
AdafruitIO_Data *f = getFeed(feed);
7194
f->setValue(value);
7295
}
7396

97+
/**************************************************************************/
98+
/*!
99+
@brief Sets value of Adafruit IO Group.
100+
@param feed
101+
Adafruit IO feed name.
102+
@param value
103+
Adafruit IO feed value.
104+
*/
105+
/**************************************************************************/
74106
void AdafruitIO_Group::set(const char *feed, String value) {
75107
AdafruitIO_Data *f = getFeed(feed);
76108
f->setValue(value);
77109
}
78110

111+
/**************************************************************************/
112+
/*!
113+
@brief Sets value of Adafruit IO Group.
114+
@param feed
115+
Adafruit IO feed name.
116+
@param value
117+
Adafruit IO feed value.
118+
*/
119+
/**************************************************************************/
79120
void AdafruitIO_Group::set(const char *feed, int value) {
80121
AdafruitIO_Data *f = getFeed(feed);
81122
f->setValue(value);
82123
}
83124

125+
/**************************************************************************/
126+
/*!
127+
@brief Sets value of Adafruit IO Group.
128+
@param feed
129+
Adafruit IO feed name.
130+
@param value
131+
Adafruit IO feed value.
132+
*/
133+
/**************************************************************************/
84134
void AdafruitIO_Group::set(const char *feed, unsigned int value) {
85135
AdafruitIO_Data *f = getFeed(feed);
86136
f->setValue(value);
87137
}
88138

139+
/**************************************************************************/
140+
/*!
141+
@brief Sets value of Adafruit IO Group.
142+
@param feed
143+
Adafruit IO feed name.
144+
@param value
145+
Adafruit IO feed value.
146+
*/
147+
/**************************************************************************/
89148
void AdafruitIO_Group::set(const char *feed, long value) {
90149
AdafruitIO_Data *f = getFeed(feed);
91150
f->setValue(value);
92151
}
93152

153+
/**************************************************************************/
154+
/*!
155+
@brief Sets value of Adafruit IO Group.
156+
@param feed
157+
Adafruit IO feed name.
158+
@param value
159+
Adafruit IO feed value.
160+
*/
161+
/**************************************************************************/
94162
void AdafruitIO_Group::set(const char *feed, unsigned long value) {
95163
AdafruitIO_Data *f = getFeed(feed);
96164
f->setValue(value);
97165
}
98166

167+
/**************************************************************************/
168+
/*!
169+
@brief Sets value of Adafruit IO Group.
170+
@param feed
171+
Adafruit IO feed name.
172+
@param value
173+
Adafruit IO feed value.
174+
*/
175+
/**************************************************************************/
99176
void AdafruitIO_Group::set(const char *feed, float value) {
100177
AdafruitIO_Data *f = getFeed(feed);
101178
f->setValue(value);
102179
}
103180

181+
/**************************************************************************/
182+
/*!
183+
@brief Sets value of Adafruit IO Group.
184+
@param feed
185+
Adafruit IO feed name.
186+
@param value
187+
Adafruit IO feed value.
188+
*/
189+
/**************************************************************************/
104190
void AdafruitIO_Group::set(const char *feed, double value) {
105191
AdafruitIO_Data *f = getFeed(feed);
106192
f->setValue(value);
107193
}
108194

195+
196+
/**************************************************************************/
197+
/*!
198+
@brief Updates value of Adafruit IO Group.
199+
@return True if successfully published to group, False if data is
200+
NULL or if unable to successfully publish data to group.
201+
*/
202+
/**************************************************************************/
109203
bool AdafruitIO_Group::save() {
110204

111205
if (data == NULL)
@@ -129,11 +223,27 @@ bool AdafruitIO_Group::save() {
129223
return _pub->publish(csv);
130224
}
131225

226+
/**************************************************************************/
227+
/*!
228+
@brief Publishes null value ("\0") to Adafruit IO Group
229+
https://io.adafruit.com/api/docs/mqtt.html#retained-values
230+
@return True if successfully published to group, False otherwise.
231+
*/
232+
/**************************************************************************/
132233
bool AdafruitIO_Group::get() { return _get_pub->publish("\0"); }
133234

235+
/**************************************************************************/
236+
/*!
237+
@brief Obtains data from feed within group.
238+
@param feed
239+
Existing Adafruit IO Feed.
240+
@return cur_data Data from feed within group
241+
data Adafruit IO Feed does not exist in group. Data is
242+
the value of a generated feed, feed, within group.
243+
NULL If unable to return data.
244+
*/
245+
/**************************************************************************/
134246
AdafruitIO_Data *AdafruitIO_Group::getFeed(const char *feed) {
135-
// uint8_t i;
136-
137247
if (data == NULL) {
138248
data = new AdafruitIO_Data(feed);
139249
return data;
@@ -158,9 +268,15 @@ AdafruitIO_Data *AdafruitIO_Group::getFeed(const char *feed) {
158268
return NULL;
159269
}
160270

271+
/**************************************************************************/
272+
/*!
273+
@brief Sets up Adafruit IO callback to monitor incoming
274+
new data in group.
275+
@param cb
276+
An function to be called if group receives new data.
277+
*/
278+
/**************************************************************************/
161279
void AdafruitIO_Group::onMessage(AdafruitIODataCallbackType cb) {
162-
// uint8_t i;
163-
164280
if (_groupCallback == NULL) {
165281
_groupCallback = new AdafruitIOGroupCallback(cb);
166282
return;
@@ -179,10 +295,18 @@ void AdafruitIO_Group::onMessage(AdafruitIODataCallbackType cb) {
179295
}
180296
}
181297

298+
/**************************************************************************/
299+
/*!
300+
@brief Sets up Adafruit IO callback to monitor incoming
301+
new data in group's feed, feed.
302+
@param feed
303+
An Adafruit IO Feed within Group.
304+
@param cb
305+
An function to be called if group receives new data.
306+
*/
307+
/**************************************************************************/
182308
void AdafruitIO_Group::onMessage(const char *feed,
183309
AdafruitIODataCallbackType cb) {
184-
// uint8_t i;
185-
186310
if (_groupCallback == NULL) {
187311
_groupCallback = new AdafruitIOGroupCallback(feed, cb);
188312
return;
@@ -205,6 +329,13 @@ void AdafruitIO_Group::onMessage(const char *feed,
205329
}
206330
}
207331

332+
/**************************************************************************/
333+
/*!
334+
@brief Adafruit IO Group subscription function callback.
335+
@param d
336+
Name of feed within group.
337+
*/
338+
/**************************************************************************/
208339
void AdafruitIO_Group::call(AdafruitIO_Data *d) {
209340
// uint8_t i;
210341

@@ -224,6 +355,15 @@ void AdafruitIO_Group::call(AdafruitIO_Data *d) {
224355
}
225356
}
226357

358+
/**************************************************************************/
359+
/*!
360+
@brief Checks for new value within Adafruit IO group.
361+
@param val
362+
Value to send to Adafruit IO group.
363+
@param len
364+
Length of Adafruit IO value.
365+
*/
366+
/**************************************************************************/
227367
void AdafruitIO_Group::subCallback(char *val, uint16_t len) {
228368

229369
char *line;
@@ -262,6 +402,17 @@ void AdafruitIO_Group::subCallback(char *val, uint16_t len) {
262402
}
263403
}
264404

405+
/**************************************************************************/
406+
/*!
407+
@brief Sets up locational metadata.
408+
@param lat
409+
Desired latitude.
410+
@param lon
411+
Desired longitude.
412+
@param ele
413+
Desired elevation.
414+
*/
415+
/**************************************************************************/
265416
void AdafruitIO_Group::setLocation(double lat, double lon, double ele) {
266417
// uint8_t i;
267418

@@ -277,6 +428,13 @@ void AdafruitIO_Group::setLocation(double lat, double lon, double ele) {
277428
}
278429
}
279430

431+
/**************************************************************************/
432+
/*!
433+
@brief Checks if Adafruit IO Group exists.
434+
https://io.adafruit.com/api/docs/#get-group
435+
@return HTTP status, 200 if group exists.
436+
*/
437+
/**************************************************************************/
280438
bool AdafruitIO_Group::exists() {
281439
_io->_http->beginRequest();
282440
_io->_http->get(_group_url);
@@ -288,6 +446,13 @@ bool AdafruitIO_Group::exists() {
288446
return status == 200;
289447
}
290448

449+
/**************************************************************************/
450+
/*!
451+
@brief Creates new Adafruit IO Group.
452+
https://io.adafruit.com/api/docs/#create-group
453+
@return HTTP status, 201 if group created successfully.
454+
*/
455+
/**************************************************************************/
291456
bool AdafruitIO_Group::create() {
292457
String body = "name=";
293458
body += name;
@@ -313,6 +478,11 @@ bool AdafruitIO_Group::create() {
313478
return status == 201;
314479
}
315480

481+
/**************************************************************************/
482+
/*!
483+
@brief Initialize MQTT topics and REST URLs for Adafruit IO groups.
484+
*/
485+
/**************************************************************************/
316486
void AdafruitIO_Group::_init() {
317487

318488
// dynamically allocate memory for mqtt topic and REST URLs

0 commit comments

Comments
 (0)