diff --git a/examples/SX128x/SX128x_Receive_Interrupt/SX128x_Receive_Interrupt.ino b/examples/SX128x/SX128x_Receive_Interrupt/SX128x_Receive_Interrupt.ino index 211a9069..5d0e4992 100644 --- a/examples/SX128x/SX128x_Receive_Interrupt/SX128x_Receive_Interrupt.ino +++ b/examples/SX128x/SX128x_Receive_Interrupt/SX128x_Receive_Interrupt.ino @@ -51,7 +51,7 @@ void setup() { // set the function that will be called // when new packet is received - radio.setDio1Action(setFlag); + radio.setPacketReceivedAction(setFlag); // start listening for LoRa packets Serial.print(F("[SX1280] Starting to listen ... ")); diff --git a/examples/SX128x/SX128x_Transmit_Interrupt/SX128x_Transmit_Interrupt.ino b/examples/SX128x/SX128x_Transmit_Interrupt/SX128x_Transmit_Interrupt.ino index 17843970..9a490030 100644 --- a/examples/SX128x/SX128x_Transmit_Interrupt/SX128x_Transmit_Interrupt.ino +++ b/examples/SX128x/SX128x_Transmit_Interrupt/SX128x_Transmit_Interrupt.ino @@ -50,7 +50,7 @@ void setup() { // set the function that will be called // when packet transmission is finished - radio.setDio1Action(setFlag); + radio.setPacketSentAction(setFlag); // start transmitting the first packet Serial.print(F("[SX1280] Sending first packet ... ")); diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index 783b3f51..f3eb20d6 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -476,6 +476,22 @@ void SX128x::clearDio1Action() { this->mod->hal->detachInterrupt(this->mod->hal->pinToInterrupt(this->mod->getIrq())); } +void SX128x::setPacketReceivedAction(void (*func)(void)) { + this->setDio1Action(func); +} + +void SX128x::clearPacketReceivedAction() { + this->clearDio1Action(); +} + +void SX128x::setPacketSentAction(void (*func)(void)) { + this->setDio1Action(func); +} + +void SX128x::clearPacketSentAction() { + this->clearDio1Action(); +} + int16_t SX128x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { // suppress unused variable warning (void)addr; diff --git a/src/modules/SX128x/SX128x.h b/src/modules/SX128x/SX128x.h index 756165b6..ca69f843 100644 --- a/src/modules/SX128x/SX128x.h +++ b/src/modules/SX128x/SX128x.h @@ -495,6 +495,28 @@ class SX128x: public PhysicalLayer { */ void clearDio1Action(); + /*! + \brief Sets interrupt service routine to call when a packet is received. + \param func ISR to call. + */ + void setPacketReceivedAction(void (*func)(void)); + + /*! + \brief Clears interrupt service routine to call when a packet is received. + */ + void clearPacketReceivedAction(); + + /*! + \brief Sets interrupt service routine to call when a packet is sent. + \param func ISR to call. + */ + void setPacketSentAction(void (*func)(void)); + + /*! + \brief Clears interrupt service routine to call when a packet is sent. + */ + void clearPacketSentAction(); + /*! \brief Interrupt-driven binary transmit method. Overloads for string-based transmissions are implemented in PhysicalLayer.