lora-sub-band.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2017 University of Padova
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Davide Magrin <magrinda@dei.unipd.it>
19  *
20  * Modified by: Bastien Tauran <bastien.tauran@viveris.fr>
21  */
22 
23 #include "lora-sub-band.h"
24 
25 #include <ns3/log.h>
26 
27 #include <stdint.h>
28 
29 namespace ns3
30 {
31 
32 NS_LOG_COMPONENT_DEFINE("LoraSubBand");
33 
34 NS_OBJECT_ENSURE_REGISTERED(LoraSubBand);
35 
36 TypeId
38 {
39  static TypeId tid = TypeId("ns3::LoraSubBand").SetParent<Object>();
40  return tid;
41 }
42 
44 {
45  NS_LOG_FUNCTION(this);
46 }
47 
48 LoraSubBand::LoraSubBand(double firstFrequency,
49  double lastFrequency,
50  double dutyCycle,
51  double maxTxPowerDbm)
52  : m_firstFrequency(firstFrequency),
53  m_lastFrequency(lastFrequency),
54  m_dutyCycle(dutyCycle),
55  m_nextTransmissionTime(Seconds(0)),
56  m_maxTxPowerDbm(maxTxPowerDbm)
57 {
58  NS_LOG_FUNCTION(this << firstFrequency << lastFrequency << dutyCycle << maxTxPowerDbm);
59 }
60 
62 {
63  NS_LOG_FUNCTION(this);
64 }
65 
66 double
68 {
69  return m_firstFrequency;
70 }
71 
72 double
74 {
75  return m_dutyCycle;
76 }
77 
78 bool
80 {
81  return (frequency > m_firstFrequency) && (frequency < m_lastFrequency);
82 }
83 
84 bool
85 LoraSubBand::BelongsToLoraSubBand(Ptr<LoraLogicalChannel> logicalChannel)
86 {
87  double frequency = logicalChannel->GetFrequency();
88  return BelongsToLoraSubBand(frequency);
89 }
90 
91 void
93 {
94  m_nextTransmissionTime = nextTime;
95 }
96 
97 Time
99 {
100  return m_nextTransmissionTime;
101 }
102 
103 void
104 LoraSubBand::SetMaxTxPowerDbm(double maxTxPowerDbm)
105 {
106  m_maxTxPowerDbm = maxTxPowerDbm;
107 }
108 
109 double
111 {
112  return m_maxTxPowerDbm;
113 }
114 } // namespace ns3
double GetFirstFrequency(void)
Get the lowest frequency of the LoraSubBand.
void SetMaxTxPowerDbm(double maxTxPowerDbm)
Set the maximum transmission power that is allowed on this LoraSubBand.
double m_maxTxPowerDbm
The maximum transmission power that is admitted on this LoraSubBand.
Time GetNextTransmissionTime(void)
Returns the next time from which transmission on this LoraSubBand will be possible.
void SetNextTransmissionTime(Time nextTime)
Update the next transmission time.
double m_firstFrequency
Starting frequency of the LoraSubBand, in MHz.
virtual ~LoraSubBand()
Time m_nextTransmissionTime
The next time a transmission will be allowed in this LoraSubBand.
double m_dutyCycle
The duty cycle that needs to be enforced on this LoraSubBand.
double GetMaxTxPowerDbm(void)
Return the maximum transmission power that is allowed on this LoraSubBand.
bool BelongsToLoraSubBand(double frequency)
Return whether or not a frequency belongs to this LoraSubBand.
static TypeId GetTypeId(void)
double GetDutyCycle(void)
Get the last frequency of the LoraSubBand.
double m_lastFrequency
Ending frequency of the LoraSubBand, in MHz.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.