Search in sources :

Example 1 with EmberNetworkParameters

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberNetworkParameters in project com.zsmartsystems.zigbee by zsmartsystems.

the class EmberConsoleNetworkStateCommand method process.

@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out) throws IllegalArgumentException {
    EmberNcp ncp = getEmberNcp(networkManager);
    EmberNetworkParameters networkState = ncp.getNetworkParameters();
    out.println("PAN ID         : " + networkState.getPanId());
    out.println("Extended PAN ID: " + networkState.getExtendedPanId());
    out.println("Radio Channel  : " + networkState.getRadioChannel());
    out.println("Transmit Power : " + networkState.getRadioTxPower());
    out.println("Join Method    : " + networkState.getJoinMethod());
    out.println("Network Manager: " + networkState.getNwkManagerId());
}
Also used : EmberNcp(com.zsmartsystems.zigbee.dongle.ember.EmberNcp) EmberNetworkParameters(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberNetworkParameters)

Example 2 with EmberNetworkParameters

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberNetworkParameters in project com.zsmartsystems.zigbee by zsmartsystems.

the class EzspGetNetworkParametersResponseTest method testVersionError.

@Test
public void testVersionError() {
    EzspFrame.setEzspVersion(4);
    EzspGetNetworkParametersResponse response = new EzspGetNetworkParametersResponse(getPacketData("05 80 28 00 01 EF CB B1 57 A8 CC C6 D7 05 C8 00 0B 00 00 00 00 00 F8 FF 07"));
    System.out.println(response);
    assertEquals(5, response.getSequenceNumber());
    assertEquals(true, response.isResponse());
    assertEquals(EzspGetNetworkParametersResponse.FRAME_ID, response.getFrameId());
    assertEquals(EmberStatus.EMBER_SUCCESS, response.getStatus());
    assertEquals(EmberNodeType.EMBER_COORDINATOR, response.getNodeType());
    EmberNetworkParameters networkParameters = response.getParameters();
    assertEquals(11, networkParameters.getRadioChannel());
    assertEquals(0, networkParameters.getRadioTxPower());
    assertEquals(EmberJoinMethod.EMBER_USE_MAC_ASSOCIATION, networkParameters.getJoinMethod());
    assertEquals(0, networkParameters.getNwkManagerId());
    assertEquals(134215680, networkParameters.getChannels());
}
Also used : EmberNetworkParameters(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberNetworkParameters) EzspFrameTest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.EzspFrameTest) Test(org.junit.Test)

Example 3 with EmberNetworkParameters

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberNetworkParameters in project com.zsmartsystems.zigbee by zsmartsystems.

the class EmberNcp method getNetworkParameters.

/**
 * Gets the current network parameters, or an empty parameters class if there's an error
 *
 * @return {@link EmberNetworkParameters}
 */
public EmberNetworkParameters getNetworkParameters() {
    EzspGetNetworkParametersRequest request = new EzspGetNetworkParametersRequest();
    EzspSingleResponseTransaction transaction = new EzspSingleResponseTransaction(request, EzspGetNetworkParametersResponse.class);
    ashHandler.sendEzspTransaction(transaction);
    EzspGetNetworkParametersResponse response = (EzspGetNetworkParametersResponse) transaction.getResponse();
    logger.debug(response.toString());
    lastStatus = response.getStatus();
    if (response.getStatus() != EmberStatus.EMBER_SUCCESS && response.getStatus() != EmberStatus.EMBER_NOT_JOINED) {
        logger.debug("Error during retrieval of network parameters: {}", response);
        return new EmberNetworkParameters();
    }
    return response.getParameters();
}
Also used : EzspGetNetworkParametersRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetNetworkParametersRequest) EzspGetNetworkParametersResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetNetworkParametersResponse) EmberNetworkParameters(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberNetworkParameters) EzspSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction)

Example 4 with EmberNetworkParameters

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberNetworkParameters 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

EmberNetworkParameters (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberNetworkParameters)4 EzspSingleResponseTransaction (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction)2 EmberNcp (com.zsmartsystems.zigbee.dongle.ember.EmberNcp)1 EzspFrameTest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.EzspFrameTest)1 EzspFormNetworkRequest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspFormNetworkRequest)1 EzspFormNetworkResponse (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspFormNetworkResponse)1 EzspGetNetworkParametersRequest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetNetworkParametersRequest)1 EzspGetNetworkParametersResponse (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspGetNetworkParametersResponse)1 Test (org.junit.Test)1