CoapBlaster is an experimental open-source CoAP client/server library written in Java.
The initial design goals for CoapBlaster were best approximated as the following:
- Full RFC7252 support
- Flexible, easy-to-use API that supports both synchronous and asynchronous design patterns
- Robust, easy-to-use resource observation
- Easily swappable back-end to support various transports
- Full support for DTLS, COSE, and possibly OSCORE
Most of these goals have already been met, while a few are still in progress.
Note that because CoapBlaster is still at the experimental/preview stage, it should not be considered production ready.
Currently, CoapBlaster supports the following:
- Full RFC7252 support for the Constrained Application Protocol
- Retransmission/deduplication support
- Tunable transmission parameters
- API allows for both asynchronous and synchronous usage
- Supports sending and receiving asynchronous CoAP responses
- Effortless RFC7641 observation support
- Support for block2 transfers on both client and server interfaces
- Support for parsing and composing RFC6690-style link formats
- Support for diverting client requests through a CoAP proxy
Program:
import com.google.iot.m2m.LocalEndpointManager;
import com.google.iot.m2m.Client;
import com.google.iot.m2m.Transaction;
import com.google.iot.m2m.Message;
LocalEndpointManager manager = new LocalEndpointManager();
Client client = new Client(manager, "coap://coap.me/test");
Transaction transaction = client.newRequestBuilder().send();
try {
Message response = transaction.getResponse();
System.out.println("Got response: " + response);
} catch(Exception exception) {
System.out.println("Exception: " + exception);
}
Which will print out a long line which looks something like this:
<CONTENT IN ACK MID:44712 TOK:"f43c" 2.05 RADDR:"/134.102.218.18:5683" OPTS:[ETag:thZhiYJXp/I=, Content-Format:0] TEXT:"welcome to the ETSI plugtest! last change: 2018-1...">
- Example 1: Fetching resources
- Example 2: Serving a simple resource
- Example 3: Serving an observable resource
This project uses Maven for building. Once Maven is installed, you should be able to build and install the project by doing the following:
mvn verify
mvn install
Note that the master branch of this project depends on CborTree, so you may need to download, build, and install that project first.
Gradle:
dependencies {
compile 'com.google.iot.coap:coap:0.02.01'
}
Maven:
<dependency>
<groupId>com.google.iot.coap</groupId>
<artifactId>coap</artifactId>
<version>0.02.01</version>
</dependency>
This project uses Maven for building. Once Maven is installed, you should be able to build and install the project by doing the following:
mvn verify
mvn install
Note that the master branch of this project depends on CborTree, so you may need to download, build, and install those projects first.
CoapBlaster is released under the Apache 2.0 license.
Copyright 2018 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This is not an officially supported Google product.