Search in sources :

Example 1 with EmberNcp

use of com.zsmartsystems.zigbee.dongle.ember.EmberNcp in project com.zsmartsystems.zigbee by zsmartsystems.

the class EmberConsoleSecurityStateCommand method process.

@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out) throws IllegalArgumentException {
    if (networkManager.getNetworkState() != ZigBeeTransportState.ONLINE) {
        throw new IllegalStateException("Network state is " + networkManager.getNetworkState() + ". Unable to show security data.");
    }
    EmberNcp ncp = getEmberNcp(networkManager);
    Integer securityLevel = ncp.getConfiguration(EzspConfigId.EZSP_CONFIG_SECURITY_LEVEL);
    Integer rejoinTimeout = ncp.getConfiguration(EzspConfigId.EZSP_CONFIG_TC_REJOINS_USING_WELL_KNOWN_KEY_TIMEOUT_S);
    Integer trustCentreCacheSize = ncp.getConfiguration(EzspConfigId.EZSP_CONFIG_TRUST_CENTER_ADDRESS_CACHE_SIZE);
    Integer keyTableSize = ncp.getConfiguration(EzspConfigId.EZSP_CONFIG_KEY_TABLE_SIZE);
    Integer transientKeyTimeout = ncp.getConfiguration(EzspConfigId.EZSP_CONFIG_TRANSIENT_KEY_TIMEOUT_S);
    EmberCurrentSecurityState securityState = ncp.getCurrentSecurityState();
    EzspDecisionId trustCentrePolicy = ncp.getPolicy(EzspPolicyId.EZSP_TRUST_CENTER_POLICY);
    EzspDecisionId appKeyPolicy = ncp.getPolicy(EzspPolicyId.EZSP_APP_KEY_REQUEST_POLICY);
    EzspDecisionId trustCentreKeyPolicy = ncp.getPolicy(EzspPolicyId.EZSP_TC_KEY_REQUEST_POLICY);
    EzspDecisionId trustCentreRejoinPolicy = ncp.getPolicy(EzspPolicyId.EZSP_TC_REJOINS_USING_WELL_KNOWN_KEY_POLICY);
    EmberKeyStruct networkKey = ncp.getKey(EmberKeyType.EMBER_CURRENT_NETWORK_KEY);
    EmberKeyStruct linkKey = ncp.getKey(EmberKeyType.EMBER_TRUST_CENTER_LINK_KEY);
    List<EmberKeyStruct> keyTable = new ArrayList<>();
    for (int cnt = 0; cnt < keyTableSize; cnt++) {
        EmberKeyStruct key = ncp.getKeyTableEntry(cnt);
        if (key != null) {
            keyTable.add(key);
        }
    }
    out.println("Trust Centre Address       : " + securityState.getTrustCenterLongAddress());
    out.println("Security level             : " + securityLevel);
    out.println("Rejoin timeout             : " + rejoinTimeout);
    out.println("Key table size             : " + keyTableSize);
    out.println("Trust Centre cache size    : " + trustCentreCacheSize);
    out.println("Transient key timeout      : " + transientKeyTimeout);
    out.println("Application Key Policy     : " + appKeyPolicy);
    out.println("Trust Centre Policy        : " + trustCentrePolicy);
    out.println("Trust Centre Key Policy    : " + trustCentreKeyPolicy);
    out.println("Trust Centre Rejoin Policy : " + trustCentreRejoinPolicy);
    out.print("Security state flags       : ");
    boolean first = true;
    for (EmberCurrentSecurityBitmask state : securityState.getBitmask()) {
        if (!first) {
            out.print("                           : ");
        }
        first = false;
        out.println(state);
    }
    if (first) {
        out.println();
    }
    out.println();
    out.println("Key Type                        IEEE Address      Key Data                          In Cnt    Out Cnt   Seq");
    out.println(printKey(linkKey));
    out.println(printKey(networkKey));
    for (EmberKeyStruct key : keyTable) {
        out.println(printKey(key));
    }
}
Also used : EmberCurrentSecurityBitmask(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberCurrentSecurityBitmask) EmberNcp(com.zsmartsystems.zigbee.dongle.ember.EmberNcp) EzspDecisionId(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EzspDecisionId) ArrayList(java.util.ArrayList) EmberKeyStruct(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberKeyStruct) EmberCurrentSecurityState(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberCurrentSecurityState)

Example 2 with EmberNcp

use of com.zsmartsystems.zigbee.dongle.ember.EmberNcp in project com.zsmartsystems.zigbee by zsmartsystems.

the class EmberConsoleNcpChildrenCommand method process.

@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out) throws IllegalArgumentException {
    EmberNcp ncp = getEmberNcp(networkManager);
    EzspGetParentChildParametersResponse childParameters = ncp.getChildParameters();
    out.println("Ember NCP contains " + childParameters.getChildCount() + " children" + ((childParameters.getChildCount() == 0) ? "." : ":"));
    for (int childId = 0; childId < childParameters.getChildCount(); childId++) {
        EzspGetChildDataResponse child = ncp.getChildInformation(childId);
        out.println(String.format("%2d  %-10s  %-10s  %s", child.getChildId(), child.getStatus(), child.getChildType(), child.getChildEui64()));
    }
}
Also used : EmberNcp(com.zsmartsystems.zigbee.dongle.ember.EmberNcp) EzspGetChildDataResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetChildDataResponse) EzspGetParentChildParametersResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetParentChildParametersResponse)

Example 3 with EmberNcp

use of com.zsmartsystems.zigbee.dongle.ember.EmberNcp in project com.zsmartsystems.zigbee by zsmartsystems.

the class EmberConsoleNcpCountersCommand method process.

@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out) throws IllegalArgumentException {
    EmberNcp ncp = getEmberNcp(networkManager);
    int[] counters = ncp.getCounters();
    out.println("Ember NCP counters -: ");
    for (int counter = 0; counter < counters.length; counter++) {
        out.println(String.format("  [%-2d] %-45s: %d", counter, EmberCounterType.getEmberCounterType(counter), counters[counter]));
    }
}
Also used : EmberNcp(com.zsmartsystems.zigbee.dongle.ember.EmberNcp)

Example 4 with EmberNcp

use of com.zsmartsystems.zigbee.dongle.ember.EmberNcp in project com.zsmartsystems.zigbee by zsmartsystems.

the class EmberStackConfiguration method getPolicy.

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

Example 5 with EmberNcp

use of com.zsmartsystems.zigbee.dongle.ember.EmberNcp 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)

Aggregations

EmberNcp (com.zsmartsystems.zigbee.dongle.ember.EmberNcp)10 EzspDecisionId (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EzspDecisionId)3 EzspConfigId (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EzspConfigId)2 EzspPolicyId (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EzspPolicyId)2 HashMap (java.util.HashMap)2 EzspGetChildDataResponse (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetChildDataResponse)1 EzspGetParentChildParametersResponse (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetParentChildParametersResponse)1 EzspVersionResponse (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionResponse)1 EmberCurrentSecurityBitmask (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberCurrentSecurityBitmask)1 EmberCurrentSecurityState (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberCurrentSecurityState)1 EmberKeyStruct (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberKeyStruct)1 EmberNetworkParameters (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberNetworkParameters)1 EmberNetworkStatus (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberNetworkStatus)1 ArrayList (java.util.ArrayList)1