11#ifndef END_DEVICE_LORA_PHY_H
12#define END_DEVICE_LORA_PHY_H
16#include "ns3/traced-value.h"
213 double txPowerDbm)
override = 0;
219 uint8_t spreadingFactor,
221 Time duration)
override = 0;
257 uint8_t spreadingFactor,
259 uint8_t symbNumTimeout,
268 void RegisterListener(
const std::shared_ptr<EndDeviceLoraPhyListener>& listener);
394 typedef std::list<std::weak_ptr<EndDeviceLoraPhyListener>>
Listeners;
455 template <
typename FUNC,
typename... Ts>
478template <
typename FUNC,
typename... Ts>
487 std::list<std::shared_ptr<EndDeviceLoraPhyListener>> listeners;
490 std::back_inserter(listeners),
491 [](
auto&& listener) { return listener.lock(); });
493 for (
const auto& listener : listeners)
497 std::invoke(f, listener, std::forward<Ts>(args)...);
An identifier for simulation events.
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Forward calls to a chain of Callback.
Trace classes with value semantics.
a unique identifier for an interface.
void StartReceive(Ptr< Packet > packet, uint32_t frequencyHz, IQPolarity iqPolarity, uint8_t spreadingFactor, double rxPowerDbm, Time duration) override=0
Start receiving a packet.
void SwitchToSleep()
Switch to the SLEEP state.
State GetState()
Return the internal state this end device is currently in.
TracedCallback< Ptr< const Packet >, uint32_t > m_wrongPolarity
Trace source for when a packet is lost because it was transmitted with a different I/Q polarity (upli...
void SwitchToTx()
Switch to the TX state.
bool IsOnFrequency(uint32_t frequencyHz) const override
Whether this device is listening on the specified frequency or not.
void SwitchToStandBy()
Switch to the STANDBY state.
void SwitchToRxActive()
Update the RX state to RX_ACTIVE on preamble lock.
void RequestRxSingleMode()
This function reads RX parameters from the internal registers of the PHY hardware and begins a recept...
void ReceiveSingle(uint32_t frequencyHz, IQPolarity iqPolarity, uint8_t spreadingFactor, uint32_t bandwidthHz, uint8_t symbNumTimeout, RxTimeoutCallback rxTimeoutCallback)
This function starts a reception attempt that will time-out if no transmission preamble is detected.
EventId m_rxTimeoutEvent
Event for timed switch from RX_ENABLED to STANDBY.
void SwitchToRxEnabled()
Switch to the RX_ENABLED state.
static const double SENSITIVITY[6]
The sensitivity vector of this device to different SFs.
void NotifyListeners(FUNC f, Ts &&... args)
Notify all EndDeviceLoraPhyListener objects of the given PHY event.
void Send(Ptr< Packet > packet, uint32_t frequencyHz, IQPolarity iqPolarity, const LoraTxParameters &txParams, double txPowerDbm) override=0
Instruct the PHY to send a packet according to some parameters.
Listeners m_listeners
PHY state listeners.
static TypeId GetTypeId()
Register this type.
EndDeviceLoraRegisters m_regs
High level model of LoRa chip registers.
bool IsTransmitting() const override
Whether this device is transmitting or not.
void DoStartReceive()
This function should be called by parent classes to signal that the PHY is starting to demodulate a t...
void EndReceive(Ptr< Packet > packet, Ptr< LoraInterferenceHelper::Event > event) override=0
Finish reception of a packet.
EndDeviceLoraPhy()
Default constructor.
void DoEndReceive()
This function should be called by parent classes to signal that the PHY is finishing to demodulate a ...
Callback< void > RxTimeoutCallback
Type definition for a callback for when a packet reception hardware timeout expires.
~EndDeviceLoraPhy() override
Destructor.
std::list< std::weak_ptr< EndDeviceLoraPhyListener > > Listeners
typedef for a list of EndDeviceLoraPhyListeners.
TracedValue< State > m_state
The state this PHY is currently in.
TracedCallback< Ptr< const Packet >, uint32_t > m_wrongSf
Trace source for when a packet is lost because it was using a spreading factor different from the one...
void RequestTxMode()
This function puts the PHY in transmission mode.
void RequestSleepMode()
Request a switch to SLEEP mode.
State
An enumeration of the possible internal states of an EndDeviceLoraPhy.
@ TX
The PHY layer is transmitting a packet.
@ RX_ACTIVE
The PHY layer is actively receiving a transmission after locking onto a preamble.
@ SLEEP
The PHY layer is in low-power sleep state.
@ RX_ENABLED
The PHY layer is listening to the channel for a valid transmission preamble.
@ STANDBY
The PHY layer is in standby mode.
void RegisterListener(const std::shared_ptr< EndDeviceLoraPhyListener > &listener)
Add the input listener to the list of objects to be notified of PHY-level events.
void TxFinished(Ptr< const Packet > packet) override
Internal call when transmission of a packet finishes.
RxTimeoutCallback m_rxTimeoutCallback
The callback to perform upon reception timeout.
TracedCallback< Ptr< const Packet >, uint32_t > m_wrongFrequency
Trace source for when a packet is lost because it was transmitted on a frequency different from the o...
void RxTimeout()
Callback for scheduling the end of an unsuccessful timed reception attempt.
void UnregisterListener(const std::shared_ptr< EndDeviceLoraPhyListener > &listener)
Remove the input listener from the list of objects to be notified of PHY-level events.
void Sleep()
Set this PHY LoRa chip to sleep from standby after a transmission / reception.
Receive notifications about PHY internal state changes.
virtual void NotifyTx(double txPowerDbm)=0
Notify listeners that the device entered TX state.
virtual void NotifyRxEnabled()=0
Notify listeners that the device entered RX_ENABLED state.
virtual void NotifyRxActive()=0
Notify listeners that the device entered RX_ACTIVE state.
virtual void NotifyStandby()=0
Notify listeners that the device entered STANDBY state.
virtual ~EndDeviceLoraPhyListener()
virtual void NotifySleep()=0
Notify listeners that the device entered SLEEP state.
LoraPhy()
Default constructor.
CodingRate
Enumeration of the LoRa supported coding rates.
IQPolarity
I/Q Polarity of LoRa transmission symbols.
@ UP
Uplink / Upchirp / Normal polarity.
std::ostream & operator<<(std::ostream &os, const EndDeviceLoraPhy::State &state)
Overloaded operator to print the value of a EndDeviceLoraPhy::State.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Parameters affecting the internal PHY transmission / reception of a packet, normally stored in the ch...
bool crcEnabled
Whether Cyclic Redundancy Check (CRC) is enabled.
IQPolarity iqPolarity
Whether to process an uplink or downlink signal.
uint16_t preambleLenSymb
Number of symbols in the packet preamble.
uint8_t spreadingFactor
Symbol Spreading Factor (SF).
int8_t txPowerDbm
The output power [dBm] to use for packet transmission.
uint8_t symbNumTimeout
The reception timeout duration in number of symbols.
bool implicitHeader
Whether to use implicit header mode.
uint8_t payloadLenBytes
Number of Bytes the packet payload.
CodingRate codingRate
Transmission coding rate.
uint32_t frequencyHz
The transmission central frequency [Hz].
bool lowDataRateOptimize
Low Data Rate Optimization (mandated for SF11/12).
uint32_t bandwidthHz
Transmission bandwidth in Hz.
uint8_t syncWord
The LoRa sync.
Structure to collect all parameters that are used to compute the duration of a packet (excluding payl...