When using a blocking receive, I was getting non-sensical packet length
and garbage data, whereas IRQ mode was working fine. This was happening
despite what looked like a workaround for this in the code which would
read the length twice.
I tracked it down to the receive function trying to read the data too
early, before the packet had even been received. The receive function
would wait for the GDO0 pin to become low, then assume the packet was
ready and read off the data.
However, the GD0 pin is set by the `startReceive` as inverted and,
according to the datasheet, in a mode which "asserts when sync word has
been received, and de-asserts at the end of the packet". In other words,
taking into account the inversion, GDO0 becomes low at the start of the
packet and high at the end of it.
Therefore the receive function would actually try to read the packet
data as soon as the packet had started, rather than wait until the end,
explaining the garbage data.
I suspect that with a slow MCU and a fast transmission rate, the
previous workaround of reading the length field twice may have delayed
the data read just enough to allow the packet to be fully received, but
this does not work in the general case.
This commit updates the logic by first waiting for a low signal,
followed by a high one. This is actually the exact same logic used in
the blocking transmit implementation, but inverted to account for the
INV flag set on GDO0. The commit also removes the past workaround, since
it should not be necessary anymore.
This removes the compatibility wrapper and applies the following
replacements:
sed -i 's/setRfSwitchState(LOW, LOW)/setRfSwitchState(Module::MODE_IDLE)/' src/modules/*/*.cpp
sed -i 's/setRfSwitchState(HIGH, LOW)/setRfSwitchState(Module::MODE_RX)/' src/modules/*/*.cpp
sed -i 's/setRfSwitchState(LOW, HIGH)/setRfSwitchState(Module::MODE_TX)/' src/modules/*/*.cpp
This gives all radios that use an rfswitch (i.e. have
a setRfSwitchPins() wrapper already) a wrapper method for
setRfSwitchTable() too. This wrapper just calls the same method on
Module, to make it easier for sketches to use it.
- all `begin()` now use macros for init values
- addressed other styling comments as per PR#612 review
Signed-off-by: Federico Maggi <federico.maggi@gmail.com>
For some reason, the `RADIOLIB_SHAPING_NONE` was being passed to `setEncoding` and `RADIOLIB_ENCODING_NRZ` was being passed to `setDataShaping`. Flipped these to be passed to the correct functions.
Note: These are both defined as `0x00` so this should have no impact on functionality, just makes initialization less confusing.