How to change variabel value without re-programming ESP32?

i want to changing const char *ssid, const char *password, conts char *ClientID without re-programming or re-upload. I'm using ESP32 Devkit V1. Anyone can help me?

#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>
#include <WiFi.h>
#include <PubSubClient.h>
#include <ArduinoJson.h>
//int rssi;
int scanTime = 1; 
BLEScan* pBLEScan;
hw_timer_t * timer = NULL;
int counter = 0;  

//WiFi
const char *ssid = "mywifi"; 
const char *password = "mypassword";  

//MQTT Broker
const char *mqtt_broker = "192.168.6.56";
const char *topic = "test";
const int mqtt_port = 1883;
const char* ClientID = "0002";
WiFiClient espClient;
PubSubClient client(espClient);

//JSON
StaticJsonDocument<256> doc;

void reconnect() {
  // Loop until we're reconnected
 while (!client.connected()) {
   Serial.print("Attempting MQTT connection...");
   // Attempt to connect
     if (client.connect(ClientID)) {
         Serial.println("connected");
     } else 
     {
         Serial.print("failed, rc=");
         Serial.print(client.state());
         Serial.println(" try again in 5 seconds");
         // Wait 5 seconds before retrying
        delay(5000);
     }
 }
}

class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
    void onResult(BLEAdvertisedDevice advertisedDevice){
    doc["node"] = ClientID;
    doc["mac"] = advertisedDevice.getAddress().toString();
    doc["rssi"] = advertisedDevice.getRSSI();
    delay (500);
    char buffer[256];
    serializeJson(doc, buffer);
    client.publish("test",buffer);
    Serial.print("published value: ");
    Serial.println(buffer);

    if (WiFi.status() != WL_CONNECTED) {
      delay(500);
      WiFi.disconnect();
      WiFi.reconnect();  
    }
     if (!client.connected()) {
    reconnect();
    }
    }
};
void IRAM_ATTR onTimer(){
  counter +=1; 
  if(counter==3){ 
  pBLEScan->clearResults();
  counter =0;
  }
}
void setup() {
  Serial.begin(115200);
  Serial.println("Scanning...");

  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
  delay(500);
  Serial.println("Connecting to WiFi..");
  }
  Serial.println("Connected "); 
  Serial.println(WiFi.localIP()); 
  client.setServer(mqtt_broker, mqtt_port);
  reconnect();
  BLEDevice::init("");
  pBLEScan = BLEDevice::getScan();  
  pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks()); 
  pBLEScan->setActiveScan(true);  
  pBLEScan->setInterval(100);
  pBLEScan->setWindow(99);  
  timer = timerBegin(0, 80, true);
  timerAttachInterrupt(timer, &onTimer, true);
  timerAlarmWrite(timer, 1000000, true);
  timerAlarmEnable(timer);
}

void loop() {
 BLEScanResults foundDevices = pBLEScan->start(0);
 client.loop();
delay(1000);
}

Hello renaldyks
Design a HMI using a display and rotary switch.
Have a nice day and enjoy coding in C++.

You can't. You'll at least have to reprogram the device with for instance the modifications to the code that @paulpaulson suggests.
There is no way except for reprogramming the device to change what's already in there.

I looked at the WiFi Manager project. They can change ssid and password without reprogramming

Sure. You'll have to modify your code to include the WIFi Manager stuff, and then reprogram your board with that new code.

In conclusion, create your own library? oh lazy :smiley:

Huh? No. I didn't suggest that at all. Not sure where you got this from.

Ok, just answer this question: do you have the ability to reprogram this device, if only for once so you can change the current software in it, or is there no way anymore to gain access to it and reprogram it?

The last option is to reprogram the library. But I wish there was an easier way so it wouldn't be a waste of time.

If the solution does not exist. Then I'll probably wait for another answer.

If still not there. I will do the last option :smiling_face_with_tear:

Sounds like it's going to be the 'last option' then. Good luck!