Index: wl_token_ring.c
===================================================================
--- wl_token_ring.c	(revision 1455)
+++ wl_token_ring.c	(revision 1456)
@@ -35,7 +35,6 @@
 #include <wl_token_ring.h>
 
 #include <stdlib.h>
-#include <stdio.h>
 
 #include <wl_defs.h>
 #include <wireless.h>
@@ -107,9 +106,11 @@
 // the amount of time a robot has had its BOM on for
 static int bom_on_count = 0;
 
-#ifndef ROBOT
+#if (!(defined ROBOT)) || (defined FIREFLY)
 static void do_nothing(void) {}
-static int get_nothing(void) {return -1;}
+static SensorReading get_nothing(void) { SensorReading ret = { READING_UNKNOWN, READING_UNKNOWN }; return ret;}
+#else
+static SensorReading default_get_bom(void) { int dist, dir; bom_refresh(BOM_ALL); dir = bom_get_max10(&dist); SensorReading ret = { dir, dist}; return ret; }
 #endif
 
 #ifdef ROBOT
@@ -116,16 +117,16 @@
 #ifndef FIREFLY
 static void (*bom_on_function) (void) = bom_on;
 static void (*bom_off_function) (void) = bom_off;
-static int (*get_max_bom_function) (void) = get_max_bom;
+static SensorReading (*get_max_bom_function) (void) = default_get_bom;
 #else
 static void (*bom_on_function) (void) = do_nothing;
 static void (*bom_off_function) (void) = do_nothing;
-static int (*get_max_bom_function) (void) = get_nothing;
+static SensorReading (*get_max_bom_function) (void) = get_nothing;
 #endif
 #else
 static void (*bom_on_function) (void) = do_nothing;
 static void (*bom_off_function) (void) = do_nothing;
-static int (*get_max_bom_function) (void) = get_nothing;
+static SensorReading (*get_max_bom_function) (void) = get_nothing;
 #endif
 
 static PacketGroupHandler wl_token_ring_handler =
@@ -211,7 +212,7 @@
  * measurement of the maximum BOM reading is needed.
  **/
 void wl_token_ring_set_bom_functions(void (*on_function) (void),
-	void (*off_function) (void), int (*max_bom_function) (void))
+	void (*off_function) (void), SensorReading (*max_bom_function) (void))
 {
 	bom_on_function = on_function;
 	bom_off_function = off_function;
@@ -344,7 +345,7 @@
  * @return a BOM reading from robot source to robot dest,
  * in the range 0-15, or -1 if it is unknown
  **/
-int wl_token_get_sensor_reading(int source, int dest)
+SensorReading * wl_token_get_sensor_reading(int source, int dest)
 {
 	if (wl_token_is_robot_in_ring(dest) &&
 			(source == wl_get_xbee_id() || wl_token_is_robot_in_ring(source))) {
@@ -351,7 +352,7 @@
 		return sensor_matrix_get_reading(source, dest);
 	}
 
-	return -1;
+	return NULL;
 }
 
 /**
@@ -364,7 +365,7 @@
  **/
 //TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
 // it reduces code size or not should be done to be sure.
-int wl_token_get_my_sensor_reading(int dest)
+SensorReading * wl_token_get_my_sensor_reading(int dest)
 {
 	return wl_token_get_sensor_reading(wl_get_xbee_id(), dest);
 }
@@ -530,6 +531,7 @@
 {
 	int i, j;
 	char nextRobot;
+	SensorReading r;
 
 	bom_on_count = -1;
 	deathDelay = -1;
@@ -549,7 +551,7 @@
 		}
 
 		//set the sensor information we receive
-		if (j < sensorDataLength / 2 && sensorData[2 * j] == i)
+		if (j < sensorDataLength / 2 && sensorData[3 * j] == i)
 		{
 			//the robot we were going to accept has already been accepted
 			if (accepted == i)
@@ -557,8 +559,9 @@
 				accepted = -1;
 				WL_DEBUG_PRINT("Someone accepted the robot we did.\r\n");
 			}
-			sensor_matrix_set_reading(source, i,
-						sensorData[2 * j + 1]);
+			r.dir = sensorData[3 * j + 1];
+			r.dist = sensorData[3 * j + 2];
+			sensor_matrix_set_reading(source, i, r);
 			if (!sensor_matrix_get_in_ring(i))
 			{
 				WL_DEBUG_PRINT("Robot ");
@@ -669,7 +672,7 @@
 {
 	char nextRobot = 0xFF;
 	int i = wl_get_xbee_id() + 1;
-	char buf[2 * sensor_matrix_get_size()];
+	char buf[3 * sensor_matrix_get_size()];
 	if (accepted == -1)
 	{
 		while (1)
@@ -708,13 +711,15 @@
 	for (i = 0; i < sensor_matrix_get_size(); i++) {
 		if (sensor_matrix_get_in_ring(i) && i != wl_get_xbee_id())
 		{
-			buf[2*j] = i;
-			buf[2*j + 1] = sensor_matrix_get_reading(wl_get_xbee_id(), i);
+			SensorReading *r = sensor_matrix_get_reading(wl_get_xbee_id(), i);
+			buf[3*j] = i;
+			buf[3*j + 1] = r->dir;
+			buf[3*j + 2] = r->dist;
 			j++;
 		}
 	}
 
-	int packetSize = 2 * j * sizeof(char);
+	int packetSize = 3 * j * sizeof(char);
 	WL_DEBUG_PRINT("Passing the token to robot ");
 	WL_DEBUG_PRINT_INT(nextRobot);
 	WL_DEBUG_PRINT(".\r\n");
@@ -738,7 +743,7 @@
  **/
 static void wl_token_bom_on_receive(int source)
 {
-	int max, dist;
+	SensorReading r;
 
 	WL_DEBUG_PRINT("Robot ");
 	WL_DEBUG_PRINT_INT(source);
@@ -746,14 +751,14 @@
 
 	bom_on_count = 0;
 
-	max = get_max_bom_function();
+	r = get_max_bom_function();
 	sensor_matrix_set_reading(wl_get_xbee_id(),
-		source, max);
+		source, r);
 
 	WL_DEBUG_PRINT("Max: ");
-	WL_DEBUG_PRINT_INT(max);
-	WL_DEBUG_PRINT("\tVar: ");
-	WL_DEBUG_PRINT_INT(dist);
+	WL_DEBUG_PRINT_INT(r.dir);
+	WL_DEBUG_PRINT("\tDist: ");
+	WL_DEBUG_PRINT_INT(r.dist);
 	WL_DEBUG_PRINT("\n\n");
 }
 
