Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of football_project by
Diff: Radio.cpp
- Revision:
- 64:8886b5e4ab57
- Parent:
- 62:9b34dc1b265d
- Parent:
- 56:dccf9b22d594
- Child:
- 65:7addf8506bdb
--- a/Radio.cpp Tue Jan 19 03:03:02 2016 +0000
+++ b/Radio.cpp Tue Jan 19 03:12:17 2016 +0000
@@ -40,6 +40,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;
@@ -51,6 +56,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)
@@ -64,6 +76,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')
@@ -78,6 +94,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};
@@ -232,6 +252,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;
