Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

chirpstack-api

ChirpStack gRPC API message and service wrappers for Java.

ToDo

Install

An artifact is not yet public on Maven Central, you have build your own jar with

make java

and then with Maven install artifact on your Local Maven Repo

sudo chown $(id -u).$(id -g) java/build/ -R && mvn -f java/build/pom.xml install

Usage

All messages, services, constants, etc. are auto-generated from the ChirpStack protobuf definitions. The result is that this package structure matches that of the protobuf definitions.

The protobuf definitions can be found here: https://github.com/brocaar/chirpstack-api/tree/master/protobuf

Example

Maven dependencies.

NOTE: for chirpstack-api you have to follow Install instructions

<dependency>
  <groupId>io.grpc</groupId>
  <artifactId>grpc-okhttp</artifactId>
  <version>${grpc.version}</version>
</dependency>

<dependency>
  <groupId>io.chirpstack</groupId>
  <artifactId>chirpstack-api</artifactId>
  <version>3.9.3</version>
</dependency>

#1 blocking stub login

private static void login() {
    ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 8080)
            .build();

    InternalServiceGrpc.InternalServiceBlockingStub stub = InternalServiceGrpc.newBlockingStub(channel);

    Internal.LoginRequest loginRequest = Internal.LoginRequest.newBuilder()
            .setEmail("user")
            .setPassword("password")
            .build();

    Internal.LoginResponse loginResponse = stub.login(loginRequest);

    String token = loginResponse.getJwt();
    logger.info("token={}", token);

    channel.shutdown();
}