blob: c03388c20de50d3881dc94fe0e81733d79ce8589 (
plain)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/****************************************************************************************************
RepRapFirmware - Webserver
This class serves a single-page web applications to the attached network. This page forms the user's
interface with the RepRap machine. This software interprests returned values from the page and uses it
to Generate G Codes, which it sends to the RepRap. It also collects values from the RepRap like
temperature and uses those to construct the web page.
The page itself - reprap.htm - uses Knockout.js and Jquery.js. See:
http://knockoutjs.com/
http://jquery.com/
-----------------------------------------------------------------------------------------------------
Version 0.2
10 May 2013
Adrian Bowyer
RepRap Professional Ltd
http://reprappro.com
Licence: GPL
****************************************************************************************************/
#ifndef WEBSERVER_H
#define WEBSERVER_H
#include <cstdint>
#include <cstddef>
// List of protocols that can execute G-Codes
enum class WebSource
{
HTTP,
Telnet
};
const uint16_t gcodeBufferLength = 512; // size of our gcode ring buffer, preferably a power of 2
const uint16_t webMessageLength = 2000; // maximum length of the web message we accept after decoding
const size_t maxQualKeys = 5; // max number of key/value pairs in the qualifier
const size_t maxHttpSessions = 8; // maximum number of simultaneous HTTP sessions
const uint32_t httpSessionTimeout = 20000; // HTTP session timeout in milliseconds
class Platform;
class Network;
class Webserver
{
public:
friend class Platform;
Webserver(Platform* p, Network *n);
void Init();
void Spin();
void Exit();
void Diagnostics(MessageType mtype);
bool GCodeAvailable(const WebSource source) const;
char ReadGCode(const WebSource source);
void HandleGCodeReply(const WebSource source, OutputBuffer *reply);
void HandleGCodeReply(const WebSource source, const char *reply);
uint32_t GetReplySeq() const { return seq; }
// Returns the available G-Code buffer space of the HTTP interpreter (may be dropped in a future version)
uint16_t GetGCodeBufferSpace(const WebSource source) const { return 0; }
private:
uint32_t seq;
};
#endif
|