Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit 35880a9

Browse files
committed
Anjay-java 2.11.0
1 parent beba583 commit 35880a9

File tree

159 files changed

+2713
-467
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+2713
-467
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Changelog
22

3+
## 2.11.0 (May 12, 2021)
4+
5+
- Update Anjay to 2.11.0
6+
- Add tests for Observe attributes, security modes, setting offline mode and
7+
reconnecting
8+
- Add AnjayAccessControl class
9+
- Fix binding to the specific port
10+
- Fix build on macOS
11+
- Fix throwing exceptions from native code, now they're translated to Exception
12+
instead of Error
13+
- Fix demo arguments description
14+
- Fix race condition that could lead to crashes when shutting down the library
15+
316
## 2.8.0.1 (Dec 1, 2020)
417

518
- Update Anjay to 2.8.0

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
# Anjay-java [<img align="right" height="50px" src="https://avsystem.github.io/Anjay-doc/_images/avsystem_logo.png">](http://www.avsystem.com/)
2+
13
[![Maven Central](https://img.shields.io/maven-central/v/com.avsystem.anjay/anjay-android?label=maven%20central%3A%20anjay-android)](https://search.maven.org/artifact/com.avsystem.anjay/anjay-android)
24
[![Maven Central](https://img.shields.io/maven-central/v/com.avsystem.anjay/anjay-java?label=maven%20central%3A%20anjay-java)](https://search.maven.org/artifact/com.avsystem.anjay/anjay-java)
35

4-
# Anjay-java [<img align="right" height="50px" src="https://avsystem.github.io/Anjay-doc/_images/avsystem_logo.png">](http://www.avsystem.com/)
5-
66
## About
77

88
This project provides almost 1:1 API bindings between [Anjay](https://github.com/AVSystem/Anjay)

demo/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 AVSystem <[email protected]>
2+
* Copyright 2020-2021 AVSystem <[email protected]>
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

demo/settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 AVSystem <[email protected]>
2+
* Copyright 2020-2021 AVSystem <[email protected]>
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

demo/src/main/java/com/avsystem/anjay/demo/DemoArgs.java

Lines changed: 115 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 AVSystem <[email protected]>
2+
* Copyright 2020-2021 AVSystem <[email protected]>
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,10 +21,50 @@
2121
import com.beust.jcommander.IStringConverter;
2222
import com.beust.jcommander.Parameter;
2323
import com.beust.jcommander.ParameterException;
24+
import java.time.Duration;
25+
import java.util.Arrays;
26+
import java.util.List;
27+
import java.util.regex.Matcher;
28+
import java.util.regex.Pattern;
2429
import org.apache.commons.codec.DecoderException;
2530
import org.apache.commons.codec.binary.Hex;
2631

2732
public class DemoArgs {
33+
public static final class AccessEntry {
34+
public int ssid;
35+
public int oid;
36+
public int iid;
37+
public int accessMask;
38+
}
39+
40+
public static AccessEntry convertAccessEntry(String value) {
41+
Pattern pattern = Pattern.compile("/(\\d+)/(\\d+),(\\d+),(\\d+)");
42+
Matcher matcher = pattern.matcher(value);
43+
if (matcher.matches()) {
44+
AccessEntry accessEntry = new AccessEntry();
45+
accessEntry.oid = Integer.parseInt(matcher.group(1));
46+
accessEntry.iid = Integer.parseInt(matcher.group(2));
47+
accessEntry.ssid = Integer.parseInt(matcher.group(3));
48+
accessEntry.accessMask = Integer.parseInt(matcher.group(4));
49+
return accessEntry;
50+
}
51+
return null;
52+
}
53+
54+
private static class AccessEntryConverter implements IStringConverter<AccessEntry> {
55+
@Override
56+
public AccessEntry convert(String value) {
57+
AccessEntry accessEntry = DemoArgs.convertAccessEntry(value);
58+
if (accessEntry != null) {
59+
return accessEntry;
60+
}
61+
throw new ParameterException(
62+
"incorrect value of access entry argument: \""
63+
+ value
64+
+ "\", the format is: /OID/IID,SSID,mask");
65+
}
66+
}
67+
2868
private static class Lwm2mVersionConverter implements IStringConverter<Lwm2mVersion> {
2969
@Override
3070
public Lwm2mVersion convert(String value) {
@@ -35,7 +75,7 @@ public Lwm2mVersion convert(String value) {
3575
}
3676
throw new ParameterException(
3777
"incorrect value of version argument, expected one of: "
38-
+ Lwm2mVersion.values());
78+
+ Arrays.toString(Lwm2mVersion.values()));
3979
}
4080
}
4181

@@ -49,7 +89,7 @@ public SecurityMode convert(String value) {
4989
}
5090
throw new ParameterException(
5191
"incorrect value of security mode argument, expected one of: "
52-
+ SecurityMode.values());
92+
+ Arrays.toString(SecurityMode.values()));
5393
}
5494
}
5595

@@ -64,6 +104,13 @@ public byte[] convert(String value) {
64104
}
65105
}
66106

107+
private static class DurationConverter implements IStringConverter<Duration> {
108+
@Override
109+
public Duration convert(String value) {
110+
return Duration.ofMillis((long) (Double.parseDouble(value) * 1000));
111+
}
112+
}
113+
67114
@Parameter(
68115
names = {"-u", "--server-uri"},
69116
description = "Server URI to connect to")
@@ -89,11 +136,51 @@ public byte[] convert(String value) {
89136
converter = HexStringConverter.class)
90137
public byte[] pskOrPrivKey;
91138

139+
@Parameter(
140+
names = {"-C", "--client-cert-file"},
141+
description =
142+
"DER-formatted client certificate file to load. Mutually exclusive with -i.")
143+
public String clientCertFile;
144+
145+
@Parameter(
146+
names = {"-K", "--key-file"},
147+
description =
148+
"DER-formatted PKCS#8 private key complementary to the certificate specified with -C. Mutually exclusive with -k.")
149+
public String keyFile;
150+
92151
@Parameter(
93152
names = {"-e", "--endpoint-name"},
94153
description = "endpoint name to use")
95154
public String endpointName = "anjay-jni";
96155

156+
@Parameter(
157+
names = {"-b", "--bootstrap"},
158+
description = "treat first URI as Bootstrap Server")
159+
public boolean bootstrap;
160+
161+
@Parameter(
162+
names = "--bootstrap=client-initiated-only",
163+
description =
164+
"treat first URI as Bootstrap Server (the legacy LwM2M 1.0-style Server-Initiated bootstrap mode is not available)")
165+
public boolean bootstrapClientInitiatedOnly = false;
166+
167+
@Parameter(
168+
names = {"-H", "--bootstrap-holdoff"},
169+
description = "number of seconds to wait before attempting Client Initiated Bootstrap")
170+
public Integer bootstrapHoldoff = 0;
171+
172+
@Parameter(
173+
names = {"-T", "--bootstrap-timeout"},
174+
description =
175+
"number of seconds to keep the Bootstrap Server Account for after successful bootstrapping, or 0 for infinity")
176+
public Integer bootstrapTimeout = 0;
177+
178+
@Parameter(
179+
names = {"-a", "--access-entry"},
180+
description = "create ACL entry for specified /OID/IID and SSID",
181+
listConverter = AccessEntryConverter.class)
182+
public List<AccessEntry> accessEntries = null;
183+
97184
@Parameter(
98185
names = "--dm-persistence-file",
99186
description =
@@ -123,12 +210,37 @@ public byte[] convert(String value) {
123210
converter = Lwm2mVersionConverter.class)
124211
public Lwm2mVersion maximumVersion = Lwm2mVersion.VERSION_1_1;
125212

213+
@Parameter(
214+
names = "--cache-size",
215+
description =
216+
"Size, in bytes, of a buffer reserved for caching sent responses to detect retransmissions. Setting it to 0 disables caching mechanism.")
217+
public Integer cacheSize = 0;
218+
126219
@Parameter(
127220
names = {"--fw-cert-file"},
128221
description =
129222
"Require certificate validation against specified file when downloading firmware over encrypted channels")
130223
public String fwCertFile = null;
131224

225+
@Parameter(
226+
names = "--ack-random-factor",
227+
description = "Configures ACK_RANDOM_FACTOR (defined in RFC7252)")
228+
public Double ackRandomFactor = 1.5;
229+
230+
@Parameter(
231+
names = "--ack-timeout",
232+
description = "Configures ACK_TIMEOUT (defined in RFC7252) in seconds",
233+
converter = DurationConverter.class)
234+
public Duration ackTimeout = Duration.ofSeconds(2);
235+
236+
@Parameter(
237+
names = "--max-retransmit",
238+
description = "Configures MAX_RETRANSMIT (defined in RFC7252)")
239+
public Integer maxRetransmit = 4;
240+
241+
@Parameter(names = "--nstart", description = "Configures NSTART (defined in RFC7252)")
242+
public Integer nstart = 1;
243+
132244
@Parameter(
133245
names = {"-h", "--help"},
134246
description = "shows this message and exits",

0 commit comments

Comments
 (0)