Making geolocation work on Geeksphone devices

01 May 2014

This post is written for my own reference, in order to document the steps for getting geolocation working on Geeksphone phones.

For a long time, an easy way to get access to a Firefox OS phone was to order a Peak or Keon model from Geeksphone. The phone maker jumped on the Firefox OS train early on, offering reasonably priced phones aimed to early adopters.

These early adopters were in for a disappointing and frustrating surprise, as they would find out that geolocation didn't work or work haphazardly at best. Such a problem is ridiculous for smartphones sold in 2013, but since those were "developer preview" devices, people didn't complain too much about it.

Fast-forward to 2014. Geeksphone is now selling the Revolution model—a pretty good and powerful phone—aimed to end users, but to those users dismay it still has the same geolocation problems. Because I want to eat my own dog food, I am now using the Revolution as my personal phone and the lack of geolocation has been an enormous frustration.

So, I set out to either make GPS work on my phone or to go back to my trusty iPhone and wait for another phone maker to come up with a Firefox OS compatible phone that matched the Revolution specs.

After looking at many different sources and thanks to some good pointers from Fernando Jiménez and Francisco Jordano, I managed to make it work. Kind of. The hardware to make geolocation possible is definitely there, and the problem looks like it is a configuration one.

I documented below the steps that made geolocation work for me on the Geeksphone Revolution:

Configuration steps

Connect your phone to the computer, open a terminal and make sure you can see the phone using adb:

$ adb devices
List of devices attached
FC7C80DF    device

Retrieve the following files using adb pull:

$ adb pull /system/b2g/defaults/pref/user.js
$ adb pull /etc/gps.conf

user.js

Change (or add) the properties geo.gps.supl_server and geo.gps.supl_port in user.js to user Google's GPS server. My user.js file looks like this:

pref('browser.manifestURL', "app://system.gaiamobile.org/manifest.webapp");
pref('browser.homescreenURL', "app://system.gaiamobile.org/index.html");
pref('network.http.max-connections-per-server', 15);
pref('dom.mozInputMethod.enabled', true);
pref('ril.debugging.enabled', false);
pref('dom.mms.version', 17);
pref('b2g.wifi.allow_unsafe_wpa_eap', true);
pref('network.dns.localDomains', "gaiamobile.org,calendar.gaiamobile.org,fl.gaiamobile.org,camera.gaiamobile.org,communications.gaiamobile.org,gallery.gaiamobile.org,keyboard.gaiamobile.org,video.gaiamobile.org,homescreen.gaiamobile.org,wallpaper.gaiamobile.org,music.gaiamobile.org,bluetooth.gaiamobile.org,ringtones.gaiamobile.org,sms.gaiamobile.org,wappush.gaiamobile.org,email.gaiamobile.org,setringtone.gaiamobile.org,browser.gaiamobile.org,system.gaiamobile.org,clock.gaiamobile.org,settings.gaiamobile.org,pdfjs.gaiamobile.org,costcontrol.gaiamobile.org,marketplace.firefox.com.gaiamobile.org");
pref("app.update.url", "http://gpfos.s3.amazonaws.com/revolution/update.xml");

pref("geo.gps.supl_server", "supl.google.com");
pref("geo.gps.supl_port", 7276);

pref("dom.payment.provider.0.name", "firefoxmarket");
pref("dom.payment.provider.0.description", "marketplace.firefox.com");
pref("dom.payment.provider.0.uri", "https://marketplace.firefox.com/mozpay/?req=");
pref("dom.payment.provider.0.type", "mozilla/payments/pay/v1");
pref("dom.payment.provider.0.requestMethod", "GET");

gps.conf

Replace the contents in gps.conf with the following ones. I got to this particular configuration after looking into different sources, and adapted it to my needs (the NTP server is the Dutch one, for example). I wrote comments to clarify some settings.

# Change Country and Region! see http://www.pool.ntp.org/en/ 
NTP_SERVER=nl.pool.ntp.org
NTP_SERVER=0.nl.pool.ntp.org
NTP_SERVER=1.nl.pool.ntp.org
NTP_SERVER=2.nl.pool.ntp.org
NTP_SERVER=3.nl.pool.ntp.org
NTP_SERVER=europe.pool.ntp.org
NTP_SERVER=0.europe.pool.ntp.org
NTP_SERVER=1.europe.pool.ntp.org
NTP_SERVER=2.europe.pool.ntp.org
NTP_SERVER=3.europe.pool.ntp.org

AGPS=http://xtra1.gpsonextra.net/xtra.bin
XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra.bin
XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra.bin
XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra.bin

DEFAULT_AGPS_ENABLE=TRUE
DEFAULT_USER_PLANE=TRUE
DEFAULT_SSL_ENABLE=FALSE

REPORT_POSITION_USE_SUPL_REFLOC=1

QOS_ACCURACY=50
QOS_TIME_OUT_STANDALONE=80
QOS_TIME_OUT_AGPS=95
QosHorizontalThreshold=1000
QosVerticalThreshold=500

AssistMethodType=1
AgpsUse=1
AgpsMtConf=0
AgpsMtResponseType=1
AgpsServerType=1
AgpsServerIp=3232235555

# Intermediate position report, 1=enable, 0=disable
INTERMEDIATE_POS=1
# Accuracy threshold for intermediate positions
# less accurate positions are ignored, 0 for passing all positions
ACCURACY_THRES=3000

C2K_HOST=c2k.pde.com
C2K_PORT=1234

### AGPS server settings for Google ###
SUPL_HOST=supl.google.com
SUPL_PORT=7276
SUPL_SECURE_PORT=7278
SUPL_NO_SECURE_PORT=3425
SUPL_TLS_HOST=FQDN
SUPL_TLS_CERT=/etc/SuplRootCert

# Carrier tags used universally in GPS configs
CURRENT_CARRIER=common

# Indoor Positioning Settings
# 0: QUIPC disabled, 1: QUIPC enabled, 2: forced QUIPC only
QUIPC_ENABLED=1

#Use WiFi 1=”On”, 0=”Off”
ENABLE_WIPER=1

Now, since Google uses a GeoTrust certificate (you can check doing openssl s_client -connect supl.google.com:7275 in the terminal), we need to retrieve it and generate the root certificate we will use in our phone:

$ wget https://www.geotrust.com/resources/root_certificates/certificates/GeoTrust_Global_CA.pem
$ openssl x509 -inform PEM -in GeoTrust_Global_CA.pem -outform DER -out SuplRootCert

Finally we need to upload all the files we modified into the device and reboot it:

$ adb remount
$ adb push user.js /system/b2g/defaults/pref/user.js
$ adb push gps.conf /etc/gps.conf
$ adb push SuplRootCert /etc/SuplRootCert
$ adb reboot

After doing this my geolocation worked, even indoors. It still takes some seconds to retrieve the AGPS fix and sometimes doesn't get it immediately, but I can say that it works well enough to not drive me mad.

Good luck!

Sources

How to create a SuplRootCert for supl.google.com
http://forum.geeksphone.com/index.php?topic=5886.msg62928#msg62928
Bug 955880 - [GPS] GPS is not working anymore
Bug 908151 - [Geeksphone][GPS] Speedup Geolocation response time, currently takes about 10 minutes
Forum: How can I enable A-GPS on my Peak?

READ MORE


Extending JavaScript with inline unit tests

09 Nov 2013

I’ve been checking out Pyret, the new language from the same guys that made Racket. Even if it is designed to be for education, it has a syntax I love and some really cool features, like the possibility of adding in-line unit tests to your functions. This feature in particular looks like this:

fun square(n):
  n * n
where:
  square(2) is 4
  square(4) is 16
  square(8) is 64
  1+1
end

Neat, huh? The where clause opens up the block of unit tests for that function, which are executed at run-time.

So obviously I decided to give it a try and implement something similar for JavaScript using sweet.js. This allows me to kill two birds with one stone because I have also been meaning to catch up with the latest developments that sweet.js has made since last year (among other improvements, we can now rewrite reserved keywords in our macros!).

READ MORE


Add code coverage to your Node.js projects

19 Jun 2013

Note: This blog post is heavily based on Xavier Seignard's blog post. He gives a longer introduction on it, and integrates it together with Sonar. You should check it out.

Code coverage is invaluable to get an overview of how well-tested your app is, and it helps finding new bugs in your code. Unfortunately coverage reports are not ubiquitous in Node.js projects, and because of that it may seem that it is hard to set up, which is not the case at all!

I'm going to show you how to set up code coverage using Mocha, Istanbul and LCOV in two easy steps.

READ MORE


Virtual list in vanilla JavaScript

12 May 2013

Let's say you need to show a scrolling list with millions of rows, or even a reasonably big list with visually complex rows, each one composed by several DOM elements or CSS3 effects.

If you try to render this the naive way, for example by appending rows into a DOM container with the CSS overflow property set to scroll (or auto), you will most likely run into performance issues. This is because all the items in the list are cached, thus your memory consumption will certainly go up, and since all the DOM nodes composing the rows of the list are appended in the document, the browser is trying to properly render them all making your CPU pretty busy as you scroll. If these rows change any style say, on hover, you will trigger a reflow and the experience will be even more sluggish.

READ MORE


Implement cursor-swiping in half an afternoon

21 Feb 2013

If you haven't seen it yet, I suggest that you take a look at this concept video that made the rounds on the internet some months ago:

I would pay to have this in my phone. Only, money wouldn’t help since I own an iPhone, and a developer has simply no way to access an internal component like the phone keyboard.

READ MORE


The promise of Firefox OS

09 Feb 2013

"But how is it going to beat Android or iOS?”

That’s the reaction many people have when I tell them that I am working on Firefox OS, the new mobile operating system from Mozilla. It is a logical reaction. After all, we live in times where every major software company and its mother is releasing a mobile platform, struggling to lure developers into their new proprietary environment, APIs, libraries, etc. And indeed, many of these companies barely make it or don’t make it at all.

But Firefox OS will not be directly battling against other mobile platforms. Its main objective is to change the way the world develops mobile apps, and even in the unlikely event that Firefox OS itself disappears in the process, if web-apps become mainstream, it will have succeeded.

READ MORE


Moving on

29 Jan 2013

A little bit more than two years ago I was sitting on a meeting room, listening to Ruben Daniels and Rik Arends, the two founders of the company I was considering to join, Cloud9 IDE. These were two of the smartest, most inspiring people I’ve met, and they were working hard on a ground-breaking concept: a full-fledged development environment that run in the browser, and in the cloud. At the time, that sounded wildly adventurous, to say the least. But the challenges were so many, the concept so revolutionary and the people so inspiring that I joined the company two weeks after that conversation.

What followed were two exhilarating years in which we got funding, surpassed almost every technical limitation that got on our way, got a huge user base and learned (many times the hard way) about software development, startup world and companionship.

READ MORE


Nodejsconf in Italy

12 Nov 2012

Last weekend I was at the Node.js conference in Brescia, Italy. Like every year the organizers managed to stage a great conference with really good talks. Even if I was there only for a lightning visit (less than 24 hours between leaving Amsterdam and being back), I had tons of fun and the talks I saw were really top-notch.

As a side note, I’m continually impressed by how much hacker spirit there is in Italy. There was lots of Arduino, BeagleBone boards and the real excitement of building stuff in Node.js that nobody has built before. Check out the talks from Simone Chiaretta or Matteo Collina to see an example of what I mean, when you have some time.

READ MORE


My talk at DynCon 2011

04 Apr 2011

The video with my talk about Cloud9 IDE at DynCon 2011 is already out! It’s quite long, but definitely worth it if you are interested in the future of the IDE, since I had the chance to answer many questions about it during the talk. About half of the video contains demo and questions from the audience, as it was quite interactive.

Also, I want to thank Peter Svensson for creating such a wildly interesting conference and being a really great host and organizer. It is a very, very hard job that he pulled off amazingly well.

This talk was especially interesting to me because although the audience included mainly professional developers, most of them weren’t using JavaScript as their main language (as is often the case in our talks). It was fun to show them the power of JavaScript. And as always when you add people with different backgrounds to a discussion, ideas and good questions quickly started popping up. It was great. We’re also working hard at getting more languages incorporated, so hopefully we can have more of these types of discussions in the future, hang in there!

READ MORE


Dynamically generating MIDI in JavaScript

08 Nov 2010 Dynamically generating and playing midi using JavaScript

READ MORE


Writing a JavaScript interpreter for DBN using PEG.js and canvas (Part II)

20 Aug 2010 Writing an interpreter for Design By Numbers in JavaScript from the grammar generated with PEG.js in the previous article of this series.

READ MORE


Writing a JavaScript interpreter for DBN using PEG.js and canvas (Part I)

03 Aug 2010 In this first part of the article, I will define a grammar for DBN and generate a parser for it, so I can interpret the syntax tree it later on with JavaScript and draw it into an HTML5 Canvas.

READ MORE


GitHub in Catalan

28 Jul 2010

This is awesome. From now on, Catalan users of GitHub can use the website in their native language. Thanks to the Github team initiative and the brilliant approach of crowd-sourcing the translations (along with some very convenient tooling to do so), I could translate almost all the strings of the website in a record time two weeks ago.

What I found out today is that the website is already making use of it and available to everyone! Just point your browser to http://github.com/blog?locale=ca and the page will be offered to you in Catalan already. The translation is currently 87% complete, so there is still some work to be done, which I expect to finish between today and tomorrow.

Anyway, if Catalan is your native language and the lack of it in Github was stopping you from using it, now you have the chance!


GitHub en Català

Des d’ara mateix, els usuaris Catalans de Github poden utilitzar la web en el seu propi llenguatge. Gràcies a la iniciativa de l’equip GitHub i a la manera brillant d’utilitzar crowd-sourcing per a traduïr la web a multitud de llenguatges (i a unes eines de traducció molt útils), he pogut traduïr quasi totes les cadenes de la web fa dues setmanes en un temps récord.

El que no m’esperava i he descobert avui és que GitHub ja està disponible online en Català! Només cal que introduïu la següent direcció al vostre navegador: http://github.com/blog?locale=ca i la pàgina us preguntarà si voleu establir Català com a llenguatge del lloc per defecte. La traducció està 87% complerta, així que encara hi ha una mica de feina per fer, que espero finalitzar entre avui i demà.

Així doncs, si la teva llengua és el Català i el fet que GitHub estigués només en anglès t’impedia utilitzar-lo, ara ja no tens excuses!

READ MORE


Blog running on Jekyll now

13 Apr 2010

That’s right, I couldn’t resist switching to Jekyll. I feel so free now!

For those who don’t know, Jekyll is a static site generator. It takes a template directory, runs it through a textile or markdown parser, and outputs a complete website ready to be served with any web server, since it is simple HTML. That means no more server queries or content stored in databases. You own your content, and it is stored in plain text files. Of course, that also means that it is perfect to be maintained with a VCS like Github, where by the way, you can host your Jekyll sites for free!

Ah, simplicity…

You can see the source code for my blog and get a feeling of how it works.

READ MORE


ABN Amro to Wesabe script

25 Feb 2009

Wesabe is a great service. And a very big part of its greatness resides in the fact that it retrieves your bank accounts data automatically from their sources whenever you log in into the page.

That is, if you don’t have a Dutch bank account.

The reason for this is that the security of Internet banking in The Netherlands is quite strong, probably much more than the ones in the US (where most Wesabe users are from). Every bank customer owns a little device in which you have to put your bank card in, type your PIN number, type a number given to you by the bank website, and type back the code calculated by the device. Only then you can access your personal bank website. Once in the site, you will have to repeat this process for every transaction or order that you make.

I much rather prefer this increased security when it comes to Internet banking as it adds an extra layer of security that makes it much more difficult to hack illegally into people’s bank accounts, but this also means that Wesabe (obviously) won’t be able to access the data in my bank website automatically.

READ MORE


YQL mashup with GWT

16 Nov 2008 In this post I build a simple mashup with Google Web Toolkit that uses Yahoo Query language to retrieve pictures from flickr and render them in a small GWT component.

READ MORE


Solitaire Encryption Algorithm implementation in F#

13 Oct 2008 Implementation of Bruce Schneier's solitaire encryption algorithm using Microsoft's new functional programming language F-sharp.

READ MORE


Nth attempt

08 Oct 2008 My last blog tried to cover too many things, from my life abroad, to ramblings on software engineering and even some poor attempts to deep thinking every other post. Well, you really can't bite off more than you can chew, and that was too broad and disorganized to maintain it properly.

READ MORE