use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EzspDecisionId 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));
}
}
use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EzspDecisionId 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;
}
use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EzspDecisionId in project com.zsmartsystems.zigbee by zsmartsystems.
the class EmberStackConfiguration method setPolicy.
/**
* Configuration utility. Takes a {@link Map} of {@link EzspConfigId} to {@link EzspDecisionId} and will work
* through setting them before returning.
*
* @param policies {@link Map} of {@link EzspPolicyId} to {@link EzspDecisionId} with configuration to set
* @return true if all policies were set successfully
*/
public boolean setPolicy(Map<EzspPolicyId, EzspDecisionId> policies) {
boolean success = true;
EmberNcp ncp = new EmberNcp(ashHandler);
for (Entry<EzspPolicyId, EzspDecisionId> policy : policies.entrySet()) {
if (!ncp.setPolicy(policy.getKey(), policy.getValue())) {
success = false;
}
}
return success;
}
use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EzspDecisionId 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;
}
Aggregations