use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspLaunchStandaloneBootloaderRequest in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeDongleEzsp method updateFirmware.
@Override
public boolean updateFirmware(final InputStream firmware, final ZigBeeTransportFirmwareCallback callback) {
if (ashHandler != null) {
logger.debug("ashHandler is operating in updateFirmware");
return false;
}
if (!initialiseEzspProtocol()) {
return false;
}
zigbeeTransportReceive.setNetworkState(ZigBeeTransportState.OFFLINE);
callback.firmwareUpdateCallback(ZigBeeTransportFirmwareStatus.FIRMWARE_UPDATE_STARTED);
// Send the bootload command, but ignore the response since there doesn't seem to be one
// despite what the documentation seems to indicate
EzspLaunchStandaloneBootloaderRequest bootloadCommand = new EzspLaunchStandaloneBootloaderRequest();
EzspTransaction bootloadTransaction = ashHandler.sendEzspTransaction(new EzspSingleResponseTransaction(bootloadCommand, EzspLaunchStandaloneBootloaderResponse.class));
EzspLaunchStandaloneBootloaderResponse bootloadResponse = (EzspLaunchStandaloneBootloaderResponse) bootloadTransaction.getResponse();
logger.debug(bootloadResponse.toString());
logger.debug("EZSP bootloadResponse {}", bootloadResponse.getStatus());
if (bootloadResponse.getStatus() != EzspStatus.EZSP_SUCCESS) {
callback.firmwareUpdateCallback(ZigBeeTransportFirmwareStatus.FIRMWARE_UPDATE_FAILED);
logger.debug("EZSP bootload failed: bootloadResponse {}", bootloadResponse.getStatus());
return false;
}
// Stop the handler and close the serial port
logger.debug("EZSP closing frame handler");
ashHandler.setClosing();
serialPort.close();
ashHandler.close();
ashHandler = null;
bootloadHandler = new EmberFirmwareUpdateHandler(this, firmware, serialPort, callback);
bootloadHandler.startBootload();
return true;
}
Aggregations