2024-02-06 05:14 AM - edited 2024-02-06 05:36 AM
Hi,
My thread starts working with the features I mentioned below:
panID = 0x2222U;
channelNB = 12U;
networkKey = (otNetworkKey) {
.m8 = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}
};
I want to change this config in mcu working. How can I do this? I changed my values and I tried the code below:
otError error;
error = otLinkSetChannel(NULL, channelNB);
if (error != OT_ERROR_NONE)
{
return AKUS_ERROR;
}
error = otLinkSetPanId(NULL, panID);
if (error != OT_ERROR_NONE)
{
return AKUS_ERROR;
}
otNetworkKey *ptr_key = (otNetworkKey*)&(networkKey);
error = otThreadSetNetworkKey(NULL, ptr_key);
if (error != OT_ERROR_NONE)
{
return AKUS_ERROR;
}
but my thread app fails when I use this codes.
Best regards.
Solved! Go to Solution.
2024-02-08 07:33 AM
Hi @Mickey_Piper,
You are right, the change of thread network configuration requires to disable the protocol operation during this time, and to re-enable it using the function otThreadSetEnabled(NULL, true) so the new parameters are considered.
I have done a test using a WB Nucleo board with the project example ../Thread_FTD_Coap_Multicast and I confirm that the update was done successfully.
At the startup the network is configured by default with channel 12
Green led means that the device established the network and has a leader role
Pressing SW1 button allows to update the network parameters ( Channel 16...See APP_THREAD_UpdateNetwork function)
Thread protocol is restarted with the new parameters.
Please find the code in attachment.
BR, Ouadi
2024-02-07 04:25 AM
Hello @Mickey_Piper,
When you say the app fails using this new config, you mean that the new parameters are not set correctly and functions returns error ? Can you describe the failure ?
Are you using a project example provided in STM32WB FW package or a customized application ?
Could you please share with us your code to understand the case ?
Regards,
Ouadi
2024-02-07 05:46 AM
Hi @Ouadi ,
When you say the app fails using this new config, you mean that the new parameters are not set correctly and functions returns error ? Can you describe the failure ?
The functions don't return error. When it comes to the first function, for example "otLinkSetChannel", it enters the function and nothing happens. That's why the thread application also crashes.
Are you using a project example provided in STM32WB FW package or a customized application ?
No, I'm not using example projects. I created my own. It works good but I have to add this feature that update PanId, Channel NB and NetworkKey when mcu working.
Could you please share with us your code to understand the case ?
Since the work is done under the institution, I cannot share anything. Sorry for that.
I have shared all the code I can share and what I can say is that I want to change the Thread configuration according to the new PanId, Channel NB and NetworkKey that arrive while the thread application is running.
Best regards.
2024-02-07 06:13 AM
Hi,
I understand from your description that the application crashes after the first call of thread APIs "otLinkSetChannel". Does the program goes into a Hard-fault error ? If it's not the case, where the program stops ? Maybe the Call Stack capture would be appreciated.
Do you confirm that the network configuration change is done after the initialization of the Thread stack ?
Regards,
Ouadi
2024-02-07 09:29 PM
Hi @Ouadi ,
The program does not go into a Hard-fault error. I tracked the program and it follows this:
otLinkSetChannel(NULL,channelNB) -> Pre_OtCmdProcessing() -> UTIL_SEQ_WaitEvt(EVENT_SYNCHRO_BYPASS_IDLE)
and stuck in the last function.
I read the documentation of the otLinkSetChannel() function and in the function description it says "Succeeds only when Thread protocols are disabled.". I tried to use "error = otThreadSetEnabled(NULL, false);" at the beginning of the codes but it doesn't work too.
@Ouadi wrote:Do you confirm that the network configuration change is done after the initialization of the Thread stack ?
Yes, absolutely. When it starts, it set itself as a coordinator and I can confirm that it communicate with children. Then I send the new configs but it stops the communication but both children and coordinator status leds stays on.
Additionally, yesterday I tried to use Cli commands. This time coordinator not freezing but panid not changing anyway.
Best regards.
2024-02-08 07:33 AM
Hi @Mickey_Piper,
You are right, the change of thread network configuration requires to disable the protocol operation during this time, and to re-enable it using the function otThreadSetEnabled(NULL, true) so the new parameters are considered.
I have done a test using a WB Nucleo board with the project example ../Thread_FTD_Coap_Multicast and I confirm that the update was done successfully.
At the startup the network is configured by default with channel 12
Green led means that the device established the network and has a leader role
Pressing SW1 button allows to update the network parameters ( Channel 16...See APP_THREAD_UpdateNetwork function)
Thread protocol is restarted with the new parameters.
Please find the code in attachment.
BR, Ouadi
2024-02-12 11:50 PM
Hi @Ouadi ,
Thank you for your support. I looked your code and applied in my project but I didn't work for me. I don't know why but when I call the update function my device freeze instantly. It cannot get any command or send anything just freezing. Is there any special config or something?
Best regards.
2024-02-13 01:03 AM
Hello @Mickey_Piper,
What is the role of your Thread device ? Is it an MTD or FTD ?
Which binary have you used to flash the wireless coprocessor (version) ?
Do you use a custom HW board or a development kit ?
As I don't have access to your code I cannot suppose the root cause of this behavior, but I can confirm that the application with an update network is working fine with a nucleo board, you can maybe compare with the project example I gave you previously.
Regards,
Ouadi
2024-02-13 02:29 AM
Hi @Ouadi ,
What is the role of your Thread device ? Is it an MTD or FTD ?
I'm using FTD in my device.
Which binary have you used to flash the wireless coprocessor (version) ?
I'm currently using v1.18.0.
Do you use a custom HW board or a development kit ?
It's a STM32WB55 Nucleo board, not a custom design.
Can I request to you create a simple Thread FTD application for testing? Maybe something is causing this but example application cause the not see the problem.
Best regards.
2024-02-13 05:23 AM
Hi,
You can find thread project examples in our GitHub following this link STM32CubeWB/Projects/P-NUCLEO-WB55.Nucleo/Applications /Thread/
You can use the example ../Thread_FTD_Coap_Multicast for your test and replace the file <app_thread.c> by <app_thread_update_network.c> provided previously in order to perform a network update.
Best regards,
Ouadi