I am having difficulty changing the NETSTACK_RADIO struct in Contiki NG to switch between 2 radios with Zolertia Firefly, since it is defined as preprocessor directives.
/* Radio driver configuration. Most often set by the platform. */
#ifdef NETSTACK_CONF_RADIO
#define NETSTACK_RADIO NETSTACK_CONF_RADIO
How can I configure radio switching in Contiki NG during execution, and is this even possible?
I tried following but it does not work.
myapp.c file extract
/* Switch to the other radio */
if (NETSTACK_RADIO.get_object == NETSTACK_CONF_RADIO.get_object) {
NETSTACK_RADIO.set_object(NETSTACK_CONF_RADIO_SUBGHZ.get_object);
}
else if (NETSTACK_RADIO.get_object == NETSTACK_CONF_RADIO_SUBGHZ.get_object) {
NETSTACK_RADIO.set_object(NETSTACK_CONF_RADIO.get_object);
}
project-conf.h file
#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
/* Enable the cc2420 radio driver */
#define NETSTACK_CONF_RADIO cc2538_rf_driver
/* Enable the sub-ghz radio driver */
#define NETSTACK_CONF_RADIO_SUBGHZ cc1200_driver
#endif /* PROJECT_CONF_H_ */
Application file
project-conf.h file
This is another solution I tried but it does not work. It fails to change NETSTACK_RADIO at runtime.
References used:
https://docs.contiki-ng.org/en/develop/
https://github.com/Apress/Prac-Contiki-Program-Wireless-Sens-Networks
J. Jung, J. Hong and Y. Yi, "On Self-Configuring IoT With Dual Radios: A Cross-Layer Approach" in IEEE Transactions on Mobile Computing, vol. 21, no. 11, pp. 4064-4077, 2022. doi: 10.1109/TMC.2021.3066441
https://github.com/mp3jjk/SEDA-Net