-->
Page 1 of 2

Different HTML on AP and STATION address.

PostPosted: Tue May 31, 2016 11:45 am
by BruceFerjulian
Did some searching and could not find an answer to this question.

Q: Can you conditionally serve different HTML based on whether the caller arrives from the AP address or STATION address?

I am trying to get my head around a configuration interface and it would be nice if the AP interface served up the configuration page and the STATION side served up HTML which display's some sensor's data.

Re: Different HTML on AP and STATION address.

PostPosted: Tue May 31, 2016 12:18 pm
by martinayotte
Yes, it is possible !
For that, you should rely on server.hostHeader() which give you remoteIP and determine if it is on AP subnet or STA subnet, and then provide different web page accordingly.

Re: Different HTML on AP and STATION address.

PostPosted: Tue May 31, 2016 3:52 pm
by BruceFerjulian
Super, thank you for providing the place to start.

-b-

Re: Different HTML on AP and STATION address.

PostPosted: Tue May 31, 2016 6:58 pm
by BruceFerjulian
As a starting point, this worked for me.

Code: Select all  IPAddress IpAP(10, 0, 100, 1);
  if (client.localIP() == IpAP) {
    Serial.println();
    Serial.println("CONFIGURED: You are connected through the ACCESS_POINT mode.");
  } else {
    Serial.println();
    Serial.println("CONFIGURED: You are connected through the STATION mode.");
  }