@@ -72,9 +72,25 @@ static void s_changeShadowValue(
72
72
73
73
ShadowState state;
74
74
JsonObject desired;
75
- desired.WithString (shadowProperty, value);
76
75
JsonObject reported;
77
- reported.WithString (shadowProperty, value);
76
+
77
+ if (value == " null" )
78
+ {
79
+ JsonObject nullObject;
80
+ nullObject.AsNull ();
81
+ desired.WithObject (shadowProperty, nullObject);
82
+ reported.WithObject (shadowProperty, nullObject);
83
+ }
84
+ else if (value == " clear_shadow" )
85
+ {
86
+ desired.AsNull ();
87
+ reported.AsNull ();
88
+ }
89
+ else
90
+ {
91
+ desired.WithString (shadowProperty, value);
92
+ reported.WithString (shadowProperty, value);
93
+ }
78
94
state.Desired = desired;
79
95
state.Reported = reported;
80
96
@@ -288,7 +304,6 @@ int main(int argc, char *argv[])
288
304
if (event->State && event->State ->View ().ValueExists (shadowProperty))
289
305
{
290
306
JsonView objectView = event->State ->View ().GetJsonObject (shadowProperty);
291
-
292
307
if (objectView.IsNull ())
293
308
{
294
309
fprintf (
@@ -324,10 +339,17 @@ int main(int argc, char *argv[])
324
339
auto onUpdateShadowAccepted = [&](UpdateShadowResponse *response, int ioErr) {
325
340
if (ioErr == AWS_OP_SUCCESS)
326
341
{
327
- fprintf (
328
- stdout,
329
- " Finished updating reported shadow value to %s.\n " ,
330
- response->State ->Reported ->View ().GetString (shadowProperty).c_str ());
342
+ if (response->State ->Reported )
343
+ {
344
+ fprintf (
345
+ stdout,
346
+ " Finished updating reported shadow value to %s.\n " ,
347
+ response->State ->Reported ->View ().GetString (shadowProperty).c_str ());
348
+ }
349
+ else
350
+ {
351
+ fprintf (stdout, " Finished clearing shadow properties\n " );
352
+ }
331
353
fprintf (stdout, " Enter desired value:\n " );
332
354
}
333
355
else
0 commit comments