Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Missing default case in switch causes #10

Closed
jenschr opened this issue Sep 13, 2022 · 3 comments
Closed

Missing default case in switch causes #10

jenschr opened this issue Sep 13, 2022 · 3 comments

Comments

@jenschr
Copy link

jenschr commented Sep 13, 2022

Describe the bug

In the example file "FullyFeatured_ESP32.ino", the Switch case does not have a "default" to catch anything not handled.

Steps to Reproduce

Compile example "FullyFeatured_ESP32.ino" in Arduino IDE with board set to "Adafruit Feather ESP32-S2".

Expected behavior

Expected the file to compile without errors

Actual behavior

Error compiling....

Solution

Just add a default case for the WiFiEvent(WiFiEvent_t event) method outside the "if" so that both versions has a default so you don't hqve to handle all possible cases:

default: break;

Information

Arduino IDE version: 1.8.19
ESP32 Core Version 2.0.4
OS: OSX 11.6

Context:
Trying to make the basic example compile

Additional context

Relevant error message:

/Users/jensa/Documents/Arduino/FullyFeatured_ESP32/FullyFeatured_ESP32.ino: In function 'void WiFiEvent(arduino_event_id_t)':
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WIFI_SCAN_DONE' not handled in switch [-Werror=switch]
   switch (event)
          ^
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WIFI_STA_STOP' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WIFI_AP_START' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WIFI_AP_STOP' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WIFI_AP_STACONNECTED' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WIFI_AP_STADISCONNECTED' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WIFI_AP_GOT_IP6' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WIFI_FTM_REPORT' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_ETH_START' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_ETH_STOP' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_ETH_CONNECTED' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_ETH_DISCONNECTED' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_ETH_GOT_IP' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_ETH_GOT_IP6' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WPS_ER_SUCCESS' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WPS_ER_FAILED' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WPS_ER_TIMEOUT' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WPS_ER_PIN' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WPS_ER_PBC_OVERLAP' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_SC_SCAN_DONE' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_SC_FOUND_CHANNEL' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_SC_GOT_SSID_PSWD' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_SC_SEND_ACK_DONE' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_PROV_INIT' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_PROV_DEINIT' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_PROV_START' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_PROV_END' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_PROV_CRED_RECV' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_PROV_CRED_FAIL' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_PROV_CRED_SUCCESS' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_MAX' not handled in switch [-Werror=switch]
cc1plus: some warnings being treated as errors
Multiple libraries were found for "WiFi.h"
 Used: /Users/jensa/Library/Arduino15/packages/esp32/hardware/esp32/2.0.4/libraries/WiFi
 Not used: /Applications/Arduino.app/Contents/Java/libraries/WiFi
Using library WiFi at version 2.0.0 in folder: /Users/jensa/Library/Arduino15/packages/esp32/hardware/esp32/2.0.4/libraries/WiFi 
Using library AsyncMQTT_Generic at version 1.6.1 in folder: /Users/jensa/Documents/Arduino/libraries/AsyncMQTT_Generic 
Using library AsyncTCP at version 1.1.1 in folder: /Users/jensa/Documents/Arduino/libraries/AsyncTCP 
exit status 1
enumeration value 'ARDUINO_EVENT_WIFI_SCAN_DONE' not handled in switch [-Werror=switch]
@khoih-prog
Copy link
Owner

HI @jenschr

Thanks for the bug report, which is caused by recently aggressive behaviour of the compiler settings.

While I'll fix the issue very soon, you can test normally by temporarily setting, if using Arduino IDE, Preferences->Compiler Warnings to Default, instead of All or More

@jenschr
Copy link
Author

jenschr commented Sep 13, 2022

Yeah. I hacked around it, but wanted to be sure you knew about this issue. I'm looking through many MQTT libs for my students tonight and there sure is a lot of them that does not compile right now :)

khoih-prog added a commit that referenced this issue Sep 14, 2022
### Releases v1.7.0

1. Fix ESP32 compile error. Check [Missing default case in switch causes #10](#10)
2. Change to new [Forked ESPAsyncTCP library](https://github.com/khoih-prog/ESPAsyncTCP) for ESP8266 boards, using WiFi or LwIP Ethernet, with [ESP8266 core v3.0.2+](https://github.com/esp8266/Arduino/releases/tag/3.0.2) or WiFi with [ESP8266 core v2.7.4](https://github.com/esp8266/Arduino/releases/tag/2.7.4) to avoid compile errors
khoih-prog added a commit that referenced this issue Sep 14, 2022
### Releases v1.7.0

1. Fix ESP32 compile error. Check [Missing default case in switch causes #10](#10)
2. Change to new [Forked ESPAsyncTCP library](https://github.com/khoih-prog/ESPAsyncTCP) for ESP8266 boards, using WiFi or LwIP Ethernet, with [ESP8266 core v3.0.2+](https://github.com/esp8266/Arduino/releases/tag/3.0.2) or WiFi with [ESP8266 core v2.7.4](https://github.com/esp8266/Arduino/releases/tag/2.7.4) to avoid compile errors
khoih-prog added a commit that referenced this issue Sep 14, 2022
### Releases v1.7.0

1. Fix ESP32 compile error. Check [Missing default case in switch causes #10](#10)
2. Change to new [Forked ESPAsyncTCP library](https://github.com/khoih-prog/ESPAsyncTCP) for ESP8266 boards, using WiFi or LwIP Ethernet, with [ESP8266 core v3.0.2+](https://github.com/esp8266/Arduino/releases/tag/3.0.2) or WiFi with [ESP8266 core v2.7.4](https://github.com/esp8266/Arduino/releases/tag/2.7.4) to avoid compile errors
@khoih-prog
Copy link
Owner

Hi @jenschr

The new AsyncMQTT_Generic releases v1.7.0 has just been published. Your contribution is noted in Contributions and Thanks

Best Regards,


Releases v1.7.0

  1. Fix ESP32 compile error. Check Missing default case in switch causes #10
  2. Change to new Forked ESPAsyncTCP library for ESP8266 boards, using WiFi or LwIP Ethernet, with ESP8266 core v3.0.2+ or WiFi with ESP8266 core v2.7.4 to avoid compile errors

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants