avoiding delay() inside a funcyions

Hi all, i'm using this library:

to interface Arduino with a SIM900 gsm module.

The problem is that there are several delay inside the library, so that the exectution of some funcyion require several seconds sometime, blocking everything else, and i was wondering what would be a good way to rewrite it.

I know a bit how to do a final state machine using classes, but in case i have a function and i want, instead to stop the program for the delay time, interrupt that specific function and go to the next one, but then come back inside the function just after a certain time (the former delay one) how could i do?
Bests
Pietro

That will be hard to do, because of the timeout in SerialGSM::ReadLine().

The normal way is to use issue a command, and use a update() function that finishes the command. That update() function could be called in the loop() at the end.

A state machine would be needed, because every command has a different sequence.

Once again, it will be hard. The code that I see evolve, it three times longer and not very pretty.

What other code needs to run ?
The delay() calls a 'weak' yield() function. Therefor a void yield(void) function can be created to do things while other code is waiting for the delay().

Sounds like an opportunity to write a better version of the library.

...R

Well, there is a function called boot in the library, this is what it does:

void SerialGSM::Boot(){
int counter=0;
while(counter++ < 15){
if (verbose) Serial.print(".");
delay(1000);
}
if (verbose) Serial.println();

}

That is only during startup ? Is that a problem ? Is it called from setup() ?

Is just an example of how the library is written, it extensively use delay() everywhere, and this particular one stop the micro for 15 seconds from doing everything.
Anyway, the library was very usefull to me to learn a bit abut how to interface my project with a gsm module, but i think i need to change approach.
For example, i was thinking tu use an array of function like here.
I can keep index of witch one is the last executed and checking millis() to see when is time to pass to the next one.

I prefer a state-machine together with millis(). A variable that holds the 'state', and a big switch-case that does what needs to be done for that state. For communication with a GSM, it would be nice of someone did already made that, but I can't find it :frowning:

Well the switch case could work, but i guess a void array is a bit easyer if i want to have a collection of voids that i could arrange in the way i want, case by case?
Or maybe seems cool to me just because i just discovered it, and then do just the same.