Search in sources :

Example 21 with EzspSingleResponseTransaction

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

the class EmberNcp method getChildParameters.

/**
 * Returns information about the children of the local node and the parent of the local node.
 *
 * @return the {@link EzspGetParentChildParametersResponse}
 */
public EzspGetParentChildParametersResponse getChildParameters() {
    EzspGetParentChildParametersRequest request = new EzspGetParentChildParametersRequest();
    EzspTransaction transaction = ashHandler.sendEzspTransaction(new EzspSingleResponseTransaction(request, EzspGetParentChildParametersResponse.class));
    EzspGetParentChildParametersResponse response = (EzspGetParentChildParametersResponse) transaction.getResponse();
    lastStatus = null;
    return response;
}
Also used : EzspTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspTransaction) EzspGetParentChildParametersResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetParentChildParametersResponse) EzspSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction) EzspGetParentChildParametersRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetParentChildParametersRequest)

Example 22 with EzspSingleResponseTransaction

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

the class ZigBeeDongleEzsp method setConcentrator.

private TransportConfigResult setConcentrator(ConcentratorConfig concentratorConfig) {
    EzspSetConcentratorRequest concentratorRequest = new EzspSetConcentratorRequest();
    concentratorRequest.setMinTime(concentratorConfig.getRefreshMinimum());
    concentratorRequest.setMaxTime(concentratorConfig.getRefreshMaximum());
    concentratorRequest.setMaxHops(concentratorConfig.getMaxHops());
    concentratorRequest.setRouteErrorThreshold(concentratorConfig.getMaxFailures());
    concentratorRequest.setDeliveryFailureThreshold(concentratorConfig.getMaxFailures());
    switch(concentratorConfig.getType()) {
        case DISABLED:
            concentratorRequest.setEnable(false);
            break;
        case HIGH_RAM:
            concentratorRequest.setConcentratorType(EmberConcentratorType.EMBER_HIGH_RAM_CONCENTRATOR);
            concentratorRequest.setEnable(true);
            break;
        case LOW_RAM:
            concentratorRequest.setConcentratorType(EmberConcentratorType.EMBER_LOW_RAM_CONCENTRATOR);
            concentratorRequest.setEnable(true);
            break;
        default:
            break;
    }
    EzspTransaction concentratorTransaction = ashHandler.sendEzspTransaction(new EzspSingleResponseTransaction(concentratorRequest, EzspSetConcentratorResponse.class));
    EzspSetConcentratorResponse concentratorResponse = (EzspSetConcentratorResponse) concentratorTransaction.getResponse();
    logger.debug(concentratorResponse.toString());
    if (concentratorResponse.getStatus() == EzspStatus.EZSP_SUCCESS) {
        return TransportConfigResult.SUCCESS;
    }
    return TransportConfigResult.FAILURE;
}
Also used : EzspSetConcentratorResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspSetConcentratorResponse) EzspSetConcentratorRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspSetConcentratorRequest) EzspTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspTransaction) EzspSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction)

Example 23 with EzspSingleResponseTransaction

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

the class ZigBeeDongleEzsp method initialize.

@Override
public ZigBeeInitializeResponse initialize() {
    logger.debug("EZSP dongle initialize.");
    zigbeeTransportReceive.setNetworkState(ZigBeeTransportState.UNINITIALISED);
    if (!initialiseEzspProtocol()) {
        return ZigBeeInitializeResponse.FAILED;
    }
    // Perform any stack configuration
    EmberStackConfiguration stackConfigurer = new EmberStackConfiguration(ashHandler);
    Map<EzspConfigId, Integer> configuration = stackConfigurer.getConfiguration(stackConfiguration.keySet());
    for (Entry<EzspConfigId, Integer> config : configuration.entrySet()) {
        logger.debug("Configuration state {} = {}", config.getKey(), config.getValue());
    }
    Map<EzspPolicyId, EzspDecisionId> policies = stackConfigurer.getPolicy(stackPolicies.keySet());
    for (Entry<EzspPolicyId, EzspDecisionId> policy : policies.entrySet()) {
        logger.debug("Policy state {} = {}", policy.getKey(), policy.getValue());
    }
    stackConfigurer.setConfiguration(stackConfiguration);
    configuration = stackConfigurer.getConfiguration(stackConfiguration.keySet());
    for (Entry<EzspConfigId, Integer> config : configuration.entrySet()) {
        logger.debug("Configuration state {} = {}", config.getKey(), config.getValue());
    }
    stackConfigurer.setPolicy(stackPolicies);
    policies = stackConfigurer.getPolicy(stackPolicies.keySet());
    for (Entry<EzspPolicyId, EzspDecisionId> policy : policies.entrySet()) {
        logger.debug("Policy state {} = {}", policy.getKey(), policy.getValue());
    }
    EmberNcp ncp = new EmberNcp(ashHandler);
    ncp.getNetworkParameters();
    // Add the endpoint
    ncp.addEndpoint(1, 0, ZigBeeProfileType.ZIGBEE_HOME_AUTOMATION.getId(), new int[] { 0 }, new int[] { 0 });
    // Now initialise the network
    EzspNetworkInitRequest networkInitRequest = new EzspNetworkInitRequest();
    EzspTransaction networkInitTransaction = ashHandler.sendEzspTransaction(new EzspSingleResponseTransaction(networkInitRequest, EzspNetworkInitResponse.class));
    EzspNetworkInitResponse networkInitResponse = (EzspNetworkInitResponse) networkInitTransaction.getResponse();
    logger.debug(networkInitResponse.toString());
    networkParameters = ncp.getNetworkParameters();
    ncp.getCurrentSecurityState();
    zigbeeTransportReceive.setNetworkState(ZigBeeTransportState.INITIALISING);
    logger.debug("EZSP dongle initialize done: Initialised {}", networkInitResponse.getStatus() == EmberStatus.EMBER_NOT_JOINED);
    // Check if the network is initialised or if we're yet to join
    if (networkInitResponse.getStatus() == EmberStatus.EMBER_NOT_JOINED) {
        return ZigBeeInitializeResponse.NOT_JOINED;
    }
    return ZigBeeInitializeResponse.JOINED;
}
Also used : EzspNetworkInitRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspNetworkInitRequest) EmberStackConfiguration(com.zsmartsystems.zigbee.dongle.ember.internal.EmberStackConfiguration) EzspNetworkInitResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspNetworkInitResponse) EzspDecisionId(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EzspDecisionId) EzspTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspTransaction) EzspConfigId(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EzspConfigId) EzspSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction) EzspPolicyId(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EzspPolicyId)

Example 24 with EzspSingleResponseTransaction

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

the class EmberNetworkInitialisation method doFormNetwork.

/**
 * Forms the ZigBee network
 *
 * @param panId the panId as int
 * @param extendedPanId the extended pan ID as {@link ExtendedPanId}
 * @param channel the radio channel to use
 * @return true if the network was formed successfully
 */
private boolean doFormNetwork(int panId, ExtendedPanId extendedPanId, int channel) {
    EmberNetworkParameters networkParameters = new EmberNetworkParameters();
    networkParameters.setJoinMethod(EmberJoinMethod.EMBER_USE_MAC_ASSOCIATION);
    networkParameters.setExtendedPanId(extendedPanId);
    networkParameters.setPanId(panId);
    networkParameters.setRadioChannel(channel);
    EzspFormNetworkRequest formNetwork = new EzspFormNetworkRequest();
    formNetwork.setParameters(networkParameters);
    EzspSingleResponseTransaction transaction = new EzspSingleResponseTransaction(formNetwork, EzspFormNetworkResponse.class);
    ashHandler.sendEzspTransaction(transaction);
    EzspFormNetworkResponse formNetworkResponse = (EzspFormNetworkResponse) transaction.getResponse();
    logger.debug(formNetworkResponse.toString());
    if (formNetworkResponse.getStatus() != EmberStatus.EMBER_SUCCESS) {
        logger.debug("Error during retrieval of network parameters: {}", formNetworkResponse);
        return false;
    }
    return true;
}
Also used : EzspFormNetworkRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspFormNetworkRequest) EzspFormNetworkResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspFormNetworkResponse) EmberNetworkParameters(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberNetworkParameters) EzspSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction)

Example 25 with EzspSingleResponseTransaction

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

the class EmberNetworkInitialisation method checkNetworkJoined.

private boolean checkNetworkJoined() {
    // Check if the network is initialised
    EzspNetworkStateRequest networkStateRequest = new EzspNetworkStateRequest();
    EzspTransaction networkStateTransaction = ashHandler.sendEzspTransaction(new EzspSingleResponseTransaction(networkStateRequest, EzspNetworkStateResponse.class));
    EzspNetworkStateResponse networkStateResponse = (EzspNetworkStateResponse) networkStateTransaction.getResponse();
    logger.debug(networkStateResponse.toString());
    logger.debug("EZSP networkStateResponse {}", networkStateResponse.getStatus());
    return networkStateResponse.getStatus() == EmberNetworkStatus.EMBER_JOINED_NETWORK;
}
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)

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