lora-device-address.h
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 #ifndef LORA_DEVICE_ADDRESS_H
24 #define LORA_DEVICE_ADDRESS_H
25 
26 #include <ns3/address.h>
27 
28 #include <string>
29 
30 namespace ns3
31 {
32 
36 class NwkID
37 {
38  public:
39  NwkID(uint8_t nwkId = 0);
40 
50  void Set(uint8_t nwkId);
51 
57  uint8_t Get(void) const;
58 
59  private:
60  uint8_t m_nwkId;
61 };
62 
67 class NwkAddr
68 {
69  public:
70  NwkAddr(uint32_t nwkId = 0);
71 
81  void Set(uint32_t nwkAddr);
82 
88  uint32_t Get(void) const;
89 
90  private:
91  uint32_t m_nwkAddr;
92 };
93 
98 {
99  public:
101 
105  LoraDeviceAddress(uint32_t address);
106 
110  LoraDeviceAddress(uint8_t nwkId, uint32_t nwkAddr);
111 
115  LoraDeviceAddress(NwkID nwkId, NwkAddr nwkAddr);
116 
120  void Serialize(uint8_t buf[4]) const;
121 
125  static LoraDeviceAddress Deserialize(const uint8_t buf[4]);
126 
130  static LoraDeviceAddress ConvertFrom(const Address& address);
131 
135  void Set(uint32_t address);
136 
145  void Set(uint8_t nwkId, uint32_t nwkAddr);
146 
150  uint32_t Get(void) const;
151 
160  uint8_t GetNwkID(void);
161 
170  void SetNwkID(uint8_t nwkId);
171 
180  uint32_t GetNwkAddr(void);
181 
190  void SetNwkAddr(uint32_t nwkAddr);
191 
197  std::string Print(void) const;
198 
199  bool operator==(const LoraDeviceAddress& other) const;
200  bool operator!=(const LoraDeviceAddress& other) const;
201  bool operator<(const LoraDeviceAddress& other) const;
202  bool operator>(const LoraDeviceAddress& other) const;
203 
204  private:
208  Address ConvertTo(void) const;
209  static uint8_t GetType(void);
212 };
213 
218 std::ostream& operator<<(std::ostream& os, const LoraDeviceAddress& address);
219 
220 } // namespace ns3
221 
222 #endif
This class represents the device address of a LoraWAN End Device.
NwkID m_nwkId
The network Id of this address.
static LoraDeviceAddress Deserialize(const uint8_t buf[4])
Convert the input buffer into a new address.
Address ConvertTo(void) const
Convert this instance of LoraDeviceAddress to an Address.
bool operator>(const LoraDeviceAddress &other) const
static LoraDeviceAddress ConvertFrom(const Address &address)
Convert from an ordinary address to a LoraDeviceAddress instance.
void Set(uint32_t address)
Set the address as a 32 bit integer.
uint32_t GetNwkAddr(void)
Get the NwkAddr of this device.
void Serialize(uint8_t buf[4]) const
Convert this address to a buffer.
bool operator!=(const LoraDeviceAddress &other) const
bool operator==(const LoraDeviceAddress &other) const
void SetNwkID(uint8_t nwkId)
Set the NwkID of this device.
uint32_t Get(void) const
Get the address in 32-bit integer form.
uint8_t GetNwkID(void)
Get the NwkID of this device.
static uint8_t GetType(void)
void SetNwkAddr(uint32_t nwkAddr)
Set the NwkAddr of this device.
void Set(uint8_t nwkId, uint32_t nwkAddr)
Set the address, combining a network id and a network address.
std::string Print(void) const
Print the address bit-by-bit to a human-readable string.
NwkAddr m_nwkAddr
The network address of this address.
bool operator<(const LoraDeviceAddress &other) const
Class representing the Network Address component of a LoraDeviceAddress (25 bits)
NwkAddr(uint32_t nwkId=0)
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.
uint32_t m_nwkAddr
8-bit integer representation of the network id
Class representing the NetworkId component of a LoraDeviceAddress (7 bits).
uint8_t m_nwkId
8-bit integer representation of the network id
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.
NwkID(uint8_t nwkId=0)
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
std::ostream & operator<<(std::ostream &os, const GeoCoordinate &coordinate)