Sim900 call detect

Is there any way to detect the char “RING” generated at the receiver serial while somebody is calling you out of lots of debugging message on the serial monitor. I thought of detecting the char “RING”, but the char is missed as the code runs sequentially and you cant wait to detect the char as the other codes have to run. So any help how to solve it ?


You can write code like below (Just example)

ISR ( ) //Copy serial data to global variable in ISR
	char uc_incoming;
	uc_incoming = BUFFER;

	receivebuf[ index++ ] = uc_incoming;
	receivebuf[ index + 1 ] = 0x00;
// Where receivebuf is global variable used to store serial data coming from GSM

       if( strstr( receivebuf, "RING") )	// In comming Call
			// Your task here

Or You can set a flag in ISR when you detect “RING” within ISR then you monitor that in main loop.

1 Like

As replied the main() code includes while(1), which means it will run forever. and there is no other code to run. But my requirement is to detect the call during other processes are happening inside main loop. And the problem is you can not forever wait to see whether there is a call or not.

I just gave you code.

Does your code execute other process all the time? When your condition comes to main loop? I mean how much time it takes to complete your ‘Other’ process and returns back to main loop?

by the way what is your actual requirement? What is your ‘other’ process?

It sends data to node-red server and the main loop takes around 7 seconds to execute once. If we try to check for the “RING” when the main loop starts, it may or may not catch the “RING” response from the GSM during a call.