Change default transfer speed to 250kbps.

Set default value for config.
Return wakeup trigger after sleep.
This commit is contained in:
Henrik Ekblad
2014-06-26 00:26:45 +02:00
parent c332667a8d
commit f3bd9e9b30
3 changed files with 12 additions and 4 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
* Configure Sensor Network
*/
#define RF24_CHANNEL 76 //RF channel for the sensor net, 0-127
#define RF24_DATARATE RF24_1MBPS //RF24_250KBPS for 250kbs, RF24_1MBPS for 1Mbps, or RF24_2MBPS for 2Mbps
#define RF24_DATARATE RF24_250KBPS //RF24_250KBPS for 250kbs, RF24_1MBPS for 1Mbps, or RF24_2MBPS for 2Mbps
#define RF24_PA_LEVEL RF24_PA_MAX //Sensor 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_LOW //Gateway PA Level, defaults to Sensor net PA Level. Tune here if using an amplified nRF2401+ in your gateway.
+9 -2
View File
@@ -46,7 +46,10 @@ void MySensor::begin(void (*_msgCallback)(const MyMessage &), uint8_t _nodeId, b
eeprom_read_block((void*)&nc, (void*)EEPROM_NODE_ID_ADDRESS, sizeof(NodeConfig));
// Read latest received controller configuration from EEPROM
eeprom_read_block((void*)&cc, (void*)EEPROM_LOCAL_CONFIG_ADDRESS, sizeof(ControllerConfig));
if (cc.isMetric == 0xff) {
// Eeprom empty, set default to metric
cc.isMetric = 0x01;
}
if (_nodeId != AUTO) {
// Set static id
@@ -541,18 +544,22 @@ void MySensor::sleep(int ms) {
internalSleep(ms);
}
void MySensor::sleep(int interrupt, int mode, int ms) {
bool MySensor::sleep(int interrupt, int mode, int ms) {
// Let serial prints finish (debug, log etc)
bool pinTriggeredWakeup = true;
Serial.flush();
RF24::powerDown();
attachInterrupt(interrupt, wakeUp, mode); //Interrupt on pin 3 for any change in solar power
if (ms>0) {
continueTimer = true;
sleep(ms);
pinTriggeredWakeup = !continueTimer;
} else {
Serial.flush();
LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
}
detachInterrupt(interrupt);
return pinTriggeredWakeup;
}
+2 -1
View File
@@ -211,8 +211,9 @@ class MySensor : public RF24
* @param interrupt Interrupt that should trigger the wakeup
* @param mode RISING, FALLING, CHANGE
* @param ms Number of milliseconds to sleep or 0 to sleep forever
* @return true if wake up was triggered by pin change and false means timer woke it up.
*/
void sleep(int interrupt, int mode, int ms=0);
bool sleep(int interrupt, int mode, int ms=0);
/**
* getInternalTemp