Send data in packets of 20 bytes (GPS to iOS app via BLE)

Hi there,
I struggling to find a way of sending GPS coördinates with date/time to my iOS app for a tracker project. I'm using a Arduino Uno, Ublox GPS module and a UART Adafruit Bluefruit LE UART Friend. For coding I've started with the 'atcommand' example provided by Adafruit and the DeviceExample from TinyGPS+.

I've setup a characteristic and service for the GPS data and can successfully send up to 20 bytes of the GPS coördinates and receive it on the iOS app.. However the required bytes is longer than 20. The complete string could look like this: 40.7127837, -73.1233872 DateTime 23-10-2015 10:15:22.

I'm quit new in the amazing Arduino world so forgive any naivety.

Can you please help with some guidance? Of show example code to send data to BLE in packets?

Any help is much appreciated!

Here is a piece of the code where the GPS data is send via BLE:

  char longitude[12];
  char latitude[12];
  char dateMonth[3]
  char dateDay[3]
  char dateYear[5]
  char timeHour[3]
  char timeMinute[3];
  char timeSecond[3];
  char comma[2] = ",";
  char dash[2] = "-";
  char colon[2] = ":";
  static char datesep [11] = " DateTime ";
  
  //Serial.print(F("Location: ")); 
  if (gps.location.isValid() && gps.date.isValid())
  {
    bluefruitSS.listen();
    /* Command is sent when \n (\r) or println is called */
    /* AT+GATTCHAR=CharacteristicID,value */
    ble.print( F("AT+GATTCHAR=") );
    ble.print( hrmMeasureCharId );
    ble.print( F(",") );
    
    //Add GPS coordinates
    ble.print(dtostrf(gps.location.lat(),6,4, latitude)); 
    ble.print(comma);
    ble.print(dtostrf(gps.location.lng(),6,4, longitude));
    
    //Add Date/Time to GPS coordinates
    ble.print(datesep);
    ble.print(dtostrf(gps.date.month(),2,0, dateMonth));
    ble.print(dash);
    ble.print(dtostrf(gps.date.day(),2,0, dateMonth));
    ble.print(dash);
    ble.println(dtostrf(gps.date.year(),4,0, dateYear));

    /* Check if command executed OK */
    if ( !ble.waitForOK() )
    {
      Serial.println(F("Failed to get response for GPS!"));
    }

The complete string could look like this: 40.7127837, -73.1233872 DateTime 23-10-2015 10:15:22.

Why? My phone knows that time it is.

You could send "Lat 40.7127837", "Lon -73.1233872", "Date 23-10-2015", and "Time 10:15:22" in 4 packets.

Hi PaulsS, thanks for the quick reply. I can see I was looking for a too complex solution for something which can be solved much easier :slight_smile: