git.haldean.org droidcopter / 9253550
Probably fixed heartbeat. Needs testing Ben 11 years ago
3 changed file(s) with 16 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
Binary diff not shown
143143 Log.i(TAG, "Connection established");
144144
145145 /* Initializes heartbeat protocol */
146 mHeartbeat.cancel();
147 mCountdown.purge();
148 //mCountdown.cancel();
149 //mCountdown = new Timer();
150 mCountdown.schedule(mHeartbeat, FIRST_PULSE);
146 resetHeartbeat(FIRST_PULSE);
151147 startReading();
152148 }
153149 /* Something's wrong with the internet connection. Try again soon. */
362358 if (parts[1].equals("PULSE")) {
363359 sendMessage(msg);
364360 //Reset the heartbeat countdown
365 mHeartbeat.cancel();
366 mCountdown.purge();
367 //mCountdown.cancel();
368 //mCountdown = new Timer();
369 mCountdown.schedule(mHeartbeat, PULSE_RATE);
361 resetHeartbeat(PULSE_RATE);
370362 return true;
371363 }
372364 }
378370
379371 }
380372 return false;
373 }
374
375 private void resetHeartbeat(int newTime) {
376 mHeartbeat.cancel();
377 mCountdown.purge();
378 mHeartbeat = new TimerTask() {
379 public void run() {
380 updateReceivers("CSYS:NOCONN");
381 }
382 };
383 //mCountdown.cancel();
384 //mCountdown = new Timer();
385 mCountdown.schedule(mHeartbeat, newTime);
381386 }
382387
383388 /** Spawns a thread that starts reading from the text socket. */
150150 /*String taskList = "{ { VEL!0!10!0!0!300 VEL!5!10!5!10!180 } " +
151151 "{ DEST!300!-74.012345!40.74!10!100 { DEST!300!-77.07950!38.97300!100!250 " +
152152 " DEST!587!-117.15!32.72!10!600 } } }";*/
153 String taskList = "{ VEL!0!0!0!180!600 }";
153 String taskList = "{ VEL!1!2!3!180!600 }";
154154 setTask(BASIC_AUTO, taskList);
155155 updateStatus(BASIC_AUTO);
156156 autoPilot(true);