Class Anjay.Configuration

  • Enclosing class:
    Anjay

    public static final class Anjay.Configuration
    extends java.lang.Object
    Initial configuration used when creating an Anjay object.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      boolean confirmableNotifications
      Controls whether Notify operations are conveyed using Confirmable CoAP messages by default.
      java.util.Optional<int[]> defaultTlsCiphersuites
      (D)TLS ciphersuites to use if the "DTLS/TLS Ciphersuite" Resource (/0/x/16) is not available or empty.
      boolean disableLegacyServerInitiatedBootstrap
      If set to true, connection to the Bootstrap Server will be closed immediately after making a successful connection to any regular LwM2M Server and only opened again if (re)connection to a regular server is rejected.
      java.util.Optional<Anjay.DtlsVersion> dtlsVersion
      DTLS version to use for communication.
      java.lang.String endpointName
      Endpoint name as presented to the LwM2M server.
      long inBufferSize
      Maximum size of a single incoming CoAP message.
      long msgCacheSize
      Number of bytes reserved for caching CoAP responses.
      long outBufferSize
      Maximum size of a single outgoing CoAP message.
      boolean preferHierarchicalFormats
      Sets the preference of the library for Content-Format used when responding to a request without Accept option.
      long storedNotificationLimit
      If "Notification Storing When Disabled or Offline" resource is set to true and either the client is in offline mode, or uses Queue Mode, Notify messages are enqueued and sent whenever the client is online again.
      java.util.Optional<Anjay.DtlsHandshakeTimeouts> udpDtlsHsTxParams
      Configuration of the DTLS handshake retransmission timeouts for UDP connection.
      int udpListenPort
      UDP port number that all listening sockets will be bound to.
      java.util.Optional<Anjay.CoapUdpTxParams> udpTxParams
      Configuration of the CoAP transmission params for UDP connection, as per RFC 7252.
      boolean useConnectionId
      Enables support for DTLS connection_id extension for all DTLS connections.
    • Constructor Summary

      Constructors 
      Constructor Description
      Configuration()  
    • Method Summary

      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • udpListenPort

        public int udpListenPort
        UDP port number that all listening sockets will be bound to. It may be left at 0 - in that case, connection with each server will use a freshly generated ephemeral port number.
      • inBufferSize

        public long inBufferSize
        Maximum size of a single incoming CoAP message. Decreasing this value reduces memory usage, but packets bigger than this value will be dropped.
      • outBufferSize

        public long outBufferSize
        Maximum size of a single outgoing CoAP message. If the message exceeds this size, the library performs the block-wise CoAP transfer (https://tools.ietf.org/html/rfc7959).

        NOTE: in case of block-wise transfers, this value limits the payload size for a single block, not the size of a whole packet.

      • msgCacheSize

        public long msgCacheSize
        Number of bytes reserved for caching CoAP responses. If not 0, the library looks up recently generated responses and reuses them to handle retransmitted packets (ones with identical CoAP message ID).

        NOTE: while a single cache is used for all LwM2M servers, cached responses are tied to a particular server and not reused for other ones.

      • udpDtlsHsTxParams

        public java.util.Optional<Anjay.DtlsHandshakeTimeouts> udpDtlsHsTxParams
        Configuration of the DTLS handshake retransmission timeouts for UDP connection.

        If not set, the default configuration ANJAY_DTLS_DEFAULT_UDP_HS_TX_PARAMS will be selected internally.

        NOTE: Parameters are copied during Anjay(com.avsystem.anjay.Anjay.Configuration) and cannot be modified later on.

        IMPORTANT: In case of a need to adjust DTLS retransmission params to match the CoAP retransmission params, the udpDtlsHsTxParams shall be initialized as dtlsHsParams is in the following code snippet:

          final CoapUdpTxParams coapTxParams = ... // some initialization
        
          // Without ACK_RANDOM_FACTOR = 1.0, it is impossible to create a DTLS
          // configuration that matches CoAP retransmission configuration perfectly.
          if (coapTxParams.ackRandomFactor != 1.0) {
              throw new IllegalStateException();
          }
        
          final DtlsHandhshakeTimeouts = new DtlsHandshakeTimeouts(
              coapTxParams.ackTimeout,
              coapTxParams.ackTimeout.multipliedBy(1 << coapTxParams.ackTimeout.maxRetransmit)
          );
         
      • confirmableNotifications

        public boolean confirmableNotifications
        Controls whether Notify operations are conveyed using Confirmable CoAP messages by default.
      • disableLegacyServerInitiatedBootstrap

        public boolean disableLegacyServerInitiatedBootstrap
        If set to true, connection to the Bootstrap Server will be closed immediately after making a successful connection to any regular LwM2M Server and only opened again if (re)connection to a regular server is rejected.

        If set to false, legacy Server-Initiated Bootstrap is possible, i.e. the Bootstrap Server can reach the client at any time to re-initiate the bootstrap sequence.

        NOTE: This parameter controls a legacy Server-Initiated Bootstrap mechanism based on an interpretation of LwM2M 1.0 TS that is not universally accepted. Server-Initiated Bootstrap as specified in LwM2M 1.1 TS is always supported, regardless of this setting.

      • storedNotificationLimit

        public long storedNotificationLimit
        If "Notification Storing When Disabled or Offline" resource is set to true and either the client is in offline mode, or uses Queue Mode, Notify messages are enqueued and sent whenever the client is online again. This value allows one to limit the size of said notification queue. The limit applies to notifications queued for all servers.

        If set to 0, size of the stored notification queue is only limited by the amount of available RAM.

        If set to a positive value, that much most recent notifications are stored. Attempting to add a notification to the queue while it is already full drops the oldest one to make room for new one.

      • preferHierarchicalFormats

        public boolean preferHierarchicalFormats
        Sets the preference of the library for Content-Format used when responding to a request without Accept option.

        If set to true, the formats used would be:

        • for LwM2M 1.0: TLV,
        • for LwM2M 1.1: SenML CBOR, or if not compiled in, SenML JSON, or if not compiled in TLV.
      • useConnectionId

        public boolean useConnectionId
        Enables support for DTLS connection_id extension for all DTLS connections.
      • defaultTlsCiphersuites

        public java.util.Optional<int[]> defaultTlsCiphersuites
        (D)TLS ciphersuites to use if the "DTLS/TLS Ciphersuite" Resource (/0/x/16) is not available or empty.

        Passing an empty array or not setting at all will cause defaults of the TLS backend library to be used.

    • Constructor Detail

      • Configuration

        public Configuration()