1

Drivers from resource in Java SDK

Тема: Drivers from resource in Java SDK

Good day,
I have a detail with the java SDK since I want to take out the drivers that are registered in the account, but I only get the resources and I do not know how to activate the view of the drivers. Like to be able to join them to a unit: this is my code:

private void searchDrivers(){
        //Create new search specification
        SearchSpec searchSpec=new SearchSpec();
        Resource recurso = new Resource();
        recurso.getDataFlags();
        //Set items type to search avl_units
        searchSpec.setItemsType(Item.ItemType.avl_resource);
        //Set property name to search
        searchSpec.setPropName("sys_name");
        //Set property value mask to search all units
        searchSpec.setPropValueMask("*");
        //Set sort type by units name
        searchSpec.setSortType("sys_name");
        //Send search by created search specification with items base data flag and from 0 to maximum number
        session.searchItems(searchSpec, 1, Item.dataFlag.base.getValue() | Resource.accessFlag.viewDrivers.getValue() | Resource.dataFlag.drivers.getValue() | Resource.accessFlag.viewDriverUnits.getValue() , 0, Integer.MAX_VALUE, new SearchResponseHandler() {
            @Override
            public void onSuccessSearch(Item... items) {
                super.onSuccessSearch(items);
                // Search succeed
                System.out.println("Search items is successful");
                printDriversNames(items);
                //printUnitsId(items);
                //logout();
            }
            @Override
            public void onFailure(int errorCode, Throwable throwableError) {
                super.onFailure(errorCode, throwableError);
                // search item failed, print error
                System.out.println(Errors.getErrorText(errorCode));
                //logout();
            }
        });
    }

    private void printDriversNames(Item... items){

        if (items!=null && items.length>0) {
            System.out.println(String.format("%d units found\r\nPrinting their names...", items.length));
            //Print items names
            for (Item item : items) {
                System.out.println(String.format("\t%s", ((Resource) item).getId()));
                //ListaUnidades.add(item.getName());
            }
        }
        //return ListaUnidades;
    }

I hope you can help me with this topic, thank you.

2

Drivers from resource in Java SDK

Re: Drivers from resource in Java SDK

Can you help me, please?

3

Drivers from resource in Java SDK

Re: Drivers from resource in Java SDK

Denisse Hello. The drivers are not implemented in the Java SDK. You can add them following the example with Sensors or CommandDefinitions at Unit.class or Notifications and Reports at Resource.class.

Mobile Development
Gurtam