Loading...
Searching...
No Matches
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 <ostream>
29#include <stdint.h>
30#include <string>
31
32namespace ns3
33{
34
38class NwkID
39{
40 public:
41 NwkID(uint8_t nwkId = 0);
42
52 void Set(uint8_t nwkId);
53
59 uint8_t Get(void) const;
60
61 private:
62 uint8_t m_nwkId;
63};
64
70{
71 public:
72 NwkAddr(uint32_t nwkId = 0);
73
83 void Set(uint32_t nwkAddr);
84
90 uint32_t Get(void) const;
91
92 private:
93 uint32_t m_nwkAddr;
94};
95
100{
101 public:
103
107 LoraDeviceAddress(uint32_t address);
108
112 LoraDeviceAddress(uint8_t nwkId, uint32_t nwkAddr);
113
117 LoraDeviceAddress(NwkID nwkId, NwkAddr nwkAddr);
118
122 void Serialize(uint8_t buf[4]) const;
123
127 static LoraDeviceAddress Deserialize(const uint8_t buf[4]);
128
132 static LoraDeviceAddress ConvertFrom(const Address& address);
133
137 void Set(uint32_t address);
138
147 void Set(uint8_t nwkId, uint32_t nwkAddr);
148
152 uint32_t Get(void) const;
153
162 uint8_t GetNwkID(void);
163
172 void SetNwkID(uint8_t nwkId);
173
182 uint32_t GetNwkAddr(void);
183
192 void SetNwkAddr(uint32_t nwkAddr);
193
199 std::string Print(void) const;
200
201 bool operator==(const LoraDeviceAddress& other) const;
202 bool operator!=(const LoraDeviceAddress& other) const;
203 bool operator<(const LoraDeviceAddress& other) const;
204 bool operator>(const LoraDeviceAddress& other) const;
205
206 private:
210 Address ConvertTo(void) const;
211 static uint8_t GetType(void);
214};
215
220std::ostream& operator<<(std::ostream& os, const LoraDeviceAddress& address);
221
222} // namespace ns3
223
224#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)