public interface IotGateway extends IotDevice
This interface is incubating and is subject to change.
An IoT gateway device is a conduit for a collection of IoT devices that lack direct connection to the enterprise IoT hub.
An IoT gateway device is an IoT device. Events can be published
that are from the gateway's deviceId and commands can be received that are targeted for it
using the gateway's events()
and commands()
.
Use getIotDevice(Map)
to get an IotDevice
for a gateway connected device
or getIotDeviceId(Map)
to get a deviceId for it.
The name/value pairs in the map are IotGateway implementation defined values.
Refer to the IotGateway implementation for details.
Events can be published that are from a connected device's deviceId and commands can be
received for that are targeted for it using
eventsForDevice()
and commandsForDevice()
.
IotDevice
CMD_DEVICE, CMD_FORMAT, CMD_ID, CMD_PAYLOAD, CMD_TS, RESERVED_ID_PREFIX
Modifier and Type | Method and Description |
---|---|
TStream<com.google.gson.JsonObject> |
commandsForDevice(java.util.Set<java.lang.String> deviceIds,
java.lang.String... commands)
Create a stream of device commands as JSON objects.
|
TStream<com.google.gson.JsonObject> |
commandsForDevice(java.lang.String deviceId,
java.lang.String... commands)
Create a stream of device commands as JSON objects.
|
TStream<com.google.gson.JsonObject> |
commandsForType(java.lang.String deviceTypeId,
java.lang.String... commands)
Create a stream of device commands as JSON objects.
|
TSink<com.google.gson.JsonObject> |
eventsForDevice(Function<com.google.gson.JsonObject,java.lang.String> deviceId,
TStream<com.google.gson.JsonObject> stream,
Function<com.google.gson.JsonObject,java.lang.String> eventId,
UnaryOperator<com.google.gson.JsonObject> payload,
Function<com.google.gson.JsonObject,java.lang.Integer> qos)
Publish a stream's tuples as device events.
|
TSink<com.google.gson.JsonObject> |
eventsForDevice(java.lang.String deviceId,
TStream<com.google.gson.JsonObject> stream,
java.lang.String eventId,
int qos)
Publish a stream's tuples as device events.
|
IotDevice |
getIotDevice(java.util.Map<java.lang.String,java.lang.String> deviceIdAttrs)
Get an
IotDevice for a connected device. |
IotDevice |
getIotDevice(java.lang.String deviceId)
Get an
IotDevice for a connected device. |
java.lang.String |
getIotDeviceId(java.util.Map<java.lang.String,java.lang.String> deviceIdAttrs)
Get a
deviceId for a device. |
commands, events, events, getDeviceId, getDeviceType
topology
IotDevice getIotDevice(java.util.Map<java.lang.String,java.lang.String> deviceIdAttrs)
IotDevice
for a connected device.
No external validation of the attribute values is performed.deviceIdAttrs
- IotGateway implementation specific attributes
that identify a device.java.lang.String getIotDeviceId(java.util.Map<java.lang.String,java.lang.String> deviceIdAttrs)
deviceId
for a device.
Logically equivalent to getIotDevice(deviceIdAttrs).getDeviceId()
.
No external validation of the attribute values is performed.deviceIdAttrs
- IotGateway implementation specific attributes
that identify a device.IotDevice getIotDevice(java.lang.String deviceId)
IotDevice
for a connected device.deviceId
- a value from IotDevice.getDeviceId()
.TSink<com.google.gson.JsonObject> eventsForDevice(Function<com.google.gson.JsonObject,java.lang.String> deviceId, TStream<com.google.gson.JsonObject> stream, Function<com.google.gson.JsonObject,java.lang.String> eventId, UnaryOperator<com.google.gson.JsonObject> payload, Function<com.google.gson.JsonObject,java.lang.Integer> qos)
Events for a particular device can also be published via its
IotDevice.events()
.
deviceId
- function to supply the device-id that the event is associated with.stream
- Stream to be published.eventId
- function to supply the event identifier.payload
- function to supply the event's payload.qos
- function to supply the event's delivery Quality of Service.TSink<com.google.gson.JsonObject> eventsForDevice(java.lang.String deviceId, TStream<com.google.gson.JsonObject> stream, java.lang.String eventId, int qos)
Events for a particular device can also be published via its
IotDevice.event()
.
deviceId
- Device-id that the event is associated with.stream
- Stream to be published.eventId
- Event identifier.qos
- Event's delivery Quality of Service.TStream<com.google.gson.JsonObject> commandsForDevice(java.util.Set<java.lang.String> deviceIds, java.lang.String... commands)
deviceIds
matching commands
will
result in a tuple on the stream. The JSON object has these keys:
device
- Command's opaque target device's id String.
command
- Command identifier as a Stringtsms
- Timestamp of the command in milliseconds since the 1970/1/1 epoch.format
- Format of the command as a Stringpayload
- Payload of the command
format
is json
then payload
is JSONpayload
is StringdeviceIds
- Filter to include commands for the specified deviceIds
If the set is empty no filtering occurs. The commands for any device are included.commands
- Command identifiers to include. If no command identifiers are provided then the
stream will contain all device commands for the specified devices.TStream<com.google.gson.JsonObject> commandsForDevice(java.lang.String deviceId, java.lang.String... commands)
deviceId
matching commands
will
result in a tuple on the stream. The JSON object has these keys:
device
- Command's target device's opaque id String.
command
- Command identifier as a Stringtsms
- Timestamp of the command in milliseconds since the 1970/1/1 epoch.format
- Format of the command as a Stringpayload
- Payload of the command
format
is json
then payload
is JSONpayload
is String
Equivalent to commandsForDevice(Collections.singleton(deviceId)), ...
.
deviceId
- Filter to include commands for the specified deviceIdcommands
- Command identifiers to include. If no command identifiers are provided then the
stream will contain all device commands for the specified device.TStream<com.google.gson.JsonObject> commandsForType(java.lang.String deviceTypeId, java.lang.String... commands)
deviceTypeId
matching commands
will result in a tuple on the stream. The JSON object has these keys:
device
- Command's target device's opaque id String.
command
- Command identifier as a Stringtsms
- Timestamp of the command in milliseconds since the 1970/1/1 epoch.format
- Format of the command as a Stringpayload
- Payload of the command
format
is json
then payload
is JSONpayload
is String
An IoT connector implementation may throw
UnsupportedOperationException
if it does not support this capability. See the implementation's documentation.
deviceTypeId
- Only return commands for connected devices with the specified
device type id value (a value from IotDevice.getDeviceType()
).commands
- Command identifiers to include. If no command identifiers are provided then the
stream will contain all device commands for devices with the specified device type id.Copyright © 2017 The Apache Software Foundation. All Rights Reserved - 4744f56-20170226-1707