System-to-User API

S2U gateway is a communication gateway with RESTful interface. It offers an interface for user applications.

All datasets are restricted according to user access rights in a concrete sensors network. You need a valid account in the system for a majority of interface operations.

Supported operations

GET getFirmware
retrieves a firmware for a given unit, supports partial retrieval of firmware chunks together with respective CRC-CCITT
POST login
obtains a new ticket from sign-on service
DELETE logout
invalidates a user sign-on ticket
GET check
validates a user sign-on ticket
GET getUnitMeasurement
reads measurements from a unit
GET getTile
renders a map tile
GET getResources
lists available resources
GET getSensors
lists available sensors
GET getMeasurementCollated
reads grouped measurements from a unit
GET getVhost
reads attributes and suggested settings of a virtual host
GET getResourceDateRange
reads date ranges of available datasets
GET getUnits
lists accessible units
GET getLastMeasurement
reads last measurements of accessible sensors
GET getCommunicationStatistics
lists timestamp of last registry and measurement packets for all units which are administered by a user

You can develop a client application in any programming language, just generate the REST client from WADL descriptor in your favorite IDE. If you are using Java, there is another (and more comfortable) way.

First, include our module in your Maven's pom.xml configuration:

<dependencies>
    ...
    <dependency>
        <groupId>cythres</groupId>
        <artifactId>sensnet-cli</artifactId>
        <version>0.9.5-SNAPSHOT</version>
    </dependency>
    ...
</dependencies>

Second, use cythres.sensnet.cli.RestClient class to access the API:

try (RestClient client = new RestClient("https://sensnet.cythres.cz/sn/rest")) {
    // login
    LoginSessionNoJpa session = client.login("user@sporilov.cythres.cz", "secret_password", "my application ID");

    // for instance, list units from VLAN007 subnet
    UnitInstance[] units = client.getUnits(session, "VLAN007");
    for (UnitInstance u : units) {
        System.out.println(u);
    }

    // ... invoke other methods of RestClient ...

    MeasurementCooked[] mc = client.getLastMeasurement(session, "VLAN007");
    for (MeasurementCooked u : mc) {
        System.out.println(u);
    }

    MeasurementCollated[] mo = client.getMeasurementCollated(session, "VLAN007", 50, 6, 1800, 0,
        (long) (Calendar.getInstance().getTimeInMillis() / 1000));
    for (MeasurementCollated u : mo) {
        System.out.println(u);
    }

    DataResource[] dr = client.getResources(session, "VLAN007");
    for (DataResource d : dr) {
        System.out.println(d);
    }

    ResourceDateRange[] rdr = client.getResourceDateRange(session, "VLAN007");
    for (ResourceDateRange r : rdr) {
        System.out.println(r);
    }

    mc = client.getUnitMeasurement(session, "VLAN007", 50, 6, 0,
        (long) (Calendar.getInstance().getTimeInMillis() / 1000));
    for (MeasurementCooked u : mc) {
        System.out.println(u);
    }

    // logout
    boolean result = client.logout(session);
    System.out.println("logout: "+result);
}