Add example sleep function
This commit is contained in:
parent
0fd1331728
commit
1ca9f6540f
2 changed files with 18 additions and 0 deletions
|
@ -48,6 +48,9 @@ void setup() {
|
|||
// Override the default join rate
|
||||
uint8_t joinDR = 4;
|
||||
|
||||
// Optionally provide a custom sleep function - see config.h
|
||||
//node.setSleepFunction(customDelay);
|
||||
|
||||
// Setup the OTAA session information
|
||||
node.beginOTAA(joinEUI, devEUI, nwkKey, appKey);
|
||||
|
||||
|
|
|
@ -142,4 +142,19 @@ void arrayDump(uint8_t *buffer, uint16_t len) {
|
|||
Serial.println();
|
||||
}
|
||||
|
||||
// Custom delay function:
|
||||
// Communication over LoRaWAN includes a lot of delays.
|
||||
// By default, RadioLib will use the Arduino delay() function,
|
||||
// which will waste a lot of power. However, you can put your
|
||||
// microcontroller to sleep instead by customizing the function below,
|
||||
// and providing it to RadioLib via "node.setSleepFunction".
|
||||
// NOTE: You ahve to ensure that this function is timed precisely, and
|
||||
// does actually wait for the amount of time specified!
|
||||
// Failure to do so will result in missed downlinks or failed join!
|
||||
void customDelay(RadioLibTime_t ms) {
|
||||
// this is just an example, so we use the Arduino delay() function,
|
||||
// but you can put your microcontroller to sleep here
|
||||
::delay(ms);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue