Basically the formatting and layout of your program is completely wrong. You haven't actually defined this smsReceivingFunction
anywhere. You have created a prototype to it part way through your loop()
function, but not created the actual function.
You should learn to strictly indent your program properly. It is important, since by doing so you can follow the flow and structure of your program much easier.
For instance, if I pass your program through Artistic Style to attempt to automatically correct your indenting it results in this:
#include <OneSheeld.h>
float lat ;
float lon ;
char charlat [30];
char charlon [30];
char readings [150];
int buttonPin = 11;
int ledPin = 12;
void setup() {
// put your setup code here, to run once:
OneSheeld.begin();
/* Set the button pin as input. */
pinMode(buttonPin, INPUT);
/* Set the LED pin as output. */
pinMode(ledPin, OUTPUT);
SMS.setOnSmsReceive(&smsReceivingFunction);
}
void loop()
{
charlat[0] = 0;
charlon[0] = 0;
readings [0] = 0;
if (digitalRead(buttonPin) == HIGH) {
/* Turn on the LED. */
digitalWrite(ledPin, HIGH);
delay( 1000);
digitalWrite(ledPin, HIGH);
delay( 500);
lat = GPS.getLatitude();
lon = GPS.getLongitude();
dtostrf(lat, 3, 7, charlat);
dtostrf(lon, 3, 7, charlon);
strcat(readings, "please call me I i do not pick up the call please reach to my location:\n");
strcat(readings, "http://maps.google.com/maps?q=");
strcat (readings, charlat);
strcat(readings, ",");
strcat (readings, charlon);
SMS.send("+917771914436", readings);
void smsReceivingFunction(const char * number, const char * text);
if (!strcmp(number, "+7771914436")) { /* phone number from which you will send the sms "PUT YOURS IN PLACE OF +1234567890" */
if (!strcmp(text, "?")) {
lat = GPS.getLatitude();
}
lon = GPS.getLongitude();
dtostrf(lat, 3, 7, charlat);
dtostrf(lon, 3, 7, charlon);
strcat(readings, "please call me I i do not pick up the call please reach to my location:\n");
strcat(readings, "http://maps.google.com/maps?q=");
strcat (readings, charlat);
strcat(readings, ",");
strcat (readings, charlon);
SMS.send("+917771914436", readings);
}
}
}
}
As you can now see you have an extra }
at the end of your sketch, so your brackets are not balanced. That in itself is a syntax error. Also you can see your function prototype slap bang in the middle of your loop() function:
...
SMS.send("+917771914436", readings);
void smsReceivingFunction(const char * number, const char * text);
if (!strcmp(number, "+7771914436")) { /* phone number
...
I think, though of course I can't actually test this since I don't have your hardware, that you really meant to start a new function at that point in your program, and of course that would mean finishing the previous function first: you cannot nest functions inside each other. So I would guess your program should have looked something more like this:
#include <OneSheeld.h>
float lat ;
float lon ;
char charlat [30];
char charlon [30];
char readings [150];
int buttonPin = 11;
int ledPin = 12;
void setup() {
// put your setup code here, to run once:
OneSheeld.begin();
/* Set the button pin as input. */
pinMode(buttonPin, INPUT);
/* Set the LED pin as output. */
pinMode(ledPin, OUTPUT);
SMS.setOnSmsReceive(&smsReceivingFunction);
}
void loop()
{
charlat[0] = 0;
charlon[0] = 0;
readings [0] = 0;
if (digitalRead(buttonPin) == HIGH) {
/* Turn on the LED. */
digitalWrite(ledPin, HIGH);
delay( 1000);
digitalWrite(ledPin, HIGH);
delay( 500);
lat = GPS.getLatitude();
lon = GPS.getLongitude();
dtostrf(lat, 3, 7, charlat);
dtostrf(lon, 3, 7, charlon);
strcat(readings, "please call me I i do not pick up the call please reach to my location:\n");
strcat(readings, "http://maps.google.com/maps?q=");
strcat (readings, charlat);
strcat(readings, ",");
strcat (readings, charlon);
SMS.send("+917771914436", readings);
}
}
void smsReceivingFunction(const char * number, const char * text) {
if (!strcmp(number, "+7771914436")) { /* phone number from which you will send the sms "PUT YOURS IN PLACE OF +1234567890" */
if (!strcmp(text, "?")) {
lat = GPS.getLatitude();
}
lon = GPS.getLongitude();
dtostrf(lat, 3, 7, charlat);
dtostrf(lon, 3, 7, charlon);
strcat(readings, "please call me I i do not pick up the call please reach to my location:\n");
strcat(readings, "http://maps.google.com/maps?q=");
strcat (readings, charlat);
strcat(readings, ",");
strcat (readings, charlon);
SMS.send("+917771914436", readings);
}
}