mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-04 18:49:00 +00:00
Add isChannelActive() function to radio interface
This commit is contained in:
parent
616c7d7b0e
commit
6d01f9aa89
@ -176,6 +176,25 @@ void RF95Interface::startReceive()
|
|||||||
enableInterrupt(isrRxLevel0);
|
enableInterrupt(isrRxLevel0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RF95Interface::isChannelActive()
|
||||||
|
{
|
||||||
|
// check if we can detect a LoRa preamble on the current channel
|
||||||
|
int16_t result;
|
||||||
|
setTransmitEnable(false);
|
||||||
|
setStandby(); // needed for smooth transition
|
||||||
|
result = lora->scanChannel();
|
||||||
|
|
||||||
|
if (result == PREAMBLE_DETECTED) {
|
||||||
|
// DEBUG_MSG("Channel is busy!\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(result != ERR_WRONG_MODEM);
|
||||||
|
|
||||||
|
// DEBUG_MSG("Channel is free!\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/** Could we send right now (i.e. either not actively receving or transmitting)? */
|
/** Could we send right now (i.e. either not actively receving or transmitting)? */
|
||||||
bool RF95Interface::isActivelyReceiving()
|
bool RF95Interface::isActivelyReceiving()
|
||||||
{
|
{
|
||||||
|
@ -40,6 +40,9 @@ class RF95Interface : public RadioLibInterface
|
|||||||
*/
|
*/
|
||||||
virtual void enableInterrupt(void (*callback)()) { lora->setDio0Action(callback); }
|
virtual void enableInterrupt(void (*callback)()) { lora->setDio0Action(callback); }
|
||||||
|
|
||||||
|
/** can we detect a LoRa preamble on the current channel? */
|
||||||
|
virtual bool isChannelActive() override;
|
||||||
|
|
||||||
/** are we actively receiving a packet (only called during receiving state) */
|
/** are we actively receiving a packet (only called during receiving state) */
|
||||||
virtual bool isActivelyReceiving() override;
|
virtual bool isActivelyReceiving() override;
|
||||||
|
|
||||||
|
@ -226,6 +226,23 @@ void SX126xInterface<T>::startReceive()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Could we send right now (i.e. either not actively receving or transmitting)? */
|
||||||
|
template<typename T>
|
||||||
|
bool SX126xInterface<T>::isChannelActive()
|
||||||
|
{
|
||||||
|
// check if we can detect a LoRa preamble on the current channel
|
||||||
|
int16_t result;
|
||||||
|
|
||||||
|
setStandby();
|
||||||
|
result = lora.scanChannel();
|
||||||
|
if (result == PREAMBLE_DETECTED)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
assert(result != ERR_WRONG_MODEM);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/** Could we send right now (i.e. either not actively receving or transmitting)? */
|
/** Could we send right now (i.e. either not actively receving or transmitting)? */
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool SX126xInterface<T>::isActivelyReceiving()
|
bool SX126xInterface<T>::isActivelyReceiving()
|
||||||
|
@ -46,6 +46,9 @@ class SX126xInterface : public RadioLibInterface
|
|||||||
*/
|
*/
|
||||||
virtual void enableInterrupt(void (*callback)()) { lora.setDio1Action(callback); }
|
virtual void enableInterrupt(void (*callback)()) { lora.setDio1Action(callback); }
|
||||||
|
|
||||||
|
/** can we detect a LoRa preamble on the current channel? */
|
||||||
|
virtual bool isChannelActive() override;
|
||||||
|
|
||||||
/** are we actively receiving a packet (only called during receiving state) */
|
/** are we actively receiving a packet (only called during receiving state) */
|
||||||
virtual bool isActivelyReceiving() override;
|
virtual bool isActivelyReceiving() override;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user