-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathSSHServer.ino
48 lines (39 loc) · 1.12 KB
/
SSHServer.ino
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
/* arduino SSH server - 1 listening session */
#include "SPI.h"
#include "Phpoc.h"
PhpocServer server(22);
boolean alreadyConnected = false; // whether or not the client was connected previously
void setup() {
Serial.begin(9600);
while(!Serial)
;
Phpoc.begin(PF_LOG_SPI | PF_LOG_NET);
//Phpoc.begin();
server.beginSSH("root", "1234");
//server.beginSSH("", "");
//server.beginSSH();
Serial.print("SSH server address : ");
Serial.println(Phpoc.localIP());
}
void loop() {
// wait for a new client:
PhpocClient client = server.available();
// when the client sends the first byte, say hello:
if (client) {
if (!alreadyConnected) {
// clear out the transmission buffer:
client.flush();
Serial.println("We have a new client");
client.println("Hello, client!");
alreadyConnected = true;
}
if (client.available() > 0) {
// read the bytes incoming from the client:
char thisChar = client.read();
// echo the bytes back to the client:
server.write(thisChar);
// echo the bytes to the server as well:
Serial.write(thisChar);
}
}
}