mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-14 17:12:08 +00:00
Fmt
This commit is contained in:
parent
25096c5c63
commit
9b18d5d85f
@ -1,7 +1,7 @@
|
|||||||
#include "SX126xInterface.h"
|
#include "SX126xInterface.h"
|
||||||
#include "mesh/NodeDB.h"
|
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "mesh/NodeDB.h"
|
||||||
|
|
||||||
// Particular boards might define a different max power based on what their hardware can do
|
// Particular boards might define a different max power based on what their hardware can do
|
||||||
#ifndef SX126X_MAX_POWER
|
#ifndef SX126X_MAX_POWER
|
||||||
@ -19,8 +19,7 @@ SX126xInterface<T>::SX126xInterface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq,
|
|||||||
/// Initialise the Driver transport hardware and software.
|
/// Initialise the Driver transport hardware and software.
|
||||||
/// Make sure the Driver is properly configured before calling init().
|
/// Make sure the Driver is properly configured before calling init().
|
||||||
/// \return true if initialisation succeeded.
|
/// \return true if initialisation succeeded.
|
||||||
template <typename T>
|
template <typename T> bool SX126xInterface<T>::init()
|
||||||
bool SX126xInterface<T>::init()
|
|
||||||
{
|
{
|
||||||
#ifdef SX126X_POWER_EN
|
#ifdef SX126X_POWER_EN
|
||||||
digitalWrite(SX126X_POWER_EN, HIGH);
|
digitalWrite(SX126X_POWER_EN, HIGH);
|
||||||
@ -77,20 +76,16 @@ bool SX126xInterface<T>::init()
|
|||||||
|
|
||||||
#if defined(SX126X_TXEN) && (SX126X_TXEN != RADIOLIB_NC)
|
#if defined(SX126X_TXEN) && (SX126X_TXEN != RADIOLIB_NC)
|
||||||
// lora.begin sets Dio2 as RF switch control, which is not true if we are manually controlling RX and TX
|
// lora.begin sets Dio2 as RF switch control, which is not true if we are manually controlling RX and TX
|
||||||
if (res == RADIOLIB_ERR_NONE)
|
if (res == RADIOLIB_ERR_NONE) {
|
||||||
{
|
|
||||||
res = lora.setDio2AsRfSwitch(false);
|
res = lora.setDio2AsRfSwitch(false);
|
||||||
lora.setRfSwitchPins(SX126X_RXEN, SX126X_TXEN);
|
lora.setRfSwitchPins(SX126X_RXEN, SX126X_TXEN);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (config.lora.sx126x_rx_boosted_gain)
|
if (config.lora.sx126x_rx_boosted_gain) {
|
||||||
{
|
|
||||||
uint16_t result = lora.setRxBoostedGainMode(true);
|
uint16_t result = lora.setRxBoostedGainMode(true);
|
||||||
LOG_INFO("Set Rx Boosted Gain mode; result: %d\n", result);
|
LOG_INFO("Set Rx Boosted Gain mode; result: %d\n", result);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
uint16_t result = lora.setRxBoostedGainMode(false);
|
uint16_t result = lora.setRxBoostedGainMode(false);
|
||||||
LOG_INFO("Set Rx Power Saving Gain mode; result: %d\n", result);
|
LOG_INFO("Set Rx Power Saving Gain mode; result: %d\n", result);
|
||||||
}
|
}
|
||||||
@ -128,8 +123,7 @@ bool SX126xInterface<T>::init()
|
|||||||
return res == RADIOLIB_ERR_NONE;
|
return res == RADIOLIB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T> bool SX126xInterface<T>::reconfigure()
|
||||||
bool SX126xInterface<T>::reconfigure()
|
|
||||||
{
|
{
|
||||||
RadioLibInterface::reconfigure();
|
RadioLibInterface::reconfigure();
|
||||||
|
|
||||||
@ -178,14 +172,12 @@ bool SX126xInterface<T>::reconfigure()
|
|||||||
return RADIOLIB_ERR_NONE;
|
return RADIOLIB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T> void INTERRUPT_ATTR SX126xInterface<T>::disableInterrupt()
|
||||||
void INTERRUPT_ATTR SX126xInterface<T>::disableInterrupt()
|
|
||||||
{
|
{
|
||||||
lora.clearDio1Action();
|
lora.clearDio1Action();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T> void SX126xInterface<T>::setStandby()
|
||||||
void SX126xInterface<T>::setStandby()
|
|
||||||
{
|
{
|
||||||
checkNotification(); // handle any pending interrupts before we force standby
|
checkNotification(); // handle any pending interrupts before we force standby
|
||||||
|
|
||||||
@ -211,8 +203,7 @@ void SX126xInterface<T>::setStandby()
|
|||||||
/**
|
/**
|
||||||
* Add SNR data to received messages
|
* Add SNR data to received messages
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T> void SX126xInterface<T>::addReceiveMetadata(meshtastic_MeshPacket *mp)
|
||||||
void SX126xInterface<T>::addReceiveMetadata(meshtastic_MeshPacket *mp)
|
|
||||||
{
|
{
|
||||||
// LOG_DEBUG("PacketStatus %x\n", lora.getPacketStatus());
|
// LOG_DEBUG("PacketStatus %x\n", lora.getPacketStatus());
|
||||||
mp->rx_snr = lora.getSNR();
|
mp->rx_snr = lora.getSNR();
|
||||||
@ -221,8 +212,7 @@ void SX126xInterface<T>::addReceiveMetadata(meshtastic_MeshPacket *mp)
|
|||||||
|
|
||||||
/** We override to turn on transmitter power as needed.
|
/** We override to turn on transmitter power as needed.
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T> void SX126xInterface<T>::configHardwareForSend()
|
||||||
void SX126xInterface<T>::configHardwareForSend()
|
|
||||||
{
|
{
|
||||||
// #if defined(SX126X_TXEN) && (SX126X_TXEN != RADIOLIB_NC) // we have RXEN/TXEN control - turn on TX power / off RX power
|
// #if defined(SX126X_TXEN) && (SX126X_TXEN != RADIOLIB_NC) // we have RXEN/TXEN control - turn on TX power / off RX power
|
||||||
// digitalWrite(SX126X_TXEN, HIGH);
|
// digitalWrite(SX126X_TXEN, HIGH);
|
||||||
@ -237,8 +227,7 @@ void SX126xInterface<T>::configHardwareForSend()
|
|||||||
// For power draw measurements, helpful to force radio to stay sleeping
|
// For power draw measurements, helpful to force radio to stay sleeping
|
||||||
// #define SLEEP_ONLY
|
// #define SLEEP_ONLY
|
||||||
|
|
||||||
template <typename T>
|
template <typename T> void SX126xInterface<T>::startReceive()
|
||||||
void SX126xInterface<T>::startReceive()
|
|
||||||
{
|
{
|
||||||
#ifdef SLEEP_ONLY
|
#ifdef SLEEP_ONLY
|
||||||
sleep();
|
sleep();
|
||||||
@ -266,8 +255,7 @@ void SX126xInterface<T>::startReceive()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 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>::isChannelActive()
|
||||||
bool SX126xInterface<T>::isChannelActive()
|
|
||||||
{
|
{
|
||||||
// check if we can detect a LoRa preamble on the current channel
|
// check if we can detect a LoRa preamble on the current channel
|
||||||
int16_t result;
|
int16_t result;
|
||||||
@ -283,8 +271,7 @@ bool SX126xInterface<T>::isChannelActive()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 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()
|
|
||||||
{
|
{
|
||||||
// The IRQ status will be cleared when we start our read operation. Check if we've started a header, but haven't yet
|
// The IRQ status will be cleared when we start our read operation. Check if we've started a header, but haven't yet
|
||||||
// received and handled the interrupt for reading the packet/handling errors.
|
// received and handled the interrupt for reading the packet/handling errors.
|
||||||
@ -301,8 +288,7 @@ bool SX126xInterface<T>::isActivelyReceiving()
|
|||||||
return hasPreamble;
|
return hasPreamble;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T> bool SX126xInterface<T>::sleep()
|
||||||
bool SX126xInterface<T>::sleep()
|
|
||||||
{
|
{
|
||||||
// Not keeping config is busted - next time nrf52 board boots lora sending fails tcxo related? - see datasheet
|
// Not keeping config is busted - next time nrf52 board boots lora sending fails tcxo related? - see datasheet
|
||||||
// \todo Display actual typename of the adapter, not just `SX126x`
|
// \todo Display actual typename of the adapter, not just `SX126x`
|
||||||
|
Loading…
Reference in New Issue
Block a user