Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By andre_teprom
#70041 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:

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:

ARQUITETURA.png


Anyone could give some insigh on how to deal with that ?
You do not have the required permissions to view the files attached to this post.
Last edited by andre_teprom on Mon Sep 18, 2017 6:04 pm, edited 1 time in total.
User avatar
By andre_teprom
#70068 Hi there, I'm almost there !
After rewriting the code by using common libraries, I finally was able to run either client and server instancies at the same code, HOWEVER there is a little problem.

When I made tests with the part of the code which enable aceess to local clients, it works only if at the Wifi connecting stage I do this:
Code: Select all  WiFi.begin  ( ssid , password )           ;
  WiFi.config ( net , gateway , subnet )    ;

But in order to grant access to remote server ( I mean, board acting as client ), I need to re-compile the code, but now ommiting the gateway/subnet configuration:
Code: Select all  WiFi.begin  ( ssid , password )  // ommiting further gateway/subnet configuration        ;

That´s what I'm meaning:
ARQUITETURA.png

The new arosed question is:

    How can I disable Gateway runtime ?
You do not have the required permissions to view the files attached to this post.
User avatar
By rudy
#70076 I have read your posts here a number of time. I either misunderstand what you are trying to do or you misunderstand how things can work. Maybe both.

As the other poster had said, you can have your application run a server and a client at the same time.

And here is the part that I really don't understand.

Code: Select all  WiFi.begin  ( ssid , password )           ;
  WiFi.config ( net , gateway , subnet )    ;


Why are you trying to change your connection to the router? Are you using a second router that you have omitted in your pictures? Otherwise it doesn't make any sense to me. You have one router that the ESPs connect to in order to gain access to the internet and then you have a second router, with a different SSID/password, that you use to provide local access to the local user.