Skip to content

Commit

Permalink
use MAX_TRANSMIT_WAIT from NetworkConfig as client awake time by default
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed Jul 19, 2019
1 parent ecf87fa commit ea62317
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,11 @@ public LeshanServerBuilder disableQueueModeSupport() {
}

/**
* Sets a new {@link ClientAwakeTimeProvider} object different from the default one (93 seconds).
* Sets a new {@link ClientAwakeTimeProvider} object different from the default one.
* <p>
* By default a {@link StaticClientAwakeTimeProvider} will be used initialized with the
* <code>MAX_TRANSMIT_WAIT</code> value available in CoAP {@link NetworkConfig} which should be by default 93s as
* defined in <a href="https://tools.ietf.org/html/rfc7252#section-4.8.2">RFC7252</a>.
*
* @param awakeTimeProvider the {@link ClientAwakeTimeProvider} to set.
*/
Expand Down Expand Up @@ -378,8 +382,16 @@ public LeshanServer build() {
decoder = new DefaultLwM2mNodeDecoder();
if (coapConfig == null)
coapConfig = createDefaultNetworkConfig();
if (awakeTimeProvider == null)
awakeTimeProvider = new StaticClientAwakeTimeProvider();
if (awakeTimeProvider == null) {
int maxTransmitWait = coapConfig.getInt(Keys.MAX_TRANSMIT_WAIT);
if (maxTransmitWait == 0) {
LOG.warn(
"No value available for MAX_TRANSMIT_WAIT in CoAP NetworkConfig. Fallback with a default 93s value.");
awakeTimeProvider = new StaticClientAwakeTimeProvider();
} else {
awakeTimeProvider = new StaticClientAwakeTimeProvider(maxTransmitWait);
}
}
if (registrationIdProvider == null)
registrationIdProvider = new RandomStringRegistrationIdProvider();
if (endpointFactory == null) {
Expand Down

0 comments on commit ea62317

Please sign in to comment.