Search in sources :

Example 1 with EzspTransaction

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

Example 2 with EzspTransaction

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

Example 3 with EzspTransaction

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

Example 4 with EzspTransaction

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;
}
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 5 with EzspTransaction

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;
}
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)

Aggregations

EzspSingleResponseTransaction (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction)21 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 EzspNetworkStateRequest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspNetworkStateRequest)2 EzspNetworkStateResponse (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspNetworkStateResponse)2 Test (org.junit.Test)2 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 EzspGetChildDataRequest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetChildDataRequest)1 EzspGetChildDataResponse (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetChildDataResponse)1 EzspGetKeyRequest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetKeyRequest)1 EzspGetKeyResponse (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetKeyResponse)1 EzspGetKeyTableEntryRequest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetKeyTableEntryRequest)1 EzspGetKeyTableEntryResponse (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetKeyTableEntryResponse)1