get device properties

Function Description:

A device attribute value is a series of values in a device object that describe the characteristics of the device. So these attribute values are the real attributes of the corresponding mobile device..

Corresponding JS API:
device.IP;	
device.DPI;  
device.IMEI;  
device.SN; 
device.width;  
device.height; 
device.androidVersionRelease;  
device.androidVersionSdkInt; 
device.manufacturer ;	
device.model;  
Whether to support multiple devices:

No

Resource Information:

Method GET
URL .../devices/:device
Requires authentication? Yes


Method Parameters:

Parameter Type Required Description
device String Yes ID value of the device


Response Parameters:

A JSON string representing an array of objects with the following fields:

Field Type Description
status Boolean Return true for success and null for failure
value String If the value of status is a null object, an error message or empty string is returned.
If the value of status is true, the value of this field is a json object containing the following fields:
"name": String. Device name,
"IP": String. IP address,
"IMEI": String. IMEI number,
"DPI": String. Screen pixel size,
"SN": String. Unique number of the device,
"width": Int. The width of the screen,
"height": Int. The height of the screen,
"androidVersionRelease": String. Android version,
"androidVersionSdkInt": String. Android SDK version,
"manufacturer": String. The name of the manufacturer,
"model": String. The model of the device,
"id": String. Device id,
"colorbits": Int. The screen color bit of the device,
"foregroundapp": String. The name of the software that is running in the foreground,
"orientation": Int. Screen orientation, 0: Portrait; 1: Landscape,
"sdcard": String. sdcard path,
"tmp_path": String. Temporary directory path,
"acceleration": Int. The rendering mode used by the current device, 0 – GDI; 1 – D3D; 2 – OpenGL,
"projection": Boolean. Does it support projection screening? False means not supported, true means support.


Request Example:
http://localhost:8090/TotalControl/v1/devices/device@1116106541?token=270eq7lXQK8bXYsJ
Response Example:

If this API executes successfully, it returns:

{
    "status": true,
    "value": {
	"name": "phone1",
	"IP": "10.0.2.11",
	"IMEI": "867065021807297",
	"DPI": "320",
	"SN": "7N2SQL154X038444",
	"width": 720,
	"height": 1280,
	"androidVersionRelease": "5.1.1",
	"androidVersionSdkInt": 22,
	"manufacturer": "HUAWEI",
	"model": "HUAWEI P7-L07",
	"id": "device@33254183",
	"colorbits": 32,
	"foregroundapp": "com.android.contacts",
	"orientation": 0,
	"sdcard": "/sdcard",
	"tmp_path": "/data/local/tmp",
	"acceleration": 1,
	"projection": false
	}
}

If the value of HTTP status code is 200, but the value of status is a null object, it returns:

{
    "status": null,
    "value": "<Error message>"
}


Example:

Warm tip:
Get the token needed for Total Control script development,see here.
Get the id value of the master device, see here.

RingoJS Example:
// Import the packages
var {request} = require("ringo/httpclient");
var base64 = require("ringo/base64");

// The username and password are separated by a single : and sent on the wire base64 encoded
var userpass = base64.encode("sigma:3D391497");

// First step: Get the API token
var gettoken = request({
	method: "GET",
	url: "http://localhost:8090/TotalControl/v1/login",
	headers: {
		"Authorization": userpass
	}
});
var ret_token = JSON.parse(gettoken.content); 
var token = ret_token.value.token; 
print("//The value of token is:" + token);

// Second step: Get the device id value of the master device
var getdevice = request({
	method: "GET",
	url: "http://localhost:8090/TotalControl/v1/devices/main?token=" + token
});
var device = JSON.parse(getdevice.content).id; 
print("//The value of device ID is:"+ device);

// Third step: Execute this REST API
var resp = request({
	method: "GET",
	url: "http://localhost:8090/TotalControl/v1/devices/"+ device,
	data: {
		"token": token,
	}
});
var obj = JSON.parse(resp.content); 
ret =obj.status;
if (ret == true) {
	print("//Executed successfully,Return value: \n"+resp.content);	
} else if (ret != true & resp.status == 200){
	print("An error message is returned: "+resp.content);
} else {
	print("This API failed to execute.");
}
The running result of the RingoJS:

If it executes successfully, it will return:

//The value of token is:QG097nhLzTSn9OZ8
//The value of device ID is:device@230441652
//Executed successfully,Return value: 
{"status":true,"value":{"name":"Mobile3","IP":"10.0.2.12","IMEI":"868146021323359","DPI":"320","SN":"JTJ4C15717001224","width":720,"height":1280,"androidVersionRelease":"5.1.1","androidVersionSdkInt":22,"manufacturer":"HUAWEI","model":"msm8909","id":"device@230441652","colorbits":32,"orientation":0,"sdcard":"/sdcard","tmp_path":"/data/local/tmp","acceleration":0,"projection":false}}
Python Example:
#!/user/bin/python
#-*- coding:utf-8 -*-
import base64
import requests

# The username and password are separated by a single : and sent on the wire base64 encoded
user_pass = 'sigma:3D391497'
encodeStr = base64.b64encode(user_pass.encode("UTF-8"))

# First step: Get the API token
LoginUrl = "http://localhost:8090/TotalControl/v1/login"
response = requests.get(LoginUrl, headers={'Authorization':encodeStr})
print("Get the token,Return value: ",response.json())
token = response.json()['value']['token']
print("The value of token is: ",token)

# Second step: Get the device id value of the master device
if token is not None:
    GetDeviceUrl = "http://localhost:8090/TotalControl/v1/devices/main?token=" + token
    response = requests.get(url=GetDeviceUrl)
    print("Get the device id,Return value: ", response.json())
    device = response.json()['id']
    print("The value of device id is: ", device)
    if device is not None:
        # Third step: Execute this REST API
        APIUrl = "http://localhost:8090/TotalControl/v1/devices/" + device
        data = {
            "token": token
        }
        response = requests.get(url=APIUrl, params=data)
        ret = response.json()['status']
        # Determine if this REST API is executed successfully
        if ret is True:
            print("Executed successfully,Return value: ", response.json())
        elif response.status_code == 200 and ret is not True:
            print("An error message is returned: ",response.json())
        else:
            print("This API failed to execute.")
    else:
        print("Failed to get device id.")
else:
    print("Failed to get token.")
The running result of the python:

If it executes successfully, it will return:

Get the token,Return value:  {'status': True, 'value': {'token': 'QG097nhLzTSn9OZ8'}}
The value of token is:  QG097nhLzTSn9OZ8
Get the device id,Return value:  {'id': 'device@230441652'}
The value of device id is:  device@230441652
Executed successfully,Return value:  {'status': True, 'value': {'name': 'Mobile3', 'IP': '10.0.2.12', 'IMEI': '868146021323359', 'DPI': '320', 'SN': 'JTJ4C15717001224', 'width': 720, 'height': 1280, 'androidVersionRelease': '5.1.1', 'androidVersionSdkInt': 22, 'manufacturer': 'HUAWEI', 'model': 'msm8909', 'id': 'device@230441652', 'colorbits': 32, 'orientation': 0, 'sdcard': '/sdcard', 'tmp_path': '/data/local/tmp', 'acceleration': 0, 'projection': False}}