diff --git a/src/LoRa.cpp b/src/LoRa.cpp index 210a589..b3e7860 100644 --- a/src/LoRa.cpp +++ b/src/LoRa.cpp @@ -359,7 +359,7 @@ void LoRaClass::flush() } #ifndef ARDUINO_SAMD_MKRWAN1300 -void LoRaClass::onReceive(void(*callback)(int)) +void LoRaClass::onReceive(std::function callback) { _onReceive = callback; @@ -377,7 +377,7 @@ void LoRaClass::onReceive(void(*callback)(int)) } } -void LoRaClass::onTxDone(void(*callback)()) +void LoRaClass::onTxDone(std::function callback) { _onTxDone = callback; diff --git a/src/LoRa.h b/src/LoRa.h index b312db5..ec38527 100644 --- a/src/LoRa.h +++ b/src/LoRa.h @@ -6,6 +6,7 @@ #include #include +#include #if defined(ARDUINO_SAMD_MKRWAN1300) #define LORA_DEFAULT_SPI SPI1 @@ -58,8 +59,8 @@ class LoRaClass : public Stream { virtual void flush(); #ifndef ARDUINO_SAMD_MKRWAN1300 - void onReceive(void(*callback)(int)); - void onTxDone(void(*callback)()); + void onReceive(std::function callback); + void onTxDone(std::function callback); void receive(int size = 0); #endif @@ -121,8 +122,8 @@ class LoRaClass : public Stream { long _frequency; int _packetIndex; int _implicitHeaderMode; - void (*_onReceive)(int); - void (*_onTxDone)(); + std::function _onReceive; + std::function _onTxDone; }; extern LoRaClass LoRa;