10
10
11
11
#include < util/CBORTestUtil.h>
12
12
#include < ArduinoCloudThing.h>
13
+ #include < PropertyContainer.h>
13
14
#include " types/CloudWrapperBool.h"
14
15
15
16
/* *************************************************************************************
@@ -39,11 +40,12 @@ SCENARIO("A callback is registered via 'onUpdate' to be called on property chang
39
40
/* ***********************************************************************************/
40
41
41
42
GIVEN (" CloudProtocol::V2" ) {
43
+ PropertyContainer property_container;
42
44
ArduinoCloudThing thing;
43
- thing.begin ();
45
+ thing.begin (&property_container );
44
46
45
47
CloudInt test = 10 ;
46
- thing .addPropertyReal (test, " test" , Permission::ReadWrite).onUpdate (externalCallbackV2);
48
+ property_container .addPropertyReal (test, " test" , Permission::ReadWrite).onUpdate (externalCallbackV2);
47
49
48
50
/* [{0: "test", 2: 7}] = 81 A2 00 64 74 65 73 74 02 07 */
49
51
uint8_t const payload[] = {0x81 , 0xA2 , 0x00 , 0x64 , 0x74 , 0x65 , 0x73 , 0x74 , 0x02 , 0x07 };
@@ -68,11 +70,12 @@ void switch_callback() {
68
70
69
71
SCENARIO (" A (boolean) property is manipulated in the callback to its origin state" , " [ArduinoCloudThing::decode]" ) {
70
72
GIVEN (" CloudProtocol::V2" ) {
73
+ PropertyContainer property_container;
71
74
ArduinoCloudThing thing;
72
- thing.begin ();
75
+ thing.begin (&property_container );
73
76
cbor::encode (thing);
74
77
75
- thing .addPropertyReal (switch_turned_on, " switch_turned_on" , Permission::ReadWrite).onUpdate (switch_callback);
78
+ property_container .addPropertyReal (switch_turned_on, " switch_turned_on" , Permission::ReadWrite).onUpdate (switch_callback);
76
79
77
80
/* [{0: "switch_turned_on", 4: true}] = 81 A2 00 70 73 77 69 74 63 68 5F 74 75 72 6E 65 64 5F 6F 6E 04 F5 */
78
81
uint8_t const payload[] = {0x81 , 0xA2 , 0x00 , 0x70 , 0x73 , 0x77 , 0x69 , 0x74 , 0x63 , 0x68 , 0x5F , 0x74 , 0x75 , 0x72 , 0x6E , 0x65 , 0x64 , 0x5F , 0x6F , 0x6E , 0x04 , 0xF5 };
@@ -113,10 +116,11 @@ SCENARIO("After a connection/reconnection an incoming cbor payload is processed
113
116
sync_callback_called = false ;
114
117
change_callback_called = false ;
115
118
119
+ PropertyContainer property_container;
116
120
ArduinoCloudThing thing;
117
- thing.begin ();
121
+ thing.begin (&property_container );
118
122
119
- thing .addPropertyReal (test, " test" , Permission::ReadWrite).onUpdate (change_callback).onSync (auto_sync_callback);
123
+ property_container .addPropertyReal (test, " test" , Permission::ReadWrite).onUpdate (change_callback).onSync (auto_sync_callback);
120
124
121
125
test.setLastLocalChangeTimestamp (1550138809 );
122
126
@@ -140,10 +144,11 @@ SCENARIO("After a connection/reconnection an incoming cbor payload is processed
140
144
sync_callback_called = false ;
141
145
change_callback_called = false ;
142
146
147
+ PropertyContainer property_container;
143
148
ArduinoCloudThing thing;
144
- thing.begin ();
149
+ thing.begin (&property_container );
145
150
146
- thing .addPropertyReal (test, " test" , Permission::ReadWrite).onUpdate (change_callback).onSync (auto_sync_callback);
151
+ property_container .addPropertyReal (test, " test" , Permission::ReadWrite).onUpdate (change_callback).onSync (auto_sync_callback);
147
152
test = false ;
148
153
test.setLastLocalChangeTimestamp (1550138811 );
149
154
@@ -166,12 +171,13 @@ SCENARIO("Primitive property: After a connection/reconnection an incoming cbor p
166
171
sync_callback_called = false ;
167
172
change_callback_called = false ;
168
173
174
+ PropertyContainer property_container;
169
175
ArduinoCloudThing thing;
170
- thing.begin ();
176
+ thing.begin (&property_container );
171
177
172
- thing .addPropertyReal (*p, " test" , Permission::ReadWrite).onUpdate (change_callback).onSync (auto_sync_callback);
178
+ property_container .addPropertyReal (*p, " test" , Permission::ReadWrite).onUpdate (change_callback).onSync (auto_sync_callback);
173
179
test = false ;
174
- thing .updateTimestampOnLocallyChangedProperties ();
180
+ property_container .updateTimestampOnLocallyChangedProperties ();
175
181
// There is no RTC on test execution environment so we force the local timestamp
176
182
p->setLastLocalChangeTimestamp (1550138809 );
177
183
@@ -196,12 +202,13 @@ SCENARIO("Primitive property: After a connection/reconnection an incoming cbor p
196
202
sync_callback_called = false ;
197
203
change_callback_called = false ;
198
204
205
+ PropertyContainer property_container;
199
206
ArduinoCloudThing thing;
200
- thing.begin ();
207
+ thing.begin (&property_container );
201
208
202
- thing .addPropertyReal (*p, " test" , Permission::ReadWrite).onUpdate (change_callback).onSync (auto_sync_callback);
209
+ property_container .addPropertyReal (*p, " test" , Permission::ReadWrite).onUpdate (change_callback).onSync (auto_sync_callback);
203
210
test = false ;
204
- thing .updateTimestampOnLocallyChangedProperties ();
211
+ property_container .updateTimestampOnLocallyChangedProperties ();
205
212
// There is no RTC on test execution environment so we force the local timestamp
206
213
p->setLastLocalChangeTimestamp (1550138811 );
207
214
@@ -223,10 +230,11 @@ SCENARIO("Object property: After a connection/reconnection an incoming cbor payl
223
230
sync_callback_called = false ;
224
231
change_callback_called = false ;
225
232
233
+ PropertyContainer property_container;
226
234
ArduinoCloudThing thing;
227
- thing.begin ();
235
+ thing.begin (&property_container );
228
236
229
- thing .addPropertyReal (location_test, " test" , Permission::ReadWrite).onUpdate (change_callback).onSync (auto_sync_callback);
237
+ property_container .addPropertyReal (location_test, " test" , Permission::ReadWrite).onUpdate (change_callback).onSync (auto_sync_callback);
230
238
location_test.setLastLocalChangeTimestamp (1550138809 );
231
239
232
240
/* [{-3: 1550138810.00, 0: "test:lat", 3: 2},{0: "test:lon", 3: 3}] = 82 A3 22 FB 41 D7 19 4F 6E 80 00 00 00 68 74 65 73 74 3A 6C 61 74 02 02 A2 00 68 74 65 73 74 3A 6C 6F 6E 02 03*/
@@ -254,10 +262,11 @@ SCENARIO("Object property: After a connection/reconnection an incoming cbor payl
254
262
sync_callback_called = false ;
255
263
change_callback_called = false ;
256
264
265
+ PropertyContainer property_container;
257
266
ArduinoCloudThing thing;
258
- thing.begin ();
267
+ thing.begin (&property_container );
259
268
260
- thing .addPropertyReal (location_test, " test" , Permission::ReadWrite).onUpdate (change_callback).onSync (auto_sync_callback);
269
+ property_container .addPropertyReal (location_test, " test" , Permission::ReadWrite).onUpdate (change_callback).onSync (auto_sync_callback);
261
270
location_test.setLastLocalChangeTimestamp (1550138811 );
262
271
263
272
/* [{-3: 1550138810.00, 0: "test:lat", 3: 2},{0: "test:lon", 3: 3}] = 82 A3 22 FB 41 D7 19 4F 6E 80 00 00 00 68 74 65 73 74 3A 6C 61 74 02 02 A2 00 68 74 65 73 74 3A 6C 6F 6E 02 03*/
@@ -291,10 +300,11 @@ SCENARIO("After a connection/reconnection an incoming cbor payload is processed
291
300
sync_callback_called = false ;
292
301
change_callback_called = false ;
293
302
303
+ PropertyContainer property_container;
294
304
ArduinoCloudThing thing;
295
- thing.begin ();
305
+ thing.begin (&property_container );
296
306
297
- thing .addPropertyReal (test, " test" , Permission::ReadWrite).onUpdate (change_callback).onSync (force_device_sync_callback);
307
+ property_container .addPropertyReal (test, " test" , Permission::ReadWrite).onUpdate (change_callback).onSync (force_device_sync_callback);
298
308
299
309
/* [{-3: 1550138810.00, 0: "test", 4: true}] = 81 A3 22 FB 41 D7 19 4F 6E 80 00 00 00 64 74 65 73 74 04 F5 */
300
310
uint8_t const payload[] = {0x81 , 0xA3 , 0x22 , 0xFB , 0x41 , 0xD7 , 0x19 , 0x4F , 0x6E , 0x80 , 0x00 , 0x00 , 0x00 , 0x64 , 0x74 , 0x65 , 0x73 , 0x74 , 0x04 , 0xF5 };
@@ -323,10 +333,11 @@ SCENARIO("After a connection/reconnection an incoming cbor payload is processed
323
333
sync_callback_called = false ;
324
334
change_callback_called = false ;
325
335
336
+ PropertyContainer property_container;
326
337
ArduinoCloudThing thing;
327
- thing.begin ();
338
+ thing.begin (&property_container );
328
339
329
- thing .addPropertyReal (test, " test" , Permission::ReadWrite).onUpdate (change_callback).onSync (force_cloud_sync_callback);
340
+ property_container .addPropertyReal (test, " test" , Permission::ReadWrite).onUpdate (change_callback).onSync (force_cloud_sync_callback);
330
341
331
342
/* [{-3: 1550138810.00, 0: "test", 4: true}] = 81 A3 22 FB 41 D7 19 4F 6E 80 00 00 00 64 74 65 73 74 04 F5 */
332
343
uint8_t const payload[] = {0x81 , 0xA3 , 0x22 , 0xFB , 0x41 , 0xD7 , 0x19 , 0x4F , 0x6E , 0x80 , 0x00 , 0x00 , 0x00 , 0x64 , 0x74 , 0x65 , 0x73 , 0x74 , 0x04 , 0xF5 };
@@ -349,10 +360,11 @@ SCENARIO("After a connection/reconnection an incoming cbor payload is processed.
349
360
sync_callback_called = false ;
350
361
change_callback_called = false ;
351
362
363
+ PropertyContainer property_container;
352
364
ArduinoCloudThing thing;
353
- thing.begin ();
365
+ thing.begin (&property_container );
354
366
355
- thing .addPropertyReal (test, " test" , Permission::ReadWrite).onUpdate (change_callback);
367
+ property_container .addPropertyReal (test, " test" , Permission::ReadWrite).onUpdate (change_callback);
356
368
357
369
/* [{-3: 1550138810.00, 0: "test", 4: true}] = 81 A3 22 FB 41 D7 19 4F 6E 80 00 00 00 64 74 65 73 74 04 F5 */
358
370
uint8_t const payload[] = {0x81 , 0xA3 , 0x22 , 0xFB , 0x41 , 0xD7 , 0x19 , 0x4F , 0x6E , 0x80 , 0x00 , 0x00 , 0x00 , 0x64 , 0x74 , 0x65 , 0x73 , 0x74 , 0x04 , 0xF5 };
0 commit comments