Skip to content

VariableService

Method LWM2M request Description
getAddress GET /variable/{variableId}/address Get variable address
getBundleId GET /variable/{variableId}/bundle/id Get variable bundle id
getBundleValues GET /variable/{variableId}/bundle/values Get variable bundle values
getCurrentAccess GET /variable/{variableId}/current-access Get access rights for the variable
getFormat GET /variable/{variableId}/format Get data format for variable
getNumberOfElements GET /variable/{variableId}/number-of-elements Get variable array size
getValue GET /variable/{variableId}/value Get variable value
putAddress PUT /variable/{variableId}/address Write variable address
putBundleId PUT /variable/{variableId}/bundle/id Write variable bundle id
putFormat PUT /variable/{variableId}/format Set data format of the variable
putNumberOfElements PUT /variable/{variableId}/number-of-elements Write variable array size
putValue PUT /variable/{variableId}/value Set variable value
setValue POST /variable/{variableId}/set-value Set variable value

getAddress

Integer getAddress(variableId)

Get variable address

Example

let myService = new VariableService();
let variableId = 56; // Integer | ID of the variable

try{
    let call = myService.getAddress(variableId);
    let value = (await call).body();
    console.log(`getAddress: ${value}`);
}
catch (ex){
    // No response from device / response error (ie: device is not connected or request timeout)
    console.error(ex);
}
import com.iotize.android.device.device.api.service.definition.VariableService;

ServiceFactory serviceFactory = ...;
VariableService myService = serviceFactory.create(VariableService.class);


Integer variableId = 56; // Integer | ID of the variable
try {
    Call<Integer> call = myService.getAddress(variableId);
    Response<Integer> response = call.execute();
    if (response.isSuccessful()){
        System.out.println(response.body());
    }
    else{
        System.out.println(DeviceResponseError.createErrorMessage(response));
    }
} catch (ApiException e) {
    System.err.println("Exception when calling VariableService#getAddress");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
variableId Integer ID of the variable

Return type

Integer

Authorization

No authorization required

getBundleId

Integer getBundleId(variableId)

Get variable bundle id

ID du bundle qui contient la variable

Example

let myService = new VariableService();
let variableId = 56; // Integer | 

try{
    let call = myService.getBundleId(variableId);
    let value = (await call).body();
    console.log(`getBundleId: ${value}`);
}
catch (ex){
    // No response from device / response error (ie: device is not connected or request timeout)
    console.error(ex);
}
import com.iotize.android.device.device.api.service.definition.VariableService;

ServiceFactory serviceFactory = ...;
VariableService myService = serviceFactory.create(VariableService.class);


Integer variableId = 56; // Integer | 
try {
    Call<Integer> call = myService.getBundleId(variableId);
    Response<Integer> response = call.execute();
    if (response.isSuccessful()){
        System.out.println(response.body());
    }
    else{
        System.out.println(DeviceResponseError.createErrorMessage(response));
    }
} catch (ApiException e) {
    System.err.println("Exception when calling VariableService#getBundleId");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
variableId Integer

Return type

Integer

Authorization

No authorization required

getBundleValues

Integer getBundleValues(variableId)

Get variable bundle values

Example

let myService = new VariableService();
let variableId = 56; // Integer | 

try{
    let call = myService.getBundleValues(variableId);
    let value = (await call).body();
    console.log(`getBundleValues: ${value}`);
}
catch (ex){
    // No response from device / response error (ie: device is not connected or request timeout)
    console.error(ex);
}
import com.iotize.android.device.device.api.service.definition.VariableService;

ServiceFactory serviceFactory = ...;
VariableService myService = serviceFactory.create(VariableService.class);


Integer variableId = 56; // Integer | 
try {
    Call<Integer> call = myService.getBundleValues(variableId);
    Response<Integer> response = call.execute();
    if (response.isSuccessful()){
        System.out.println(response.body());
    }
    else{
        System.out.println(DeviceResponseError.createErrorMessage(response));
    }
} catch (ApiException e) {
    System.err.println("Exception when calling VariableService#getBundleValues");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
variableId Integer

Return type

Integer

Authorization

No authorization required

getCurrentAccess

ReadWriteRights getCurrentAccess(variableId)

Get access rights for the variable

Get access rights for the variable (read and write)

Example

let myService = new VariableService();
let variableId = 56; // Integer | ID of the variable

try{
    let call = myService.getCurrentAccess(variableId);
    let value = (await call).body();
    console.log(`getCurrentAccess: ${value}`);
}
catch (ex){
    // No response from device / response error (ie: device is not connected or request timeout)
    console.error(ex);
}
import com.iotize.android.device.device.api.service.definition.VariableService;

ServiceFactory serviceFactory = ...;
VariableService myService = serviceFactory.create(VariableService.class);


Integer variableId = 56; // Integer | ID of the variable
try {
    Call<ReadWriteRights> call = myService.getCurrentAccess(variableId);
    Response<ReadWriteRights> response = call.execute();
    if (response.isSuccessful()){
        System.out.println(response.body());
    }
    else{
        System.out.println(DeviceResponseError.createErrorMessage(response));
    }
} catch (ApiException e) {
    System.err.println("Exception when calling VariableService#getCurrentAccess");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
variableId Integer ID of the variable

Return type

ReadWriteRights

Authorization

No authorization required

getFormat

Integer getFormat(variableId)

Get data format for variable

Example

let myService = new VariableService();
let variableId = 56; // Integer | ID of the variable

try{
    let call = myService.getFormat(variableId);
    let value = (await call).body();
    console.log(`getFormat: ${value}`);
}
catch (ex){
    // No response from device / response error (ie: device is not connected or request timeout)
    console.error(ex);
}
import com.iotize.android.device.device.api.service.definition.VariableService;

ServiceFactory serviceFactory = ...;
VariableService myService = serviceFactory.create(VariableService.class);


Integer variableId = 56; // Integer | ID of the variable
try {
    Call<Integer> call = myService.getFormat(variableId);
    Response<Integer> response = call.execute();
    if (response.isSuccessful()){
        System.out.println(response.body());
    }
    else{
        System.out.println(DeviceResponseError.createErrorMessage(response));
    }
} catch (ApiException e) {
    System.err.println("Exception when calling VariableService#getFormat");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
variableId Integer ID of the variable

Return type

Integer

Authorization

No authorization required

getNumberOfElements

Integer getNumberOfElements(variableId)

Get variable array size

Get the number of element of the variable

Example

let myService = new VariableService();
let variableId = 56; // Integer | ID of the variable

try{
    let call = myService.getNumberOfElements(variableId);
    let value = (await call).body();
    console.log(`getNumberOfElements: ${value}`);
}
catch (ex){
    // No response from device / response error (ie: device is not connected or request timeout)
    console.error(ex);
}
import com.iotize.android.device.device.api.service.definition.VariableService;

ServiceFactory serviceFactory = ...;
VariableService myService = serviceFactory.create(VariableService.class);


Integer variableId = 56; // Integer | ID of the variable
try {
    Call<Integer> call = myService.getNumberOfElements(variableId);
    Response<Integer> response = call.execute();
    if (response.isSuccessful()){
        System.out.println(response.body());
    }
    else{
        System.out.println(DeviceResponseError.createErrorMessage(response));
    }
} catch (ApiException e) {
    System.err.println("Exception when calling VariableService#getNumberOfElements");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
variableId Integer ID of the variable

Return type

Integer

Authorization

No authorization required

getValue

byte[] getValue(variableId)

Get variable value

Value of array of values. The size depends of variable format

Example

let myService = new VariableService();
let variableId = 56; // Integer | ID of the variable

try{
    let call = myService.getValue(variableId);
    let value = (await call).body();
    console.log(`getValue: ${value}`);
}
catch (ex){
    // No response from device / response error (ie: device is not connected or request timeout)
    console.error(ex);
}
import com.iotize.android.device.device.api.service.definition.VariableService;

ServiceFactory serviceFactory = ...;
VariableService myService = serviceFactory.create(VariableService.class);


Integer variableId = 56; // Integer | ID of the variable
try {
    Call<byte[]> call = myService.getValue(variableId);
    Response<byte[]> response = call.execute();
    if (response.isSuccessful()){
        System.out.println(response.body());
    }
    else{
        System.out.println(DeviceResponseError.createErrorMessage(response));
    }
} catch (ApiException e) {
    System.err.println("Exception when calling VariableService#getValue");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
variableId Integer ID of the variable

Return type

byte[]

Authorization

No authorization required

putAddress

putAddress(variableId, address)

Write variable address

Example

let myService = new VariableService();
let variableId = 56; // Integer | ID of the variable
let address = 56; // Integer | New address of the variable

try{
    let call = myService.putAddress(variableId, address);
    let value = (await call).body();
    console.log(`putAddress: ${value}`);
}
catch (ex){
    // No response from device / response error (ie: device is not connected or request timeout)
    console.error(ex);
}
import com.iotize.android.device.device.api.service.definition.VariableService;

ServiceFactory serviceFactory = ...;
VariableService myService = serviceFactory.create(VariableService.class);


Integer variableId = 56; // Integer | ID of the variable
Integer address = 56; // Integer | New address of the variable
try {
    Call<Void> call = myService.putAddress(variableId, address);
    Response<Void> response = call.execute();
    if (response.isSuccessful()){
        System.out.println(response.body());
    }
    else{
        System.out.println(DeviceResponseError.createErrorMessage(response));
    }
} catch (ApiException e) {
    System.err.println("Exception when calling VariableService#putAddress");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
variableId Integer ID of the variable
address Integer New address of the variable

Return type

null (empty response body)

Authorization

No authorization required

putBundleId

putBundleId(variableId, value)

Write variable bundle id

Example

let myService = new VariableService();
let variableId = 56; // Integer | 
let value = 56; // Integer | 

try{
    let call = myService.putBundleId(variableId, value);
    let value = (await call).body();
    console.log(`putBundleId: ${value}`);
}
catch (ex){
    // No response from device / response error (ie: device is not connected or request timeout)
    console.error(ex);
}
import com.iotize.android.device.device.api.service.definition.VariableService;

ServiceFactory serviceFactory = ...;
VariableService myService = serviceFactory.create(VariableService.class);


Integer variableId = 56; // Integer | 
Integer value = 56; // Integer | 
try {
    Call<Void> call = myService.putBundleId(variableId, value);
    Response<Void> response = call.execute();
    if (response.isSuccessful()){
        System.out.println(response.body());
    }
    else{
        System.out.println(DeviceResponseError.createErrorMessage(response));
    }
} catch (ApiException e) {
    System.err.println("Exception when calling VariableService#putBundleId");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
variableId Integer
value Integer

Return type

null (empty response body)

Authorization

No authorization required

putFormat

putFormat(variableId, value)

Set data format of the variable

Example

let myService = new VariableService();
let variableId = 56; // Integer | ID of the variable
let value = 56; // Integer | New format of the variable

try{
    let call = myService.putFormat(variableId, value);
    let value = (await call).body();
    console.log(`putFormat: ${value}`);
}
catch (ex){
    // No response from device / response error (ie: device is not connected or request timeout)
    console.error(ex);
}
import com.iotize.android.device.device.api.service.definition.VariableService;

ServiceFactory serviceFactory = ...;
VariableService myService = serviceFactory.create(VariableService.class);


Integer variableId = 56; // Integer | ID of the variable
Integer value = 56; // Integer | New format of the variable
try {
    Call<Void> call = myService.putFormat(variableId, value);
    Response<Void> response = call.execute();
    if (response.isSuccessful()){
        System.out.println(response.body());
    }
    else{
        System.out.println(DeviceResponseError.createErrorMessage(response));
    }
} catch (ApiException e) {
    System.err.println("Exception when calling VariableService#putFormat");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
variableId Integer ID of the variable
value Integer New format of the variable

Return type

null (empty response body)

Authorization

No authorization required

putNumberOfElements

putNumberOfElements(variableId, value)

Write variable array size

Set the number of element of the variable

Example

let myService = new VariableService();
let variableId = 56; // Integer | ID of the variable
let value = 56; // Integer | New number of element for this variable

try{
    let call = myService.putNumberOfElements(variableId, value);
    let value = (await call).body();
    console.log(`putNumberOfElements: ${value}`);
}
catch (ex){
    // No response from device / response error (ie: device is not connected or request timeout)
    console.error(ex);
}
import com.iotize.android.device.device.api.service.definition.VariableService;

ServiceFactory serviceFactory = ...;
VariableService myService = serviceFactory.create(VariableService.class);


Integer variableId = 56; // Integer | ID of the variable
Integer value = 56; // Integer | New number of element for this variable
try {
    Call<Void> call = myService.putNumberOfElements(variableId, value);
    Response<Void> response = call.execute();
    if (response.isSuccessful()){
        System.out.println(response.body());
    }
    else{
        System.out.println(DeviceResponseError.createErrorMessage(response));
    }
} catch (ApiException e) {
    System.err.println("Exception when calling VariableService#putNumberOfElements");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
variableId Integer ID of the variable
value Integer New number of element for this variable

Return type

null (empty response body)

Authorization

No authorization required

putValue

putValue(variableId, value)

Set variable value

Example

let myService = new VariableService();
let variableId = 56; // Integer | ID of the variable
let value = BINARY_DATA_HERE; // byte[] | 

try{
    let call = myService.putValue(variableId, value);
    let value = (await call).body();
    console.log(`putValue: ${value}`);
}
catch (ex){
    // No response from device / response error (ie: device is not connected or request timeout)
    console.error(ex);
}
import com.iotize.android.device.device.api.service.definition.VariableService;

ServiceFactory serviceFactory = ...;
VariableService myService = serviceFactory.create(VariableService.class);


Integer variableId = 56; // Integer | ID of the variable
byte[] value = BINARY_DATA_HERE; // byte[] | 
try {
    Call<Void> call = myService.putValue(variableId, value);
    Response<Void> response = call.execute();
    if (response.isSuccessful()){
        System.out.println(response.body());
    }
    else{
        System.out.println(DeviceResponseError.createErrorMessage(response));
    }
} catch (ApiException e) {
    System.err.println("Exception when calling VariableService#putValue");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
variableId Integer ID of the variable
value byte[](byte[].md)

Return type

null (empty response body)

Authorization

No authorization required

setValue

setValue(variableId, value)

Set variable value

Difference with put ?

Example

let myService = new VariableService();
let variableId = 56; // Integer | ID of the variable
let value = BINARY_DATA_HERE; // byte[] | 

try{
    let call = myService.setValue(variableId, value);
    let value = (await call).body();
    console.log(`setValue: ${value}`);
}
catch (ex){
    // No response from device / response error (ie: device is not connected or request timeout)
    console.error(ex);
}
import com.iotize.android.device.device.api.service.definition.VariableService;

ServiceFactory serviceFactory = ...;
VariableService myService = serviceFactory.create(VariableService.class);


Integer variableId = 56; // Integer | ID of the variable
byte[] value = BINARY_DATA_HERE; // byte[] | 
try {
    Call<Void> call = myService.setValue(variableId, value);
    Response<Void> response = call.execute();
    if (response.isSuccessful()){
        System.out.println(response.body());
    }
    else{
        System.out.println(DeviceResponseError.createErrorMessage(response));
    }
} catch (ApiException e) {
    System.err.println("Exception when calling VariableService#setValue");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
variableId Integer ID of the variable
value byte[](byte[].md)

Return type

null (empty response body)

Authorization

No authorization required