These are chat archives for esp8266/Arduino

17th
Aug 2017
rodrigocirilo
@rodrigocirilo
Aug 17 2017 17:14
How to change the IPAddress of the server during program execution, since the IPAddress stays before void setup () and it seems that it does not update the value while the code is running
rodrigocirilo
@rodrigocirilo
Aug 17 2017 17:33
this line ( byte server[] = { 64, 233, 187, 99 }; // Google )does not work inside void setup()
Dmitry Munda
@dimkin-eu
Aug 17 2017 17:36
wrap text inside ```
if (client.connect(server, 80)) {
Serial.println("connected");
client.println("GET /search?q=arduino HTTP/1.0");
client.println();
} else {
otherwise its unreadable
rodrigocirilo
@rodrigocirilo
Aug 17 2017 17:43
Sorry.
 #include <Ethernet.h>
#include <SPI.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 10, 0, 0, 177 };
byte server[] = { 64, 233, 187, 99 }; // Google

EthernetClient client;

void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);

  delay(1000);

  Serial.println("connecting...");

  if (client.connect(server, 80)) {
    Serial.println("connected");
    client.println("GET /search?q=arduino HTTP/1.0");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;;)
      ;
  }
}
Sorry, it does not work.
Dmitry Munda
@dimkin-eu
Aug 17 2017 17:47
Screen Shot 2017-08-17 at 20.47.19.png
rodrigocirilo
@rodrigocirilo
Aug 17 2017 17:48
@dimkin-eu I got
@dimkin-eu Can you help me?
this line does not work inside void setup() just before
byte server[] = { 64, 233, 187, 99 }; // Google
I need to change the IP during the program running
But when I give a new IP value to the server it does not load the new IP value
Dmitry Munda
@dimkin-eu
Aug 17 2017 17:52

just replace

if (client.connect(server, 80)) {

with

if (client.connect({ 64, 233, 187, 99 }, 80)) {

or wharever you need
but thise code sux

rodrigocirilo
@rodrigocirilo
Aug 17 2017 17:55
@dimkin-eu But it has to be a variable, since I need to change without compilation, but during the execution of the program, I will receive a new IP via tcp from a C #application
Dmitry Munda
@dimkin-eu
Aug 17 2017 18:17
just pass result to server variable
Deveyes
@deveyes_twitter
Aug 17 2017 18:21
Hi all, has anyonne encountered an issue where Chrome on Android fails to finish loading a webpage served by the ESP8266WebServer? For me loading the pages works from a pc with the usual browsers, from iOS Safari, a MAC as well, but when accessing the exact same webpage from any browser in Android, Chrome gets stuck.
I tried connecting the phone to a pc via usb to do remote debugging from the pc Chrom. The timing diagramnsays that the request is not finished. I added a windows.onload callback to the served webpage, and it never fires, so it agrees: it's as if the android chrome is waiting to receive a final byte or something, and it never arrives.
rodrigocirilo
@rodrigocirilo
Aug 17 2017 18:42
@dimkin-eu Could you please give me an example?
rodrigocirilo
@rodrigocirilo
Aug 17 2017 19:37

If I declare the variable before the void is set up so:

byte server[] = {};

And void setup gives a value to it, it continues with empty value
So below is how do I give value to the variable

byte server[] = {192, 168, 1, 200};
Deveyes
@deveyes_twitter
Aug 17 2017 20:11
byte server is an array.
byte server[] = {some values} is an initialization of the array. This can only be done on declaration, which you are doing in global scope outside the functions
byte server[4] ;
Then in the function:
server[0] = 192;
server[1] = 168;
Etc... is one way to assign at runtime
rodrigocirilo
@rodrigocirilo
Aug 17 2017 20:35

@deveyes_twitter Gave this error message:
too many initializers for 'byte [0] {aka unsigned char [0]}'

On startup I did so:

byte server[4] = {};

In void setup () I did so:

byte servidor[0] = {192}; //Error points to this line
byte servidor[1] = {168};
byte servidor[2] = {001};
byte servidor[3] = {200};
Dmitry Munda
@dimkin-eu
Aug 17 2017 20:40
remove {}
byte servidor[0] = 192;
and how server disappeared and servidor appeared ? :)
rodrigocirilo
@rodrigocirilo
Aug 17 2017 20:44
@dimkin-eu Sorry, it was typo here, it's all server.
He accuses an error without {}
array must be initialized with a brace-enclosed initializer
Dmitry Munda
@dimkin-eu
Aug 17 2017 20:51
ouch
remove byte too
you initialise only once
rodrigocirilo
@rodrigocirilo
Aug 17 2017 20:57

@dimkin-eu Truth, in the example of the friend just above is already without.

I'll soon test ..

Deveyes
@deveyes_twitter
Aug 17 2017 21:49
Nobody has had Chrome issues on Android when accessing a page served by ESP8266WebServer? It's just me then?
rodrigocirilo
@rodrigocirilo
Aug 17 2017 21:51
@deveyes_twitter Thank you so much, it's working for now.
@dimkin-eu Thank you so much, it's working for now.
Nobody has had Chrome issues on Android when accessing a page served by ESP8266WebServer? It's just me then?
Sorry I can not help, I'm newbie