0

Context

I'm working on an ESP32 device that use WifiManager library to set up the device Wifi. This library just create a Wifi Hotspot who redirect to a basic HTML page. This page will be reachable via a smartphone. I want to know the user location when he visits this HTML page.

My Problem

The problem is, that to see this page, he must be connected to the ESP32 Wifi Hotspot so every solution must work without an Internet connection. Furthermore, I know that there is this API (HTML5 Geolocation), but it didn't work because the server is hosted locally in HTTP. (And I saw a post that said that it must be connected to Internet). I have also a size constraint. I'm working on a tiny device with already a lot of code so the solution mustn't be to heavy.

So, is there a way to get a smartphone GPS Location via a Javascript script and without using HTML5 Geolocation and without an Internet connection ?

Gazouu
  • 372
  • 3
  • 16
  • Where did you see it must be connected to the internet? Have you tried it on the device? – G Cadogan Jun 29 '18 at 19:01
  • @GCadogan I saw it here https://stackoverflow.com/questions/17312826/get-gps-location-using-javascript-without-internet – Gazouu Jun 29 '18 at 19:09
  • And yes I ran it into my device but the API doesn't work on HTTP for chrome. It must use HTTPS. – Gazouu Jun 29 '18 at 19:10
  • In the browser your only option is the [Geolocation API](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API) but as you already said you need SSL and depending on the browser implementation also internet. Only via a native app you can access directly the GPS hardware. But also then the GPS lock can be extremely slow. Normally phone use A-GPS ( Assisted GPS ) to achieve fast locks and A-GPS uses internet. – Victor Perez Jul 08 '18 at 19:26
  • Are you using Phonegap/Cordova? Do you need Android and/or iOS support? – tremor Jul 09 '18 at 13:45
  • What I want to achieve seems impossible. I just wanted to get the user GPS in a webpage without "HTML5 Geolocation" (because I can't config https on my arduino device). So I changed my architecture with one that doesn't need this information – Gazouu Jul 09 '18 at 14:05

1 Answers1

1

I don't know why you wouldn't want to use JS. It's the only way you can get information from the client in a web app.

The hurdle is, you usually need HTTPS for such sensitive data to be allowed to be sent by the users browser. But how to set your server up for HTTTPS is not a question for StackOverflow.

Sorry that we can't give you a better answer. If you can't do it native you'll have to work with what you've got.

EDIT: Some browsers need intenet to verify certificates, can't do anything about that. If you don't control the device -> browser.

dscham
  • 547
  • 2
  • 10