UHSL-Marcus
Posts: 1
Joined: Fri Aug 25, 2017 11:09 am

Raspberry Pi3 - Send packets on SoftAP network

Fri Aug 25, 2017 11:13 am

I am having an issue with UDP packets when using the Pi3 with a SoftAP.

I have a ESP8266 which broadcasts UDP packets. My Pi has a UWP program to listen on a set port and respond to any packets that arrive.

When both the ESP and Pi are stations on another network, it works fine, The pi responds and the ESP receives the packets. However, when the ESP is connected to the Pi's SoftAP (while the pi is connected to another network via a wired connection), the Pi receives the packets, but the ESP does not get the response. It looks like the Pi is trying to send the response packets down the wired connection rather than over the SoftAP network. How can I make the Pi use transmit over its SoftAP network?

Code: Select all

private async void StartUdpListener()
{
  _udpSocket = new DatagramSocket();
  _udpSocket.MessageReceived += _udpSocket_MessageReceived;

  await _udpSocket.BindServiceNameAsync(_udpPort.ToString());
}

private async void _udpSocket_MessageReceived(DatagramSocket sender, DatagramSocketMessageReceivedEventArgs args)
{
            
  using (StreamReader reader = new StreamReader(args.GetDataStream().AsStreamForRead()))
  {
    string message = await reader.ReadToEndAsync();
    TextBox_WriteLn(txtBx_packetIn, $"{message} from {args.RemoteAddress.DisplayName}:{args.RemotePort}");
                
    using (IOutputStream oStream = await _udpSocket.GetOutputStreamAsync(args.RemoteAddress, args.RemotePort))
    {
        using (DataWriter writer = new DataWriter(oStream))
        {
          writer.WriteString("reply");
          await writer.StoreAsync();
       }
    }
  }
}

Return to “Windows 10 for IoT”

Who is online

Users browsing this forum: No registered users and 1 guest