From 59c6296ccd2650ec1493917c8aa08830f3f18833 Mon Sep 17 00:00:00 2001 From: maniacbug Date: Mon, 13 Jun 2011 18:31:24 -0700 Subject: [PATCH] finished moving sensornet to octal addressing --- examples/sensornet/Jamfile | 5 +++-- examples/sensornet/nodeconfig.cpp | 9 +++++++-- examples/sensornet/sensornet.pde | 10 +++++----- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/examples/sensornet/Jamfile b/examples/sensornet/Jamfile index 312776be..afbd4376 100644 --- a/examples/sensornet/Jamfile +++ b/examples/sensornet/Jamfile @@ -37,7 +37,7 @@ AVR_LD = $(AVR_TOOLS_PATH)/avr-gcc ; AVR_OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy ; AVRDUDE = $(AVR_TOOLS_PATH)/avrdude ; -DEFINES = F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) VERSION_H ; +DEFINES = F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) ; CTUNING = -ffunction-sections -fdata-sections ; CXXTUNING = -fno-exceptions -fno-strict-aliasing ; CFLAGS = -Os -Werror -Wall -Wextra -mmcu=$(MCU) $(CTUNING) ; @@ -90,7 +90,8 @@ actions GitVersion echo "\";" >> $(<) } -GitVersion version.h ; +# Broken :( +#GitVersion version.h ; rule AvrCc { diff --git a/examples/sensornet/nodeconfig.cpp b/examples/sensornet/nodeconfig.cpp index 8a56b1d2..b57c1c08 100644 --- a/examples/sensornet/nodeconfig.cpp +++ b/examples/sensornet/nodeconfig.cpp @@ -9,6 +9,7 @@ #include #include #include +#include "nodeconfig.h" // Avoid spurious warnings #undef PROGMEM @@ -36,7 +37,11 @@ uint8_t nodeconfig_read(void) } else { - printf_P(PSTR("*** No valid address found. Send 1-9 via serial to set node address\n\r")); + printf_P(PSTR("*** No valid address found. Send 0-9 via serial to set node address\n\r")); + while(1) + { + nodeconfig_listen(); + } } return result; @@ -51,7 +56,7 @@ void nodeconfig_listen(void) { // If the character on serial input is in a valid range... char c = Serial.read(); - if ( c >= '1' && c <= '9' ) + if ( c >= '0' && c <= '9' ) { // It is our address eeprom_write_byte(address_at_eeprom_location,valid_eeprom_flag); diff --git a/examples/sensornet/sensornet.pde b/examples/sensornet/sensornet.pde index aa5de979..224c51a9 100644 --- a/examples/sensornet/sensornet.pde +++ b/examples/sensornet/sensornet.pde @@ -53,7 +53,7 @@ RF24 radio(8,9); RF24Network network(radio); // Our node address -uint16_t this_node = -1; +uint16_t this_node; // The message that we send is just a ulong, containing the time unsigned long message; @@ -61,7 +61,7 @@ unsigned long message; // Sleep constants. In this example, the watchdog timer wakes up // every 1s, and every 4th wakeup we power up the radio and send // a reading. In real use, these numbers which be much higher. -// Try wdt_8s and 7 cycles for one reading per minute. +// Try wdt_8s and 7 cycles for one reading per minute.> 1 const wdt_prescalar_e wdt_prescalar = wdt_1s; const short sleep_cycles_per_transmission = 4; @@ -88,7 +88,7 @@ void setup(void) // // Only the leaves sleep. - if ( this_node > 1 ) + if ( this_node > 0 ) Sleep.begin(wdt_prescalar,sleep_cycles_per_transmission); // @@ -106,7 +106,7 @@ void loop(void) network.update(); // If we are the base, is there anything ready for us? - while ( this_node == 1 && network.available() ) + while ( this_node == 0 && network.available() ) { // If so, grab it and print it out RF24NetworkHeader header; @@ -115,7 +115,7 @@ void loop(void) } // If we are not the base, send sensor readings to the base - if ( this_node > 1 ) + if ( this_node > 0 ) { // Take a 'reading'. Just using the millis() clock for an example 'reading' message = millis();