Using device MetaData
Some of the device information is known by the Octave Cloud platform (such as it's serial number).
If you need to have access to that information within a Cloud Action, you can use the Octave.device functions to access them as referenced here.
For example, the following code shows how to access the device hardware information from a Cloud Action
function (event) {
var deviceName = Octave.Device.getName(); // get the name of the device which was originating the event
var filterString = 'name=="' + deviceName + '"'; // we'll need to search it from the device database - assembling the search term
var device = Octave.Device.find({'filter': filterString})[0]; // getting the result of the search, as we're searching for
// a single device with a unique name we'll just take the first of the list [0]
// (shouldn't be more anyway)
var FSN = null;
var IMEI = null;
console.log(deviceName);
if(device.hasOwnProperty('hardware')){ // just for security - check if sub elements are present
if(device.hardware.hasOwnProperty('fsn')){
FSN = device.hardware.fsn;
}
if(device.hardware.hasOwnProperty('imei')){
IMEI = device.hardware.imei;
}
}
/// your logic based on IMEI/FSN here
}
Updated over 3 years ago