Search in sources :

Example 1 with EzspSingleResponseTransaction

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction 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 EzspSingleResponseTransaction

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

the class EmberNcp method setPolicy.

/**
 * Set a policy used by the NCP to make fast decisions.
 *
 * @param policyId the {@link EzspPolicyId} to set
 * @param decisionId the {@link EzspDecisionId} to set to
 * @return true if the policy setting was successful
 */
public boolean setPolicy(EzspPolicyId policyId, EzspDecisionId decisionId) {
    EzspSetPolicyRequest setPolicyRequest = new EzspSetPolicyRequest();
    setPolicyRequest.setPolicyId(policyId);
    setPolicyRequest.setDecisionId(decisionId);
    EzspSingleResponseTransaction transaction = new EzspSingleResponseTransaction(setPolicyRequest, EzspSetPolicyResponse.class);
    ashHandler.sendEzspTransaction(transaction);
    EzspSetPolicyResponse setPolicyResponse = (EzspSetPolicyResponse) transaction.getResponse();
    lastStatus = null;
    logger.debug(setPolicyResponse.toString());
    if (setPolicyResponse.getStatus() != EzspStatus.EZSP_SUCCESS) {
        logger.debug("Error during setting policy: {}", setPolicyResponse);
        return false;
    }
    return true;
}
Also used : EzspSetPolicyResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspSetPolicyResponse) EzspSetPolicyRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspSetPolicyRequest) EzspSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction)

Example 3 with EzspSingleResponseTransaction

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction 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 4 with EzspSingleResponseTransaction

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction 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 5 with EzspSingleResponseTransaction

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

the class EmberNcp method getPolicy.

/**
 * Get a policy used by the NCP to make fast decisions.
 *
 * @param policyId the {@link EzspPolicyId} to set
 * @return the returned {@link EzspDecisionId} if the policy was retrieved successfully or null if there was an
 *         error
 */
public EzspDecisionId getPolicy(EzspPolicyId policyId) {
    EzspGetPolicyRequest getPolicyRequest = new EzspGetPolicyRequest();
    getPolicyRequest.setPolicyId(policyId);
    EzspSingleResponseTransaction transaction = new EzspSingleResponseTransaction(getPolicyRequest, EzspGetPolicyResponse.class);
    ashHandler.sendEzspTransaction(transaction);
    EzspGetPolicyResponse getPolicyResponse = (EzspGetPolicyResponse) transaction.getResponse();
    lastStatus = null;
    logger.debug(getPolicyResponse.toString());
    if (getPolicyResponse.getStatus() != EzspStatus.EZSP_SUCCESS) {
        logger.debug("Error getting policy: {}", getPolicyResponse);
        return null;
    }
    return getPolicyResponse.getDecisionId();
}
Also used : EzspGetPolicyRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetPolicyRequest) EzspGetPolicyResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetPolicyResponse) 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