Search in sources :

Example 1 with EzspConfigId

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EzspConfigId in project com.zsmartsystems.zigbee by zsmartsystems.

the class EmberStackConfiguration method setConfiguration.

/**
 * Configuration utility. Takes a {@link Map} of {@link EzspConfigId} to {@link Integer} and will work through
 * setting them before returning.
 *
 * @param configuration {@link Map} of {@link EzspConfigId} to {@link Integer} with configuration to set
 * @return true if all configuration were set successfully
 */
public boolean setConfiguration(Map<EzspConfigId, Integer> configuration) {
    boolean success = true;
    EmberNcp ncp = new EmberNcp(ashHandler);
    for (Entry<EzspConfigId, Integer> config : configuration.entrySet()) {
        if (!ncp.setConfiguration(config.getKey(), config.getValue())) {
            success = false;
        }
    }
    return success;
}
Also used : EmberNcp(com.zsmartsystems.zigbee.dongle.ember.EmberNcp) EzspConfigId(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EzspConfigId)

Example 2 with EzspConfigId

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EzspConfigId 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 3 with EzspConfigId

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EzspConfigId in project com.zsmartsystems.zigbee by zsmartsystems.

the class EmberStackConfiguration method getConfiguration.

/**
 * Configuration utility. Takes a {@link Set} of {@link EzspConfigId} and will work through
 * requesting them before returning.
 *
 * @param configuration {@link Set} of {@link EzspConfigId} to request
 * @return map of configuration data mapping {@link EzspConfigId} to {@link Integer}. Value will be null if error
 *         occurred.
 */
public Map<EzspConfigId, Integer> getConfiguration(Set<EzspConfigId> configuration) {
    Map<EzspConfigId, Integer> response = new HashMap<EzspConfigId, Integer>();
    EmberNcp ncp = new EmberNcp(ashHandler);
    for (EzspConfigId configId : configuration) {
        response.put(configId, ncp.getConfiguration(configId));
    }
    return response;
}
Also used : EmberNcp(com.zsmartsystems.zigbee.dongle.ember.EmberNcp) HashMap(java.util.HashMap) EzspConfigId(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EzspConfigId)

Aggregations

EzspConfigId (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EzspConfigId)3 EmberNcp (com.zsmartsystems.zigbee.dongle.ember.EmberNcp)2 EmberStackConfiguration (com.zsmartsystems.zigbee.dongle.ember.internal.EmberStackConfiguration)1 EzspNetworkInitRequest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspNetworkInitRequest)1 EzspNetworkInitResponse (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspNetworkInitResponse)1 EzspDecisionId (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EzspDecisionId)1 EzspPolicyId (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EzspPolicyId)1 EzspSingleResponseTransaction (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction)1 EzspTransaction (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspTransaction)1 HashMap (java.util.HashMap)1