Class ConnectionBuilder<T extends ConnectionBuilder<T>>

    • Constructor Detail

      • ConnectionBuilder

        public ConnectionBuilder()
        Create a new connection builder, with default settings.
    • Method Detail

      • setSnClassInfo

        public T setSnClassInfo​(java.util.Collection<SnClassInfo> snClassInfos)
        Set the SN class info in order to compute the SN attribute/method offset.
        Parameters:
        snClassInfos - the class info.
        Returns:
        the ConnectionBuilder
      • setReferencingMethod

        public T setReferencingMethod​(ReferencingMethod referencingMethod)
        Set the referencing method used to address COSEM objects in the remote meter.

        The default referencing method is ReferencingMethod.LOGICAL.

        Parameters:
        referencingMethod - the referencing method.
        Returns:
        the ConnectionBuilder
      • setHdlcMaxInformationLength

        public void setHdlcMaxInformationLength​(int hdlcMaxInformationLength)
        Set the maximum HDLC information length.

        The information length is in the range of [128, 2030].

        Parameters:
        hdlcMaxInformationLength - the information length in #bytes.
      • setAlwaysSendSecurityMechanismName

        public T setAlwaysSendSecurityMechanismName​(boolean alwaysSendSecurityMechanismName)
        If set to true, the Security Mechanism Name is sent even if there is no security mechanism

        Default is false.

        Parameters:
        alwaysSendSecurityMechanismName - the flag
        Returns:
        the ConnectionBuilder
      • setSkipAARQEncryption

        public T setSkipAARQEncryption​(boolean skipAARQEncryption)
        If set to true, the AARQ is not encrypted even if the security suite requires it. (Non-standard)

        Default is false.

        Parameters:
        skipAARQEncryption - the flag
        Returns:
        the ConnectionBuilder
      • setSecuritySuite

        public T setSecuritySuite​(SecuritySuite securitySuite)
        Set SecuritySuite.

        Default authentication is NONE.

        Parameters:
        securitySuite - authentication object
        Returns:
        the ConnectionBuilder
      • setClientId

        public T setClientId​(int clientId)
        Set the client ID which should be used to connect to the server.

        Default client ID is 16 (Public Client).

        Parameters:
        clientId - the client id.
        Returns:
        the ConnectionBuilder
      • setUserId

        public T setUserId​(int userId)
        Set the user ID which should be used to connect to the server.

        No default user ID

        Parameters:
        userId - the user id.
        Returns:
        the ConnectionBuilder
      • setLogicalDeviceId

        public T setLogicalDeviceId​(int logicalDeviceId)
        Set the logical device ID of the logical device in the physical server.

        Default logical device ID is 1 (Management Logical Device).

        Parameters:
        logicalDeviceId - the logical device ID.
        Returns:
        the ConnectionBuilder
      • setChallengeLength

        public T setChallengeLength​(int challengeLength)
        Change the used challenge length.

        The length must be in the range [8, 64]. Default is 64.

        Parameters:
        challengeLength - challenge length
        Returns:
        the ConnectionBuilder
        Throws:
        java.lang.IllegalArgumentException - if the integer is not in the range [8, 64].
      • setFrameCounter

        public T setFrameCounter​(long frameCounter)
        Change the start frame counter (32 Bit unsigned).
        Parameters:
        frameCounter - frame counter
        Returns:
        the ConnectionBuilder * @throws IllegalArgumentException if the frame counter value is not in the range [0, 4294967295].
      • setPhysicalDeviceAddress

        public T setPhysicalDeviceAddress​(int physicalDeviceAddress)
        Sets the physical device address.

        This is only relevant if a connection over HDLC is used. In this case the physical device address is by default 0.

        Parameters:
        physicalDeviceAddress - the physical device address.
        Returns:
        the ConnectionBuilder
      • setResponseTimeout

        public T setResponseTimeout​(int responseTimeout)
        Sets the time in milliseconds the client waits for a response.
        Parameters:
        responseTimeout - time in milliseconds.
        Returns:
        the ConnectionBuilder
      • setSystemTitle

        public T setSystemTitle​(java.lang.String manufacturerId,
                                long deviceId)
        Set the client's system title. It consists of 8 bytes: 3 characters for the manufacturer ID and 5 bytes for the device ID. The default is "MMM" (manufacturer ID) and 1 (device ID).
        Parameters:
        manufacturerId - the manufacturer ID
        deviceId - the device ID
        Returns:
        the ConnectionBuilder
      • setRawMessageListener

        public T setRawMessageListener​(RawMessageListener rawMessageListener)
        Set the a RawMessageListener to log the incoming and outgoing messages as byte arrays.

        NOTE: listening to the data costs extra computation time.

        Parameters:
        rawMessageListener - the RawMessageListener.
        Returns:
        the builder.
        See Also:
        RawMessageData
      • build

        public DlmsConnection build()
                             throws java.io.IOException
        Builds a new DLMS/COSEM Connection, which is connected to the remote meter.
        Returns:
        A new DlmsConnection with the given settings.
        Throws:
        java.io.IOException - if an error occurs, while connecting to the meter.
        See Also:
        buildSnConnection()
      • buildSnConnection

        public DlmsSnConnection buildSnConnection()
                                           throws java.io.IOException
        Builds a new DLMS/COSEM short name (SN) referencing Connection, which is connected to the remote meter.

        This also sets the referencing method to short.

        Returns:
        A new DlmsSnConnection with the given settings.
        Throws:
        java.io.IOException - if an error occurs, while connecting to the meter.
        See Also:
        build()
      • buildSettings

        protected abstract Settings buildSettings()
      • buildSessionLayer

        protected abstract <S extends SettingsSessionLayer buildSessionLayer​(S settings)
                                                                        throws java.io.IOException
        Throws:
        java.io.IOException