Search in sources :

Example 16 with EzspSingleResponseTransaction

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction in project com.zsmartsystems.zigbee by zsmartsystems.

the class EmberNcp method getVersion.

/**
 * The command allows the Host to specify the desired EZSP version and must be sent before any other command. The
 * response provides information about the firmware running on the NCP.
 *
 * @param desiredVersion the requested version we support
 * @return the {@link EzspVersionResponse}
 */
public EzspVersionResponse getVersion(int desiredVersion) {
    EzspVersionRequest request = new EzspVersionRequest();
    request.setDesiredProtocolVersion(EzspFrame.getEzspVersion());
    EzspTransaction transaction = ashHandler.sendEzspTransaction(new EzspSingleResponseTransaction(request, EzspVersionResponse.class));
    EzspVersionResponse response = (EzspVersionResponse) transaction.getResponse();
    logger.debug(response.toString());
    lastStatus = null;
    return response;
}
Also used : EzspVersionRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionRequest) EzspTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspTransaction) EzspVersionResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionResponse) EzspSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction)

Example 17 with EzspSingleResponseTransaction

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction in project com.zsmartsystems.zigbee by zsmartsystems.

the class EmberNcp method getNetworkParameters.

/**
 * Gets the current network parameters, or an empty parameters class if there's an error
 *
 * @return {@link EmberNetworkParameters}
 */
public EmberNetworkParameters getNetworkParameters() {
    EzspGetNetworkParametersRequest request = new EzspGetNetworkParametersRequest();
    EzspSingleResponseTransaction transaction = new EzspSingleResponseTransaction(request, EzspGetNetworkParametersResponse.class);
    ashHandler.sendEzspTransaction(transaction);
    EzspGetNetworkParametersResponse response = (EzspGetNetworkParametersResponse) transaction.getResponse();
    logger.debug(response.toString());
    lastStatus = response.getStatus();
    if (response.getStatus() != EmberStatus.EMBER_SUCCESS && response.getStatus() != EmberStatus.EMBER_NOT_JOINED) {
        logger.debug("Error during retrieval of network parameters: {}", response);
        return new EmberNetworkParameters();
    }
    return response.getParameters();
}
Also used : EzspGetNetworkParametersRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetNetworkParametersRequest) EzspGetNetworkParametersResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetNetworkParametersResponse) EmberNetworkParameters(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberNetworkParameters) EzspSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction)

Example 18 with EzspSingleResponseTransaction

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction in project com.zsmartsystems.zigbee by zsmartsystems.

the class EmberNcp method addEndpoint.

/**
 * Configures endpoint information on the NCP. The NCP does not remember these settings after a reset. Endpoints can
 * be added by the Host after the NCP has reset. Once the status of the stack changes to EMBER_NETWORK_UP, endpoints
 * can no longer be added and this command will respond with EZSP_ERROR_INVALID_CALL.
 *
 * @param endpointId the endpoint number to add
 * @param deviceId the device id for the endpoint
 * @param profileId the profile id
 * @param inputClusters an array of input clusters supported by the endpoint
 * @param outputClusters an array of output clusters supported by the endpoint
 * @return the {@link EzspStatus} of the response
 */
public EzspStatus addEndpoint(int endpointId, int deviceId, int profileId, int[] inputClusters, int[] outputClusters) {
    EzspAddEndpointRequest request = new EzspAddEndpointRequest();
    request.setEndpoint(endpointId);
    request.setDeviceId(deviceId);
    request.setProfileId(profileId);
    request.setInputClusterList(new int[] { 0 });
    request.setOutputClusterList(new int[] { 0 });
    EzspTransaction transaction = ashHandler.sendEzspTransaction(new EzspSingleResponseTransaction(request, EzspAddEndpointResponse.class));
    EzspAddEndpointResponse response = (EzspAddEndpointResponse) transaction.getResponse();
    logger.debug(response.toString());
    lastStatus = null;
    return response.getStatus();
}
Also used : EzspTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspTransaction) EzspSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction) EzspAddEndpointRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspAddEndpointRequest) EzspAddEndpointResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspAddEndpointResponse)

Example 19 with EzspSingleResponseTransaction

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction in project com.zsmartsystems.zigbee by zsmartsystems.

the class EmberNcp method setConfiguration.

/**
 * Set a configuration value
 *
 * @param configId the {@link EzspConfigId} to set
 * @param value the value to set
 * @return true if the configuration returns success
 */
public boolean setConfiguration(EzspConfigId configId, Integer value) {
    EzspSetConfigurationValueRequest request = new EzspSetConfigurationValueRequest();
    request.setConfigId(configId);
    request.setValue(value);
    logger.debug(request.toString());
    EzspTransaction transaction = ashHandler.sendEzspTransaction(new EzspSingleResponseTransaction(request, EzspSetConfigurationValueResponse.class));
    EzspSetConfigurationValueResponse response = (EzspSetConfigurationValueResponse) transaction.getResponse();
    lastStatus = null;
    logger.debug(response.toString());
    return response.getStatus() == EzspStatus.EZSP_SUCCESS;
}
Also used : EzspSetConfigurationValueResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspSetConfigurationValueResponse) EzspTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspTransaction) EzspSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction) EzspSetConfigurationValueRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspSetConfigurationValueRequest)

Example 20 with EzspSingleResponseTransaction

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction in project com.zsmartsystems.zigbee by zsmartsystems.

the class EmberNcp method getKeyTableEntry.

/**
 * Gets a Security Key based on the passed key type.
 *
 * @param index the index of the key to get
 * @return the {@link EmberKeyStruct} of the requested key or null on error
 */
public EmberKeyStruct getKeyTableEntry(int index) {
    EzspGetKeyTableEntryRequest request = new EzspGetKeyTableEntryRequest();
    request.setIndex(index);
    EzspTransaction transaction = ashHandler.sendEzspTransaction(new EzspSingleResponseTransaction(request, EzspGetKeyTableEntryResponse.class));
    EzspGetKeyTableEntryResponse response = (EzspGetKeyTableEntryResponse) transaction.getResponse();
    logger.debug(response.toString());
    lastStatus = response.getStatus();
    if (lastStatus != EmberStatus.EMBER_SUCCESS) {
        return null;
    }
    return response.getKeyStruct();
}
Also used : EzspGetKeyTableEntryRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetKeyTableEntryRequest) EzspTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspTransaction) EzspSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction) EzspGetKeyTableEntryResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetKeyTableEntryResponse)

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