use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction in project com.zsmartsystems.zigbee by zsmartsystems.
the class EmberNcp method getCurrentSecurityState.
/**
* Gets the current security state that is being used by a device that is joined in the network.
*
* @return the {@link EmberNetworkParameters} or null on error
*/
public EmberCurrentSecurityState getCurrentSecurityState() {
EzspGetCurrentSecurityStateRequest request = new EzspGetCurrentSecurityStateRequest();
EzspSingleResponseTransaction transaction = new EzspSingleResponseTransaction(request, EzspGetCurrentSecurityStateResponse.class);
ashHandler.sendEzspTransaction(transaction);
EzspGetCurrentSecurityStateResponse response = (EzspGetCurrentSecurityStateResponse) transaction.getResponse();
logger.debug(response.toString());
lastStatus = response.getStatus();
if (response.getStatus() != EmberStatus.EMBER_SUCCESS) {
logger.debug("Error during retrieval of security parameters: {}", response);
return null;
}
return response.getState();
}
use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction 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.EzspSingleResponseTransaction 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;
}
use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction in project com.zsmartsystems.zigbee by zsmartsystems.
the class EmberNetworkInitialisation method setSecurityState.
/**
* Sets the initial security state
*
* @param networkKey the initial {@link EmberKeyData}
* @return true if the security state was set successfully
*/
private boolean setSecurityState(EmberKeyData networkKey) {
// Define the ZigBeeAliance09 key for HA link-key
// This is used to encrypt the network key when it is transferred to a newly joining device.
EmberKeyData linkKey = new EmberKeyData();
linkKey.setContents(new int[] { 0x5A, 0x69, 0x67, 0x42, 0x65, 0x65, 0x41, 0x6C, 0x6C, 0x69, 0x61, 0x6E, 0x63, 0x65, 0x30, 0x39 });
// linkKey.setContents(new int[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
// 0xFF, 0xFF, 0xFF });
EzspSetInitialSecurityStateRequest securityState = new EzspSetInitialSecurityStateRequest();
EmberInitialSecurityState state = new EmberInitialSecurityState();
// state.addBitmask(EmberInitialSecurityBitmask.EMBER_STANDARD_SECURITY_MODE);
// state.addBitmask(EmberInitialSecurityBitmask.EMBER_DISTRIBUTED_TRUST_CENTER_MODE);//
// EMBER_TRUST_CENTER_GLOBAL_LINK_KEY);
state.addBitmask(EmberInitialSecurityBitmask.EMBER_TRUST_CENTER_GLOBAL_LINK_KEY);
state.addBitmask(EmberInitialSecurityBitmask.EMBER_HAVE_PRECONFIGURED_KEY);
state.addBitmask(EmberInitialSecurityBitmask.EMBER_HAVE_NETWORK_KEY);
state.addBitmask(EmberInitialSecurityBitmask.EMBER_NO_FRAME_COUNTER_RESET);
state.addBitmask(EmberInitialSecurityBitmask.EMBER_REQUIRE_ENCRYPTED_KEY);
state.setNetworkKey(networkKey);
state.setPreconfiguredKey(linkKey);
state.setPreconfiguredTrustCenterEui64(new IeeeAddress());
securityState.setState(state);
EzspSingleResponseTransaction transaction = new EzspSingleResponseTransaction(securityState, EzspSetInitialSecurityStateResponse.class);
ashHandler.sendEzspTransaction(transaction);
EzspSetInitialSecurityStateResponse securityStateResponse = (EzspSetInitialSecurityStateResponse) transaction.getResponse();
logger.debug(securityStateResponse.toString());
if (securityStateResponse.getStatus() != EmberStatus.EMBER_SUCCESS) {
logger.debug("Error during retrieval of network parameters: {}", securityStateResponse);
return false;
}
return true;
}
use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction in project com.zsmartsystems.zigbee by zsmartsystems.
the class EzspNeighborTable method getNeighborCount.
private int getNeighborCount() {
// Check if the network is initialised
EzspNeighborCountRequest neighborCountRequest = new EzspNeighborCountRequest();
EzspTransaction neighborCountTransaction = ashHandler.sendEzspTransaction(new EzspSingleResponseTransaction(neighborCountRequest, EzspNeighborCountResponse.class));
EzspNeighborCountResponse neighborCountResponse = (EzspNeighborCountResponse) neighborCountTransaction.getResponse();
logger.debug(neighborCountResponse.toString());
logger.debug("EZSP neighborCountResponse {}", neighborCountResponse);
return neighborCountResponse.getValue();
}
Aggregations