How to make this multi tasking in better way ?

Hi,

I am preparing a GPS tracker in which fetching data from Neo6MV2 and sending it to remote server using SIM900A.
In the process, there are some 5 to 8 AT commands that are related to SIM900A. The functionality is working perfect. As of now I am using delay() with it but now I want to make it with the help of millis().

So my goal is to run multiple commands one after another with the delay of 1 second.
E.g.
command1 -> command2 -> command3 -> command1 -> command2 -> command3 ......

So I created a sample code that runs 2 commands,

unsigned long previousMillis1 = 0;
unsigned long previousMillis2 = 0;
const long interval = 1000;
boolean here = false;
boolean here2 = false;

void setup(){
  Serial.begin(9600);
}
void loop(){
  Serial.println("..................................");
  unsigned long currentMillis1 = millis();
  if(here == false && (currentMillis1 - previousMillis1 >= interval))
  {
    previousMillis1 = currentMillis1;
    Serial.println("Here");
    here = true;
    here2 = true;
  }

  unsigned long currentMillis2 = millis();
  if(here2 = true && (currentMillis2 - previousMillis2 >= 2000))
  {
    previousMillis2 = currentMillis2;
    previousMillis1 = currentMillis2;
    Serial.println("Here2");
    here2 = false;
    here = false;
  }

  
}

But how can I make it more simpler ? In above code, no. of commands = no. of boolean flags.
After running every command, I have to disable its corresponding flag and enable the one for next one. How to make this easy ?

I don't think there is anything fundamentally wrong with your approach. There is no need for currentMillis1 and currentMillis2 - just use one of them for both parts.

As you are using separate timing for the activities (previousMillis1 and previousMillis2) you probably don't need the here and here2.

The style previousMillis1 += interval; will be a little more accurate in the long run than previousMillis1 = currentMillis1;. The reason is discussed at length in the following link.

Have a look at the demo Several Things at a Time

...R