DESERT 4.0.0
uwranging_tdoa_hdr.h
Go to the documentation of this file.
1//
2// Copyright (c) 2022 Regents of the SIGNET lab, University of Padova.
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions
7// are met:
8// 1. Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// 2. Redistributions in binary form must reproduce the above copyright
11// notice, this list of conditions and the following disclaimer in the
12// documentation and/or other materials provided with the distribution.
13// 3. Neither the name of the University of Padova (SIGNET lab) nor the
14// names of its contributors may be used to endorse or promote products
15// derived from this software without specific prior written permission.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28//
29
40#ifndef UWRANGING_TDOA_HDR_H
41#define UWRANGING_TDOA_HDR_H
42
43#include <cmath>
44#include <packet.h>
45#include <sys/types.h>
46
47#define MAX_NUM_NODES 32
48#define HDR_RANGING_TDOA(p) \
49 (hdr_ranging_tdoa::access( \
50 p))
52extern packet_t PT_UWRANGING_TDOA;
53
54typedef float
56typedef uint8_t uwrange_pkt_t;
57typedef uint8_t uwrange_node_t;
79
83typedef struct hdr_ranging_tdoa {
84 static int offset_;
88 tdoa_entry times_[MAX_NUM_NODES];
90 inline uint8_t &
92 {
93 return times_size_;
94 }
95
100 size_t
101 getSize() const
102 {
103 return std::ceil(times_size_ * sizeof(tdoa_entry) +
104 sizeof(uwrange_node_t) + sizeof(uwrange_pkt_t));
105 }
106
112 static size_t
113 getSize(int entries)
114 {
115 return std::ceil(entries * sizeof(tdoa_entry) + sizeof(uwrange_node_t) +
116 sizeof(uwrange_pkt_t));
117 }
118
123 inline static int &
125 {
126 return offset_;
127 }
128
134 inline static struct hdr_ranging_tdoa *
135 access(const Packet *p)
136 {
137 return (struct hdr_ranging_tdoa *) p->access(offset_);
138 }
140
141#endif
Definition uwranging_tdoa_hdr.h:83
static int offset_
Definition uwranging_tdoa_hdr.h:84
static size_t getSize(int entries)
Definition uwranging_tdoa_hdr.h:113
static struct hdr_ranging_tdoa * access(const Packet *p)
Definition uwranging_tdoa_hdr.h:135
size_t getSize() const
Definition uwranging_tdoa_hdr.h:101
uwrange_node_t times_size_
Definition uwranging_tdoa_hdr.h:87
uint8_t & times_size()
Definition uwranging_tdoa_hdr.h:91
static int & offset()
Definition uwranging_tdoa_hdr.h:124
uwrange_pkt_t source_pkt_id
Definition uwranging_tdoa_hdr.h:85
uwrange_node_t source_node_id
Definition uwranging_tdoa_hdr.h:86
tdoa_entry times_[MAX_NUM_NODES]
Definition uwranging_tdoa_hdr.h:88
Definition uwranging_tdoa_hdr.h:62
tdoa_entry(uwrange_time_t time, uwrange_node_t node, uwrange_pkt_t id)
Definition uwranging_tdoa_hdr.h:67
uwrange_pkt_t id
Definition uwranging_tdoa_hdr.h:64
uwrange_time_t time
Definition uwranging_tdoa_hdr.h:63
uwrange_node_t node
Definition uwranging_tdoa_hdr.h:65
tdoa_entry()
Definition uwranging_tdoa_hdr.h:74
packet_t PT_UWRANGING_TDOA
Definition initlib.cpp:42
uint8_t uwrange_pkt_t
Definition uwranging_tdoa_hdr.h:56
float uwrange_time_t
Definition uwranging_tdoa_hdr.h:55
uint8_t uwrange_node_t
Definition uwranging_tdoa_hdr.h:57