Skip to content
This repository has been archived by the owner on Nov 16, 2024. It is now read-only.
/ llrp4j Public archive
forked from enilink/llrp4j

LLRP protocol and networking for Java

Notifications You must be signed in to change notification settings

cjhawley/llrp4j

 
 

Repository files navigation

LLRP4J - LLRP for Java Build Status

LLRP protocol and networking implementation for Java.

LLRP4J implements encoders and decoders for the binary and (proprietary) XML serializations of the Low Level Reader Protocol (LLRP).

LLRP4J consists of the following modules:

  • llrp4j-core: Encoders and decoders for the binary and XML serializations.

  • llrp4j-generator: Java source code generator for annotated POJOs based on XML definition files.

  • llrp4j-llrp-module: The LLRP module that provides Java classes for messages and parameters as defined by the LLRP 1.1 standard.

  • llrp4j-impinj-module: A placeholder for a custom Impinj module whose definition (impinjdef.xml) must be directly obtained from Impinj due to licensing restrictions.

  • llrp4j-net: LLRP client and server implementations using Java NIO.

Get started

final LlrpContext ctx = LlrpContext.create(new LlrpModule());
LlrpEndpoint endpoint = new LlrpEndpoint() {
  @Override
  public void messageReceived(LlrpMessage message) {
    StringWriter writer = new StringWriter();
    try {
      XMLStreamWriter xmlWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(writer);
      ctx.createXmlEncoder(true).encodeMessage(message, xmlWriter);
      String xml = writer.toString();
      System.out.println("RECEIVED:\n" + xml);
    } catch (Exception e) {
      // handle exception
    }
  }

  @Override
  public void errorOccured(String message, Throwable cause) {
  }
};
LlrpServer server = LlrpServer.create(ctx, "127.0.0.1").endpoint(endpoint);
LlrpClient client = LlrpClient.create(ctx, "127.0.0.1").endpoint(endpoint);

client.transact(new SET_READER_CONFIG().resetToFactoryDefault(true));

client.close();
server.close();

Get the sources

git clone https://github.com/enilink/llrp4j

Build LLRP4J

LLRP4J can be build with Maven. You can simply use mvn -P generator package to compile and package all modules or mvn -P generator install to install them within your local Maven repository.

Differences to LLRP Toolkit for Java

A popular implementation of LLRP in Java is the LLRP Toolkit (LTK) for Java. Its development has been stalled since 2012 and hence we decided to create a new LLRP library for Java with the following benefits:

  • Pluggable serializers: LLRP4J does not generate the serialization logic into the message and parameter classes but uses annotations to declare the respective LLRP data types and encoding rules. This enables serializers to leverage runtime reflection for encoding or decoding message and parameter objects.

  • Dynamic modules: LLRP4J can be extended with modules at runtime to add custom messages or parameters. LTK for Java had to know custom messages or parameters at the generation time of the Java source code for messages and parameters.

  • Minimal runtime dependencies: LLRP4J has no additional runtime dependencies other than SLF4J.

  • Better code generator: LLRP4J uses JCodeModel for source code generation that is simpler and better extendable in comparison to the template based approach of LTK for Java.

License

LLRP4J is licensed under the Eclipse Public License v1.0.

Acknowledgements

The networking module is based on the Rox Java NIO Tutorial and the bit buffer implementation is a fork of https://github.com/magik6k/BitBuffer.

About

LLRP protocol and networking for Java

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 99.8%
  • Shell 0.2%