4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include "Tracking/LiveTrack24.hpp"
25 #include "Net/Init.hpp"
26 #include "Time/BrokenDateTime.hpp"
27 #include "Units/System.hpp"
28 #include "OS/Args.hpp"
29 #include "DebugReplay.hpp"
33 using namespace LiveTrack24
;
36 TestTracking(int argc
, char *argv
[])
38 Args
args(argc
, argv
, "[DRIVER] FILE [USERNAME [PASSWORD]]");
39 DebugReplay
*replay
= CreateDebugReplay(args
);
45 tstring username
, password
;
51 username
= args
.ExpectNextT();
52 password
= args
.IsEmpty() ? _T("") : args
.ExpectNextT();
54 user_id
= LiveTrack24::GetUserID(username
.c_str(), password
.c_str());
55 has_user_id
= (user_id
!= 0);
58 SessionID session
= has_user_id
?
59 GenerateSessionID(user_id
) : GenerateSessionID();
60 printf("Generated session id: %u\n", session
);
63 printf("Starting tracking ... ");
64 bool result
= StartTracking(session
, username
.c_str(), password
.c_str(), 10,
65 VehicleType::GLIDER
, "Hornet");
66 printf(result
? "done\n" : "failed\n");
70 BrokenDate now
= BrokenDate::TodayUTC();
72 printf("Sending positions ");
73 unsigned package_id
= 2;
74 while (replay
->Next()) {
75 if (package_id
% 10 == 0) {
79 const MoreData
&basic
= replay
->Basic();
81 const BrokenTime time
= basic
.date_time_utc
;
82 BrokenDateTime
datetime(now
.year
, now
.month
, now
.day
, time
.hour
,
83 time
.minute
, time
.second
);
85 result
= SendPosition(
86 session
, package_id
, basic
.location
, (unsigned)basic
.nav_altitude
,
87 (unsigned)Units::ToUserUnit(basic
.ground_speed
, Unit::KILOMETER_PER_HOUR
),
88 basic
.track
, datetime
.ToUnixTimeUTC());
95 printf(result
? "done\n" : "failed\n");
97 printf("Stopping tracking ... ");
98 result
= EndTracking(session
, package_id
);
99 printf(result
? "done\n" : "failed\n");
105 main(int argc
, char *argv
[])
109 LiveTrack24::SetServer(_T("test.livetrack24.com"));
110 bool result
= TestTracking(argc
, argv
);
114 return result
? EXIT_SUCCESS
: EXIT_FAILURE
;