I am trying to use esp8266 as a offline web server that has JavaScript inside. My question is how can the esp8266 read the value of a JavaScript variable?
I am trying to make a speedometer that reads the speed from the geolocation api on a phone.
Below is the JS code that would run on the esp8266 web server. I need it to be able to grab the value of variable "speed".
function initGeo() {
navigator.geolocation.watchPosition(
geosuccess,
geofailure,
{
enableHighAccuracy:true,
maximumAge:30000,
timeout:20000
}
);
//moveSpeed(30);
//moveCompassNeedle(56);
}
var count = 0;
function geosuccess(event) {
$("#debugoutput").text("geosuccess: " + count++ + " : " + event.coords.heading + ":" + event.coords.speed);
var heading = event.coords.heading;
var speed = event.coords.speed;
if (heading != null && speed !=null && speed > 0) {
//moveCompassNeedle(heading);
}
if (speed != null) {
// update the speed
moveSpeed(speed);
}
}