| Modifier | Constructor and Description |
|---|---|
protected |
Device(long deviceNodeId,
Network parent)
|
| Modifier and Type | Method and Description |
|---|---|
void |
addTuyaResource(java.lang.String metadata,
java.util.List<Parameter<InfoResponse.Value>> parameters,
long timeout,
Device.AddResourceListener listener)
This function is used to add the discovered resources to the resource list.
|
void |
addZigbeeResource(java.lang.String resourceEui,
java.lang.String metadata,
java.util.List<Parameter<InfoResponse.Value>> parameters,
long timeout,
Device.AddResourceListener listener)
This function is used to add the discovered resources to the resource list.
|
void |
addZwaveResource(java.lang.String metadata,
java.util.List<Parameter<InfoResponse.Value>> parameters,
long timeout,
Device.AddResourceListener listener)
This function is used to add the discovered resources to the resource list.
|
void |
configureWiFi(java.lang.String ssid,
java.lang.String password,
Device.DeviceManagementStatusListener listener)
Change the connected Wi-Fi of the device.
|
boolean |
containsResource(java.lang.String resourceEui)
This function checks membership of resource in resource map.
|
void |
discoverResources(RadioProtocol protocol,
Device.DiscoverResourceListener listener)
This function is used to discover resources of the given device which are present.
|
void |
discoverResources(RadioProtocol protocol,
long timeout,
Device.DiscoverResourceListener listener)
This function is used to discover resources of the given device which are present.
|
void |
forceRemoveResource(Resource resource,
Device.RemoveResourceListener listener)
FORCE Remove the resource from the device.
|
int[] |
getAvailableChannelPorts(int portCount)
A function to get free ports to talk to this device.
|
java.lang.String |
getDevicePsn()
A function to get the PSN of the device.
|
java.lang.String |
getFirmwareVersion()
A function to get the version of firmware the device is running.
|
long |
getId()
This function is used to get the unique identifier of the device.
|
java.lang.String |
getMake()
A function to get the Manufacturer name of the device.
|
java.lang.String |
getModel()
A function to get the model name of the device.
|
java.lang.String |
getName()
This function is used to get the Name of the device.
|
Network |
getParent()
This function is used to get the parent Network of the given device.
|
PowerSource |
getPowerSource()
A function to get the
PowerSource on which the device is running on. |
java.lang.String |
getProductName()
A function to get the product name of the device.
|
ReceiverType |
getReceiverType()
A function to get the
ReceiverType of the device. |
<T extends Resource> |
getResource(java.lang.String resourceEui)
This function is used to get the resource with the given EUI.
|
java.util.Map<java.lang.String,Resource> |
getResourceMap()
This function is used to return the HashMap that the sdk uses to map
the resourceEuis to the Resource Objects.
|
java.util.List<RadioProtocol> |
getSupportedProtocols()
A getter of list of supported radio protocols.
|
int |
hashCode() |
protected void |
internalAddResource(Resource resource)
A function that would be triggered when a
Resource is added. |
protected void |
internalRemoveDevice()
A function that would be triggered when the device is removed.
|
protected void |
internalRemoveResource(java.lang.String resourceEui)
A function that would be triggered when a
Resource is removed. |
protected void |
internalSetDevicePsn(java.lang.String devicePsn)
A function that would be triggered when
devicePsn is updated. |
protected void |
internalSetExtendable(boolean extendable)
A function that would be triggered when
isExtendable is updated. |
protected void |
internalSetFirmwareVersion(java.lang.String firmwareVersion)
A function that would be triggered when
firmwareVersion is updated. |
protected void |
internalSetMake(java.lang.String make)
A function that would be triggered when
make is updated. |
protected void |
internalSetModel(java.lang.String model)
A function that would be triggered when
model is updated. |
protected void |
internalSetName(java.lang.String deviceName)
A function that would be triggered when
name is updated. |
protected void |
internalSetParent(Network parent)
A function that would be triggered when
parent is updated. |
protected void |
internalSetPowerSource(PowerSource powerSource)
A function that would be triggered when
powerSource is updated. |
protected void |
internalSetProductName(java.lang.String productName)
A function that would be triggered when
productName is updated. |
protected void |
internalSetProtocolSupported(int[] supportedProtocols)
A function that would be triggered when
supportedProtocolFlags are updated. |
protected void |
internalSetReady(boolean ready)
A function that would be triggered when
ready is updated. |
protected void |
internalSetReceiverType(ReceiverType receiverType)
A function that would be triggered when
receiverType is updated. |
boolean |
isExtendable()
This function is used to indicate that the device is extendable or not.
|
boolean |
isReady()
A function suggesting if the device is created from
NativeCallbacks.deviceInfoCallback(boolean, boolean, java.lang.String, long, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, int, int, boolean, int[], java.lang.String[], java.lang.Object)
or retrieved from cache. |
java.util.Iterator<Resource> |
iterator() |
void |
reboot(Device.DeviceManagementStatusListener listener)
This function is used to reboot the device.
|
void |
removeResource(Resource resource,
java.util.List<Parameter<InfoResponse.Value>> parameters,
long timeout,
Device.RemoveResourceListener listener)
This function is used to remove the previously added resources.
|
void |
sendDeviceManagementCommand(Command<Device.CommandId> command,
Device.DeviceManagementStatusListener listener)
A function to send commands such as removing resource
Device.RemoveResource,
adding resource Device.AddResource to device. |
void |
sendInfoRequest(InfoRequest infoRequest,
Device.InfoRequestStatusListener listener)
A function to send InfoRequest to a device.
|
void |
sendInfoResponse(InfoResponse infoResponse,
Device.InfoResponseStatusListener listener)
A call to respond to the commandInfoRequest.
|
protected void |
setResourceMetadata(Resource resource,
java.lang.String metadata,
Device.DeviceManagementStatusListener listener)
This function is used to set metadata of resource.
|
protected void |
setResourceName(Resource resource,
java.lang.String name,
Device.DeviceManagementStatusListener listener)
This function is used to set name of resource.
|
boolean |
supportsProtocol(RadioProtocol radioProtocol)
This function offers an easy check if the Device in interest supports any of
RadioProtocol. |
java.lang.String |
toString() |
protected Device(long deviceNodeId,
Network parent)
deviceNodeId - The unique id of the device.parent - The parent network of the device.public void sendDeviceManagementCommand(Command<Device.CommandId> command, Device.DeviceManagementStatusListener listener)
Device.RemoveResource,
adding resource Device.AddResource to device.
device
.sendDeviceManagementCommand(
new Device.RemoveResource(resourceEui, parameters,
(commandResponse, resourceImpacted, throwable) -> {
if (null != throwable) {
// success case.
}
}));
command - Command to be sent to Device.listener - The listener which will be triggered after the callbackpublic void reboot(Device.DeviceManagementStatusListener listener)
johnsDevice.reboot(
(commandResponse, impactedResources, throwable) -> {
if (null != throwable) {
// success case.
}
});
listener - The listener that will be triggered
Device.DeviceManagementStatusListenerprotected void setResourceName(Resource resource, java.lang.String name, Device.DeviceManagementStatusListener listener)
device.setResourceName(colorBulb, newName,
(command, resourcesImpacted, throwable) -> {
if (null != throwable) {
// client specific code.
}
})
resource - The resource which name has to be changed.name - Name of the resourcelistener - The listener that will be triggered
Device.DeviceManagementStatusListenerprotected void setResourceMetadata(Resource resource, java.lang.String metadata, Device.DeviceManagementStatusListener listener)
resource - The resource which metadata has to be set.metadata - Metadata of the resourcelistener - The listener that will be triggered.
Device.DeviceManagementStatusListenerpublic final long getId()
public java.lang.String getName()
public boolean isExtendable()
public final Network getParent()
public java.util.Map<java.lang.String,Resource> getResourceMap()
public final <T extends Resource> T getResource(java.lang.String resourceEui)
T - capture for casting.resourceEui - ID of the Resource which needs to be fetched.public boolean isReady()
NativeCallbacks.deviceInfoCallback(boolean, boolean, java.lang.String, long, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, int, int, boolean, int[], java.lang.String[], java.lang.Object)
or retrieved from cache.public void discoverResources(RadioProtocol protocol, Device.DiscoverResourceListener listener)
protocol - The protocol which will be usedlistener - The listener which will be triggered after the callbackpublic void discoverResources(RadioProtocol protocol, long timeout, Device.DiscoverResourceListener listener)
johnsDevice
.discoverResources(
RadioProtocol.ZWAVE, 10000,
new Device.DiscoverResourceListener() {
@Override
public void onInfoRequest (
InfoRequest infoRequest) {
}
@Override
public void onMessage(
String title,
String message,
MessageType messageType) {
}
@Override
public void onStatusChanged(
CommandResponse{@code <CommandId> } response,
Resource[] resourcesImpacted, Throwable tr) {
if (null != tr) {
// success case.
} else {
// failure case.
}
}
);
}
protocol - The protocol which will be usedtimeout - The timeout for this commandlistener - The listener which will be triggered after the callbackpublic void addZwaveResource(java.lang.String metadata,
java.util.List<Parameter<InfoResponse.Value>> parameters,
long timeout,
Device.AddResourceListener listener)
johnsDevice.
addZwaveResource() {
metdata,
params,
new AddResourceListener() {
@Override
public void onInfoRequest(
InfoRequest infoRequest) {
}
@Override
public void onMessage(
String title,
String message,
MessageType messageType) {
// client specific code.
}
@Override
public void onStatusChanged(
CommandResponse {@code <CommandId> } response,
Resource[] resourcesImpacted,
Throwable tr) {
if (null != tr) {
// success case.
} else {
// failure case.
}
}
});
}
metadata - The metadata that has to be set on this resourceparameters - The parameters to be passed while addingtimeout - The timeout for this commandlistener - The listener which will be triggered after the callbackpublic void addZigbeeResource(java.lang.String resourceEui,
java.lang.String metadata,
java.util.List<Parameter<InfoResponse.Value>> parameters,
long timeout,
Device.AddResourceListener listener)
resourceEui - The ID of the resource to be added.metadata - The metadata that has to be set on this resourceparameters - The parameters to be passed while addingtimeout - The timeout for this commandlistener - The listener which will be triggered after the callbackjava.lang.RuntimeException - Throws exception on communication failures etc.,public void addTuyaResource(java.lang.String metadata,
java.util.List<Parameter<InfoResponse.Value>> parameters,
long timeout,
Device.AddResourceListener listener)
metadata - The metadata that has to be set on this resourceparameters - The parameters to be passed while addingtimeout - The timeout for this commandlistener - The listener which will be triggered after the callbackjava.lang.RuntimeException - Throws exception on communication failures etc.,public void removeResource(Resource resource, java.util.List<Parameter<InfoResponse.Value>> parameters, long timeout, Device.RemoveResourceListener listener)
johnsDevice.
removeResource(
resourceToBeRemoved,
null,
10_000L,
new Device.RemoveResourceListener() {
@Override
public void onMessage(
String title,
String message,
MessageType messageType) {
}
@Override
public void onStatusChanged(
CommandResponse <CommandId> response,
Resource[] resourcesImpacted,
Throwable tr) {
if (null != tr) {
// success case.
} else {
// failure case.
}
}
});
resource - The resource to be removed.parameters - The parameters to be passed while addingtimeout - The timeout for the command.listener - The listener which will be triggered after the callbackjava.lang.RuntimeException - Throws an exception on communication failures and other
cases like removing resources which haven't been added.public void forceRemoveResource(Resource resource, Device.RemoveResourceListener listener)
resource - The resource to be removed.listener - The listener which will be triggered after the callbackjava.lang.RuntimeException - Throws an exception on communication failures and other
cases like removing resources which haven't been added.public void configureWiFi(java.lang.String ssid,
java.lang.String password,
Device.DeviceManagementStatusListener listener)
johnsDevice
.configureWifi(
newSSID,
password,
new (commandResponse, resourceImpacted, tr) -> {
if (null != tr) {
// success case.
} else {
// failure case.
}
});
ssid - SSID of the Wi-Fi to connectpassword - PASSWORD of the Wi-Fi to connectlistener - The listener which will be triggered after the callbackjava.lang.RuntimeException - Throws an exception on communication failures and other
cases like removing resources which haven't been added.public void sendInfoResponse(InfoResponse infoResponse, Device.InfoResponseStatusListener listener)
infoResponse - The response object to be sent.listener - The listener which will be triggered after the callbackpublic void sendInfoRequest(InfoRequest infoRequest, Device.InfoRequestStatusListener listener)
InfoResponse will be returned in CallbacksInterface.infoResponseCallback(buzz.getcoco.iot.InfoRequest, buzz.getcoco.iot.InfoResponse).
InfoRequest infoRequest =
new InfoRequest(
null,
new ArrayList<>(
new InfoRequest.RemoteButtonInfo(applianceId, resourceEUI)));
johnsDevice
.sendInfoRequest(
infoRequest,
new InfoRequestStatusListener() {
@Override
public void onInfoRequestStatus(
InfoRequest request,
Throwable tr) {
if (null != tr) {
// success case.
} else {
// failure case.
}
}
@Override
public void onInfoResponse(
InfoResponse response) {
}
});
infoRequest - The infoRequest object which will contain info to be queried on devicelistener - The listener which will be triggered with
CallbacksInterface.infoResponseCallback(buzz.getcoco.iot.InfoRequest, buzz.getcoco.iot.InfoResponse)public java.lang.String getDevicePsn()
public java.lang.String getProductName()
public java.lang.String getMake()
public java.lang.String getModel()
public java.lang.String getFirmwareVersion()
public PowerSource getPowerSource()
PowerSource on which the device is running on.public ReceiverType getReceiverType()
ReceiverType of the device.public int[] getAvailableChannelPorts(int portCount)
portCount - Required number of ports over which communication can take place.public boolean supportsProtocol(RadioProtocol radioProtocol)
RadioProtocol.radioProtocol - An enum with possible values of protocols for communication. Ex: Zigbeeprotected void internalSetProtocolSupported(int[] supportedProtocols)
supportedProtocolFlags are updated.supportedProtocols - supportedProtocols array of this device.public java.util.List<RadioProtocol> getSupportedProtocols()
RadioProtocolprotected void internalRemoveDevice()
protected void internalSetName(java.lang.String deviceName)
name is updated.deviceName - Updated device name of the device.protected void internalSetDevicePsn(java.lang.String devicePsn)
devicePsn is updated.devicePsn - Updated device psn of the device.protected void internalSetProductName(java.lang.String productName)
productName is updated.productName - Updated product name of the device.protected void internalSetMake(java.lang.String make)
make is updated.make - Updated manufacturer name of device.protected void internalSetModel(java.lang.String model)
model is updated.model - Updated model of the device.protected void internalSetFirmwareVersion(java.lang.String firmwareVersion)
firmwareVersion is updated.firmwareVersion - Updated firmware version of the device.protected void internalSetPowerSource(PowerSource powerSource)
powerSource is updated.powerSource - Updated power source of the device.protected void internalSetReceiverType(ReceiverType receiverType)
receiverType is updated.receiverType - Updated receiver type of the device.protected void internalSetExtendable(boolean extendable)
isExtendable is updated.extendable - Updated extendable flag.protected void internalSetParent(Network parent)
parent is updated.parent - network which is parent of the device.protected void internalSetReady(boolean ready)
ready is updated.ready - Updated ready flag.public boolean containsResource(java.lang.String resourceEui)
resourceEui - The ID of the resourceprotected void internalAddResource(Resource resource)
Resource is added.resource - Resource that is added.protected void internalRemoveResource(java.lang.String resourceEui)
Resource is removed.resourceEui - ID of removed resource.public final int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object