Hi guys ,
i have problem with esp32 , i receive ssid and password value through serial bluetooth as string value
and i successfully save the values in EEPROM but i have problem when i try to use values to connect to wifi , i think i have to convert values from string to char but i dont know how ...
this is the code i use and i attache screen shot to Err i faced on ide
#include "BluetoothSerial.h"
#include <WiFi.h>
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
BluetoothSerial SerialBT;
#include "EEPROM.h"
int addr = 0;
int addr1 = 20;
#define EEPROM_SIZE 64
String ssid ;
String password ;
void setup() {
Serial.begin(115200);
ssid = EEPROM.read(addr) ;
password = EEPROM.read(addr1) ;
WiFi.begin(ssid, password);
SerialBT.begin("JD0001");
if (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.println("WIFI NOT CONNACTED..");
}else(){
Serial.print(">>>>>>>>>>>>>WIFI OK<<<<<<<<<<<")
}
if (!EEPROM.begin(EEPROM_SIZE))
{
Serial.println("failed to initialise EEPROM"); delay(1000000);
}
Serial.print("ssid : ");
Serial.println(ssid);
Serial.print("password : ");
Serial.println(password);
}
void loop() {
String x=SerialBT.readString();
if(x=="a"){
state1:
if(SerialBT.available()>0){
ssid=SerialBT.readString();
EEPROM.writeString(addr, ssid);
EEPROM.commit();
Serial.print("ssid is : ");
Serial.println(EEPROM.readString(addr));
}else{goto state1;}
}
if(x=="b"){
state2:
if(SerialBT.available()>0){
password=SerialBT.readString();
EEPROM.writeString(addr1, password);
EEPROM.commit();
Serial.print("password is : ");
Serial.println(EEPROM.readString(addr1));
}else{goto state2;}
}
}