Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
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);
           }
        }
   		}
	}
}
    
private final static ResultConsumer<SerialUploadResult> serialCallback = ResultConsumer.createResultConsumer(
    (result) -> {
        SerialUploadResult r = (SerialUploadResult)result;
        IntegrationTestUtilsSystem.out.testPrintprintln("Progress: " + r.getProgress());
    },
    (throwable) -> {
        failSystem.err.println("Serial upload failed: " + throwable.getMessage());
     }
);

...