I have a project that was completely developed for certain packet type and length. Now there is the need to be able to receive this packet or an entirely new one whose length, preamble, and the payload are different.
There are two options for this and the first one is having two separate versions of the code, one that works with the current packet type and radio configuration, and another separate version with the new packet type and configuration.
The second, and best option, is to have the radio working with both packet types in the same code and have a configuration flag to choose one or the other.
Fortunately, anything else besides the packet length, preamble, and the payload changes, not even the CRC. The frequency, data, encoding, modulation, etc remain exactly the same which gives me hope that this can be achieved.
So my question is, what API functions do I use, or in other words, how can I achieve this? What are the necessary manipulations to perform at runtime to be able to change the packet type on the fly?
The easiest way is to create two configuration arrays. When you need to switch the packet type just call the radio initialization function, but when you call the ezradio_configuration_init() function use the new configuration array as argument.