Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flaw in using the quietest channel for the network (Ember) #1003

Closed
triller-telekom opened this issue Mar 17, 2020 · 1 comment · Fixed by #1004
Closed

Flaw in using the quietest channel for the network (Ember) #1003

triller-telekom opened this issue Mar 17, 2020 · 1 comment · Fixed by #1004
Labels

Comments

@triller-telekom
Copy link
Contributor

The EmberNetworkInitialisation class creates the zigbee network via

public void formNetwork(EmberNetworkParameters networkParameters, ZigBeeKey linkKey, ZigBeeKey networkKey) {
.
...
.
    if (networkParameters.getRadioChannel() == 0) {
            networkParameters.setRadioChannel(quietestChannel);
    }
.
...
.
}

The problem is, that the ZigBeeDongleEzsp which calls this formNetwork method, initializes the networkParameters during its initialization as follows:

// Get the current network parameters so that any configuration updates start from here
networkParameters = ncp.getNetworkParameters().getParameters();

As far as I understand it, this means that networkParameters.getRadioChannel() will always contain the channel that is set on the chip and thus never 0.

UNLESS one calls ZigbeeNetworkManager#setZigBeeChannel(ZigBeeChannel channel) between the ZigbeeNetworkManager#initialize() and ZigbeeNetworkManager#startup().

This boils down to the problem of setting a channel that satisfies the check from above: networkParameters.getRadioChannel() == 0.

The naive approach with

networkManager.setZigBeeChannel(ZigBeeChannel.create(0));

results in

ZigBeeDongleEzsp] - Unable to set channel outside of 2.4GHz channels: CHANNEL_00

The error occurs due to this check in ZigBeeDongleEzsp:

public ZigBeeStatus setZigBeeChannel(ZigBeeChannel channel) {
        if ((ZigBeeChannelMask.CHANNEL_MASK_2GHZ & channel.getMask()) == 0) {
            logger.debug("Unable to set channel outside of 2.4GHz channels: {}", channel);
            return ZigBeeStatus.INVALID_ARGUMENTS;
        }
        networkParameters.setRadioChannel(channel.getChannel());
        return ZigBeeStatus.SUCCESS;
    }

As a solution to this problem I think the check in formNetwork should be changed to:

if (networkParameters.getRadioChannel() == ZigBeeChannel.UNKNOWN.getChannel()) {
            networkParameters.setRadioChannel(quietestChannel);
}

And the check for setting a zigbee channel in ZigbeeDongleEzsp should be extended to allow for setting the UNKNOWN channel, which then means "Use auto detection to find the quietest channel":

public ZigBeeStatus setZigBeeChannel(ZigBeeChannel channel) {
        if (channel != ZigBeeChannel.UNKNOWN && (ZigBeeChannelMask.CHANNEL_MASK_2GHZ & channel.getMask()) == 0) {
            logger.debug("Unable to set channel outside of 2.4GHz channels: {}", channel);
            return ZigBeeStatus.INVALID_ARGUMENTS;
        }
        networkParameters.setRadioChannel(channel.getChannel());
        return ZigBeeStatus.SUCCESS;
}

However, I am also wondering why there is a check for the 2GHz band in there. Is there any regulatory that Ember chips must only be used within this frequency band?


I also had a look at the telegesis implementation, but I think this feature is not implemented (yet), at least I didn't see it in the transport implementation.

@cdjackson
Copy link
Member

Hi Stefan,
I think from a quick look at your proposal that it sounds ok.

However, I am also wondering why there is a check for the 2GHz band in there. Is there any regulatory that Ember chips must only be used within this frequency band?

ZigBee defines channels outside of 2GHz so we can't really do this - it is perfectly possible for the Ember chipset to use these frequencies. If the code that restrict this then we may need to remove that restriction at some point in future. Currently the 868MHz band is possible, and I understand that 915MHz will also be opened up in future (that said, these frequencies are currently only defined for use with Smart Energy but there are other users I know of looking at using ZigBee devices on these bands for added range).

Possibly also linked to #958.

triller-telekom added a commit to triller-telekom/com.zsmartsystems.zigbee that referenced this issue Mar 18, 2020
Using ZigbeeNetworkManager#setZigBeeChannel(ZigBeeChannel.UNKNOWN) before
the networkmanager startup will enable the scan for the quietest channel

Fixes zsmartsystems#1003
triller-telekom added a commit to triller-telekom/com.zsmartsystems.zigbee that referenced this issue Mar 18, 2020
Using ZigbeeNetworkManager#setZigBeeChannel(ZigBeeChannel.UNKNOWN) before
the networkmanager startup will enable the scan for the quietest channel

Fixes zsmartsystems#1003
cdjackson pushed a commit that referenced this issue Mar 18, 2020
Using ZigbeeNetworkManager#setZigBeeChannel(ZigBeeChannel.UNKNOWN) before
the networkmanager startup will enable the scan for the quietest channel

Fixes #1003
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants