This is maybe not a question about B4A but it seems to be an Android "feature".
Long post, I am sorry (I have been working on this for a couple of weeks now).
I have a B4A app that I use to control devices via WiFi.
The devices have an off-the-shelf WiFi-Serial module that can be configured to show up as an access point. The serial port goes to a microcontroller. The WiFi modules are used in "transparent" serial emulation mode, all the heavy lifting is done by the microcontroller.
I connect the tablet to the module/access point, the wifi module is configured to listen to port 8899 (TCP) over IP address 10.10.100.254.
My app opens this port for TCP, sends commands to that port and gets responses from the microcontroller over that port. Of course, the WiFi module is not connected to my home network, but the home network is visible from the Android tablet.
As long as I am at home, all goes well. I have also used it at my customer's location (where there also is a WiFi network) and there also all goes well. My app can use UDP or TCP and at home, both work equally well.
The site where these systems are eventually used does not actually have a WiFi network, so when at the site, the WiFi module's access point is the only visible WiFi device.
When we start the tablet and the WiFi device at the site, all goes OK, we connect to the access point, start the app and all goes well.
After about a minute, the port goes dead. The tablet shows being connected to the access point, but the app cannot open the TCP port. It's like the tablet simply refuses to even try to connect (I get Socket1_Connected( False ) instantly), yet the tablet shows being connected to the access point and if I open the browser on the tablet, I can get to the WiFi module's configuration web page.
If I reboot the tablet, I get another minute or so of WiFi and then the socket dies again. If I simply toggle wifi on and off on the tablet, sometimes the tablet will refuse reconnecting to the module, saying "no internet", but even in the cases where it does reconnect to the access point, the socket won't open.
If I then put the tablet and device in the car and drive home, as soon as I pull in the driveway and the tablet sees my internet connected home wifi router, it all starts running again. If I drive off away from home with the app running, it seems to be running fine as long as I do not disconnect. If I manually disconnect, I cannot reconnect.
It is as if as long as the tablet sees an access point that it knows to be internet connected (even though it is not associated with it), you get full wifi (all ports). Otherwise, after a minute or so, only port 80 works.
I have used two tablets, one with Android 6.0 and another with 4.4, and a phone with Android 5.1 and they all do the same thing.
Has anyone (like robot or drone designers) encountered a problem like this?
I wonder how the drone people are doing it since drones are used outside, typically away from other WiFi networks, maybe they use Port 80 for everything, or maybe there is an Android switch somewhere to keep WiFi up?
Thanks in advance for any suggestion.
<edit 3:46 PM>
The first round of Google searches did not yield anything but a second round yielded a number of issues with Android dropping WiFi when it cannot call home (I suppose it pings the mothership, googoe.com). I have tried a couple of apps that are supposed to keep WiFi up in a case like this but so far, while it seems to delay the inevitable, no success. I am still looking for a fix that works.
Long post, I am sorry (I have been working on this for a couple of weeks now).
I have a B4A app that I use to control devices via WiFi.
The devices have an off-the-shelf WiFi-Serial module that can be configured to show up as an access point. The serial port goes to a microcontroller. The WiFi modules are used in "transparent" serial emulation mode, all the heavy lifting is done by the microcontroller.
I connect the tablet to the module/access point, the wifi module is configured to listen to port 8899 (TCP) over IP address 10.10.100.254.
My app opens this port for TCP, sends commands to that port and gets responses from the microcontroller over that port. Of course, the WiFi module is not connected to my home network, but the home network is visible from the Android tablet.
As long as I am at home, all goes well. I have also used it at my customer's location (where there also is a WiFi network) and there also all goes well. My app can use UDP or TCP and at home, both work equally well.
The site where these systems are eventually used does not actually have a WiFi network, so when at the site, the WiFi module's access point is the only visible WiFi device.
When we start the tablet and the WiFi device at the site, all goes OK, we connect to the access point, start the app and all goes well.
After about a minute, the port goes dead. The tablet shows being connected to the access point, but the app cannot open the TCP port. It's like the tablet simply refuses to even try to connect (I get Socket1_Connected( False ) instantly), yet the tablet shows being connected to the access point and if I open the browser on the tablet, I can get to the WiFi module's configuration web page.
If I reboot the tablet, I get another minute or so of WiFi and then the socket dies again. If I simply toggle wifi on and off on the tablet, sometimes the tablet will refuse reconnecting to the module, saying "no internet", but even in the cases where it does reconnect to the access point, the socket won't open.
If I then put the tablet and device in the car and drive home, as soon as I pull in the driveway and the tablet sees my internet connected home wifi router, it all starts running again. If I drive off away from home with the app running, it seems to be running fine as long as I do not disconnect. If I manually disconnect, I cannot reconnect.
It is as if as long as the tablet sees an access point that it knows to be internet connected (even though it is not associated with it), you get full wifi (all ports). Otherwise, after a minute or so, only port 80 works.
I have used two tablets, one with Android 6.0 and another with 4.4, and a phone with Android 5.1 and they all do the same thing.
Has anyone (like robot or drone designers) encountered a problem like this?
I wonder how the drone people are doing it since drones are used outside, typically away from other WiFi networks, maybe they use Port 80 for everything, or maybe there is an Android switch somewhere to keep WiFi up?
Thanks in advance for any suggestion.
<edit 3:46 PM>
The first round of Google searches did not yield anything but a second round yielded a number of issues with Android dropping WiFi when it cannot call home (I suppose it pings the mothership, googoe.com). I have tried a couple of apps that are supposed to keep WiFi up in a case like this but so far, while it seems to delay the inevitable, no success. I am still looking for a fix that works.
Last edited: