hi folks,
I have a problem with the fona library and my SIM5320 GSM/GPS shield (w Arduino UNO).
I have managed to connect and to send receive SMS but I still have some issues with std calls.
What I want to do is simply recognize the caller id number.
I have found in the Adafuit_FONA.cpp file a specific function for doing this, which is “incomingCallNumber”
here’s the code of part of the file:
void Adafruit_FONA::onIncomingCall() {
DEBUG_PRINT(F("> ")); DEBUG_PRINTLN(F("Incoming call..."));
Adafruit_FONA::_incomingCall = true;
}
boolean Adafruit_FONA::_incomingCall = false;
boolean Adafruit_FONA::callerIdNotification(boolean enable, uint8_t interrupt) {
if(enable){
attachInterrupt(interrupt, onIncomingCall, FALLING);
return sendCheckReply(F("AT+CLIP=1"), ok_reply);
}
detachInterrupt(interrupt);
return sendCheckReply(F("AT+CLIP=0"), ok_reply);
}
boolean Adafruit_FONA::incomingCallNumber(char* phonenum) {
//+CLIP: "<incoming phone number>",145,"",0,"",0
if(!Adafruit_FONA::_incomingCall)
return false;
readline();
while(!prog_char_strcmp(replybuffer, (prog_char*)F("RING")) == 0) {
flushInput();
readline();
}
readline(); //reads incoming phone number line
parseReply(F("+CLIP: \""), phonenum, '"');
DEBUG_PRINT(F("Phone Number: "));
DEBUG_PRINTLN(replybuffer);
Adafruit_FONA::_incomingCall = false;
return true;
}
unfortunately when I call this function in my script nothing happens.
What I preventively did was to Enable incoming call notification
(see my code)
in order to have some output in the form //+CLIP: "<incoming phone number>",145,"",0,"",0
as displayed in the .cpp file, but still no information is received…
I am also attaching my code in order for you to understand
#include "Adafruit_FONA.h"
#define FONA_RX 11
#define FONA_TX 10
#define FONA_RST 5
#include <SoftwareSerial.h>
SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
SoftwareSerial *fonaSerial = &fonaSS;
Adafruit_FONA_3G fona = Adafruit_FONA_3G(FONA_RST);
void setup() {
Serial.begin(4800);
Serial.println(F("FONA incoming call example"));
Serial.println(F("Initializing....(May take 3 seconds)"));
fonaSerial->begin(4800);
if (! fona.begin(*fonaSerial)) {
Serial.println(F("Couldn't find FONA"));
while(1);
}
Serial.println(F("FONA is OK"));
// Enable incoming call notification
Serial.println(F("Enabling incoming call notification..."));
fona.sendCheckReply(F("AT+CLIP=1"), F("ok!"));
void loop(){
// Create a small string buffer to hold incoming call number.
char phone[32] = {0};
// Check for an incoming call. Will return true if a call is incoming.
if(fona.incomingCallNumber(phone)){
Serial.println(F("RING!"));
Serial.print(F("Phone Number: "));
Serial.println(phone);
}
}
I have to admit that I have copied this code from link
and I do not still understand the purpose of wiring the interrupt PIN of that script.
thanks for the help