Search in sources :

Example 1 with EzspFormNetworkRequest

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

the class EmberNetworkInitialisation method doFormNetwork.

/**
 * Forms the ZigBee network
 *
 * @param panId the panId as int
 * @param extendedPanId the extended pan ID as {@link ExtendedPanId}
 * @param channel the radio channel to use
 * @return true if the network was formed successfully
 */
private boolean doFormNetwork(int panId, ExtendedPanId extendedPanId, int channel) {
    EmberNetworkParameters networkParameters = new EmberNetworkParameters();
    networkParameters.setJoinMethod(EmberJoinMethod.EMBER_USE_MAC_ASSOCIATION);
    networkParameters.setExtendedPanId(extendedPanId);
    networkParameters.setPanId(panId);
    networkParameters.setRadioChannel(channel);
    EzspFormNetworkRequest formNetwork = new EzspFormNetworkRequest();
    formNetwork.setParameters(networkParameters);
    EzspSingleResponseTransaction transaction = new EzspSingleResponseTransaction(formNetwork, EzspFormNetworkResponse.class);
    ashHandler.sendEzspTransaction(transaction);
    EzspFormNetworkResponse formNetworkResponse = (EzspFormNetworkResponse) transaction.getResponse();
    logger.debug(formNetworkResponse.toString());
    if (formNetworkResponse.getStatus() != EmberStatus.EMBER_SUCCESS) {
        logger.debug("Error during retrieval of network parameters: {}", formNetworkResponse);
        return false;
    }
    return true;
}
Also used : EzspFormNetworkRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspFormNetworkRequest) EzspFormNetworkResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspFormNetworkResponse) EmberNetworkParameters(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberNetworkParameters) EzspSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction)

Aggregations

EzspFormNetworkRequest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspFormNetworkRequest)1 EzspFormNetworkResponse (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspFormNetworkResponse)1 EmberNetworkParameters (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberNetworkParameters)1 EzspSingleResponseTransaction (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction)1