14#include "ns3/simulator.h"
39 TypeId(
"ns3::EndDeviceLoraPhy")
41 .SetGroupName(
"lorawan")
42 .AddTraceSource(
"LostPacketBecauseWrongFrequency",
43 "Trace source indicating a packet "
44 "could not be correctly decoded because"
45 "the end device was listening on a different frequency",
47 "ns3::Packet::TracedCallback")
48 .AddTraceSource(
"LostPacketBecauseWrongSpreadingFactor",
49 "Trace source indicating a packet "
50 "could not be correctly decoded because"
51 "the end device was listening for a different Spreading Factor",
53 "ns3::Packet::TracedCallback")
54 .AddTraceSource(
"EndDeviceState",
55 "The current state of the device",
57 "ns3::TracedValueCallback::EndDeviceLoraPhy::State");
133 (*i)->NotifyStandby();
149 (*i)->NotifyRxStart();
165 (*i)->NotifyTxStart(txPowerDbm);
bool IsNull() const
Check for null implementation.
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
bool IsOnFrequency(double frequencyMHz) override
Whether this device is listening on the specified frequency or not.
void SwitchToSleep()
Switch to the SLEEP state.
EndDeviceLoraPhy::State GetState()
Return the state this end device is currently in.
void SetFrequency(double frequencyMHz)
Set the frequency this end device will listen on.
uint8_t GetSpreadingFactor() const
Get the Spreading Factor this end device is listening for.
static const double sensitivity[6]
The sensitivity vector of this device to different SFs.
Listeners m_listeners
PHY listeners.
void RegisterListener(EndDeviceLoraPhyListener *listener)
Add the input listener to the list of objects to be notified of PHY-level events.
bool IsTransmitting() override
Whether this device is transmitting or not.
uint8_t m_sf
The Spreading Factor this device is listening for.
static TypeId GetTypeId()
Register this type.
void SwitchToRx()
Switch to the RX state.
void SwitchToStandby()
Switch to the STANDBY state.
EndDeviceLoraPhy()
Default constructor.
~EndDeviceLoraPhy() override
Destructor.
void SetSpreadingFactor(uint8_t sf)
Set the Spreading Factor this end device will listen for.
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 SwitchToTx(double txPowerDbm)
Switch to the TX state.
void UnregisterListener(EndDeviceLoraPhyListener *listener)
Remove the input listener from the list of objects to be notified of PHY-level events.
State
An enumeration of the possible states of an EndDeviceLoraPhy.
@ RX
The PHY layer is receiving a packet.
@ TX
The PHY layer is sending a packet.
@ SLEEP
The PHY layer is sleeping.
@ STANDBY
The PHY layer is in STANDBY.
void TxFinished(Ptr< const Packet > packet) override
Signals the end of a transmission by the EndDeviceLoraPhy.
double m_frequency
The frequency this device is listening on.
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...
Receive notifications about PHY events.
virtual ~EndDeviceLoraPhyListener()
Destructor.
Base class for PHY layers implementing the LoRa modulation scheme.
TxFinishedCallback m_txFinishedCallback
The callback to perform upon the end of a transmission.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
@ SLEEP
The PHY layer is sleeping.