A Discrete-Event Network Simulator
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
21
22#include "ns3/log.h"
23
24namespace ns3
25{
26namespace lorawan
27{
28
29NS_LOG_COMPONENT_DEFINE("LoraDeviceAddressGenerator");
30
31TypeId
33{
34 static TypeId tid = TypeId("ns3::LoraDeviceAddressGenerator")
36 .SetGroupName("lorawan")
37 .AddConstructor<LoraDeviceAddressGenerator>();
38 return tid;
39}
40
42{
43 NS_LOG_FUNCTION(this << unsigned(nwkId) << nwkAddr);
44
45 m_currentNwkId.Set(nwkId);
46 m_currentNwkAddr.Set(nwkAddr);
47}
48
51{
53
56
58}
59
62{
64
65 NwkAddr oldNwkAddr = m_currentNwkAddr;
67
68 return LoraDeviceAddress(m_currentNwkId, oldNwkAddr);
69}
70
73{
75
77}
78} // namespace lorawan
79} // namespace ns3
A base class which provides memory management and object aggregation.
Definition: object.h:89
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
This class generates sequential LoraDeviceAddress instances.
LoraDeviceAddress NextAddress()
Allocate the next LoraDeviceAddress.
NwkAddr m_currentNwkAddr
The current Network Address value.
NwkID m_currentNwkId
The current Network Id value.
LoraDeviceAddress GetNextAddress()
Get the LoraDeviceAddress that will be allocated upon a call to NextAddress.
LoraDeviceAddress NextNetwork()
Get the first address from the next network.
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.
This class represents the device address of a LoraWAN end device.
Class representing the Network Address component of a LoraDeviceAddress (25 bits)
void Set(uint32_t nwkAddr)
Set the NwkAddr, starting from a 32-bit representation of a 25-bit integer.
uint32_t Get() const
Get an uint32_t representation of the 25-bit network address.
uint8_t Get() const
Get an uint8_t representation of the 7-bit network ID.
void Set(uint8_t nwkId)
Set the NwkID, starting from a 8-bit representation of a 7-bit integer.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#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 ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.