com.ibm.wiotp.sdk.app

Class ApplicationClient

  • All Implemented Interfaces:
    org.eclipse.paho.client.mqttv3.MqttCallback, org.eclipse.paho.client.mqttv3.MqttCallbackExtended


    public class ApplicationClient
    extends AbstractClient
    implements org.eclipse.paho.client.mqttv3.MqttCallbackExtended
    A client, used by application, that handles connections with the IBM Watson IoT Platform.
    This is a derived class from AbstractClient and can be used by end-applications to handle connections with IBM Watson IoT Platform.
    • Constructor Detail

      • ApplicationClient

        public ApplicationClient(ApplicationConfig config)
                          throws Exception
        Create an application client for the IBM Watson IoT Platform. Connecting to specific org on IBM Watson IoT Platform
        Parameters:
        config - Configuration object for the client
        Throws:
        Exception - Failure in parsing the properties
    • Method Detail

      • publishEvent

        public boolean publishEvent(String typeId,
                                    String deviceId,
                                    String eventId,
                                    Object data,
                                    int qos)
        Publish event, on the behalf of a device, to the IBM Watson IoT Platform.
        This method will attempt to create a JSON obejct out of the payload
        Parameters:
        typeId - object of String which denotes deviceType
        deviceId - object of String which denotes deviceId
        eventId - object of String which denotes event
        data - Payload data
        qos - Quality of Service, in int - can have values 0,1,2
        Returns:
        Whether the send was successful.
      • publishCommand

        public boolean publishCommand(String typeId,
                                      String deviceId,
                                      String commandId,
                                      Object data,
                                      int qos)
        Publish command to the IBM Watson IoT Platform.
        This method will attempt to create a JSON obejct out of the payload
        Parameters:
        typeId - object of String which denotes deviceType
        deviceId - object of String which denotes deviceId
        commandId - object of String which denotes command
        data - Payload data
        qos - Quality of Service, in int - can have values 0,1,2
        Returns:
        Whether the send was successful.
      • subscribeToDeviceEvents

        public void subscribeToDeviceEvents(String typeId,
                                            String deviceId,
                                            String eventId,
                                            String format,
                                            int qos)
        Subscribe to device events of the IBM Watson IoT Platform.
        Parameters:
        typeId - object of String which denotes deviceType
        deviceId - object of String which denotes deviceId
        eventId - object of String which denotes event
        format - object of String which denotes format
        qos - Quality of Service, in int - can have values 0,1,2
      • subscribeToDeviceEvents

        public void subscribeToDeviceEvents(String typeId,
                                            String deviceId,
                                            String eventId,
                                            String format)
      • subscribeToDeviceEvents

        public void subscribeToDeviceEvents(String typeId,
                                            String deviceId,
                                            String eventId)
      • subscribeToDeviceEvents

        public void subscribeToDeviceEvents(String typeId,
                                            String deviceId)
      • subscribeToDeviceEvents

        public void subscribeToDeviceEvents(String typeId)
      • subscribeToDeviceEvents

        public void subscribeToDeviceEvents()
      • unsubscribeFromDeviceEvents

        public void unsubscribeFromDeviceEvents(String typeId,
                                                String deviceId,
                                                String eventId)
        Unsubscribe from device events of the IBM Watson IoT Platform.
        Parameters:
        typeId - object of String which denotes deviceType
        deviceId - object of String which denotes deviceId
        eventId - object of String which denotes event
      • unsubscribeFromDeviceEvents

        public void unsubscribeFromDeviceEvents(String typeId,
                                                String deviceId)
      • unsubscribeFromDeviceEvents

        public void unsubscribeFromDeviceEvents(String typeId)
      • unsubscribeFromDeviceEvents

        public void unsubscribeFromDeviceEvents()
      • subscribeToDeviceCommands

        public void subscribeToDeviceCommands(String typeId,
                                              String deviceId,
                                              String commandId,
                                              String format,
                                              int qos)
        Subscribe to device commands, on the behalf of a device, of the IBM Watson IoT Platform.
        Parameters:
        typeId - object of String which denotes deviceType
        deviceId - object of String which denotes deviceId
        commandId - object of String which denotes command
        format - object of String which denotes format
        qos - Quality of Service, in int - can have values 0,1,2
      • subscribeToDeviceCommands

        public void subscribeToDeviceCommands(String typeId,
                                              String deviceId,
                                              String commandId,
                                              String format)
      • subscribeToDeviceCommands

        public void subscribeToDeviceCommands(String typeId,
                                              String deviceId,
                                              String commandId)
      • subscribeToDeviceCommands

        public void subscribeToDeviceCommands(String typeId,
                                              String deviceId)
      • subscribeToDeviceCommands

        public void subscribeToDeviceCommands(String typeId)
      • unsubscribeFromDeviceCommands

        public void unsubscribeFromDeviceCommands(String typeId,
                                                  String deviceId,
                                                  String commandId)
        Unsubscribe from device commands of the IBM Watson IoT Platform.
        Parameters:
        typeId - object of String which denotes deviceType
        deviceId - object of String which denotes deviceId
        commandId - object of String which denotes command
      • unsubscribeFromDeviceCommands

        public void unsubscribeFromDeviceCommands(String typeId,
                                                  String commandId)
      • unsubscribeFromDeviceCommands

        public void unsubscribeFromDeviceCommands(String typeId)
      • unsubscribeFromDeviceCommands

        public void unsubscribeFromDeviceCommands()
      • subscribeToDeviceStatus

        public void subscribeToDeviceStatus(String typeId,
                                            String deviceId)
        Subscribe to device status of the IBM Watson IoT Platform.
        Parameters:
        typeId - object of String which denotes deviceType
        deviceId - object of String which denotes deviceId
      • subscribeToApplicationStatus

        public void subscribeToApplicationStatus(String appId)
        Subscribe to application status of the IBM Watson IoT Platform.
        Parameters:
        appId - object of String which denotes the application uniquely in the organization
      • unSubscribeFromApplicationStatus

        public void unSubscribeFromApplicationStatus(String appId)
        Unsubscribe from application status of the IBM Watson IoT Platform.
        Parameters:
        appId - object of String which denotes the application uniquely in the organization
      • connectionLost

        public void connectionLost(Throwable e)
        Simply log error when connection is lost
        Specified by:
        connectionLost in interface org.eclipse.paho.client.mqttv3.MqttCallback
      • connectComplete

        public void connectComplete(boolean reconnect,
                                    String serverURI)
        Specified by:
        connectComplete in interface org.eclipse.paho.client.mqttv3.MqttCallbackExtended
      • deliveryComplete

        public void deliveryComplete(org.eclipse.paho.client.mqttv3.IMqttDeliveryToken token)
        A completed deliver does not guarantee that the message is recieved by the service because devices send messages with Quality of Service (QoS) 0. The message count represents the number of messages that were sent by the device without an error on from the perspective of the device.
        Specified by:
        deliveryComplete in interface org.eclipse.paho.client.mqttv3.MqttCallback
      • messageArrived

        public void messageArrived(String topic,
                                   org.eclipse.paho.client.mqttv3.MqttMessage msg)
        Specified by:
        messageArrived in interface org.eclipse.paho.client.mqttv3.MqttCallback
      • registerCodec

        public void registerCodec(MessageCodec codec)
      • registerCommandCallback

        public void registerCommandCallback(CommandCallback callback)
      • registerEventCallback

        public void registerEventCallback(EventCallback callback)
      • setStatusCallback

        public void setStatusCallback(StatusCallback callback)

Copyright © 2019. All rights reserved.