Android 7.1 and SoftAP

Has anyone else come up against an issue using Android 7.1 (Google Pixel mobile) and SoftAP?

Am pretty sure that the problem is with Android 7.1 because Android 5.0.2 (HTC One) works fine, as does a MacBook running macOS 10.12.1.

Settings:Phone Status:Status shows that the phone has IP address 10.245.142.241, but it should be 192.168.0.2. It looks to me that Android 7.1 is rejecting the served IP address.

I think this is different to iOS 10 and SoftAP which seems to be a browser security issue.

Hey UMD,

Thanks for reaching out. I’m afraid I don’t quite understand the issue here. Are you having issues connecting to your Photon while it’s in listening mode or when it’s in a user-defined SoftAP mode?

I unfortunately don’t have a Android 7.1 phone in front of me now but I have a friend with one and I can test if you can clarify! :smile:

@harrisonhjones, it is in user defined SoftAP mode, ie it implemented Application softAP http as per https://github.com/spark/firmware/pull/906.

Hope this helps.

Update - same issue with the Pixel mobile phone running Android 8.0.0.

In summary, Photon is in listening mode, running SoftAP.

Mobile phone associates okay with the Photon and is correctly issued IP 192.168.0.2 with gateway 192.168.0.1. So far so good, but the mobile cannot browse to http://192.168.0.1/ using the Chrome browser (noting that I did select http: and not https:)

Using a MacBook, same procedure was successful, ie able to browse http://192.168.0.1/ and the SoftAP page displayed as expected.

To check that Chrome was not the issue, ran Telnet on my phone, and tried to connect to 192.168.0.1 port 80 - problem was NO CONNECTION. This clears Chrome as the problem.

So, it looks like Android 7.1 and above.

Anyone else have similar issues?

Update!

Partial source code:

void myPage(const char* url, ResponseCallback* cb, void* cbArg, Reader* body, Writer* result, void* reserved)
{

Log.trace("myPage:Handling page %s", url);
if (strcmp(url,"/index")==0) 
{
    Log.trace("myPage:Sending redirect");
    Header h("Location: /index.html\r\n");
    cb(cbArg, 0, 301, "text/plain", &h);
    return;
}

A successful transaction looks like this:

0001330578 [app] TRACE: myPage:Sending redirect
0001330581 [app] TRACE: myPage:Handling page /index.html
0001330732 [app] TRACE: myPage:Handling page /style.css
0001330838 [app] TRACE: myPage:Handling page /rsa-utils/jsbn_1.js
0001330844 [app] TRACE: myPage:Handling page /rsa-utils/jsbn_2.js
0001330851 [app] TRACE: myPage:Handling page /rsa-utils/prng4.js
0001330855 [app] TRACE: myPage:Handling page /rsa-utils/rng.js
0001330962 [app] TRACE: myPage:Handling page /rsa-utils/rsa.js
0001331069 [app] TRACE: myPage:Handling page /script.js

The issue gives this:

0000517794 [app] TRACE: myPage:Handling page /gen_204

I will modify the code now to handle url "/gen_204" request and report back...

PS - There is a bucket of information on gen_204 on the web... more research to follow

Happy to report that the following modified line in MyPage() fixed the issue:

   // Catching page request "/gen_204" and other variants is necessary for Android 7.1 and above. 
    if ((strcmp(url,"/index")==0) || (strcmp(url,"/gen")==0))

Looks like my Telnet test was bad - the “connection fail” does not make sense given that a connection is in play…

Anyhow, case closed!

PS - if anyone knows what /gen_204 is about for the record, that would be appreciated.

1 Like

Testing again today, it is not case closed!

Found this gem which gives an explanation of what gen_204 might mean:

It seems that this is sent out by Android devices to check for internet connectivity.

The above site mentions http://www.google.com/gen_204 - curl :

curl -I http://www.google.com/gen_204

returns:

HTTP/1.1 204 No Content
Content-Type: text/html; charset=ISO-8859-1
P3P: CP="This is not a P3P policy! See P3P and Google's cookies - Google Account Help for more info."
Date: Sun, 03 Dec 2017 09:57:45 GMT
Server: gws
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Set-Cookie: NID=118=omS8w1nIGn7s2VXuN2IPeKaufNsHu9kCG1wACUuUj6B1-6jo_5KljO2Kc0attjx4v1ru-tSYdgtf7neQPjz_0N-OTL6_rULg9z6-XvgkcvY5EBi7Yae-IQDV1CHULquI; expires=Mon, 04-Jun-2018 09:57:45 GMT; path=/; domain=.google.com; HttpOnly

Am going to experiment with returning 204 No content to the mobile to overcome the Android issue. Will report back.

Have discovered why I had success yesterday and not today....

When a connection is first made to the SoftAP - Android determines that there is no internet access (via the gen_204 request I assume) and asks:

This network has no Internet access.
Stay connected?

      NO     YES

By pressing YES, the SoftAP page is displayed (good).

Conclusion:

  • my suggested code, Android 7.1 and SoftAP - #6 by UMD, is ineffective.

  • Configure WiFi access as appropriate on the mobile to allow connection to a non-internet connected WiFi AP

  • There should be a way to make configuration of the mobile not required by properly responding to the gen_204 request. Am happy to test any suggestions here as I have not been able to work it out.

Will call it case closed (again).

This is a problem, since different devices have different ways to determine wheter a "real" internet access exist or not.
Some just ping 8.8.8.8 others might try to ping their home server or even request a particular page - there is no way to build all these possible responses into SoftAP.

2 Likes

@ScruffR,

Got it, understood. Too much variation - simpler to remember to press the “YES” button!

2 Likes