Search in sources :

Example 6 with EzspSingleResponseTransaction

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();
}
Also used : EzspGetCurrentSecurityStateResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetCurrentSecurityStateResponse) EzspGetCurrentSecurityStateRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetCurrentSecurityStateRequest) EzspSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction)

Example 7 with EzspSingleResponseTransaction

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;
}
Also used : EzspGetChildDataResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetChildDataResponse) EzspTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspTransaction) EzspGetChildDataRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetChildDataRequest) EzspSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction)

Example 8 with EzspSingleResponseTransaction

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;
}
Also used : EmberFirmwareUpdateHandler(com.zsmartsystems.zigbee.dongle.ember.internal.EmberFirmwareUpdateHandler) EzspLaunchStandaloneBootloaderRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspLaunchStandaloneBootloaderRequest) EzspTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspTransaction) EzspSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction) EzspLaunchStandaloneBootloaderResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspLaunchStandaloneBootloaderResponse)

Example 9 with EzspSingleResponseTransaction

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;
}
Also used : EzspSetInitialSecurityStateRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspSetInitialSecurityStateRequest) EmberKeyData(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberKeyData) EzspSetInitialSecurityStateResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspSetInitialSecurityStateResponse) EzspSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction) EmberInitialSecurityState(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberInitialSecurityState) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress)

Example 10 with EzspSingleResponseTransaction

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();
}
Also used : EzspNeighborCountRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspNeighborCountRequest) EzspNeighborCountResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspNeighborCountResponse) EzspTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspTransaction) EzspSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction)

Aggregations

EzspSingleResponseTransaction (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction)28 EzspTransaction (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspTransaction)21 EzspVersionRequest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionRequest)3 EzspVersionResponse (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionResponse)3 EzspFrameTest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.EzspFrameTest)2 EzspGetConfigurationValueRequest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetConfigurationValueRequest)2 EzspGetConfigurationValueResponse (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetConfigurationValueResponse)2 EzspGetNetworkParametersRequest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetNetworkParametersRequest)2 EzspGetNetworkParametersResponse (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetNetworkParametersResponse)2 EzspNetworkStateRequest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspNetworkStateRequest)2 EzspNetworkStateResponse (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspNetworkStateResponse)2 EmberNetworkParameters (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberNetworkParameters)2 Test (org.junit.Test)2 IeeeAddress (com.zsmartsystems.zigbee.IeeeAddress)1 EmberFirmwareUpdateHandler (com.zsmartsystems.zigbee.dongle.ember.internal.EmberFirmwareUpdateHandler)1 EmberStackConfiguration (com.zsmartsystems.zigbee.dongle.ember.internal.EmberStackConfiguration)1 EzspAddEndpointRequest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspAddEndpointRequest)1 EzspAddEndpointResponse (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspAddEndpointResponse)1 EzspFormNetworkRequest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspFormNetworkRequest)1 EzspFormNetworkResponse (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspFormNetworkResponse)1