Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add functions to PhysicalLayer interface #700

Merged
merged 1 commit into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/protocols/PhysicalLayer/PhysicalLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ int16_t PhysicalLayer::receive(uint8_t* data, size_t len) {
return(RADIOLIB_ERR_UNSUPPORTED);
}

int16_t PhysicalLayer::sleep() {
return(RADIOLIB_ERR_UNSUPPORTED);
}

int16_t PhysicalLayer::standby() {
return(standby(RADIOLIB_STANDBY_DEFAULT));
}
Expand All @@ -119,6 +123,13 @@ int16_t PhysicalLayer::standby(uint8_t mode) {
return(RADIOLIB_ERR_UNSUPPORTED);
}

int16_t PhysicalLayer::startReceive(uint32_t timeout, uint16_t irqFlags, uint16_t irqMask) {
(void)timeout;
(void)irqFlags;
(void)irqMask;
return(RADIOLIB_ERR_UNSUPPORTED);
}

int16_t PhysicalLayer::startTransmit(String& str, uint8_t addr) {
return(startTransmit(str.c_str(), addr));
}
Expand Down Expand Up @@ -230,6 +241,14 @@ size_t PhysicalLayer::getPacketLength(bool update) {
return(0);
}

float PhysicalLayer::getRSSI() {
return(RADIOLIB_ERR_UNSUPPORTED);
}

float PhysicalLayer::getSNR() {
return(RADIOLIB_ERR_UNSUPPORTED);
}

int32_t PhysicalLayer::random(int32_t max) {
if(max == 0) {
return(0);
Expand Down Expand Up @@ -365,6 +384,13 @@ int16_t PhysicalLayer::setDIOMapping(RADIOLIB_PIN_TYPE pin, uint8_t value) {
return(RADIOLIB_ERR_UNSUPPORTED);
}

void PhysicalLayer::setDio1Action(void (*func)(void)) {
(void)func;
}

void PhysicalLayer::clearDio1Action() {
}

#if defined(RADIOLIB_INTERRUPT_TIMING)
void PhysicalLayer::setInterruptSetup(void (*func)(uint32_t)) {
Module* mod = getMod();
Expand Down
46 changes: 46 additions & 0 deletions src/protocols/PhysicalLayer/PhysicalLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ class PhysicalLayer {
*/
int16_t receive(String& str, size_t len = 0);

/*!
\brief Sets module to sleep.

\returns \ref status_codes
*/
virtual int16_t sleep();

/*!
\brief Sets module to standby.

Expand All @@ -98,6 +105,19 @@ class PhysicalLayer {
*/
virtual int16_t standby(uint8_t mode);

/*!
\brief Interrupt-driven receive method. DIO1 will be activated when full packet is received.

\param timeout Raw timeout value.

\param irqFlags Sets the IRQ flags.

\param irqMask Sets the mask of IRQ flags that will trigger DIO1.

\returns \ref status_codes
*/
virtual int16_t startReceive(uint32_t timeout = 0, uint16_t irqFlags = 0, uint16_t irqMask = 0);

/*!
\brief Binary receive method. Must be implemented in module class.

Expand Down Expand Up @@ -258,6 +278,20 @@ class PhysicalLayer {
*/
virtual size_t getPacketLength(bool update = true);

/*!
\brief Gets RSSI (Recorded Signal Strength Indicator) of the last received packet.

\returns RSSI of the last received packet in dBm.
*/
virtual float getRSSI();

/*!
\brief Gets SNR (Signal to Noise Ratio) of the last received packet. Only available for LoRa modem.

\returns SNR of the last received packet in dB.
*/
virtual float getSNR();

/*!
\brief Get truly random number in range 0 - max.

Expand Down Expand Up @@ -351,6 +385,18 @@ class PhysicalLayer {
*/
virtual int16_t setDIOMapping(RADIOLIB_PIN_TYPE pin, uint8_t value);

/*!
\brief Sets interrupt service routine to call when DIO1 activates.

\param func ISR to call.
*/
virtual void setDio1Action(void (*func)(void));

/*!
\brief Clears interrupt service routine to call when DIO1 activates.
*/
virtual void clearDio1Action();

#if defined(RADIOLIB_INTERRUPT_TIMING)

/*!
Expand Down