Abstraction for the glider class

Dependents:   DropTest

Revision:
1:7039ae86fe70
Parent:
0:4e6b53a7bd38
Child:
2:cc07e65227ff
--- a/Glider.cpp	Sun Apr 09 05:05:52 2017 +0000
+++ b/Glider.cpp	Mon Apr 10 17:33:41 2017 +0000
@@ -1,10 +1,14 @@
 #include "Glider.h"
 
-Glider::Glider(Serial* device, PinName sda, PinName scl) {
+Glider::Glider(Serial* device, PinName sda, PinName scl, PinName tx, PinName rx) {
+    startTime = time(NULL);
     dev = device;
-    dev->printf("constructing glider...");  
-    heading = 0; 
-    telemetry = "hello";
+    xbee = new Serial(tx, rx);
+    dev->printf("constructing glider...");
+    heading = 0.0;
+    pressure = 0.0;
+    temp = 0.0;
+    alt = 0.0;
     hmc = new HMC5883L(sda, scl);
     bmp = new BMP180(sda, scl);
     bmp->Initialize(1013.25, BMP180_OSS_ULTRA_LOW_POWER);
@@ -18,8 +22,18 @@
     bmp->ReadData(&this->temp, &this->pressure, &this->alt);
 }
 
+void Glider::setMissionTime() {
+    this->missionTime = time(NULL) - this->startTime;
+}
+
 void Glider::saveTelem() {
      FILE *fp = fopen("/telem/telem.txt", "w");
      fprintf(fp, "hello,");
-     fclose(fp);  
-}
\ No newline at end of file
+     fclose(fp);
+}
+
+void Glider::transmitPacket() {
+    //TODO: transmit mission time, packet count, alt, pressure, speed
+            //temp, voltage, state
+    xbee->printf("3387, GLIDER, %f, %d\r\n", this->heading, this->missionTime);
+}