I keep getting the error: expected unqualified-id before '.' token for all of my Serial.print lines contained in a library I am making.
For some reason if I change the lines to say Serial1.print the errors go away.
Could someone please point out what I am obviously missing?
Library:
//***********LIBRARIES***************************
#include <SIM900.h> //include the declaration for this class
#include <gsmbase.h>
#include <Stdio.h>
#include <SD.h>
#include <MASTER.h>
#include <EEPROM.h>
#include <Ethernet.h>
#include <SPI.h>
#include <NewSoftSerial.h>
#include <WProgram.h>
#include <ArdOSC.h>
#include <stdlib.h>
//************DEFINES****************************
byte timeStamp[50];
//**************VARIABLES************************
const byte LED_PIN = 13; //use the LED @ Arduino pin 13, this should not change so make it const (constant)
char SSfile[]={"S00DATA.csv"};
File datatext;
char fileT[]={"csv"};//FILE TYPE
static const char cb64[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
//<<constructor>> setup the LED, make pin 13 an OUTPUT
SIM900::SIM900(Serial& telit, uint32_t(*millis)(), Serial* debug):
GSMbase(telit, millis, debug), getData(NULL){
memset(ipAddress1,'\0',IPsize); //Sets ipAddress1 to all Null(\0) characters
memset(ipAddress2,'\0',IPsize);
}
//<<destructor>>
SIM900::~SIM900(){/*nothing to destruct*/}
//Turns the SIM900 on/off (requires special hardware configuration that uses a digital input to switch an NPN transistor that allows powerKey to ground)
//Need to add more functionality to test if the shield is already on by sending an AT command
void SIM900::powerKey(int powerPin){
pinMode(powerPin, OUTPUT); //Makes the desired digital I/O an output that controls the NPN transistor base.
digitalWrite(powerPin,HIGH); //Makes the digital control output +5VDC allowing flow through the NPN transistor.
delay(2000); //It is assumed that a delay() is okay here as it is expected that this function would reside in the SETUP
digitalWrite(powerPin,LOW); //Pull the digital pin back down to 0V, turning off the NPN transistor and stoping the current flow between PowerKey and Ground.
}
//Sends an SMS message to a recipitant
void SIM900::sendSms(String phoneNumber, String message){
Serial2.print("AT+CMGS="); //SIM900 AT command to send an SMS message
Serial2.print(34,BYTE); //prints quatation marks "
Serial2.print(phoneNumber); //ptints the phone number of the recipitant
Serial2.print(34,BYTE); //prints quatation marks "
Serial2.println(13,BYTE); //prints <CR> also know as cariage reutrn
delay(3000); //wait 3 seconds for a response from the SIM900 **(THIS SHOULD CHANGE TO USE ANOTHER TIMER NOT DELAY)**
Serial2.print(message); //prints the desired message
Serial2.println(26,BYTE); //prints CTRL-Z also known as sub (Used to let the SIM900 know your SMS is ready to send) **(See SIM900 command manual for details)**
}
const char* const SIM900::shutIpConnection(){
Serial2.print("AT+CIPSHUT"); //SIM900 AT command to shut IP connection
Serial2.print(13,BYTE); //Prints <CR> to finish command
//return catchTelitData(2000,1);
}
const char* const SIM900::getTimeStamp(){
Serial2.print("AT+CCLK?"); //SIM900 AT command to get time stamp
Serial2.print(13,BYTE);
delay(2000);
if (Serial2.available()>0){
int i = 0;
while (Serial2.available()>0){
// if(i < 20 || i >39){
// Serial2.read();
// }else {
// Serial.print(Serial2.peek());
timeStamp[i]=(Serial2.read());
// Serial.print(i);
// }
i++;
}
}
int years = (((timeStamp[25])-48)*10)+((timeStamp[26])-48);
int months = (((timeStamp[22])-48)*10)+((timeStamp[23])-48);
int days = (((timeStamp[19])-48)*10)+((timeStamp[20])-48);
int hours = (((timeStamp[28])-48)*10)+((timeStamp[29])-48);
int mins = (((timeStamp[31])-48)*10)+((timeStamp[32])-48);
int secs = (((timeStamp[34])-48)*10)+((timeStamp[35])-48);
Serial.print("Time is: ");
if(days<10){
Serial.print(0);
}
Serial.print(days);
Serial.print("/");
if(months<10){
Serial.print(0);
}
Serial.print(months);
Serial.print("/");
if (years<10){
Serial.print(0);
}
Serial.print(years);
Serial.print("-");
if (hours<10){
Serial.print(0);
}
Serial.print(hours);
Serial.print(":");
if (mins<10){
Serial.print(0);
}
Serial.print(mins);
Serial.print(":");
if (secs<10){
Serial.print(0);
}
Serial.println(secs);
delay(5000);
}
Arduino Code:
#include <gsmbase.h>
#include <SIM900.h>
#include <Stdio.h>
#include <SD.h>
#include <MASTER.h>
#include <EEPROM.h>
#include <Ethernet.h>
#include <SPI.h>
#include <NewSoftSerial.h>
#include <WProgram.h>
#include <ArdOSC.h>
#include <stdlib.h>
//SIM900 SIM;
SIM900 mySIM900(Serial2,millis,&Serial);
byte timeStamp[50];
void setup() {
Serial2.begin(9600);
Serial.begin(9600);
mySIM900.shutIpConnection();
delay(5000);
Serial.println("Setup complete");
}
void loop() {
Serial2.flush();
mySIM900.getTimeStamp();
delay(2000);
/* if (Serial2.available()>0){
int i = 0;
while (Serial2.available()>0){
// if(i < 20 || i >39){
// Serial2.read();
// }else {
Serial.write(Serial2.peek());
timeStamp[i]=(Serial2.read());
// Serial.print(i);
// }
i++;
}
}
int hours = (((timeStamp[28])-48)*10)+((timeStamp[29])-48);
int mins = (((timeStamp[31])-48)*10)+((timeStamp[32])-48);
int secs = (((timeStamp[34])-48)*10)+((timeStamp[35])-48);
if (hours<10){
Serial.print(0);
}
Serial.print(hours);
Serial.print(":");
if (mins<10){
Serial.print(0);
}
Serial.print(mins);
Serial.print(":");
if (secs<10){
Serial.print(0);
}
Serial.print(secs);
delay(5000);*/
}