public class GatewayClient extends DeviceClient implements org.eclipse.paho.client.mqttv3.MqttCallbackExtended
Gateways are a specialized class of devices in Watson IoT Platform which serve as access points to the Watson IoT Platform for other devices. Gateway devices have additional permission when compared to regular devices and can perform the following functions:
Refer to the documentation for more information about the Gateway support in Watson IoT Platform.
This is a derived class from AbstractClient.commandCallbacks, messageCodecs, messageCodecsByFormatCLIENT_ID_DELIMITER, config, DEFAULT_ACTION_TIMEOUT, DEFAULT_DISCONNECTED_BUFFER_SIZE, DEFAULT_MAX_CONNECT_ATTEMPTS, DEFAULT_MAX_INFLIGHT_MESSAGES, DEFAULT_MESSAGING_QOS, disconnectRequested, gson, messageCount, mqttAsyncClient, mqttCallback, mqttClient, mqttClientOptions, persistence| Constructor and Description |
|---|
GatewayClient(GatewayConfig config)
Create a Gateway client for the IBM Watson IoT Platform using the properties file passed.
|
| Modifier and Type | Method and Description |
|---|---|
void |
messageArrived(String topic,
org.eclipse.paho.client.mqttv3.MqttMessage msg)
This method is called by the MQTT library when a message(command) is sent by the IBM Watson IoT Platform.
|
boolean |
publishDeviceEvent(String deviceType,
String deviceId,
String event,
Object data) |
boolean |
publishDeviceEvent(String typeId,
String deviceId,
String eventId,
Object data,
int qos)
Publish an event on the behalf of a device to the IBM Watson IoT Platform.
|
void |
subscribeToDeviceCommands(String tpyeId,
String deviceId,
String commandId,
String format,
int qos)
Subscribe to device commands, on the behalf of a device, to the IBM Watson IoT Platform.
|
void |
unsubscribeFromDeviceCommands(String typeId,
String deviceId,
String commandId)
Unsubscribe from device commands, on the behalf of a device, from the IBM Watson IoT Platform.
|
connect, connectComplete, connectionLost, deliveryComplete, publishEvent, publishEvent, reconnect, registerCodec, registerCommandCallbackclose, configureMqttClient, disconnect, getConfig, isConnected, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitpublic GatewayClient(GatewayConfig config) throws Exception
Create a Gateway client for the IBM Watson IoT Platform using the properties file passed. The properties must have the following definitions,
config - Configuration object for the gateway client
with the Watson Internet of Things Platform module.Exception - Failure in parsing the properties passedpublic boolean publishDeviceEvent(String deviceType, String deviceId, String event, Object data)
public boolean publishDeviceEvent(String typeId, String deviceId, String eventId, Object data, int qos)
typeId - object of String which denotes deviceTypedeviceId - object of String which denotes deviceIdeventId - object of String which denotes eventdata - Payload dataqos - Quality of Service, in int - can have values 0,1,2public void subscribeToDeviceCommands(String tpyeId, String deviceId, String commandId, String format, int qos)
tpyeId - object of String which denotes deviceTypedeviceId - object of String which denotes deviceIdcommandId - object of String which denotes commandformat - object of String which denotes format, typical example of format could be jsonqos - Quality of Service, in int - can have values 0,1,2public void unsubscribeFromDeviceCommands(String typeId, String deviceId, String commandId)
typeId - object of String which denotes deviceTypedeviceId - object of String which denotes deviceIdcommandId - object of String which denotes command namepublic void messageArrived(String topic, org.eclipse.paho.client.mqttv3.MqttMessage msg)
This method is called by the MQTT library when a message(command) is sent by the IBM Watson IoT Platform.
The message(command) will be processed by this class and corresponding callback method will be called if registered.messageArrived in interface org.eclipse.paho.client.mqttv3.MqttCallbackmessageArrived in class DeviceClientCopyright © 2019. All rights reserved.