AT COMMANDS and String

Hello guys, I have this AT Command which is AT+CMMSDOWN="PIC",size,time,"NAME".

So I do this in arduino.

Serial1.println("AT+CMMSDOWN=\"PIC\",7000,20000,\"image.jpg\"");

It works fine.

But the pictures that I get using the serial camera have different sizes. And so,
I tried this:

Serial1.println("AT+CMMSDOWN=\"PIC\"," + imgFile.size() + ",20000,\"image.jpg\"");

I get an error:

In function 'void loop()':
error: invalid operands of types 'const char*' and 'const char [18]' to binary 'operator+'

Please help me debug this.

\"," you forgot to escape the second ". you then repeat the error later in the same line.

Mark

Sir Mark, I don't get it. Please explain further. Thank you Sir.

  • is the addition operator. You can't ADD two strings.

No matter how much you'd like to think that add two strings means append one to the other, it does not.

Okay sir, but I still don't know how to fix it. Please help.

Okay sir, but I still don't know how to fix it. Please help.

It is NOT necessary to send the data using one function call. Use three. The device on the other end will NOT know.

Serial1.print("AT+CMMSDOWN=\"PIC\",");
Serial1.print(imgFile.size() );
Serial1.println(",20000,\"image.jpg\"");

PaulS:

Okay sir, but I still don't know how to fix it. Please help.

It is NOT necessary to send the data using one function call. Use three. The device on the other end will NOT know.

Serial1.print("AT+CMMSDOWN=\"PIC\",");

Serial1.print(imgFile.size() );
Serial1.println(",20000,"image.jpg"");

I tried what you said sir.

dataFile = SD.open("kris.jpg");
  dataFile.size();
  delay(10000);
  
   Serial1.print(("AT+CMMSDOWN=\"PIC\","));
   
  Serial1.print(dataFile.size());
  
  Serial1.print(",25000,\"kris.jpg\"");
  
  readSerial();
  delay(10000);
 

dataFile = SD.open("kris.jpg");

if (dataFile) {
    while (dataFile.available()) {
      Serial1.write(dataFile.read());
    }
    dataFile.close();
   
  }  
  // if the file isn't open, pop up an error:
  else {
    Serial.println("error opening kris.jpg");
  } 
  
   delay(20000);

but in the serial monitor. It shows this:

AT+CMMSDOWN="PIC",6477,25000,"kris.jpg"ÿØÿà

It should be like this:

AT+CMMSDOWN="PIC",6477,25000,"kris.jpg"

CONNECT

OK

Do you any idea sir why is it like that?

I tried what you said sir.

No,you didn't. print() and println() are NOT the same thing.

dataFile = SD.open("kris.jpg");

if (dataFile) {
    while (dataFile.available()) {
      Serial1.write(dataFile.read());
    }
    dataFile.close();

Why are you sending binary data to a text based viewer?

FIX :smiley:
Thank you Sir PaulS. You're a beast. :grin:

i am facing the same problem with AT+CMMSDOWN. The following command does not execute. Please help.

The following command does not execute.

Since we have no idea what your code looks like, or what "the following command" is, you are on your own.