Skip to content

Commit

Permalink
Merge pull request arduino#2 from bblacey/net-config
Browse files Browse the repository at this point in the history
Centralize sensor network configuration and debug flag feature
  • Loading branch information
henrikekblad committed Mar 9, 2014
2 parents c1441dc + 2195a8c commit 7132453
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
4 changes: 2 additions & 2 deletions SerialGateway/SerialGateway.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@


// No blink or button functionality. Use the vanilla constructor.
Gateway gw;
//Gateway gw;

// To start gateway with include button and led blinking functionality enabled use this instead!
//Gateway gw(9, 10, INCLUSION_MODE_TIME, INCLUSION_MODE_PIN, 6, 5, 4);
Gateway gw(9, 10, INCLUSION_MODE_TIME, INCLUSION_MODE_PIN, 6, 5, 4);


char inputString[MAX_RECEIVE_LENGTH] = ""; // A string to hold incoming commands from serial/ethernet interface
Expand Down
17 changes: 17 additions & 0 deletions libraries/MySensors/Config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef Config_h
#define Config_h

/***
* Configure Sensor Network
*/
#define RF24_CHANNEL 76 //RF channel for the sensor net, 0-127
#define RF24_DATARATE RF24_2MBPS //RF24_250KBPS for 250kbs, RF24_1MBPS for 1Mbps, or RF24_2MBPS for 2Mbps
#define RF24_PA_LEVEL RF24_PA_MAX //Senor PA Level == RF24_PA_MIN=-18dBm, RF24_PA_LOW=-12dBm, RF24_PA_HIGH=-6dBM, and RF24_PA_HIGH=0dBm
#define RF24_PA_LEVEL_GW RF24_PA_LEVEL //Gateway PA Level, defaults to Sensor net PA Level. Tune here if using an amplified nRF2401+ in your gateway.

/***
* Enable/Disable debug logging
*/
//#define DEBUG

#endif
2 changes: 1 addition & 1 deletion libraries/MySensors/Gateway.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Gateway : public Relay
Gateway(uint8_t _cepin, uint8_t _cspin, uint8_t _inclusion_time, uint8_t _inclusion_pin, uint8_t _rx, uint8_t _tx, uint8_t _er);

/* Use this and pass a function that should be called when you want to process commands that arrive from radio network */
void begin(rf24_pa_dbm_e paLevel=RF24_PA_MAX, uint8_t channel=76, rf24_datarate_e dataRate=RF24_2MBPS, void (*dataCallback)(char *)=NULL);
void begin(rf24_pa_dbm_e paLevel=RF24_PA_LEVEL_GW, uint8_t channel=RF24_CHANNEL, rf24_datarate_e dataRate=RF24_DATARATE, void (*dataCallback)(char *)=NULL);

void processRadioMessage();
void parseAndSend(char *inputString);
Expand Down
2 changes: 1 addition & 1 deletion libraries/MySensors/Relay.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Relay : public Sensor
*/
Relay(uint8_t _cepin = 9, uint8_t _cspin = 10);

void begin(uint8_t radioId=AUTO, rf24_pa_dbm_e paLevel=RF24_PA_MAX, uint8_t channel=76, rf24_datarate_e dataRate=RF24_2MBPS);
void begin(uint8_t radioId=AUTO, rf24_pa_dbm_e paLevel=RF24_PA_LEVEL, uint8_t channel=RF24_CHANNEL, rf24_datarate_e dataRate=RF24_DATARATE);
boolean messageAvailable();
boolean send(message_s message, int length);

Expand Down
5 changes: 2 additions & 3 deletions libraries/MySensors/Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#ifndef Sensor_h
#define Sensor_h

#include "Config.h"
#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>
Expand All @@ -22,8 +23,6 @@
#include <avr/pgmspace.h>
#include <stdarg.h>

//#define DEBUG

#ifdef DEBUG
#define debug(x,...) debugPrint(x, ##__VA_ARGS__)
#else
Expand Down Expand Up @@ -137,7 +136,7 @@ class Sensor : public RF24
* @param channel Radio channel. Default is channel 76
* @param dataRate Radio transmission speed. Default RF24_2MBPS
*/
void begin(uint8_t radioId=AUTO, rf24_pa_dbm_e paLevel=RF24_PA_MAX, uint8_t channel=76, rf24_datarate_e dataRate=RF24_2MBPS);
void begin(uint8_t radioId=AUTO, rf24_pa_dbm_e paLevel=RF24_PA_LEVEL, uint8_t channel=RF24_CHANNEL, rf24_datarate_e dataRate=RF24_DATARATE);

uint8_t getRadioId();

Expand Down

0 comments on commit 7132453

Please sign in to comment.