Esp32 few clients and few servers

I have few esp32 clients and few esp32 servers. I want the clients connect the nearest servers so each server must have one client at a time (the nearest). This is possible?

Some questions:

  1. How do you plan on identifying the "nearest" server?
  2. What is your medium of communication? WiFi, Cell, packet radio?
  3. What protocol are you planning to use to connect? (HTTP, custom, etc.)
  4. Will your connection be permanent or momentary?
1 Like
  1. That Client what have greater RSSI.
  2. WiFi but any medium is good
  3. If the Medium is wifi then html
  4. Momentary

Okay. I don't know the specific answer, but a TCP based protocol should mean you can set the number of connections to 1 to prevent more than one client connecting at a time. How you get that set in your server's WiFi settings, I don't know. You may have to dig into the library code to find that setting if it is not exposed as a user setting during Init().

Assuming you can limit client connections to 1, nothing other should be required to make your dream come true.

Here's a relevant article.

Good luck!

1 Like

Thanks for the answer but I think this is not enough for me. If I limit the number of allowed connections, not sure the client connect to the greatest RSSI's server.

I suppose you had meant to connect to the nearest server that was not currently in use. If not, I apparently did not understand what you meant.

Best of luck, anyway!

1 Like

Take a look at the WiFiScan example in the Arduino IDE.

1 Like

Nearly. For Example they are 2 clients called C1 and C2 who want to connect to the nearest server. In this case the server closest to clients called S1. First Connect C1 to S1 because it have greater RSSI than C2. But for example in one minute C2 will have greater RSSI than C1, so C2 has to connect to S1 and C1 has to disconnect to S1. Sorry if my english is so bad.

This is a good example but i want to know how to can i kick out a client of the server if this client have lesser RSSI than other client.

I see a couple of challenges with what you are asking:

  1. No, I don't think a server can detach a client during a synchronous http request-response. Given the transient nature of a synchronous http call (on the close order of a couple of seconds), I'm not sure why it matters.

  2. How would the "server" know there was a closer client that wanted to attach? The clients presumably know the RSSI of the server, but the server does not typically know the RSSI of the client(s).

Unfortunately I dont know. if the client is already connected to the server, it know the server's RSSI? Or only If it not connected?