Skip to content

Commit f894847

Browse files
committed
Add callback for board-specific actions on radio RX interrupt
In some cases it is useful to let the board driver know when the radio issues an RX interrupt. This can be used to wake up the board from a low power state asynchronously for example. Signed-off-by: Frieder Schrempf <frieder@fris.de>
1 parent 180399b commit f894847

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

src/MeshCore.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class MainBoard {
5353
virtual const char* getManufacturerName() const = 0;
5454
virtual void onBeforeTransmit() { }
5555
virtual void onAfterTransmit() { }
56+
virtual void onRXInterrupt() {}
5657
virtual void reboot() = 0;
5758
virtual void powerOff() { /* no op */ }
5859
virtual void enterSleep(uint32_t secs) {

src/helpers/radiolib/RadioLibWrappers.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#define SAMPLING_THRESHOLD 14
1313

1414
static volatile uint8_t state = STATE_IDLE;
15+
static mesh::MainBoard *board;
1516

1617
// this function is called when a complete packet
1718
// is transmitted by the module
@@ -22,9 +23,12 @@ static
2223
void radioISR(void) {
2324
// we sent a packet, set the flag
2425
state |= STATE_INT_READY;
26+
27+
if (state & STATE_RX) board->onRXInterrupt();
2528
}
2629

2730
void RadioLibWrapper::begin() {
31+
board = _board;
2832
_radio->setPacketReceivedAction(radioISR); // this is also SentComplete interrupt
2933
state = STATE_IDLE;
3034

0 commit comments

Comments
 (0)