Client WiFi Feather to Host WiFi Feather : Data sent but not received

I'm trying to set up two Feather WiFi M0s, one as an Access Point Host and one as a Client, so that the Client one can connect to the Host one and send and receive data with the Host.

I seem to be successful in setting up the Host. When it's running I can even see it's name on the list of available WiFi connections as reported on my PC. And when I run the client Feather I have it do a scan for connections and sure enough it reports that other Feather that's running as a Host.

When I run the Client Feather it reports that it successfully connects to the Host, and the Host reports that it is now connected to the Client, by reporting its WiFi.status as WL_AP_CONNECTED. So I SEEM to have a successful connection both from the Client's and the Host's perspectives.

Having made the connection with the Host, the Client Feather then sends some data using the following code:

Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
Udp.write("BLINK");
Udp.endPacket();

and diagnostics on the Client indicates that it successfully sent the right number of bytes.

BUT BUT BUT, I can't figure out how to actually RECEIVE the data on the Host Feather.
I tried using a Udp as in:

Udp.parsePacket();

and that always returns zero, i.e. no data available.
I tried using:

WiFiClient client = server.available();

and that always indicates no server available.

SO I'M STUMPED. What might I be doing wrong?

Following is the major code for the Host side, with comments throughout indicating what's working and what's not.

#include <SPI.h>
#include <WiFi101.h>
char ssidWiFiAccessPoint[] = "YabbaDoo777";
int status = WL_IDLE_STATUS;


void setup()
{
  //Configure pins for Adafruit ATWINC1500 Feather
  WiFi.setPins(8,7,4,2);

  // Check for the presence of the shield
  Serial.print("WiFi hardware: : ");
  if (WiFi.status() == WL_NO_SHIELD)
  {
    Serial.println("NOT PRESENT : UNABLE TO CONTINUE PROGRAM");
    return; // don't continue. I actually don't think that this causes it to "not continue".
  }
  Serial.println("DETECTED"); // this shows that the WiFi circuitry is present.
  // And indeed it is present.

  WiFi.beginAP(ssidWiFiAccessPoint); 

  // Start up this Feather as an Access Point.
  status = WiFi.beginAP(ssidWiFiAccessPoint); // i.e. as YabbaDoo777
  if (status != WL_AP_LISTENING)
  {
    Serial.println("Creating access point FAILURE");
    // don't continue
    while (true);
  }
  else
  {
    Serial.println("Created Access Point SUCCESS");
  }
  // wait 10 seconds to complete the connection:
  delay(10000);

  // And indeed it is successful doing the WiFi.beginAP(ssidWiFiAccessPoint);
  // In fact I can see this WiFi Access Point, i.e. YabbaDoo777, via my PC when I
  // use it to show the list of available WiFi access points.

} // END OF setup

void loop()
{
    status = WiFi.status();

    if (status == WL_AP_CONNECTED)
    {
      Serial.println("We HAVE A CONNECTION");

      // We do indeed get here as soon as my OTHER Feather, which is set up to attempt
      // a connection to THIS Feather, by doing a WiFi.begin(ssidWiFiAccessPoint);
      // over on that OTHER Feather.
     
      // That OTHER Feather then repeatedly sends out data (presumably to THIS Feather)
      // using the following sequence
      //       Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
      //       Udp.write("BLINK");
      //       Udp.endPacket();
      //  Diagnostics over on that OTHER Feather indicates that it did indeed send 5 bytes
      //  BUT it shows Udp.remoteIP() as 0,0,0,0 and Udp.remotePort() as 0
      //  so it seems sometyhing's not quite right over there.

     // THE QUESTION now is HOW DO I **RECEIVE** the data that was sent???

      // I TRIED setting up a Udp on THIS Feather and doing...
      Udp.parsePacket();
      // but that always returns 0 as the packet size, so apparently nothing received.

      // I also tried setting up a server and doing...
      WiFiClient client = server.available();
  
      // BUT client always come back indicating that no client is available.

      // SO WHAT DO I DO to receive the data being sent by that other Feather, which SEEMS
      // to have successfully connected to THIS Feather and SEEMS to be successfully sending
      // some data??
  }
}

I'm a little bit bemused as to why you only posted the (probably incomplete) server code...

If you don't specify an IP address for the host it will take a default, as stated in an example here:

  // by default the local IP address of will be 192.168.1.1
  // you can override it with the following:
// WiFi.config(IPAddress(10, 0, 0, 1));

You also need to have the host listen on a port using:

uint8_t begin(uint16_t); // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use

On the client you are trying to send the packet using Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());, but Udp.remoteIP/Port will only have valid data if the client has received a packet already and is trying to reply to it.
You need to use the host's IP and port as arguments.

Take a little time to read through the other examples.

Thank you for your helpful response.

You note that the host must listen on a specified port via a call to a "begin" method. I'm begin-ing the WiFi on the host code like this:

status = WiFi.beginAP(ssidWiFiAccessPoint);

where that ssidWiFiAccessPoint is the name that I want the Access Point to be referable to. In my case I'm using "YabbaDoo777". And that name appears very nicely when I check for available WiFi networks via my PC.

The host code also has a WiFiServer object that gets instantiated with:

WiFiServer server(80); // Where the 80 is (presumably) the listening port.

Later that server gets started with a begin() statement like this:

server.begin();

There's no port specified in that begin call. Yet you indicated that I need to do a begin() call somewhere like this:

uint8_t begin(uint16_t); // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use

Yet there's no WiFiServer.begin()method that takes a port number as a parameter. So I"m a bit confused as to where I'm supposed to do that begin() statement and what object is doing it.

RogerInHawaii:
The host code also has a WiFiServer object that gets instantiated with:

WiFiServer server(80); // Where the 80 is (presumably) the listening port.

I believe WiFiServer is for TCP connections. You are trying to use UDP.

RogerInHawaii:
There's no port specified in that begin call. Yet you indicated that I need to do a begin() call somewhere like this:

uint8_t begin(uint16_t); // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use

Yet there's no WiFiServer.begin()method that takes a port number as a parameter. So I"m a bit confused as to where I'm supposed to do that begin() statement and what object is doing it.

WiFiUDP -> uint8_t begin(uint16_t)

See the WiFiUdpSendReceiveString example.