GSM modem ON/OFF by software?

How to ON and OFF the Sim900? using software is there any difference between the code to ON and OFF the gsm modem.I have read but didn't get from the datasheet.

i'm using following code to ON the modem:

int pwr=4;
void gsm_modem_ON()

now how to off the gsm modem? i have tried the same code to off also it works sometimes but sometimes fails also..why that fails?

Which board do you have?

On my board, which is the Itead one, it is as you have, pretty well: waggle the power control line low for a few hundred milliseconds, then put it high again. The problem is that this procedure TOGGLES the power, and if you don't know whether its on or off in the first place you don't know if you're turning if off or on.

To do it properly, I had to issue an AT command to see if it looked to be on already, before monkeying with the power control. Then after running the power control sequence listen for the first few chars that it sends when its powered on. If I see those within 2,000ms then I know its powered on and continue.

It's a PITA.

What I really need to do it to tack a line onto the main power LED or something, and bring it out so I can sense the power status from the controller.

arduino uno gsm sim900 can u post sample code for on and off

I don't see a specific shield/board named "gsm sim900". This is the one I'm using:

I'm controlling mine from a UNIX computer, not an Arduino. The code would not help you.

Search for SIMcom SIM900A

That is the GSM module, not the board. There must be 1,001 GSM shields/boards that use that simcom module -- it is one of the most widely used ones. To some extent they likely work similarly, but specifics about how the power-on logic is set up are the kind of thing that could vary from board to board.