Hi, I have coded the Thinger State listener like described at end of the coding guide:
But my compier throws a bench of warnings:
D:\Activities\3_Maker\ESP_SwissArmyKnife_Rev10_2024\c_Setup.ino: In lambda function:
D:\Activities\3_Maker\ESP_SwissArmyKnife_Rev10_2024\c_Setup.ino:123:12: warning: enumeration value 'NETWORK_CONNECTING' not handled in switch [-Wswitch]
123 | switch (thinger_state) {
| ^
D:\Activities\3_Maker\ESP_SwissArmyKnife_Rev10_2024\c_Setup.ino:123:12: warning: enumeration value 'NETWORK_CONNECTED' not handled in switch [-Wswitch]
D:\Activities\3_Maker\ESP_SwissArmyKnife_Rev10_2024\c_Setup.ino:123:12: warning: enumeration value 'NETWORK_CONNECT_ERROR' not handled in switch [-Wswitch]
D:\Activities\3_Maker\ESP_SwissArmyKnife_Rev10_2024\c_Setup.ino:123:12: warning: enumeration value 'SOCKET_CONNECTING' not handled in switch [-Wswitch]
D:\Activities\3_Maker\ESP_SwissArmyKnife_Rev10_2024\c_Setup.ino:123:12: warning: enumeration value 'SOCKET_CONNECTED' not handled in switch [-Wswitch]
D:\Activities\3_Maker\ESP_SwissArmyKnife_Rev10_2024\c_Setup.ino:123:12: warning: enumeration value 'SOCKET_CONNECTION_ERROR' not handled in switch [-Wswitch]
D:\Activities\3_Maker\ESP_SwissArmyKnife_Rev10_2024\c_Setup.ino:123:12: warning: enumeration value 'SOCKET_DISCONNECTED' not handled in switch [-Wswitch]
D:\Activities\3_Maker\ESP_SwissArmyKnife_Rev10_2024\c_Setup.ino:123:12: warning: enumeration value 'SOCKET_TIMEOUT' not handled in switch [-Wswitch]
D:\Activities\3_Maker\ESP_SwissArmyKnife_Rev10_2024\c_Setup.ino:123:12: warning: enumeration value 'SOCKET_ERROR' not handled in switch [-Wswitch]
D:\Activities\3_Maker\ESP_SwissArmyKnife_Rev10_2024\c_Setup.ino:123:12: warning: enumeration value 'THINGER_AUTHENTICATING' not handled in switch [-Wswitch]
D:\Activities\3_Maker\ESP_SwissArmyKnife_Rev10_2024\c_Setup.ino:123:12: warning: enumeration value 'THINGER_STOP_REQUEST' not handled in switch [-Wswitch]
My code is however directly derived from the coding guide:
thing.set_state_listener([&](ThingerClient::THINGER_STATE state) {
switch (state) {
case ThingerClient::THINGER_AUTH_FAILED:
Console1.print("\n***Thinger Auth Fail***");
GracePause = 64;
break;
case ThingerClient::NETWORK_CONNECTING:
case ThingerClient::NETWORK_CONNECT_ERROR:
case ThingerClient::SOCKET_CONNECTING:
case ThingerClient::SOCKET_CONNECTION_ERROR:
case ThingerClient::SOCKET_DISCONNECTED:
case ThingerClient::SOCKET_ERROR:
case ThingerClient::SOCKET_TIMEOUT:
case ThingerClient::THINGER_AUTHENTICATING:
case ThingerClient::THINGER_STOP_REQUEST:
Console1.print("\n***Network_Error***");
GracePause = 64;
break;
case ThingerClient::THINGER_AUTHENTICATED:
GracePause = 0;
break;
default:
break;
}
});
Has someone got a clue why the states are not handled in the switch?
By the way, defining a variable “state” is not a good idea, it may conflict with other libraries.
Calling it “thinger_state” were more unique and les prone to conflicts.