Update WP examples
This commit is contained in:
parent
b5e9bc8ad6
commit
7cae6d51c3
|
|
@ -17,6 +17,7 @@
|
||||||
// The handshake protocol that receives the sketch from the serial port
|
// 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
|
// 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
|
// These libraries and custom 1k Optiboot bootloader for the target node are at: http://github.com/lowpowerlab
|
||||||
|
|
||||||
#include <RFM69.h>
|
#include <RFM69.h>
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#include <SPIFlash.h>
|
#include <SPIFlash.h>
|
||||||
|
|
@ -25,12 +26,16 @@
|
||||||
#define MYID 1 // node ID used for this unit
|
#define MYID 1 // node ID used for this unit
|
||||||
#define TARGET_ID 55 // ID of node being wirelessly reprogrammed
|
#define TARGET_ID 55 // ID of node being wirelessly reprogrammed
|
||||||
#define NETWORKID 250
|
#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 LED 9
|
||||||
#define SERIAL_BAUD 115200
|
#define SERIAL_BAUD 115200
|
||||||
#define ACK_TIME 50 // # of ms to wait for an ack
|
#define ACK_TIME 50 // # of ms to wait for an ack
|
||||||
#define TIMEOUT 3000
|
#define TIMEOUT 3000
|
||||||
#define KEY "thisIsEncryptKey"
|
#define ENCRYPTKEY "sampleEncryptKey"
|
||||||
|
|
||||||
RFM69 radio;
|
RFM69 radio;
|
||||||
char c = 0;
|
char c = 0;
|
||||||
|
|
@ -39,7 +44,10 @@ char input[64]; //serial input buffer
|
||||||
void setup(){
|
void setup(){
|
||||||
Serial.begin(SERIAL_BAUD);
|
Serial.begin(SERIAL_BAUD);
|
||||||
radio.initialize(FREQUENCY,MYID,NETWORKID);
|
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...");
|
Serial.print("Start wireless gateway...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,29 +25,38 @@
|
||||||
|
|
||||||
#define MYID 55 // node ID used for this unit
|
#define MYID 55 // node ID used for this unit
|
||||||
#define NETWORKID 250
|
#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 SERIAL_BAUD 115200
|
||||||
#define ACK_TIME 50 // # of ms to wait for an ack
|
#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;
|
RFM69 radio;
|
||||||
char input = 0;
|
char input = 0;
|
||||||
long lastPeriod = -1;
|
long lastPeriod = -1;
|
||||||
|
|
||||||
//////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// flash(SPI_CS, MANUFACTURER_ID)
|
// flash(SPI_CS, MANUFACTURER_ID)
|
||||||
// SPI_CS - CS pin attached to SPI flash chip (8 in case of Moteino)
|
// SPI_CS - CS pin attached to SPI flash chip (8 in case of Moteino)
|
||||||
// MANUFACTURER_ID - OPTIONAL, 0x1F44 for adesto(ex atmel) 4mbit flash
|
// MANUFACTURER_ID - OPTIONAL, 0x1F44 for adesto(ex atmel) 4mbit flash
|
||||||
// 0xEF30 for windbond 4mbit flash
|
// 0xEF30 for windbond 4mbit flash
|
||||||
// 0xEF40 for windbond 16mbit flash
|
// 0xEF40 for windbond 16/64mbit flash
|
||||||
//////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
SPIFlash flash(8, 0xEF30); //EF30 for windbond 4mbit flash, EF40 for 16/64mbit
|
SPIFlash flash(8, 0xEF30); //EF30 for windbond 4mbit flash
|
||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
|
pinMode(LED, OUTPUT);
|
||||||
Serial.begin(SERIAL_BAUD);
|
Serial.begin(SERIAL_BAUD);
|
||||||
radio.initialize(FREQUENCY,MYID,NETWORKID);
|
radio.initialize(FREQUENCY,MYID,NETWORKID);
|
||||||
//radio.encrypt(KEY); //OPTIONAL
|
//radio.encrypt(ENCRYPTKEY); //OPTIONAL
|
||||||
//radio.setHighPower(); //for RFM69HW only!
|
#ifdef IS_RFM69HW
|
||||||
|
radio.setHighPower(); //only for RFM69HW!
|
||||||
|
#endif
|
||||||
Serial.print("Start node...");
|
Serial.print("Start node...");
|
||||||
|
|
||||||
if (flash.initialize())
|
if (flash.initialize())
|
||||||
|
|
@ -121,12 +130,11 @@ void loop(){
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Real sketch code here, let's blink the onboard LED every 0.5sec
|
// Real sketch code here, let's blink the onboard LED
|
||||||
if ((int)(millis()/500) > lastPeriod)
|
if ((int)(millis()/BLINKPERIOD) > lastPeriod)
|
||||||
{
|
{
|
||||||
lastPeriod++;
|
lastPeriod++;
|
||||||
pinMode(9, OUTPUT);
|
digitalWrite(LED, lastPeriod%2);
|
||||||
digitalWrite(9, lastPeriod%2);
|
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue