public interface IotDevice extends TopologyElement
IotDevice characteristics:
IotDevice.getDeviceTypeId()
returns an opaque value whose form
is the domain of an IoT connector implementation.IotDevice.getDeviceId()
returns an opaque value whose form
is the domain of an IoT connector implementation.
The value is unique for a particular a logical device.
IotDevice.equals()
returns true if two IotDevice instances are
for the same logical device, false otherwise.IotDevice.hashCode()
returns the same value for all IotDevice instances
for the same logical device.IotGateway
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CMD_DEVICE
Device identifier key.
|
static java.lang.String |
CMD_FORMAT
Command format key.
|
static java.lang.String |
CMD_ID
Command identifier key.
|
static java.lang.String |
CMD_PAYLOAD
Command payload key.
|
static java.lang.String |
CMD_TS
Command timestamp (in milliseconds) key.
|
static java.lang.String |
RESERVED_ID_PREFIX
Device event and command identifiers starting with "edgent" are reserved for use by Edgent.
|
Modifier and Type | Method and Description |
---|---|
TStream<com.google.gson.JsonObject> |
commands(java.lang.String... commands)
Create a stream of device commands as JSON objects.
|
TSink<com.google.gson.JsonObject> |
events(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> |
events(TStream<com.google.gson.JsonObject> stream,
java.lang.String eventId,
int qos)
Publish a stream's tuples as device events.
|
java.lang.String |
getDeviceId()
Get the device's unique opaque device identifier.
|
java.lang.String |
getDeviceType()
Get the device's opaque device type identifier.
|
topology
static final java.lang.String RESERVED_ID_PREFIX
static final java.lang.String CMD_ID
commands(String...)
,
Constant Field Valuesstatic final java.lang.String CMD_TS
commands(String...)
,
Constant Field Valuesstatic final java.lang.String CMD_FORMAT
commands(String...)
,
Constant Field Valuesstatic final java.lang.String CMD_PAYLOAD
json
then
the key's value will be a JsonObject
,
otherwise a String
.
Key is "payload".commands(String...)
,
Constant Field Valuesstatic final java.lang.String CMD_DEVICE
getDeviceId()
.commands(String...)
,
Constant Field Valuesjava.lang.String getDeviceType()
java.lang.String getDeviceId()
TSink<com.google.gson.JsonObject> events(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)
Each tuple is published as a device event with the supplied functions providing the event identifier, payload and QoS. The event identifier and QoS can be generated based upon the tuple.
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> events(TStream<com.google.gson.JsonObject> stream, java.lang.String eventId, int qos)
Each tuple is published as a device event with fixed event identifier and QoS.
stream
- Stream to be published.eventId
- Event identifier.qos
- Event's delivery Quality of Service.TStream<com.google.gson.JsonObject> commands(java.lang.String... commands)
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 Stringcommands
- Command identifiers to include. If no command identifiers are provided then the
stream will contain all of this IotDevice's device commands.Copyright © 2017 The Apache Software Foundation. All Rights Reserved - 4744f56-20170226-1707