Bluetooth transfer problem with big files I want to send some data from an Arduino Mega to an android device via bluetooth (HC-06). I have installed some sensors whose values are frequently written in an SD card. Every time a new string line is added in a text file of the SD card. This is the format of the line

27/5/2015,11:55:00,34.00,27.00,42.50,26.80,47.80,26.00,24.62,24.12,26,0,0,708,1023,1023,1023,1023,10.5,10.5,10.5,10.5


and this is part of the code. I send from a bluetooth terminal the string "download" and after that the text file is opened and every line is readed and sent to the android device via bluetooth.

void loop(void){  
    while(Serial1.available()) {
       character = Serial1.read();
       content.concat(character);
     }

if (content == "download") {
    Serial.println(content);
    content = "";
    read_from_SD_Card();
    }
    ........................
    ........................
    ........................
}


void read_from_SD_Card(){
    myFile = SD.open("test.txt");
    if (myFile) {
        Serial1.println("test.txt:");

        while (myFile.available()) {
            Serial1.write(myFile.read());
      }
      myFile.close();
    } 
else {
  Serial1.println("error opening test.txt");
  }
}


The problems are:


the data are downloaded only after an upload of the sketch has been done. (I can't upload the sketch once and download the data from time to time) 
No more than 10-20 lines can be downloaded. With bigger files the downloading seems to slow down and finally stops after a few lines.


Any thoughts would be appreciated.
I suspect that this is a String class heap-fragementation issue (again). To test this you could sending a fixed string buffer (vector of characters, "Hello world" :). Do not use String and SD/FAT in the test. Just send a large number of lines with dummy data. 

If this works replace the String usage with a character buffer. Fill it from the SD file (buffer size at a time) and write to Serial. 

Cheers!