Search in sources :

Example 1 with EzspSetInitialSecurityStateResponse

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspSetInitialSecurityStateResponse in project com.zsmartsystems.zigbee by zsmartsystems.

the class EmberNetworkInitialisation method setSecurityState.

/**
 * Sets the initial security state
 *
 * @param networkKey the initial {@link EmberKeyData}
 * @return true if the security state was set successfully
 */
private boolean setSecurityState(EmberKeyData networkKey) {
    // Define the ZigBeeAliance09 key for HA link-key
    // This is used to encrypt the network key when it is transferred to a newly joining device.
    EmberKeyData linkKey = new EmberKeyData();
    linkKey.setContents(new int[] { 0x5A, 0x69, 0x67, 0x42, 0x65, 0x65, 0x41, 0x6C, 0x6C, 0x69, 0x61, 0x6E, 0x63, 0x65, 0x30, 0x39 });
    // linkKey.setContents(new int[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
    // 0xFF, 0xFF, 0xFF });
    EzspSetInitialSecurityStateRequest securityState = new EzspSetInitialSecurityStateRequest();
    EmberInitialSecurityState state = new EmberInitialSecurityState();
    // state.addBitmask(EmberInitialSecurityBitmask.EMBER_STANDARD_SECURITY_MODE);
    // state.addBitmask(EmberInitialSecurityBitmask.EMBER_DISTRIBUTED_TRUST_CENTER_MODE);//
    // EMBER_TRUST_CENTER_GLOBAL_LINK_KEY);
    state.addBitmask(EmberInitialSecurityBitmask.EMBER_TRUST_CENTER_GLOBAL_LINK_KEY);
    state.addBitmask(EmberInitialSecurityBitmask.EMBER_HAVE_PRECONFIGURED_KEY);
    state.addBitmask(EmberInitialSecurityBitmask.EMBER_HAVE_NETWORK_KEY);
    state.addBitmask(EmberInitialSecurityBitmask.EMBER_NO_FRAME_COUNTER_RESET);
    state.addBitmask(EmberInitialSecurityBitmask.EMBER_REQUIRE_ENCRYPTED_KEY);
    state.setNetworkKey(networkKey);
    state.setPreconfiguredKey(linkKey);
    state.setPreconfiguredTrustCenterEui64(new IeeeAddress());
    securityState.setState(state);
    EzspSingleResponseTransaction transaction = new EzspSingleResponseTransaction(securityState, EzspSetInitialSecurityStateResponse.class);
    ashHandler.sendEzspTransaction(transaction);
    EzspSetInitialSecurityStateResponse securityStateResponse = (EzspSetInitialSecurityStateResponse) transaction.getResponse();
    logger.debug(securityStateResponse.toString());
    if (securityStateResponse.getStatus() != EmberStatus.EMBER_SUCCESS) {
        logger.debug("Error during retrieval of network parameters: {}", securityStateResponse);
        return false;
    }
    return true;
}
Also used : EzspSetInitialSecurityStateRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspSetInitialSecurityStateRequest) EmberKeyData(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberKeyData) EzspSetInitialSecurityStateResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspSetInitialSecurityStateResponse) EzspSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction) EmberInitialSecurityState(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberInitialSecurityState) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress)

Aggregations

IeeeAddress (com.zsmartsystems.zigbee.IeeeAddress)1 EzspSetInitialSecurityStateRequest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspSetInitialSecurityStateRequest)1 EzspSetInitialSecurityStateResponse (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspSetInitialSecurityStateResponse)1 EmberInitialSecurityState (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberInitialSecurityState)1 EmberKeyData (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberKeyData)1 EzspSingleResponseTransaction (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction)1