Is there any function that checks if there was pairing
android -> bluetooth hc 05
if there is no link then it will not send this file
and can it be done on the application side so that it will receive as a file and not individual lines of this file?
because I'm going to make a phone app, but for now I've used a serial monitor to test
sd_file = SD.open("data.txt", FILE_READ);
if (sd_file) {
Serial.println("data.txt:");
while (sd_file.available()) {
Serial.write(sd_file.read());
} sd_file.close();
} else {
Serial.println("error opening file");
}
Your code looks like it is from the DumpFile example in the IDE, which does that - dumps the whole file. If you want something more sophisticated, you may have to use one of the other SD libraries. Your post implies occasional auto-connection, so dumping the whole file is probably what you want, and DumpFile is all you need.
You may be able to make a phone app but I suspect it is going against the grain and, either way, it would surely be easier to do it at the Arduino end - at least as far as the actual dump operation is concerned. I think the worst that can happen is that you may have to configure the STATE pin mentioned above. This may depend on the module you have, I have heard that the pin follows the on-board LED. But I don't think it makes sense that it must, and it was probably just a coincidence.
Another option is to simply have Arduino listen for a filename and dump accordingly. There is nothing automatic about it, but absolves you from having to to do anything smart with Bluetooth, and you get to choose the file to be dumped, which might be useful.