;Logfile
logfile='signal_strength.log'

;Ask for com port and set connect string 
inputbox 'Com Port ?' 'Com Port'
cmprt=inputstr
cntstring='/C='
strconcat cntstring cmprt
connect cntstring

fileopen fhandle logfile 0





;Ask for signal poll duraction and set variable 
inputbox 'signal poll interval (minutes) ?' 'Signal Poll Duration'

str2int siginterval inputstr
siginterval=siginterval*60

filewriteln fhandle 'Signal Strength 0= None 5= Best,,'
filewriteln fhandle '***********************************,,'
filewriteln fhandle 'Signal, Time, Date'
filewriteln fhandle '***********************************,,'
fileclose fhandle


:SigStrength
fileopen fhandle logfile 1

sendln 'at+CSQ'
wait '+CSQ:5' '+CSQ:4' '+CSQ:3' '+CSQ:2' '+CSQ:1' '+CSQ:0' 'ERROR'

if result = 1 goto sig5
if result = 2 goto sig4
if result = 3 goto sig3
if result = 4 goto sig2
if result = 5 goto sig1
if result = 6 goto sig0


:sig5

filewrite fhandle '5,'
goto timeStamp


:sig4

filewrite fhandle '4,'
goto timeStamp

:sig3

filewrite fhandle '3,'
goto timeStamp

:sig2

filewrite fhandle '2,'
goto timeStamp

:sig1

filewrite fhandle '1,'
goto timeStamp

:sig0

filewrite fhandle '0,'
goto timeStamp

:error

filewrite fhandle 'error - logging stopped'
fileclose fhandle

end

:timeStamp


getdate date
gettime time
filewrite fhandle time
filewrite fhandle ','
filewriteln fhandle date
fileclose fhandle
pause siginterval

goto SigStrength



end

