Help with function Parameter. (it's very ALIEN to me)

Hi guys! so i recently stumbled upon this function and its parameters confused me a bit here is the function.

bool DFRobot_SIM808::getLocation(const __FlashStringHelper *apn, float *longitude, float *latitude)

My questions are. 1.) why is there a "*" mark before the variable name? i.e. (const __FlashStringHelper *apn, float *longitude, float *latitude)

2.) how do I properly type in the function parameters when using the function?

3.) how to declare variable for that function? (especially the "__FlashStringHelper")

4.) what is a "__FlashStringHelper"?

By the way the function belongs to the library called "DFRobot_Sim808" it's for the Sim808 GSM+GPS module. Posted below is the full code of the function, I got it from the .cpp file of the library.

bool DFRobot_SIM808::getLocation(const __FlashStringHelper *apn, float *longitude, float *latitude)
{     
    int i = 0;
    char gprsBuffer[80];
    char buffer[20];
    char *s;
    
    //send AT+SAPBR=3,1,"Contype","DFRobot_SIM808"
    sim808_check_with_cmd("AT+SAPBR=3,1,\"Contype\",\"DFRobot_SIM808\"\r","OK\r\n",CMD);
    //sen AT+SAPBR=3,1,"APN","DFRobot_SIM808_APN"
    sim808_send_cmd("AT+SAPBR=3,1,\"APN\",\"");
    if (apn) {
      sim808_send_cmd(apn);
    }
    sim808_check_with_cmd("\"\r","OK\r\n",CMD);
    //send AT+SAPBR =1,1
    sim808_check_with_cmd("AT+SAPBR=1,1\r","OK\r\n",CMD);

    //AT+CIPGSMLOC=1,1
    sim808_flush_serial();
    sim808_send_cmd("AT+CIPGSMLOC=1,1\r");
    sim808_clean_buffer(gprsBuffer,sizeof(gprsBuffer)); 
    sim808_read_buffer(gprsBuffer,sizeof(gprsBuffer),2*DEFAULT_TIMEOUT,6*DEFAULT_INTERCHAR_TIMEOUT);
    //Serial.println(gprsBuffer);
    
    if(NULL != ( s = strstr(gprsBuffer,"+CIPGSMLOC:")))
    {
        s = strstr((char *)s, ",");
        s = s+1;
        //Serial.println(*s);
        i=0;
        while(*(++s) !=  ',')
            buffer[i++]=*s;
        buffer[i] = 0;
        *longitude = atof(buffer);
               
        i=0;
        while(*(++s) !=  ',')
            buffer[i++]=*s;
        buffer[i] = 0;
        *latitude = atof(buffer);            
        return true;
    }
    return false;
}

Replies would be very much appreciated!! Thanks in Advance! :D

1.) why is there a "*" mark before the variable name?

To indicate that the type is pointer to whatever the type in front of the * is.

2.) how do I properly type in the function parameters when using the function?

Use your keyboard. 8)

The function you posted the prototype for takes 3 arguments. The first is a string in flash memory. The second and third are addresses where the function is to write some data.

   float lat, lon;
   if(robbieTheRobot.getLocation(F("SomeName"), &lat, &lon))
   {
   }

4.) what is a "__FlashStringHelper"?

All string literals are stored in flash memory by the compiler. By default, they are copied to SRAM. For literals, that will never change, that is a waste of SRAM. So, the F() macro tells the compiler not to copy the literal to SRAM. But, since functions normally expect strings to be in SRAM, something needs to tell the function that the data is in flash memory, not SRAM. That is what a __FlashStringHelper does.

I also tried experimenting with the function and here is my source code

#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>

#define PIN_TX    7
#define PIN_RX    8
SoftwareSerial mySerial(PIN_TX,PIN_RX);
DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,

const __FlashStringHelper *apn;
float *longitude;
float *latitude;
//DFRobot_SIM808 sim808(&Serial);

void setup() {
  mySerial.begin(9600);
  Serial.begin(9600);

  //******** Initialize sim808 module *************
  while(!sim808.init()) { 
      delay(1000);
      Serial.print("Sim808 init error\r\n");
  }

  //************* Turn on the GPS power************
  if( sim808.attachGPS())
      Serial.println("Open the GPS power success");
  else 
      Serial.println("Open the GPS power failure");
  
}

void loop() {

  sim808.getLocation(*apn, *longitude,*latitude);

}

And all I got was an error message. Here is the error message that I got.

Arduino: 1.6.7 (Windows 8), Board: "Arduino Nano, ATmega328"

C:\Users\Enerio\AppData\Local\Temp\arduino_b27b7111d80c322339002a9d7d57fe62\SIM808_GetGPS.ino: In function 'void loop()':

SIM808_GetGPS:46: error: no matching function for call to 'DFRobot_SIM808::getLocation(const __FlashStringHelper&, float&, float&)'

   sim808.getLocation(*apn, *longitude,*latitude);

                                                ^

C:\Users\Enerio\AppData\Local\Temp\arduino_b27b7111d80c322339002a9d7d57fe62\SIM808_GetGPS.ino:46:48: note: candidate is:

In file included from C:\Users\Enerio\AppData\Local\Temp\arduino_b27b7111d80c322339002a9d7d57fe62\SIM808_GetGPS.ino:13:0:

C:\Program Files (x86)\Arduino\libraries\DFRobot_SIM808/DFRobot_sim808.h:324:10: note: bool DFRobot_SIM808::getLocation(const __FlashStringHelper*, float*, float*)

     bool getLocation(const __FlashStringHelper *apn, float *longitude, float *latitude);

          ^

C:\Program Files (x86)\Arduino\libraries\DFRobot_SIM808/DFRobot_sim808.h:324:10: note:   no known conversion for argument 1 from 'const __FlashStringHelper' to 'const __FlashStringHelper*'

exit status 1
no matching function for call to 'DFRobot_SIM808::getLocation(const __FlashStringHelper&, float&, float&)'

PaulS: To indicate that the type is pointer to whatever the type in front of the * is. Use your keyboard. 8)

The function you posted the prototype for takes 3 arguments. The first is a string in flash memory. The second and third are addresses where the function is to write some data.

   float lat, lon;
   if(robbieTheRobot.getLocation(F("SomeName"), &lat, &lon))
   {
   }

All string literals are stored in flash memory by the compiler. By default, they are copied to SRAM. For literals, that will never change, that is a waste of SRAM. So, the F() macro tells the compiler not to copy the literal to SRAM. But, since functions normally expect strings to be in SRAM, something needs to tell the function that the data is in flash memory, not SRAM. That is what a __FlashStringHelper does.

Thanks mate! Your answer shed a bit of light on my confusions. :D ..

apn is a pointer that points to nothing. The called function expects a pointer that points to memory that it can read from.

longitude is a pointer that points nowhere. The called function expects a pointer that points to memory that it can write to.

Same with latitude.

Look at my example.

PaulS: apn is a pointer that points to nothing. The called function expects a pointer that points to memory that it can read from.

longitude is a pointer that points nowhere. The called function expects a pointer that points to memory that it can write to.

Same with latitude.

Look at my example.

I tried your example. It had no errors while compiling! THANKS SO MUCH! :)