Anbei findet ihr eine Anleitung und eine Reihe Scripts (von mir und von anderen), die es ermöglichen dürften, GPRS auf dem FR zu nutzen und das leidige GPS-Antennen Problem mit Software wesentlich zu verbessern. Ich habe die Anleitung auf Englisch geschrieben, damit ich sie später ins OpenMoko Wiki setzen kann. Also bitte testen und falls Fragen aufkommen, dürft Ihr gerne einen Kommentar lassen und ich werde versuchen so gut es geht zu helfen.
Dear all,
After playing around with my Freerunner for almost a week now, I have finally been able to get GPRS working (with Multiplexing) and to reduce my GPS first fix time from over 10 Minutes to less than 2 Minutes (your mileage may vary depending on where you are). In the course of getting all of this up and running, I have written a couple of scripts as well as a GUI to help with managing GPRS and AGPS. I would have preferred to be able to add a GPRS icon to the top of the FR screen, but as I am using ASU, this has proven too complicated for now (afaik, it would involve coding a new icon in C as an Illume extension). The good news is that the GUI, which I named "Services" does also allow some more stuff, like switching Bluetooth, GSM, Wifi, GPS, etc. on and off (btw, by switching Wifi off (which is on by default), I have nicely improved my battery life).
So let's start with GPRS first:
Please note that I have tried all of this with the latest ASU image only. I have not tested it on OM2007.2 or FSO. You will probably have to change some of the steps on these images.
1) Download my script package from http://www.karasuma.net/mokoservicescripts.tar.gz and transfer it to /home/root on the FR.
Please note that you'll need to install some more packages from the repositories. Unfortunately, I don't remember exactly what packages I had to install. So if one script or the other fails with an error, you probably lack one of the dependencies.
2) You need at least the following packages from the repositories:
- Code: Alles auswählen
opkg update
opkg install gpsd gsm0710muxd moko-gtk-theme moko-gtk-engine python-pygtk python-pygobject python-subprocess
As I said, some more packages might be needed...
3) With my script package, do the following:
- Code: Alles auswählen
tar -xvzf mokoservicescripts.tar.gz
cd mokoscripts
cp gprs-* /etc/ppp/ (make sure these are executable)
cp gprs /etc/ppp/peers/
cp gprs* agps* wifistatus nowifi mokoservices.py /usr/bin (make sure these are executable)
cp gtkrc /usr/share/themes/Moko/gtk-2.0/ (DON'T DO THIS IN OM2007.2)
ln -s /usr/share/themes/Moko/gtk-2.0/gtkrc /home/root/.gtkrc-2.0 (DON'T DO THIS IN OM2007.2)
cp mokoservices.png /usr/share/pixmaps/
cp mokoservices.desktop /usr/share/applications
At this point, a new icon should have appeared on your FR's screen (an old fashioned hotel bell). Don't start it yet.
4) Let's get the multiplexer working
Add gsm0710muxd to your startup services:
- Code: Alles auswählen
update-rc.d gsm0710muxd defaults 22
On reboot, the multiplexer daemon will connect to the GSM modem (under /dev/ttySAC0) and divide it from 1 hardware modem to one or several software modems under /dev/pts Don't reboot yet.
5) Tell ASU (or OM2007.2) to use the multiplexer instead of accessing the GSM Modem directly
This is the tricky part for OM2007.2 and FSO users, as I have no clue where you will have to make this change.
Under ASU, just copy from my scripts folder a new Qtopia start file:
- Code: Alles auswählen
cp 89qtopia /etc/X11/Xsession.d/
The code that has changed in this file is this (Please note that when updating the qtopia packages, this file may be overwritten again, so make sure to have a copy of the modified version at hand to get GSM working again):
- Code: Alles auswählen
identvar=$(date +%s)
ptsvar=$(dbus-send --system --print-reply --type=method_call --dest=org.pyneo.muxer /org/pyneo/Muxer org.freesmartphone.GSM.MUX.AllocChannel string:$identvar | grep string | awk -F '"' '{ print $2 }')
export QTOPIA_PHONE_DEVICE=$ptsvar
Please note that there are 3 lines only, the second one is very long and has probably been split in two by your browser.
This tells the multiplexer daemon to create a new channel under /dev/pts/ for qpe, the Qtopia GSM handler. Then we tell Qtopa to use this new channel instead of /dev/ttySAC0. Under OM2007.2 you will have to tell the same thing to gsmd. However I don't know where exactly, probably it has a config file in /etc or you can give a command line argument in its init script under /etc/init.d . Remember that you'll have to open a new channel first using the two first lines of my above code and then tell gsmd to use whatever is returned in the variable $ptsvar as serial device instead of /dev/ttySAC0. If you get this working under OM2007.2, please let me know how and I'll update the documentation.
6) Change syslog.conf (needed for the GUI)
Edit /etc/syslog.conf and replace DESTINATION="remote" by DESTINATION="file".
7) Reboot
If all went well, after a reboot, your FR should connect as usual to the GSM network. But it will in reality be connected to the multiplexer instead of the real hardware. Now we can continue and edit some of the GPRS configuration files for your needs.
8 ) GPRS configuration
Open up /etc/ppp/pap-secrets. It should look like this:
- Code: Alles auswählen
# Secrets for authentication using PAP
# client server secret IP addresses
* * * *
Replace the second and the third * by the username and password provided by your network operator. These are usually identical for all of the customers of the operator. Ask your network operator. For me (Tele2Tango Luxembourg), it is:
- Code: Alles auswählen
# Secrets for authentication using PAP
# client server secret IP addresses
"tango" * "tango" *
Copy the same information into /etc/ppp/chap-secrets
Open up /etc/ppp/peers/gprs and replace PUT_USERNAME_IN_HERE by the user name you used in the CHAP and PAP files.
Now open up /etc/ppp/gprs-connect-chat.
It should look like this:
- Code: Alles auswählen
#!/bin/sh
exec chat -v\
ABORT BUSY\
ABORT DELAYED\
ABORT "NO ANSWER"\
ABORT "NO DIALTONE"\
ABORT VOICE\
ABORT ERROR\
ABORT RINGING\
TIMEOUT 20\
"" +++\
OK ATZ\
OK ATE1\
OK AT+CFUN=1\
OK AT+COPS\
OK AT+CGDCONT=1,\"IP\",\"hspa\"\
OK ATD*99#\
CONNECT /n/d
In the third last line, replace hspa by the name of the APN of your network operator. Popular values are "hspa", "internet", "Internet". Ask your network operator. Also, you may have to modify the second last line with a different dial number (between the * and the #). Popular values are "99", "99***1" and "99***2".
9) That's it!
If all went well, you should be able to activate GPRS by typing "gprson" and deactivate it by typing "gprsoff". The easiest way to verify whether it worked is to open up the Services GUI now. If GPRS is on, the upper right button should say: "GPRS is on" and below you should see after a few seconds "0 k/ 0k" (Which is actually the amount of downloaded and uploaded data in KiB). Open up any application using Internet data and you should see the numbers rise. If it only shows k / k, then pppd is running, but the connection is dead. Try reconnecting by clicking on the GPRS button in the GUI.
Once all works, you can comfortably connect and disconnect GPRS using the Services GUI. Please note that while a GPRS connection is active, you can't suspend the FR. It will either wake up again immediately or in some cases suspend correctly, but then on wakeup, the GSM modem will be frozen and you'll have to reboot the FR to get GSM/GPRS back.
While we are at it, let's have a look at the GPS too:
Normally, you should already have all the files copied into the right places if you followed by instructions from step 3) above. As you may have noticed, the FR GPS is very slow to acquire a first fix and position. This is due to several hardware constraints. The GPS chip in the FR has no flash memory. This means everytime it is turned off, it has to perform a cold start and download all the required information from the satellites. This alone can take up to 15 minutes, depending on reception! It has a very small antenna, which also seems to be not that well soldered to the FR's board. This explains why it is a lot easier to get a quick fix using an external antenna.
Some quick physical tips first: The GPS antenna in the FR points upward. This means you have to keep the FR horizontally, screen facing the horizon, to get optimal reception and not hold it down with the screen more or less horizontally as you would instinctively do. Also, it will be quicker to get a fix if you stay still while acquiring the fix. No moving, no turning will work best.
Now besides that, how can we improve the GPS performance. As I said before, the GPS has no flash memory. It thus does not remember where the satellites were when last turned on and thus can not make any calculations on where the satellites probably are now. Instead of searching only small bits of the sky, it has to screen all of the sky anew to find any satellites. Fortunately, this can be fixed with software. That's what the agps-onlinec and agps scripts do. Please note that I got agps-onlinec from http://svn.openmoko.org/developers/matt_hsu/agps-online/ and I am not its author. What this application does, is download ephemeridis and almanac data (the stuff needed to guess where the satellites are) from u-blox (the manufacturer of the FR GPS) from the Internet and feed it to the GPS chip. The chip will then be able to do its calculation magic and get a fix much much quicker.
Note that this service is free and you can get an account by sending an empty email to agps-account at u-blox.com. You will get a username and password in return. Then edit /usr/bin/agps and replace YOUR_USERNAME_HERE and YOUR_PASSWORD_HERE by the identifiers you received. Please note that the scripts also works best if you provide it with your estimated current position and altitude (you will find my data in there). You can note these down once you get a first fix and then put them into the agps script. The last value is the precision (here 500km) of your estimation. This means that the GPS will think that you are within a 500km radius of the coordinates you gave it. This helps speed up the calculations. For now I put a large value in there, as I have no means yet of updating these coordinates by my real current position (using hints such as the GSM network used, nearby Wifi spots, etc.). For now, these settings should work to get a quicker fix for 500km around my home.
To use this from the GUI, fire up the Services GUI, activate GPRS (if you are not on a wifi or usb network), then click on the GPS button. The script will then download the latest AGPS data from the Internet (around 3k in size, valid for 4 hours), turn the GPS on and feed it the data.
After that, open up TangoGPS and wait a minute or two and you should have your fix. Please DO NOT use openmoko-agpsui. The problem with this program is that it resets the GPS when starting to monitor it, thus erasing again the AGPS data. As a consequence the AGPS trick just won't work. Stick to TangoGPS for monitoring the GPS data for now.
Well that's it! I hope it will work fine for all of you. Please let me know your comments.




