Update WP examples

This commit is contained in:
Felix Rusu 2013-11-12 20:22:16 -05:00
parent b5e9bc8ad6
commit 7cae6d51c3
2 changed files with 34 additions and 18 deletions

View File

@ -17,6 +17,7 @@
// The handshake protocol that receives the sketch from the serial port
// is handled by the SPIFLash/WirelessHEX69 library, which also relies on the RFM12B library
// These libraries and custom 1k Optiboot bootloader for the target node are at: http://github.com/lowpowerlab
#include <RFM69.h>
#include <SPI.h>
#include <SPIFlash.h>
@ -25,12 +26,16 @@
#define MYID 1 // node ID used for this unit
#define TARGET_ID 55 // ID of node being wirelessly reprogrammed
#define NETWORKID 250
#define FREQUENCY RF69_915MHZ // Match this with the version of your Moteino! (others: RF69_433MHZ, RF69_868MHZ)
//Match frequency to the hardware version of the radio on your Moteino (uncomment one):
//#define FREQUENCY RF69_433MHZ
//#define FREQUENCY RF69_868MHZ
#define FREQUENCY RF69_915MHZ
//#define IS_RFM69HW //uncomment only for RFM69HW! Leave out if you have RFM69W!
#define LED 9
#define SERIAL_BAUD 115200
#define ACK_TIME 50 // # of ms to wait for an ack
#define TIMEOUT 3000
#define KEY "thisIsEncryptKey"
#define ENCRYPTKEY "sampleEncryptKey"
RFM69 radio;
char c = 0;
@ -39,7 +44,10 @@ char input[64]; //serial input buffer
void setup(){
Serial.begin(SERIAL_BAUD);
radio.initialize(FREQUENCY,MYID,NETWORKID);
//radio.encrypt(KEY); //OPTIONAL
//radio.encrypt(ENCRYPTKEY); //OPTIONAL
#ifdef IS_RFM69HW
radio.setHighPower(); //only for RFM69HW!
#endif
Serial.print("Start wireless gateway...");
}
@ -75,4 +83,4 @@ void Blink(byte PIN, int DELAY_MS)
digitalWrite(PIN,HIGH);
delay(DELAY_MS);
digitalWrite(PIN,LOW);
}
}

View File

@ -25,31 +25,40 @@
#define MYID 55 // node ID used for this unit
#define NETWORKID 250
#define FREQUENCY RF69_915MHZ //Match this with the version of your Moteino! (others: RF69_433MHZ, RF69_868MHZ)
//Match frequency to the hardware version of the radio on your Moteino (uncomment one):
//#define FREQUENCY RF69_433MHZ
//#define FREQUENCY RF69_868MHZ
#define FREQUENCY RF69_915MHZ
//#define IS_RFM69HW //uncomment only for RFM69HW! Leave out if you have RFM69W!
#define SERIAL_BAUD 115200
#define ACK_TIME 50 // # of ms to wait for an ack
#define KEY "thisIsEncryptKey"
#define ENCRYPTKEY "sampleEncryptKey"
#define LED 9
#define BLINKPERIOD 200
RFM69 radio;
char input = 0;
long lastPeriod = -1;
//////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// flash(SPI_CS, MANUFACTURER_ID)
// SPI_CS - CS pin attached to SPI flash chip (8 in case of Moteino)
// MANUFACTURER_ID - OPTIONAL, 0x1F44 for adesto(ex atmel) 4mbit flash
// 0xEF30 for windbond 4mbit flash
// 0xEF40 for windbond 16mbit flash
//////////////////////////////////////////
SPIFlash flash(8, 0xEF30); //EF30 for windbond 4mbit flash, EF40 for 16/64mbit
// 0xEF40 for windbond 16/64mbit flash
/////////////////////////////////////////////////////////////////////////////
SPIFlash flash(8, 0xEF30); //EF30 for windbond 4mbit flash
void setup(){
pinMode(LED, OUTPUT);
Serial.begin(SERIAL_BAUD);
radio.initialize(FREQUENCY,MYID,NETWORKID);
//radio.encrypt(KEY); //OPTIONAL
//radio.setHighPower(); //for RFM69HW only!
//radio.encrypt(ENCRYPTKEY); //OPTIONAL
#ifdef IS_RFM69HW
radio.setHighPower(); //only for RFM69HW!
#endif
Serial.print("Start node...");
if (flash.initialize())
Serial.println("SPI Flash Init OK!");
else
@ -121,12 +130,11 @@ void loop(){
}
////////////////////////////////////////////////////////////////////////////////////////////
// Real sketch code here, let's blink the onboard LED every 0.5sec
if ((int)(millis()/500) > lastPeriod)
// Real sketch code here, let's blink the onboard LED
if ((int)(millis()/BLINKPERIOD) > lastPeriod)
{
lastPeriod++;
pinMode(9, OUTPUT);
digitalWrite(9, lastPeriod%2);
digitalWrite(LED, lastPeriod%2);
}
////////////////////////////////////////////////////////////////////////////////////////////
}
}