how to change the Variable from input?

  arduino-c++, c++
#define RXD 16
#define TXD 17
#include <stdio.h>   /* Standard input/output definitions */
#include <string.h>  /* String function definitions */
#include <unistd.h>  /* UNIX standard function definitions */
#include <fcntl.h>   /* File control definitions */

//PROTOCOL SYNTAX
const String PREFIX_REQUEST = "#"; //Symbol(s) beginning a query
const String PREFIX_ANSWER = "[email protected]"; //Symbol(s) beginning an answer
const String APPENDIX_QUESTION = "?"; //Symbol(s) following a query
const String APPENDIX_ANSWER = ""; //Symbol(s) following a query
const String READY_MESSAGE = "READY"; //Message sent after boot
const String ERROR_MESSAGE = "unknown command"; //Message sent for unknown query
const int WAIT_TIME = 120;  //time between answers sent //multiples of 60 work best

//SYSTEM PARAMETERS
const String VERSION = "2.0";
//going to be changed
//PARAMETER ROOMNAME
String roomname_short; //Roomname alias //maximum 8 characters
String roomname; //Roomname full for display on UI

//QUERYS
//uppercase characters and hyphens
//no spaces
//minimum 3 characters
//phrase "INTERNAL"
//Commands using in Hercules

const String COMMAND_ROOMNAME = "ROOMNAME";
const String COMMAND_ROOMNAME_SHORT = "ROOMNAME-SHORT";

void setup() {
  Serial2.begin(9600, SERIAL_8N1, RXD, TXD);
  Serial.begin(115200);
  //Serial2.write("A");
  while(!Serial);
  Serial2.println((READY_MESSAGE));
  Serial.println(READY_MESSAGE);
  }

void loop() {
  String readString;
  while (Serial2.available()) {
    char c = (char)Serial2.read(); //gets  one byte from serial buffer
    if(roomname == " "){
    }else if (topicMatching(readString, COMMAND_ROOMNAME)) {
      sendAnswer(COMMAND_ROOMNAME_SHORT + " " + roomname);
      }
    else {
      sendAnswer(ERROR_MESSAGE);
    }
  }
}

  if (Serial2.available()) {          // got anything from Linux?
    char c = (char)Serial2.read();    // read from Linux
    Serial.write(c);                  // write to USB-serial
  }
}
bool topicMatching(String question, String command) {
  return question == PREFIX_REQUEST + command + APPENDIX_QUESTION;
}

void sendAnswer(String message) {
  Serial2.println(PREFIX_ANSWER + message);
  delay(WAIT_TIME);
}

void roomconfig(){
  Serial2.readString();
  sendAnswer(COMMAND_ROOMNAME_SHORT + roomname);
  sendAnswer(COMMAND_ROOMNAME_SHORT + " " + roomname_short);
}

I have some written code here and I only want to know how is it possible to change my roomname. I want to write via TCP Client with commands into it. So it´s declared as String and I want to change it by typing a new String for it.

I think nobody is knowing the Program Hercules SETUP utility. I configured an esp32 and write compile into it this Code but now I want to change for example the roomname not in Code rather in Hercules TCP client.

Should be something like ##ROOMNAME (this is the command) and after then the String which I want to have

Source: Windows Questions C++

LEAVE A COMMENT