arduino-lmic icon indicating copy to clipboard operation
arduino-lmic copied to clipboard

LMIC_unjoin, LMIC_unjoinAndRejoin are unsafe

Open terrillmoore opened this issue 3 years ago • 1 comments

Unfortunately, neither LMIC_unjoin(), nor LMIC_startJoining() are safe to be called outside the LMIC. They will corrupt state if the LMIC is actively doing work. But they are published as APIs. (The technical reason that they are unsafe is that they don't synchronize properly with ongoing operations in the LMIC. So strange things will happen if the LMIC is active, for example an assert "FAILURE at radio.c line 1065".)

LMIC_unjoinAndRejoin() is mostly safe; as it uses LMIC.osjob, guaranteeing that it's in sync. However, the reuse of LMIC.osjob means that things are just impossible to analyze; it kills any pending completion, which is mostly good, but it can itself be killed by other uses. This can only be fixed properly by switching to an explicit FSM design. Guess it's time.

terrillmoore avatar Jul 15 '21 13:07 terrillmoore