References
.data()
.get()

device.data.get

Each device comes with a privileged space in which you can save data. Like suppose you have build a power meter, then you can store the voltage, current and power measured by the device in this space. This data can be be set by a device and retrived by the app to be consumed/displayed to end user.

This storage space is sanboxed, so only the paired users can request or update the data. You can store the data in json format and can also get/set individual key by specifying the path in dot notation.For instance if you have stored {voltage: { vpp: 10, vrms: 7}}, current: 1} , then you can access the current and vpp by providing current and voltage.vpp respectively in the path argument.

NameTypeDescription
pathstringcan be empty or a path to a key in dot notation

This method returns the following codes in response

DEVICE-DATA-FETCHED

data has been fetched

PATH-INVALID

the key is undefined

DEVICE-NOT-PAIRED

device is not paired to the account

DEVICE-ID-INVALID

device is not registered with this id

DATA-INVALID

device id is required

Use of get method has been illustrated in the example below

// Submit request to the server
device.data().get().then((res) => {
  // Got the response
  switch(res.code) {
    case "DEVICE-DATA-FETCHED": 
      // Device data has been fetched
      console.log(res.data);
  }
})