I've got a sim900 gsm module and I'm using a sketch that checks the sim entries from position 1 to 3 and if the calling number is in one of those positions, it hangs up the call and sends an sms to that number. Alternatively I added a sendSMS command outside this "authorized number check" if-block just to make sure the sketch worked. The outside sendSMS always worked.
My idea was to replace one of the SIM entries with the number I'm calling from in order to make the inner if-block sendSMS work. Here is the original:
#include "SIM900.h"
#include <SoftwareSerial.h>
#include "sms.h"
#include "call.h"
SoftwareSerial SIM900(18, 19);
CallGSM call;
SMSGSM sms;
char number[20];
byte stat=0;
void setup() {
Serial.begin(9600);
if (gsm.begin(2400))
Serial.println("\nstatus=READY");
else Serial.println("\nstatus=IDLE");
[color=red] //THESE ARE THE LINES I ADDED TO ADD THE ENTRY TO THE SIM @ POS3
//NOTE I ONLY RAN THE SKETCH ONCE WITH THESE LINES
SIM900.print("AT+CPBS=\"SM\"");
SIM900.print("AT+CPBW=e,\"+countrycode&number\",145,\"ArduinoHonduras\"");
};[/color]
Where Sim900 is my software serial defined as pins 18,19 for my mega since I'm using Serial for the monitor.
I'm not sure why the number wasn't being written to the phonebook but whenever I read the first 3 positions, I still got the originally programmed numbers at those positions instead of the one I added at position 3.
The serial monitor originally produced something like:
ATT: +CPMS:
RIC:
+CPMS: 72,190,72,190,72,190
OK
+CPMS: 72,190,72,190,72,190
and the outer sms was sent. But now after running the above code with the red lines, I get this:
ATT: OK
RIC:
OK
ATT: +CPMS:
RIC:
ATT: +CPMS:
RIC: AT+CPMS="SM","SM","SM"
ERROR
OK
ATT: SHUT OK
RIC: AT+CIPSHUT
SHUT OK
And no matter how many times I run the original code (without the lines in red) I always get the same error lines which I never had before.
Any ideas?