I’m using PlaformIO and ESP32.
I have this error when I try to compile:
error: jump to case label [-fpermissive]
case WStype_TEXT:
I’ve checked and the value of WStype_TEXT is ‘3’ so, the previous cases are ‘1’ and ‘2’
this is the full void:
void webSocketEvent(byte num, WStype_t type, uint8_t * payload, size_t length){
switch (type) {
case WStype_DISCONNECTED: // if a client is disconnected, then type == WStype_DISCONNECTED (1)
break;
case WStype_CONNECTED: // if a client is connected, then type == WStype_CONNECTED (2)
sendJson("Type_AC",String(SelfCont));
uint8_t typFan = 0;
if(PWM_Dig == true) {
if(Rel_Modb==false) {
typFan = 1;
}else {
typFan = 2; // if PWM type => 0 if Relay +. 1, if Modbus => 2
}
}
sendJson("Type-Fan",String(typFan));
sendJson("On_Off", String(StatusONOFF));
sendJson("Order_Sensor",String(SensOrd));
sendJson("Def_temp",String(SetDef));
sendJson("Txt",Txt);
break;
case WStype_TEXT: // if a client has sent data, then type == WStype_TEXT (3)
// try to decipher the JSON string received
StaticJsonDocument<200> doc;
DeserializationError error = deserializeJson(doc, payload);
if (error) {
Serial.print(F("deserializeJson() failed: "));
Serial.println(error.f_str());
return;
}
else {
// JSON string was received correctly, so information can be retrieved:
const char* l_type = doc["type"];
const int l_value = doc["value"];
Serial.println("Type: " + String(l_type));
Serial.println("Value: " + String(l_value));
sendJson(String(l_type),String(l_value));//update other connected phones
if(String(l_type)=="Type_AC") {
SelfCont=l_value;
}
else if(String(l_type)=="Type-Fan"){
PWM_Dig=true;
if(l_value > 0) {
PWM_Dig= false;
if(l_value == 1) Rel_Modb = true; else Rel_Modb=false;
}
}
else if(String(l_type)=="On_Offv") {
StatusONOFF=l_value;
}
else if(String(l_type)=="Order_Sensor") {
SensOrd=l_value;
}
else if(String(l_type)=="Def_temp"){
SetDef=l_value;
}
if(String(l_type)=="Txt"){
Txt=l_value;
}
}
break;
}
}
PlatformIO give me the error on: case WStype_TEXT:
I have also a warning saying: StaticJsonDocument<200> doc; is decrepitated, is someone know another way to define the size of the Json container and it’s size?
Thank you for your help.
compile a program, communicate between ESP32 and phone
Michel Royer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.