hello all...
It was very hard for me to understand the SIM900_suli library, there are very few examples and I tried to figure it out reading the cpp file.
Many things unfortunatelly are still unclear.
Anyway, the code below calls a number and starts to count RINGs in the DO/WHILE loop, int ringCount increment is by 1.
When running the code it goes 1,3,5,7....and so on.!!!??? WHY?
I should be 1,2,3,4....
Also, the response from the GPRS shield, in string gprsBuffer is truncated. there are only the 2 last digits from the caller ID. gprsBuffer length is always 16. (???)
you can see it in the screenshot....
I cant figure out why this is happening....any help is appreciated?
#include <GPRS_Shield_Arduino.h>
#include <SoftwareSerial.h>
#include <Wire.h>
#include <Suli.h>
#define NUM "xxxx083314"
char gprsBuffer[32];
char *s = NULL;
GPRS gprsVP(7,8,19200);//RX,TX,PWR,BaudRate
void setup()
{
Serial.begin(19200);
while (!Serial.available()) {Serial.println("Press key to start") ;}
while(0 == gprsVP.init())
{delay(500);
Serial.print("Init error\r\n");
}
delay(500);
Serial.println("Initialized..OK!");
countrings();
}
void loop()
{
sim900_read_buffer(gprsBuffer,32,DEFAULT_TIMEOUT);
Serial.println(gprsBuffer);
}
void countrings()
{
int ringCount = 0;
int readCount = 0;
int busyCount = 0;
int nocarCount = 0;
gprsVP.hangup();
gprsVP.callUp(NUM);
delay(200);
sim900_clean_buffer(gprsBuffer,32);
do {
sim900_read_buffer(gprsBuffer,32,DEFAULT_TIMEOUT);
Serial.println(gprsBuffer);
Serial.print("buffer length=");
String t=String(gprsBuffer);
Serial.println(t.length());
if(NULL != strstr(gprsBuffer,"RING"))
{ringCount++;
Serial.print("ring string found -->"); //(ringCount);
Serial.println(ringCount++);
}
if(NULL !=strstr(gprsBuffer, "BUSY"))
{Serial.println("busy string found ");
busyCount++;
Serial.println(busyCount);
ringCount=20; //escape do loop
}
if(NULL !=strstr(gprsBuffer, "NO CARRIER"))
{Serial.print("no carrier found ");
nocarCount++;
Serial.println(nocarCount);
ringCount=20; // escape do loop
}
} while (ringCount < 20);
gprsVP.hangup();
Serial.print("OUT of the LOOOOp ==>");
Serial.println(ringCount);
sim900_clean_buffer(gprsBuffer,32);
}
