RTIC with dynamic scheduling and callbacks to static class methods

I'm trying to get RTIC to dynamically schedule tasks with a callback mechanism. I create an application class, Printer, it has a scheduler class Reactor. Scheduling for future execution is handled by the RTIC macros, so my Reactor class really just temporarily holds the callback until the main reactor_run() method can run where it looks for new callbacks and then schedule's them to run with the message parameter being the callback. The problem is, how do I get the correct object reference to the class with the method I want to run?

   #[task(local = [led], shared=[printer])]
    fn reactor_run(ctx: reactor_run::Context) {
        let mut printer = ctx.shared.printer;

        (printer).lock(|printer_a| {
            match &printer_a.run_result {
                Some(v) => {
                    // After init, schedule first reactor task
                    if v.eq(&String::from("init")) {
                        let callback =
                            |eventtime: shared_types::EventTime| printer_a.connect(eventtime);
                _ => {}

It looks like I may have to create #[task] type function handlers for every callback that I have that needs to be scheduled. Is that the case? I've got open ended callbacks for 100's of methods in various classes ahead of me. I'd rather have this ability contained in each module as they are added and such that they are independent modules. Otherwise, I'm going to end up with a global collection of methods in the app{} class. Yuck!

The problem with the above is :

error[E0597]: `printer` does not live long enough
   --> src/main.rs:375:61
199 | #[app(device = rp_pico::hal::pac, peripherals = true, dispatchers = [TIMER_IRQ_1])]
    |                                                                                   - `printer` dropped here while still borrowed
375 |         let callback = |eventtime: shared_types::EventTime| printer.connect(eventtime);
    |                        ------------------------------------ ^^^^^^^ borrowed value does not live long enough
    |                        |
    |                        value captured here
376 |         printer.reactor.register_callback(Box::new(callback));
    |                                           ------------------ cast requires that `printer` is borrowed for `'static`

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.