Configuring openthread with random panid, channel

We are using:

NCS v1.9.1
nRF52840
openthread

We expect to operate in an environment with other Thread networks.  So, we would like to randomize the network credentials, and be able to change channels based on the environment.

Issue 1:

This application is for a commissioner, which will form the network.  We would like to configure this project so that, initially and after a factory reset, the network credentials (panid, channel, network key) are random.  In prf.conf, I can set 

CONFIG_OPENTHREAD_NETWORKKEY=""
and the network key is a new random string after a factory reset.  So, that's good.  How do you do that for panid and channel?
The channel and panid seem to be hard coded with defaults in .config.  The documentation about network forming suggest that these can be selected (best channel) or generated  randomly (panid) after a factory reset by an FTD.  How do I configure the project for that?
Issue 2:
Are there any examples or tutorials about changing channels dynamically.  I see that there is an api for that.
I tried including this code in main() at startup, but the channel remains at 25, as defined in prj.conf.
prj.conf (partial)
CONFIG_OPENTHREAD_NETWORKKEY=""
CONFIG_OPENTHREAD_PANID=23709
CONFIG_OPENTHREAD_CHANNEL=25
CONFIG_OPENTHREAD_CHANNEL_MONITOR=y
CONFIG_OPENTHREAD_CHANNEL_MANAGER=y
CONFIG_OPENTHREAD_COMMISSIONER=y
CONFIG_OPENTHREAD_FTD=y

CONFIG_OPENTHREAD_THREAD_STACK_SIZE=8192
CONFIG_OPENTHREAD_RADIO_WORKQUEUE_STACK_SIZE=2048
main()
	otInstance *instance = openthread_get_default_instance();
	otChannelManagerSetAutoChannelSelectionInterval(instance, 60);
	otChannelManagerSetSupportedChannels(instance, 0xFFFFFFFF);
    otChannelManagerSetAutoChannelSelectionEnabled(instance, true);
	printk("Openthread Channel Manager: delay = %d sec   supportedCh = 0x%x  favoredCh = 0x%x\r\n", 
			otChannelManagerGetDelay(instance),
			otChannelManagerGetSupportedChannels(instance),
			otChannelManagerGetFavoredChannels(instance) );
	//otChannelManagerRequestChannelChange(instance, 15);
	otChannelManagerRequestChannelSelect(instance, true);
Do the other devices on the network also change channels if one device does? 
What happens to SEDs when an FTD changes the selected channel?
Do all nodes save the new channel for use at the next power cycle?
Mary
Parents Reply Children
No Data
Related