A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
lora-device-address-generator.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2017 University of Padova
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Davide Magrin <magrinda@dei.unipd.it>
18
*/
19
20
#include "
lora-device-address-generator.h
"
21
22
#include "ns3/log.h"
23
24
namespace
ns3
25
{
26
namespace
lorawan
27
{
28
29
NS_LOG_COMPONENT_DEFINE
(
"LoraDeviceAddressGenerator"
);
30
31
TypeId
32
LoraDeviceAddressGenerator::GetTypeId
()
33
{
34
static
TypeId
tid =
TypeId
(
"ns3::LoraDeviceAddressGenerator"
)
35
.
SetParent
<
Object
>()
36
.SetGroupName(
"lorawan"
)
37
.AddConstructor<
LoraDeviceAddressGenerator
>();
38
return
tid;
39
}
40
41
LoraDeviceAddressGenerator::LoraDeviceAddressGenerator
(
const
uint8_t nwkId,
const
uint32_t
nwkAddr)
42
{
43
NS_LOG_FUNCTION
(
this
<<
unsigned
(nwkId) << nwkAddr);
44
45
m_currentNwkId
.
Set
(nwkId);
46
m_currentNwkAddr
.
Set
(nwkAddr);
47
}
48
49
LoraDeviceAddress
50
LoraDeviceAddressGenerator::NextNetwork
()
51
{
52
NS_LOG_FUNCTION_NOARGS
();
53
54
m_currentNwkId
.
Set
(
m_currentNwkId
.
Get
() + 1);
55
m_currentNwkAddr
.
Set
(0);
56
57
return
LoraDeviceAddress
(
m_currentNwkId
,
m_currentNwkAddr
);
58
}
59
60
LoraDeviceAddress
61
LoraDeviceAddressGenerator::NextAddress
()
62
{
63
NS_LOG_FUNCTION_NOARGS
();
64
65
NwkAddr
oldNwkAddr =
m_currentNwkAddr
;
66
m_currentNwkAddr
.
Set
(
m_currentNwkAddr
.
Get
() + 1);
67
68
return
LoraDeviceAddress
(
m_currentNwkId
, oldNwkAddr);
69
}
70
71
LoraDeviceAddress
72
LoraDeviceAddressGenerator::GetNextAddress
()
73
{
74
NS_LOG_FUNCTION_NOARGS
();
75
76
return
LoraDeviceAddress
(
m_currentNwkId
.
Get
(),
m_currentNwkAddr
.
Get
() + 1);
77
}
78
}
// namespace lorawan
79
}
// namespace ns3
ns3::Object
A base class which provides memory management and object aggregation.
Definition:
object.h:89
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:932
ns3::lorawan::LoraDeviceAddressGenerator
This class generates sequential LoraDeviceAddress instances.
Definition:
lora-device-address-generator.h:38
ns3::lorawan::LoraDeviceAddressGenerator::NextAddress
LoraDeviceAddress NextAddress()
Allocate the next LoraDeviceAddress.
Definition:
lora-device-address-generator.cc:61
ns3::lorawan::LoraDeviceAddressGenerator::m_currentNwkAddr
NwkAddr m_currentNwkAddr
The current Network Address value.
Definition:
lora-device-address-generator.h:92
ns3::lorawan::LoraDeviceAddressGenerator::m_currentNwkId
NwkID m_currentNwkId
The current Network Id value.
Definition:
lora-device-address-generator.h:91
ns3::lorawan::LoraDeviceAddressGenerator::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition:
lora-device-address-generator.cc:32
ns3::lorawan::LoraDeviceAddressGenerator::GetNextAddress
LoraDeviceAddress GetNextAddress()
Get the LoraDeviceAddress that will be allocated upon a call to NextAddress.
Definition:
lora-device-address-generator.cc:72
ns3::lorawan::LoraDeviceAddressGenerator::NextNetwork
LoraDeviceAddress NextNetwork()
Get the first address from the next network.
Definition:
lora-device-address-generator.cc:50
ns3::lorawan::LoraDeviceAddressGenerator::LoraDeviceAddressGenerator
LoraDeviceAddressGenerator(const uint8_t nwkId=0, const uint32_t nwkAddr=0)
Initialise the base NwkID and the first NwkAddr to be used by the generator.
Definition:
lora-device-address-generator.cc:41
ns3::lorawan::LoraDeviceAddress
This class represents the device address of a LoraWAN end device.
Definition:
lora-device-address.h:117
ns3::lorawan::NwkAddr
Class representing the Network Address component of a LoraDeviceAddress (25 bits)
Definition:
lora-device-address.h:78
ns3::lorawan::NwkAddr::Set
void Set(uint32_t nwkAddr)
Set the NwkAddr, starting from a 32-bit representation of a 25-bit integer.
Definition:
lora-device-address.cc:68
ns3::lorawan::NwkAddr::Get
uint32_t Get() const
Get an uint32_t representation of the 25-bit network address.
Definition:
lora-device-address.cc:80
ns3::lorawan::NwkID::Get
uint8_t Get() const
Get an uint8_t representation of the 7-bit network ID.
Definition:
lora-device-address.cc:54
ns3::lorawan::NwkID::Set
void Set(uint8_t nwkId)
Set the NwkID, starting from a 8-bit representation of a 7-bit integer.
Definition:
lora-device-address.cc:42
uint32_t
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition:
log-macros-enabled.h:206
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition:
log-macros-enabled.h:240
lora-device-address-generator.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
lorawan
model
lora-device-address-generator.cc
Generated on Mon Aug 12 2024 11:16:15 for ns-3 by
1.9.6