DESERT 4.0.0
uwphy-clmsg.h
Go to the documentation of this file.
1//
2// Copyright (c) 2015 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
38#ifndef UWPHY_CLMSG_H
39#define UWPHY_CLMSG_H
40
41#include <clmessage.h>
42#include <packet.h>
43
44#define CLMSG_UWPHY_VERBOSITY (3)
45
46#define CLMSG_UWPHY_NOT_VALID (-1)
47
48#define CLMSG_UWPHY_TIME_NOT_VALID (-1)
49
50#define CLMSG_UWPHY_STACK_ID_NOT_VALID (-1)
51
52extern ClMessage_t CLMSG_UWPHY_TX_POWER;
53extern ClMessage_t CLMSG_UWPHY_B_RATE;
54extern ClMessage_t CLMSG_UWPHY_THRESH;
55extern ClMessage_t CLMSG_UWPHY_LOSTPKT;
56extern ClMessage_t CLMSG_UWPHY_TX_BUSY;
57
63class ClMsgUwPhy : public ClMessage
64{
65public:
67
71 ClMsgUwPhy(ClMessage_t type);
72
78 ClMsgUwPhy(int stack_id, int dest_module_id, ClMessage_t type);
79
84 ClMsgUwPhy(const ClMsgUwPhy &msg);
85
89 virtual ~ClMsgUwPhy();
90
97 virtual ClMsgUwPhy *copy();
98
103 void setReqType(ReqType type);
104
110
111protected:
112 // receiver stack id (valid only for broadcast request)
113 int stack_id; /* <id of the stack */
114 ReqType req_type; /*< request type: either get, set, request or reply */
115};
116
125{
126public:
131
137 ClMsgUwPhyTxPwr(int stack_id, int dest_module_id);
138
144
148 virtual ~ClMsgUwPhyTxPwr();
149
154 double getPower();
155
160 void setPower(double powr);
161
162private:
163 double tx_power; /* < Transmission power. Its definition (W, dB, dB re uPa,
164 ...) depends on the specific phy.*/
165};
166
176{
177public:
182
188 ClMsgUwPhyBRate(int stack_id, int dest_module_id);
189
195
199 virtual ~ClMsgUwPhyBRate();
200
205 double getBRate();
206
211 void setBRate(double rate);
212
213private:
214 double b_rate; /* < Communication threshold. Can be either the baud or the
215 bit rate.*/
216};
217
226{
227public:
232
238 ClMsgUwPhyThresh(int stack_id, int dest_module_id);
239
246
250 virtual ~ClMsgUwPhyThresh();
251
256 double getThresh();
257
262 void setThresh(double thresh);
263
264private:
265 double threshold; /* < Receiving threshold. Can be either the rx_power or
266 the SNR.*/
267};
268
275{
276public:
283 ClMsgUwPhyGetLostPkts(bool control = false);
284
293 int stack_id, int dest_module_id, bool control = false);
294
301
306
311 uint getLostPkts();
312
317 void setLostPkts(uint lost_pkt);
318
319 inline bool
321 {
322 return is_control;
323 }
324
325private:
326 uint lost_packets; /* < Number of packets lost by the phy.*/
328};
329
338{
339public:
344
350 ClMsgUwPhyTxBusy(int stack_id, int dest_module_id);
351
357
362
367 int getTxBusy();
368
373 void setTxBusy(int powr);
374
379 int getGetOp();
380
385 void setGetOp(int);
386
387private:
388 int tx_busy; /* < Transmission power. Its definition (W, dB, dB re uPa, ...)
389 depends on the specific phy.*/
390 int getop; // To signal if mac just wants to read the value
391};
392
393#endif /* UWPHY_CLMSG_H */
Definition uwphy-clmsg.h:176
void setBRate(double rate)
Definition uwphy-clmsg.cc:146
double getBRate()
Definition uwphy-clmsg.cc:140
double b_rate
Definition uwphy-clmsg.h:214
virtual ~ClMsgUwPhyBRate()
Definition uwphy-clmsg.cc:135
ClMsgUwPhyBRate()
Definition uwphy-clmsg.cc:117
Definition uwphy-clmsg.h:275
void setLostPkts(uint lost_pkt)
Definition uwphy-clmsg.cc:263
bool is_control
Definition uwphy-clmsg.h:327
uint getLostPkts()
Definition uwphy-clmsg.cc:257
bool isControl()
Definition uwphy-clmsg.h:320
~ClMsgUwPhyGetLostPkts()
Definition uwphy-clmsg.cc:252
uint lost_packets
Definition uwphy-clmsg.h:326
Definition uwphy-clmsg.h:226
ClMsgUwPhyThresh()
Definition uwphy-clmsg.cc:151
void setThresh(double thresh)
Definition uwphy-clmsg.cc:180
double getThresh()
Definition uwphy-clmsg.cc:174
double threshold
Definition uwphy-clmsg.h:265
virtual ~ClMsgUwPhyThresh()
Definition uwphy-clmsg.cc:169
Definition uwphy-clmsg.h:338
void setGetOp(int)
Definition uwphy-clmsg.cc:228
int getop
Definition uwphy-clmsg.h:390
~ClMsgUwPhyTxBusy()
Definition uwphy-clmsg.cc:205
ClMsgUwPhyTxBusy()
Definition uwphy-clmsg.cc:185
void setTxBusy(int powr)
Definition uwphy-clmsg.cc:216
int getGetOp()
Definition uwphy-clmsg.cc:222
int getTxBusy()
Definition uwphy-clmsg.cc:210
int tx_busy
Definition uwphy-clmsg.h:388
Definition uwphy-clmsg.h:125
void setPower(double powr)
Definition uwphy-clmsg.cc:112
double getPower()
Definition uwphy-clmsg.cc:106
virtual ~ClMsgUwPhyTxPwr()
Definition uwphy-clmsg.cc:101
ClMsgUwPhyTxPwr()
Definition uwphy-clmsg.cc:83
double tx_power
Definition uwphy-clmsg.h:163
Definition uwphy-clmsg.h:64
ReqType req_type
Definition uwphy-clmsg.h:114
virtual ClMsgUwPhy * copy()
Definition uwphy-clmsg.cc:66
void setReqType(ReqType type)
Definition uwphy-clmsg.cc:72
virtual ~ClMsgUwPhy()
Definition uwphy-clmsg.cc:61
ReqType getReqType()
Definition uwphy-clmsg.cc:78
int stack_id
Definition uwphy-clmsg.h:113
ReqType
Definition uwphy-clmsg.h:66
@ SET_REQ
Definition uwphy-clmsg.h:66
@ GET_REPLY
Definition uwphy-clmsg.h:66
@ SET_REPLY
Definition uwphy-clmsg.h:66
@ GET_REQ
Definition uwphy-clmsg.h:66
@ NOT_VALID
Definition uwphy-clmsg.h:66
ClMessage_t CLMSG_UWPHY_B_RATE
Definition initlib.cpp:41
ClMessage_t CLMSG_UWPHY_TX_BUSY
Definition initlib.cc:47
ClMessage_t CLMSG_UWPHY_TX_POWER
Definition initlib.cc:40
ClMessage_t CLMSG_UWPHY_LOSTPKT
Definition initlib.cc:43
ClMessage_t CLMSG_UWPHY_THRESH
Definition initlib.cpp:42