Fona gps 808

Hi everyone :slight_smile:
ive managed too use my fona breakout board,combined with arduino uno too upload gps co-ordinate data to ubidots, everything works fine, however, if i get a negative latitude or longitude number , it wont upload :

this is some of the code:

void senseValues()
{
value1 = latitude;
value2 = longitude;

////////////////////////////////////////////

sendDataUbidots(value1, id1);
sendDataUbidots(value2, id2);

/////////////////////////////////////////////

}

void sendDataUbidots(int value, char* myid)
{

uint16_t statuscode;
int16_t length;

char url1 = "things.ubidots.com/api/v1.6/variables/";
char* url2 = myid;
char url3 = "/values?token=";
char* url4 = token;
int lurl = strlen(url1) + strlen(url2) + strlen(url3) + strlen(url4);

char url[lurl];
sprintf(url,"%s%s%s%s",url1,url2,url3,url4);
// Serial.println(url);

char data1 = "{"value":";
char data2[get_int_len(value)+1];
char data3 = "}";
itoa(value,data2,10);
int ldata = strlen(data1) + strlen(data2) + strlen(data3);

char data[ldata];
sprintf(data,"%s%s%s",data1,data2,data3);
//Serial.println(data);

Serial.print(F("http://"));
Serial.println(url);
Serial.println(data);

Serial.println(F("****"));
if (!fona.HTTP_POST_start(url, F("application/json"), (uint8_t *) data, strlen(data), &statuscode, (uint16_t *)&length)) {
Serial.println("Failed!");

/////////////////////////////////////////////

so if value 1 or value 2 is negative it doesnt upload... ive tried to change the char to unsigned char and ive tried to change char to int, but it still wont upload...is there anything im missing or perhaps i need to change something else...i assume its my code, because ubibots does support negative numbers and i know char doesnt store this type..so im not sure how 2 go about this. i normally get negative latitude values in my area.

is there anything im missing

A whole bunch of code.

int ldata = strlen(data1) + strlen(data2) + strlen(data3);

char data[ldata];
sprintf(data,"%s%s%s",data1,data2,data3);

There is no room for the terminating NULL.

Hi PaulS
Thank you for the reply

i understand what your saying , im just really unsure how to do that :confused:
ive been trying for a while now and no luck. My understanding of code isnt that good yet.

Is there anyway you could please show me what to do ?

Is there anyway you could please show me what to do ?

About what? About not posting all of your code? That seems pretty obvious to me.

About not including room in the array for the terminating NULL?

int ldata = strlen(data1) + strlen(data2) + strlen(data3);

char data[ldata + 1];
sprintf(data,"%s%s%s",data1,data2,data3);

data2 is never assigned a value, so treating it as though it is a string is a mistake.

Hi, i’ve fona 808 i can connect to GSM all is working sms, location with gprs is also working but
GPS is not turning on i’m using the fonatest program and usin “O” (capital O ) as suggested to enable GPS module it tried to execute
" —> AT+CGPSPWR?
<— ERROR
"
so i’m getting this error i’m not sure if i’ve broken the board or there is some other issue.
I’ve to make it work asap any help would be great