INCLUDE rtcu.inc
VAR_OUTPUT
gsmConnect : BOOL;
gpsValid : BOOL;
END_VAR;
PROGRAM GPS_Example;
VAR
sms : gsmIncomingSMS;
gps : gpsFix;
gc : gpsDistanceX;
str : STRING;
awaitFix : BOOL;
END_VAR;
gpsPower(power:=TRUE);
gsmPower(power:=TRUE);
BEGIN
sms();
gps();
IF gps.mode > 1 THEN
gc(latitude1:=55513078, longitude1:=9510530, latitude2:=gps.latitude, longitude2:=gps.longitude);
str:=strFormat(format:="Distance to Logic IO=\4.\3 KM, bearing=\2 deg", v4:=gc.distance/1000, v3:=INT(gc.distance MOD 1000), v2:=gc.bearing);
DebugMsg(message:=str);
END_IF;
IF sms.status>0 THEN
awaitFix:=TRUE;
END_IF;
IF awaitFix AND gps.mode > 1 THEN
awaitFix:=false;
gsmSendSMS(phonenumber:=sms.phonenumber, message:=str);
END_IF;
gsmConnect:=gsmConnected();
gpsValid := gps.mode > 1;
END;
END_PROGRAM;
|