-
Notifications
You must be signed in to change notification settings - Fork 31
/
cslim.pde
54 lines (42 loc) · 978 Bytes
/
cslim.pde
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
#include <SPI.h>
#include <Client.h>
#include <Ethernet.h>
#include <Server.h>
#include <Udp.h>
#include "TcpComLink.h"
extern "C" {
#include "Slim.h"
}
Slim * slim;
Server server(22);
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,1, 177 };
byte gateway[] = { 192,168,1, 1 };
byte subnet[] = { 255, 255, 255, 0 };
void setup()
{
slim = Slim_Create();
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
Serial.begin(9600);
Serial.write("Slim running\n");
}
void loop_ethernet()
{
Client client = server.available();
if (client) {
Serial.write("New Connection\n");
TcpComLink * comLink = TcpComLink_Create(&client);
Slim_HandleConnection(slim, (void*)comLink, &TcpComLink_send, &TcpComLink_recv);
TcpComLink_Destroy(comLink);
}
}
#include "SerialComLink.h"
void loop_serial()
{
Slim_HandleConnection(slim, (void*)0, &SerialComLink_send, &SerialComLink_recv);
}
void loop()
{
loop_ethernet();
}