use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberCurrentSecurityState 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.EmberCurrentSecurityState in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeDongleEzsp method startup.
@Override
public boolean startup(boolean reinitialize) {
logger.debug("EZSP dongle startup.");
// If ashHandler is null then the serial port didn't initialise
if (ashHandler == null) {
logger.error("Initialising Ember Dongle but low level handle is not initialised.");
return false;
}
EmberNcp ncp = new EmberNcp(ashHandler);
// Check if the network is initialised
EmberNetworkStatus networkState = ncp.getNetworkState();
logger.debug("EZSP networkStateResponse {}", networkState);
// If we want to reinitialize the network, then go...
if (reinitialize) {
logger.debug("Reinitialising Ember NCP and forming network.");
EmberNetworkInitialisation netInitialiser = new EmberNetworkInitialisation(ashHandler);
netInitialiser.formNetwork(networkParameters, networkKey);
ncp.getNetworkParameters();
}
// Check if the network is now up
networkState = ncp.getNetworkState();
logger.debug("EZSP networkStateResponse {}", networkState);
if (networkState == EmberNetworkStatus.EMBER_JOINED_NETWORK) {
zigbeeTransportReceive.setNetworkState(ZigBeeTransportState.ONLINE);
}
// Get the security state - mainly for debug
EmberCurrentSecurityState currentSecurityState = ncp.getCurrentSecurityState();
logger.debug("Current Security State = {}", currentSecurityState);
EzspGetParentChildParametersResponse childParametersResponse = ncp.getChildParameters();
logger.debug("Current Parent Child Information = {}", childParametersResponse);
for (int childId = 0; childId < childParametersResponse.getChildCount(); childId++) {
ncp.getChildInformation(childId);
}
logger.debug("EZSP dongle startup done.");
return true;
}
Aggregations