1

Background

My Android App allows the device to be used as a remote sensor. The device sends the Sensor data over a local WiFi-Network towards an application that is running on a PC on the same network. The PC supports multiple devices and can connect to the available devices. The device discovery is done via UDP Broadcast messages.

UDP Messages are blocked when the screen is off

As soon as the screen goes off, UDP Packets can't be received. Therefore, the device discovery stops working. There are already multiple questions regarding this topic, and even the ugliest workarounds are not reliable working. I tested these options:

  • Partial Wake Lock
  • Wifi Lock
  • Turn off Wi-Fi and back on, when the screen goes off
  • Rebind the UPD Socket when the screen goes off
  • Different timings on the steps above

Only the UPD device discovery is affected by this problem, not the TCP connections that are used for the communication. As soon as the screen turns off, TCP packets can still be sent and received, but UDP packets are blocked. I tested this using Wireshark with multiple devices. It is even possible to connect to a device while the screen if off by manually typing the device's IP. Therefore, this is not a Battery / Sleep / Dose / Permission issue, instead there is a filter for UDP packets that can't be reliably deactivated.

How to do a Service Discovery given the following constraints?

  • No internet connection
  • Must work while the screen is off
  • UDP Packets are blocked

There are a lot of Service Discovery Protocols out there, but as far as I am aware, they are all using UDP or a central Server. So, is there any solution to my problem?

Notes

If you want to read more about the UDP issue, checkout these links:

Crigges
  • 1,083
  • 2
  • 15
  • 28

0 Answers0