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

Moderator: igrr

User avatar
By andre_teprom
#70083 Hi rudy,

You are absolutelly right, the picture presented before do not depits the communication flow as it is.
Prease refer to the following picture, and see the Arduino configuration which allows each link.

In shorts; by not-configuring Gateway in code, remote access works, whereas by explicitly configuring gateway, only local access works:

ARQUITETURA.png


My question is: How could I disable gateway diring program execution ?
You do not have the required permissions to view the files attached to this post.
User avatar
By rudy
#70085 I'm still not sure if I understand correctly but what I think you want to do is to stop the client on the ESPs. In order to do that look at the following. The first and the last line are what I think you want. Start the client and after you are done end the client.


Code: Select all  if (client.connect(server, 80)) {

    client.print("POST /update HTTP/1.1\n");
    client.print("Host: api.thingspeak.com\n");
    client.print("Connection: close\n");
    client.print("X-THINGSPEAKAPIKEY: " + writeAPIKey + "\n");
    client.print("Content-Type: application/x-www-form-urlencoded\n");
    client.print("Content-Length: ");
    client.print(body.length());
    client.print("\n\n");
    client.print(body);
    client.print("\n\n");
  }
  client.stop();


Connect to the remote server, do your business, stop/end the connection to the server.

Code: Select all  if (client.connect(server, 80)) {

    your code here
  }
  client.stop();


See http://forum.arduino.cc/index.php?topic=245829.0#1
User avatar
By gdsports
#70088 I do not understand the newer diagram. The program only needs to connect the AP once but the latest diagram indicates it connects using static IP for http server then connects using DHCP for http client. If the http client cannot connect to the Internet when using static IP, the gateway or subnet parameters are wrong. Or worse, another device is using the same IP address on the network.

Most wifi routers have a feature to assign an IP address to a MAC address. Use this so the ESP uses DHCP but always get the same IP address. This is much simpler than using static IP because it eliminates worries about using the same IP address for two devices. And since the router provides the gateway and subnet parameters, these are always correct.
User avatar
By andre_teprom
#70090
gdsports wrote:the latest diagram indicates it connects using static IP for http server then connects using DHCP for http client. If the http client cannot connect to the Internet when using static IP, the gateway or subnet parameters are wrong.


@gdsports,
For both scenarios I had configured static IPs for all ESP8266 devices, each one having its sufix shifted by '1' ( e.g 192.168.n.i+[1...10] ). The router is configured so that assigns low IPs for each incomming DHCP connection. By the way, the router is dedicated for that, so there is no risk of another application intrude on this network.

I was able to connect each ESP8266 either to the remote server, as well to the local clients with their static IPs, therefore I'm not sure if I got exactly what you meant. On this case, should I keep the Gateway configuration, but by using "correct" values ?

I'm using the following configuration:
Code: Select allIPAddress   subnet      (255,255,255,0)                 ;
IPAddress   net         (192,168, 1, 211)      ;  // varies from 211 up to 220
IPAddress   gateway     (192,168, 1 ,0)              ;
/// IPAddress   dns         (8,8, 8 ,8)            ;



rudy wrote:I think you want to do is to stop the client on the ESPs.


@rudy,
Regardless from this step, the main issue is at some layer bellow of the communication stack, in the IP settings. In fact, once solving the gateway issue, I will run client and server one at a time, at least on the initial stage of the project.