[SOLVED] ESP8266 as Time-Multiplexed Server / Client
Posted: Sun Sep 17, 2017 3:48 am
Hello guys,
I'm aware that this subject was already widely discussed here on this forum, but I was not able to find any working template. So, to make things simpler, I thought about using the libraries already available and instead of concurrently accessing both features (Client / Server), I was just trying to allocate each one at a specific time, but it is not working .
The fact is that when I experiment with client or server functionality separately, it works well, but when I put it all together, it does not.
Here's a snippet of code:
The concept behind of what I wish:
Anyone could give some insigh on how to deal with that ?
I'm aware that this subject was already widely discussed here on this forum, but I was not able to find any working template. So, to make things simpler, I thought about using the libraries already available and instead of concurrently accessing both features (Client / Server), I was just trying to allocate each one at a specific time, but it is not working .
The fact is that when I experiment with client or server functionality separately, it works well, but when I put it all together, it does not.
Here's a snippet of code:
Code: Select all
#include <ThingSpeak.h> // Client library
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h> // Server library
....stuffs
WiFiClient client;
setup()
{
....stuffs
ESP8266WebServer server(80);
server.begin();
ThingSpeak.begin(client);
....stuffs
}
loop()
{
if ( ELAPSED_LONG_TIME )
{
....stuffs
server.stop();
ThingSpeak.begin(client);
Serial.println ( String( ThingSpeak.readIntField( testChannelNumber , 1, testChannelReadAPIKey ) ) ) ; // read last value stored in cloud
server.begin();
....stuffs
}
}
The concept behind of what I wish:
Anyone could give some insigh on how to deal with that ?