Leosac
0.8.0
Open Source Access Control
rplethprotocol.hpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2014-2016 Leosac
3
4
This file is part of Leosac.
5
6
Leosac is free software: you can redistribute it and/or modify
7
it under the terms of the GNU Affero General Public License as published by
8
the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
10
11
Leosac is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU Affero General Public License for more details.
15
16
You should have received a copy of the GNU Affero General Public License
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
26
#ifndef RPLETHPROTOCOL_HPP
27
#define RPLETHPROTOCOL_HPP
28
29
#include "
network/circularbuffer.hpp
"
30
#include "
rplethpacket.hpp
"
31
32
#include <queue>
33
34
namespace
Leosac
35
{
36
namespace
Module
37
{
38
namespace
Rpleth
39
{
40
41
class
RplethProtocol
42
{
43
static
const
std::size_t
TypeByteIdx
= 0;
44
static
const
std::size_t
CommandByteIdx
= 1;
45
static
const
std::size_t
SizeByteIdx
= 2;
46
static
const
std::size_t
PacketMinSize
= 4;
47
48
RplethProtocol
() =
delete
;
49
50
public
:
51
enum
TypeCode
52
{
53
Rpleth
= 0x00,
54
HID
= 0x01,
55
LCD
= 0x02,
56
MaxType
57
};
58
enum
RplethCommands
59
{
60
DHCPState
= 0x01,
61
SetDHCP
= 0x02,
62
SetMAC
= 0x03,
63
SetIP
= 0x04,
64
SetSubnet
= 0x05,
65
SetGateway
= 0x06,
66
SetPort
= 0x07,
67
Message
= 0x08,
// NOTE not documented
68
Reset
= 0x09,
// This will actually trigger a restart, not a reset.
69
Ping
= 0x0a
70
};
71
72
enum
HIDCommands
73
{
74
Beep
= 0x00,
75
Greenled
= 0x01,
76
Redled
= 0x02,
77
Nop
= 0x03,
78
Badge
= 0x04,
79
Com
= 0x05,
80
Wait_insertion
= 0x06,
81
Wait_removal
= 0x07,
82
Connect
= 0x08,
83
Disconnect
= 0x09,
84
GetReaderType
= 0x0a,
85
GetCSN
= 0x0b,
86
SetCardType
= 0x0c,
87
SendCards
= 0x0d,
// text, separated by a pipe
88
ReceiveCardsWaited
= 0x0e
89
};
90
91
enum
StatusCode
92
{
93
Success
= 0x00,
94
Failed
= 0x01,
95
BadChecksum
= 0x02,
96
Timeout
= 0x03,
97
BadSize
= 0x04,
98
BadType
= 0x05,
99
MaxStatus
100
};
101
102
public
:
108
static
RplethPacket
decodeCommand
(
CircularBuffer
&buffer,
109
bool
from_server =
false
);
110
111
static
std::size_t
encodeCommand
(
const
RplethPacket
&packet,
Byte
*buffer,
112
std::size_t size);
113
};
114
}
115
}
116
}
117
#endif // RPLETHPROTOCOL_HPP
Leosac::Module::Rpleth::RplethProtocol::Ping
@ Ping
Definition:
rplethprotocol.hpp:69
Leosac::Module::Rpleth::RplethProtocol::SetIP
@ SetIP
Definition:
rplethprotocol.hpp:63
Leosac::Module::Rpleth::RplethProtocol::BadChecksum
@ BadChecksum
Definition:
rplethprotocol.hpp:95
Leosac::Module::Rpleth::RplethProtocol::SendCards
@ SendCards
Definition:
rplethprotocol.hpp:87
Leosac::Module::Rpleth::RplethProtocol::SetCardType
@ SetCardType
Definition:
rplethprotocol.hpp:86
Leosac::Module::Rpleth::RplethProtocol::Connect
@ Connect
Definition:
rplethprotocol.hpp:82
circularbuffer.hpp
simple circular buffer class
Leosac::Module::Rpleth::RplethProtocol::Nop
@ Nop
Definition:
rplethprotocol.hpp:77
Leosac::Module::Rpleth::RplethProtocol::GetReaderType
@ GetReaderType
Definition:
rplethprotocol.hpp:84
Leosac::Module::Rpleth::RplethProtocol::RplethProtocol
RplethProtocol()=delete
Leosac::Module::Rpleth::RplethProtocol::CommandByteIdx
static const std::size_t CommandByteIdx
Definition:
rplethprotocol.hpp:44
Leosac::Module::Rpleth::RplethProtocol::SetDHCP
@ SetDHCP
Definition:
rplethprotocol.hpp:61
Leosac::Module::Rpleth::RplethProtocol::Wait_removal
@ Wait_removal
Definition:
rplethprotocol.hpp:81
Leosac::Module::Rpleth::RplethProtocol::SetGateway
@ SetGateway
Definition:
rplethprotocol.hpp:65
Leosac::Module::Rpleth::RplethProtocol::decodeCommand
static RplethPacket decodeCommand(CircularBuffer &buffer, bool from_server=false)
Decode a packet from a circular buffer object.
Definition:
rplethprotocol.cpp:32
Leosac::Module::Rpleth::RplethPacket
Definition:
rplethpacket.hpp:39
Leosac::Module::Rpleth::RplethProtocol::SetPort
@ SetPort
Definition:
rplethprotocol.hpp:66
Leosac::Module::Rpleth::RplethProtocol::Disconnect
@ Disconnect
Definition:
rplethprotocol.hpp:83
Leosac::Module::Rpleth::RplethProtocol::encodeCommand
static std::size_t encodeCommand(const RplethPacket &packet, Byte *buffer, std::size_t size)
Definition:
rplethprotocol.cpp:72
Leosac::Module::Rpleth::RplethProtocol::Timeout
@ Timeout
Definition:
rplethprotocol.hpp:96
Leosac::Module::Rpleth::RplethProtocol::Success
@ Success
Definition:
rplethprotocol.hpp:93
Leosac::Module::Rpleth::RplethProtocol::Rpleth
@ Rpleth
Definition:
rplethprotocol.hpp:53
Leosac::Module::Rpleth::RplethProtocol::MaxStatus
@ MaxStatus
Definition:
rplethprotocol.hpp:99
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition:
APIStatusCode.hpp:22
Leosac::Module::Rpleth::RplethProtocol::Message
@ Message
Definition:
rplethprotocol.hpp:67
Leosac::Module::Rpleth::RplethProtocol::HIDCommands
HIDCommands
Definition:
rplethprotocol.hpp:72
Leosac::Module::Rpleth::RplethProtocol::BadSize
@ BadSize
Definition:
rplethprotocol.hpp:97
Leosac::Module::Rpleth::RplethProtocol::Wait_insertion
@ Wait_insertion
Definition:
rplethprotocol.hpp:80
Leosac::Module::Rpleth::RplethProtocol::Com
@ Com
Definition:
rplethprotocol.hpp:79
Leosac::Module::Rpleth::RplethProtocol::TypeByteIdx
static const std::size_t TypeByteIdx
Definition:
rplethprotocol.hpp:43
Leosac::Module::Rpleth::RplethProtocol::ReceiveCardsWaited
@ ReceiveCardsWaited
Definition:
rplethprotocol.hpp:88
Leosac::Module::Rpleth::RplethProtocol::LCD
@ LCD
Definition:
rplethprotocol.hpp:55
Leosac::Module::Rpleth::RplethProtocol::Redled
@ Redled
Definition:
rplethprotocol.hpp:76
Leosac::Module::Rpleth::RplethProtocol::GetCSN
@ GetCSN
Definition:
rplethprotocol.hpp:85
rplethpacket.hpp
Rpleth packet class.
Leosac::Module::Rpleth::RplethProtocol::DHCPState
@ DHCPState
Definition:
rplethprotocol.hpp:60
Leosac::Module::Rpleth::RplethProtocol::MaxType
@ MaxType
Definition:
rplethprotocol.hpp:56
Leosac::Module::Rpleth::RplethProtocol::RplethCommands
RplethCommands
Definition:
rplethprotocol.hpp:58
Leosac::Module::Rpleth::RplethProtocol::SetMAC
@ SetMAC
Definition:
rplethprotocol.hpp:62
Leosac::Module::Rpleth::RplethProtocol
Definition:
rplethprotocol.hpp:41
Leosac::Module::Rpleth::RplethProtocol::Failed
@ Failed
Definition:
rplethprotocol.hpp:94
Leosac::Module::Rpleth::RplethProtocol::Greenled
@ Greenled
Definition:
rplethprotocol.hpp:75
Leosac::Module::Rpleth::RplethProtocol::PacketMinSize
static const std::size_t PacketMinSize
Definition:
rplethprotocol.hpp:46
Leosac::Module::Rpleth::RplethProtocol::SetSubnet
@ SetSubnet
Definition:
rplethprotocol.hpp:64
Leosac::Module::Rpleth::CircularBuffer
Implementation of a ring buffer.
Definition:
circularbuffer.hpp:43
Leosac::Module::Rpleth::RplethProtocol::Reset
@ Reset
Definition:
rplethprotocol.hpp:68
Leosac::Module::Rpleth::RplethProtocol::BadType
@ BadType
Definition:
rplethprotocol.hpp:98
Leosac::Module::Rpleth::RplethProtocol::TypeCode
TypeCode
Definition:
rplethprotocol.hpp:51
Leosac::Module::Rpleth::RplethProtocol::Beep
@ Beep
Definition:
rplethprotocol.hpp:74
Byte
std::uint8_t Byte
Definition:
bufferutils.hpp:31
Leosac::Module::Rpleth::RplethProtocol::SizeByteIdx
static const std::size_t SizeByteIdx
Definition:
rplethprotocol.hpp:45
Leosac::Module::Rpleth::RplethProtocol::HID
@ HID
Definition:
rplethprotocol.hpp:54
Leosac::Module::Rpleth::RplethProtocol::Badge
@ Badge
Definition:
rplethprotocol.hpp:78
Leosac::Module::Rpleth::RplethProtocol::StatusCode
StatusCode
Definition:
rplethprotocol.hpp:91
src
modules
rpleth
rplethprotocol.hpp
Generated on Tue Mar 22 2022 10:48:26 for Leosac by
1.8.17