
Build a Map of Local GSM Cells #61
Chapter 5, Mapping with Gadgets
|
275
HACK
($location =~ /P=(.+?) (.+?),D=(.+?),S=(.+?)/gos);
next unless $date;
# Turn the date into an RFC 2445 ICal date string.
my ($mo, $d, $y, $h, $m, $s) = split /[ \/:]/o, $date;
$date = "${y}${mo}${d}T${h}${m}${s}Z";
# Query cell ID and location area code.
$gsm->atsend( "AT+CREG?\r" );
my ($cid, $lac) = ($gsm->answer =~ /"([\dA-F]{4})"/gios);
# Query signal strength.
$gsm->atsend( "AT+CSQ\r" );
my ($signal) = ($gsm->answer =~ /(\d+)/gos);
$signal = -113 + $signal * 2;
# Print a line of data and wait.
print join(",", $date, $status, $lat, $long,
hex($cid), hex($lac), $signal), "\n";
sleep( $Rate );
}
Running the Code
As mentioned earlier, you need to have gpsd running before starting cell-
stumbler.pl. We used a Bluetooth RFCOMM serial connection to talk to a
Nokia 3650, so we had to bind an RFCOMM port first, using the six-part
Bluetooth ID of the phone. You can use
hcitool scan in Linux to search for
the Bluetooth ID of your phone. If your phone doesn’t have Bluetooth, then
you’ll need a serial cable, but you can skip the whole RFCOMM bit. You
may need to use a terminal program like minicom to poke around your sys-
tem’s serial ports to figure out which the phone is accessible on. You’ll
know it’s working when you type
AT<enter> into the terminal program, and
get an
OK from the phone in response.
Finally, assuming cellstumbler.pl ...