Go Down

Topic: Wifi101: Client reading data from the (MKR1000) server (Read 465 times) previous topic - next topic

Lechatroger

Hi everybody,
I am trying to make bidirectionnal wifi communication between two MKR1000. One MKR1000 creates the wifi network and the server and the other MKR1000 is a client. The two MKR have ATSAMW25... atmel wifi module and its firmware are 19.4.4 version (I read  there that the latest firmware for this module is 19.4.4 and not 19.5.2, is it true?).

I am able to send data from the "Client" MKR to the "Server" MKR like it is shown in all WIFI101 examples but I never saw how to send data to ALL clients (using server.print("") ).
My problem is that i don't know how to send data from the "Server" MKR to the server or, how to read data from the server to the "Client" MKR. My code below shows you my two functions for reading and sending.

Code: [Select]
void sendWifi(String txString){
    Serial.print("Send:  ");
    Serial.println(txString);
    server.print(txString); // send to all clients
    server.print("\n");
}

sendWifi on "Server" MKR side.

Code: [Select]
void receiveWifi(){
   client.stop();
   if (client.connect(server, port)) {
          Serial.println("client is connected to server");
          do{
            c = client.read();
            Serial.print(c);
            Serial.println(":char is still not a new line");
          } while (c != '\n');
          Serial.println("char is now a newline");       
    }       
}

receiveWifi on "Client" MKR side,
and i'm getting nothing to read on the "Client" serial port, it outputs:

client is connected to server
βΈ®:char is still not a new line    <-- endlessly

Is my sent string on the server?
How can I make my "Server" to "Client" communication work with server.print() ?

Best regards!

ballscrewbob

You need to attach all the code used not "snippets"
It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

Lechatroger

There are the entire codes.

Go Up