I created an Arduino program that can be send and receive SMS/voice calls. But I do not know how to receive a phone call.
Everything works except the Get_Call()
function. I want this function to receive a phone call and stop this call with a serial command like my Send_Call
function.
I haven't found how the program can receive phone calls with AT commands.
This is my code:
#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);
char message=0;
void setup() {
SIM900.begin(19200);
delay(25000);
Serial.begin(19200);
Serial.println("OK");
digitalWrite(9, HIGH);
delay(1000);
}
void Send_Call() {
SIM900.println("ATD 0608446677;");
delay(100);
SIM900.println();
while(Serial.read() != '1') {
delay(100);
}
SIM900.println("ATH");
delay(1000);
}
void Send_SMS() {
SIM900.print("AT+CMGF=1\r");
delay(100);
SIM900.println("AT+CMGS=\"0608446677\"");
delay(100);
SIM900.println("test sms");
delay(100);
SIM900.println((char)26);
delay(100);
SIM900.println();
delay(5000);
Serial.println("SMS sent successfully");
}
void Get_SMS() {
SIM900.println("AT+CNMI=2,2,0,0,0");
delay(1000);
}
void Get_Call() {
}
void loop() {
if (Serial.available()>0) {
if(Serial.read() == 'p') {
Send_Call();
}
if(Serial.read() == 's') {
Send_SMS();
}
Get_SMS();
Get_Call();
}
if (SIM900.available()>0)
Serial.write(SIM900.read());
}
I tried this for Get_Call()
:
void Get_Call() {
SIM900.print("AT+ATA\r\n"); //accept call
SIM900.print("AT+CLIP=1\r\n"); //view phone number
while(Serial.read() != '1') {
delay(100);
}
SIM900.println("ATH"); //exit call when send in com '1'
}