Dear together,
in Arduino IDE i want check if the network and cloud connection established.
Could you please tell me how i can realize that.
Best Regards
Marcel
Dear together,
in Arduino IDE i want check if the network and cloud connection established.
Could you please tell me how i can realize that.
Best Regards
Marcel
Hello @starlight1986,
There is a command that allows you print the status of the connection, it is documented here: http://docs.thinger.io/arduino/#coding-enabling-debug-output
Bascialy you only have to put #define _DEBUG_
before including Thigner.io library and open a Serial port to start showing all the connection trace.
Hope it helps!
Hey jtrinc26,
thanks for your support. I want to get the status of the Network and/or Thinger-Server connection to check with an if request in the code.
Finaly depends on connection i wanna turn on/off a led, to see what happend.
Do you’ve a solution for that?
Regards Marcel
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;
}
Es necesario el uso de algun librería adicional? Compilando el codigo me muestra un error en la linea donde se utiliza thinger_state_listener. La unica diferencia que estoy utilizando un arduino yun para ejecutar esto.
No, you just have to include this in your sketch instead of common thinger.io object definition
best
Hi, how do you rewrite your code to esp32?
I have to be sure that I have a connection with thinger and then add data to the bucket, otherwise I will save it in the SPIFFs file.
The device is turned off and on using the Adafruit TPL5110 Power Timer.