Welcome to mirror list, hosted at ThFree Co, Russian Federation.

TelnetResponder.h « Networking « src - github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 87f12d10b2e1f90c1d5542a59e9cd1f43f85232f (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
/*
 * TelnetResponder.h
 *
 *  Created on: 14 Apr 2017
 *      Author: David
 */

#ifndef SRC_NETWORKING_TELNETRESPONDER_H_
#define SRC_NETWORKING_TELNETRESPONDER_H_

#include "NetworkResponder.h"

class TelnetResponder : public NetworkResponder
{
public:
	TelnetResponder(NetworkResponder *n) noexcept;
	bool Spin() noexcept override;								// do some work, returning true if we did anything significant
	bool Accept(Socket *s, NetworkProtocol protocol) noexcept override;	// ask the responder to accept this connection, returns true if it did
	void Terminate(NetworkProtocol protocol, NetworkInterface *interface) noexcept override;	// terminate the responder if it is serving the specified protocol on the specified interface

	static void InitStatic() noexcept;
	static void Disable() noexcept;
	static void HandleGCodeReply(const char *reply) noexcept;
	static void HandleGCodeReply(OutputBuffer *reply) noexcept;
	void Diagnostics(MessageType mtype) const noexcept override;

private:
	void CharFromClient(char c) noexcept;
	void ProcessLine() noexcept;
	void ConnectionLost() noexcept override;

	bool SendGCodeReply() noexcept;

	bool haveCompleteLine;
	char clientMessage[GCODE_LENGTH];
	size_t clientPointer;
	uint32_t connectTime;

	static unsigned int numSessions;
	static unsigned int clientsServed;
	static OutputBuffer *gcodeReply;
	static Mutex gcodeReplyMutex;

	static const uint32_t TelnetSetupDuration = 4000;	// ignore the first Telnet request within this duration (in ms)
};

#endif /* SRC_NETWORKING_TELNETRESPONDER_H_ */