mcci-catena/arduino-lmic

LMIC validDR() doesn't check out-of-range

terrillmoore opened this issue · 2 comments

If you pass an invalid value to validDR() [off end of table], it returns garbage. Unfortunately, MAC commands use DRs and assume validDR() will do the right thing. And the compliance test for EU sends invalid DRs (section 5.4).

The implementation is inherently somewhat fragile. But the solution is to make validDR() a region-sensitive API, so that it co-resides with the implementation of _DR2RPS_CRC, allowing it to check against the size.

Fixing this requires moving some material from lorabase.h to an LMIC-specific file. Those items (some static inline functions) actually already were LMIC-specific, but didn't really depend on the new region scheme... apparently. They're all in-scope for clients after #include "lmic.h", so we can't just rip them out. Moving them to lmic_bandplan.h will make things work.