Andriy Makukha / Mbed 2 deprecated football_project_wo_output

Dependencies:   mbed

Fork of football_project by MZJ

Revision:
56:dccf9b22d594
Parent:
44:4ad6133987ed
Child:
64:8886b5e4ab57
--- a/Radio.cpp	Sat Jan 09 21:46:34 2016 +0000
+++ b/Radio.cpp	Tue Jan 12 08:12:55 2016 +0000
@@ -45,6 +45,11 @@
     int mac;    
 };
 
+int get_node_id()
+{
+    return my_node_id == RADIO_STARTUP_ID ? 0 : my_node_id;    
+}
+
 static node_id_mapping nodes[10] = {0};
 static int node_idx = 0;
 static int my_mac = 0;
@@ -56,6 +61,13 @@
   radio.promiscuous(promiscuousMode);
 }
 
+/* Gets the node ID which is associated with the
+ * given mac. If no ID has been given then zero
+ * is returned.
+ *
+ * @param mac - the mac address if the cone
+ * @returns ID if found else zero 
+ */
 static int get_node_id(int mac)
 {
     for (int i = 0; i < node_idx; ++i)
@@ -69,6 +81,10 @@
     return 0;    
 }
 
+/* Process a radio startup message from the master.
+ * 
+ * @param em - the message from the master
+ */
 static void slave_process(extended_message *em)
 {
     if (em->m.command == 'R')
@@ -83,6 +99,10 @@
     }
 }
 
+/* Process a radio startup message from a slave.
+ *
+ * @param m - the message from the slave
+ */
 static void master_process(Message *m)
 {
     byte payload[10] = {0};
@@ -237,6 +257,14 @@
     return radio.ACKReceived(cone);
 }
 
+/* This is only needed for the slave cones, the master
+ * cone will just return.
+ *
+ * If the slave cone doesn't have a valid node ID send out
+ * the node ID request message to the master cone.
+ *
+ * @param mac - the mac address for this cone (currently the first two bytes)
+ */
 void radio_loop(int mac)
 {
     static unsigned long last_send = 0L;