Hi, the current solution relies on overriding a function defined in ThingerClient called thinger_state_listener, that provides information about any state inside thinger, like network connecting, thinger.io connection, etc.
Thus, you can extend your own class to provide such functionality, i.e., replace your thing definition (supposing you are using a ESP8266) with:
class ClientListener : public ThingerESP8266{
public:
ClientListener(const char* user, const char* device, const char* device_credential) :
ThingerESP8266(user, device, device_credential){}
protected:
virtual void thinger_state_listener(THINGER_STATE state){
// call current implementation (debug)
ThingerESP8266::thinger_state_listener(state);
switch(state){
case THINGER_AUTHENTICATED:
// turn on your led
break;
default:
// turn off your led
break;
}
}
};
ClientListener thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
If you want to do something more advanced, for example, blink your led while connecting to the network, here you have all possible states:
switch(state){
case NETWORK_CONNECTING:
break;
case NETWORK_CONNECTED:
break;
case NETWORK_CONNECT_ERROR:
break;
case SOCKET_CONNECTING:
break;
case SOCKET_CONNECTED:
break;
case SOCKET_CONNECTION_ERROR:
break;
case SOCKET_DISCONNECTED:
break;
case SOCKET_TIMEOUT:
break;
case THINGER_AUTHENTICATING:
break;
case THINGER_AUTHENTICATED:
break;
case THINGER_AUTH_FAILED:
break;
case THINGER_STOP_REQUEST:
break;
}