lora-logical-channel.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-logical-channel.h"
24 
25 #include <ns3/log.h>
26 
27 namespace ns3
28 {
29 
30 NS_LOG_COMPONENT_DEFINE("LoraLogicalChannel");
31 
32 NS_OBJECT_ENSURE_REGISTERED(LoraLogicalChannel);
33 
34 TypeId
36 {
37  static TypeId tid = TypeId("ns3::LoraLogicalChannel").SetParent<Object>();
38  return tid;
39 }
40 
42  : m_frequency(0),
43  m_minDataRate(0),
44  m_maxDataRate(5),
45  m_enabledForUplink(true)
46 {
47  NS_LOG_FUNCTION(this);
48 }
49 
51 {
52  NS_LOG_FUNCTION(this);
53 }
54 
56  : m_frequency(frequency),
57  m_enabledForUplink(true)
58 {
59  NS_LOG_FUNCTION(this);
60 }
61 
62 LoraLogicalChannel::LoraLogicalChannel(double frequency, uint8_t minDataRate, uint8_t maxDataRate)
63  : m_frequency(frequency),
64  m_minDataRate(minDataRate),
65  m_maxDataRate(maxDataRate),
66  m_enabledForUplink(true)
67 {
68  NS_LOG_FUNCTION(this);
69 }
70 
71 double
73 {
74  return m_frequency;
75 }
76 
77 void
79 {
80  m_minDataRate = minDataRate;
81 }
82 
83 void
85 {
86  m_maxDataRate = maxDataRate;
87 }
88 
89 uint8_t
91 {
92  return m_minDataRate;
93 }
94 
95 uint8_t
97 {
98  return m_maxDataRate;
99 }
100 
101 void
103 {
104  m_enabledForUplink = true;
105 }
106 
107 void
109 {
110  m_enabledForUplink = false;
111 }
112 
113 bool
115 {
116  return m_enabledForUplink;
117 }
118 
119 bool
120 operator==(const Ptr<LoraLogicalChannel>& first, const Ptr<LoraLogicalChannel>& second)
121 {
122  double thisFreq = first->GetFrequency();
123  double otherFreq = second->GetFrequency();
124 
125  NS_LOG_DEBUG("Checking equality between logical lora channels: " << thisFreq << " "
126  << otherFreq);
127 
128  NS_LOG_DEBUG("Result:" << (thisFreq == otherFreq));
129  return (thisFreq == otherFreq);
130 }
131 
132 bool
133 operator!=(const Ptr<LoraLogicalChannel>& first, const Ptr<LoraLogicalChannel>& second)
134 {
135  return !(first == second);
136 }
137 } // namespace ns3
bool m_enabledForUplink
Whether this channel can be used for uplink or not.
uint8_t GetMaximumDataRate(void)
Get the maximum Data Rate that is allowed on this channel.
static TypeId GetTypeId(void)
bool IsEnabledForUplink(void)
Test whether this channel is marked as enabled for uplink.
void SetEnabledForUplink(void)
Set this channel as enabled for uplink.
void SetMinimumDataRate(uint8_t minDataRate)
Set the frequency (MHz).
uint8_t GetMinimumDataRate(void)
Get the minimum Data Rate that is allowed on this channel.
uint8_t m_maxDataRate
The maximum Data Rate that is allowed on this channel.
double GetFrequency(void) const
Get the frequency (MHz).
void DisableForUplink(void)
Set this channel as disabled for uplink.
double m_frequency
The central frequency of this channel, in MHz.
uint8_t m_minDataRate
The minimum Data Rate that is allowed on this channel.
void SetMaximumDataRate(uint8_t maxDataRate)
Set the maximum Data Rate that is allowed on this channel.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
bool operator==(const Ptr< LoraLogicalChannel > &first, const Ptr< LoraLogicalChannel > &second)
Overload of the == operator to compare different instances of the same LoraLogicalChannel.
bool operator!=(const Ptr< LoraLogicalChannel > &first, const Ptr< LoraLogicalChannel > &second)
Overload the != operator to compare different instances of the same LoraLogicalChannel.