I am receiving some feedback on the serial port from a modem, it is six lines in total. To facilitate the decoding process, I'd like to break it into 6 distinct string variables instead of just one. Is there an easy way of doing this?
The code sending a command and then receiving a multi-line response:
void atsendbasic(String command, int fallout3, int fallout4){
unsigned long initialtime4 = millis();
Serial2.print(command);
Serial2.flush(); // Wait until it is all sent
while ((!Serial2.available() && millis() - initialtime4 <= fallout3) || millis() - initialtime4 <= fallout4) continue;
while ((Serial2.available()&& millis() - initialtime4 <= fallout3) || millis() - initialtime4 <= fallout4) {
char feedback = Serial2.read();
Serial.print(feedback);
}
}
what I am reading on the serial monitor:
15:45:17.907 -> AT+QMTPUBEX=1,0,0,0,"motorbeta/heartbeat","{"pulse":1,"secondary":2}"
15:45:17.907 -> OK
15:45:17.907 ->
15:45:17.907 -> +QMTPUB: 1,0,0
15:45:17.907 ->
15:45:17.907 -> +QMTRECV: 1,0,"motorbeta/shutdown","shutdown=1"
So with this approach ideally:
variable1 = AT+QMTPUBEX=1,0,0,0,"motorbeta/heartbeat","{"pulse":1,"secondary":2}"
variable2 = OK
variable3 =
variable4 = +QMTPUB: 1,0,0
variable5 =
variable6 = +QMTRECV: 1,0,"motorbeta/shutdown","shutdown=1"