Index: branches/wireless/code/projects/libwireless/wireless.h
===================================================================
--- branches/wireless/code/projects/libwireless/wireless.h	(revision 1586)
+++ branches/wireless/code/projects/libwireless/wireless.h	(revision 1587)
@@ -76,6 +76,18 @@
 /**@brief high priority, handle immediately **/
 #define HIGH_PRIORITY UINT8_C(1)
 
+/**@brief packet still in sending phase **/
+#define SENDING UINT8_C(0)
+
+/**@brief packet was send successfully **/
+#define ACK_OK UINT8_C(1)
+
+/**@brief packet failure - no acknowledgment **/
+#define ACK_FAILURE UINT8_C(2)
+
+/**@brief packet failure - network too busy **/
+#define CCA_FAILURE UINT8_C(3)
+
 /**@} **/ // end defines group
 
 
@@ -112,7 +124,7 @@
 // the ack function
 
 /**@brief Returns the number of acknowledgment errors. **/
-int8_t wl_ack_error(void);
+uint8_t wl_ack_error(void);
 
 /**@brief Checks a specific packet for the acknowledgement status. **/
 int8_t wl_ack_check(uint8_t packet);
Index: branches/wireless/code/projects/libwireless/xbee.c
===================================================================
--- branches/wireless/code/projects/libwireless/xbee.c	(revision 1586)
+++ branches/wireless/code/projects/libwireless/xbee.c	(revision 1587)
@@ -59,67 +59,6 @@
 #include <string.h>
 
 
-/**@addtogroup xbee
- * @{ **/
- 
-/**@defgroup xbee_const xbee constants 
- * @{ **/
- 
-// TODO: move constants to xbee.h so they can be used publicly
-
-/**@brief The port to use the XBee from on the computer. **/
-#ifndef ROBOT
-#define XBEE_PORT_DEFAULT "/dev/ttyUSB1"
-#endif
- 
-/**@name xbee options
- * @{ **/
- 
-/**@brief Unset PAN, uses XBee default **/
-#define XBEE_PAN_DEFAULT 0xFFFF
-/**@brief Unset channel, uses XBee default **/
-#define XBEE_CHANNEL_DEFAULT 0
-/**@brief Broadcast to all robots in the PAN **/
-#define XBEE_BROADCAST 0xFFFF
-/**@brief No special options **/
-#define XBEE_OPTIONS_NONE 0x00
-/**@brief Do not receive a TX_STATUS message from this packet **/
-#define XBEE_OPTIONS_DISABLE_RESPONSE 0x01
-/**@brief Send the packet to all PANS **/
-#define XBEE_OPTIONS_BROADCAST_ALL_PANS 0x04
-/**@brief A transmit status packet **/
-#define XBEE_TX_STATUS 0x89
-/**@brief A packet received from another XBee **/
-#define XBEE_RX 0x81
-
-/**@}
- * @name xbee frame types
- * @{ **/
-
-// TODO: add comments for all of these definitions
-#define XBEE_FRAME_START 0x7E
-#define XBEE_GET_PACKET_TIMEOUT 1000
-
-/*Frame Types*/
-#define XBEE_FRAME_STATUS 0x8A
-#define XBEE_FRAME_AT_COMMAND 0x08
-#define XBEE_FRAME_AT_COMMAND_RESPONSE 0x88
-#define XBEE_FRAME_TX_REQUEST_64 0x00
-#define XBEE_FRAME_TX_REQUEST_16 0x01
-#define XBEE_FRAME_TX_STATUS XBEE_TX_STATUS
-#define XBEE_FRAME_RX_64 0x80
-#define XBEE_FRAME_RX_16 XBEE_RX
-
-/** @} **/
-
-
-// TODO: is this a good size?
-/*Buffer sizes*/
-#define XBEE_BUFFER_SIZE	128
-#define PACKET_BUFFER_SIZE	108
-
-/**@} **/ // end const group
-
 /*Internal Function Prototypes*/
 
 // TODO: convert all int references to int16_t syntax (see stdint.h)
@@ -183,6 +122,10 @@
 static volatile unsigned int xbee_address = 0;
 
 
+/**@addtogroup xbee
+ * @{ **/
+
+
 /*Function Implementations*/
 
 #ifdef ROBOT
Index: branches/wireless/code/projects/libwireless/wireless_send.c
===================================================================
--- branches/wireless/code/projects/libwireless/wireless_send.c	(revision 1586)
+++ branches/wireless/code/projects/libwireless/wireless_send.c	(revision 1587)
@@ -35,8 +35,30 @@
 
 #include "wl_defs.h"
 #include "wireless.h"
+#include <string.h>
 
 
+/* Definition for wireless library packet structure
+ * byte 1: frame number
+ * byte 2: group code 
+ * bytes 3-n: data
+ *
+ * Definition for ack buffer
+ * 2 bit system: 0=still sending
+ *               1=OK
+ *               2=ack failure
+ *               3=CCA failure
+ */
+
+
+/* global variables */
+uint8_t nextframe = 1;
+uint8_t ack_buf[64];
+
+/* private function prototypes */
+void setack(uint8_t num,uint8_t val);
+
+
 // the send functions
 
 /**
@@ -57,9 +79,42 @@
  *
  * @return positive packet number for tracking acks, or error code (TBD)
  **/
-int16_t wl_send(char *data, uint8_t length, uint8_t group, uint8_t scope, uint16_t dest, uint8_t mode) {
+int16_t wl_send(uint8_t *data, uint8_t length, uint8_t group, uint8_t scope, uint16_t dest, uint8_t mode) {
+  uint8_t packet[length+2];
+  uint8_t options = XBEE_OPTIONS_NONE;
+  int16_t ret_val = (int16_t)nextframe;
+  
+  // build packet
+  packet[0] = nextframe;
+  packet[1] = group;
+  memcpy(packet+2,data,length);
+  
+  // set options
+  if (scope == GLOBAL)
+    options &= XBEE_OPTIONS_BROADCAST_ALL_PANS;
+  if (mode == FAST) {
+    options &= XBEE_OPTIONS_DISABLE_RESPONSE;
+    ret_val = 0;
+    setack(nextframe,ACK_OK); // save in ack system
+  } else if (mode == RELIABLE) {   
+    // save in ack system
+    setack(nextframe,SENDING); // save in ack system
+  } else {
+    WL_DEBUG_PRINT("Error - bad mode in core send function\r\n");
+    return WL_ERROR_MODE;
+  }
 
-  return 0;
+  // send the packet
+  if (xbee_send_packet(packet,length,dest,options,(uint_8)ret_val) != 0) {
+    WL_DEBUG_PRINT("Error sending packet from core send function\r\n");
+    return WL_ERROR_SEND;
+  }
+  
+  // increment frame number
+  nextframe = (nextframe == 0xFF)?1:nextframe+1;
+    
+
+  return ret_val; // return frame number for ack tracking
 }
 
 /**
@@ -129,23 +184,38 @@
  *
  * @return the # of packets lost (up to 255)
  **/
-int8_t wl_ack_error(void) {
+uint8_t wl_ack_error(void) {
+  uint_8 val=0,i=1;
+  
+  while(1) {
+    if (ack_buf[i/4]&(0x3<<(i%4)) != 0)
+      val++;
+    if (i==255)
+      break;
+    i++;
+  }
 
-  return 0;
+  return val;
 }
 
 /**
  * acknowledgement error check
  * check if a specific packet has been lost
- * note: buffer will overflow ever 255 packets
+ * note: buffer will overflow every 255 packets
  * 
- * @param packet number
+ * @param packet packet number
  *
- * @return 0=still sending,1=ack received,-1=ack failure
+ * @return {SENDING,ACK_OK,ACK_FAILURE,CCA_FAILURE}
  **/
 int8_t wl_ack_check(uint8_t packet) {
-
-	return 0;
+  if (packet == 0) {
+    // no ack information here
+    WL_DEBIG_PRINT("packet number cannot be 0\r\n");
+    return WL_ERROR_ARGUMENT;
+  }
+  
+  // check ack
+  return ack_buf[packet/4]&(0x3<<(packet%4));
 }
 
 /**
@@ -153,7 +223,7 @@
  * reset the acknowledgement buffer
  **/
 void wl_ack_reset(void) {
-
+  memset(ack_buf,0,64);
 }
 
 
@@ -162,5 +232,26 @@
 
 // Define all private functions down here
 
+/*
+ * sets 2 bits in the ack_buf
+ *
+ * @param num the ack number
+ * @param val {SENDING,ACK_OK,ACK_FAILURE,CCA_FAILURE}
+ */
+void setack(uint8_t num,uint8_t val) {
+  switch(num%4) {
+  case 0:
+    ack_buf[num/4] &= (0xFC|val);
+    break;
+  case 1:
+    ack_buf[num/4] &= (0xF3|(val<<2));
+    break;
+  case 2:
+    ack_buf[num/4] &= (0xCF|(val<<4));
+    break;
+  case 3:
+    ack_buf[num/4] &= (0x3F|(val<<6));
+    break;
+  }
+}
 
-
Index: branches/wireless/code/projects/libwireless/wl_defs.h
===================================================================
--- branches/wireless/code/projects/libwireless/wl_defs.h	(revision 1586)
+++ branches/wireless/code/projects/libwireless/wl_defs.h	(revision 1587)
@@ -93,13 +93,13 @@
 #define WL_ERROR_BAD_GROUP INT8_C(-11)
 
 /** @brief Error code for a bad scope **/
-#define WL_ERROR_SCOPE INIT8_C(-12)
+#define WL_ERROR_SCOPE INT8_C(-12)
 
 /** @brief Error code for a bad robot address **/
-#define WL_ERROR_ADDRESS INIT8_C(-13)
+#define WL_ERROR_ADDRESS INT8_C(-13)
 
 /** @brief Error code for a bad mode **/
-#define WL_ERROR_MODE INIT8_C(-14)
+#define WL_ERROR_MODE INT8_C(-14)
 
 
 /**@} */ // end error group
Index: branches/wireless/code/projects/libwireless/xbee.h
===================================================================
--- branches/wireless/code/projects/libwireless/xbee.h	(revision 1586)
+++ branches/wireless/code/projects/libwireless/xbee.h	(revision 1587)
@@ -54,7 +54,71 @@
  * @{
  **/
  
+ /**@defgroup xbee_const xbee constants 
+  * @brief These are constants used for the xbee module.
+  * @{ **/
  
+// TODO: move constants to xbee.h so they can be used publicly
+
+/**@brief The port to use the XBee from on the computer. **/
+#ifndef ROBOT
+#define XBEE_PORT_DEFAULT "/dev/ttyUSB1"
+#endif
+ 
+/**@name xbee options
+ * @{ **/
+ 
+/**@brief Unset PAN, uses XBee default **/
+#define XBEE_PAN_DEFAULT 0xFFFF
+/**@brief Unset channel, uses XBee default **/
+#define XBEE_CHANNEL_DEFAULT 0
+/**@brief Broadcast to all robots in the PAN **/
+#define XBEE_BROADCAST 0xFFFF
+/**@brief No special options **/
+#define XBEE_OPTIONS_NONE 0x00
+/**@brief Do not receive a TX_STATUS message from this packet **/
+#define XBEE_OPTIONS_DISABLE_RESPONSE 0x01
+/**@brief Send the packet to all PANS **/
+#define XBEE_OPTIONS_BROADCAST_ALL_PANS 0x04
+/**@brief A transmit status packet **/
+#define XBEE_TX_STATUS 0x89
+/**@brief A packet received from another XBee **/
+#define XBEE_RX 0x81
+
+/**@}
+ * @name xbee frame types
+ * @{ **/
+
+// TODO: add comments for all of these definitions
+#define XBEE_FRAME_START 0x7E
+#define XBEE_GET_PACKET_TIMEOUT 1000
+
+/*Frame Types*/
+#define XBEE_FRAME_STATUS 0x8A
+#define XBEE_FRAME_AT_COMMAND 0x08
+#define XBEE_FRAME_AT_COMMAND_RESPONSE 0x88
+#define XBEE_FRAME_TX_REQUEST_64 0x00
+#define XBEE_FRAME_TX_REQUEST_16 0x01
+#define XBEE_FRAME_TX_STATUS XBEE_TX_STATUS
+#define XBEE_FRAME_RX_64 0x80
+#define XBEE_FRAME_RX_16 XBEE_RX
+
+/** @} **/
+
+
+// TODO: is this a good size?
+/*Buffer sizes*/
+#define XBEE_BUFFER_SIZE	128
+#define PACKET_BUFFER_SIZE	108
+
+/**@} **/ // end const group
+ 
+/**
+ * @defgroup xbee_funcs Xbee Functions
+ * @brief These are the public xbee functions.
+ * @{
+ **/
+  
 // TODO: convert all int references to int16_t syntax (see stdint.h)
 
 /**@brief Initialize the XBee library **/
@@ -80,6 +144,8 @@
 /**@brief Reset XBee **/
 int xbee_reset(void);
 
-/**@}**/ //end defgroup
+/**@} **/ //end xbee_funcs group
 
+/**@} **/ //end defgroup
+
 #endif
