hi my image doesn't encode to base64 completly.but counter work correctly and it encoded just until counter=58 instead of counter=126. but counter count.and from 58 until end don't encoded.
i try another image it do until 53...i dont know what is my problem...please help me.thanks
{ enc = SD.open("ESP/enc.txt", FILE_WRITE);
myFile = SD.open("ESP/16.jpg", FILE_READ);
int sizeOfMyFile = myFile.size();
Serial.println(sizeOfMyFile);
int quotient = sizeOfMyFile / 3;
Serial.println(quotient);
if (myFile)
{
if (enc) {
Serial.println("The File is Opened, And Please Show Data On Serial Port");
// read from the file until there's nothing else in it:
while (myFile.available())
{
if (quotient >= counter)
{ int lim=3;
String data;
byte input[lim];
for (int i = 0; i < lim; i++)
{
input[i] = myFile.read();
buffere += input[i];
}
int inputLen = sizeof(buffere);
int encodedLen = base64_enc_len(inputLen);
char encoded[encodedLen];
base64_encode(encoded, input, inputLen);
char sub[5];
strncpy(sub, encoded, 4);
sub[4] = '\0';
// Serial.println(sub);
data = sub;
Serial.println(data);
Serial.println("dakhele halghe quotient>counter");
// outFuncenc = forfuncencod(limit);
enc.print(data);
Serial.println("khoroojie tabe...");
Serial.println(outFuncenc);
counter++;
Serial.println(counter);
}
if (quotient < counter)
{
if (sizeOfMyFile % 3 == 1) {
Serial.println("dakhele halghe quotient<counter va limit=1");
limit = 1;
// forfuncencod(limit, connectionId,myFile);
// outFuncenc = forfuncencod(limit);
// outFuncenc += '=';
// outFuncenc += '=';
// enc.print(outFuncenc);
// espsend(outFuncenc, connectionId);
}
if (sizeOfMyFile % 3 == 2) {
Serial.println("dakhele halghe quotient<counter va limit=2");
limit = 2;
// forfuncencod(limit,connectionId,myFile);
// outFuncenc = forfuncencod(limit);
// outFuncenc += '=';
// enc.print(outFuncenc);
// espsend(outFuncenc, connectionId);
}
}
}
}
enc.close();
myFile.close();
// im = "\"alt=\"Red dot\" /></div>";
// espsend(im, connectionId);
Serial.println("finish");
}