RF24Ethernet - TCP/IP over RF24Network
v1.6.17
TMRh20 - Pushing the practical limits of RF24 modules
Main Page
Related Pages
Topics
Classes
Files
Examples
File List
File Members
Loading...
Searching...
No Matches
RF24Server.cpp
Go to the documentation of this file.
1
/*
2
RF24Server.cpp - Arduino implementation of a uIP wrapper class.
3
Copyright (c) 2014 tmrh20@gmail.com, github.com/TMRh20
4
Copyright (c) 2013 Norbert Truchsess <norbert.truchsess@t-online.de>
5
All rights reserved.
6
7
This program is free software: you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation, either version 3 of the License, or
10
(at your option) any later version.
11
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
16
17
You should have received a copy of the GNU General Public License
18
along with this program. If not, see <http://www.gnu.org/licenses/>.
19
*/
20
#include "
RF24Ethernet.h
"
21
#include "
RF24Server.h
"
22
23
extern
"C"
{
24
//#include "uip-conf.h"
25
}
26
27
/*************************************************************/
28
29
RF24Server::RF24Server
(uint16_t port) : _port(htons(port))
30
{
31
}
32
33
/*************************************************************/
34
35
RF24Client
RF24Server::available
()
36
{
37
Ethernet
.tick();
38
for
(uip_userdata_t* data = &
RF24Client::all_data
[0]; data < &
RF24Client::all_data
[UIP_CONNS]; data++)
39
{
40
if
(data->packets_in != 0 && (((data->state &
UIP_CLIENT_CONNECTED
) && uip_conns[data->state &
UIP_CLIENT_SOCKETS
].lport == _port) || ((data->state &
UIP_CLIENT_REMOTECLOSED
) && ((uip_userdata_closed_t*)data)->lport == _port)))
41
{
42
return
RF24Client
(data);
43
}
44
}
45
return
RF24Client
();
46
}
47
48
/*************************************************************/
49
50
void
RF24Server::begin
()
51
{
52
uip_listen(_port);
53
RF24Ethernet
.tick();
54
}
55
56
/*************************************************************/
57
#if defined(ESP32)
58
void
RF24Server::begin
(uint16_t port)
59
{
60
_port = port;
61
begin
();
62
}
63
#endif
64
65
/*************************************************************/
66
67
size_t
RF24Server::write
(uint8_t c)
68
{
69
return
write
(&c, 1);
70
}
71
72
/*************************************************************/
73
74
size_t
RF24Server::write
(
const
uint8_t* buf,
size_t
size)
75
{
76
size_t
ret = 0;
77
for
(uip_userdata_t* data = &
RF24Client::all_data
[0]; data < &
RF24Client::all_data
[UIP_CONNS]; data++)
78
{
79
if
((data->state &
UIP_CLIENT_CONNECTED
) && uip_conns[data->state &
UIP_CLIENT_SOCKETS
].lport == _port)
80
ret += RF24Client::_write(data, buf, size);
81
}
82
return
ret;
83
}
84
85
/*************************************************************/
86
87
void
RF24Server::setTimeout
(uint32_t timeout)
88
{
89
#if UIP_CONNECTION_TIMEOUT > 0
90
for
(uint8_t i = 0; i < UIP_CONNS; i++) {
91
uip_userdata_t* data = &
RF24Client::all_data
[i];
92
if
(data) {
93
data->connectTimeout = timeout;
94
}
95
}
96
#endif
97
}
UIP_CLIENT_SOCKETS
#define UIP_CLIENT_SOCKETS
Definition
RF24Client.h:36
UIP_CLIENT_REMOTECLOSED
#define UIP_CLIENT_REMOTECLOSED
Definition
RF24Client.h:33
UIP_CLIENT_CONNECTED
#define UIP_CLIENT_CONNECTED
Definition
RF24Client.h:31
RF24Ethernet.h
RF24Ethernet
RF24EthernetClass RF24Ethernet
RF24Server.h
RF24Client
Definition
RF24Client.h:76
RF24Client::all_data
static uip_userdata_t all_data[UIP_CONNS]
Definition
RF24Client.h:162
RF24Server::write
size_t write(uint8_t)
Definition
RF24Server.cpp:67
RF24Server::begin
void begin()
Definition
RF24Server.cpp:50
RF24Server::RF24Server
RF24Server(uint16_t)
Definition
RF24Server.cpp:29
RF24Server::available
RF24Client available()
Definition
RF24Server.cpp:35
RF24Server::setTimeout
void setTimeout(uint32_t timeout)
Definition
RF24Server.cpp:87
Ethernet
#define Ethernet
Definition
ethernet_comp.h:4
Generated on Sun Oct 6 2024 for RF24Ethernet - TCP/IP over RF24Network by
1.11.0