Skip to content

Commit 7132453

Browse files
committed
Merge pull request arduino#2 from bblacey/net-config
Centralize sensor network configuration and debug flag feature
2 parents c1441dc + 2195a8c commit 7132453

File tree

5 files changed

+23
-7
lines changed

5 files changed

+23
-7
lines changed

SerialGateway/SerialGateway.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535

3636

3737
// No blink or button functionality. Use the vanilla constructor.
38-
Gateway gw;
38+
//Gateway gw;
3939

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

4343

4444
char inputString[MAX_RECEIVE_LENGTH] = ""; // A string to hold incoming commands from serial/ethernet interface

libraries/MySensors/Config.h

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifndef Config_h
2+
#define Config_h
3+
4+
/***
5+
* Configure Sensor Network
6+
*/
7+
#define RF24_CHANNEL 76 //RF channel for the sensor net, 0-127
8+
#define RF24_DATARATE RF24_2MBPS //RF24_250KBPS for 250kbs, RF24_1MBPS for 1Mbps, or RF24_2MBPS for 2Mbps
9+
#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
10+
#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.
11+
12+
/***
13+
* Enable/Disable debug logging
14+
*/
15+
//#define DEBUG
16+
17+
#endif

libraries/MySensors/Gateway.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Gateway : public Relay
4040
Gateway(uint8_t _cepin, uint8_t _cspin, uint8_t _inclusion_time, uint8_t _inclusion_pin, uint8_t _rx, uint8_t _tx, uint8_t _er);
4141

4242
/* Use this and pass a function that should be called when you want to process commands that arrive from radio network */
43-
void begin(rf24_pa_dbm_e paLevel=RF24_PA_MAX, uint8_t channel=76, rf24_datarate_e dataRate=RF24_2MBPS, void (*dataCallback)(char *)=NULL);
43+
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);
4444

4545
void processRadioMessage();
4646
void parseAndSend(char *inputString);

libraries/MySensors/Relay.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Relay : public Sensor
3939
*/
4040
Relay(uint8_t _cepin = 9, uint8_t _cspin = 10);
4141

42-
void begin(uint8_t radioId=AUTO, rf24_pa_dbm_e paLevel=RF24_PA_MAX, uint8_t channel=76, rf24_datarate_e dataRate=RF24_2MBPS);
42+
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);
4343
boolean messageAvailable();
4444
boolean send(message_s message, int length);
4545

libraries/MySensors/Sensor.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#ifndef Sensor_h
1313
#define Sensor_h
1414

15+
#include "Config.h"
1516
#include <nRF24L01.h>
1617
#include <RF24.h>
1718
#include <RF24_config.h>
@@ -22,8 +23,6 @@
2223
#include <avr/pgmspace.h>
2324
#include <stdarg.h>
2425

25-
//#define DEBUG
26-
2726
#ifdef DEBUG
2827
#define debug(x,...) debugPrint(x, ##__VA_ARGS__)
2928
#else
@@ -137,7 +136,7 @@ class Sensor : public RF24
137136
* @param channel Radio channel. Default is channel 76
138137
* @param dataRate Radio transmission speed. Default RF24_2MBPS
139138
*/
140-
void begin(uint8_t radioId=AUTO, rf24_pa_dbm_e paLevel=RF24_PA_MAX, uint8_t channel=76, rf24_datarate_e dataRate=RF24_2MBPS);
139+
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);
141140

142141
uint8_t getRadioId();
143142

0 commit comments

Comments
 (0)