Problem with streaming Gcode via tx/rx from device to GRBL running on Nano

That function unilaterally returns after sending "G30" so you never transmit "M2" or "%"

In your getReplyFromGRBL() function, you should initialize your grbl_error to an empty string since you just start concatenating to it in your error code. Or better yet, there is no need to build up a String just to print it out. Just do it char by char.

    if (grbl_reply.indexOf("error:") >= 0) {
      while (Serial1.available()) {
        Serial.write(Serial1.read());
      }
      // Serial.println(grbl_error);
      grblReportError();
      return -1;
...