This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How can you adjust the channel using the Zigbee SDK

I have been struggling to get a Zigbee end device talking to a SmartThings hub which is on channel 14. I have now discovered that regardless of the channel mask I give it the nRF52840 is using channel 16. I can see this by calling nrf_081541_channel_get(). I even tried to use nrf_802514_channel_set() to set the channel to 14 immediately before the commissioning start but it makes no difference.

What am I doing wrong? The demo light switch code running on a PCA10056 and two PCA10059s also seems to ignore any channel options and work only on channel 16.

Having played with this for a while it seems that the call to bdb_start_top_level_commissioning is setting the channel to 16. I set it to 14 before the call using the call nrf_802154_channel_set(14);. here is my code:

static zb_void_t light_switch_retry_join(zb_uint8_t leave_type)
{
    zb_bool_t comm_status;

    if (leave_type == ZB_NWK_LEAVE_TYPE_RESET)
    {
        NRF_LOG_INFO("Starting commisioning");
//        comm_status = bdb_start_top_level_commissioning(ZB_BDB_NETWORK_STEERING);
        zb_set_bdb_primary_channel_set(0x00004000UL);
        zb_set_bdb_secondary_channel_set(0x00008000UL);
    nrf_802154_channel_set(14);
    NRF_LOG_INFO("Before commisioning start Channel set to %d", nrf_802154_channel_get());
        comm_status = bdb_start_top_level_commissioning(ZB_BDB_FINDING_N_BINDING | ZB_BDB_NETWORK_STEERING);
    NRF_LOG_INFO("After commisioning start Channel set to %d", nrf_802154_channel_get());
        ZB_COMM_STATUS_CHECK(comm_status);
//        zb_bdb_set_legacy_device_support()

    }
}

When the system gives up I print out the failure message with the current channel number -
NRF_LOG_ERROR("Failed to join network. Status: %d on channel %d", status, nrf_802154_channel_get());

The join call shows a channel of 14 but the fail shows channel 16. The call to enable the device sets the channel to 14...
    zb_set_network_ed_role(IEEE_CHANNEL_MASK);    //IEEE_CHANNEL_MASK is set to (1l<<14)
  • Hello,

    Are you sure you don't have multiple definitions of IEEE_CHANNEL_MASK?

    Try to only change the #define ZIGBEE_CHANNEL 11 in sdk_config.h (SDK\examples\zigbee\light_control\light_switch\pca10056\blank\config). Also, make sure that you erase the chip, either by using nrfjprog -e before programming the DK, or by setting "#define ERASE_PERSISTENT_CONFIG             ZB_TRUE" near the top of main.c.

    Let me know if it still doesn't work, but I tested it here. I didn't try to log anything, but the device was certainly not connecting to the network when it was using the wrong channel.

    BR,

    Edvin

  • It was the persistent config setting. The source code set the ERASE_PERSISTENT_CONFIG to ZB_FALSE and because I initially tested the three boards together in the light switch demo project the channel got fixed to 16. From then on it was picking it out of the configuration and ignoring anything I was giving it.

    A rookie mistake I suppose but then again I am just starting out with this!

    Having changed the setting and putting the channel number to 14 the demo switch was found by my SmartThing hub so now I can make some progress.

    Many thanks for your speedy reply and help.

Related