Openthread application in both FTD and RCP mode
Posted: Wed Jun 18, 2025 12:20 pm
Hello everyone!
I am trying to make an ESP32 application by combining the examples of `ot_cli` and `ot_rcp`. I want to compile a firmware where the device can operate both as a JOINER and in RCP mode. Of course the application will never be in both states, but I want to compile with the possibility of using both these states and dynamically on runtime choose which version to initialize.
I noticed that when I enable these configuration options simultaneously the firmware cannot be compiled:
FTD mode works fine if I have this enabled:
and RCP mode seems to compile fine if I have this enabled:
I noticed this line of code inside `idf/components/openthread/private_include/openthread-core-esp32x-radio-config.h`
It looks to me like the esp32 openthread library was not intended to allow compilation for both RCP and JOINER mode.
I also noticed that even if I suppress the error above and enable both RADIO and JOINER
the CMakeLists.txt in the openthread component (idf/components/openthread/CMakeLists.txt) handles these configurations as mutually exclusive, thus not allowing compilation for both without manually changing this file (and thus diverging from the espressif idf branch)
My question is if there is any reason that it is not allowed to compile for both these modes. Of course I understand why I cannot use both these modes simultaneously, I just want to allow compiling for both and choose on runtime which one to initialize. Is there a limitation on that based on the way the openthread library works? Can I just modify the CMake files myself and to compile succesfully or is there a reason that I cannot do that?
Has anyone ever encountered this scenario in the past, I am curious to hear how you solved this.
I am trying to make an ESP32 application by combining the examples of `ot_cli` and `ot_rcp`. I want to compile a firmware where the device can operate both as a JOINER and in RCP mode. Of course the application will never be in both states, but I want to compile with the possibility of using both these states and dynamically on runtime choose which version to initialize.
I noticed that when I enable these configuration options simultaneously the firmware cannot be compiled:
Code: Select all
CONFIG_OPENTHREAD_RADIO=y
CONFIG_OPENTHREAD_JOINER=y
Code: Select all
CONFIG_OPENTHREAD_RADIO=n
CONFIG_OPENTHREAD_JOINER=y
Code: Select all
CONFIG_OPENTHREAD_RADIO=y
CONFIG_OPENTHREAD_JOINER=n
Code: Select all
#if CONFIG_OPENTHREAD_JOINER
#error "Joiner shouldn't be enabled for RCP"
#endif
I also noticed that even if I suppress the error above and enable both RADIO and JOINER
Code: Select all
CONFIG_OPENTHREAD_RADIO=y
CONFIG_OPENTHREAD_JOINER=y
My question is if there is any reason that it is not allowed to compile for both these modes. Of course I understand why I cannot use both these modes simultaneously, I just want to allow compiling for both and choose on runtime which one to initialize. Is there a limitation on that based on the way the openthread library works? Can I just modify the CMake files myself and to compile succesfully or is there a reason that I cannot do that?
Has anyone ever encountered this scenario in the past, I am curious to hear how you solved this.