Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is not possible thinger.io + WebSocketsServer.h #17

Open
vicen-t opened this issue Mar 15, 2018 · 2 comments
Open

Is not possible thinger.io + WebSocketsServer.h #17

vicen-t opened this issue Mar 15, 2018 · 2 comments

Comments

@vicen-t
Copy link

vicen-t commented Mar 15, 2018

Hi.

My project uses websockets. Everything is fine until I insert in the main loop ()
"thing.handle()". Right next comes the call to the socket loop.

Then the loop function of the socket stops working or it does erratically.

There's a solution?

@alvarolb
Copy link
Member

Hi @vicen-t, I would require more information about the lib you are using and how you plan to integrate thinger.io with it.

Jus to know, why do you require to handle web sockets on the device? You can open web sockets over a thinger device, and query stream any resource at the frequency you want.

Best.

@vicen-t
Copy link
Author

vicen-t commented Mar 16, 2018

Hola Álvaro.

My project is composed of several esp8266 (nodemcu board) located in some rooms of my house. Every esp has a DHT22, and some of them are also connected to a relay or a TIP120 transistor for controlling led lights.

One ESP collects data from other ESP and take decisions. This ESP has a RTC clock and a HC-05 BT and is connected to de wifi/Internet. This ESP is acting as the "server". I can connect with it in a normal port (not websocket) and send orders with any mobile device.

All the ESP communicate using ESP-NOW, but some days ago the protocol stop working without reason. The project was connected to thinger.io over 6 month ago without problems, very solid.

After ESP-NOW collapse, I replaced it with a new own protocol based on websockets and json. The clients send own states to the server and the server send orders based on own decisions or on orders received via normal port throught mobile devices (man decisions).

Everything was good until I re-insert the module thinger.io. I planned to use thinger.io for displaying data over internet and provides a method for sending orders to the server over internet, extending the project outside my house.

Ok, it is a complex project ;)

This is a summary of the server sketch (I dont have access just now to the original code)

#include <WebSocketsServer.h>
#include <ThingerESP8266.h>

...
ThingerESP8266 thing(usuario, device_Id, device_credentials);
WebSocketsServer SOCKET = WebSocketsServer(9999);

...
SOCKET.begin();
SOCKET.onEvent(callbackfunc);   
...
// I dont pass wifi parameters to thing object
// I will connect with my own methods later:    **BOTH AP and STATION**
//thing.add_wifi(WiFi_ssid, WiFi_password);

void loop() {
  SOCKET.loop();
  thing.handle();  // When I insert this line the SOCKET object stop working or work erratically
}

Gracias por tu amabilidad, Álvaro.

Saludos!

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

No branches or pull requests

2 participants