@@ -43,12 +43,39 @@ class ArduinoCloudPropertyGeneric
43
43
virtual bool shouldBeUpdated () = 0;
44
44
virtual void updateShadow () = 0;
45
45
virtual bool canRead () = 0;
46
- virtual void printinfo () = 0;
46
+ virtual void printinfo (Stream& stream ) = 0;
47
47
virtual ArduinoCloudPropertyGeneric& onUpdate (void (*fn)(void )) = 0;
48
48
virtual ArduinoCloudPropertyGeneric& publishEvery (long seconds) = 0;
49
49
void (*callback)(void ) = NULL ;
50
50
};
51
51
52
+ class ArduinoCloudThing {
53
+ public:
54
+ ArduinoCloudThing ();
55
+ void begin ();
56
+ ArduinoCloudPropertyGeneric& addPropertyReal (int & property, String name);
57
+ ArduinoCloudPropertyGeneric& addPropertyReal (bool & property, String name);
58
+ ArduinoCloudPropertyGeneric& addPropertyReal (float & property, String name);
59
+ ArduinoCloudPropertyGeneric& addPropertyReal (void * property, String name);
60
+ ArduinoCloudPropertyGeneric& addPropertyReal (String& property, String name);
61
+ // poll should return > 0 if something has changed
62
+ int poll (uint8_t * data, size_t size);
63
+ void decode (uint8_t * payload, size_t length);
64
+
65
+ private:
66
+ void update ();
67
+ int checkNewData ();
68
+ int findPropertyByName (String &name);
69
+
70
+ ArduinoCloudPropertyGeneric* exists (String &name);
71
+
72
+ bool status = OFF;
73
+ char uuid[33 ];
74
+
75
+ LinkedList<ArduinoCloudPropertyGeneric*> list;
76
+ int currentListIndex = -1 ;
77
+ };
78
+
52
79
template <typename T>
53
80
class ArduinoCloudProperty : public ArduinoCloudPropertyGeneric
54
81
{
@@ -67,8 +94,8 @@ class ArduinoCloudProperty : public ArduinoCloudPropertyGeneric
67
94
return false ;
68
95
}
69
96
70
- void printinfo () {
71
- Serial .println (" name: " + name + " value: " + String (property) + " shadow: " + String (shadow_property) + " permission: " + String (permission));
97
+ void printinfo (Stream& stream ) {
98
+ stream .println (" name: " + name + " value: " + String (property) + " shadow: " + String (shadow_property) + " permission: " + String (permission));
72
99
}
73
100
74
101
void updateShadow () {
@@ -183,6 +210,8 @@ class ArduinoCloudProperty : public ArduinoCloudPropertyGeneric
183
210
T minDelta;
184
211
permissionType permission = READWRITE;
185
212
static int tagIndex;
213
+
214
+ friend ArduinoCloudThing;
186
215
};
187
216
188
217
template <>
@@ -231,31 +260,4 @@ inline void ArduinoCloudProperty<char*>::appendValue(CborEncoder* mapEncoder) {
231
260
cbor_encode_text_stringz (mapEncoder, property);
232
261
};
233
262
234
- class ArduinoCloudThing {
235
- public:
236
- ArduinoCloudThing ();
237
- void begin ();
238
- ArduinoCloudPropertyGeneric& addPropertyReal (int & property, String name);
239
- ArduinoCloudPropertyGeneric& addPropertyReal (bool & property, String name);
240
- ArduinoCloudPropertyGeneric& addPropertyReal (float & property, String name);
241
- ArduinoCloudPropertyGeneric& addPropertyReal (void * property, String name);
242
- ArduinoCloudPropertyGeneric& addPropertyReal (String& property, String name);
243
- // poll should return > 0 if something has changed
244
- int poll (uint8_t * data, size_t size);
245
- void decode (uint8_t * payload, size_t length);
246
-
247
- private:
248
- void update ();
249
- int checkNewData ();
250
- int findPropertyByName (String &name);
251
-
252
- ArduinoCloudPropertyGeneric* exists (String &name);
253
-
254
- bool status = OFF;
255
- char uuid[33 ];
256
-
257
- LinkedList<ArduinoCloudPropertyGeneric*> list;
258
- int currentListIndex = -1 ;
259
- };
260
-
261
263
#endif
0 commit comments