forked from pa-pa/AskSinPP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Peer.h
56 lines (44 loc) · 1.34 KB
/
Peer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//- -----------------------------------------------------------------------------------------------------------------------
// AskSin++
// 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
//- -----------------------------------------------------------------------------------------------------------------------
#ifndef __PEER_H__
#define __PEER_H__
#include "HMID.h"
#include "Debug.h"
namespace as {
class Peer : public HMID {
uint8_t chan;
public:
Peer() : chan(0) {}
Peer (const HMID& id,uint8_t ch) : HMID(id), chan(ch) {}
Peer (uint8_t i1, uint8_t i2, uint8_t i3, uint8_t ch) : HMID(i1,i2,i3), chan(ch) {}
Peer (uint8_t* ptr) : HMID(*ptr,*(ptr+1),*(ptr+2)), chan(*(ptr+3)) {}
Peer (uint8_t ch) : chan(ch) {}
Peer (const Peer& other) : HMID(other) {
chan = other.chan;
}
Peer& operator = (const Peer& other) {
*(HMID*)this = (const HMID&)other;
chan = other.chan;
return *this;
}
bool operator == (const Peer& other) const {
return chan==other.chan && *(HMID*)this == (HMID&)other;
}
static uint8_t size() { return sizeof(Peer); }
uint8_t channel () const {
return chan;
}
bool even () const {
return (chan & 0x01) == 0x00;
}
bool odd () const {
return (chan & 0x01) == 0x01;
}
void dump () {
DHEX((uint8_t*)this,sizeof(Peer));
}
};
}
#endif