How to send multiple AT commands in a loop?

In my program, I need to send 5 different AT commands, then check if the connection is fine.

first, I have a function called "connection_check()";

then, I do this:

GPRS_Serial.println("ATE0"); //Command echo off
connection_check(4,10);

so I repeat this for 5 times with different commands, but I want to change the code to another way.

char* commands[]={"command 1","command 2","command 3","command 4","command 5"}

for(int i=0;i<5;i++)
{
GPRS_Serial.println(""");
GPRS_Serial.print(commands*);*

  • GPRS_Serial.print("\r"");*
  • connection_check(4,10);*
    }
    Am I able to do in this way? because if I write my code in this way, my AT command will be split into 3 parts

A double quote is not part of the AT command sequence.
When you want to issue multiple commands, typically you will issue each command followed by a newline, as specified by the command set.
So what is it you want to do? Do you want to send many commands, and then, after that, check whether the connection is there?
In general, you can tie many AT commands into a single string starting with a single AT. The "AT" traditionally stands for "Attention."
Thus, if you want to give the commands ATA0, ATB1 and ATC2, you could string them together in a single string as ATA0B1C1.
One reference for AT commands in GSM equipment can be found here: GSM - Openmoko

I'm doing a project with SMS and GRPS..so I need to change the setting on sim900,like getting ip address, access point name etc.
so, do you mean, i write it like this:

for(int i=0;i<5;i++)
{
GPRS_Serial.println(command*);*

  • connection_check(4,10);*
    }

Assuming connection_check() does the right thing, yes, I imagine that would work. That loop will send five commands in sequence, calling connection_check() after each of those commands.