public abstract class Device extends Object implements BiConsumer<com.mmbnetworks.rotarrandevicemodel.DeviceProperty,com.mmbnetworks.rotarrandevicemodel.DeviceModel.DevicePropertyEventEnum>, Consumer<String>
Modifier and Type | Method and Description |
---|---|
abstract boolean |
abortOtaUpgrade()
Abort an ongoing OTA upgrade.
|
void |
accept(com.mmbnetworks.rotarrandevicemodel.DeviceProperty deviceProperty,
com.mmbnetworks.rotarrandevicemodel.DeviceModel.DevicePropertyEventEnum devicePropertyEventEnum) |
void |
accept(String json) |
boolean |
addPropertyUpdateHandler(BiConsumer<Device,Property> handler)
Adds a Property update handler.
|
boolean |
addProtocolHandler(BiConsumer<Device,String> handler)
Adds a ProtocolHandler to handle protocol messages from the Device.
|
CompletableFuture<String> |
addToGroup(int groupId) |
CompletableFuture<String> |
bindDevice(String destinationDeviceId,
String propertyToBind)
Creates a binding between this device (the source) and a destination
device, on the specified Property.
|
CompletableFuture<String> |
callFunction(String jsonFunctionObject)
Calls a function on the device model with the supplied parameters.
|
CompletableFuture<String> |
configureReporting(String propertyToBind,
List<Parameter> parameters)
Configures reporting a specified Property on this device.
|
CompletableFuture<Collection<Property>> |
discoverAllProperties()
Gets all
Property objects associated with this device type. |
abstract CompletableFuture<String> |
enableDefaultReporting()
Configures the device to report changes to its properties to the
GatewayClient to which it is connected.
|
Collection<Property> |
getCachedProperties()
Gets all currently known
Property objects associated with this device type. |
Optional<Property> |
getCachedProperty(String propertyName)
Gets the
Property with the associated propertyName . |
Collection<Property> |
getCachedProtocolProperties()
Gets all currently known
Property objects associated with this device type. |
Optional<String> |
getConnectedGatewayId()
Get the
String identifier of the Gateway that this Device
is connected to. |
DeviceConnectionType |
getDeviceConnectionType() |
abstract DeviceType |
getDeviceType()
Get the
DeviceType associated with the Device. |
abstract CompletableFuture<String> |
getHardwareVersion()
Retrieves the Hardware Version Of This Device.
|
String |
getID()
Get the
String identifier of this Device. |
abstract CompletableFuture<String> |
getManufacturerName()
Retrieves the Manufacturer Name Of This Device.
|
abstract CompletableFuture<String> |
getModelNumber()
Retrieves the Model Identifier Of This Device.
|
CompletableFuture<Collection<Property>> |
getProperties()
Gets all currently known
Property objects associated with this device type. |
CompletableFuture<Property> |
getProperty(String propertyName)
Gets the
Property with the associated propertyName . |
CompletableFuture<Collection<Property>> |
getProtocolProperties()
Get all currently known protocol
Property for this device. |
void |
leaveNetwork()
Request the remote device to leave the network.
|
CompletableFuture<String> |
ping()
Gets the round-trip latency information for a device, including last-hop LQI/RSSI
if available.
|
boolean |
removeAllPropertyUpdateHandlers()
Removes all handlers that have been previously registered.
|
boolean |
removeAllProtocolHandlers()
Removes all handlers that have been previously registered.
|
CompletableFuture<String> |
removeFromGroup(int groupId) |
boolean |
removePropertyUpdateHandler(BiConsumer<Device,Property> handler)
Removes a previously added handler.
|
boolean |
removeProtocolHandler(BiConsumer<Device,String> handler)
Removes a previously added ProtocolHandler
|
CompletableFuture<String> |
sendProtocolMessage(String json)
Using this device this method will send a zigbee specific protocol message (ZCL, or ZDO).
|
abstract boolean |
startOtaUpgrade()
Notify the remote device that an OTA image is available for upgrade.
|
CompletableFuture<String> |
unbindDevice(String destinationDeviceId,
String propertyName)
Removes the binding between this device (the source) and the destination device.
|
PropertyCommandData |
updateProperty(Property property)
Updates the
Property associated with this device. |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
andThen
public String getID()
String
identifier of this Device.public Optional<String> getConnectedGatewayId()
String
identifier of the Gateway that this Device
is connected to.public DeviceConnectionType getDeviceConnectionType()
public CompletableFuture<Collection<Property>> discoverAllProperties()
Property
objects associated with this device type.
A request to refresh the Property value will be sent out over the
underlying network, and will result in a PropertyUpdate handler being called if the value
is different, and a handler exists for this device.CompletableFuture
object. It will contain the collection of Property objects tied to the device.
The future will be tied to the deviceCompletableFuture
,
Property
public CompletableFuture<Collection<Property>> getProtocolProperties()
Property
for this device.
Note: Protocol Properties are properties that are specific to that particular protocol the device is using. i.e ZigBee, BlueTooth, ZWave etc
A request to refresh the Property value will be sent out over the underlying network, and will result in a PropertyUpdate handler being called if the value is different, and a handler exists for this device.CompletableFuture
object. It will contain the collection of Property objects tied to the deviceCompletableFuture
,
Property
public Collection<Property> getCachedProtocolProperties()
Property
objects associated with this device type.
Note: Protocol Properties are properties that are specific to that particular protocol the device is using. i.e ZigBee, BlueTooth, ZWave etc
Each Property in the collection will contain the last cached value for that Property, without going out to the underlying network to obtain it.
Collection
,
Property
public CompletableFuture<Collection<Property>> getProperties()
Property
objects associated with this device type.
A request to refresh the Property value will be sent out over the
underlying network, and will result in a PropertyUpdate handler being called if the value
is different, and a handler exists for this device.CompletableFuture
object. It will contain the collection of Property objects tied to the device.
The future will be tied to the deviceCompletableFuture
,
Property
public abstract CompletableFuture<String> getManufacturerName()
CompletableFuture
object will return immediately with the cached valueCompletableFuture
object. It will contain the manufacturer name if it exists.public abstract CompletableFuture<String> getHardwareVersion()
CompletableFuture
object will return immediately with the cached valueCompletableFuture
object. It will contain the hardware version if it exists.public abstract CompletableFuture<String> getModelNumber()
CompletableFuture
object will return immediately with the cached valueCompletableFuture
object. It will contain the model identifier if it exists.public Collection<Property> getCachedProperties()
Property
objects associated with this device type.
Each Property in the collection will contain the last cached value for that Property, without going out to the underlying network to obtain it.
CompletableFuture
,
Property
public CompletableFuture<Property> getProperty(String propertyName)
Property
with the associated propertyName
.
This call will request the latest value of the Property from the device on the network. If no properties has been discovered so far, it will perform a discovery on all properties.
propertyName
- Property identifier.CompletableFuture
representing the computation with Property
as a result. The Future object will throw an exception if it cannot find that property.CompletableFuture
,
Property
public Optional<Property> getCachedProperty(String propertyName)
Property
with the associated propertyName
.
This call will return the last known (cached) value of the Property from the device. Cached values are updated on writes, reads, and attribute reports.
propertyName
- Property identifier.Property
. Will be empty if the Property
is not found, or on any errorsProperty
public CompletableFuture<String> callFunction(String jsonFunctionObject) throws InvalidInputException
jsonFunctionObject
- contains the name, and supplied parameters to the device function.CompletableFuture
of a String
containing the result of the
function call.InvalidInputException
- if supplied jsonFunctionObject
parameter is not correct.public PropertyCommandData updateProperty(Property property)
Property
associated with this device.property
- Property object with a new value to update.PropertyCommandData
object with a cache Property value, if present, the CompletableFuture
representing the Computation and with the new Property
object if successful otherwise the
CompletableFuture
returns null.IllegalArgumentException
- if property
is nullpublic abstract DeviceType getDeviceType()
DeviceType
associated with the Device.DeviceType
object.public CompletableFuture<String> unbindDevice(String destinationDeviceId, String propertyName) throws InvalidInputException
destinationDeviceId
- Device ID of the destination device.propertyName
- Name of the Property to unbind.CompletableFuture
of a String
containing the
result of the function call.InvalidInputException
- if the supplied parameters are not correct.public CompletableFuture<String> bindDevice(String destinationDeviceId, String propertyToBind) throws InvalidInputException
destinationDeviceId
- Destination device ID to bind to.propertyToBind
- Property we want to bind on.CompletableFuture
of a String
containing the
result of the function call.InvalidInputException
- if supplied parameters are not correct.public CompletableFuture<String> configureReporting(String propertyToBind, List<Parameter> parameters) throws InvalidInputException
Reports are generally sent to the destination device that has a binding on the same Property being configured using this method.
propertyToBind
- Name of the Property to configure reporting for.parameters
- A list of reporting parameters. Can use empty list to use defaults.CompletableFuture
of a String
containing the
result of the function call.InvalidInputException
- If any of the parameters are incorrect.public CompletableFuture<String> addToGroup(int groupId)
public CompletableFuture<String> removeFromGroup(int groupId)
public abstract CompletableFuture<String> enableDefaultReporting() throws IllegalStateException
IllegalStateException
- if the function is called before
the device Properties have been discovered (i.e. through getProperties()).public boolean addPropertyUpdateHandler(BiConsumer<Device,Property> handler)
handler
- A Consumer
that is called when
a Property on the Device changes, or an error occurs.public boolean removePropertyUpdateHandler(BiConsumer<Device,Property> handler)
This method has no effect if the handler could not be found.
handler
- The handler to remove.public boolean removeAllPropertyUpdateHandlers()
The handler list will be empty after this call.
public boolean addProtocolHandler(BiConsumer<Device,String> handler)
When a message from the underlying protocol is received from this Device, the handler will be called with the message in JSON format.
handler
- A BiConsumer interface that is called when a protocol message
is received from this Device.public boolean removeProtocolHandler(BiConsumer<Device,String> handler)
This method has no effect if the handler could not be found.
handler
- The handler instance to remove.public boolean removeAllProtocolHandlers()
The handler list will be empty after this call.
public void leaveNetwork()
public CompletableFuture<String> ping()
CompletableFuture
of a String
representing
the LatencyInfo
class.
The CompletableFuture will complete exceptionally with a
RequestException
on errors.public abstract boolean startOtaUpgrade()
true
if OTA image notification is sent out successfully; false
otherwise.public abstract boolean abortOtaUpgrade()
true
if aborting OTA upgrade is sent out successfully; false
otherwise.public void accept(com.mmbnetworks.rotarrandevicemodel.DeviceProperty deviceProperty, com.mmbnetworks.rotarrandevicemodel.DeviceModel.DevicePropertyEventEnum devicePropertyEventEnum)
accept
in interface BiConsumer<com.mmbnetworks.rotarrandevicemodel.DeviceProperty,com.mmbnetworks.rotarrandevicemodel.DeviceModel.DevicePropertyEventEnum>
public CompletableFuture<String> sendProtocolMessage(String json) throws InvalidInputException
Note:
The final result of the CompletableFuture will be a json array containing all the responses, if any.
In order to receive the responses as they come, use the addProtocolHandler(BiConsumer)
method.
Every time a response is received in response to the request, the protocolHandlers will get triggered
containing the json string object
json
- JSON String of the messageCompletableFuture
where the result is a json array string containing the zcl or zdo response(s)
of the request.InvalidInputException
- if json is malformedCompletionException
- if something erroneous has happened during computationCompletableFuture
,
CompletionException
,
ZCLUnicastMessage
,
ZCLUnicastMessage.ZCLUnicastMessageBuilder
,
ZCLBroadcastMessage
,
ZCLBroadcastMessage.ZCLBroadcastMessageBuilder
,
ZCLMulticastMessage
,
ZCLMulticastMessage.ZCLMulticastMessageBuilder
,
ZCLResponseMessage
,
ZCLResponseMessage.ZCLResponseMessageBuilder
,
ZDOUnicastMessage
,
ZDOUnicastMessage.ZDOUnicastMessageBuilder
,
ZDOBroadcastMessage
,
ZDOBroadcastMessage.ZDOBroadcastMessageBuilder
,
ZDOResponseMessage
,
ZDOResponseMessage.ZDOResponseMessageBuilder
Copyright © 2021. All rights reserved.