lora-device-address-generator.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 
24 
25 #include <ns3/log.h>
26 
27 namespace ns3
28 {
29 
30 NS_LOG_COMPONENT_DEFINE("LoraDeviceAddressGenerator");
31 
32 TypeId
34 {
35  static TypeId tid = TypeId("ns3::LoraDeviceAddressGenerator")
36  .SetParent<Object>()
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 
51 {
52  NS_LOG_FUNCTION_NOARGS();
53 
56 
58 }
59 
62 {
63  NS_LOG_FUNCTION_NOARGS();
64 
65  NwkAddr oldNwkAddr = m_currentNwkAddr;
67 
68  return LoraDeviceAddress(m_currentNwkId, oldNwkAddr);
69 }
70 
73 {
74  NS_LOG_FUNCTION_NOARGS();
75 
77 }
78 } // namespace ns3
NwkID m_currentNwkId
The current Network Id value.
LoraDeviceAddress GetNextAddress(void)
Get the LoraDeviceAddress that will be allocated upon a call to NextAddress.
NwkAddr m_currentNwkAddr
The current Network Address value.
LoraDeviceAddress NextNetwork(void)
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.
LoraDeviceAddress NextAddress(void)
Allocate the next LoraDeviceAddress.
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(void) const
Get an uint32_t representation of the 25-bit network address.
uint8_t Get(void) 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.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.