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)