Modifier | Constructor and Description |
---|---|
protected |
Network(java.lang.String id)
The constructor of the class.
|
Modifier and Type | Method and Description |
---|---|
void |
connect()
To connect to an individual network.
|
void |
connect(int port)
To connect to an individual network.This function must be used to connect to single network.
|
static void |
connectWithInvite(Network network,
java.lang.String inviteUrl,
long nodeId)
A function to connect to the network with inviteUrl.
|
static void |
connectWithInvite(java.lang.String networkId,
java.lang.String networkName,
Network.NetworkType networkType,
Network.UserRole userRole,
Network.AccessType accessType,
java.lang.String inviteUrl,
long nodeId)
A function to connect to the network with inviteUrl.
|
static boolean |
containsClearFlag(Network.State state)
A function to check if the state contains a clear flag for network i.e, if state is either of
Network.State.NETWORK_RESET . |
boolean |
containsDevice(long deviceNodeId) |
boolean |
containsRule(int ruleId) |
boolean |
containsScene(int sceneId) |
boolean |
containsZone(int zoneId) |
static int |
createClearOnDisconnectionFlag(Network.State... states)
A function to create flags to clear network from memory in case of disconnection.
|
void |
createRule(java.lang.String ruleName,
Network.NetworkManagementStatusListener listener)
A function to create rule in the network.
|
void |
createScene(java.lang.String sceneName,
Network.NetworkManagementStatusListener listener)
A function to create scene in a network.
|
void |
createZone(java.lang.String zoneName,
Network.NetworkManagementStatusListener listener)
A function to create a zone in the network.
|
void |
deleteRule(Rule[] rules,
Network.NetworkManagementStatusListener listener)
A function to delete rules in a network.
|
void |
deleteRule(Rule rule,
Network.NetworkManagementStatusListener listener)
A function to delete rule in a network.
|
void |
deleteScene(Scene[] scenes,
Network.NetworkManagementStatusListener listener)
A function to delete scenes in a network.
|
void |
deleteScene(Scene scene,
Network.NetworkManagementStatusListener listener)
A function to delete a scene from the network.
|
void |
deleteZone(Zone[] zones,
Network.NetworkManagementStatusListener listener)
A function to delete zones from the network.
|
void |
deleteZone(Zone zone,
Network.NetworkManagementStatusListener listener)
A function to delete a zone from the network.
|
void |
disconnect()
This function is used to disconnect from a network and delete from local database accordingly.
|
Network.AccessType |
getAccessType()
This function is used to return the access type of the user.
|
ConnectivityStateManager.State |
getConnectivityManagerState()
This function is used to get the connectivity state of the network.
|
<T extends Device> |
getDevice(long deviceNodeId)
This function is used to get the zone of this network.
|
java.lang.Iterable<Device> |
getDeviceIterable()
This function fetches device iterable to traverse over list of devices.
|
java.util.Map<java.lang.Long,Device> |
getDeviceMap()
This function is used to return the HashMap that the sdk uses to map the DeviceIds
to the Device Objects.
|
java.lang.String |
getId()
This function is used to get the Id that uniquely identifies the current Network.
|
java.lang.String |
getMetadata() |
java.lang.String |
getName()
This function is used to get the Name of the network.
|
Network.NetworkType |
getNetworkType()
This function is used to get the type of the network.
|
java.util.List<Network.ResourceTemplate> |
getResourceTemplates()
This function is used to get the list of resource templates.
|
<T extends Rule> |
getRule(int ruleId)
This function is used to get the rules of this network.
|
java.lang.Iterable<Rule> |
getRuleIterable()
This function fetches device iterable to traverse over list of rules.
|
java.util.Map<java.lang.Integer,Rule> |
getRuleMap()
This function is used to return the HashMap that the sdk uses to map
the ruleIds to the Rule Objects.
|
<T extends Scene> |
getScene(int sceneId)
This function is used to get the scene of this network.
|
java.lang.Iterable<Scene> |
getSceneIterable()
This function fetches device iterable to traverse over list of scenes.
|
java.util.Map<java.lang.Integer,Scene> |
getSceneMap()
This function is used to return the HashMap that the sdk uses to map
the sceneIds to the Scene Objects.
|
Network.State |
getState()
This function is used to get the current state of the Network.
|
Network.UserRole |
getUserRole()
This function is used to get role of the current user in this network.
|
<T extends Zone> |
getZone(int zoneId)
This function is used to get the zone of this network.
|
java.lang.Iterable<Zone> |
getZoneIterable()
This function fetches device iterable to traverse over list of zones.
|
java.util.Map<java.lang.Integer,Zone> |
getZoneMap()
This function is used to return the HashMap that the sdk uses to map
the zoneIds to the Zone Objects.
|
int |
hashCode() |
protected void |
internalAddDevice(Device device) |
protected void |
internalAddRule(Rule rule) |
protected void |
internalAddScene(Scene scene) |
protected void |
internalAddZone(Zone zone) |
protected void |
internalRemoveDevice(long deviceNodeId) |
protected void |
internalRemoveNetwork() |
protected void |
internalRemoveRule(int ruleId) |
protected void |
internalRemoveScene(int sceneId) |
protected void |
internalRemoveZone(int zoneId) |
protected void |
internalSetAccessType(Network.AccessType accessType) |
protected void |
internalSetConnectivityState(ConnectivityStateManager.State state) |
protected void |
internalSetMetadata(java.lang.String metadata) |
protected void |
internalSetName(java.lang.String name) |
protected void |
internalSetNetworkType(Network.NetworkType type) |
protected void |
internalSetResourceTemplates(java.util.List<Network.ResourceTemplate> resourceTemplates) |
protected void |
internalSetState(Network.State state) |
protected void |
internalSetUserRole(Network.UserRole userRole) |
java.util.Iterator<Device> |
iterator() |
void |
leave(Network.LeaveStatusListener listener)
This function is used to leave the network.
|
void |
moveResources(Zone fromZone,
Zone toZone,
Resource[] resources,
Network.NetworkManagementStatusListener listener)
A function to move resources of a zone to another zone.
|
void |
restoreNetworkState(java.lang.String networkState)
A function to restore network information from memory.
|
java.lang.String |
saveState()
A function to serialize the whole memory.
|
void |
sendContentInfo(long contentTime,
java.lang.String data,
long[] nodeIds)
An api to send data to the specified nodes or all nodes of network.
|
void |
sendData(java.lang.String data,
long[] nodeIds)
An api to send data to the specified nodes or all nodes of network.
|
void |
sendNetworkManagementCommand(Command<Network.CommandId> command,
Network.NetworkManagementStatusListener listener)
A function to manage the network like, add zone, remove zone and other stuff.
|
java.lang.String |
toString() |
protected Network(java.lang.String id)
id
- Id of the current network.public static int createClearOnDisconnectionFlag(Network.State... states)
states
- array of statespublic static boolean containsClearFlag(Network.State state)
Network.State.NETWORK_RESET
. Network.State.CONNECTION_ERROR
, Network.State.DISCONNECTED
.state
- State under interest to check for clearpublic static void connectWithInvite(java.lang.String networkId, java.lang.String networkName, Network.NetworkType networkType, Network.UserRole userRole, Network.AccessType accessType, java.lang.String inviteUrl, long nodeId)
inviteUrl
- The URL which is provided by the CloudnetworkId
- The networkID of the network to connectnetworkName
- The name of the network to connectuserRole
- The role of the useraccessType
- The accessType needednodeId
- The type of node that is being addedpublic static void connectWithInvite(Network network, java.lang.String inviteUrl, long nodeId)
network
- The network to which to connectinviteUrl
- The URL which is provided by the CloudnodeId
- The type of node that is being addedpublic void connect()
java.lang.RuntimeException
- Throws an exception on failure during communication.public void connect(int port)
port
- This function takes a port over which the communication will
take place NOTE: The port should be a free port or this call
will fail If 0 is passed there will be a search and free port
will be chosen automatically.java.lang.RuntimeException
- Throws an exception on failure during communication.public void disconnect()
java.lang.RuntimeException
- Throw an exception on failures during communication.public void leave(Network.LeaveStatusListener listener)
public void sendNetworkManagementCommand(Command<Network.CommandId> command, Network.NetworkManagementStatusListener listener)
command
- The command which has to be sentlistener
- The listener which will be triggered with
CallbacksInterface.networkManagementCommandCallback(buzz.getcoco.iot.Network, buzz.getcoco.iot.CommandResponse<?>)
public void createZone(java.lang.String zoneName, Network.NetworkManagementStatusListener listener)
zoneName
- The name of the zone.listener
- The listener which will be triggered with
CallbacksInterface.networkManagementCommandCallback(buzz.getcoco.iot.Network, buzz.getcoco.iot.CommandResponse<?>)
public void deleteZone(Zone zone, Network.NetworkManagementStatusListener listener)
zone
- The zone which has to deletedlistener
- The listener which will be triggered with
CallbacksInterface.networkManagementCommandCallback(buzz.getcoco.iot.Network, buzz.getcoco.iot.CommandResponse<?>)
public void deleteZone(Zone[] zones, Network.NetworkManagementStatusListener listener)
zones
- The zones which are to deletedlistener
- The listener which will be triggered with
CallbacksInterface.networkManagementCommandCallback(buzz.getcoco.iot.Network, buzz.getcoco.iot.CommandResponse<?>)
public void moveResources(Zone fromZone, Zone toZone, Resource[] resources, Network.NetworkManagementStatusListener listener)
fromZone
- The zone from which the resources has to be movedtoZone
- The zone to which the resource has to be movedlistener
- The listener which will be triggered with
CallbacksInterface.networkManagementCommandCallback(buzz.getcoco.iot.Network, buzz.getcoco.iot.CommandResponse<?>)
public void createScene(java.lang.String sceneName, Network.NetworkManagementStatusListener listener)
sceneName
- The name of the scenelistener
- The listener which will be triggered with
CallbacksInterface.networkManagementCommandCallback(buzz.getcoco.iot.Network, buzz.getcoco.iot.CommandResponse<?>)
public void deleteScene(Scene scene, Network.NetworkManagementStatusListener listener)
scene
- Scene which has to be deletedlistener
- The listener which will be triggered with
CallbacksInterface.networkManagementCommandCallback(buzz.getcoco.iot.Network, buzz.getcoco.iot.CommandResponse<?>)
public void deleteScene(Scene[] scenes, Network.NetworkManagementStatusListener listener)
scenes
- The scenes to be deletedlistener
- The listener which will be triggered with
CallbacksInterface.networkManagementCommandCallback(buzz.getcoco.iot.Network, buzz.getcoco.iot.CommandResponse<?>)
public void createRule(java.lang.String ruleName, Network.NetworkManagementStatusListener listener)
ruleName
- The name of the rulelistener
- The listener which will be triggered with
CallbacksInterface.networkManagementCommandCallback(buzz.getcoco.iot.Network, buzz.getcoco.iot.CommandResponse<?>)
public void deleteRule(Rule rule, Network.NetworkManagementStatusListener listener)
rule
- Rule which has to be deletedlistener
- The listener which will be triggered with
CallbacksInterface.networkManagementCommandCallback(buzz.getcoco.iot.Network, buzz.getcoco.iot.CommandResponse<?>)
public void deleteRule(Rule[] rules, Network.NetworkManagementStatusListener listener)
rules
- The rules to be deletedlistener
- The listener which will be triggered with
CallbacksInterface.networkManagementCommandCallback(buzz.getcoco.iot.Network, buzz.getcoco.iot.CommandResponse<?>)
public final java.lang.String getId()
public java.lang.String getName()
public Network.State getState()
public ConnectivityStateManager.State getConnectivityManagerState()
ConnectivityStateManager.getInstance()
.public Network.UserRole getUserRole()
public Network.AccessType getAccessType()
public Network.NetworkType getNetworkType()
public java.util.Map<java.lang.Long,Device> getDeviceMap()
public java.util.Map<java.lang.Integer,Zone> getZoneMap()
public java.util.Map<java.lang.Integer,Scene> getSceneMap()
public java.util.Map<java.lang.Integer,Rule> getRuleMap()
public java.util.List<Network.ResourceTemplate> getResourceTemplates()
public final <T extends Device> T getDevice(long deviceNodeId)
public final <T extends Zone> T getZone(int zoneId)
public final <T extends Scene> T getScene(int sceneId)
public final <T extends Rule> T getRule(int ruleId)
public java.lang.String saveState()
CocoClient.restoreNetworkState(String)
public void restoreNetworkState(java.lang.String networkState)
networkState
- JSON string which was serialized to memory during
saveState()
CocoClient.restoreNetworkState(String)
protected void internalRemoveNetwork()
protected void internalSetResourceTemplates(java.util.List<Network.ResourceTemplate> resourceTemplates)
protected void internalAddDevice(Device device)
protected void internalRemoveDevice(long deviceNodeId)
public boolean containsDevice(long deviceNodeId)
protected void internalAddZone(Zone zone)
protected void internalRemoveZone(int zoneId)
public boolean containsZone(int zoneId)
protected void internalAddScene(Scene scene)
protected void internalRemoveScene(int sceneId)
public boolean containsScene(int sceneId)
protected void internalAddRule(Rule rule)
protected void internalRemoveRule(int ruleId)
public boolean containsRule(int ruleId)
protected void internalSetName(java.lang.String name)
protected void internalSetUserRole(Network.UserRole userRole)
protected void internalSetAccessType(Network.AccessType accessType)
protected void internalSetState(Network.State state)
protected void internalSetConnectivityState(ConnectivityStateManager.State state)
protected void internalSetNetworkType(Network.NetworkType type)
protected void internalSetMetadata(java.lang.String metadata)
public java.lang.String getMetadata()
public final int hashCode()
hashCode
in class java.lang.Object
public java.util.Iterator<Device> iterator()
iterator
in interface java.lang.Iterable<Device>
public java.lang.Iterable<Device> getDeviceIterable()
public java.lang.Iterable<Zone> getZoneIterable()
public java.lang.Iterable<Scene> getSceneIterable()
public java.lang.Iterable<Rule> getRuleIterable()
public void sendData(java.lang.String data, long[] nodeIds)
data
- The data that has to be sentnodeIds
- The nodes which will get the data.
null to send to all nodes.public void sendContentInfo(long contentTime, java.lang.String data, long[] nodeIds)
contentTime
- The time at which the data is sentdata
- The data that has to be sentnodeIds
- The nodes which will get the data.
null to send to all nodes.public java.lang.String toString()
toString
in class java.lang.Object