I am attempting to build an HTTP Proxy App for Android, through which Bluetooth 2.1 hardware devices can send HTTP requests to the internet via a smartphone.
The hardware devices assign an IP address and subnet mask to the android smartphone via DHCP. As the devices do not have internet access themselves, no router or DNS server is specified via DHCP.
I am trying to connect the devices to the Android smartphone within the system settings app.
What is happening is that the connection is established briefly, but is immediately terminated by the Android operating system. I expected that the connection is established and maintained until the user disconnects it.
What I have discovered so far:
Some Android devices (e.g., Motorola G5) attempt to reach http://connectivitycheck.gstatic.com/generate_204. If my Bluetooth devices successfully process this request (by modifying the DNS response and answering the request itself with an HTTP status code 204), the connection is maintained for a longer time. Unfortunately, this method doesn't work on my Samsung test device and is likely not a reliable solution.
On iOS, the Bluetooth PAN connection works perfectly. In the system settings app, an additional element "Ethernet" appears with a submenu "Bluetooth PAN." The assigned IP address and subnet mask is displayed there, and I can communicate in my app with the device using Bluetooth.
For your information: I am currently simulating my Bluetooth 2.1 hardware devices using a MacBook Pro with macOS Catalina. Therefore I have created a Bluetooth PAN interface in network settings and set up a DHCP and DNS server using dnsmasq.
Can anyone help me, how I can create a reliable Bluetooth PAN connection on android? The connection doesn't necessarily have to be established through the System Settings app but can also be established in a custom app.
The goal is to establish a Bluetooth PAN connection that is consistently maintained but doesn't provide internet access.