Skip to content

Commit

Permalink
BREAKING: Change shadow API to return state object
Browse files Browse the repository at this point in the history
...not entire MQTT message.

Previously GET and UPDATE_ACCEPTED messages would return an object like this:
```json
{
  "state": {
    "reported": { ... },
    "desired": { ... }
  }
}
```

Now they will return an object like this:
```json
{
  "reported": { ... },
  "desired": { ... }
}
```

This is necessary for the upcoming Azure shadow implementation.

Shadow update API is also being changed to take reported state only.

CL: BREAKING: Change shadow API to return state object

PUBLISHED_FROM=8706cfce56532d3f037d9940dbdcec891d43bb0a
  • Loading branch information
Deomid Ryabkov authored and cesantabot committed Apr 17, 2018
1 parent cd8bd1d commit 6302e12
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions include/mgos_shadow.h
Expand Up @@ -73,8 +73,8 @@ bool mgos_shadow_get(void);

/*
* Send an update. Format string should define the value of the "state" key,
* i.e. it should be an object with "reported" and/or "desired" keys, e.g.:
* `mgos_shadow_updatef("{reported:{foo: %d, bar: %d}}", foo, bar)`.
* i.e. it should be an object with an update to the reported state, e.g.:
* `mgos_shadow_updatef("{foo: %d, bar: %d}", foo, bar)`.
* Response will arrive via UPDATE_ACCEPTED or REJECTED topic.
* If you want the update to be aplied only if a particular version is
* current,
Expand Down
2 changes: 1 addition & 1 deletion mjs_fs/api_shadow.js
Expand Up @@ -37,7 +37,7 @@ let Shadow = {
// `CONNECTED` event and report the current state, and b) catch `UPDATE_DELTA`
// event, apply the delta, and report the state. Example:
// ```javascript
// Shadow.update(0, {reported:{temperature: 12.34}});
// Shadow.update(0, {temperature: 12.34});
// ```
update: function(version, obj) {
this._upd(version, JSON.stringify(obj));
Expand Down

0 comments on commit 6302e12

Please sign in to comment.