Replies: 2 comments 6 replies
-
Yes, it's very possible. However, it requires care, because you must put the LMIC in its own task, and you must introduce trampoline functions to deal with synchronization. You cannot call the LMIC APIs directly because the job loop "knows" it's not going to be interrupted, and your call to the LMIC starts a copy of the framework running in a different thread. Result: crashes. The right thing is three tasks: one to send packets; one for your other task; and a third for the LMIC. The LMIC task alternates between checking the run loop and checking for incoming requests. Because the LMIC directly exposes the Is your feather a single core or multi-core system? This is really hard to describe (based on lots of years trying to describe it) because a concrete description depends on how you've structured your app. It's comparatively easy to show by example. If you'll post a link to your repo, I can possibly fork it and send updates. I can certainly review and give more concrete suggestions. |
Beta Was this translation helpful? Give feedback.
-
The The actual flow you need (sorry that the examples are not clear) is this:
Detecting LMIC idleIf the LMIC is idle, you don’t need to call os_runloop_once. It’s currently not so easy to find out if the LMIC is idle. You can do it without changing code by a two-step process.
Discussion of send APIs
Recommended LMIC thread designAssume that LMIC_thread() is started "somehow" -- it's the main function of the LMIC task. Use the following pseudocode. Some changes are needed to make this simpler; maybe in v5. void LMIC_thread(void *arg) {
// initialize the LMIC
// other initialization for message queue ... app specific
while (1) {
// wait for something to do
while (LMIC is idle && no message to send)
/* block -- OS-specific */;
// transmit a message if one is ready to be transmitted
if (message to send && LMIC_queryTxReady()) {
// consume message
// ("consume" -- reset flags or adjust queues so that the message only gets sent once.)
status = LMIC_sendWithCallback(...);
// remember to check the status code!
}
// now keep running the LMIC until it goes idle, sleeping when possible.
while (! LMIC is idle) {
os_runloop_once();
if (! os_queryTimeCriticalJobs(ms2osticks(10)) {
// use an OS API to sleep the task for 10ms, as there's nothing happening soon
} // end while
// LMIC is now idle,... loop around and look for a message; if not found, sleep forever.
}
// not reached
} |
Beta Was this translation helpful? Give feedback.
-
Hello,
Is multi-tasking using (FreeRTOS) possible with the LoRaWAN LMICC library ?
I am running two tasks on my FeatherBoard:
-one to sendLoRa packets and then suspending it to run another task and do some computation
-and then resuming back the sendLora task but the transmission never resumes
Any suggestions or help would be appreciated.
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions