Prosper Van / xbeeCom

Fork of com by Prosper Van

Files at this revision

API Documentation at this revision

Comitter:
oprospero
Date:
Tue Apr 22 06:28:49 2014 +0000
Parent:
4:f8e953201251
Child:
6:4d96c8776442
Commit message:
fixed previous commit. Added txQueue initialization

Changed in this revision

com.cpp Show annotated file Show diff for this revision Revisions of this file
com.h Show annotated file Show diff for this revision Revisions of this file
--- a/com.cpp	Tue Apr 22 05:43:33 2014 +0000
+++ b/com.cpp	Tue Apr 22 06:28:49 2014 +0000
@@ -31,6 +31,7 @@
     xbeeTx.baud(BAUDRATE);                    // Setup the serial baud rate.
     xbeeRx.baud(BAUDRATE);                    // Setup the serial baud rate.
     rxBuffer = new queue();                 // Point to the rxQueue.
+    txBuffer = new queue();
     signalStrength = 0;
     xbeeRx.attach( this, &com::callback );    // Set callback as the interrupt handler. 
     #ifdef DEBUG
@@ -95,20 +96,25 @@
     }
 }
 
-/*************************** char read()  ********************************/
+/*************************** char ackCheck()  ********************************/
 /*                                                                       */
 /*************************************************************************/
 
 void com::ackCheck()
 {
-    if( !txBuffer->isEmpty())
+    if( !txBuffer->isEmpty() && xbeeTx.writeable())
     {
-        short * pkt = rxBuffer->pop();
-        write(pkt[0],pkt[1]);
+        short * pkt = txBuffer->pop();
+        write(pkt[0],pkt[1]); //may need to disable interrupt
+        delete[] pkt;
     }
         
 }
 
+bool com::rdy2ack()
+{
+    return !txBuffer->isEmpty();
+}
 
 /*************************** char read()  ********************************/
 /*                                                                       */
--- a/com.h	Tue Apr 22 05:43:33 2014 +0000
+++ b/com.h	Tue Apr 22 06:28:49 2014 +0000
@@ -32,6 +32,7 @@
         short * read();             // Read from the queue.
         void setAPImode(bool mode);
         void ackCheck();
+        bool rdy2ack();
         
     private:         
         Serial xbeeTx;                // tx - DIN, rx - DOUT