https://github.com/mobius-software-ltd/coap-parser
COAP packets and headers parser library based on netty
https://github.com/mobius-software-ltd/coap-parser
coap coap-parser decoding encoding
Last synced: about 1 month ago
JSON representation
COAP packets and headers parser library based on netty
- Host: GitHub
- URL: https://github.com/mobius-software-ltd/coap-parser
- Owner: mobius-software-ltd
- Created: 2018-05-14T10:13:51.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-12-27T15:02:58.000Z (about 7 years ago)
- Last Synced: 2025-08-05T18:01:50.080Z (7 months ago)
- Topics: coap, coap-parser, decoding, encoding
- Language: Java
- Homepage:
- Size: 26.4 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# COAP-parser
COAP parser is a library designed for encoding and decoding of AMQP packets. It is written in Java.
COAP parser is developed by [Mobius Software](https://www.mobius-software.com/).
## Getting Started
First you should clone COAP parser. Then you should add the following lines within the element of pom.xml file of
your project:
```
com.mobius-software.coap
coap-parser
1.0.1-SNAPSHOT
```
Now you are able to start using COAP parser.
# Examples
## Create, encode, decode message
```
try
{
String name = "hanna";
String clientId = "hanna007";
String contentString = "hellow wo
int version = 1;
int messageID = 1;
byte[] content = contentString.getBytes();
byte[] nameBytes = name.getBytes();
byte[] nodeIdBytes = clientId.getBytes();
byte[] qosValue = new byte[2];
qosValue[1] = 0x01;
CoapMessage coapMessage = CoapMessage.builder().version(version).type(CoapType.CONFIRMABLE).code(CoapCode.PUT).messageID(messageID).payload(content)
.option(new CoapOption(CoapOptionType.URI_PATH.getValue(), nameBytes.length, nameBytes))
.option(new CoapOption((int) CoapOptionType.NODE_ID.getValue(), nodeIdBytes.length, nodeIdBytes)).option(new CoapOption(CoapOptionType.ACCEPT.getValue(), 2, qosValue)).build();
// Encode message
ByteBuf encoded = CoapParser.encode(open);
// process encoded value...
// Decode message
CoapMessage decoded = COAPParser.decode(encoded);
// process decoded value...https://github.com/mobius-software-ltd/coap-parser/blob/master/README.md
}
catch (Exception e)
{
e.printStackTrace();
fail();
}
```