Post Viewer - 20141123.HTM

Pulling GPS data from a Sierra Wireless Overdrive Pro with Node.js

As part of an ongoing series of improvements to a remote control car I bought at a thrift store, I needed a stream of GPS data from a Sierra Wireless Overdrive Pro 3G/4G hotspot (which, coincidentally, I also picked up at a thrift store). After registering the device with my carrier, logging into the admin interface, and accepting the GPS agreement, I started breaking down what AJAX queries the hotspot was using to get its GPS data to display on the admin panel to see if I could replicate them on the client webpage used to drive the car, but as expected I was immediately stopped by the big red CORS warning.

Sierra Wireless Overdrive pro supplying GPS data to Raspberry Pi rover

Sourcing the GPS data

After a short bit of Googling, I stumbled across this post by zharvek on Archaic Binary indicating that port 5502 on the hotspot was open and telnet could be used to see GPS updates. While I was unable to replicate the telnet behavior (immediately disconnected each time, even with escape character off), a port scan revealed that ports 53, 80, 5502, 5503, and 5504 were indeed available. Pointing gpsd at 5502 did the trick, and with a little visualization help from xgps I could now see what data was being captured and how quickly.

Accessing telemetry with Node.js

For my purposes, I needed this data to pass through my Node.js control program where it would be separated out and sent to the connected client. As always, npm delivered with the package node-gpsd by eelco. After running gpsd tcp://192.168.0.1:5502 , the following code is able to listen to gpsd and pull through TPV data as a periodically updated object to be later manipulated and sent out (how periodically can be adjusted in the hotspot admin panel).

var gpsd = require('node-gpsd');
var gpsData = "No GPS data received.";

var gpsListener = new gpsd.Listener({
	port: 2947,
	hostname: 'localhost'
});

function startGPS () {
	gpsListener.connect();
	gpsListener.watch();
	gpsListener.on('TPV', function (tpvData) {
		gpsData = tpvData;
	});
}

function stopGPS () {
	gpsListener.unwatch();
	gpsListener.disconnect();
}

startGPS();

 

Last Updated: 2024-05-16 - Questions? Feedback? Send me a note!