use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspTransaction in project com.zsmartsystems.zigbee by zsmartsystems.
the class EmberNcp method getKey.
/**
* Gets a Security Key based on the passed key type.
*
* @param keyType the {@link EmberKeyType} of the key to get
* @return the {@link EmberKeyStruct} or null on error
*/
public EmberKeyStruct getKey(EmberKeyType keyType) {
EzspGetKeyRequest request = new EzspGetKeyRequest();
request.setKeyType(keyType);
EzspTransaction transaction = ashHandler.sendEzspTransaction(new EzspSingleResponseTransaction(request, EzspGetKeyResponse.class));
EzspGetKeyResponse response = (EzspGetKeyResponse) transaction.getResponse();
logger.debug(response.toString());
lastStatus = response.getStatus();
if (lastStatus != EmberStatus.EMBER_SUCCESS) {
return null;
}
return response.getKeyStruct();
}
use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspTransaction in project com.zsmartsystems.zigbee by zsmartsystems.
the class EmberNcp method getNetworkState.
/**
* Returns a value indicating whether the node is joining, joined to, or leaving a network.
*
* @return the {@link EmberNetworkStatus}
*/
public EmberNetworkStatus getNetworkState() {
EzspNetworkStateRequest request = new EzspNetworkStateRequest();
EzspTransaction transaction = ashHandler.sendEzspTransaction(new EzspSingleResponseTransaction(request, EzspNetworkStateResponse.class));
EzspNetworkStateResponse response = (EzspNetworkStateResponse) transaction.getResponse();
logger.debug(response.toString());
lastStatus = null;
return response.getStatus();
}
use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspTransaction in project com.zsmartsystems.zigbee by zsmartsystems.
the class EmberNcp method getCounters.
/**
* Retrieves Ember counters. See the EmberCounterType enumeration for the counter types.
*
* @return the array of counters
*/
public int[] getCounters() {
EzspReadCountersRequest request = new EzspReadCountersRequest();
EzspTransaction transaction = ashHandler.sendEzspTransaction(new EzspSingleResponseTransaction(request, EzspReadCountersResponse.class));
EzspReadCountersResponse response = (EzspReadCountersResponse) transaction.getResponse();
logger.debug(response.toString());
lastStatus = null;
return response.getValues();
}
use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspTransaction in project com.zsmartsystems.zigbee by zsmartsystems.
the class EmberNcp method getChildInformation.
/**
* Returns information about a child of the local node.
*
* @param childId the ID of the child to get information on
* @return the {@link EzspGetChildDataResponse} of the requested childId or null on error
*/
public EzspGetChildDataResponse getChildInformation(int childId) {
EzspGetChildDataRequest request = new EzspGetChildDataRequest();
request.setIndex(childId);
EzspTransaction transaction = ashHandler.sendEzspTransaction(new EzspSingleResponseTransaction(request, EzspGetChildDataResponse.class));
EzspGetChildDataResponse response = (EzspGetChildDataResponse) transaction.getResponse();
logger.debug(response.toString());
lastStatus = response.getStatus();
if (lastStatus != EmberStatus.EMBER_SUCCESS) {
return null;
}
return response;
}
use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspTransaction 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