-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsioTelnetJob.cpp
62 lines (57 loc) · 1.36 KB
/
sioTelnetJob.cpp
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
/*
Created by tan (trinity09181718@gmail.com)
Copyright (c) 2022 tan
All rights reserved.
* Please contact trinity09181718@gmail.com if you need a commercial license.
* This software is available under GPL v3.
*/
#include "Esp32PC8001SIO.h"
extern WiFiClient telnetClient;
extern int telnetSeqNo;
extern SIOCMD sioSendCmd;
extern int sioSendBufPos;
extern int sioSendBufByte;
extern char sioSendBuf[128+16];
void sioTelnetMain( void )
{
switch ( telnetSeqNo )
{
case 0:
// idle
break;
case 10:
if ( sioSendCmd != cmdNon )
break;
if ( !telnetClient.connected() )
{
sprintf( sioSendBuf,"\r\nConnection closed by foreign host.\r\n%c%c", ESC, 0xFF );
sioSendBufPos = 0;
sioSendBufByte = strlen( sioSendBuf );
telnetSeqNo = 20;
break;
}
while ( true )
{
if ( !telnetClient.available() )
break;
uint8_t recvData = telnetClient.read();
Serial2.write( recvData );
}
break;
case 20:
while ( true )
{
if ( sioSendBufPos >= sioSendBufByte )
{
telnetSeqNo = 0;
break;
}
uint8_t sendData = sioSendBuf[sioSendBufPos];
Serial2.write( sendData );
sioSendBufPos++;
}
break;
default:
break;
}
}