3 # Send a NMEA dump to the Android emulator.
5 # Example: AndroidMockLocation.pl test.nmea 127.0.0.1:5554
12 die "Usage: AndroidMockLocation.pl FILE.nmea HOST:PORT\n"
15 my ($path, $address) = @ARGV;
17 open FILE
, "<$path" or die "Failed to open $path: $!\n";
19 my $socket = new IO
::Socket
::INET
(PeerAddr
=> $address);
20 die "Failed to connect to emulator: $!\n" unless defined $socket;
27 if (/^\$..GGA,(\d+)/) {
29 unless ($new_time eq $time) {
30 # sleep for a second when the time stamp has been updated
34 } elsif (/^\$..RMC,/) {
36 # the Android emulator understands only GPGGA and GPRMC
40 my $line = "geo nmea $_";
42 $socket->syswrite($line) or die $!;
43 my $response = $socket->getline;
44 die $response unless $response =~ /^OK/;