IotCoreClient.Builder (iotcore 1.0.0 API)

com.google.android.things.iotcore

Class IotCoreClient.Builder

  • Enclosing class:
    IotCoreClient


    public static class IotCoreClient.Builder
    extends Object
    Constructs IotCoreClient instances.
    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • setConnectionParams

        public IotCoreClient.Builder setConnectionParams(@NonNull
                                                         ConnectionParams connectionParams)
        Set ConnectionParams the client should use to connect to Cloud IoT Core.

        This parameter is required.

        Parameters:
        connectionParams - the connection parameters the client should use
        Returns:
        this builder
      • setKeyPair

        public IotCoreClient.Builder setKeyPair(@NonNull
                                                KeyPair keyPair)
        Set the key pair used to register this device with Cloud IoT Core.

        Supports RSA and EC key algorithms. See the Cloud IoT Core security documentation for more information.

        This parameter is required.

        Parameters:
        keyPair - the key pair used to register the device in this configuration
        Returns:
        this builder
      • setTelemetryQueue

        public IotCoreClient.Builder setTelemetryQueue(@NonNull
                                                       Queue<TelemetryEvent> telemetryQueue)
        Set the queue the client should use for storing telemetry events when the client is disconnected from Cloud IoT Core.

        This parameter is optional. If the telemetry queue is unspecified, the default queue implementation is a queue that stores up to 1000 telemetry events and drops events from the head of the queue when messages are inserted beyond the maximum capacity.

        Users with more complicated requirements can provide their own telemetry queue implementation to control IotCoreClient's behavior when they are trying to publish events faster than IotCoreClient can send them to Cloud IoT Core (this could happen under adverse network conditions).

        Users who implement their own telemetry queue do not need to worry about concurrency or thread safety, but IotCoreClient takes ownership over its telemetry queue, so users should not attempt to add or remove events from the telemetry queue once the IotCoreClient is constructed.

        Parameters:
        telemetryQueue - the queue this client should use for storing unpublished telemetry events
        Returns:
        this builder
      • setConnectionCallback

        public IotCoreClient.Builder setConnectionCallback(@NonNull
                                                           Executor executor,
                                                           @NonNull
                                                           ConnectionCallback callback)
        Add a callback to receive updates when the connection to Cloud IoT Core changes.

        This parameter is optional.

        Parameters:
        executor - the thread the callback should be executed on
        callback - the callback to add
        Returns:
        this builder
      • setConnectionCallback

        public IotCoreClient.Builder setConnectionCallback(@NonNull
                                                           ConnectionCallback callback)
        Add a callback to receive updates when the connection to Cloud IoT Core changes.

        This parameter is optional.

        Parameters:
        callback - the callback to add
        Returns:
        this builder
      • setOnConfigurationListener

        public IotCoreClient.Builder setOnConfigurationListener(@NonNull
                                                                Executor executor,
                                                                @NonNull
                                                                OnConfigurationListener listener)
        Add a listener to receive configuration changes sent to the device from Cloud IoT Core.

        Cloud IoT Core resends device configuration every time the device connects to Cloud IoT Core, so clients should expect to receive the same configuration multiple times.

        This parameter is optional.

        Parameters:
        executor - the thread the callback should be executed on
        listener - the listener to add
        Returns:
        this builder
      • setOnConfigurationListener

        public IotCoreClient.Builder setOnConfigurationListener(@NonNull
                                                                OnConfigurationListener listener)
        Add a listener to receive configuration changes sent to the device from Cloud IoT Core.

        Cloud IoT Core resends device configuration every time the device connects to Cloud IoT Core, so clients should expect to receive the same configuration multiple times.

        This parameter is optional.

        Parameters:
        listener - the listener to add
        Returns:
        this builder
      • build

        public IotCoreClient build()
        Construct a new IotCoreClient with the Builder's parameters.
        Returns:
        a new IotCoreClient instance
        Throws:
        IllegalArgumentException - if the Builder's parameters are invalid
Was this page helpful? Let us know how we did:

Send feedback about...

Cloud IoT Core Documentation