Skip to content

Commit

Permalink
finished moving sensornet to octal addressing
Browse files Browse the repository at this point in the history
  • Loading branch information
maniacbug committed Jun 14, 2011
1 parent 2f6eb06 commit 59c6296
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
5 changes: 3 additions & 2 deletions examples/sensornet/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -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) ;
Expand Down Expand Up @@ -90,7 +90,8 @@ actions GitVersion
echo "\";" >> $(<)
}

GitVersion version.h ;
# Broken :(
#GitVersion version.h ;

rule AvrCc
{
Expand Down
9 changes: 7 additions & 2 deletions examples/sensornet/nodeconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <WProgram.h>
#include <avr/eeprom.h>
#include <avr/pgmspace.h>
#include "nodeconfig.h"

// Avoid spurious warnings
#undef PROGMEM
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions examples/sensornet/sensornet.pde
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ 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;

// 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;

Expand All @@ -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);

//
Expand All @@ -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;
Expand All @@ -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();
Expand Down

0 comments on commit 59c6296

Please sign in to comment.