...
Code Block | ||
---|---|---|
| ||
public void doSerialUpgrade() throws InterruptedException, ExecutionException, TimeoutException, IOException { // setup final GatewayClient gw = new GatewayClient(new ConnectionInfo(ConnectionType.ZIGBEE_UART, "/dev/ttyUSB0")); final File upgradeFile = new File("/path/to/file"); // start the upgrade final Collection<ConnectionInfo> connections = gw.getConnectionInfo(); for (ConnectionInfo c : connections) { if (c.getType() == ConnectionType.ZIGBEE_UART) { final Status status = gw.upgradeFirmware(c, upgradeFile, serialCallback).get(UPGRADE_TIMEOUT_MINUTES, TimeUnit.MINUTES); System.out.println("Status: " + status); } } } public final static ResultConsumer<SerialUploadResult> serialCallback = ResultConsumer.createResultConsumer( (result) -> { SerialUploadResult r = (SerialUploadResult)result; System.out.println("Progress: " + r.getProgress()); }, (throwable) -> { System.err.println("Serial upload failed: " + throwable.getMessage()); } ); |
Network API
...
getNetworkInfo(ConnectionInfo c)
Usage
Returns the network status of any relevant network information associated with the specified network interface.
...
Returns
Return Type | Description |
---|---|
CompletableFuture<NetworkStatus>CompletableFuture<NetworkInformationn> | A CompletableFuture that will contain the network statusa NeworkInformation object. |
Example
Code Block | ||
---|---|---|
| ||
GatewayClient gw = new GatewayClient(new ConnectionInfo(ConnectionType.ZIGBEE_UART, "/dev/ttyUSB0")); ... for (ConnectionInfo c : gw.getConnectionInfo()) { gw.getNetworkStatusgetNetworkInfo(c); } |
createNetwork(ConnectionInfo c)
...
Returns
Return Type | Description |
---|---|
CompletableFuture<NetworkStatus>CompletableFuture<NetworkInformation> | A CompletableFuture that will contain the network statusa NetworkInformation object. The NetworkInformation.status field will be NETWORK_UP if the command succeeded (or a network was already formed); otherwise NETWORK_COMMAND_FAILED. |
...
Returns
Return Type | Description |
---|---|
CompletableFuture<NetworkStatus>CompletableFuture<NetworkInformation> | A CompletableFuture that will contain the network statusa NetworkInformation object. The NetworkInformation.status field will be NETWORK_UP if the command succeeded (or a network was already formed); otherwise NETWORK_COMMAND_FAILED. |
...
Returns
Return Type | Description |
---|---|
CompletableFuture<NetworkStatus>CompletableFuture<NetworkInformation> | A CompletableFuture that will contain the network statusa NetworkInformation object. NETWORKThe NetworkInformation.status field will be NETWORK_DOWN if the command succeeded (or network was already down); otherwise, NETWORK_COMMAND_FAILED. |
...
Returns
Return Type | Description |
---|---|
CompletableFuture<NetworkStatus>CompletableFuture<NetworkInformation> | A CompletableFuture that will contain the network statusa NetworkInformation object. NETWORKThe NetworkInformation.status field will be NETWORK_OPEN if the command succeeded; NETWORK_COMMAND_FAILED otherwise. |
...