Last active
November 7, 2017 12:25
-
-
Save dutchLuck/2e2d5cbb8f26b5357711b9bafbc0da79 to your computer and use it in GitHub Desktop.
Test the feasibility of remotely obtaining GPS information from an Android phone with RFO BASIC! interpreter installed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REM Start of BASIC! Program | |
prgName$="GPS Server" | |
prgVer$="2" | |
! Set Update interval to 2 sec & Server port to 52345 | |
intrvl=2000 | |
srvrSckt=52345 | |
! | |
verNum=val(version$()) | |
GPS.open stts, intrvl | |
if stts <> 1 | |
print "GPS Open failed & returned error: "+GetError$() | |
else | |
! GPS opened OK so keep wifi on & start server | |
wifilock 2 % 2 Maintains normal operation | |
socket.server.create srvrSckt | |
socket.myip ipaddrss$ | |
sScktStr$=format_using$("","%d",int(srvrSckt)) | |
print "My IP Address is; - "+ipaddrss$, "Port ; - "+sScktStr$ | |
prgTitle$=prgName$+" "+prgVer$ | |
console.title prgTitle$+" - "+ipaddrss$+":"+sScktStr$ | |
! Save phone power: allow Screen to blank but no CPU sleeping | |
wakelock 1 % 1 Allows screen to blank, 2 allows screen to dim | |
processingTime = 0 | |
for cnt=1 to 1800 | |
pause intrvl - processingTime | |
strtProcTime = clock() | |
GPS.location tme, prvdr$, satcnt, accrcy, lttd, lngtd, alttd, br, spd | |
msg$=format_using$("","%d, ",int(cnt)) | |
if prvdr$ <> "gps" | |
msg$=msg$+"GPS not available" | |
else | |
msg$=msg$+using$(, "%tT, %s, %d", int(tme), prvdr$, int(satcnt)) | |
msg$=msg$+", "+str$(accrcy)+", "+str$(lttd)+", "+str$(lngtd) | |
msg$=msg$+", "+str$(alttd)+", "+str$(br)+", "+str$(spd) | |
endif | |
if !background() then print msg$ | |
socket.server.status ssstts | |
if ssstts <> 3 | |
socket.server.connect 0 | |
socket.server.status ssstts | |
endif | |
if ssstts = 3 then socket.server.write.line msg$ | |
processingTime = clock() - strtProcTime | |
next cnt | |
! Clean up & exit | |
wakelock 5 % Release lock | |
socket.server.close | |
wifilock 4 % Release lock | |
GPS.close | |
endif | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The output of the gps_server.bas program on the Android phone, (which has IP address 10.0.0.46) can be obtained remotely with any program that can open port 52345 on 10.0.0.46 - for instance on linux (or cygwin on windows); -
gawk 'BEGIN {s="/inet/tcp/0/10.0.0.46/52345";while((s|&getline)>0)print$0;close(s)}'
The format of the output is comma separated columns; -
index, time, location source, satellite count, accuracy, latitude, longitude, altitude, bearing, speed
For example; -
7, 22:55:49, gps, 9, 10.0, -30.00000021272361, 140.00000073167312, 65.0000244140625, 40.0, 0.0
8, 22:55:51, gps, 9, 10.0, -30.00000021272361, 140.00000073167312, 65.0000244140625, 40.0, 0.0
9, 22:55:53, gps, 9, 10.0, -30.00000021272361, 140.00000073167312, 65.0000244140625, 40.0, 0.0