File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,8 @@ LoRaClass::LoRaClass() :
71
71
_packetIndex(0 ),
72
72
_implicitHeaderMode(0 ),
73
73
_onReceive(NULL ),
74
- _onTxDone(NULL )
74
+ _onTxDone(NULL ),
75
+ _onError(NULL )
75
76
{
76
77
// overide Stream timeout value
77
78
setTimeout (0 );
@@ -385,6 +386,23 @@ void LoRaClass::onTxDone(void(*callback)())
385
386
}
386
387
}
387
388
389
+ void LoRaClass::onError (void (*callback)()){
390
+ _onError = callback;
391
+
392
+ if (callback) {
393
+ pinMode (_dio0, INPUT);
394
+ #ifdef SPI_HAS_NOTUSINGINTERRUPT
395
+ SPI.usingInterrupt (digitalPinToInterrupt (_dio0));
396
+ #endif
397
+ attachInterrupt (digitalPinToInterrupt (_dio0), LoRaClass::onDio0Rise, RISING);
398
+ } else {
399
+ detachInterrupt (digitalPinToInterrupt (_dio0));
400
+ #ifdef SPI_HAS_NOTUSINGINTERRUPT
401
+ SPI.notUsingInterrupt (digitalPinToInterrupt (_dio0));
402
+ #endif
403
+ }
404
+ }
405
+
388
406
void LoRaClass::receive (int size)
389
407
{
390
408
@@ -684,6 +702,10 @@ void LoRaClass::handleDio0Rise()
684
702
_onTxDone ();
685
703
}
686
704
}
705
+ } else {
706
+ if (_onError) {
707
+ _onError ();
708
+ }
687
709
}
688
710
}
689
711
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ class LoRaClass : public Stream {
58
58
#ifndef ARDUINO_SAMD_MKRWAN1300
59
59
void onReceive (void (*callback)(int ));
60
60
void onTxDone (void (*callback)());
61
+ void onError (void (*callback)());
61
62
62
63
void receive (int size = 0 );
63
64
#endif
@@ -119,6 +120,7 @@ class LoRaClass : public Stream {
119
120
int _implicitHeaderMode;
120
121
void (*_onReceive)(int );
121
122
void (*_onTxDone)();
123
+ void (*_onError)();
122
124
};
123
125
124
126
extern LoRaClass LoRa;
You can’t perform that action at this time.
0 commit comments