Convert Arduino Code to Mbed code

Great .
Now i try to add AT commands of GPS in the library to receive location by using GSM. is it necessary to define the process of GPS or just to put directly the AT commands .

im waiting for your response

I am not sure what do you exactly want.
If you want to test GPS commands then it is good to do this like I wrote few post above. Connect A9G directly to USB TTL and via PC Serial terminal just type AT commands and look reactions of the module.
How the result will be sufficient and you will understand how it works, then you can continue with developing of your library.

You probably need check AT+GPS? for state of GPS and if it is not set to 1 then send AT+GPS=1 and so on.

BR, Jan

my purpse is to create A9g library in mbed for receive Gpsdata by GSM then to define errors in code for example when terminal show error21 I have to now what is the error

Of course I understand you want make a A9G library, but I was not sure with

But before you can make a library you need to study how the module works for understand what you have to do, right?
So what is your progress, where are you stuck?

BR, Jan

Hello again what I want know is to receive GPS data (latitude, longitude) the At+GPSRD=1 (this commande used for send data) but how define it in code is my problem

hello i m waiting for your response

I waiting a code what you did according to example what I gave you 6 days ago. The process is still same, send AT command via Cmd Parser and wait for a response, process the response and so on.
When I will see you really did something, then I will help. But until now, I saw nothing from you only copy paste.
I’m happy to help but I’m not going to do school work for you or what is this. It is fair I think.

BR, Jan

hello sir i add this to library
A9G.cpp
int A9G::a9g_get_gps_info(float timeout){
bool result = true;
// set mode to text mode
int mode = 1;
_module.send(“AT+GPS=1”, mode);
if(_module.recv(“OK”)){
debug_if(DEBUG, “GPS is on\n”, mode);
} else {
debug_if(DEBUG, " failed!\n");
}

_module.set_timeout(10000);
_module.send("AT+CPSRD=1");
if(_module.recv(">")){
    debug_if(DEBUG, "GPS ON\n", mode); 
    _module.send("Gps info "); 
    
}
_module.set_timeout(1000);  
return result;

}

The command AT+CPSRD should be AT+GPSRB. The rest not makes sense, you rewrote only few rows from my function of sendSMS.

But for that you need

AT+LOCATION: Get positioin through LBS server(Ai-Thinker) or GPS
Command:
AT+LOCATION= value 1:get location info through LBS
                   2:get location by GPS(GPS should be open first by AT+GPS=1) 
return: <latitude>,<longitude> (uint:°) OK
Example of serial communication:

AT>AT+LOCATION=1

AT<22.608901,113.841279

AT<OK

BR, Jan

hello sir
this is the code that i progress

int A9G::get_positioin_through_LBS_server(float timeout) {
float longitude;
float latitude ;
float altitude;
bool result = true;
_module.send(“AT+GPS=1”);
if(_module.recv(“OK”)){
debug_if(DEBUG, “GPS is on\n”);
} else {
debug_if(DEBUG, " failed!\n");
}

_module.set_timeout(10000);
_module.send("AT+location=1");
if(_module.recv(">")){
    debug_if(DEBUG, "GPS ON\n"); 
    _module.send("" ,longitude); 
    _module.send("" ,latitude);
    _module.send("" ,altitude);
}
_module.set_timeout(1000); 
return result;

}Preformatted text

You not want to send anything to the module besides AT command and that you already did.
You need to set _module.recv(...) to be able to catch incoming values - <latitude>,<longitude>. It works similar like scanf function.

BR, Jan

ok understood

int A9G::get_positioin_through_LBS_server(float timeout) {
float longitude;
float latitude ;
float altitude;
bool result = true;
_module.send(“AT+GPS=1”);
if(_module.recv(“OK”)){
debug_if(DEBUG, “GPS is on\n”);
} else {
debug_if(DEBUG, " failed!\n");
}

_module.set_timeout(10000);
_module.send("AT+location=1");
if(_module.recv(">")){
    debug_if(DEBUG, "GPS ON\n"); 
    _module.recv("" ,longitude); 
    _module.recv("" ,latitude);
    _module.recv("" ,altitude);
}
_module.set_timeout(1000); 
return result;

Nope

It may be something like this probably

if(_module.recv("%f,%f",latitude, longitude)){
    debug_if(DEBUG, "latitude: %f, longitude: %f",latitude, longitude); 
}

BR, Jan

hello sir hope you’r doing well
this is the code sir

int A9G::get_positioin_through_LBS_server(float timeout) {
float longitude;
float latitude ; 
float altitude;
bool result = true;
    _module.send("AT+GPS=1");
    if(_module.recv("OK")){
        debug_if(DEBUG, "GPS is on\n");
    } else {
        debug_if(DEBUG, " failed!\n");
    }

    _module.set_timeout(10000);
    _module.send("AT+location=1");
    if(_module.recv("%f,%f",latitude, longitude)){
    debug_if(DEBUG, "latitude: %f, longitude: %f",latitude, longitude); 
}
    
    _module.set_timeout(1000); 
    return result;
   } 

HELLO SIR hope your doing well i’m waiting ur reply

Hello,

you wrote about you have the code and that was all. No question, no result (working /not working), so truly, I do not know what you want from me.
It’s been 26 days, so I suppose you made a good progress.

BR, Jan

Hello sir now i move to the nexxt part : Integration of mqtt protocol in libraray to recuperate the latitude and longitude of GPS

Hello sir do you have any information howe to use the mqtt client to recuperate GPS Data using the mosquitto server

Hello,

sorry I have no experiences with MQTT

BR, Jan