Help for wifiServer

I am having strange situation with my new Arduino Giga.
I took program from tutorial , copy, paste and more or less it is working as expected.
The WebServer as AP is not working but connecting to other network is working fine.
So i was thinking it will be simple and proceeded with integrating into my project (made on Due with ethernet shield)
So here is strange situation.
If i will declare WifiServer and WifiClient in the main file, it is working fine.
However if i will use additional file and define that file .h into main project file the compiler is happy and loads the program into device.
But looks like it is having some dummy references now because it is garbage.

  1. WifiServer defined in 2nd file will never work (my browser is not able to connect)
    If i will declare WifiServer in the main file and pass pointer to it to class or function in the other file it is working (almost).
  2. So once i have this situation that WifiServer defined in main file. I have class that is using pointer to it to detect connection and so on.

And it is working to detect connections but not able to get incoming message:

WiFiClient httpclient = (*serverHTTP).available();
// this is working ,
// also serverHTTP->available(); will work

if (httpclient) {
//it is not 0 pointer and get in
if(debug)Serial.println("new client");
//i can see print in serial
int incommingMsgLen = 0;
if (httpclient.connected()) {
//it is getting into this condition, so it is working for connected
incommingMsgLen = httpclient.available();
// this returns 0
httpRequest.reserve(incommingMsgLen);
if (debug) {
Serial.print(F("Incomming Msg Length: "));
Serial.println(incommingMsgLen);
// this will print out 0

Again if i will put the same code in main file, it will work

I am adding #include <Wifi.h> in both files and i and suspecting that this is an issue

are you on latest Mbed Core?
has the second server a different port?

Bytes "on the wire" can stall and come in groups/parts, so generally this should be more like

int incommingMsgLen = 0;
while (httpclient.connected()) {
  if (incommingMsgLen = httpclient.available()) {

Of course, a genuine HTTP server would handle these "plumbing" details for you and present the captured request method, URL, headers, and body. But since you are trying to unravel your mystery, you can start there.

A properly constructed header file can be included several times in the same file, and in nested files. The usual problem is when you forget to include it; each "compilation unit" needs its own.

there is only 1 server ,
How to check Mbed core version ?
I am running latest arduino ide

in Boards Manager

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.