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
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Davide Magrin <magrinda@dei.unipd.it>
7
*/
8
9
#include "
lora-device-address-generator.h
"
10
11
#include "ns3/log.h"
12
13
namespace
ns3
14
{
15
namespace
lorawan
16
{
17
18
NS_LOG_COMPONENT_DEFINE
(
"LoraDeviceAddressGenerator"
);
19
20
TypeId
21
LoraDeviceAddressGenerator::GetTypeId
()
22
{
23
static
TypeId
tid =
TypeId
(
"ns3::LoraDeviceAddressGenerator"
)
24
.
SetParent
<
Object
>()
25
.SetGroupName(
"lorawan"
)
26
.AddConstructor<
LoraDeviceAddressGenerator
>();
27
return
tid;
28
}
29
30
LoraDeviceAddressGenerator::LoraDeviceAddressGenerator
(
const
uint8_t nwkId,
const
uint32_t
nwkAddr)
31
{
32
NS_LOG_FUNCTION
(
this
<<
unsigned
(nwkId) << nwkAddr);
33
34
m_currentNwkId
.
Set
(nwkId);
35
m_currentNwkAddr
.
Set
(nwkAddr);
36
}
37
38
LoraDeviceAddress
39
LoraDeviceAddressGenerator::NextNetwork
()
40
{
41
NS_LOG_FUNCTION_NOARGS
();
42
43
m_currentNwkId
.
Set
(
m_currentNwkId
.
Get
() + 1);
44
m_currentNwkAddr
.
Set
(0);
45
46
return
LoraDeviceAddress
(
m_currentNwkId
,
m_currentNwkAddr
);
47
}
48
49
LoraDeviceAddress
50
LoraDeviceAddressGenerator::NextAddress
()
51
{
52
NS_LOG_FUNCTION_NOARGS
();
53
54
NwkAddr
oldNwkAddr =
m_currentNwkAddr
;
55
m_currentNwkAddr
.
Set
(
m_currentNwkAddr
.
Get
() + 1);
56
57
return
LoraDeviceAddress
(
m_currentNwkId
, oldNwkAddr);
58
}
59
60
LoraDeviceAddress
61
LoraDeviceAddressGenerator::GetNextAddress
()
62
{
63
NS_LOG_FUNCTION_NOARGS
();
64
65
return
LoraDeviceAddress
(
m_currentNwkId
.
Get
(),
m_currentNwkAddr
.
Get
() + 1);
66
}
67
}
// namespace lorawan
68
}
// namespace ns3
ns3::Object
A base class which provides memory management and object aggregation.
Definition
object.h:78
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
ns3::lorawan::LoraDeviceAddressGenerator
This class generates sequential LoraDeviceAddress instances.
Definition
lora-device-address-generator.h:27
ns3::lorawan::LoraDeviceAddressGenerator::NextAddress
LoraDeviceAddress NextAddress()
Allocate the next LoraDeviceAddress.
Definition
lora-device-address-generator.cc:50
ns3::lorawan::LoraDeviceAddressGenerator::m_currentNwkAddr
NwkAddr m_currentNwkAddr
The current Network Address value.
Definition
lora-device-address-generator.h:81
ns3::lorawan::LoraDeviceAddressGenerator::m_currentNwkId
NwkID m_currentNwkId
The current Network Id value.
Definition
lora-device-address-generator.h:80
ns3::lorawan::LoraDeviceAddressGenerator::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition
lora-device-address-generator.cc:21
ns3::lorawan::LoraDeviceAddressGenerator::GetNextAddress
LoraDeviceAddress GetNextAddress()
Get the LoraDeviceAddress that will be allocated upon a call to NextAddress.
Definition
lora-device-address-generator.cc:61
ns3::lorawan::LoraDeviceAddressGenerator::NextNetwork
LoraDeviceAddress NextNetwork()
Get the first address from the next network.
Definition
lora-device-address-generator.cc:39
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:30
ns3::lorawan::LoraDeviceAddress
This class represents the device address of a LoraWAN end device.
Definition
lora-device-address.h:106
ns3::lorawan::NwkAddr
Class representing the Network Address component of a LoraDeviceAddress (25 bits)
Definition
lora-device-address.h:67
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:57
ns3::lorawan::NwkAddr::Get
uint32_t Get() const
Get an uint32_t representation of the 25-bit network address.
Definition
lora-device-address.cc:69
ns3::lorawan::NwkID::Get
uint8_t Get() const
Get an uint8_t representation of the 7-bit network ID.
Definition
lora-device-address.cc:43
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:31
uint32_t
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition
log-macros-enabled.h:195
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:229
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 Fri Nov 8 2024 13:59:02 for ns-3 by
1.11.0