#include #define blue Serial3 // bluetooth unit on tx3/rx3 uint8_t blueBuffer[1024]; char encoded[16]; // encoded string output by base64 int inputLen; int inputLenA; // length of input string for decoding last bytes int encodedLenA; char input[12]; // input string for encoding int blueSpeed; // speed of UART 460800 long i; byte lang = 0; bool sendMidiFile = false; void setup() { pinMode(19,INPUT); // does not work with/without this Serial.begin(460800); blueSpeed = 230400; blue.begin(blueSpeed); delay(5); blue.attachCts(19); Serial.println("waiting for send"); while (!blue.available()) {} // wait for handler int data = blue.read(); if (data == 83) { Serial.println("sending"); unsigned long timer = millis(); // encodeMidiFile(); //if connected to bluetooth device encode the file for transmission and send sendFile(); timer = millis() - timer; Serial.print("stop sending at "); Serial.println(timer); } } void loop() { // put your main code here, to run repeatedly: } void sendFile() { byte o = 0; long byteCount1 = 40000; Serial.print("raw file length "); Serial.println(byteCount1); for (i = 0; i < byteCount1; i++) { blue.write(o); o++; if(o>100)o=0; delayMicroseconds(100); } blue.flush(); blue.write(126); // end of message blue.flush(); }