Hi, I am trying to switch listening between SIM900 and TinyGPS+ but I have no idea what is the name of SoftwareSerial used by SIM900 library.
My GPS is:
SoftwareSerial ss(10, 11);
so I can listen it with
ss.listen();
but I dont know how to listen to SIM900.
Here is my code:
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include "SIM900.h"
#include "sms.h"
SMSGSM sms;
char latitude[12];
char longitude[12];
char textnav[180];
char number[]="123123123";
char message[180]="123";
char pos;
char *p;
static const int RXPin = 7, TXPin = 8;
static const uint32_t GPSBaud = 9600;
// The TinyGPS++ object
TinyGPSPlus gps;
// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);
void setup()
{
Serial.begin(115200);
ss.begin(GPSBaud);
if (gsm.begin(2400))
Serial.println("\nstatus=READY");
else Serial.println("\nstatus=IDLE");
}
void loop()
{
pos=sms.IsSMSPresent(SMS_UNREAD);
Serial.println((int)pos);
if((int)pos>0&&(int)pos<=20){
Serial.print("Incomming message, POS=");
Serial.println((int)pos);
message[0]='\0';
sms.GetSMS((int)pos,number,message,180);
p=strstr(message,"PASSWORD");
if(p){
Serial.println("Success");
while (ss.available() > 0)
gps.encode(ss.read());
if (gps.location.isUpdated())
{
strcpy(textnav, "comgooglemaps://?q=");
dtostrf(gps.location.lat(), 1, 6, latitude);
strcat(textnav,latitude);
strcat(textnav,",");
dtostrf(gps.location.lng(), 1, 6, longitude);
strcat(textnav,longitude);
Serial.println(textnav);
sms.SendSMS(number, textnav);
delay(1000);
}
}
}
sms.DeleteSMS((int)pos);
delay(2000);
}